[FFmpeg-cvslog] truespeech: Convert to the new bitstream reader

Alexandra Hájková git at videolan.org
Tue Apr 4 21:52:33 EEST 2017


ffmpeg | branch: master | Alexandra Hájková <alexandra at khirnov.net> | Thu Apr 14 10:32:31 2016 +0200| [8e4cadea5d20e463e9d6cf00fc58841f17c811e0] | committer: Diego Biurrun

truespeech: Convert to the new bitstream reader

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8e4cadea5d20e463e9d6cf00fc58841f17c811e0
---

 libavcodec/truespeech.c | 88 +++++++++++++++++++++++++------------------------
 1 file changed, 45 insertions(+), 43 deletions(-)

diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
index b2195ba..48e2126 100644
--- a/libavcodec/truespeech.c
+++ b/libavcodec/truespeech.c
@@ -21,12 +21,14 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
+
 #include "avcodec.h"
+#include "bitstream.h"
 #include "bswapdsp.h"
-#include "get_bits.h"
 #include "internal.h"
 
 #include "truespeech_data.h"
+
 /**
  * @file
  * TrueSpeech decoder.
@@ -77,50 +79,50 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx)
 
 static void truespeech_read_frame(TSContext *dec, const uint8_t *input)
 {
-    GetBitContext gb;
+    BitstreamContext bc;
 
     dec->bdsp.bswap_buf((uint32_t *) dec->buffer, (const uint32_t *) input, 8);
-    init_get_bits(&gb, dec->buffer, 32 * 8);
-
-    dec->vector[7] = ts_codebook[7][get_bits(&gb, 3)];
-    dec->vector[6] = ts_codebook[6][get_bits(&gb, 3)];
-    dec->vector[5] = ts_codebook[5][get_bits(&gb, 3)];
-    dec->vector[4] = ts_codebook[4][get_bits(&gb, 4)];
-    dec->vector[3] = ts_codebook[3][get_bits(&gb, 4)];
-    dec->vector[2] = ts_codebook[2][get_bits(&gb, 4)];
-    dec->vector[1] = ts_codebook[1][get_bits(&gb, 5)];
-    dec->vector[0] = ts_codebook[0][get_bits(&gb, 5)];
-    dec->flag      = get_bits1(&gb);
-
-    dec->offset1[0] = get_bits(&gb, 4) << 4;
-    dec->offset2[3] = get_bits(&gb, 7);
-    dec->offset2[2] = get_bits(&gb, 7);
-    dec->offset2[1] = get_bits(&gb, 7);
-    dec->offset2[0] = get_bits(&gb, 7);
-
-    dec->offset1[1]  = get_bits(&gb, 4);
-    dec->pulseval[1] = get_bits(&gb, 14);
-    dec->pulseval[0] = get_bits(&gb, 14);
-
-    dec->offset1[1] |= get_bits(&gb, 4) << 4;
-    dec->pulseval[3] = get_bits(&gb, 14);
-    dec->pulseval[2] = get_bits(&gb, 14);
-
-    dec->offset1[0] |= get_bits1(&gb);
-    dec->pulsepos[0] = get_bits_long(&gb, 27);
-    dec->pulseoff[0] = get_bits(&gb, 4);
-
-    dec->offset1[0] |= get_bits1(&gb) << 1;
-    dec->pulsepos[1] = get_bits_long(&gb, 27);
-    dec->pulseoff[1] = get_bits(&gb, 4);
-
-    dec->offset1[0] |= get_bits1(&gb) << 2;
-    dec->pulsepos[2] = get_bits_long(&gb, 27);
-    dec->pulseoff[2] = get_bits(&gb, 4);
-
-    dec->offset1[0] |= get_bits1(&gb) << 3;
-    dec->pulsepos[3] = get_bits_long(&gb, 27);
-    dec->pulseoff[3] = get_bits(&gb, 4);
+    bitstream_init(&bc, dec->buffer, 32 * 8);
+
+    dec->vector[7] = ts_codebook[7][bitstream_read(&bc, 3)];
+    dec->vector[6] = ts_codebook[6][bitstream_read(&bc, 3)];
+    dec->vector[5] = ts_codebook[5][bitstream_read(&bc, 3)];
+    dec->vector[4] = ts_codebook[4][bitstream_read(&bc, 4)];
+    dec->vector[3] = ts_codebook[3][bitstream_read(&bc, 4)];
+    dec->vector[2] = ts_codebook[2][bitstream_read(&bc, 4)];
+    dec->vector[1] = ts_codebook[1][bitstream_read(&bc, 5)];
+    dec->vector[0] = ts_codebook[0][bitstream_read(&bc, 5)];
+    dec->flag      = bitstream_read_bit(&bc);
+
+    dec->offset1[0] = bitstream_read(&bc, 4) << 4;
+    dec->offset2[3] = bitstream_read(&bc, 7);
+    dec->offset2[2] = bitstream_read(&bc, 7);
+    dec->offset2[1] = bitstream_read(&bc, 7);
+    dec->offset2[0] = bitstream_read(&bc, 7);
+
+    dec->offset1[1]  = bitstream_read(&bc, 4);
+    dec->pulseval[1] = bitstream_read(&bc, 14);
+    dec->pulseval[0] = bitstream_read(&bc, 14);
+
+    dec->offset1[1] |= bitstream_read(&bc, 4) << 4;
+    dec->pulseval[3] = bitstream_read(&bc, 14);
+    dec->pulseval[2] = bitstream_read(&bc, 14);
+
+    dec->offset1[0] |= bitstream_read_bit(&bc);
+    dec->pulsepos[0] = bitstream_read(&bc, 27);
+    dec->pulseoff[0] = bitstream_read(&bc, 4);
+
+    dec->offset1[0] |= bitstream_read_bit(&bc) << 1;
+    dec->pulsepos[1] = bitstream_read(&bc, 27);
+    dec->pulseoff[1] = bitstream_read(&bc, 4);
+
+    dec->offset1[0] |= bitstream_read_bit(&bc) << 2;
+    dec->pulsepos[2] = bitstream_read(&bc, 27);
+    dec->pulseoff[2] = bitstream_read(&bc, 4);
+
+    dec->offset1[0] |= bitstream_read_bit(&bc) << 3;
+    dec->pulsepos[3] = bitstream_read(&bc, 27);
+    dec->pulseoff[3] = bitstream_read(&bc, 4);
 }
 
 static void truespeech_correlate_filter(TSContext *dec)



More information about the ffmpeg-cvslog mailing list