aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-03-22 07:05:00 +0100
committerMax Kellermann <max@duempel.org>2013-04-05 23:30:47 +0200
commite0c2c77c2ab1fcd65b18a4c8c71b34b2b8652900 (patch)
tree617d2e3fd996b0dca6765dc9c9d09649dd396cfd /src
parent46528783ef07d1180d7059f3916d277a2f9a0c31 (diff)
downloadmpd-e0c2c77c2ab1fcd65b18a4c8c71b34b2b8652900.tar.gz
mpd-e0c2c77c2ab1fcd65b18a4c8c71b34b2b8652900.tar.xz
mpd-e0c2c77c2ab1fcd65b18a4c8c71b34b2b8652900.zip
ffmpeg decoder plugin: do not allocate an AVFrame on stack.
AVFrame must be allocated with avcodec_alloc_frame().
Diffstat (limited to 'src')
-rw-r--r--src/decoder/ffmpeg_decoder_plugin.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c
index 4c4cb2b81..fcf7507f4 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/ffmpeg_decoder_plugin.c
@@ -318,20 +318,33 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
cmd == DECODE_COMMAND_NONE) {
int audio_size = buffer_size;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
- AVFrame frame;
+
+ AVFrame *frame = avcodec_alloc_frame();
+ if (frame == NULL) {
+ g_warning("Could not allocate frame");
+ break;
+ }
+
int got_frame = 0;
int len = avcodec_decode_audio4(codec_context,
- &frame, &got_frame,
+ frame, &got_frame,
&packet2);
if (len >= 0 && got_frame) {
audio_size = copy_interleave_frame(codec_context,
- &frame,
+ frame,
aligned_buffer,
buffer_size);
if (audio_size < 0)
len = audio_size;
} else if (len >= 0)
len = -1;
+
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
+ avcodec_free_frame(&frame);
+#else
+ av_freep(&frame);
+#endif
+
#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
int len = avcodec_decode_audio3(codec_context,
aligned_buffer, &audio_size,