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.
Showing the changes to libavfilter (2 of 2 files). Show all
Unified · Split
| @@ -767,28 +767,39 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) · 766 unmodified lines | ||
| 767 | 767 | goto failed; |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | + s->nb_seq_buffers = param->num_ext_buf; | |
| 770 | 771 | #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; | |
| 773 | 792 | s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers)); |
| 774 | 793 | if (!s->ext_buffers) { |
| 775 | 794 | ret = AVERROR(ENOMEM); |
| 776 | 795 | goto failed; |
| 777 | 796 | } |
| 778 | 797 | |
| 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)); | |
| 787 | 799 | } |
| 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; | |
| 792 | 803 | |
| 793 | 804 | s->got_frame = 0; |
| 794 | 805 | |
| @@ -861,9 +872,8 @@ int ff_qsvvpp_close(AVFilterContext *avctx) · 66 unmodified lines | ||
| 861 | 872 | clear_frame_list(&s->out_frame_list); |
| 862 | 873 | av_freep(&s->surface_ptrs_in); |
| 863 | 874 | av_freep(&s->surface_ptrs_out); |
| 864 | −#if QSV_HAVE_OPAQUE | |
| 875 | + av_freep(&s->seq_buffers); | |
| 865 | 876 | av_freep(&s->ext_buffers); |
| 866 | −#endif | |
| 867 | 877 | av_freep(&s->frame_infos); |
| 868 | 878 | av_fifo_freep2(&s->async_fifo); |
| 869 | 879 | |
| @@ -74,9 +74,14 @@ typedef struct QSVVPPContext { · 73 unmodified lines | ||
| 74 | 74 | #if QSV_HAVE_OPAQUE |
| 75 | 75 | /** MFXVPP extern parameters */ |
| 76 | 76 | 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 */ | |
| 77 | 83 | mfxExtBuffer **ext_buffers; |
| 78 | 84 | int nb_ext_buffers; |
| 79 | −#endif | |
| 80 | 85 | |
| 81 | 86 | int got_frame; |
| 82 | 87 | int async_depth; |