summaryrefslogtreecommitdiff
path: root/src/combined/ffmpeg/ff_audio_decoder.c
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2011-05-17 02:15:12 +0000
committerBrad Smith <brad@comstyle.com>2011-05-17 02:15:12 +0000
commitc5159206dcea00766b7d567193e1c4fd13f12cf3 (patch)
tree33109eca512e5fc87b32c450b6c9d1f660c3fcf9 /src/combined/ffmpeg/ff_audio_decoder.c
parent4decf418a1f1bd0be76734f656c2f4d63f2fe204 (diff)
downloadxine-lib-c5159206dcea00766b7d567193e1c4fd13f12cf3.tar.gz
xine-lib-c5159206dcea00766b7d567193e1c4fd13f12cf3.tar.bz2
Fix build with very recent copies of FFmpeg
This is a backport of the 1.2 code that was commited to utilize the new API provided by FFmpeg for awhile now but this is especially important because the old API has been eliminated all together from said copies of FFmpeg.
Diffstat (limited to 'src/combined/ffmpeg/ff_audio_decoder.c')
-rw-r--r--src/combined/ffmpeg/ff_audio_decoder.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c
index 125eff12c..60544ad0c 100644
--- a/src/combined/ffmpeg/ff_audio_decoder.c
+++ b/src/combined/ffmpeg/ff_audio_decoder.c
@@ -46,6 +46,12 @@
#define AUDIOBUFSIZE (64 * 1024)
+#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32)
+# define AVAUDIO 3
+#else
+# define AVAUDIO 2
+#endif
+
typedef struct {
audio_decoder_class_t decoder_class;
} ff_audio_class_t;
@@ -255,6 +261,9 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
buf->decoder_info[2]);
} else if (!(buf->decoder_flags & BUF_FLAG_SPECIAL)) {
+#if AVAUDIO > 2
+ AVPacket avpkt;
+#endif
if( !this->decoder_ok ) {
if ( ! this->context || ! this->codec ) {
@@ -286,11 +295,21 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
if (!this->output_open) {
if (!this->audio_bits || !this->audio_sample_rate || !this->audio_channels) {
decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+#if AVAUDIO > 2
+ av_init_packet (&avpkt);
+ avpkt.data = (uint8_t *)&this->buf[0];
+ avpkt.size = this->size;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ avcodec_decode_audio3 (this->context,
+ (int16_t *)this->decode_buffer,
+ &decode_buffer_size, &avpkt);
+#else
avcodec_decode_audio2 (this->context,
(int16_t *)this->decode_buffer,
&decode_buffer_size,
&this->buf[0],
this->size);
+#endif
this->audio_bits = this->context->bits_per_sample;
this->audio_sample_rate = this->context->sample_rate;
this->audio_channels = this->context->channels;
@@ -311,12 +330,21 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
offset = 0;
while (this->size>0) {
decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+#if AVAUDIO > 2
+ av_init_packet (&avpkt);
+ avpkt.data = (uint8_t *)&this->buf[offset];
+ avpkt.size = this->size;
+ avpkt.flags = AV_PKT_FLAG_KEY;
+ bytes_consumed = avcodec_decode_audio3 (this->context,
+ (int16_t *)this->decode_buffer,
+ &decode_buffer_size, &avpkt);
+#else
bytes_consumed = avcodec_decode_audio2 (this->context,
(int16_t *)this->decode_buffer,
&decode_buffer_size,
&this->buf[offset],
this->size);
-
+#endif
if (bytes_consumed<0) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"ffmpeg_audio_dec: error decompressing audio frame\n");