diff mbox

[FFmpeg-devel] qsv: get FrameInfo.Shift by desc->comp[0].shift

Message ID 1568131743-20177-1-git-send-email-linjie.fu@intel.com
State New
Headers show

Commit Message

Fu, Linjie Sept. 10, 2019, 4:09 p.m. UTC
Since Y410 is a pixel format with depth > 8 but shift = 0, get Shift
info by depth is not quite accurate.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/qsvenc.c       | 4 ++--
 libavutil/hwcontext_qsv.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Zhong Li Sept. 12, 2019, 1:23 p.m. UTC | #1
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Linjie Fu

> Sent: Wednesday, September 11, 2019 12:09 AM

> To: ffmpeg-devel@ffmpeg.org

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

> Subject: [FFmpeg-devel] [PATCH] qsv: get FrameInfo.Shift by desc->comp[0].shift

> 

> Since Y410 is a pixel format with depth > 8 but shift = 0, get Shift info by depth is

> not quite accurate.

> 

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

> ---

>  libavcodec/qsvenc.c       | 4 ++--

>  libavutil/hwcontext_qsv.c | 2 +-

>  2 files changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 9bf8574..912f2a8

> 100644

> --- a/libavcodec/qsvenc.c

> +++ b/libavcodec/qsvenc.c

> @@ -437,7 +437,7 @@ static int init_video_param_jpeg(AVCodecContext

> *avctx, QSVEncContext *q)

>      q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;

>      q->param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;

>      q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;

> -    q->param.mfx.FrameInfo.Shift          = desc->comp[0].depth > 8;

> +    q->param.mfx.FrameInfo.Shift          = desc->comp[0].shift > 0;


Is it safe enough? 
As MSDK docs: "Not all codecs and SDK implementations support this value. Use Query function to check if this feature is supported."
Fu, Linjie Dec. 2, 2019, 10:04 a.m. UTC | #2
> -----Original Message-----

> From: Li, Zhong <zhong.li@intel.com>

> Sent: Thursday, September 12, 2019 21:23

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

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

> Subject: RE: [FFmpeg-devel] [PATCH] qsv: get FrameInfo.Shift by desc-

> >comp[0].shift

> 

> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of

> Linjie Fu

> > Sent: Wednesday, September 11, 2019 12:09 AM

> > To: ffmpeg-devel@ffmpeg.org

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

> > Subject: [FFmpeg-devel] [PATCH] qsv: get FrameInfo.Shift by desc-

> >comp[0].shift

> >

> > Since Y410 is a pixel format with depth > 8 but shift = 0, get Shift info by

> depth is

> > not quite accurate.

> >

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

> > ---

> >  libavcodec/qsvenc.c       | 4 ++--

> >  libavutil/hwcontext_qsv.c | 2 +-

> >  2 files changed, 3 insertions(+), 3 deletions(-)

> >

> > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index

> 9bf8574..912f2a8

> > 100644

> > --- a/libavcodec/qsvenc.c

> > +++ b/libavcodec/qsvenc.c

> > @@ -437,7 +437,7 @@ static int init_video_param_jpeg(AVCodecContext

> > *avctx, QSVEncContext *q)

> >      q->param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV420;

> >      q->param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;

> >      q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;

> > -    q->param.mfx.FrameInfo.Shift          = desc->comp[0].depth > 8;

> > +    q->param.mfx.FrameInfo.Shift          = desc->comp[0].shift > 0;

> 

> Is it safe enough?

> As MSDK docs: "Not all codecs and SDK implementations support this value.

> Use Query function to check if this feature is supported."


Checked the MSDK doc:
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxFrameInfo

It shows that not only Shift, but also BitDepthLuma and BitDepthChroma are warned with:
"Not all codecs and SDK implementations support this value. Use Query function to check if this feature is supported."

Hence I think we could fix this in a separate patch to make the usage of FrameInfo.Shift/BitDepthLuma/BitDepthChroma
Safer if necessary.

Thanks,
- linjie
diff mbox

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 9bf8574..912f2a8 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -437,7 +437,7 @@  static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q)
     q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
     q->param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
     q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
-    q->param.mfx.FrameInfo.Shift          = desc->comp[0].depth > 8;
+    q->param.mfx.FrameInfo.Shift          = desc->comp[0].shift > 0;
 
     q->param.mfx.FrameInfo.Width  = FFALIGN(avctx->width, 16);
     q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 16);
@@ -532,7 +532,7 @@  static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
     q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
     q->param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
     q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
-    q->param.mfx.FrameInfo.Shift          = desc->comp[0].depth > 8;
+    q->param.mfx.FrameInfo.Shift          = desc->comp[0].shift > 0;
 
     // If the minor version is greater than or equal to 19,
     // then can use the same alignment settings as H.264 for HEVC
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 7f8f2de..d722c9a 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -323,7 +323,7 @@  static int qsv_init_surface(AVHWFramesContext *ctx, mfxFrameSurface1 *surf)
 
     surf->Info.BitDepthLuma   = desc->comp[0].depth;
     surf->Info.BitDepthChroma = desc->comp[0].depth;
-    surf->Info.Shift          = desc->comp[0].depth > 8;
+    surf->Info.Shift          = desc->comp[0].shift > 0;
 
     if (desc->log2_chroma_w && desc->log2_chroma_h)
         surf->Info.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;