Commit 5b8e0fc3 authored by aurel's avatar aurel

use generic xiph header spliting func to split theora headers

Original thread:
Date: Thu, 22 Mar 2007 20:23:08 -0400
Subject: [Ffmpeg-devel] [PATCH] Theora in MKV (GSoC '07 Qualification)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@8506 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 610e2d23
...@@ -141,7 +141,7 @@ OBJS-$(CONFIG_SVQ1_ENCODER) += svq1.o ...@@ -141,7 +141,7 @@ OBJS-$(CONFIG_SVQ1_ENCODER) += svq1.o
OBJS-$(CONFIG_SVQ3_DECODER) += h264.o OBJS-$(CONFIG_SVQ3_DECODER) += h264.o
OBJS-$(CONFIG_TARGA_DECODER) += targa.o OBJS-$(CONFIG_TARGA_DECODER) += targa.o
OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o
OBJS-$(CONFIG_THEORA_DECODER) += vp3.o OBJS-$(CONFIG_THEORA_DECODER) += vp3.o xiph.o
OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
OBJS-$(CONFIG_TIFF_DECODER) += tiff.o lzw.o OBJS-$(CONFIG_TIFF_DECODER) += tiff.o lzw.o
OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "mpegvideo.h" #include "mpegvideo.h"
#include "vp3data.h" #include "vp3data.h"
#include "xiph.h"
#define FRAGMENT_PIXELS 8 #define FRAGMENT_PIXELS 8
...@@ -2574,8 +2575,9 @@ static int theora_decode_init(AVCodecContext *avctx) ...@@ -2574,8 +2575,9 @@ static int theora_decode_init(AVCodecContext *avctx)
Vp3DecodeContext *s = avctx->priv_data; Vp3DecodeContext *s = avctx->priv_data;
GetBitContext gb; GetBitContext gb;
int ptype; int ptype;
uint8_t *p= avctx->extradata; uint8_t *header_start[3];
int op_bytes, i; int header_len[3];
int i;
s->theora = 1; s->theora = 1;
...@@ -2585,12 +2587,14 @@ static int theora_decode_init(AVCodecContext *avctx) ...@@ -2585,12 +2587,14 @@ static int theora_decode_init(AVCodecContext *avctx)
return -1; return -1;
} }
for(i=0;i<3;i++) { if (ff_split_xiph_headers(avctx->extradata, avctx->extradata_size,
op_bytes = *(p++)<<8; 42, header_start, header_len) < 0) {
op_bytes += *(p++); av_log(avctx, AV_LOG_ERROR, "Corrupt extradata\n");
return -1;
}
init_get_bits(&gb, p, op_bytes); for(i=0;i<3;i++) {
p += op_bytes; init_get_bits(&gb, header_start[i], header_len[i]);
ptype = get_bits(&gb, 8); ptype = get_bits(&gb, 8);
debug_vp3("Theora headerpacket type: %x\n", ptype); debug_vp3("Theora headerpacket type: %x\n", ptype);
...@@ -2620,8 +2624,8 @@ static int theora_decode_init(AVCodecContext *avctx) ...@@ -2620,8 +2624,8 @@ static int theora_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80); av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80);
break; break;
} }
if(8*op_bytes != get_bits_count(&gb)) if(8*header_len[i] != get_bits_count(&gb))
av_log(avctx, AV_LOG_ERROR, "%d bits left in packet %X\n", 8*op_bytes - get_bits_count(&gb), ptype); av_log(avctx, AV_LOG_ERROR, "%d bits left in packet %X\n", 8*header_len[i] - get_bits_count(&gb), ptype);
if (s->theora < 0x030200) if (s->theora < 0x030200)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment