diff mbox series

[FFmpeg-devel] libavcodec/qsvdec.c: using queue count to unref frame

Message ID 20210311052639.488078-1-wenbin.chen@intel.com
State Superseded
Headers show
Series [FFmpeg-devel] libavcodec/qsvdec.c: using queue count to unref frame | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Wenbin Chen March 11, 2021, 5:26 a.m. UTC
From: "Chen,Wenbin" <wenbin.chen@intel.com>

MSDK vc1 and av1 sometimes output frame into the same suface, but
ffmpeg-qsv assume the surface will be used only once, so it will
unref the frame when it receives the outpur surface. Now change
it to unref frame according to queue count.

Signed-off-by Wenbin Chen <wenbin.chen@intel.com>
---
 libavcodec/qsvdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Xiang, Haihao March 11, 2021, 8:39 a.m. UTC | #1
On Thu, 2021-03-11 at 13:26 +0800, wenbin.chen@intel.com wrote:
> From: "Chen,Wenbin" <wenbin.chen@intel.com>
> 
> MSDK vc1 and av1 sometimes output frame into the same suface, but
> ffmpeg-qsv assume the surface will be used only once, so it will
> unref the frame when it receives the outpur surface. Now change

typo? s/outpur/output

> it to unref frame according to queue count.
> 
> Signed-off-by Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavcodec/qsvdec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index d10f90a0db..e073e10699 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -470,7 +470,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext
> *q,
>              return AVERROR_BUG;
>          }
>  
> -        out_frame->queued = 1;
> +        out_frame->queued += 1;
>          av_fifo_generic_write(q->async_fifo, &out_frame, sizeof(out_frame),
> NULL);
>          av_fifo_generic_write(q->async_fifo,
> &sync,      sizeof(sync),      NULL);
>      } else {
> @@ -483,7 +483,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext
> *q,
>  
>          av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame),
> NULL);
>          av_fifo_generic_read(q->async_fifo,
> &sync,      sizeof(sync),      NULL);
> -        out_frame->queued = 0;
> +        out_frame->queued -= 1;
>  
>          if (avctx->pix_fmt != AV_PIX_FMT_QSV) {
>              do {
Wenbin Chen March 11, 2021, 8:44 a.m. UTC | #2
> -----Original Message-----
> From: Xiang, Haihao <haihao.xiang@intel.com>
> Sent: Thursday, March 11, 2021 4:39 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Chen, Wenbin <wenbin.chen@intel.com>
> Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec.c: using queue count
> to unref frame
> 
> On Thu, 2021-03-11 at 13:26 +0800, wenbin.chen@intel.com wrote:
> > From: "Chen,Wenbin" <wenbin.chen@intel.com>
> >
> > MSDK vc1 and av1 sometimes output frame into the same suface, but
> > ffmpeg-qsv assume the surface will be used only once, so it will
> > unref the frame when it receives the outpur surface. Now change
> 
> typo? s/outpur/output

yes typo. Do I need to submit again?

> 
> > it to unref frame according to queue count.
> >
> > Signed-off-by Wenbin Chen <wenbin.chen@intel.com>
> > ---
> >  libavcodec/qsvdec.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index d10f90a0db..e073e10699 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -470,7 +470,7 @@ static int qsv_decode(AVCodecContext *avctx,
> QSVContext
> > *q,
> >              return AVERROR_BUG;
> >          }
> >
> > -        out_frame->queued = 1;
> > +        out_frame->queued += 1;
> >          av_fifo_generic_write(q->async_fifo, &out_frame, sizeof(out_frame),
> > NULL);
> >          av_fifo_generic_write(q->async_fifo,
> > &sync,      sizeof(sync),      NULL);
> >      } else {
> > @@ -483,7 +483,7 @@ static int qsv_decode(AVCodecContext *avctx,
> QSVContext
> > *q,
> >
> >          av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame),
> > NULL);
> >          av_fifo_generic_read(q->async_fifo,
> > &sync,      sizeof(sync),      NULL);
> > -        out_frame->queued = 0;
> > +        out_frame->queued -= 1;
> >
> >          if (avctx->pix_fmt != AV_PIX_FMT_QSV) {
> >              do {
Xiang, Haihao March 12, 2021, 2:25 a.m. UTC | #3
On Thu, 2021-03-11 at 08:44 +0000, Chen, Wenbin wrote:
> > -----Original Message-----
> > From: Xiang, Haihao <haihao.xiang@intel.com>
> > Sent: Thursday, March 11, 2021 4:39 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Chen, Wenbin <wenbin.chen@intel.com>
> > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvdec.c: using queue count
> > to unref frame
> > 
> > On Thu, 2021-03-11 at 13:26 +0800, wenbin.chen@intel.com wrote:
> > > From: "Chen,Wenbin" <wenbin.chen@intel.com>
> > > 
> > > MSDK vc1 and av1 sometimes output frame into the same suface, but
> > > ffmpeg-qsv assume the surface will be used only once, so it will
> > > unref the frame when it receives the outpur surface. Now change
> > 
> > typo? s/outpur/output
> 
> yes typo. Do I need to submit again?
> 

Yes, I think you should re-submit the patch, otherwise others have to change it
for you.

Thanks
Haihao

> > 
> > > it to unref frame according to queue count.
> > > 
> > > Signed-off-by Wenbin Chen <wenbin.chen@intel.com>
> > > ---
> > >  libavcodec/qsvdec.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > > index d10f90a0db..e073e10699 100644
> > > --- a/libavcodec/qsvdec.c
> > > +++ b/libavcodec/qsvdec.c
> > > @@ -470,7 +470,7 @@ static int qsv_decode(AVCodecContext *avctx,
> > 
> > QSVContext
> > > *q,
> > >              return AVERROR_BUG;
> > >          }
> > > 
> > > -        out_frame->queued = 1;
> > > +        out_frame->queued += 1;
> > >          av_fifo_generic_write(q->async_fifo, &out_frame,
> > > sizeof(out_frame),
> > > NULL);
> > >          av_fifo_generic_write(q->async_fifo,
> > > &sync,      sizeof(sync),      NULL);
> > >      } else {
> > > @@ -483,7 +483,7 @@ static int qsv_decode(AVCodecContext *avctx,
> > 
> > QSVContext
> > > *q,
> > > 
> > >          av_fifo_generic_read(q->async_fifo, &out_frame,
> > > sizeof(out_frame),
> > > NULL);
> > >          av_fifo_generic_read(q->async_fifo,
> > > &sync,      sizeof(sync),      NULL);
> > > -        out_frame->queued = 0;
> > > +        out_frame->queued -= 1;
> > > 
> > >          if (avctx->pix_fmt != AV_PIX_FMT_QSV) {
> > >              do {
diff mbox series

Patch

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index d10f90a0db..e073e10699 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -470,7 +470,7 @@  static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
             return AVERROR_BUG;
         }
 
-        out_frame->queued = 1;
+        out_frame->queued += 1;
         av_fifo_generic_write(q->async_fifo, &out_frame, sizeof(out_frame), NULL);
         av_fifo_generic_write(q->async_fifo, &sync,      sizeof(sync),      NULL);
     } else {
@@ -483,7 +483,7 @@  static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
 
         av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame), NULL);
         av_fifo_generic_read(q->async_fifo, &sync,      sizeof(sync),      NULL);
-        out_frame->queued = 0;
+        out_frame->queued -= 1;
 
         if (avctx->pix_fmt != AV_PIX_FMT_QSV) {
             do {