Browse code

aacsbr: don't call sbr_dequant twice without intermediate read_sbr_data

Doing that doesn't make sense, because the only purpose of sbr_dequant
is to process the data from read_sbr_data.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit 1c3e43a6273822e1369818b80f34c8464e1009d5)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>

Andreas Cadhalpun authored on 2015/11/21 04:15:21
Showing 2 changed files
... ...
@@ -70,6 +70,7 @@ av_cold void AAC_RENAME(ff_aac_sbr_init)(void)
70 70
 /** Places SBR in pure upsampling mode. */
71 71
 static void sbr_turnoff(SpectralBandReplication *sbr) {
72 72
     sbr->start = 0;
73
+    sbr->ready_for_dequant = 0;
73 74
     // Init defults used in pure upsampling mode
74 75
     sbr->kx[1] = 32; //Typo in spec, kx' inits to 32
75 76
     sbr->m[1] = 0;
... ...
@@ -177,6 +178,7 @@ static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext
177 177
     SpectrumParameters old_spectrum_params;
178 178
 
179 179
     sbr->start = 1;
180
+    sbr->ready_for_dequant = 0;
180 181
 
181 182
     // Save last spectrum parameters variables to compare to new ones
182 183
     memcpy(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters));
... ...
@@ -1032,6 +1034,7 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr,
1032 1032
     unsigned int cnt = get_bits_count(gb);
1033 1033
 
1034 1034
     sbr->id_aac = id_aac;
1035
+    sbr->ready_for_dequant = 1;
1035 1036
 
1036 1037
     if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) {
1037 1038
         if (read_sbr_single_channel_element(ac, sbr, gb)) {
... ...
@@ -1449,6 +1452,12 @@ void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int
1449 1449
         sbr_turnoff(sbr);
1450 1450
     }
1451 1451
 
1452
+    if (sbr->start && !sbr->ready_for_dequant) {
1453
+        av_log(ac->avctx, AV_LOG_ERROR,
1454
+               "No quantized data read for sbr_dequant.\n");
1455
+        sbr_turnoff(sbr);
1456
+    }
1457
+
1452 1458
     if (!sbr->kx_and_m_pushed) {
1453 1459
         sbr->kx[0] = sbr->kx[1];
1454 1460
         sbr->m[0] = sbr->m[1];
... ...
@@ -1458,6 +1467,7 @@ void AAC_RENAME(ff_sbr_apply)(AACContext *ac, SpectralBandReplication *sbr, int
1458 1458
 
1459 1459
     if (sbr->start) {
1460 1460
         sbr_dequant(sbr, id_aac);
1461
+        sbr->ready_for_dequant = 0;
1461 1462
     }
1462 1463
     for (ch = 0; ch < nch; ch++) {
1463 1464
         /* decode channel */
... ...
@@ -137,6 +137,7 @@ typedef struct AACSBRContext {
137 137
 struct SpectralBandReplication {
138 138
     int                sample_rate;
139 139
     int                start;
140
+    int                ready_for_dequant;
140 141
     int                id_aac;
141 142
     int                reset;
142 143
     SpectrumParameters spectrum_params;