[FFmpeg-cvslog] lavfi: Use ff_get_video_buffer in all filters using hwframes
Mark Thompson
git at videolan.org
Thu Mar 30 00:36:38 EEST 2017
ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Mon Oct 31 22:14:10 2016 +0000| [7e2561fa8313982aa21f7657953eedeeb33b210d] | committer: Mark Thompson
lavfi: Use ff_get_video_buffer in all filters using hwframes
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e2561fa8313982aa21f7657953eedeeb33b210d
---
libavfilter/vf_deinterlace_qsv.c | 10 ++++------
libavfilter/vf_hwupload.c | 9 ++-------
libavfilter/vf_hwupload_cuda.c | 6 +-----
libavfilter/vf_scale_qsv.c | 6 +-----
libavfilter/vf_scale_vaapi.c | 11 +++--------
5 files changed, 11 insertions(+), 31 deletions(-)
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index b26a900..36eea15 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -433,13 +433,11 @@ static int process_frame(AVFilterContext *ctx, const AVFrame *in,
mfxStatus err;
int ret, again = 0;
- out = av_frame_alloc();
- if (!out)
- return AVERROR(ENOMEM);
-
- ret = av_hwframe_get_buffer(s->hw_frames_ctx, out, 0);
- if (ret < 0)
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+ if (!out) {
+ ret = AVERROR(ENOMEM);
goto fail;
+ }
surf_out = (mfxFrameSurface1*)out->data[3];
surf_out->Info.CropW = outlink->w;
diff --git a/libavfilter/vf_hwupload.c b/libavfilter/vf_hwupload.c
index c438d5a..8c43e00 100644
--- a/libavfilter/vf_hwupload.c
+++ b/libavfilter/vf_hwupload.c
@@ -161,15 +161,10 @@ static int hwupload_filter_frame(AVFilterLink *link, AVFrame *input)
if (input->format == outlink->format)
return ff_filter_frame(outlink, input);
- output = av_frame_alloc();
+ output = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!output) {
- err = AVERROR(ENOMEM);
- goto fail;
- }
-
- err = av_hwframe_get_buffer(ctx->hwframes_ref, output, 0);
- if (err < 0) {
av_log(ctx, AV_LOG_ERROR, "Failed to allocate frame to upload to.\n");
+ err = AVERROR(ENOMEM);
goto fail;
}
diff --git a/libavfilter/vf_hwupload_cuda.c b/libavfilter/vf_hwupload_cuda.c
index dfb3506..0ab5276 100644
--- a/libavfilter/vf_hwupload_cuda.c
+++ b/libavfilter/vf_hwupload_cuda.c
@@ -156,16 +156,12 @@ static int cudaupload_filter_frame(AVFilterLink *link, AVFrame *in)
AVFrame *out = NULL;
int ret;
- out = av_frame_alloc();
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
ret = AVERROR(ENOMEM);
goto fail;
}
- ret = av_hwframe_get_buffer(s->hwframe, out, 0);
- if (ret < 0)
- goto fail;
-
out->width = in->width;
out->height = in->height;
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index e5c3da5..f7c1c55 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -528,16 +528,12 @@ static int qsvscale_filter_frame(AVFilterLink *link, AVFrame *in)
AVFrame *out = NULL;
int ret = 0;
- out = av_frame_alloc();
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
ret = AVERROR(ENOMEM);
goto fail;
}
- ret = av_hwframe_get_buffer(s->out_frames_ref, out, 0);
- if (ret < 0)
- goto fail;
-
do {
err = MFXVideoVPP_RunFrameVPPAsync(s->session,
(mfxFrameSurface1*)in->data[3],
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 704456d..67648a9 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -31,6 +31,7 @@
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
+#include "video.h"
typedef struct ScaleVAAPIContext {
const AVClass *class;
@@ -274,19 +275,13 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale input.\n",
input_surface);
- output_frame = av_frame_alloc();
+ output_frame = ff_get_video_buffer(outlink, ctx->output_width,
+ ctx->output_height);
if (!output_frame) {
- av_log(ctx, AV_LOG_ERROR, "Failed to allocate output frame.");
err = AVERROR(ENOMEM);
goto fail;
}
- err = av_hwframe_get_buffer(ctx->output_frames_ref, output_frame, 0);
- if (err < 0) {
- av_log(ctx, AV_LOG_ERROR, "Failed to get surface for "
- "output: %d\n.", err);
- }
-
output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3];
av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale output.\n",
output_surface);
More information about the ffmpeg-cvslog
mailing list