diff mbox

[FFmpeg-devel] lavc/qsvdec: reinit if the resolution changes little

Message ID 20190213100010.30537-1-linjie.fu@intel.com
State New
Headers show

Commit Message

Fu, Linjie Feb. 13, 2019, 10 a.m. UTC
Currently, resolution change detection is based on 16 alignment,
small resolution changes (same after FFALIGN 16) in coded width or
coded height will not trigger the reinit and will lead to a decode
failure.

Modify to use last_coded_width and last_coded_height to detect the
small resolution change.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/qsvdec.c | 8 +++++---
 libavcodec/qsvdec.h | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Zhong Li Feb. 21, 2019, 9:52 a.m. UTC | #1
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Linjie Fu

> Sent: Wednesday, February 13, 2019 6:00 PM

> To: ffmpeg-devel@ffmpeg.org

> Cc: Fu, Linjie <linjie.fu@intel.com>

> Subject: [FFmpeg-devel] [PATCH] lavc/qsvdec: reinit if the resolution changes

> little

> 

> Currently, resolution change detection is based on 16 alignment, small

> resolution changes (same after FFALIGN 16) in coded width or coded height

> will not trigger the reinit and will lead to a decode failure.

> 

> Modify to use last_coded_width and last_coded_height to detect the small

> resolution change.

> 

> Signed-off-by: Linjie Fu <linjie.fu@intel.com>


Is it still needed if https://patchwork.ffmpeg.org/patch/12112/ applied?
Fu, Linjie Feb. 22, 2019, 2:40 a.m. UTC | #2
> -----Original Message-----

> From: Li, Zhong

> Sent: Thursday, February 21, 2019 17:53

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Cc: Fu, Linjie <linjie.fu@intel.com>

> Subject: RE: [FFmpeg-devel] [PATCH] lavc/qsvdec: reinit if the resolution

> changes little

> 

> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> Behalf

> > Of Linjie Fu

> > Sent: Wednesday, February 13, 2019 6:00 PM

> > To: ffmpeg-devel@ffmpeg.org

> > Cc: Fu, Linjie <linjie.fu@intel.com>

> > Subject: [FFmpeg-devel] [PATCH] lavc/qsvdec: reinit if the resolution

> changes

> > little

> >

> > Currently, resolution change detection is based on 16 alignment, small

> > resolution changes (same after FFALIGN 16) in coded width or coded height

> > will not trigger the reinit and will lead to a decode failure.

> >

> > Modify to use last_coded_width and last_coded_height to detect the small

> > resolution change.

> >

> > Signed-off-by: Linjie Fu <linjie.fu@intel.com>

> 

> Is it still needed if https://patchwork.ffmpeg.org/patch/12112/ applied?


Garbage still exists after applying the patch set. 
Will comment under patch 12112.
Fu, Linjie May 22, 2019, 4:21 a.m. UTC | #3
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Fu, Linjie

> Sent: Friday, February 22, 2019 10:40

> To: Li, Zhong <zhong.li@intel.com>; FFmpeg development discussions and

> patches <ffmpeg-devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: reinit if the resolution

> changes little

> 

> > -----Original Message-----

> > From: Li, Zhong

> > Sent: Thursday, February 21, 2019 17:53

> > To: FFmpeg development discussions and patches <ffmpeg-

> > devel@ffmpeg.org>

> > Cc: Fu, Linjie <linjie.fu@intel.com>

> > Subject: RE: [FFmpeg-devel] [PATCH] lavc/qsvdec: reinit if the resolution

> > changes little

> >

> > > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> > Behalf

> > > Of Linjie Fu

> > > Sent: Wednesday, February 13, 2019 6:00 PM

> > > To: ffmpeg-devel@ffmpeg.org

> > > Cc: Fu, Linjie <linjie.fu@intel.com>

> > > Subject: [FFmpeg-devel] [PATCH] lavc/qsvdec: reinit if the resolution

> > changes

> > > little

> > >

> > > Currently, resolution change detection is based on 16 alignment, small

> > > resolution changes (same after FFALIGN 16) in coded width or coded

> height

> > > will not trigger the reinit and will lead to a decode failure.

> > >

> > > Modify to use last_coded_width and last_coded_height to detect the

> small

> > > resolution change.

> > >

> > > Signed-off-by: Linjie Fu <linjie.fu@intel.com>

> >

> > Is it still needed if https://patchwork.ffmpeg.org/patch/12112/ applied?

> 

> Garbage still exists after applying the patch set.

> Will comment under patch 12112.


Ping?
diff mbox

Patch

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 4a0be811fb..b29f869366 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -523,9 +523,9 @@  int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
 
     avctx->field_order  = q->parser->field_order;
     /* TODO: flush delayed frames on reinit */
-    if (q->parser->format       != q->orig_pix_fmt    ||
-        FFALIGN(q->parser->coded_width, 16)  != FFALIGN(avctx->coded_width, 16) ||
-        FFALIGN(q->parser->coded_height, 16) != FFALIGN(avctx->coded_height, 16)) {
+    if (q->parser->format != q->orig_pix_fmt ||
+        q->last_coded_height != q->parser->coded_height ||
+        q->last_coded_width !=  q->parser->coded_width) {
         enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV,
                                            AV_PIX_FMT_NONE,
                                            AV_PIX_FMT_NONE };
@@ -558,6 +558,8 @@  int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
         avctx->coded_height = FFALIGN(q->parser->coded_height, 16);
         avctx->level        = q->avctx_internal->level;
         avctx->profile      = q->avctx_internal->profile;
+        q->last_coded_width = q->parser->coded_width;
+        q->last_coded_height = q->parser->coded_height;
 
         ret = ff_get_format(avctx, pix_fmts);
         if (ret < 0)
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index 111536caba..1af0c42404 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -55,6 +55,8 @@  typedef struct QSVContext {
     int zero_consume_run;
     int buffered_count;
     int reinit_flag;
+    int last_coded_width;
+    int last_coded_height;
 
     // the internal parser and codec context for parsing the data
     AVCodecParserContext *parser;