summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-04-04 15:19:20 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-04-04 15:19:20 +0000
commitbbb77e7c2eceaf4924783ff3fdb145613c499bcb (patch)
tree9129e1e0faf5a1532b9ea456a4633fc77ad2268e /libavformat
parent6d8f985ecfb1cab04dc114307091282db6f16933 (diff)
remove function call from muxer->encoder and cleanly pass global headers
Originally committed as revision 2956 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/ogg.c53
1 files changed, 13 insertions, 40 deletions
diff --git a/libavformat/ogg.c b/libavformat/ogg.c
index 3c8b1e2b9c..43d111d5b5 100644
--- a/libavformat/ogg.c
+++ b/libavformat/ogg.c
@@ -9,10 +9,8 @@
#include <stdio.h>
#include <ogg/ogg.h>
-#include <vorbis/vorbisenc.h>
#include "avformat.h"
-#include "oggvorbis.h"
#undef NDEBUG
#include <assert.h>
@@ -35,52 +33,28 @@ typedef struct OggContext {
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 ;
+ 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++];
- /* begin vorbis specific code */
-
- vorbis_info_init(&vi) ;
+ op->packet= &p[i];
+ op->b_o_s= op->packetno==0;
- /* code copied from libavcodec/oggvorbis.c */
+ ogg_stream_packetin(&context->os, op);
- if(oggvorbis_init_encoder(&vi, avccontext) < 0) {
- fprintf(stderr, "ogg_write_header: init_encoder failed") ;
- return -1 ;
- }
-
- 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) ;
-
- 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 */
+ op->packetno++; //FIXME multiple streams
+ }
context->header_handled = 0 ;
}
@@ -88,7 +62,6 @@ static int ogg_write_header(AVFormatContext *avfcontext)
return 0 ;
}
-
static int ogg_write_packet(AVFormatContext *avfcontext,
int stream_index,
const uint8_t *buf, int size, int64_t pts)