aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-28 20:53:48 +0100
committerMax Kellermann <max@duempel.org>2013-01-28 21:32:14 +0100
commit0dd4b52b63519a4fb8197b127b7548f7c94a1a32 (patch)
tree91666c04968f4e3025061a1e65f078fea29c2a55
parent88c17926e4b5d5d88025b62a84a8c83991f397ff (diff)
downloadmpd-0dd4b52b63519a4fb8197b127b7548f7c94a1a32.tar.gz
mpd-0dd4b52b63519a4fb8197b127b7548f7c94a1a32.tar.xz
mpd-0dd4b52b63519a4fb8197b127b7548f7c94a1a32.zip
decoder/ffmpeg: require ffmpeg/libav 0.7.6
This is the version present in Ubuntu Oneiric, the oldest distribution with gcc 4.6. Debian Squeeze is off target, because it has gcc 4.4, which is unable to compile MPD anyway. This commit drops all API compatibility hacks for older versions.
-rw-r--r--configure.ac2
-rw-r--r--src/decoder/FfmpegDecoderPlugin.cxx68
-rw-r--r--src/decoder/FfmpegMetaData.cxx9
-rw-r--r--src/decoder/FfmpegMetaData.hxx8
-rw-r--r--src/input/FfmpegInputPlugin.cxx31
5 files changed, 4 insertions, 114 deletions
diff --git a/configure.ac b/configure.ac
index f6bb64a89..ca445880d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -874,7 +874,7 @@ AM_PATH_FAAD()
AM_CONDITIONAL(HAVE_FAAD, test x$enable_aac = xyes)
dnl ---------------------------------- ffmpeg ---------------------------------
-MPD_AUTO_PKG(ffmpeg, FFMPEG, [libavformat >= 52.31 libavcodec >= 52.20 libavutil >= 49.15],
+MPD_AUTO_PKG(ffmpeg, FFMPEG, [libavformat >= 53.2 libavcodec >= 53.5 libavutil >= 51.7],
[ffmpeg decoder library], [libavformat+libavcodec+libavutil not found])
if test x$enable_ffmpeg = xyes; then
diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx
index e89f35ef6..e40813775 100644
--- a/src/decoder/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -49,9 +49,7 @@ extern "C" {
#include <libavutil/avutil.h>
#include <libavutil/log.h>
#include <libavutil/mathematics.h>
-#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#include <libavutil/dict.h>
-#endif
}
#undef G_LOG_DOMAIN
@@ -92,11 +90,8 @@ struct mpd_ffmpeg_stream {
struct decoder *decoder;
struct input_stream *input;
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
AVIOContext *io;
-#else
- ByteIOContext *io;
-#endif
+
unsigned char buffer[8192];
};
@@ -129,19 +124,11 @@ mpd_ffmpeg_stream_open(struct decoder *decoder, struct input_stream *input)
struct mpd_ffmpeg_stream *stream = g_new(struct mpd_ffmpeg_stream, 1);
stream->decoder = decoder;
stream->input = input;
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
stream->io = avio_alloc_context(stream->buffer, sizeof(stream->buffer),
false, stream,
mpd_ffmpeg_stream_read, NULL,
input->seekable
? mpd_ffmpeg_stream_seek : NULL);
-#else
- stream->io = av_alloc_put_byte(stream->buffer, sizeof(stream->buffer),
- false, stream,
- mpd_ffmpeg_stream_read, NULL,
- input->seekable
- ? mpd_ffmpeg_stream_seek : NULL);
-#endif
if (stream->io == NULL) {
g_free(stream);
return NULL;
@@ -156,15 +143,10 @@ mpd_ffmpeg_stream_open(struct decoder *decoder, struct input_stream *input)
*/
static int
mpd_ffmpeg_open_input(AVFormatContext **ic_ptr,
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
AVIOContext *pb,
-#else
- ByteIOContext *pb,
-#endif
const char *filename,
AVInputFormat *fmt)
{
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,1,3)
AVFormatContext *context = avformat_alloc_context();
if (context == NULL)
return AVERROR(ENOMEM);
@@ -172,9 +154,6 @@ mpd_ffmpeg_open_input(AVFormatContext **ic_ptr,
context->pb = pb;
*ic_ptr = context;
return avformat_open_input(ic_ptr, filename, fmt, NULL);
-#else
- return av_open_input_stream(ic_ptr, pb, filename, fmt, NULL);
-#endif
}
static void
@@ -198,11 +177,7 @@ ffmpeg_find_audio_stream(const AVFormatContext *format_context)
{
for (unsigned i = 0; i < format_context->nb_streams; ++i)
if (format_context->streams[i]->codec->codec_type ==
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0)
AVMEDIA_TYPE_AUDIO)
-#else
- CODEC_TYPE_AUDIO)
-#endif
return i;
return -1;
@@ -301,12 +276,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
decoder_timestamp(decoder,
time_from_ffmpeg(packet->pts, *time_base));
-#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
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
uint8_t aligned_buffer[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
@@ -319,12 +289,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
#endif
enum decoder_command cmd = DECODE_COMMAND_NONE;
- while (
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
- packet2.size > 0 &&
-#else
- packet_size > 0 &&
-#endif
+ while (packet2.size > 0 &&
cmd == DECODE_COMMAND_NONE) {
int audio_size = buffer_size;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
@@ -342,14 +307,10 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
len = audio_size;
} else if (len >= 0)
len = -1;
-#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
+#else
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) {
@@ -358,13 +319,8 @@ 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;
@@ -376,33 +332,21 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
return cmd;
}
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 94, 1)
-#define AVSampleFormat SampleFormat
-#endif
-
G_GNUC_CONST
static enum sample_format
ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
{
switch (sample_fmt) {
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
case AV_SAMPLE_FMT_S16:
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
case AV_SAMPLE_FMT_S16P:
#endif
-#else
- case SAMPLE_FMT_S16:
-#endif
return SAMPLE_FORMAT_S16;
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
case AV_SAMPLE_FMT_S32:
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
case AV_SAMPLE_FMT_S32P:
#endif
-#else
- case SAMPLE_FMT_S32:
-#endif
return SAMPLE_FORMAT_S32;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
@@ -414,7 +358,6 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
break;
}
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
char buffer[64];
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
sample_fmt);
@@ -422,7 +365,6 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
g_warning("Unsupported libavcodec SampleFormat value: %s (%d)",
name, sample_fmt);
else
-#endif
g_warning("Unsupported libavcodec SampleFormat value: %d",
sample_fmt);
return SAMPLE_FORMAT_UNDEFINED;
@@ -665,10 +607,6 @@ ffmpeg_scan_stream(struct input_stream *is,
tag_handler_invoke_duration(handler, handler_ctx,
f->duration / AV_TIME_BASE);
-#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52,101,0)
- av_metadata_conv(f, NULL, f->iformat->metadata_conv);
-#endif
-
ffmpeg_scan_dictionary(f->metadata, handler, handler_ctx);
int idx = ffmpeg_find_audio_stream(f);
if (idx >= 0)
diff --git a/src/decoder/FfmpegMetaData.cxx b/src/decoder/FfmpegMetaData.cxx
index d3000591c..2d7ebbca3 100644
--- a/src/decoder/FfmpegMetaData.cxx
+++ b/src/decoder/FfmpegMetaData.cxx
@@ -29,9 +29,6 @@
#define G_LOG_DOMAIN "ffmpeg"
static const struct tag_table ffmpeg_tags[] = {
-#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52,50,0)
- { "author", TAG_ARTIST },
-#endif
{ "year", TAG_DATE },
{ "author-sort", TAG_ARTIST_SORT },
{ "album_artist", TAG_ALBUM_ARTIST },
@@ -53,8 +50,6 @@ ffmpeg_copy_metadata(enum tag_type type,
type, mt->value);
}
-#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
-
static void
ffmpeg_scan_pairs(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx)
@@ -66,8 +61,6 @@ ffmpeg_scan_pairs(AVDictionary *dict,
i->key, i->value);
}
-#endif
-
void
ffmpeg_scan_dictionary(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx)
@@ -81,8 +74,6 @@ ffmpeg_scan_dictionary(AVDictionary *dict,
ffmpeg_copy_metadata(i->type, dict, i->name,
handler, handler_ctx);
-#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
if (handler->pair != NULL)
ffmpeg_scan_pairs(dict, handler, handler_ctx);
-#endif
}
diff --git a/src/decoder/FfmpegMetaData.hxx b/src/decoder/FfmpegMetaData.hxx
index f76e16287..466d2cb1d 100644
--- a/src/decoder/FfmpegMetaData.hxx
+++ b/src/decoder/FfmpegMetaData.hxx
@@ -23,17 +23,9 @@
extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
-#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#include <libavutil/dict.h>
-#endif
}
-#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0)
-#define AVDictionary AVMetadata
-#define AVDictionaryEntry AVMetadataTag
-#define av_dict_get av_metadata_get
-#endif
-
struct tag_handler;
void
diff --git a/src/input/FfmpegInputPlugin.cxx b/src/input/FfmpegInputPlugin.cxx
index d9e223861..52a31da8d 100644
--- a/src/input/FfmpegInputPlugin.cxx
+++ b/src/input/FfmpegInputPlugin.cxx
@@ -38,11 +38,7 @@ extern "C" {
struct input_ffmpeg {
struct input_stream base;
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
AVIOContext *h;
-#else
- URLContext *h;
-#endif
bool eof;
};
@@ -56,12 +52,8 @@ ffmpeg_quark(void)
static inline bool
input_ffmpeg_supported(void)
{
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
void *opaque = nullptr;
return avio_enum_protocols(&opaque, 0) != nullptr;
-#else
- return av_protocol_next(nullptr) != nullptr;
-#endif
}
static bool
@@ -99,13 +91,7 @@ input_ffmpeg_open(const char *uri,
input_stream_init(&i->base, &input_plugin_ffmpeg, uri,
mutex, cond);
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,1,0)
int ret = avio_open(&i->h, uri, AVIO_FLAG_READ);
-#elif LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
- int ret = avio_open(&i->h, uri, AVIO_RDONLY);
-#else
- int ret = url_open(&i->h, uri, URL_RDONLY);
-#endif
if (ret != 0) {
g_free(i);
g_set_error(error_r, ffmpeg_quark(), ret,
@@ -116,13 +102,8 @@ input_ffmpeg_open(const char *uri,
i->eof = false;
i->base.ready = true;
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
i->base.seekable = (i->h->seekable & AVIO_SEEKABLE_NORMAL) != 0;
i->base.size = avio_size(i->h);
-#else
- i->base.seekable = !i->h->is_streamed;
- i->base.size = url_filesize(i->h);
-#endif
/* hack to make MPD select the "ffmpeg" decoder plugin - since
avio.h doesn't tell us the MIME type of the resource, we
@@ -139,11 +120,7 @@ input_ffmpeg_read(struct input_stream *is, void *ptr, size_t size,
{
struct input_ffmpeg *i = (struct input_ffmpeg *)is;
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
int ret = avio_read(i->h, (unsigned char *)ptr, size);
-#else
- int ret = url_read(i->h, (unsigned char *)ptr, size);
-#endif
if (ret <= 0) {
if (ret < 0)
g_set_error(error_r, ffmpeg_quark(), 0,
@@ -162,11 +139,7 @@ input_ffmpeg_close(struct input_stream *is)
{
struct input_ffmpeg *i = (struct input_ffmpeg *)is;
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
avio_close(i->h);
-#else
- url_close(i->h);
-#endif
input_stream_deinit(&i->base);
g_free(i);
}
@@ -184,11 +157,7 @@ input_ffmpeg_seek(struct input_stream *is, goffset offset, int whence,
G_GNUC_UNUSED GError **error_r)
{
struct input_ffmpeg *i = (struct input_ffmpeg *)is;
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
int64_t ret = avio_seek(i->h, offset, whence);
-#else
- int64_t ret = url_seek(i->h, offset, whence);
-#endif
if (ret >= 0) {
i->eof = false;