]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/nellymoserdec.c
xsubdec: Convert to the new bitstream reader
[ffmpeg] / libavcodec / nellymoserdec.c
index d78916b1c97363e2e97c3f4bd4ee2f606b5ef11f..390872c89aef4153bc33147f534e7a9fc7172bbf 100644 (file)
 #include "libavutil/float_dsp.h"
 #include "libavutil/lfg.h"
 #include "libavutil/random_seed.h"
+
+#define BITSTREAM_READER_LE
 #include "avcodec.h"
+#include "bitstream.h"
 #include "fft.h"
-#include "fmtconvert.h"
 #include "internal.h"
 #include "nellymoser.h"
 #include "sinewin.h"
 
-#define BITSTREAM_READER_LE
-#include "get_bits.h"
-
 
 typedef struct NellyMoserDecodeContext {
     AVCodecContext* avctx;
     AVLFG           random_state;
-    GetBitContext   gb;
+    BitstreamContext bc;
     float           scale_bias;
     AVFloatDSPContext fdsp;
     FFTContext      imdct_ctx;
@@ -68,14 +67,14 @@ static void nelly_decode_block(NellyMoserDecodeContext *s,
     int bits[NELLY_BUF_LEN];
     unsigned char v;
 
-    init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8);
+    bitstream_init(&s->bc, block, NELLY_BLOCK_LEN * 8);
 
     bptr = buf;
     pptr = pows;
-    val = ff_nelly_init_table[get_bits(&s->gb, 6)];
+    val = ff_nelly_init_table[bitstream_read(&s->bc, 6)];
     for (i=0 ; i<NELLY_BANDS ; i++) {
         if (i > 0)
-            val += ff_nelly_delta_table[get_bits(&s->gb, 5)];
+            val += ff_nelly_delta_table[bitstream_read(&s->bc, 5)];
         pval = -pow(2, val/2048) * s->scale_bias;
         for (j = 0; j < ff_nelly_band_sizes_table[i]; j++) {
             *bptr++ = val;
@@ -89,8 +88,8 @@ static void nelly_decode_block(NellyMoserDecodeContext *s,
     for (i = 0; i < 2; i++) {
         aptr = audio + i * NELLY_BUF_LEN;
 
-        init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8);
-        skip_bits_long(&s->gb, NELLY_HEADER_BITS + i*NELLY_DETAIL_BITS);
+        bitstream_init(&s->bc, block, NELLY_BLOCK_LEN * 8);
+        bitstream_skip(&s->bc, NELLY_HEADER_BITS + i * NELLY_DETAIL_BITS);
 
         for (j = 0; j < NELLY_FILL_LEN; j++) {
             if (bits[j] <= 0) {
@@ -98,7 +97,7 @@ static void nelly_decode_block(NellyMoserDecodeContext *s,
                 if (av_lfg_get(&s->random_state) & 1)
                     aptr[j] *= -1.0;
             } else {
-                v = get_bits(&s->gb, bits[j]);
+                v = bitstream_read(&s->bc, bits[j]);
                 aptr[j] = ff_nelly_dequantization_table[(1<<bits[j])-1+v]*pows[j];
             }
         }
@@ -122,7 +121,7 @@ static av_cold int decode_init(AVCodecContext * avctx) {
     av_lfg_init(&s->random_state, 0);
     ff_mdct_init(&s->imdct_ctx, 8, 1, 1.0);
 
-    avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
+    avpriv_float_dsp_init(&s->fdsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
 
     s->scale_bias = 1.0/(32768*8);
     avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
@@ -166,7 +165,7 @@ static int decode_tag(AVCodecContext *avctx, void *data,
 
     /* get output buffer */
     frame->nb_samples = NELLY_SAMPLES * blocks;
-    if ((ret = ff_get_buffer(avctx, frame)) < 0) {
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;
     }
@@ -193,14 +192,14 @@ static av_cold int decode_end(AVCodecContext * avctx) {
 
 AVCodec ff_nellymoser_decoder = {
     .name           = "nellymoser",
+    .long_name      = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
     .type           = AVMEDIA_TYPE_AUDIO,
     .id             = AV_CODEC_ID_NELLYMOSER,
     .priv_data_size = sizeof(NellyMoserDecodeContext),
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_tag,
-    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE,
-    .long_name      = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
+    .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_PARAM_CHANGE,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
                                                       AV_SAMPLE_FMT_NONE },
 };