History

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.

Haihao Xiang committed 3 years ago

Commit cf21ca91 parent 579711c2 files · +32 −17Browse files

Showing the changes to libavfilter (2 of 2 files). Show all

Unified · Split

2 files
  1. libavfilter/qsvvpp.c +26 −16
  2. libavfilter/qsvvpp.h +6 −1
libavfilter/qsvvpp.c+26−16
@@ -767,28 +767,39 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) · 766 unmodified lines
767767 goto failed;
768768 }
769769
770+ s->nb_seq_buffers = param->num_ext_buf;
770771 #if QSV_HAVE_OPAQUE
771− if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {
772− s->nb_ext_buffers = param->num_ext_buf + 1;
772+ if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode))
773+ s->nb_seq_buffers++;
774+#endif
775+
776+ if (s->nb_seq_buffers) {
777+ s->seq_buffers = av_calloc(s->nb_seq_buffers, sizeof(*s->seq_buffers));
778+ if (!s->seq_buffers) {
779+ ret = AVERROR(ENOMEM);
780+ goto failed;
781+ }
782+
783+ for (i = 0; i < param->num_ext_buf; i++)
784+ s->seq_buffers[i] = param->ext_buf[i];
785+
786+#if QSV_HAVE_OPAQUE
787+ if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode))
788+ s->seq_buffers[i] = (mfxExtBuffer *)&s->opaque_alloc;
789+#endif
790+
791+ s->nb_ext_buffers = s->nb_seq_buffers;
773792 s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
774793 if (!s->ext_buffers) {
775794 ret = AVERROR(ENOMEM);
776795 goto failed;
777796 }
778797
779− s->ext_buffers[0] = (mfxExtBuffer *)&s->opaque_alloc;
780− for (i = 1; i < param->num_ext_buf; i++)
781− s->ext_buffers[i] = param->ext_buf[i - 1];
782− s->vpp_param.ExtParam = s->ext_buffers;
783− s->vpp_param.NumExtParam = s->nb_ext_buffers;
784− } else {
785− s->vpp_param.NumExtParam = param->num_ext_buf;
786− s->vpp_param.ExtParam = param->ext_buf;
798+ memcpy(s->ext_buffers, s->seq_buffers, s->nb_seq_buffers * sizeof(*s->seq_buffers));
787799 }
788−#else
789− s->vpp_param.NumExtParam = param->num_ext_buf;
790− s->vpp_param.ExtParam = param->ext_buf;
791−#endif
800+
801+ s->vpp_param.ExtParam = s->ext_buffers;
802+ s->vpp_param.NumExtParam = s->nb_ext_buffers;
792803
793804 s->got_frame = 0;
794805
@@ -861,9 +872,8 @@ int ff_qsvvpp_close(AVFilterContext *avctx) · 66 unmodified lines
861872 clear_frame_list(&s->out_frame_list);
862873 av_freep(&s->surface_ptrs_in);
863874 av_freep(&s->surface_ptrs_out);
864−#if QSV_HAVE_OPAQUE
875+ av_freep(&s->seq_buffers);
865876 av_freep(&s->ext_buffers);
866−#endif
867877 av_freep(&s->frame_infos);
868878 av_fifo_freep2(&s->async_fifo);
869879
libavfilter/qsvvpp.h+6−1
@@ -74,9 +74,14 @@ typedef struct QSVVPPContext { · 73 unmodified lines
7474 #if QSV_HAVE_OPAQUE
7575 /** MFXVPP extern parameters */
7676 mfxExtOpaqueSurfaceAlloc opaque_alloc;
77+#endif
78+ /** store sequence parameters */
79+ mfxExtBuffer **seq_buffers;
80+ int nb_seq_buffers;
81+
82+ /** store all parameters for vpp execution, including parameters per frame */
7783 mfxExtBuffer **ext_buffers;
7884 int nb_ext_buffers;
79−#endif
8085
8186 int got_frame;
8287 int async_depth;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t