History

lavfi/qsvvpp: switch to new FIFO API

Anton Khirnov committed 4 years ago

Commit 85c938f1 parent 90eef1c2 files · +20 −28Browse files

Unified · Split

2 files
  1. libavfilter/qsvvpp.c +19 −27
  2. libavfilter/qsvvpp.h +1 −1
libavfilter/qsvvpp.c+19−27
@@ -40,6 +40,11 @@ · 39 unmodified lines
40 40
41static const AVRational default_tb = { 1, 90000 };41static const AVRational default_tb = { 1, 90000 };
42 42
43typedef struct QSVAsyncFrame {
44 mfxSyncPoint sync;
45 QSVFrame *frame;
46} QSVAsyncFrame;
47
43static const struct {48static const struct {
44 int mfx_iopattern;49 int mfx_iopattern;
45 const char *desc;50 const char *desc;
@@ -642,16 +647,6 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 596 unmodified lines
642 return 0;647 return 0;
643}648}
644 649
645static unsigned int qsv_fifo_item_size(void)
646{
647 return sizeof(mfxSyncPoint) + sizeof(QSVFrame*);
648}
649
650static unsigned int qsv_fifo_size(const AVFifoBuffer* fifo)
651{
652 return av_fifo_size(fifo)/qsv_fifo_item_size();
653}
654
655int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param)650int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param)
656{651{
657 int i;652 int i;
@@ -727,7 +722,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p · 69 unmodified lines
727 s->got_frame = 0;722 s->got_frame = 0;
728 723
729 /** keep fifo size at least 1. Even when async_depth is 0, fifo is used. */724 /** keep fifo size at least 1. Even when async_depth is 0, fifo is used. */
730 s->async_fifo = av_fifo_alloc((param->async_depth + 1) * qsv_fifo_item_size());725 s->async_fifo = av_fifo_alloc2(param->async_depth + 1, sizeof(QSVAsyncFrame), 0);
731 s->async_depth = param->async_depth;726 s->async_depth = param->async_depth;
732 if (!s->async_fifo) {727 if (!s->async_fifo) {
733 ret = AVERROR(ENOMEM);728 ret = AVERROR(ENOMEM);
@@ -789,7 +784,7 @@ int ff_qsvvpp_free(QSVVPPContext **vpp) · 55 unmodified lines
789 av_freep(&s->surface_ptrs_out);784 av_freep(&s->surface_ptrs_out);
790 av_freep(&s->ext_buffers);785 av_freep(&s->ext_buffers);
791 av_freep(&s->frame_infos);786 av_freep(&s->frame_infos);
792 av_fifo_free(s->async_fifo);787 av_fifo_freep2(&s->async_fifo);
793 av_freep(vpp);788 av_freep(vpp);
794 789
795 return 0;790 return 0;
@@ -799,24 +794,23 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr · 3 unmodified lines
799{794{
800 AVFilterContext *ctx = inlink->dst;795 AVFilterContext *ctx = inlink->dst;
801 AVFilterLink *outlink = ctx->outputs[0];796 AVFilterLink *outlink = ctx->outputs[0];
797 QSVAsyncFrame aframe;
802 mfxSyncPoint sync;798 mfxSyncPoint sync;
803 QSVFrame *in_frame, *out_frame, *tmp;799 QSVFrame *in_frame, *out_frame, *tmp;
804 int ret, filter_ret;800 int ret, filter_ret;
805 801
806 while (s->eof && qsv_fifo_size(s->async_fifo)) {802 while (s->eof && av_fifo_read(s->async_fifo, &aframe, 1) >= 0) {
807 av_fifo_generic_read(s->async_fifo, &tmp, sizeof(tmp), NULL);803 if (MFXVideoCORE_SyncOperation(s->session, aframe.sync, 1000) < 0)
808 av_fifo_generic_read(s->async_fifo, &sync, sizeof(sync), NULL);
809 if (MFXVideoCORE_SyncOperation(s->session, sync, 1000) < 0)
810 av_log(ctx, AV_LOG_WARNING, "Sync failed.\n");804 av_log(ctx, AV_LOG_WARNING, "Sync failed.\n");
811 805
812 filter_ret = s->filter_frame(outlink, tmp->frame);806 filter_ret = s->filter_frame(outlink, aframe.frame->frame);
813 if (filter_ret < 0) {807 if (filter_ret < 0) {
814 av_frame_free(&tmp->frame);808 av_frame_free(&aframe.frame->frame);
815 return filter_ret;809 return filter_ret;
816 }810 }
817 tmp->queued--;811 aframe.frame->queued--;
818 s->got_frame = 1;812 s->got_frame = 1;
819 tmp->frame = NULL;813 aframe.frame->frame = NULL;
820 };814 };
821 815
822 if (!picref)816 if (!picref)
@@ -853,16 +847,14 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr · 30 unmodified lines
853 default_tb, outlink->time_base);847 default_tb, outlink->time_base);
854 848
855 out_frame->queued++;849 out_frame->queued++;
856 av_fifo_generic_write(s->async_fifo, &out_frame, sizeof(out_frame), NULL);850 aframe = (QSVAsyncFrame){ sync, out_frame };
857 av_fifo_generic_write(s->async_fifo, &sync, sizeof(sync), NULL);851 av_fifo_write(s->async_fifo, &aframe, 1);
858
859 852
860 if (qsv_fifo_size(s->async_fifo) > s->async_depth) {853 if (av_fifo_can_read(s->async_fifo) > s->async_depth) {
861 av_fifo_generic_read(s->async_fifo, &tmp, sizeof(tmp), NULL);854 av_fifo_read(s->async_fifo, &aframe, 1);
862 av_fifo_generic_read(s->async_fifo, &sync, sizeof(sync), NULL);
863 855
864 do {856 do {
865 ret = MFXVideoCORE_SyncOperation(s->session, sync, 1000);857 ret = MFXVideoCORE_SyncOperation(s->session, aframe.sync, 1000);
866 } while (ret == MFX_WRN_IN_EXECUTION);858 } while (ret == MFX_WRN_IN_EXECUTION);
867 859
868 filter_ret = s->filter_frame(outlink, tmp->frame);860 filter_ret = s->filter_frame(outlink, tmp->frame);
libavfilter/qsvvpp.h+1−1
@@ -73,7 +73,7 @@ typedef struct QSVVPPContext { · 72 unmodified lines
73 int async_depth;73 int async_depth;
74 int eof;74 int eof;
75 /** order with frame_out, sync */75 /** order with frame_out, sync */
76 AVFifoBuffer *async_fifo;76 AVFifo *async_fifo;
77} QSVVPPContext;77} QSVVPPContext;
78 78
79typedef struct QSVVPPCrop {79typedef struct QSVVPPCrop {

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