[FFmpeg-cvslog] theora: support midstream reconfiguration

Michael Niedermayer git at videolan.org
Sun Jan 20 18:00:53 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Jan 16 20:02:37 2013 +0100| [bc15fcb8cfa87ef91e2b00ab5951c5b6dc78e72b] | committer: Michael Niedermayer

theora: support midstream reconfiguration

Fixes Ticket868

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 Changelog        |    1 +
 libavcodec/vp3.c |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/Changelog b/Changelog
index b4ae074..7934f26 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version <next>:
 - SRTP support
 - Error diffusion dither in Swscale
 - Chained Ogg support
+- Theora Midstream reconfiguration support
 
 
 version 1.1:
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 98e8e72..c768eb9 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -75,6 +75,10 @@ typedef struct Vp3Fragment {
 /* special internal mode */
 #define MODE_COPY             8
 
+static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb);
+static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb);
+
+
 /* There are 6 preset schemes, plus a free-form scheme */
 static const int ModeAlphabet[6][CODING_MODE_COUNT] =
 {
@@ -292,6 +296,8 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx)
     av_freep(&s->motion_val[1]);
     av_freep(&s->edge_emu_buffer);
 
+    s->theora_tables = 0;
+
     if (avctx->internal->is_copy)
         return 0;
 
@@ -1912,16 +1918,46 @@ static int vp3_decode_frame(AVCodecContext *avctx,
     Vp3DecodeContext *s = avctx->priv_data;
     GetBitContext gb;
     int i;
+    int ret;
 
     init_get_bits(&gb, buf, buf_size * 8);
 
     if (s->theora && get_bits1(&gb))
     {
+        int type = get_bits(&gb, 7);
+        skip_bits_long(&gb, 6*8); /* "theora" */
+
+        if (type == 0) {
+            if (s->avctx->active_thread_type&FF_THREAD_FRAME) {
+                av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
+                return AVERROR_PATCHWELCOME;
+            }
+            vp3_decode_end(avctx);
+            ret = theora_decode_header(avctx, &gb);
+
+            if (ret < 0) {
+                vp3_decode_end(avctx);
+            } else
+                ret = vp3_decode_init(avctx);
+            return ret;
+        } else if (type == 2) {
+            ret = theora_decode_tables(avctx, &gb);
+            if (ret < 0) {
+                vp3_decode_end(avctx);
+            } else
+                ret = vp3_decode_init(avctx);
+            return ret;
+        }
+
         av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n");
         return -1;
     }
 
     s->keyframe = !get_bits1(&gb);
+    if (!s->all_fragments) {
+        av_log(avctx, AV_LOG_ERROR, "Data packet without prior valid headers\n");
+        return -1;
+    }
     if (!s->theora)
         skip_bits(&gb, 1);
     for (i = 0; i < 3; i++)



More information about the ffmpeg-cvslog mailing list