From 334b8f3f9c2dbea74ad5f289d0114f47d816619b Mon Sep 17 00:00:00 2001 From: Barrett17 Date: Fri, 3 Aug 2018 16:36:30 +0200 Subject: [PATCH] ffmpeg: Remove obsolete code --- .../media/plugins/ffmpeg/AVCodecDecoder.cpp | 29 +--------------- .../media/plugins/ffmpeg/AVCodecDecoder.h | 6 ---- .../media/plugins/ffmpeg/AVCodecEncoder.cpp | 33 ------------------- .../media/plugins/ffmpeg/AVCodecEncoder.h | 2 -- .../media/plugins/ffmpeg/AVFormatReader.cpp | 8 ----- .../media/plugins/ffmpeg/AVFormatWriter.cpp | 7 ---- .../media/plugins/ffmpeg/CodecTable.cpp | 8 ----- .../media/plugins/ffmpeg/EncoderTable.cpp | 24 -------------- .../media/plugins/ffmpeg/EncoderTable.h | 2 -- .../media/plugins/ffmpeg/FFmpegPlugin.cpp | 2 -- src/add-ons/media/plugins/ffmpeg/gfx_util.cpp | 26 --------------- src/add-ons/media/plugins/ffmpeg/gfx_util.h | 4 --- 12 files changed, 1 insertion(+), 150 deletions(-) diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp index 13ec9f3834..f3a2880369 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp @@ -51,16 +51,7 @@ static int sDumpedPackets = 0; #endif - -#if LIBAVCODEC_VERSION_INT > ((54 << 16) | (50 << 8)) typedef AVCodecID CodecID; -#endif -#if LIBAVCODEC_VERSION_INT < ((55 << 16) | (45 << 8)) -#define av_frame_alloc avcodec_alloc_frame -#define av_frame_unref avcodec_get_frame_defaults -#define av_frame_free avcodec_free_frame -#endif - struct wave_format_ex { uint16 format_tag; @@ -127,14 +118,11 @@ AVCodecDecoder::AVCodecDecoder() fDecodedDataBuffer(av_frame_alloc()), fDecodedDataBufferOffset(0), - fDecodedDataBufferSize(0) -#if LIBAVCODEC_VERSION_INT >= ((57 << 16) | (0 << 8)) - , + fDecodedDataBufferSize(0), fBufferSinkContext(NULL), fBufferSourceContext(NULL), fFilterGraph(NULL), fFilterFrame(NULL) -#endif { TRACE("AVCodecDecoder::AVCodecDecoder()\n"); @@ -173,10 +161,8 @@ AVCodecDecoder::~AVCodecDecoder() av_free(fContext); av_free(fDecodedDataBuffer); -#if LIBAVCODEC_VERSION_INT >= ((57 << 16) | (0 << 8)) av_frame_free(&fFilterFrame); avfilter_graph_free(&fFilterGraph); -#endif #if USE_SWS_FOR_COLOR_SPACE_CONVERSION if (fSwsContext != NULL) @@ -799,10 +785,8 @@ AVCodecDecoder::_ApplyEssentialAudioContainerPropertiesToContext() = static_cast(containerProperties.frame_size); ConvertRawAudioFormatToAVSampleFormat( containerProperties.output.format, fContext->sample_fmt); -#if LIBAVCODEC_VERSION_INT > ((52 << 16) | (114 << 8)) ConvertRawAudioFormatToAVSampleFormat( containerProperties.output.format, fContext->request_sample_fmt); -#endif fContext->sample_rate = static_cast(containerProperties.output.frame_rate); fContext->channels @@ -1648,18 +1632,10 @@ AVCodecDecoder::_DeinterlaceAndColorConvertVideoFrame() avpicture_alloc(&deinterlacedPicture, fContext->pix_fmt, displayWidth, displayHeight); -#if LIBAVCODEC_VERSION_INT < ((57 << 16) | (0 << 8)) - if (avpicture_deinterlace(&deinterlacedPicture, &rawPicture, - fContext->pix_fmt, displayWidth, displayHeight) < 0) { - TRACE("[v] avpicture_deinterlace() - error\n"); - } else - useDeinterlacedPicture = true; -#else // deinterlace implemented using avfilter _ProcessFilterGraph(&deinterlacedPicture, &rawPicture, fContext->pix_fmt, displayWidth, displayHeight); useDeinterlacedPicture = true; -#endif } // Some decoders do not set pix_fmt until they have decoded 1 frame @@ -1740,8 +1716,6 @@ AVCodecDecoder::_DeinterlaceAndColorConvertVideoFrame() } -#if LIBAVCODEC_VERSION_INT >= ((57 << 16) | (0 << 8)) - /*! \brief Init the deinterlace filter graph. \returns B_OK the filter graph could be built. @@ -1835,4 +1809,3 @@ AVCodecDecoder::_ProcessFilterGraph(AVPicture *dst, const AVPicture *src, av_frame_unref(fFilterFrame); return B_OK; } -#endif diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.h b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.h index b2978cb502..4eb4e00564 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.h +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.h @@ -19,11 +19,9 @@ extern "C" { #include "avcodec.h" -#if LIBAVCODEC_VERSION_INT >= ((57 << 16) | (0 << 8)) #include "avfilter.h" #include "buffersink.h" #include "buffersrc.h" -#endif #include "swresample.h" #include "swscale.h" } @@ -100,14 +98,12 @@ private: void _UpdateMediaHeaderForVideoFrame(); status_t _DeinterlaceAndColorConvertVideoFrame(); -#if LIBAVCODEC_VERSION_INT >= ((57 << 16) | (0 << 8)) // video deinterlace filter graph status_t _InitFilterGraph(enum AVPixelFormat pixfmt, int32 width, int32 height); status_t _ProcessFilterGraph(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pixfmt, int32 width, int32 height); -#endif media_header fHeader; // Contains the properties of the current @@ -158,7 +154,6 @@ private: AVPacket fTempPacket; -#if LIBAVCODEC_VERSION_INT >= ((57 << 16) | (0 << 8)) // video deinterlace feature AVFilterContext* fBufferSinkContext; AVFilterContext* fBufferSourceContext; @@ -167,7 +162,6 @@ private: int32 fLastWidth; int32 fLastHeight; enum AVPixelFormat fLastPixfmt; -#endif }; #endif // AVCODEC_DECODER_H diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp index c6608cb8b8..752de24c29 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.cpp @@ -35,18 +35,6 @@ extern "C" { static const size_t kDefaultChunkBufferSize = 2 * 1024 * 1024; -#if LIBAVCODEC_VERSION_INT < ((54 << 16) | (50 << 8)) -#define AV_PIX_FMT_NONE PIX_FMT_NONE -#define AV_CODEC_ID_NONE CODEC_ID_NONE -#define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO -#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO -#endif -#if LIBAVCODEC_VERSION_INT < ((55 << 16) | (45 << 8)) -#define av_frame_alloc avcodec_alloc_frame -#define av_frame_unref avcodec_get_frame_defaults -#define av_frame_free avcodec_free_frame -#endif - AVCodecEncoder::AVCodecEncoder(uint32 codecID, int bitRateScale) : @@ -716,17 +704,12 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount, fDstFrame.linesize); // Encode one video chunk/frame. -#if LIBAVCODEC_VERSION_INT < ((55 << 16) | (45 << 8)) - int usedBytes = avcodec_encode_video(fContext, fChunkBuffer, - kDefaultChunkBufferSize, fFrame); -#else int gotPacket; AVPacket pkt; pkt.data = NULL; pkt.size = 0; av_init_packet(&pkt); int usedBytes = avcodec_encode_video2(fContext, &pkt, fFrame, &gotPacket); -#endif // avcodec.h says we need to set it. fFrame->pts++; @@ -735,17 +718,6 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount, return B_ERROR; } -#if LIBAVCODEC_VERSION_INT < ((55 << 16) | (45 << 8)) - // Maybe we need to use this PTS to calculate start_time: - if (fContext->coded_frame->pts != kNoPTSValue) { - TRACE(" codec frame PTS: %lld (codec time_base: %d/%d)\n", - fContext->coded_frame->pts, fContext->time_base.num, - fContext->time_base.den); - } else { - TRACE(" codec frame PTS: N/A (codec time_base: %d/%d)\n", - fContext->time_base.num, fContext->time_base.den); - } -#else // Maybe we need to use this PTS to calculate start_time: if (pkt.pts != AV_NOPTS_VALUE) { TRACE(" codec frame PTS: %lld (codec time_base: %d/%d)\n", @@ -755,7 +727,6 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount, TRACE(" codec frame PTS: N/A (codec time_base: %d/%d)\n", fContext->time_base.num, fContext->time_base.den); } -#endif // Setup media_encode_info, most important is the time stamp. info->start_time = (bigtime_t)(fFramesWritten * 1000000LL @@ -766,11 +737,7 @@ AVCodecEncoder::_EncodeVideo(const void* buffer, int64 frameCount, info->flags |= B_MEDIA_KEY_FRAME; // Write the chunk -#if LIBAVCODEC_VERSION_INT < ((55 << 16) | (45 << 8)) - ret = WriteChunk(fChunkBuffer, usedBytes, info); -#else ret = WriteChunk(pkt.data, pkt.size, info); -#endif if (ret != B_OK) { TRACE(" error writing chunk: %s\n", strerror(ret)); break; diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.h b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.h index 40cc42c808..b2e41625c2 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.h +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.h @@ -17,9 +17,7 @@ extern "C" { #include "EncoderPlugin.h" -#if LIBAVCODEC_VERSION_INT > ((54 << 16) | (50 << 8)) typedef AVCodecID CodecID; -#endif class AVCodecEncoder : public Encoder { diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp index bd7d8c29ee..211cd7a3bd 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp @@ -47,14 +47,6 @@ extern "C" { #define ERROR(a...) fprintf(stderr, a) -#if LIBAVCODEC_VERSION_INT < ((54 << 16) | (50 << 8)) -#define AV_CODEC_ID_PCM_S16BE CODEC_ID_PCM_S16BE -#define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE -#define AV_CODEC_ID_PCM_U16BE CODEC_ID_PCM_U16BE -#define AV_CODEC_ID_PCM_U16LE CODEC_ID_PCM_U16LE -#define AV_CODEC_ID_PCM_S8 CODEC_ID_PCM_S8 -#define AV_CODEC_ID_PCM_U8 CODEC_ID_PCM_U8 -#endif static const int64 kNoPTSValue = AV_NOPTS_VALUE; diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp index 8a101b58fa..edd64a8e98 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp @@ -42,11 +42,6 @@ extern "C" { #define ERROR(a...) fprintf(stderr, a) -#if LIBAVCODEC_VERSION_INT < ((54 << 16) | (50 << 8)) -#define AV_CODEC_ID_NONE CODEC_ID_NONE -#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P -#endif - static const size_t kIOBufferSize = 64 * 1024; // TODO: This could depend on the BMediaFile creation flags, IIRC, @@ -58,9 +53,7 @@ static const size_t kIOBufferSize = 64 * 1024; #define OPEN_CODEC_CONTEXT 1 #define GET_CONTEXT_DEFAULTS 0 -#if LIBAVCODEC_VERSION_INT > ((54 << 16) | (50 << 8)) typedef AVCodecID CodecID; -#endif // #pragma mark - AVFormatWriter::StreamCookie diff --git a/src/add-ons/media/plugins/ffmpeg/CodecTable.cpp b/src/add-ons/media/plugins/ffmpeg/CodecTable.cpp index 302b1587ad..b27337f53e 100644 --- a/src/add-ons/media/plugins/ffmpeg/CodecTable.cpp +++ b/src/add-ons/media/plugins/ffmpeg/CodecTable.cpp @@ -12,15 +12,7 @@ extern "C" { } -#if LIBAVCODEC_VERSION_INT > ((54 << 16) | (50 << 8)) typedef AVCodecID CodecID; -#else -#define AV_CODEC_ID_NONE CODEC_ID_NONE -#define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE -#define AV_CODEC_ID_RAWVIDEO CODEC_ID_RAWVIDEO -#define AV_CODEC_ID_DVD_SUBTITLE CODEC_ID_DVD_SUBTITLE -#define AV_CODEC_ID_ADPCM_IMA_QT CODEC_ID_ADPCM_IMA_QT -#endif //XXX: newer versions have it in libavformat/internal.h diff --git a/src/add-ons/media/plugins/ffmpeg/EncoderTable.cpp b/src/add-ons/media/plugins/ffmpeg/EncoderTable.cpp index 2b300e612e..d0987b5ffe 100644 --- a/src/add-ons/media/plugins/ffmpeg/EncoderTable.cpp +++ b/src/add-ons/media/plugins/ffmpeg/EncoderTable.cpp @@ -7,30 +7,6 @@ #include "EncoderTable.h" -#if LIBAVCODEC_VERSION_INT < ((54 << 16) | (50 << 8)) -#define AV_CODEC_ID_NONE CODEC_ID_NONE -#define AV_CODEC_ID_PCM_F32LE CODEC_ID_PCM_F32LE -#define AV_CODEC_ID_PCM_F64LE CODEC_ID_PCM_F64LE -#define AV_CODEC_ID_PCM_S32LE CODEC_ID_PCM_S32LE -#define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE -#define AV_CODEC_ID_PCM_U8 CODEC_ID_PCM_U8 -#define AV_CODEC_ID_PCM_F32BE CODEC_ID_PCM_F32BE -#define AV_CODEC_ID_PCM_F64BE CODEC_ID_PCM_F64BE -#define AV_CODEC_ID_PCM_S32BE CODEC_ID_PCM_S32BE -#define AV_CODEC_ID_PCM_S16BE CODEC_ID_PCM_S16BE -#define AV_CODEC_ID_AAC CODEC_ID_AAC -#define AV_CODEC_ID_AC3 CODEC_ID_AC3 -#define AV_CODEC_ID_DVVIDEO CODEC_ID_DVVIDEO -#define AV_CODEC_ID_FLAC CODEC_ID_FLAC -#define AV_CODEC_ID_MJPEG CODEC_ID_MJPEG -#define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO -#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO -#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4 -#define AV_CODEC_ID_THEORA CODEC_ID_THEORA -#endif - - - const EncoderDescription gEncoderTable[] = { // Video codecs { diff --git a/src/add-ons/media/plugins/ffmpeg/EncoderTable.h b/src/add-ons/media/plugins/ffmpeg/EncoderTable.h index c2d36184b8..0ebe50d4f9 100644 --- a/src/add-ons/media/plugins/ffmpeg/EncoderTable.h +++ b/src/add-ons/media/plugins/ffmpeg/EncoderTable.h @@ -13,9 +13,7 @@ extern "C" { } -#if LIBAVCODEC_VERSION_INT > ((54 << 16) | (50 << 8)) typedef AVCodecID CodecID; -#endif struct EncoderDescription { diff --git a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp index 83697b41bc..b1545ef18b 100644 --- a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp +++ b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp @@ -87,9 +87,7 @@ FFmpegPlugin::GlobalInitilizer::GlobalInitilizer() av_register_all(); // This will also call av_codec_init() by registering codecs. -#if LIBAVCODEC_VERSION_INT >= ((57 << 16) | (0 << 8)) avfilter_register_all(); -#endif } diff --git a/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp b/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp index f20c61c251..f641744d34 100644 --- a/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp +++ b/src/add-ons/media/plugins/ffmpeg/gfx_util.cpp @@ -22,32 +22,6 @@ extern "C" { #define TRACE(a...) #endif -#if LIBAVCODEC_VERSION_INT < ((54 << 16) | (50 << 8)) -#define AVPixelFormat PixelFormat -#define AV_PIX_FMT_NONE PIX_FMT_NONE -#define AV_PIX_FMT_YUV410P PIX_FMT_YUV410P -#define AV_PIX_FMT_YUV411P PIX_FMT_YUV411P -#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P -#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P -#define AV_PIX_FMT_YUV422P PIX_FMT_YUV422P -#define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P -#define AV_PIX_FMT_YUYV422 PIX_FMT_YUYV422 -#define AV_PIX_FMT_YUV420P10LE PIX_FMT_YUV420P10LE -#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P -#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24 -#define AV_PIX_FMT_BGR24 PIX_FMT_BGR24 -#define AV_PIX_FMT_RGB565 PIX_FMT_RGB565 -#define AV_PIX_FMT_RGB555 PIX_FMT_RGB555 -#define AV_PIX_FMT_GRAY8 PIX_FMT_GRAY8 -#define AV_PIX_FMT_MONOBLACK PIX_FMT_MONOBLACK -#define AV_PIX_FMT_PAL8 PIX_FMT_PAL8 -#define AV_PIX_FMT_BGR32 PIX_FMT_BGR32 -#define AV_PIX_FMT_BGR565 PIX_FMT_BGR565 -#define AV_PIX_FMT_BGR555 PIX_FMT_BGR555 -#define AV_PIX_FMT_RGB32 PIX_FMT_RGB32 -#define AV_PIX_FMT_GBRP PIX_FMT_GBRP -#endif - //! This function will try to find the best colorspaces for both the ff-codec // and the Media Kit sides. diff --git a/src/add-ons/media/plugins/ffmpeg/gfx_util.h b/src/add-ons/media/plugins/ffmpeg/gfx_util.h index cc1f63806d..aa8aa4f301 100644 --- a/src/add-ons/media/plugins/ffmpeg/gfx_util.h +++ b/src/add-ons/media/plugins/ffmpeg/gfx_util.h @@ -28,10 +28,6 @@ extern "C" { #include "libavcodec/avcodec.h" } -#if LIBAVCODEC_VERSION_INT < ((54 << 16) | (50 << 8)) -typedef PixelFormat AVPixelFormat; -#endif - // this function will be used by the wrapper to write into // the Media Kit provided buffer from the self-allocated ffmpeg codec buffer