[FFmpeg-devel] [PATCH] Remove parser from g726 decoder.

Michael Niedermayer michaelni
Mon Jun 16 23:08:31 CEST 2008


Hi

Patch below removes the truncated bitstream handling from our g726 decoder.
The stuff belongs in a parser.
Iam planning to commit that in a few days unless roman objects, the only
file i have that doesnt just crash the decoder is unaffected by the
change.

Index: libavcodec/g726.c
===================================================================
--- libavcodec/g726.c	(revision 13782)
+++ libavcodec/g726.c	(working copy)
@@ -314,8 +314,6 @@
 
 typedef struct AVG726Context {
     G726Context c;
-    int bits_left;
-    int bit_buffer;
     int code_size;
 } AVG726Context;
 
@@ -335,8 +333,6 @@
     }
     g726_reset(&c->c, avctx->bit_rate);
     c->code_size = c->c.tbls->bits;
-    c->bit_buffer = 0;
-    c->bits_left = 0;
 
     avctx->coded_frame = avcodec_alloc_frame();
     if (!avctx->coded_frame)
@@ -377,23 +373,14 @@
 {
     AVG726Context *c = avctx->priv_data;
     short *samples = data;
-    uint8_t code;
-    uint8_t mask;
     GetBitContext gb;
 
-    mask = (1<<c->code_size) - 1;
     init_get_bits(&gb, buf, buf_size * 8);
-    if (c->bits_left) {
-        int s = c->code_size - c->bits_left;
-        code = (c->bit_buffer << s) | get_bits(&gb, s);
-        *samples++ = g726_decode(&c->c, code & mask);
-    }
-
     while (get_bits_count(&gb) + c->code_size <= buf_size*8)
         *samples++ = g726_decode(&c->c, get_bits(&gb, c->code_size));
 
-    c->bits_left = buf_size*8 - get_bits_count(&gb);
-    c->bit_buffer = get_bits(&gb, c->bits_left);
+    if(buf_size*8 != get_bits_count(&gb))
+        av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n");
 
     *data_size = (uint8_t*)samples - (uint8_t*)data;
     return buf_size;


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080616/aef8d244/attachment.pgp>



More information about the ffmpeg-devel mailing list