Mercurial > libavformat.hg
changeset 408:237eeeb50fb8 libavformat
fix global header passing from demuxer to decoder
author | michael |
---|---|
date | Sun, 04 Apr 2004 17:55:59 +0000 |
parents | b9d16c18ee18 |
children | b6949d80b7a9 |
files | ogg.c |
diffstat | 1 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ogg.c Sun Apr 04 15:19:20 2004 +0000 +++ b/ogg.c Sun Apr 04 17:55:59 2004 +0000 @@ -167,9 +167,13 @@ static int ogg_read_header(AVFormatContext *avfcontext, AVFormatParameters *ap) { OggContext *context = avfcontext->priv_data; + ogg_packet op ; char *buf ; ogg_page og ; AVStream *ast ; + AVCodecContext *codec; + uint8_t *p; + int i; avfcontext->ctx_flags |= AVFMTCTX_NOHEADER; @@ -183,16 +187,28 @@ ogg_sync_pageout(&context->oy, &og) ; ogg_stream_init(&context->os, ogg_page_serialno(&og)) ; ogg_stream_pagein(&context->os, &og) ; - + /* currently only one vorbis stream supported */ ast = av_new_stream(avfcontext, 0) ; if(!ast) return AVERROR_NOMEM ; - ast->codec.codec_type = CODEC_TYPE_AUDIO ; - ast->codec.codec_id = CODEC_ID_VORBIS ; - + codec= &ast->codec; + codec->codec_type = CODEC_TYPE_AUDIO; + codec->codec_id = CODEC_ID_VORBIS; + for(i=0; i<3; i++){ + if(next_packet(avfcontext, &op)){ + return -1; + } + codec->extradata_size+= 2 + op.bytes; + codec->extradata= av_realloc(codec->extradata, codec->extradata_size); + p= codec->extradata + codec->extradata_size - 2 - op.bytes; + *(p++)= op.bytes>>8; + *(p++)= op.bytes&0xFF; + memcpy(p, op.packet, op.bytes); + } + return 0 ; } @@ -216,6 +232,7 @@ ogg_stream_clear(&context->os) ; ogg_sync_clear(&context->oy) ; + av_freep(&avfcontext->streams[0]->codec.extradata); return 0 ; }