Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 11 Nov 2013 21:21:38 +0000 (22:21 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 11 Nov 2013 21:21:38 +0000 (22:21 +0100)
* qatar/master:
  mpegaudioenc: Move some static tables to MpegAudioContext

Conflicts:
libavcodec/mpegaudioenc.c
libavcodec/mpegaudiotab.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/mpegaudioenc.c
libavcodec/mpegaudiotab.h

@@@ -64,6 -61,11 +64,16 @@@ typedef struct MpegAudioContext 
      unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT];
      int sblimit; /* number of used subbands */
      const unsigned char *alloc_table;
+     int16_t filter_bank[512];
+     int scale_factor_table[64];
+     unsigned char scale_diff_table[128];
++#ifdef USE_FLOATS
+     float scale_factor_inv_table[64];
++#else
++    int8_t scale_factor_shift[64];
++    unsigned short scale_factor_mult[64];
++#endif
+     unsigned short total_quant_bits[17]; /* total number of bits per allocation group */
  } MpegAudioContext;
  
  static av_cold int MPA_encode_init(AVCodecContext *avctx)
      }
  
      for(i=0;i<64;i++) {
 -        v = (int)(pow(2.0, (3 - i) / 3.0) * (1 << 20));
 +        v = (int)(exp2((3 - i) / 3.0) * (1 << 20));
          if (v <= 0)
              v = 1;
-         scale_factor_table[i] = v;
+         s->scale_factor_table[i] = v;
 -        s->scale_factor_inv_table[i] = pow(2.0, -(3 - i) / 3.0) / (float)(1 << 20);
 +#ifdef USE_FLOATS
-         scale_factor_inv_table[i] = exp2(-(3 - i) / 3.0) / (float)(1 << 20);
++        s->scale_factor_inv_table[i] = exp2(-(3 - i) / 3.0) / (float)(1 << 20);
 +#else
 +#define P 15
-         scale_factor_shift[i] = 21 - P - (i / 3);
-         scale_factor_mult[i] = (1 << P) * exp2((i % 3) / 3.0);
++        s->scale_factor_shift[i] = 21 - P - (i / 3);
++        s->scale_factor_mult[i] = (1 << P) * exp2((i % 3) / 3.0);
 +#endif
      }
      for(i=0;i<128;i++) {
          v = i - 64;
@@@ -398,9 -395,9 +409,9 @@@ static void compute_scale_factors(MpegA
              }
  
              av_dlog(NULL, "%2d:%d in=%x %x %d\n",
-                     j, i, vmax, scale_factor_table[index], index);
+                     j, i, vmax, s->scale_factor_table[index], index);
              /* store the scale factor */
 -            assert(index >=0 && index <= 63);
 +            av_assert2(index >=0 && index <= 63);
              sf[i] = index;
          }
  
@@@ -671,33 -668,14 +682,33 @@@ static void encode_frame(MpegAudioConte
                          qindex = s->alloc_table[j+b];
                          steps = ff_mpa_quant_steps[qindex];
                          for(m=0;m<3;m++) {
 -                            float a;
                              sample = s->sb_samples[ch][k][l + m][i];
                              /* divide by scale factor */
 -                            a = (float)sample * s->scale_factor_inv_table[s->scale_factors[ch][i][k]];
 -                            q[m] = (int)((a + 1.0) * steps * 0.5);
 +#ifdef USE_FLOATS
 +                            {
 +                                float a;
-                                 a = (float)sample * scale_factor_inv_table[s->scale_factors[ch][i][k]];
++                                a = (float)sample * s->scale_factor_inv_table[s->scale_factors[ch][i][k]];
 +                                q[m] = (int)((a + 1.0) * steps * 0.5);
 +                            }
 +#else
 +                            {
 +                                int q1, e, shift, mult;
 +                                e = s->scale_factors[ch][i][k];
-                                 shift = scale_factor_shift[e];
-                                 mult = scale_factor_mult[e];
++                                shift = s->scale_factor_shift[e];
++                                mult = s->scale_factor_mult[e];
 +
 +                                /* normalize to P bits */
 +                                if (shift < 0)
 +                                    q1 = sample << (-shift);
 +                                else
 +                                    q1 = sample >> shift;
 +                                q1 = (q1 * mult) >> P;
 +                                q[m] = ((q1 + (1 << P)) * steps) >> (P + 1);
 +                            }
 +#endif
                              if (q[m] >= steps)
                                  q[m] = steps - 1;
 -                            assert(q[m] >= 0 && q[m] < steps);
 +                            av_assert2(q[m] >= 0 && q[m] < steps);
                          }
                          bits = ff_mpa_quant_bits[qindex];
                          if (bits < 0) {
Simple merge