mirror of https://github.com/mgba-emu/mgba.git
FFmpeg: Fix encoing AAC
This commit is contained in:
parent
5c744a3f13
commit
cf6006f9f8
1
CHANGES
1
CHANGES
|
@ -5,6 +5,7 @@ Bugfixes:
|
||||||
- GBA Cheats: Fix holding onto pointers that may get invalidated
|
- GBA Cheats: Fix holding onto pointers that may get invalidated
|
||||||
- Qt: Fix "close" button on Overrides view
|
- Qt: Fix "close" button on Overrides view
|
||||||
- Qt: Fix saving overrides
|
- Qt: Fix saving overrides
|
||||||
|
- FFmpeg: Fix encoding AAC
|
||||||
Misc:
|
Misc:
|
||||||
- All: Only update version info if needed
|
- All: Only update version info if needed
|
||||||
|
|
||||||
|
|
|
@ -381,6 +381,11 @@ void _ffmpegPostAudioFrame(struct mAVStream* stream, int16_t left, int16_t right
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (encoder->absf && !left) {
|
||||||
|
// XXX: AVBSF doesn't like silence. Figure out why.
|
||||||
|
left = 1;
|
||||||
|
}
|
||||||
|
|
||||||
encoder->audioBuffer[encoder->currentAudioSample * 2] = left;
|
encoder->audioBuffer[encoder->currentAudioSample * 2] = left;
|
||||||
encoder->audioBuffer[encoder->currentAudioSample * 2 + 1] = right;
|
encoder->audioBuffer[encoder->currentAudioSample * 2 + 1] = right;
|
||||||
|
|
||||||
|
@ -415,36 +420,46 @@ void _ffmpegPostAudioFrame(struct mAVStream* stream, int16_t left, int16_t right
|
||||||
int gotData;
|
int gotData;
|
||||||
#ifdef FFMPEG_USE_PACKETS
|
#ifdef FFMPEG_USE_PACKETS
|
||||||
avcodec_send_frame(encoder->audio, encoder->audioFrame);
|
avcodec_send_frame(encoder->audio, encoder->audioFrame);
|
||||||
gotData = avcodec_receive_packet(encoder->audio, &packet) == 0;
|
gotData = avcodec_receive_packet(encoder->audio, &packet);
|
||||||
|
gotData = (gotData == 0) && packet.size;
|
||||||
#else
|
#else
|
||||||
avcodec_encode_audio2(encoder->audio, &packet, encoder->audioFrame, &gotData);
|
avcodec_encode_audio2(encoder->audio, &packet, encoder->audioFrame, &gotData);
|
||||||
#endif
|
#endif
|
||||||
if (gotData) {
|
if (gotData) {
|
||||||
if (encoder->absf) {
|
if (encoder->absf) {
|
||||||
AVPacket tempPacket = packet;
|
AVPacket tempPacket;
|
||||||
|
|
||||||
#ifdef FFMPEG_USE_NEW_BSF
|
#ifdef FFMPEG_USE_NEW_BSF
|
||||||
int success = av_bsf_send_packet(encoder->absf, &packet) && av_bsf_receive_packet(encoder->absf, &packet);
|
int success = av_bsf_send_packet(encoder->absf, &packet);
|
||||||
|
if (success >= 0) {
|
||||||
|
success = av_bsf_receive_packet(encoder->absf, &tempPacket);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int success = av_bitstream_filter_filter(encoder->absf, encoder->audio, 0,
|
int success = av_bitstream_filter_filter(encoder->absf, encoder->audio, 0,
|
||||||
&tempPacket.data, &tempPacket.size,
|
&tempPacket.data, &tempPacket.size,
|
||||||
packet.data, packet.size, 0);
|
packet.data, packet.size, 0);
|
||||||
#endif
|
#endif
|
||||||
if (success > 0) {
|
|
||||||
|
if (success >= 0) {
|
||||||
#if LIBAVUTIL_VERSION_MAJOR >= 53
|
#if LIBAVUTIL_VERSION_MAJOR >= 53
|
||||||
tempPacket.buf = av_buffer_create(tempPacket.data, tempPacket.size, av_buffer_default_free, 0, 0);
|
tempPacket.buf = av_buffer_create(tempPacket.data, tempPacket.size, av_buffer_default_free, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FFMPEG_USE_PACKET_UNREF
|
#ifdef FFMPEG_USE_PACKET_UNREF
|
||||||
av_packet_unref(&packet);
|
av_packet_move_ref(&packet, &tempPacket);
|
||||||
#else
|
#else
|
||||||
av_free_packet(&packet);
|
av_free_packet(&packet);
|
||||||
#endif
|
|
||||||
}
|
|
||||||
packet = tempPacket;
|
packet = tempPacket;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
packet.stream_index = encoder->audioStream->index;
|
packet.stream_index = encoder->audioStream->index;
|
||||||
av_interleaved_write_frame(encoder->context, &packet);
|
av_interleaved_write_frame(encoder->context, &packet);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
packet.stream_index = encoder->audioStream->index;
|
||||||
|
av_interleaved_write_frame(encoder->context, &packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef FFMPEG_USE_PACKET_UNREF
|
#ifdef FFMPEG_USE_PACKET_UNREF
|
||||||
av_packet_unref(&packet);
|
av_packet_unref(&packet);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue