aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-04-12 08:16:57 +0200
committerMax Kellermann <max@duempel.org>2011-05-09 09:24:17 +0200
commit246db3d5652bb7289b1a1ab255dfdb67e0fa260e (patch)
tree5d31e6f3c1748e5699b0546269da59cfd68f2831
parenteaf414cbc8b624394b1269861b7e51a4907004c2 (diff)
downloadmpd-246db3d5652bb7289b1a1ab255dfdb67e0fa260e.tar.gz
mpd-246db3d5652bb7289b1a1ab255dfdb67e0fa260e.tar.xz
mpd-246db3d5652bb7289b1a1ab255dfdb67e0fa260e.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 '')
-rw-r--r--NEWS2
-rw-r--r--src/decoder/ffmpeg_decoder_plugin.c23
2 files changed, 23 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index a68f83bd5..05b9d86fa 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
ver 0.16.3 (2011/??/??)
* fix assertion failure in audio format mask parser
* decoder:
- - ffmpeg: support lavc 53
+ - ffmpeg: support libavcodec 0.7
ver 0.16.2 (2011/03/18)
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c
index c4f4dfa0b..6d794db49 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/ffmpeg_decoder_plugin.c
@@ -194,19 +194,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 */
@@ -214,8 +230,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;