]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wma.c
vc1dsp: K&R formatting cosmetics
[ffmpeg] / libavcodec / wma.c
index f9ba9c385598876ede751be8dc4afe05133ca2f0..f5ea64a9ffcb99634d3ff8fb106f38a5eb3897a6 100644 (file)
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/attributes.h"
 #include "avcodec.h"
 #include "sinewin.h"
 #include "wma.h"
@@ -30,9 +31,9 @@
 
 /* XXX: use same run/length optimization as mpeg decoders */
 //FIXME maybe split decode / encode or pass flag
-static void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
-                          float **plevel_table, uint16_t **pint_table,
-                          const CoefVLCTable *vlc_table)
+static av_cold void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
+                                  float **plevel_table, uint16_t **pint_table,
+                                  const CoefVLCTable *vlc_table)
 {
     int n = vlc_table->n;
     const uint8_t  *table_bits   = vlc_table->huffbits;
@@ -68,7 +69,7 @@ static void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
     av_free(level_table);
 }
 
-int ff_wma_init(AVCodecContext *avctx, int flags2)
+av_cold int ff_wma_init(AVCodecContext *avctx, int flags2)
 {
     WMACodecContext *s = avctx->priv_data;
     int i;
@@ -82,12 +83,6 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
         || avctx->bit_rate    <= 0)
         return -1;
 
-    s->sample_rate = avctx->sample_rate;
-    s->nb_channels = avctx->channels;
-    s->bit_rate    = avctx->bit_rate;
-    s->block_align = avctx->block_align;
-
-    ff_dsputil_init(&s->dsp, avctx);
     ff_fmt_convert_init(&s->fmt_conv, avctx);
     avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
 
@@ -98,7 +93,8 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
     }
 
     /* compute MDCT block size */
-    s->frame_len_bits = ff_wma_get_frame_len_bits(s->sample_rate, s->version, 0);
+    s->frame_len_bits = ff_wma_get_frame_len_bits(avctx->sample_rate,
+                                                  s->version, 0);
     s->next_block_len_bits = s->frame_len_bits;
     s->prev_block_len_bits = s->frame_len_bits;
     s->block_len_bits      = s->frame_len_bits;
@@ -107,7 +103,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
     if (s->use_variable_block_len) {
         int nb_max, nb;
         nb = ((flags2 >> 3) & 3) + 1;
-        if ((s->bit_rate / s->nb_channels) >= 32000)
+        if ((avctx->bit_rate / avctx->channels) >= 32000)
             nb += 2;
         nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
         if (nb > nb_max)
@@ -119,10 +115,10 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
 
     /* init rate dependent parameters */
     s->use_noise_coding = 1;
-    high_freq = s->sample_rate * 0.5;
+    high_freq = avctx->sample_rate * 0.5;
 
     /* if version 2, then the rates are normalized */
-    sample_rate1 = s->sample_rate;
+    sample_rate1 = avctx->sample_rate;
     if (s->version == 2) {
         if (sample_rate1 >= 44100) {
             sample_rate1 = 44100;
@@ -137,13 +133,13 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
         }
     }
 
-    bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
+    bps = (float)avctx->bit_rate / (float)(avctx->channels * avctx->sample_rate);
     s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2;
 
     /* compute high frequency value and choose if noise coding should
        be activated */
     bps1 = bps;
-    if (s->nb_channels == 2)
+    if (avctx->channels == 2)
         bps1 = bps * 1.6;
     if (sample_rate1 == 44100) {
         if (bps1 >= 0.61) {
@@ -186,8 +182,8 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
     }
     av_dlog(s->avctx, "flags2=0x%x\n", flags2);
     av_dlog(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
-            s->version, s->nb_channels, s->sample_rate, s->bit_rate,
-            s->block_align);
+            s->version, avctx->channels, avctx->sample_rate, avctx->bit_rate,
+            avctx->block_align);
     av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
             bps, bps1, high_freq, s->byte_offset_bits);
     av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
@@ -210,7 +206,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
                 lpos = 0;
                 for (i = 0; i < 25; i++) {
                     a = ff_wma_critical_freqs[i];
-                    b = s->sample_rate;
+                    b = avctx->sample_rate;
                     pos = ((block_len * 2 * a) + (b >> 1)) / b;
                     if (pos > block_len)
                         pos = block_len;
@@ -227,11 +223,11 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
                 table = NULL;
                 a = s->frame_len_bits - BLOCK_MIN_BITS - k;
                 if (a < 3) {
-                    if (s->sample_rate >= 44100) {
+                    if (avctx->sample_rate >= 44100) {
                         table = exponent_band_44100[a];
-                    } else if (s->sample_rate >= 32000) {
+                    } else if (avctx->sample_rate >= 32000) {
                         table = exponent_band_32000[a];
-                    } else if (s->sample_rate >= 22050) {
+                    } else if (avctx->sample_rate >= 22050) {
                         table = exponent_band_22050[a];
                     }
                 }
@@ -245,7 +241,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
                     lpos = 0;
                     for (i = 0; i < 25; i++) {
                         a = ff_wma_critical_freqs[i];
-                        b = s->sample_rate;
+                        b = avctx->sample_rate;
                         pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
                         pos <<= 2;
                         if (pos > block_len)
@@ -264,7 +260,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
             s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
             /* high freq computation */
             s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
-                                          s->sample_rate + 0.5);
+                                          avctx->sample_rate + 0.5);
             n = s->exponent_sizes[k];
             j = 0;
             pos = 0;
@@ -308,7 +304,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
     }
 #endif
 
-    /* init MDCT windows : simple sinus window */
+    /* init MDCT windows : simple sine window */
     for (i = 0; i < s->nb_block_sizes; i++) {
         ff_init_ff_sine_windows(s->frame_len_bits - i);
         s->windows[i] = ff_sine_windows[s->frame_len_bits - i];
@@ -344,7 +340,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
 
     /* choose the VLC tables for the coefficients */
     coef_vlc_table = 2;
-    if (s->sample_rate >= 32000) {
+    if (avctx->sample_rate >= 32000) {
         if (bps1 < 0.72) {
             coef_vlc_table = 0;
         } else if (bps1 < 1.16) {