# HG changeset patch # User michael # Date 1081091960 0 # Node ID b9d16c18ee186839c5790b5158077d875d1dd1e4 # Parent ea22a438ca7969b10bc947484d2f1114bd03efa4 remove function call from muxer->encoder and cleanly pass global headers diff -r ea22a438ca79 -r b9d16c18ee18 ogg.c --- a/ogg.c Sun Apr 04 14:39:20 2004 +0000 +++ b/ogg.c Sun Apr 04 15:19:20 2004 +0000 @@ -9,10 +9,8 @@ #include #include -#include #include "avformat.h" -#include "oggvorbis.h" #undef NDEBUG #include @@ -35,52 +33,28 @@ static int ogg_write_header(AVFormatContext *avfcontext) { OggContext *context = avfcontext->priv_data; - AVCodecContext *avccontext ; - vorbis_info vi ; - vorbis_dsp_state vd ; - vorbis_comment vc ; - vorbis_block vb ; - ogg_packet header, header_comm, header_code ; - int n ; + ogg_packet *op= &context->op; + int n, i; av_set_pts_info(avfcontext, 60, 1, AV_TIME_BASE); ogg_stream_init(&context->os, 31415); for(n = 0 ; n < avfcontext->nb_streams ; n++) { - avccontext = &avfcontext->streams[n]->codec ; - - /* begin vorbis specific code */ - - vorbis_info_init(&vi) ; - - /* code copied from libavcodec/oggvorbis.c */ - - if(oggvorbis_init_encoder(&vi, avccontext) < 0) { - fprintf(stderr, "ogg_write_header: init_encoder failed") ; - return -1 ; - } + AVCodecContext *codec = &avfcontext->streams[n]->codec; + uint8_t *p= codec->extradata; + + for(i=0; i < codec->extradata_size; i+= op->bytes){ + op->bytes = p[i++]<<8; + op->bytes+= p[i++]; - vorbis_analysis_init(&vd, &vi) ; - vorbis_block_init(&vd, &vb) ; - - vorbis_comment_init(&vc) ; - vorbis_comment_add_tag(&vc, "encoder", LIBAVFORMAT_IDENT) ; - if(*avfcontext->title) - vorbis_comment_add_tag(&vc, "title", avfcontext->title) ; + op->packet= &p[i]; + op->b_o_s= op->packetno==0; - vorbis_analysis_headerout(&vd, &vc, &header, - &header_comm, &header_code) ; - ogg_stream_packetin(&context->os, &header) ; - ogg_stream_packetin(&context->os, &header_comm) ; - ogg_stream_packetin(&context->os, &header_code) ; - - vorbis_block_clear(&vb) ; - vorbis_dsp_clear(&vd) ; - vorbis_info_clear(&vi) ; - vorbis_comment_clear(&vc) ; - - /* end of vorbis specific code */ + ogg_stream_packetin(&context->os, op); + + op->packetno++; //FIXME multiple streams + } context->header_handled = 0 ; } @@ -88,7 +62,6 @@ return 0 ; } - static int ogg_write_packet(AVFormatContext *avfcontext, int stream_index, const uint8_t *buf, int size, int64_t pts)