From c96693ef12727f6af405c91363fab21b5f58e9b6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Apr 2013 11:36:14 +0200 Subject: ffmpeg_decoder_plugin: drop support for old versions --- src/decoder/ffmpeg_decoder_plugin.c | 131 ------------------------------------ src/decoder/ffmpeg_metadata.c | 8 --- src/decoder/ffmpeg_metadata.h | 8 --- 3 files changed, 147 deletions(-) diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index cffbefcc..41f15989 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -40,9 +40,7 @@ #include #include #include -#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0) #include -#endif #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "ffmpeg" @@ -82,11 +80,7 @@ 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]; }; @@ -119,19 +113,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; @@ -146,15 +132,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); @@ -162,9 +143,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 @@ -188,33 +166,12 @@ 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; } -#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 static double time_from_ffmpeg(int64_t t, const AVRational time_base) @@ -233,7 +190,6 @@ time_to_ffmpeg(double t, const AVRational time_base) time_base); } -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0) /** * Copy PCM data from a AVFrame to an interleaved buffer. */ @@ -265,7 +221,6 @@ copy_interleave_frame(const AVCodecContext *codec_context, return data_size; } -#endif static enum decoder_command ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is, @@ -277,34 +232,17 @@ 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) #define AVCODEC_MAX_AUDIO_FRAME_SIZE 50000 uint8_t aligned_buffer[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16]; 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 = align16(audio_buf, &buffer_size); -#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 cmd == DECODE_COMMAND_NONE) { int audio_size = buffer_size; -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0) AVFrame frame; int got_frame = 0; int len = avcodec_decode_audio4(codec_context, @@ -319,15 +257,6 @@ 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) - 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 */ @@ -335,13 +264,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; @@ -357,18 +281,10 @@ static enum sample_format ffmpeg_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context) { switch (codec_context->sample_fmt) { -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1) case AV_SAMPLE_FMT_S16: -#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: -#else - case SAMPLE_FMT_S32: -#endif return SAMPLE_FORMAT_S32; default: @@ -438,19 +354,11 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) return; } -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,6,0) const int find_result = avformat_find_stream_info(format_context, NULL); -#else - const int find_result = av_find_stream_info(format_context); -#endif if (find_result < 0) { g_warning("Couldn't find stream info\n"); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&format_context); -#else - av_close_input_stream(format_context); -#endif mpd_ffmpeg_stream_close(stream); return; } @@ -458,11 +366,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) int audio_stream = ffmpeg_find_audio_stream(format_context); if (audio_stream == -1) { g_warning("No audio stream inside\n"); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&format_context); -#else - av_close_input_stream(format_context); -#endif mpd_ffmpeg_stream_close(stream); return; } @@ -477,11 +381,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) if (!codec) { g_warning("Unsupported audio codec\n"); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&format_context); -#else - av_close_input_stream(format_context); -#endif mpd_ffmpeg_stream_close(stream); return; } @@ -494,11 +394,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) codec_context->channels, &error)) { g_warning("%s", error->message); g_error_free(error); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&format_context); -#else - av_close_input_stream(format_context); -#endif mpd_ffmpeg_stream_close(stream); return; } @@ -508,18 +404,10 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) values into AVCodecContext.channels - a change that will be 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); -#else - const int open_result = avcodec_open(codec_context, codec); -#endif if (open_result < 0) { g_warning("Could not open codec\n"); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&format_context); -#else - av_close_input_stream(format_context); -#endif mpd_ffmpeg_stream_close(stream); return; } @@ -563,11 +451,7 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) } while (cmd != DECODE_COMMAND_STOP); avcodec_close(codec_context); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&format_context); -#else - av_close_input_stream(format_context); -#endif mpd_ffmpeg_stream_close(stream); } @@ -591,18 +475,10 @@ ffmpeg_scan_stream(struct input_stream *is, return false; } -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,6,0) const int find_result = avformat_find_stream_info(f, NULL); -#else - const int find_result = av_find_stream_info(f); -#endif if (find_result < 0) { -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&f); -#else - av_close_input_stream(f); -#endif mpd_ffmpeg_stream_close(stream); return false; } @@ -611,9 +487,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); @@ -621,11 +494,7 @@ ffmpeg_scan_stream(struct input_stream *is, ffmpeg_scan_dictionary(f->streams[idx]->metadata, handler, handler_ctx); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) avformat_close_input(&f); -#else - av_close_input_stream(f); -#endif mpd_ffmpeg_stream_close(stream); return true; diff --git a/src/decoder/ffmpeg_metadata.c b/src/decoder/ffmpeg_metadata.c index 3ef774f6..bc51363c 100644 --- a/src/decoder/ffmpeg_metadata.c +++ b/src/decoder/ffmpeg_metadata.c @@ -26,9 +26,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 }, @@ -50,7 +47,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, @@ -63,8 +59,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) @@ -78,8 +72,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/ffmpeg_metadata.h b/src/decoder/ffmpeg_metadata.h index 60658f47..81255a66 100644 --- a/src/decoder/ffmpeg_metadata.h +++ b/src/decoder/ffmpeg_metadata.h @@ -22,15 +22,7 @@ #include #include -#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0) #include -#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; -- cgit v1.2.3