Commit 45775f68 authored by michael's avatar michael

pts hack (correct solution would be to pass the pts from the encoder to the muxer)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@2957 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 04130f48
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include "avcodec.h" #include "avcodec.h"
//#define OGGVORBIS_FRAME_SIZE 1024 #undef NDEBUG
#include <assert.h>
#define OGGVORBIS_FRAME_SIZE 64 #define OGGVORBIS_FRAME_SIZE 64
#define BUFFER_SIZE (1024*64) #define BUFFER_SIZE (1024*64)
...@@ -19,6 +21,7 @@ typedef struct OggVorbisContext { ...@@ -19,6 +21,7 @@ typedef struct OggVorbisContext {
vorbis_block vb ; vorbis_block vb ;
uint8_t buffer[BUFFER_SIZE]; uint8_t buffer[BUFFER_SIZE];
int buffer_index; int buffer_index;
int64_t fake_pts; //pts which libavformat will guess, HACK FIXME
/* decoder */ /* decoder */
vorbis_comment vc ; vorbis_comment vc ;
...@@ -130,20 +133,27 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext, ...@@ -130,20 +133,27 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
} }
} }
l=0;
if(context->buffer_index){ if(context->buffer_index){
ogg_packet *op2= (ogg_packet*)context->buffer; ogg_packet *op2= (ogg_packet*)context->buffer;
op2->packet = context->buffer + sizeof(ogg_packet); op2->packet = context->buffer + sizeof(ogg_packet);
l= op2->bytes;
if(op2->granulepos <= context->fake_pts /*&& (context->fake_pts || context->buffer_index > 4*1024)*/){
memcpy(packets, op2->packet, l); assert(op2->granulepos == context->fake_pts);
context->buffer_index -= l + sizeof(ogg_packet); l= op2->bytes;
memcpy(context->buffer, context->buffer + l + sizeof(ogg_packet), context->buffer_index);
memcpy(packets, op2->packet, l);
context->buffer_index -= l + sizeof(ogg_packet);
memcpy(context->buffer, context->buffer + l + sizeof(ogg_packet), context->buffer_index);
}
// av_log(avccontext, AV_LOG_DEBUG, "E%d\n", l); // av_log(avccontext, AV_LOG_DEBUG, "E%d\n", l);
return l;
} }
return 0; if(l || context->fake_pts){
context->fake_pts += avccontext->frame_size;
}
return l;
} }
......
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