* commit '7e2561fa8313982aa21f7657953eedeeb33b210d':
lavfi: Use ff_get_video_buffer in all filters using hwframes
vf_hwupload_cuda: Fix build error
Merged-by: Matthieu Bouron <matthieu.bouron@gmail.com>
... | ... |
@@ -434,13 +434,11 @@ static int process_frame(AVFilterContext *ctx, const AVFrame *in, |
434 | 434 |
mfxStatus err; |
435 | 435 |
int ret, again = 0; |
436 | 436 |
|
437 |
- out = av_frame_alloc(); |
|
438 |
- if (!out) |
|
439 |
- return AVERROR(ENOMEM); |
|
440 |
- |
|
441 |
- ret = av_hwframe_get_buffer(s->hw_frames_ctx, out, 0); |
|
442 |
- if (ret < 0) |
|
437 |
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
|
438 |
+ if (!out) { |
|
439 |
+ ret = AVERROR(ENOMEM); |
|
443 | 440 |
goto fail; |
441 |
+ } |
|
444 | 442 |
|
445 | 443 |
surf_out = (mfxFrameSurface1*)out->data[3]; |
446 | 444 |
surf_out->Info.CropW = outlink->w; |
... | ... |
@@ -159,15 +159,10 @@ static int hwupload_filter_frame(AVFilterLink *link, AVFrame *input) |
159 | 159 |
if (input->format == outlink->format) |
160 | 160 |
return ff_filter_frame(outlink, input); |
161 | 161 |
|
162 |
- output = av_frame_alloc(); |
|
162 |
+ output = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
|
163 | 163 |
if (!output) { |
164 |
- err = AVERROR(ENOMEM); |
|
165 |
- goto fail; |
|
166 |
- } |
|
167 |
- |
|
168 |
- err = av_hwframe_get_buffer(ctx->hwframes_ref, output, 0); |
|
169 |
- if (err < 0) { |
|
170 | 164 |
av_log(ctx, AV_LOG_ERROR, "Failed to allocate frame to upload to.\n"); |
165 |
+ err = AVERROR(ENOMEM); |
|
171 | 166 |
goto fail; |
172 | 167 |
} |
173 | 168 |
|
... | ... |
@@ -113,21 +113,17 @@ static int cudaupload_config_output(AVFilterLink *outlink) |
113 | 113 |
static int cudaupload_filter_frame(AVFilterLink *link, AVFrame *in) |
114 | 114 |
{ |
115 | 115 |
AVFilterContext *ctx = link->dst; |
116 |
- CudaUploadContext *s = ctx->priv; |
|
116 |
+ AVFilterLink *outlink = ctx->outputs[0]; |
|
117 | 117 |
|
118 | 118 |
AVFrame *out = NULL; |
119 | 119 |
int ret; |
120 | 120 |
|
121 |
- out = av_frame_alloc(); |
|
121 |
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
|
122 | 122 |
if (!out) { |
123 | 123 |
ret = AVERROR(ENOMEM); |
124 | 124 |
goto fail; |
125 | 125 |
} |
126 | 126 |
|
127 |
- ret = av_hwframe_get_buffer(s->hwframe, out, 0); |
|
128 |
- if (ret < 0) |
|
129 |
- goto fail; |
|
130 |
- |
|
131 | 127 |
out->width = in->width; |
132 | 128 |
out->height = in->height; |
133 | 129 |
|
... | ... |
@@ -530,16 +530,12 @@ static int qsvscale_filter_frame(AVFilterLink *link, AVFrame *in) |
530 | 530 |
AVFrame *out = NULL; |
531 | 531 |
int ret = 0; |
532 | 532 |
|
533 |
- out = av_frame_alloc(); |
|
533 |
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
|
534 | 534 |
if (!out) { |
535 | 535 |
ret = AVERROR(ENOMEM); |
536 | 536 |
goto fail; |
537 | 537 |
} |
538 | 538 |
|
539 |
- ret = av_hwframe_get_buffer(s->out_frames_ref, out, 0); |
|
540 |
- if (ret < 0) |
|
541 |
- goto fail; |
|
542 |
- |
|
543 | 539 |
do { |
544 | 540 |
err = MFXVideoVPP_RunFrameVPPAsync(s->session, |
545 | 541 |
(mfxFrameSurface1*)in->data[3], |
... | ... |
@@ -32,6 +32,7 @@ |
32 | 32 |
#include "formats.h" |
33 | 33 |
#include "internal.h" |
34 | 34 |
#include "scale.h" |
35 |
+#include "video.h" |
|
35 | 36 |
|
36 | 37 |
typedef struct ScaleVAAPIContext { |
37 | 38 |
const AVClass *class; |
... | ... |
@@ -288,19 +289,13 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame) |
288 | 288 |
av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale input.\n", |
289 | 289 |
input_surface); |
290 | 290 |
|
291 |
- output_frame = av_frame_alloc(); |
|
291 |
+ output_frame = ff_get_video_buffer(outlink, ctx->output_width, |
|
292 |
+ ctx->output_height); |
|
292 | 293 |
if (!output_frame) { |
293 |
- av_log(ctx, AV_LOG_ERROR, "Failed to allocate output frame."); |
|
294 | 294 |
err = AVERROR(ENOMEM); |
295 | 295 |
goto fail; |
296 | 296 |
} |
297 | 297 |
|
298 |
- err = av_hwframe_get_buffer(ctx->output_frames_ref, output_frame, 0); |
|
299 |
- if (err < 0) { |
|
300 |
- av_log(ctx, AV_LOG_ERROR, "Failed to get surface for " |
|
301 |
- "output: %d\n.", err); |
|
302 |
- } |
|
303 |
- |
|
304 | 298 |
output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3]; |
305 | 299 |
av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale output.\n", |
306 | 300 |
output_surface); |