ffmpeg: Remove obsolete code

This commit is contained in:
Barrett17
2018-08-04 12:11:08 +02:00
parent 38fc668b2e
commit 334b8f3f9c
12 changed files with 1 additions and 150 deletions
@@ -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<int>(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<int>(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
@@ -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
@@ -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;
@@ -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 {
@@ -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;
@@ -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
@@ -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
@@ -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
{
@@ -13,9 +13,7 @@ extern "C" {
}
#if LIBAVCODEC_VERSION_INT > ((54 << 16) | (50 << 8))
typedef AVCodecID CodecID;
#endif
struct EncoderDescription {
@@ -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
}
@@ -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.
@@ -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