Commit 8b2dcf70 authored by Max Kellermann's avatar Max Kellermann

decoder/ffmpeg: require ffmpeg/libav 0.8

Now that even Debian stable has picked up version 0.8, we can safely make this a requirement, and remove a lot of old cruft.
parent 44621f73
...@@ -3,6 +3,7 @@ ver 0.18 (2012/??/??) ...@@ -3,6 +3,7 @@ ver 0.18 (2012/??/??)
- soup: plugin removed - soup: plugin removed
* decoder: * decoder:
- adplug: new decoder plugin using libadplug - adplug: new decoder plugin using libadplug
- ffmpeg: drop support for pre-0.8 ffmpeg
- flac: require libFLAC 1.2 or newer - flac: require libFLAC 1.2 or newer
- flac: support FLAC files inside archives - flac: support FLAC files inside archives
- opus: new decoder plugin for the Opus codec - opus: new decoder plugin for the Opus codec
......
...@@ -850,7 +850,7 @@ AM_PATH_FAAD() ...@@ -850,7 +850,7 @@ AM_PATH_FAAD()
AM_CONDITIONAL(HAVE_FAAD, test x$enable_aac = xyes) AM_CONDITIONAL(HAVE_FAAD, test x$enable_aac = xyes)
dnl ---------------------------------- ffmpeg --------------------------------- dnl ---------------------------------- ffmpeg ---------------------------------
MPD_AUTO_PKG(ffmpeg, FFMPEG, [libavformat >= 53.2 libavcodec >= 53.5 libavutil >= 51.7], MPD_AUTO_PKG(ffmpeg, FFMPEG, [libavformat >= 53.17 libavcodec >= 53.25 libavutil >= 51.17],
[ffmpeg decoder library], [libavformat+libavcodec+libavutil not found]) [ffmpeg decoder library], [libavformat+libavcodec+libavutil not found])
if test x$enable_ffmpeg = xyes; then if test x$enable_ffmpeg = xyes; then
......
...@@ -180,23 +180,6 @@ ffmpeg_find_audio_stream(const AVFormatContext *format_context) ...@@ -180,23 +180,6 @@ ffmpeg_find_audio_stream(const AVFormatContext *format_context)
return -1; return -1;
} }
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,25,0)
/**
* On some platforms, libavcodec wants the output buffer aligned to 16
* bytes (because it uses SSE/Altivec internally). This function
* returns the aligned version of the specified buffer, and corrects
* the buffer size.
*/
static void *
align16(void *p, size_t *length_p)
{
unsigned add = 16 - (size_t)p % 16;
*length_p -= add;
return (char *)p + add;
}
#endif
G_GNUC_CONST G_GNUC_CONST
static double static double
time_from_ffmpeg(int64_t t, const AVRational time_base) time_from_ffmpeg(int64_t t, const AVRational time_base)
...@@ -215,8 +198,6 @@ time_to_ffmpeg(double t, const AVRational time_base) ...@@ -215,8 +198,6 @@ time_to_ffmpeg(double t, const AVRational time_base)
time_base); time_base);
} }
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
static void static void
copy_interleave_frame2(uint8_t *dest, uint8_t **src, copy_interleave_frame2(uint8_t *dest, uint8_t **src,
unsigned nframes, unsigned nchannels, unsigned nframes, unsigned nchannels,
...@@ -261,7 +242,6 @@ copy_interleave_frame(const AVCodecContext *codec_context, ...@@ -261,7 +242,6 @@ copy_interleave_frame(const AVCodecContext *codec_context,
return data_size; return data_size;
} }
#endif
static enum decoder_command static enum decoder_command
ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
...@@ -276,21 +256,13 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, ...@@ -276,21 +256,13 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
AVPacket packet2 = *packet; AVPacket packet2 = *packet;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
uint8_t aligned_buffer[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16]; uint8_t aligned_buffer[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
const size_t buffer_size = sizeof(aligned_buffer); const size_t buffer_size = sizeof(aligned_buffer);
#else
/* libavcodec < 0.8 needs an aligned buffer */
uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
size_t buffer_size = sizeof(audio_buf);
int16_t *aligned_buffer = (int16_t *)align16(audio_buf, &buffer_size);
#endif
enum decoder_command cmd = DECODE_COMMAND_NONE; enum decoder_command cmd = DECODE_COMMAND_NONE;
while (packet2.size > 0 && while (packet2.size > 0 &&
cmd == DECODE_COMMAND_NONE) { cmd == DECODE_COMMAND_NONE) {
int audio_size = buffer_size; int audio_size = buffer_size;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
int got_frame = 0; int got_frame = 0;
int len = avcodec_decode_audio4(codec_context, int len = avcodec_decode_audio4(codec_context,
frame, &got_frame, frame, &got_frame,
...@@ -304,13 +276,6 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, ...@@ -304,13 +276,6 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
len = audio_size; len = audio_size;
} else if (len >= 0) } else if (len >= 0)
len = -1; len = -1;
#else
(void)frame;
int len = avcodec_decode_audio3(codec_context,
aligned_buffer, &audio_size,
&packet2);
#endif
if (len < 0) { if (len < 0) {
/* if error, we skip the frame */ /* if error, we skip the frame */
...@@ -337,21 +302,15 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt) ...@@ -337,21 +302,15 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
{ {
switch (sample_fmt) { switch (sample_fmt) {
case AV_SAMPLE_FMT_S16: case AV_SAMPLE_FMT_S16:
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
case AV_SAMPLE_FMT_S16P: case AV_SAMPLE_FMT_S16P:
#endif
return SAMPLE_FORMAT_S16; return SAMPLE_FORMAT_S16;
case AV_SAMPLE_FMT_S32: case AV_SAMPLE_FMT_S32:
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
case AV_SAMPLE_FMT_S32P: case AV_SAMPLE_FMT_S32P:
#endif
return SAMPLE_FORMAT_S32; return SAMPLE_FORMAT_S32;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
case AV_SAMPLE_FMT_FLTP: case AV_SAMPLE_FMT_FLTP:
return SAMPLE_FORMAT_FLOAT; return SAMPLE_FORMAT_FLOAT;
#endif
default: default:
break; break;
...@@ -429,19 +388,11 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) ...@@ -429,19 +388,11 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
return; return;
} }
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,6,0)
const int find_result = const int find_result =
avformat_find_stream_info(format_context, NULL); avformat_find_stream_info(format_context, NULL);
#else
const int find_result = av_find_stream_info(format_context);
#endif
if (find_result < 0) { if (find_result < 0) {
g_warning("Couldn't find stream info\n"); g_warning("Couldn't find stream info\n");
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); avformat_close_input(&format_context);
#else
av_close_input_stream(format_context);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return; return;
} }
...@@ -449,11 +400,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) ...@@ -449,11 +400,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
int audio_stream = ffmpeg_find_audio_stream(format_context); int audio_stream = ffmpeg_find_audio_stream(format_context);
if (audio_stream == -1) { if (audio_stream == -1) {
g_warning("No audio stream inside\n"); g_warning("No audio stream inside\n");
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); avformat_close_input(&format_context);
#else
av_close_input_stream(format_context);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return; return;
} }
...@@ -468,11 +415,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) ...@@ -468,11 +415,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
if (!codec) { if (!codec) {
g_warning("Unsupported audio codec\n"); g_warning("Unsupported audio codec\n");
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); avformat_close_input(&format_context);
#else
av_close_input_stream(format_context);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return; return;
} }
...@@ -490,11 +433,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) ...@@ -490,11 +433,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
codec_context->channels, &error)) { codec_context->channels, &error)) {
g_warning("%s", error->message); g_warning("%s", error->message);
g_error_free(error); g_error_free(error);
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); avformat_close_input(&format_context);
#else
av_close_input_stream(format_context);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return; return;
} }
...@@ -504,18 +443,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) ...@@ -504,18 +443,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
values into AVCodecContext.channels - a change that will be values into AVCodecContext.channels - a change that will be
reverted later by avcodec_decode_audio3() */ reverted later by avcodec_decode_audio3() */
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,6,0)
const int open_result = avcodec_open2(codec_context, codec, NULL); const int open_result = avcodec_open2(codec_context, codec, NULL);
#else
const int open_result = avcodec_open(codec_context, codec);
#endif
if (open_result < 0) { if (open_result < 0) {
g_warning("Could not open codec\n"); g_warning("Could not open codec\n");
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); avformat_close_input(&format_context);
#else
av_close_input_stream(format_context);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return; return;
} }
...@@ -530,11 +461,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) ...@@ -530,11 +461,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
AVFrame *frame = avcodec_alloc_frame(); AVFrame *frame = avcodec_alloc_frame();
if (!frame) { if (!frame) {
g_warning("Could not allocate frame\n"); g_warning("Could not allocate frame\n");
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); avformat_close_input(&format_context);
#else
av_close_input_stream(format_context);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return; return;
} }
...@@ -578,11 +505,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) ...@@ -578,11 +505,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
#endif #endif
avcodec_close(codec_context); avcodec_close(codec_context);
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&format_context); avformat_close_input(&format_context);
#else
av_close_input_stream(format_context);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
} }
...@@ -606,18 +529,10 @@ ffmpeg_scan_stream(struct input_stream *is, ...@@ -606,18 +529,10 @@ ffmpeg_scan_stream(struct input_stream *is,
return false; return false;
} }
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,6,0)
const int find_result = const int find_result =
avformat_find_stream_info(f, NULL); avformat_find_stream_info(f, NULL);
#else
const int find_result = av_find_stream_info(f);
#endif
if (find_result < 0) { if (find_result < 0) {
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&f); avformat_close_input(&f);
#else
av_close_input_stream(f);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return false; return false;
} }
...@@ -632,11 +547,7 @@ ffmpeg_scan_stream(struct input_stream *is, ...@@ -632,11 +547,7 @@ ffmpeg_scan_stream(struct input_stream *is,
ffmpeg_scan_dictionary(f->streams[idx]->metadata, ffmpeg_scan_dictionary(f->streams[idx]->metadata,
handler, handler_ctx); handler, handler_ctx);
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&f); avformat_close_input(&f);
#else
av_close_input_stream(f);
#endif
mpd_ffmpeg_stream_close(stream); mpd_ffmpeg_stream_close(stream);
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment