lavfi/qsvvpp: store a copy of the sequence parameters

We will postpone the vpp session initialization to when input and output
frames are ready, this copy of the sequence parameters will be used to
initialize vpp session.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
pull/389/head
Haihao Xiang 2 years ago
parent 579711c2cc
commit cf21ca9efb
  1. 42
      libavfilter/qsvvpp.c
  2. 7
      libavfilter/qsvvpp.h

@ -767,28 +767,39 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
goto failed; goto failed;
} }
s->nb_seq_buffers = param->num_ext_buf;
#if QSV_HAVE_OPAQUE #if QSV_HAVE_OPAQUE
if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) { if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode))
s->nb_ext_buffers = param->num_ext_buf + 1; s->nb_seq_buffers++;
#endif
if (s->nb_seq_buffers) {
s->seq_buffers = av_calloc(s->nb_seq_buffers, sizeof(*s->seq_buffers));
if (!s->seq_buffers) {
ret = AVERROR(ENOMEM);
goto failed;
}
for (i = 0; i < param->num_ext_buf; i++)
s->seq_buffers[i] = param->ext_buf[i];
#if QSV_HAVE_OPAQUE
if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode))
s->seq_buffers[i] = (mfxExtBuffer *)&s->opaque_alloc;
#endif
s->nb_ext_buffers = s->nb_seq_buffers;
s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers)); s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
if (!s->ext_buffers) { if (!s->ext_buffers) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto failed; goto failed;
} }
s->ext_buffers[0] = (mfxExtBuffer *)&s->opaque_alloc; memcpy(s->ext_buffers, s->seq_buffers, s->nb_seq_buffers * sizeof(*s->seq_buffers));
for (i = 1; i < param->num_ext_buf; i++)
s->ext_buffers[i] = param->ext_buf[i - 1];
s->vpp_param.ExtParam = s->ext_buffers;
s->vpp_param.NumExtParam = s->nb_ext_buffers;
} else {
s->vpp_param.NumExtParam = param->num_ext_buf;
s->vpp_param.ExtParam = param->ext_buf;
} }
#else
s->vpp_param.NumExtParam = param->num_ext_buf; s->vpp_param.ExtParam = s->ext_buffers;
s->vpp_param.ExtParam = param->ext_buf; s->vpp_param.NumExtParam = s->nb_ext_buffers;
#endif
s->got_frame = 0; s->got_frame = 0;
@ -861,9 +872,8 @@ int ff_qsvvpp_close(AVFilterContext *avctx)
clear_frame_list(&s->out_frame_list); clear_frame_list(&s->out_frame_list);
av_freep(&s->surface_ptrs_in); av_freep(&s->surface_ptrs_in);
av_freep(&s->surface_ptrs_out); av_freep(&s->surface_ptrs_out);
#if QSV_HAVE_OPAQUE av_freep(&s->seq_buffers);
av_freep(&s->ext_buffers); av_freep(&s->ext_buffers);
#endif
av_freep(&s->frame_infos); av_freep(&s->frame_infos);
av_fifo_freep2(&s->async_fifo); av_fifo_freep2(&s->async_fifo);

@ -74,9 +74,14 @@ typedef struct QSVVPPContext {
#if QSV_HAVE_OPAQUE #if QSV_HAVE_OPAQUE
/** MFXVPP extern parameters */ /** MFXVPP extern parameters */
mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxExtOpaqueSurfaceAlloc opaque_alloc;
#endif
/** store sequence parameters */
mfxExtBuffer **seq_buffers;
int nb_seq_buffers;
/** store all parameters for vpp execution, including parameters per frame */
mfxExtBuffer **ext_buffers; mfxExtBuffer **ext_buffers;
int nb_ext_buffers; int nb_ext_buffers;
#endif
int got_frame; int got_frame;
int async_depth; int async_depth;

Loading…
Cancel
Save