all repos — mgba @ e9333c8749e36819a7b6ba55284475a0de355f30

mGBA Game Boy Advance Emulator

Fix audio frame pts
Jeffrey Pfau jeffrey@endrift.com
Mon, 27 Oct 2014 23:31:51 -0700
commit

e9333c8749e36819a7b6ba55284475a0de355f30

parent

4fb82e4b80d66be60f1679a4dd5dbea118a7c178

2 files changed, 4 insertions(+), 1 deletions(-)

jump to
M src/platform/ffmpeg/ffmpeg-encoder.csrc/platform/ffmpeg/ffmpeg-encoder.c

@@ -241,6 +241,7 @@ encoder->context = 0;

encoder->currentAudioSample = 0; encoder->currentAudioFrame = 0; + encoder->nextAudioPts = 0; encoder->currentVideoFrame = 0; }

@@ -272,7 +273,8 @@ }

avresample_read(encoder->resampleContext, encoder->audioFrame->data, encoder->postaudioBufferSize / channelSize); AVRational timeBase = { 1, PREFERRED_SAMPLE_RATE }; - encoder->audioFrame->pts = av_rescale_q(encoder->currentAudioFrame, timeBase, encoder->audioStream->time_base); + encoder->audioFrame->pts = encoder->nextAudioPts; + encoder->nextAudioPts = av_rescale_q(encoder->currentAudioFrame, timeBase, encoder->audioStream->time_base); AVPacket packet; av_init_packet(&packet);
M src/platform/ffmpeg/ffmpeg-encoder.hsrc/platform/ffmpeg/ffmpeg-encoder.h

@@ -29,6 +29,7 @@ size_t postaudioBufferSize;

AVFrame* audioFrame; size_t currentAudioSample; int64_t currentAudioFrame; + int64_t nextAudioPts; AVAudioResampleContext* resampleContext; AVStream* audioStream;