comparison vp3.c @ 4723:b62a3a46856c libavcodec

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)
author aurel
date Sun, 25 Mar 2007 01:09:26 +0000
parents a96d905dcbaa
children 66ef3690d108
comparison
equal deleted inserted replaced
4722:7595ead28402 4723:b62a3a46856c
39 #include "avcodec.h" 39 #include "avcodec.h"
40 #include "dsputil.h" 40 #include "dsputil.h"
41 #include "mpegvideo.h" 41 #include "mpegvideo.h"
42 42
43 #include "vp3data.h" 43 #include "vp3data.h"
44 #include "xiph.h"
44 45
45 #define FRAGMENT_PIXELS 8 46 #define FRAGMENT_PIXELS 8
46 47
47 /* 48 /*
48 * Debugging Variables 49 * Debugging Variables
2572 static int theora_decode_init(AVCodecContext *avctx) 2573 static int theora_decode_init(AVCodecContext *avctx)
2573 { 2574 {
2574 Vp3DecodeContext *s = avctx->priv_data; 2575 Vp3DecodeContext *s = avctx->priv_data;
2575 GetBitContext gb; 2576 GetBitContext gb;
2576 int ptype; 2577 int ptype;
2577 uint8_t *p= avctx->extradata; 2578 uint8_t *header_start[3];
2578 int op_bytes, i; 2579 int header_len[3];
2580 int i;
2579 2581
2580 s->theora = 1; 2582 s->theora = 1;
2581 2583
2582 if (!avctx->extradata_size) 2584 if (!avctx->extradata_size)
2583 { 2585 {
2584 av_log(avctx, AV_LOG_ERROR, "Missing extradata!\n"); 2586 av_log(avctx, AV_LOG_ERROR, "Missing extradata!\n");
2585 return -1; 2587 return -1;
2586 } 2588 }
2587 2589
2590 if (ff_split_xiph_headers(avctx->extradata, avctx->extradata_size,
2591 42, header_start, header_len) < 0) {
2592 av_log(avctx, AV_LOG_ERROR, "Corrupt extradata\n");
2593 return -1;
2594 }
2595
2588 for(i=0;i<3;i++) { 2596 for(i=0;i<3;i++) {
2589 op_bytes = *(p++)<<8; 2597 init_get_bits(&gb, header_start[i], header_len[i]);
2590 op_bytes += *(p++);
2591
2592 init_get_bits(&gb, p, op_bytes);
2593 p += op_bytes;
2594 2598
2595 ptype = get_bits(&gb, 8); 2599 ptype = get_bits(&gb, 8);
2596 debug_vp3("Theora headerpacket type: %x\n", ptype); 2600 debug_vp3("Theora headerpacket type: %x\n", ptype);
2597 2601
2598 if (!(ptype & 0x80)) 2602 if (!(ptype & 0x80))
2618 break; 2622 break;
2619 default: 2623 default:
2620 av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80); 2624 av_log(avctx, AV_LOG_ERROR, "Unknown Theora config packet: %d\n", ptype&~0x80);
2621 break; 2625 break;
2622 } 2626 }
2623 if(8*op_bytes != get_bits_count(&gb)) 2627 if(8*header_len[i] != get_bits_count(&gb))
2624 av_log(avctx, AV_LOG_ERROR, "%d bits left in packet %X\n", 8*op_bytes - get_bits_count(&gb), ptype); 2628 av_log(avctx, AV_LOG_ERROR, "%d bits left in packet %X\n", 8*header_len[i] - get_bits_count(&gb), ptype);
2625 if (s->theora < 0x030200) 2629 if (s->theora < 0x030200)
2626 break; 2630 break;
2627 } 2631 }
2628 2632
2629 vp3_decode_init(avctx); 2633 vp3_decode_init(avctx);