[FFmpeg-cvslog] amrnb/amrwb: Remove get_bits usage.

Alex Converse git at videolan.org
Tue Mar 6 06:16:03 CET 2012


ffmpeg | branch: master | Alex Converse <alex.converse at gmail.com> | Sun Mar  4 17:24:38 2012 -0800| [b70feb405386cda5ea7a7d2a9921a7f2f17976a4] | committer: Alex Converse

amrnb/amrwb: Remove get_bits usage.

It is used to parse fixed sized fields out of a single octet. The code
is simpler without it.

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

 libavcodec/amrnbdec.c |   10 ++--------
 libavcodec/amrwbdec.c |   10 ++--------
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
index a7d0b4e..0eeda6d 100644
--- a/libavcodec/amrnbdec.c
+++ b/libavcodec/amrnbdec.c
@@ -44,7 +44,6 @@
 #include <math.h>
 
 #include "avcodec.h"
-#include "get_bits.h"
 #include "libavutil/common.h"
 #include "celp_math.h"
 #include "celp_filters.h"
@@ -189,16 +188,11 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx)
 static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf,
                                   int buf_size)
 {
-    GetBitContext gb;
     enum Mode mode;
 
-    init_get_bits(&gb, buf, buf_size * 8);
-
     // Decode the first octet.
-    skip_bits(&gb, 1);                        // padding bit
-    mode = get_bits(&gb, 4);                  // frame type
-    p->bad_frame_indicator = !get_bits1(&gb); // quality bit
-    skip_bits(&gb, 2);                        // two padding bits
+    mode = buf[0] >> 3 & 0x0F;                      // frame type
+    p->bad_frame_indicator = (buf[0] & 0x4) != 0x4; // quality bit
 
     if (mode >= N_MODES || buf_size < frame_sizes_nb[mode] + 1) {
         return NO_DATA;
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index b9ae9ec..8bbc31c 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -27,7 +27,6 @@
 #include "libavutil/lfg.h"
 
 #include "avcodec.h"
-#include "get_bits.h"
 #include "lsp.h"
 #include "celp_math.h"
 #include "celp_filters.h"
@@ -120,14 +119,9 @@ static av_cold int amrwb_decode_init(AVCodecContext *avctx)
  */
 static int decode_mime_header(AMRWBContext *ctx, const uint8_t *buf)
 {
-    GetBitContext gb;
-    init_get_bits(&gb, buf, 8);
-
     /* Decode frame header (1st octet) */
-    skip_bits(&gb, 1);  // padding bit
-    ctx->fr_cur_mode  = get_bits(&gb, 4);
-    ctx->fr_quality   = get_bits1(&gb);
-    skip_bits(&gb, 2);  // padding bits
+    ctx->fr_cur_mode  = buf[0] >> 3 & 0x0F;
+    ctx->fr_quality   = (buf[0] & 0x4) != 0x4;
 
     return 1;
 }



More information about the ffmpeg-cvslog mailing list