all repos — mgba @ 1e10098e337730f580359fb64cc182473412d904

mGBA Game Boy Advance Emulator

FFmpeg: Encoding cleanup
Jeffrey Pfau jeffrey@endrift.com
Wed, 21 Sep 2016 14:09:49 -0700
commit

1e10098e337730f580359fb64cc182473412d904

parent

cf6006f9f8851a39fb4de5206372fdea87535206

3 files changed, 7 insertions(+), 5 deletions(-)

jump to
M CHANGESCHANGES

@@ -8,6 +8,7 @@ - Qt: Fix saving overrides

- FFmpeg: Fix encoding AAC Misc: - All: Only update version info if needed + - FFmpeg: Encoding cleanup 0.5.0: (2016-09-19) Features:
M src/feature/ffmpeg/ffmpeg-encoder.csrc/feature/ffmpeg/ffmpeg-encoder.c

@@ -395,7 +395,6 @@

if ((encoder->currentAudioSample * 4) < encoder->audioBufferSize) { return; } - encoder->currentAudioSample = 0; int channelSize = 2 * av_get_bytes_per_sample(encoder->audio->sample_fmt); avresample_convert(encoder->resampleContext,

@@ -409,14 +408,15 @@ av_frame_make_writable(encoder->audioFrame);

#endif avresample_read(encoder->resampleContext, encoder->audioFrame->data, encoder->postaudioBufferSize / channelSize); - AVRational timeBase = { 1, PREFERRED_SAMPLE_RATE }; - encoder->audioFrame->pts = encoder->nextAudioPts; - encoder->nextAudioPts = av_rescale_q(encoder->currentAudioFrame, timeBase, encoder->audioStream->time_base); + encoder->audioFrame->pts = av_rescale_q(encoder->currentAudioFrame - encoder->currentAudioSample, encoder->audio->time_base, encoder->audioStream->time_base); + encoder->currentAudioSample = 0; AVPacket packet; av_init_packet(&packet); packet.data = 0; packet.size = 0; + packet.pts = encoder->audioFrame->pts; + int gotData; #ifdef FFMPEG_USE_PACKETS avcodec_send_frame(encoder->audio, encoder->audioFrame);

@@ -483,6 +483,7 @@ #if LIBAVCODEC_VERSION_MAJOR >= 55

av_frame_make_writable(encoder->videoFrame); #endif encoder->videoFrame->pts = av_rescale_q(encoder->currentVideoFrame, encoder->video->time_base, encoder->videoStream->time_base); + packet.pts = encoder->videoFrame->pts; ++encoder->currentVideoFrame; sws_scale(encoder->scaleContext, (const uint8_t* const*) &pixels, (const int*) &stride, 0, encoder->iheight, encoder->videoFrame->data, encoder->videoFrame->linesize);
M src/feature/ffmpeg/ffmpeg-encoder.hsrc/feature/ffmpeg/ffmpeg-encoder.h

@@ -52,7 +52,7 @@ size_t postaudioBufferSize;

AVFrame* audioFrame; size_t currentAudioSample; int64_t currentAudioFrame; - int64_t nextAudioPts; + int64_t nextAudioPts; // TODO (0.6): Remove struct AVAudioResampleContext* resampleContext; #ifdef FFMPEG_USE_NEW_BSF struct AVBSFContext* absf; // Needed for AAC in MP4