theora: Skip zero-sized headers

Message ID 1358431911-661-1-git-send-email-martin@martin.st
State Committed
Commit e33db35b4a91ad543d9dde3a981a89118ba68937
Headers show

Commit Message

Martin Storsjö Jan. 17, 2013, 2:11 p.m.
This fixes a regression since d9cf5f51 with theora over RTP
(possibly with other variants of theora as well).

In theora over RTP, the second of the 3 headers turns out to be
0 bytes long, which prior to d9cf5f51 worked just fine. After
d9cf5f51, reading from the bitstream reader fails (since the reader
wasn't initialized but returned an error if initialized with 0 bits).

CC: libav-stable@libav.org

---
The return value of the bitstream reader initialization should
perhaps also be checked, but there's not much point in trying
to initialize it and trying to read something, if we know that the
header is 0 bytes long.
---
 libavcodec/vp3.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Luca Barbato Jan. 17, 2013, 2:36 p.m. | #1
On 17/01/13 15:11, Martin Storsjö wrote:
> This fixes a regression since d9cf5f51 with theora over RTP
> (possibly with other variants of theora as well).
> 
> In theora over RTP, the second of the 3 headers turns out to be
> 0 bytes long, which prior to d9cf5f51 worked just fine. After
> d9cf5f51, reading from the bitstream reader fails (since the reader
> wasn't initialized but returned an error if initialized with 0 bits).
> 
> CC: libav-stable@libav.org
> 

Ok, please push also to release/9

lu

Patch

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index bdd4289..0340c22 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2339,6 +2339,8 @@  static av_cold int theora_decode_init(AVCodecContext *avctx)
     }
 
   for(i=0;i<3;i++) {
+    if (header_len[i] <= 0)
+        continue;
     init_get_bits(&gb, header_start[i], header_len[i] * 8);
 
     ptype = get_bits(&gb, 8);