aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/ffmpeg_decoder_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-04-12 08:16:57 +0200
committerMax Kellermann <max@duempel.org>2011-04-12 08:20:35 +0200
commitfe30db935b94cd20f898b162485827ac6a223b58 (patch)
treec2f96467ba4490c3307113108cd215419e9415cf /src/decoder/ffmpeg_decoder_plugin.c
parent6303d54cbb265d6696d114b34b8b4be7c1149c59 (diff)
downloadmpd-fe30db935b94cd20f898b162485827ac6a223b58.tar.gz
mpd-fe30db935b94cd20f898b162485827ac6a223b58.tar.xz
mpd-fe30db935b94cd20f898b162485827ac6a223b58.zip
decoder/ffmpeg: use avcodec_decode_audio3() if available
avcodec_decode_audio3() has been added in libavformat 52.25.0, and the predecessor avcodec_decode_audio2() has been deprecated.
Diffstat (limited to 'src/decoder/ffmpeg_decoder_plugin.c')
-rw-r--r--src/decoder/ffmpeg_decoder_plugin.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c
index 56c413f95..c0bb8d6d5 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/ffmpeg_decoder_plugin.c
@@ -174,19 +174,35 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
av_rescale_q(packet->pts, *time_base,
(AVRational){1, 1}));
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
+ AVPacket packet2 = *packet;
+#else
const uint8_t *packet_data = packet->data;
int packet_size = packet->size;
+#endif
uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
size_t buffer_size = sizeof(audio_buf);
int16_t *aligned_buffer = align16(audio_buf, &buffer_size);
enum decoder_command cmd = DECODE_COMMAND_NONE;
- while ((packet_size > 0) && (cmd == DECODE_COMMAND_NONE)) {
+ while (
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
+ packet2.size > 0 &&
+#else
+ packet_size > 0 &&
+#endif
+ cmd == DECODE_COMMAND_NONE) {
int audio_size = buffer_size;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
+ int len = avcodec_decode_audio3(codec_context,
+ aligned_buffer, &audio_size,
+ &packet2);
+#else
int len = avcodec_decode_audio2(codec_context,
aligned_buffer, &audio_size,
packet_data, packet_size);
+#endif
if (len < 0) {
/* if error, we skip the frame */
@@ -194,8 +210,13 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
break;
}
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
+ packet2.data += len;
+ packet2.size -= len;
+#else
packet_data += len;
packet_size -= len;
+#endif
if (audio_size <= 0)
continue;