FFmpeg  4.4.9
qsvvpp.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file
21  * Intel Quick Sync Video VPP base function
22  */
23 
24 #include "libavutil/common.h"
25 #include "libavutil/mathematics.h"
26 #include "libavutil/hwcontext.h"
28 #include "libavutil/time.h"
29 #include "libavutil/pixdesc.h"
30 
31 #include "internal.h"
32 #include "qsvvpp.h"
33 #include "video.h"
34 
35 #define IS_VIDEO_MEMORY(mode) (mode & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \
36  MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
37 #define IS_OPAQUE_MEMORY(mode) (mode & MFX_MEMTYPE_OPAQUE_FRAME)
38 #define IS_SYSTEM_MEMORY(mode) (mode & MFX_MEMTYPE_SYSTEM_MEMORY)
39 
40 typedef struct QSVFrame {
41  AVFrame *frame;
42  mfxFrameSurface1 *surface;
43  mfxFrameSurface1 surface_internal; /* for system memory */
44  struct QSVFrame *next;
45 } QSVFrame;
46 
47 /* abstract struct for all QSV filters */
48 struct QSVVPPContext {
49  mfxSession session;
50  int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame);/* callback */
51  enum AVPixelFormat out_sw_format; /* Real output format */
52  mfxVideoParam vpp_param;
53  mfxFrameInfo *frame_infos; /* frame info for each input */
54 
55  /* members related to the input/output surface */
62  mfxFrameSurface1 **surface_ptrs_in;
63  mfxFrameSurface1 **surface_ptrs_out;
64 
65  /* MFXVPP extern parameters */
66  mfxExtOpaqueSurfaceAlloc opaque_alloc;
67  mfxExtBuffer **ext_buffers;
69 };
70 
71 static const mfxHandleType handle_types[] = {
72  MFX_HANDLE_VA_DISPLAY,
73  MFX_HANDLE_D3D9_DEVICE_MANAGER,
74  MFX_HANDLE_D3D11_DEVICE,
75 };
76 
77 static const AVRational default_tb = { 1, 90000 };
78 
79 static const struct {
81  const char *desc;
82 } qsv_iopatterns[] = {
83  {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" },
84  {MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" },
85  {MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" },
86  {MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" },
87  {MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" },
88  {MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" },
89 };
90 
92  const char *extra_string)
93 {
94  const char *desc = NULL;
95 
96  for (int i = 0; i < FF_ARRAY_ELEMS(qsv_iopatterns); i++) {
98  desc = qsv_iopatterns[i].desc;
99  }
100  }
101  if (!desc)
102  desc = "unknown iopattern";
103 
104  av_log(log_ctx, AV_LOG_VERBOSE, "%s: %s\n", extra_string, desc);
105  return 0;
106 }
107 
108 static const struct {
109  mfxStatus mfxerr;
110  int averr;
111  const char *desc;
112 } qsv_errors[] = {
113  { MFX_ERR_NONE, 0, "success" },
114  { MFX_ERR_UNKNOWN, AVERROR_UNKNOWN, "unknown error" },
115  { MFX_ERR_NULL_PTR, AVERROR(EINVAL), "NULL pointer" },
116  { MFX_ERR_UNSUPPORTED, AVERROR(ENOSYS), "unsupported" },
117  { MFX_ERR_MEMORY_ALLOC, AVERROR(ENOMEM), "failed to allocate memory" },
118  { MFX_ERR_NOT_ENOUGH_BUFFER, AVERROR(ENOMEM), "insufficient input/output buffer" },
119  { MFX_ERR_INVALID_HANDLE, AVERROR(EINVAL), "invalid handle" },
120  { MFX_ERR_LOCK_MEMORY, AVERROR(EIO), "failed to lock the memory block" },
121  { MFX_ERR_NOT_INITIALIZED, AVERROR_BUG, "not initialized" },
122  { MFX_ERR_NOT_FOUND, AVERROR(ENOSYS), "specified object was not found" },
123  /* the following 3 errors should always be handled explicitly, so those "mappings"
124  * are for completeness only */
125  { MFX_ERR_MORE_DATA, AVERROR_UNKNOWN, "expect more data at input" },
126  { MFX_ERR_MORE_SURFACE, AVERROR_UNKNOWN, "expect more surface at output" },
127  { MFX_ERR_MORE_BITSTREAM, AVERROR_UNKNOWN, "expect more bitstream at output" },
128  { MFX_ERR_ABORTED, AVERROR_UNKNOWN, "operation aborted" },
129  { MFX_ERR_DEVICE_LOST, AVERROR(EIO), "device lost" },
130  { MFX_ERR_INCOMPATIBLE_VIDEO_PARAM, AVERROR(EINVAL), "incompatible video parameters" },
131  { MFX_ERR_INVALID_VIDEO_PARAM, AVERROR(EINVAL), "invalid video parameters" },
132  { MFX_ERR_UNDEFINED_BEHAVIOR, AVERROR_BUG, "undefined behavior" },
133  { MFX_ERR_DEVICE_FAILED, AVERROR(EIO), "device failed" },
134  { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio parameters" },
135  { MFX_ERR_INVALID_AUDIO_PARAM, AVERROR(EINVAL), "invalid audio parameters" },
136 
137  { MFX_WRN_IN_EXECUTION, 0, "operation in execution" },
138  { MFX_WRN_DEVICE_BUSY, 0, "device busy" },
139  { MFX_WRN_VIDEO_PARAM_CHANGED, 0, "video parameters changed" },
140  { MFX_WRN_PARTIAL_ACCELERATION, 0, "partial acceleration" },
141  { MFX_WRN_INCOMPATIBLE_VIDEO_PARAM, 0, "incompatible video parameters" },
142  { MFX_WRN_VALUE_NOT_CHANGED, 0, "value is saturated" },
143  { MFX_WRN_OUT_OF_RANGE, 0, "value out of range" },
144  { MFX_WRN_FILTER_SKIPPED, 0, "filter skipped" },
145  { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio parameters" },
146 };
147 
148 static int qsv_map_error(mfxStatus mfx_err, const char **desc)
149 {
150  int i;
151  for (i = 0; i < FF_ARRAY_ELEMS(qsv_errors); i++) {
152  if (qsv_errors[i].mfxerr == mfx_err) {
153  if (desc)
154  *desc = qsv_errors[i].desc;
155  return qsv_errors[i].averr;
156  }
157  }
158  if (desc)
159  *desc = "unknown error";
160  return AVERROR_UNKNOWN;
161 }
162 
163 int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
164  const char *error_string)
165 {
166  const char *desc;
167  int ret;
168  ret = qsv_map_error(err, &desc);
169  av_log(log_ctx, AV_LOG_ERROR, "%s: %s (%d)\n", error_string, desc, err);
170  return ret;
171 }
172 
173 int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
174  const char *warning_string)
175 {
176  const char *desc;
177  int ret;
178  ret = qsv_map_error(err, &desc);
179  av_log(log_ctx, AV_LOG_WARNING, "%s: %s (%d)\n", warning_string, desc, err);
180  return ret;
181 }
182 
183 /* functions for frameAlloc */
184 static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req,
185  mfxFrameAllocResponse *resp)
186 {
187  QSVVPPContext *s = pthis;
188  int i;
189 
190  if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET) ||
191  !(req->Type & (MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT)) ||
192  !(req->Type & MFX_MEMTYPE_EXTERNAL_FRAME))
193  return MFX_ERR_UNSUPPORTED;
194 
195  if (req->Type & MFX_MEMTYPE_FROM_VPPIN) {
196  resp->mids = av_mallocz(s->nb_surface_ptrs_in * sizeof(*resp->mids));
197  if (!resp->mids)
198  return AVERROR(ENOMEM);
199 
200  for (i = 0; i < s->nb_surface_ptrs_in; i++)
201  resp->mids[i] = s->surface_ptrs_in[i]->Data.MemId;
202 
203  resp->NumFrameActual = s->nb_surface_ptrs_in;
204  } else {
205  resp->mids = av_mallocz(s->nb_surface_ptrs_out * sizeof(*resp->mids));
206  if (!resp->mids)
207  return AVERROR(ENOMEM);
208 
209  for (i = 0; i < s->nb_surface_ptrs_out; i++)
210  resp->mids[i] = s->surface_ptrs_out[i]->Data.MemId;
211 
212  resp->NumFrameActual = s->nb_surface_ptrs_out;
213  }
214 
215  return MFX_ERR_NONE;
216 }
217 
218 static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
219 {
220  av_freep(&resp->mids);
221  return MFX_ERR_NONE;
222 }
223 
224 static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
225 {
226  return MFX_ERR_UNSUPPORTED;
227 }
228 
229 static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
230 {
231  return MFX_ERR_UNSUPPORTED;
232 }
233 
234 static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
235 {
236  *hdl = mid;
237  return MFX_ERR_NONE;
238 }
239 
241 {
242  switch (format) {
243  case AV_PIX_FMT_YUV420P:
244  return MFX_FOURCC_YV12;
245  case AV_PIX_FMT_NV12:
246  return MFX_FOURCC_NV12;
247  case AV_PIX_FMT_YUYV422:
248  return MFX_FOURCC_YUY2;
249  case AV_PIX_FMT_BGRA:
250  return MFX_FOURCC_RGB4;
251  }
252 
253  return MFX_FOURCC_NV12;
254 }
255 
256 static int map_frame_to_surface(AVFrame *frame, mfxFrameSurface1 *surface)
257 {
258  switch (frame->format) {
259  case AV_PIX_FMT_NV12:
260  case AV_PIX_FMT_P010:
261  surface->Data.Y = frame->data[0];
262  surface->Data.UV = frame->data[1];
263  break;
264  case AV_PIX_FMT_YUV420P:
265  surface->Data.Y = frame->data[0];
266  surface->Data.U = frame->data[1];
267  surface->Data.V = frame->data[2];
268  break;
269  case AV_PIX_FMT_YUYV422:
270  surface->Data.Y = frame->data[0];
271  surface->Data.U = frame->data[0] + 1;
272  surface->Data.V = frame->data[0] + 3;
273  break;
274  case AV_PIX_FMT_RGB32:
275  surface->Data.B = frame->data[0];
276  surface->Data.G = frame->data[0] + 1;
277  surface->Data.R = frame->data[0] + 2;
278  surface->Data.A = frame->data[0] + 3;
279  break;
280  default:
281  return MFX_ERR_UNSUPPORTED;
282  }
283  surface->Data.Pitch = frame->linesize[0];
284 
285  return 0;
286 }
287 
288 /* fill the surface info */
289 static int fill_frameinfo_by_link(mfxFrameInfo *frameinfo, AVFilterLink *link)
290 {
291  enum AVPixelFormat pix_fmt;
292  AVHWFramesContext *frames_ctx;
293  AVQSVFramesContext *frames_hwctx;
294  const AVPixFmtDescriptor *desc;
295 
296  if (link->format == AV_PIX_FMT_QSV) {
297  if (!link->hw_frames_ctx)
298  return AVERROR(EINVAL);
299 
300  frames_ctx = (AVHWFramesContext *)link->hw_frames_ctx->data;
301  frames_hwctx = frames_ctx->hwctx;
302  *frameinfo = frames_hwctx->surfaces[0].Info;
303  } else {
304  pix_fmt = link->format;
306  if (!desc)
307  return AVERROR_BUG;
308 
309  frameinfo->CropX = 0;
310  frameinfo->CropY = 0;
311  frameinfo->Width = FFALIGN(link->w, 32);
312  frameinfo->Height = FFALIGN(link->h, 32);
313  frameinfo->PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
314  frameinfo->FourCC = pix_fmt_to_mfx_fourcc(pix_fmt);
315  frameinfo->BitDepthLuma = desc->comp[0].depth;
316  frameinfo->BitDepthChroma = desc->comp[0].depth;
317  frameinfo->Shift = desc->comp[0].depth > 8;
318  if (desc->log2_chroma_w && desc->log2_chroma_h)
319  frameinfo->ChromaFormat = MFX_CHROMAFORMAT_YUV420;
320  else if (desc->log2_chroma_w)
321  frameinfo->ChromaFormat = MFX_CHROMAFORMAT_YUV422;
322  else
323  frameinfo->ChromaFormat = MFX_CHROMAFORMAT_YUV444;
324  }
325 
326  frameinfo->CropW = link->w;
327  frameinfo->CropH = link->h;
328  frameinfo->FrameRateExtN = link->frame_rate.num;
329  frameinfo->FrameRateExtD = link->frame_rate.den;
330  frameinfo->AspectRatioW = link->sample_aspect_ratio.num ? link->sample_aspect_ratio.num : 1;
331  frameinfo->AspectRatioH = link->sample_aspect_ratio.den ? link->sample_aspect_ratio.den : 1;
332 
333  return 0;
334 }
335 
336 static void clear_unused_frames(QSVFrame *list)
337 {
338  while (list) {
339  if (list->surface && !list->surface->Data.Locked) {
340  list->surface = NULL;
341  av_frame_free(&list->frame);
342  }
343  list = list->next;
344  }
345 }
346 
347 static void clear_frame_list(QSVFrame **list)
348 {
349  while (*list) {
350  QSVFrame *frame;
351 
352  frame = *list;
353  *list = (*list)->next;
354  av_frame_free(&frame->frame);
355  av_freep(&frame);
356  }
357 }
358 
360 {
361  QSVFrame *out = *list;
362 
363  for (; out; out = out->next) {
364  if (!out->surface)
365  break;
366  }
367 
368  if (!out) {
369  out = av_mallocz(sizeof(*out));
370  if (!out) {
371  av_log(NULL, AV_LOG_ERROR, "Can't alloc new output frame.\n");
372  return NULL;
373  }
374  out->next = *list;
375  *list = out;
376  }
377 
378  return out;
379 }
380 
381 /* get the input surface */
383 {
384  QSVFrame *qsv_frame;
385  AVFilterContext *ctx = inlink->dst;
386 
387  clear_unused_frames(s->in_frame_list);
388 
389  qsv_frame = get_free_frame(&s->in_frame_list);
390  if (!qsv_frame)
391  return NULL;
392 
393  /* Turn AVFrame into mfxFrameSurface1.
394  * For video/opaque memory mode, pix_fmt is AV_PIX_FMT_QSV, and
395  * mfxFrameSurface1 is stored in AVFrame->data[3];
396  * for system memory mode, raw video data is stored in
397  * AVFrame, we should map it into mfxFrameSurface1.
398  */
399  if (!IS_SYSTEM_MEMORY(s->in_mem_mode)) {
400  if (picref->format != AV_PIX_FMT_QSV) {
401  av_log(ctx, AV_LOG_ERROR, "QSVVPP gets a wrong frame.\n");
402  return NULL;
403  }
404  qsv_frame->frame = av_frame_clone(picref);
405  qsv_frame->surface = (mfxFrameSurface1 *)qsv_frame->frame->data[3];
406  } else {
407  /* make a copy if the input is not padded as libmfx requires */
408  if (picref->height & 31 || picref->linesize[0] & 31) {
409  qsv_frame->frame = ff_get_video_buffer(inlink,
410  FFALIGN(inlink->w, 32),
411  FFALIGN(inlink->h, 32));
412  if (!qsv_frame->frame)
413  return NULL;
414 
415  qsv_frame->frame->width = picref->width;
416  qsv_frame->frame->height = picref->height;
417 
418  if (av_frame_copy(qsv_frame->frame, picref) < 0) {
419  av_frame_free(&qsv_frame->frame);
420  return NULL;
421  }
422 
423  if (av_frame_copy_props(qsv_frame->frame, picref) < 0) {
424  av_frame_free(&qsv_frame->frame);
425  return NULL;
426  }
427  } else
428  qsv_frame->frame = av_frame_clone(picref);
429 
430  if (map_frame_to_surface(qsv_frame->frame,
431  &qsv_frame->surface_internal) < 0) {
432  av_log(ctx, AV_LOG_ERROR, "Unsupported frame.\n");
433  return NULL;
434  }
435  qsv_frame->surface = &qsv_frame->surface_internal;
436  }
437 
438  qsv_frame->surface->Info = s->frame_infos[FF_INLINK_IDX(inlink)];
439  qsv_frame->surface->Data.TimeStamp = av_rescale_q(qsv_frame->frame->pts,
440  inlink->time_base, default_tb);
441 
442  qsv_frame->surface->Info.PicStruct =
443  !qsv_frame->frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
444  (qsv_frame->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
445  MFX_PICSTRUCT_FIELD_BFF);
446  if (qsv_frame->frame->repeat_pict == 1)
447  qsv_frame->surface->Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
448  else if (qsv_frame->frame->repeat_pict == 2)
449  qsv_frame->surface->Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
450  else if (qsv_frame->frame->repeat_pict == 4)
451  qsv_frame->surface->Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
452 
453  return qsv_frame;
454 }
455 
456 /* get the output surface */
458 {
459  AVFilterContext *ctx = outlink->src;
460  QSVFrame *out_frame;
461  int ret;
462 
463  clear_unused_frames(s->out_frame_list);
464 
465  out_frame = get_free_frame(&s->out_frame_list);
466  if (!out_frame)
467  return NULL;
468 
469  /* For video memory, get a hw frame;
470  * For system memory, get a sw frame and map it into a mfx_surface. */
471  if (!IS_SYSTEM_MEMORY(s->out_mem_mode)) {
472  out_frame->frame = av_frame_alloc();
473  if (!out_frame->frame)
474  return NULL;
475 
476  ret = av_hwframe_get_buffer(outlink->hw_frames_ctx, out_frame->frame, 0);
477  if (ret < 0) {
478  av_log(ctx, AV_LOG_ERROR, "Can't allocate a surface.\n");
479  return NULL;
480  }
481 
482  out_frame->surface = (mfxFrameSurface1 *)out_frame->frame->data[3];
483  } else {
484  /* Get a frame with aligned dimensions.
485  * Libmfx need system memory being 128x64 aligned */
486  out_frame->frame = ff_get_video_buffer(outlink,
487  FFALIGN(outlink->w, 128),
488  FFALIGN(outlink->h, 64));
489  if (!out_frame->frame)
490  return NULL;
491 
492  out_frame->frame->width = outlink->w;
493  out_frame->frame->height = outlink->h;
494 
495  ret = map_frame_to_surface(out_frame->frame,
496  &out_frame->surface_internal);
497  if (ret < 0)
498  return NULL;
499 
500  out_frame->surface = &out_frame->surface_internal;
501  }
502 
503  out_frame->surface->Info = s->vpp_param.vpp.Out;
504 
505  return out_frame;
506 }
507 
508 /* create the QSV session */
510 {
511  AVFilterLink *inlink = avctx->inputs[0];
512  AVFilterLink *outlink = avctx->outputs[0];
513  AVQSVFramesContext *in_frames_hwctx = NULL;
514  AVQSVFramesContext *out_frames_hwctx = NULL;
515 
516  AVBufferRef *device_ref;
517  AVHWDeviceContext *device_ctx;
518  AVQSVDeviceContext *device_hwctx;
519  mfxHDL handle;
520  mfxHandleType handle_type;
521  mfxVersion ver;
522  mfxIMPL impl;
523  int ret, i;
524 
525  if (inlink->hw_frames_ctx) {
526  AVHWFramesContext *frames_ctx = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
527 
528  device_ref = frames_ctx->device_ref;
529  in_frames_hwctx = frames_ctx->hwctx;
530 
531  s->in_mem_mode = in_frames_hwctx->frame_type;
532 
533  s->surface_ptrs_in = av_mallocz_array(in_frames_hwctx->nb_surfaces,
534  sizeof(*s->surface_ptrs_in));
535  if (!s->surface_ptrs_in)
536  return AVERROR(ENOMEM);
537 
538  for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
539  s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i;
540 
541  s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces;
542  } else if (avctx->hw_device_ctx) {
543  device_ref = avctx->hw_device_ctx;
544  s->in_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY;
545  } else {
546  av_log(avctx, AV_LOG_ERROR, "No hw context provided.\n");
547  return AVERROR(EINVAL);
548  }
549 
550  device_ctx = (AVHWDeviceContext *)device_ref->data;
551  device_hwctx = device_ctx->hwctx;
552 
553  if (outlink->format == AV_PIX_FMT_QSV) {
554  AVHWFramesContext *out_frames_ctx;
555  AVBufferRef *out_frames_ref = av_hwframe_ctx_alloc(device_ref);
556  if (!out_frames_ref)
557  return AVERROR(ENOMEM);
558 
559  s->out_mem_mode = IS_OPAQUE_MEMORY(s->in_mem_mode) ?
560  MFX_MEMTYPE_OPAQUE_FRAME :
561  MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
562 
563  out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data;
564  out_frames_hwctx = out_frames_ctx->hwctx;
565 
566  out_frames_ctx->format = AV_PIX_FMT_QSV;
567  out_frames_ctx->width = FFALIGN(outlink->w, 32);
568  out_frames_ctx->height = FFALIGN(outlink->h, 32);
569  out_frames_ctx->sw_format = s->out_sw_format;
570  out_frames_ctx->initial_pool_size = 64;
571  if (avctx->extra_hw_frames > 0)
572  out_frames_ctx->initial_pool_size += avctx->extra_hw_frames;
573  out_frames_hwctx->frame_type = s->out_mem_mode;
574 
575  ret = av_hwframe_ctx_init(out_frames_ref);
576  if (ret < 0) {
577  av_buffer_unref(&out_frames_ref);
578  av_log(avctx, AV_LOG_ERROR, "Error creating frames_ctx for output pad.\n");
579  return ret;
580  }
581 
582  s->surface_ptrs_out = av_mallocz_array(out_frames_hwctx->nb_surfaces,
583  sizeof(*s->surface_ptrs_out));
584  if (!s->surface_ptrs_out) {
585  av_buffer_unref(&out_frames_ref);
586  return AVERROR(ENOMEM);
587  }
588 
589  for (i = 0; i < out_frames_hwctx->nb_surfaces; i++)
590  s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i;
591  s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces;
592 
593  av_buffer_unref(&outlink->hw_frames_ctx);
594  outlink->hw_frames_ctx = out_frames_ref;
595  } else
596  s->out_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY;
597 
598  /* extract the properties of the "master" session given to us */
599  ret = MFXQueryIMPL(device_hwctx->session, &impl);
600  if (ret == MFX_ERR_NONE)
601  ret = MFXQueryVersion(device_hwctx->session, &ver);
602  if (ret != MFX_ERR_NONE) {
603  av_log(avctx, AV_LOG_ERROR, "Error querying the session attributes\n");
604  return AVERROR_UNKNOWN;
605  }
606 
607  for (i = 0; i < FF_ARRAY_ELEMS(handle_types); i++) {
608  ret = MFXVideoCORE_GetHandle(device_hwctx->session, handle_types[i], &handle);
609  if (ret == MFX_ERR_NONE) {
611  break;
612  }
613  }
614 
615  if (ret < 0)
616  return ff_qsvvpp_print_error(avctx, ret, "Error getting the session handle");
617  else if (ret > 0) {
618  ff_qsvvpp_print_warning(avctx, ret, "Warning in getting the session handle");
619  return AVERROR_UNKNOWN;
620  }
621 
622  /* create a "slave" session with those same properties, to be used for vpp */
623  ret = MFXInit(impl, &ver, &s->session);
624  if (ret < 0)
625  return ff_qsvvpp_print_error(avctx, ret, "Error initializing a session");
626  else if (ret > 0) {
627  ff_qsvvpp_print_warning(avctx, ret, "Warning in session initialization");
628  return AVERROR_UNKNOWN;
629  }
630 
631  if (handle) {
632  ret = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
633  if (ret != MFX_ERR_NONE)
634  return AVERROR_UNKNOWN;
635  }
636 
637  if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) {
638  ret = MFXJoinSession(device_hwctx->session, s->session);
639  if (ret != MFX_ERR_NONE)
640  return AVERROR_UNKNOWN;
641  }
642 
643  if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {
644  s->opaque_alloc.In.Surfaces = s->surface_ptrs_in;
645  s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in;
646  s->opaque_alloc.In.Type = s->in_mem_mode;
647 
648  s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out;
649  s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out;
650  s->opaque_alloc.Out.Type = s->out_mem_mode;
651 
652  s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
653  s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
654  } else if (IS_VIDEO_MEMORY(s->in_mem_mode) || IS_VIDEO_MEMORY(s->out_mem_mode)) {
655  mfxFrameAllocator frame_allocator = {
656  .pthis = s,
657  .Alloc = frame_alloc,
658  .Lock = frame_lock,
659  .Unlock = frame_unlock,
660  .GetHDL = frame_get_hdl,
661  .Free = frame_free,
662  };
663 
664  ret = MFXVideoCORE_SetFrameAllocator(s->session, &frame_allocator);
665  if (ret != MFX_ERR_NONE)
666  return AVERROR_UNKNOWN;
667  }
668 
669  return 0;
670 }
671 
673 {
674  int i;
675  int ret;
676  QSVVPPContext *s;
677 
678  s = av_mallocz(sizeof(*s));
679  if (!s)
680  return AVERROR(ENOMEM);
681 
682  s->filter_frame = param->filter_frame;
683  if (!s->filter_frame)
684  s->filter_frame = ff_filter_frame;
685  s->out_sw_format = param->out_sw_format;
686 
687  /* create the vpp session */
688  ret = init_vpp_session(avctx, s);
689  if (ret < 0)
690  goto failed;
691 
692  s->frame_infos = av_mallocz_array(avctx->nb_inputs, sizeof(*s->frame_infos));
693  if (!s->frame_infos) {
694  ret = AVERROR(ENOMEM);
695  goto failed;
696  }
697 
698  /* Init each input's information */
699  for (i = 0; i < avctx->nb_inputs; i++) {
700  ret = fill_frameinfo_by_link(&s->frame_infos[i], avctx->inputs[i]);
701  if (ret < 0)
702  goto failed;
703  }
704 
705  /* Update input's frame info according to crop */
706  for (i = 0; i < param->num_crop; i++) {
707  QSVVPPCrop *crop = param->crop + i;
708  if (crop->in_idx > avctx->nb_inputs) {
709  ret = AVERROR(EINVAL);
710  goto failed;
711  }
712  s->frame_infos[crop->in_idx].CropX = crop->x;
713  s->frame_infos[crop->in_idx].CropY = crop->y;
714  s->frame_infos[crop->in_idx].CropW = crop->w;
715  s->frame_infos[crop->in_idx].CropH = crop->h;
716  }
717 
718  s->vpp_param.vpp.In = s->frame_infos[0];
719 
720  ret = fill_frameinfo_by_link(&s->vpp_param.vpp.Out, avctx->outputs[0]);
721  if (ret < 0) {
722  av_log(avctx, AV_LOG_ERROR, "Fail to get frame info from link.\n");
723  goto failed;
724  }
725 
726  if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {
727  s->nb_ext_buffers = param->num_ext_buf + 1;
728  s->ext_buffers = av_mallocz_array(s->nb_ext_buffers, sizeof(*s->ext_buffers));
729  if (!s->ext_buffers) {
730  ret = AVERROR(ENOMEM);
731  goto failed;
732  }
733 
734  s->ext_buffers[0] = (mfxExtBuffer *)&s->opaque_alloc;
735  for (i = 1; i < param->num_ext_buf; i++)
736  s->ext_buffers[i] = param->ext_buf[i - 1];
737  s->vpp_param.ExtParam = s->ext_buffers;
738  s->vpp_param.NumExtParam = s->nb_ext_buffers;
739  } else {
740  s->vpp_param.NumExtParam = param->num_ext_buf;
741  s->vpp_param.ExtParam = param->ext_buf;
742  }
743 
744  s->vpp_param.AsyncDepth = 1;
745 
746  if (IS_SYSTEM_MEMORY(s->in_mem_mode))
747  s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_SYSTEM_MEMORY;
748  else if (IS_VIDEO_MEMORY(s->in_mem_mode))
749  s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_VIDEO_MEMORY;
750  else if (IS_OPAQUE_MEMORY(s->in_mem_mode))
751  s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_OPAQUE_MEMORY;
752 
753  if (IS_SYSTEM_MEMORY(s->out_mem_mode))
754  s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
755  else if (IS_VIDEO_MEMORY(s->out_mem_mode))
756  s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_VIDEO_MEMORY;
757  else if (IS_OPAQUE_MEMORY(s->out_mem_mode))
758  s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
759 
760  /* Print input memory mode */
761  ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0x0F, "VPP");
762  /* Print output memory mode */
763  ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0xF0, "VPP");
764  ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
765  if (ret < 0) {
766  ret = ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
767  goto failed;
768  } else if (ret > 0)
769  ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
770 
771  *vpp = s;
772  return 0;
773 
774 failed:
775  ff_qsvvpp_free(&s);
776 
777  return ret;
778 }
779 
781 {
782  QSVVPPContext *s = *vpp;
783 
784  if (!s)
785  return 0;
786 
787  if (s->session) {
788  MFXVideoVPP_Close(s->session);
789  MFXClose(s->session);
790  }
791 
792  /* release all the resources */
793  clear_frame_list(&s->in_frame_list);
794  clear_frame_list(&s->out_frame_list);
795  av_freep(&s->surface_ptrs_in);
796  av_freep(&s->surface_ptrs_out);
797  av_freep(&s->ext_buffers);
798  av_freep(&s->frame_infos);
799  av_freep(vpp);
800 
801  return 0;
802 }
803 
805 {
806  AVFilterContext *ctx = inlink->dst;
807  AVFilterLink *outlink = ctx->outputs[0];
808  mfxSyncPoint sync;
809  QSVFrame *in_frame, *out_frame;
810  int ret, filter_ret;
811 
812  in_frame = submit_frame(s, inlink, picref);
813  if (!in_frame) {
814  av_log(ctx, AV_LOG_ERROR, "Failed to submit frame on input[%d]\n",
815  FF_INLINK_IDX(inlink));
816  return AVERROR(ENOMEM);
817  }
818 
819  do {
820  out_frame = query_frame(s, outlink);
821  if (!out_frame) {
822  av_log(ctx, AV_LOG_ERROR, "Failed to query an output frame.\n");
823  return AVERROR(ENOMEM);
824  }
825 
826  do {
827  ret = MFXVideoVPP_RunFrameVPPAsync(s->session, in_frame->surface,
828  out_frame->surface, NULL, &sync);
829  if (ret == MFX_WRN_DEVICE_BUSY)
830  av_usleep(500);
831  } while (ret == MFX_WRN_DEVICE_BUSY);
832 
833  if (ret < 0 && ret != MFX_ERR_MORE_SURFACE) {
834  /* Ignore more_data error */
835  if (ret == MFX_ERR_MORE_DATA)
836  ret = AVERROR(EAGAIN);
837  break;
838  }
839 
840  if (MFXVideoCORE_SyncOperation(s->session, sync, 1000) < 0)
841  av_log(ctx, AV_LOG_WARNING, "Sync failed.\n");
842 
843  out_frame->frame->pts = av_rescale_q(out_frame->surface->Data.TimeStamp,
844  default_tb, outlink->time_base);
845 
846  filter_ret = s->filter_frame(outlink, out_frame->frame);
847  if (filter_ret < 0) {
848  av_frame_free(&out_frame->frame);
849  ret = filter_ret;
850  break;
851  }
852  out_frame->frame = NULL;
853  } while(ret == MFX_ERR_MORE_SURFACE);
854 
855  return ret;
856 }
static const char *const format[]
Definition: af_aiir.c:457
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1099
#define s(width, name)
Definition: cbs_vp9.c:257
common internal and external API header
#define NULL
Definition: coverity.c:32
static enum AVPixelFormat pix_fmt
static AVFrame * frame
int
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:125
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
#define AVERROR(e)
Definition: error.h:43
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:540
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:190
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:799
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:210
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
Definition: mem.c:190
for(j=16;j >0;--j)
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:333
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:247
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
Definition: hwcontext.c:506
mfxHandleType handle_type
Definition: hwcontext_qsv.c:89
An API-specific header for AV_HWDEVICE_TYPE_QSV.
int i
Definition: input.c:407
#define FF_INLINK_IDX(link)
Find the index of a link.
Definition: internal.h:302
common internal API header
#define FFALIGN(x, a)
Definition: macros.h:48
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_P010
Definition: pixfmt.h:448
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:89
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition: pixfmt.h:222
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:372
#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR)
Definition: qsv_internal.h:59
static QSVFrame * query_frame(QSVVPPContext *s, AVFilterLink *outlink)
Definition: qsvvpp.c:457
static const AVRational default_tb
Definition: qsvvpp.c:77
#define IS_VIDEO_MEMORY(mode)
Definition: qsvvpp.c:35
static int qsv_map_error(mfxStatus mfx_err, const char **desc)
Definition: qsvvpp.c:148
static int pix_fmt_to_mfx_fourcc(int format)
Definition: qsvvpp.c:240
static QSVFrame * submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picref)
Definition: qsvvpp.c:382
static void clear_frame_list(QSVFrame **list)
Definition: qsvvpp.c:347
int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern, const char *extra_string)
Definition: qsvvpp.c:91
static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req, mfxFrameAllocResponse *resp)
Definition: qsvvpp.c:184
#define IS_OPAQUE_MEMORY(mode)
Definition: qsvvpp.c:37
static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)
Definition: qsvvpp.c:234
const char * desc
Definition: qsvvpp.c:81
static int fill_frameinfo_by_link(mfxFrameInfo *frameinfo, AVFilterLink *link)
Definition: qsvvpp.c:289
static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
Definition: qsvvpp.c:224
int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param)
Definition: qsvvpp.c:672
int mfx_iopattern
Definition: qsvvpp.c:80
#define IS_SYSTEM_MEMORY(mode)
Definition: qsvvpp.c:38
static int map_frame_to_surface(AVFrame *frame, mfxFrameSurface1 *surface)
Definition: qsvvpp.c:256
int ff_qsvvpp_free(QSVVPPContext **vpp)
Definition: qsvvpp.c:780
static void clear_unused_frames(QSVFrame *list)
Definition: qsvvpp.c:336
int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err, const char *error_string)
Definition: qsvvpp.c:163
static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
Definition: qsvvpp.c:509
static const mfxHandleType handle_types[]
Definition: qsvvpp.c:71
int averr
Definition: qsvvpp.c:110
int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err, const char *warning_string)
Definition: qsvvpp.c:173
static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp)
Definition: qsvvpp.c:218
static const struct @212 qsv_errors[]
static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr)
Definition: qsvvpp.c:229
static const struct @211 qsv_iopatterns[]
static QSVFrame * get_free_frame(QSVFrame **list)
Definition: qsvvpp.c:359
int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picref)
Definition: qsvvpp.c:804
mfxStatus mfxerr
Definition: qsvvpp.c:109
Intel Quick Sync Video VPP base function.
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Definition: buffer.h:84
uint8_t * data
The data buffer.
Definition: buffer.h:92
An instance of a filter.
Definition: avfilter.h:341
int extra_hw_frames
Sets the number of extra hardware frames which the filter will allocate on its output links for use i...
Definition: avfilter.h:427
unsigned nb_inputs
number of input pads
Definition: avfilter.h:350
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:349
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
Definition: avfilter.h:397
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:353
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:411
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
int width
Definition: frame.h:376
int height
Definition: frame.h:376
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:470
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:465
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:391
int repeat_pict
When decoding, this signals how much the picture must be delayed.
Definition: frame.h:460
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:92
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:209
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:141
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:162
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:222
int initial_pool_size
Initial size of the frame pool.
Definition: hwcontext.h:199
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:229
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_qsv.h:35
mfxSession session
Definition: hwcontext_qsv.h:36
This struct is allocated as AVHWFramesContext.hwctx.
Definition: hwcontext_qsv.h:42
mfxFrameSurface1 * surfaces
Definition: hwcontext_qsv.h:43
int frame_type
A combination of MFX_MEMTYPE_* describing the frame pool.
Definition: hwcontext_qsv.h:49
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int num
Numerator.
Definition: rational.h:59
int den
Denominator.
Definition: rational.h:60
AVFrame * frame
Definition: qsv_internal.h:73
mfxFrameSurface1 * surface
Definition: qsvvpp.c:42
struct QSVFrame * next
Definition: qsv_internal.h:82
mfxFrameSurface1 surface
Definition: qsv_internal.h:74
mfxFrameSurface1 surface_internal
Definition: qsvvpp.c:43
mfxExtOpaqueSurfaceAlloc opaque_alloc
Definition: qsvvpp.c:66
mfxFrameSurface1 ** surface_ptrs_in
Definition: qsvvpp.c:62
mfxSession session
Definition: qsvvpp.c:49
int nb_surface_ptrs_out
Definition: qsvvpp.c:61
int nb_surface_ptrs_in
Definition: qsvvpp.c:60
enum AVPixelFormat out_sw_format
Definition: qsvvpp.c:51
mfxFrameSurface1 ** surface_ptrs_out
Definition: qsvvpp.c:63
mfxVideoParam vpp_param
Definition: qsvvpp.c:52
QSVFrame * in_frame_list
Definition: qsvvpp.c:58
mfxFrameInfo * frame_infos
Definition: qsvvpp.c:53
int out_mem_mode
Definition: qsvvpp.c:57
QSVFrame * out_frame_list
Definition: qsvvpp.c:59
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
Definition: qsvvpp.c:50
mfxExtBuffer ** ext_buffers
Definition: qsvvpp.c:67
int in_mem_mode
Definition: qsvvpp.c:56
int nb_ext_buffers
Definition: qsvvpp.c:68
int h
Crop rectangle.
Definition: qsvvpp.h:46
int y
Definition: qsvvpp.h:46
int x
Definition: qsvvpp.h:46
int in_idx
Input index.
Definition: qsvvpp.h:45
int w
Definition: qsvvpp.h:46
int num_crop
Definition: qsvvpp.h:61
QSVVPPCrop * crop
Definition: qsvvpp.h:62
mfxExtBuffer ** ext_buf
Definition: qsvvpp.h:55
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
Definition: qsvvpp.h:51
enum AVPixelFormat out_sw_format
Definition: qsvvpp.h:58
int num_ext_buf
Definition: qsvvpp.h:54
#define av_freep(p)
#define av_log(a,...)
FILE * out
Definition: movenc.c:54
AVFormatContext * ctx
Definition: movenc.c:48
int av_usleep(unsigned usec)
Sleep for a period of time.
Definition: time.c:84
if(ret< 0)
Definition: vf_mcdeint.c:282
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104