compat: fix old pixfmt. compatible with latest ffmpeg

This commit is contained in:
wang-bin
2015-09-21 20:41:56 +08:00
parent 9ce7a391d3
commit 7a132dfd4c
5 changed files with 42 additions and 21 deletions
+11
View File
@@ -313,3 +313,14 @@ const char *get_codec_long_name(enum AVCodecID id)
return "unknown_codec";
}
#if !AV_MODULE_CHECK(LIBAVFILTER, 2, 22, 0, 79, 100) //FF_API_AVFILTERPAD_PUBLIC
const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
{
return pads[pad_idx].name;
}
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
{
return pads[pad_idx].type;
}
#endif
+2 -2
View File
@@ -36,8 +36,8 @@ public:
: interlaced(false)
, w_in(0),h_in(0)
, w_out(0),h_out(0)
, fmt_in(PIX_FMT_YUV420P)
, fmt_out(PIX_FMT_RGB32)
, fmt_in(QTAV_PIX_FMT_C(YUV420P))
, fmt_out(QTAV_PIX_FMT_C(RGB32))
, brightness(0)
, contrast(0)
, saturation(0)
+23 -9
View File
@@ -81,10 +81,6 @@ extern "C"
#include <libavfilter/avfilter.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#if QTAV_USE_FFMPEG(LIBAVFILTER)
/* used ffmpeg's by avfilter_copy_buf_props (now in avfilter.h). all deprecated in new versions*/
#include <libavfilter/avcodec.h>
#endif
#endif //QTAV_HAVE(AVFILTER)
#if QTAV_HAVE(AVDEVICE)
@@ -394,11 +390,29 @@ void av_packet_free_side_data(AVPacket *pkt);
void avcodec_free_context(AVCodecContext **avctx);
#endif
#ifndef FF_API_OLD_GRAPH_PARSE
#define avfilter_graph_parse_ptr(...) avfilter_graph_parse(__VA_ARGS__)
#endif //FF_API_OLD_GRAPH_PARSE
// helper functions
// ffmpeg2.0 2013-07-03 - 838bd73 - lavfi 3.78.100 - avfilter.h
#if QTAV_USE_LIBAV(LIBAVFILTER)
#define avfilter_graph_parse_ptr(pGraph, pFilters, ppInputs, ppOutputs, pLog) avfilter_graph_parse(pGraph, pFilters, *ppInputs, *ppOutputs, pLog)
#elif !FFMPEG_MODULE_CHECK(LIBAVFILTER, 3, 78, 100)
#define avfilter_graph_parse_ptr(pGraph, pFilters, ppInputs, ppOutputs, pLog) avfilter_graph_parse(pGraph, pFilters, ppInputs, ppOutputs, pLog)
#endif
//ffmpeg1.0 2012-06-12 - c7b9eab / 84b9fbe - lavfi 2.79.100 / 2.22.0 - avfilter.h
#if !AV_MODULE_CHECK(LIBAVFILTER, 2, 22, 0, 79, 100) //FF_API_AVFILTERPAD_PUBLIC
const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
#endif
///ffmpeg1.0 lavfi 2.74.100 / 2.17.0. was in ffmpeg <libavfilter/avcodec.h> in old ffmpeg and now are in avfilter.h and deprecated. declare here to avoid version check
#if QTAV_USE_FFMPEG(LIBAVFILTER)
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct AVFilterBufferRef;
int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/* helper functions */
const char *get_codec_long_name(AVCodecID id);
#define AV_RUN_CHECK(FUNC, RETURN, ...) do { \
+1 -1
View File
@@ -168,7 +168,7 @@ AVPixelFormat VideoDecoderFFmpegHWPrivate::getFormat(struct AVCodecContext *p_co
}
if (!can_hwaccel)
goto end;
for (size_t i = 0; pi_fmt[i] != PIX_FMT_NONE; i++) {
for (size_t i = 0; pi_fmt[i] != QTAV_PIX_FMT_C(NONE); i++) {
if (vaPixelFormat() != pi_fmt[i])
continue;
/* We try to call setup when possible to detect errors when possible (later is too late) */
+5 -9
View File
@@ -156,11 +156,7 @@ public:
}
} scoped_in(&inputs), scoped_out(&outputs);
//avfilter_graph_parse, avfilter_graph_parse2?
#if QTAV_USE_FFMPEG(LIBAVFILTER)
AV_ENSURE_OK(avfilter_graph_parse_ptr(filter_graph, options.toUtf8().constData(), &inputs, &outputs, NULL), false);
#else
AV_ENSURE_OK(avfilter_graph_parse(filter_graph, options.toUtf8().constData(), inputs, outputs, NULL), false);
#endif //QTAV_USE_FFMPEG(LIBAVFILTER)
AV_ENSURE_OK(avfilter_graph_config(filter_graph, NULL), false);
avframe = av_frame_alloc();
status = LibAVFilter::ConfigureOk;
@@ -275,7 +271,7 @@ QStringList LibAVFilter::registeredFilters(int type)
#if QTAV_HAVE(AVFILTER)
avfilter_register_all();
const AVFilter* f = NULL;
const AVFilterPad* fp = NULL;
AVFilterPad* fp = NULL; // no const in avfilter_pad_get_name() for ffmpeg<=1.2 libav<=9
#if AV_MODULE_CHECK(LIBAVFILTER, 3, 8, 0, 53, 100)
while ((f = avfilter_next(f))) {
#else
@@ -283,13 +279,13 @@ QStringList LibAVFilter::registeredFilters(int type)
while ((ff = av_filter_next(ff)) && *ff) {
f = (*ff);
#endif
fp = f->inputs;
fp = (AVFilterPad*)f->inputs;
// only check the 1st pad
if (!fp || !fp[0].name || fp[0].type != (AVMediaType)type)
if (!fp || !avfilter_pad_get_name(fp, 0) || avfilter_pad_get_type(fp, 0) != (AVMediaType)type)
continue;
fp = f->outputs;
fp = (AVFilterPad*)f->outputs;
// only check the 1st pad
if (!fp || !fp[0].name || fp[0].type != (AVMediaType)type)
if (!fp || !avfilter_pad_get_name(fp, 0) || avfilter_pad_get_type(fp, 0) != (AVMediaType)type)
continue;
filters.append(QLatin1String(f->name));
}