Message ID | 20210728081547.26105-1-haihao.xiang@intel.com |
---|---|
State | Accepted |
Commit | c8cfe676948c1d97c8d6d50564065d0f2d52a568 |
Headers | show |
Series | [FFmpeg-devel,1/2] lavc/qsvdec: update color properties in codec context | expand |
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 |
On Wed, Jul 28, 2021 at 4:16 PM Haihao Xiang <haihao.xiang@intel.com> wrote: > > User may get color properties from the SDK via VIDEO_SIGNAL_INFO extbuf > --- > libavcodec/qsvdec.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c > index 622750927c..19a6a776db 100644 > --- a/libavcodec/qsvdec.c > +++ b/libavcodec/qsvdec.c > @@ -311,7 +311,8 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, > mfxVideoParam *param) > { > int ret; > - > + mfxExtVideoSignalInfo video_signal_info = { 0 }; > + mfxExtBuffer *header_ext_params[1] = { (mfxExtBuffer *)&video_signal_info }; > mfxBitstream bs = { 0 }; > > if (avpkt->size) { > @@ -336,6 +337,12 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, > return ret; > > param->mfx.CodecId = ret; > + video_signal_info.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO; > + video_signal_info.Header.BufferSz = sizeof(video_signal_info); > + // The SDK doesn't support other ext buffers when calling MFXVideoDECODE_DecodeHeader, > + // so do not append this buffer to the existent buffer array > + param->ExtParam = header_ext_params; > + param->NumExtParam = 1; > ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, param); > if (MFX_ERR_MORE_DATA == ret) { > return AVERROR(EAGAIN); > @@ -344,6 +351,17 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, > return ff_qsv_print_error(avctx, ret, > "Error decoding stream header"); > > + avctx->color_range = video_signal_info.VideoFullRange ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; > + > + if (video_signal_info.ColourDescriptionPresent) { > + avctx->color_primaries = video_signal_info.ColourPrimaries; > + avctx->color_trc = video_signal_info.TransferCharacteristics; > + avctx->colorspace = video_signal_info.MatrixCoefficients; > + } > + > + param->ExtParam = q->ext_buffers; > + param->NumExtParam = q->nb_ext_buffers; > + > return 0; > } > > -- > 2.17.1 Both patches LGTM
On Thu, 2021-07-29 at 13:12 +0800, mypopy@gmail.com wrote: > On Wed, Jul 28, 2021 at 4:16 PM Haihao Xiang <haihao.xiang@intel.com> wrote: > > > > User may get color properties from the SDK via VIDEO_SIGNAL_INFO extbuf > > --- > > libavcodec/qsvdec.c | 20 +++++++++++++++++++- > > 1 file changed, 19 insertions(+), 1 deletion(-) > > > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c > > index 622750927c..19a6a776db 100644 > > --- a/libavcodec/qsvdec.c > > +++ b/libavcodec/qsvdec.c > > @@ -311,7 +311,8 @@ static int qsv_decode_header(AVCodecContext *avctx, > > QSVContext *q, > > mfxVideoParam *param) > > { > > int ret; > > - > > + mfxExtVideoSignalInfo video_signal_info = { 0 }; > > + mfxExtBuffer *header_ext_params[1] = { (mfxExtBuffer > > *)&video_signal_info }; > > mfxBitstream bs = { 0 }; > > > > if (avpkt->size) { > > @@ -336,6 +337,12 @@ static int qsv_decode_header(AVCodecContext *avctx, > > QSVContext *q, > > return ret; > > > > param->mfx.CodecId = ret; > > + video_signal_info.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO; > > + video_signal_info.Header.BufferSz = sizeof(video_signal_info); > > + // The SDK doesn't support other ext buffers when calling > > MFXVideoDECODE_DecodeHeader, > > + // so do not append this buffer to the existent buffer array > > + param->ExtParam = header_ext_params; > > + param->NumExtParam = 1; > > ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, param); > > if (MFX_ERR_MORE_DATA == ret) { > > return AVERROR(EAGAIN); > > @@ -344,6 +351,17 @@ static int qsv_decode_header(AVCodecContext *avctx, > > QSVContext *q, > > return ff_qsv_print_error(avctx, ret, > > "Error decoding stream header"); > > > > + avctx->color_range = video_signal_info.VideoFullRange ? > > AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; > > + > > + if (video_signal_info.ColourDescriptionPresent) { > > + avctx->color_primaries = video_signal_info.ColourPrimaries; > > + avctx->color_trc = video_signal_info.TransferCharacteristics; > > + avctx->colorspace = video_signal_info.MatrixCoefficients; > > + } > > + > > + param->ExtParam = q->ext_buffers; > > + param->NumExtParam = q->nb_ext_buffers; > > + > > return 0; > > } > > > > -- > > 2.17.1 > > Both patches LGTM Thanks for the review. - Haihao
> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of > Haihao Xiang > Sent: Wednesday, 28 July 2021 10:16 > To: ffmpeg-devel@ffmpeg.org > Cc: Haihao Xiang <haihao.xiang@intel.com> > Subject: [FFmpeg-devel] [PATCH 1/2] lavc/qsvdec: update color properties in > codec context > > User may get color properties from the SDK via VIDEO_SIGNAL_INFO extbuf > --- > libavcodec/qsvdec.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index > 622750927c..19a6a776db 100644 > --- a/libavcodec/qsvdec.c > +++ b/libavcodec/qsvdec.c > @@ -311,7 +311,8 @@ static int qsv_decode_header(AVCodecContext > *avctx, QSVContext *q, > mfxVideoParam *param) { > int ret; > - > + mfxExtVideoSignalInfo video_signal_info = { 0 }; > + mfxExtBuffer *header_ext_params[1] = { (mfxExtBuffer > + *)&video_signal_info }; > mfxBitstream bs = { 0 }; > > if (avpkt->size) { > @@ -336,6 +337,12 @@ static int qsv_decode_header(AVCodecContext > *avctx, QSVContext *q, > return ret; > > param->mfx.CodecId = ret; > + video_signal_info.Header.BufferId = > MFX_EXTBUFF_VIDEO_SIGNAL_INFO; > + video_signal_info.Header.BufferSz = sizeof(video_signal_info); > + // The SDK doesn't support other ext buffers when calling > MFXVideoDECODE_DecodeHeader, > + // so do not append this buffer to the existent buffer array > + param->ExtParam = header_ext_params; > + param->NumExtParam = 1; > ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, param); > if (MFX_ERR_MORE_DATA == ret) { > return AVERROR(EAGAIN); > @@ -344,6 +351,17 @@ static int qsv_decode_header(AVCodecContext > *avctx, QSVContext *q, > return ff_qsv_print_error(avctx, ret, > "Error decoding stream header"); > > + avctx->color_range = video_signal_info.VideoFullRange ? > + AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; > + > + if (video_signal_info.ColourDescriptionPresent) { > + avctx->color_primaries = video_signal_info.ColourPrimaries; > + avctx->color_trc = video_signal_info.TransferCharacteristics; > + avctx->colorspace = video_signal_info.MatrixCoefficients; > + } > + > + param->ExtParam = q->ext_buffers; > + param->NumExtParam = q->nb_ext_buffers; > + > return 0; > } Patchset LGTM. Hopefully the addition of HDR to decoded surfaces will be completed soon, so we can add that as well: https://github.com/Intel-Media-SDK/MediaSDK/issues/2597
On 8/4/2021 5:36 AM, Soft Works wrote: > > >> -----Original Message----- >> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of >> Haihao Xiang >> Sent: Wednesday, 28 July 2021 10:16 >> To: ffmpeg-devel@ffmpeg.org >> Cc: Haihao Xiang <haihao.xiang@intel.com> >> Subject: [FFmpeg-devel] [PATCH 1/2] lavc/qsvdec: update color properties in >> codec context >> >> User may get color properties from the SDK via VIDEO_SIGNAL_INFO extbuf >> --- >> libavcodec/qsvdec.c | 20 +++++++++++++++++++- >> 1 file changed, 19 insertions(+), 1 deletion(-) >> >> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index >> 622750927c..19a6a776db 100644 >> --- a/libavcodec/qsvdec.c >> +++ b/libavcodec/qsvdec.c >> @@ -311,7 +311,8 @@ static int qsv_decode_header(AVCodecContext >> *avctx, QSVContext *q, >> mfxVideoParam *param) { >> int ret; >> - >> + mfxExtVideoSignalInfo video_signal_info = { 0 }; >> + mfxExtBuffer *header_ext_params[1] = { (mfxExtBuffer >> + *)&video_signal_info }; >> mfxBitstream bs = { 0 }; >> >> if (avpkt->size) { >> @@ -336,6 +337,12 @@ static int qsv_decode_header(AVCodecContext >> *avctx, QSVContext *q, >> return ret; >> >> param->mfx.CodecId = ret; >> + video_signal_info.Header.BufferId = >> MFX_EXTBUFF_VIDEO_SIGNAL_INFO; >> + video_signal_info.Header.BufferSz = sizeof(video_signal_info); >> + // The SDK doesn't support other ext buffers when calling >> MFXVideoDECODE_DecodeHeader, >> + // so do not append this buffer to the existent buffer array >> + param->ExtParam = header_ext_params; >> + param->NumExtParam = 1; >> ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, param); >> if (MFX_ERR_MORE_DATA == ret) { >> return AVERROR(EAGAIN); >> @@ -344,6 +351,17 @@ static int qsv_decode_header(AVCodecContext >> *avctx, QSVContext *q, >> return ff_qsv_print_error(avctx, ret, >> "Error decoding stream header"); >> >> + avctx->color_range = video_signal_info.VideoFullRange ? >> + AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; >> + >> + if (video_signal_info.ColourDescriptionPresent) { >> + avctx->color_primaries = video_signal_info.ColourPrimaries; >> + avctx->color_trc = video_signal_info.TransferCharacteristics; >> + avctx->colorspace = video_signal_info.MatrixCoefficients; >> + } >> + >> + param->ExtParam = q->ext_buffers; >> + param->NumExtParam = q->nb_ext_buffers; >> + >> return 0; >> } > > Patchset LGTM. > > Hopefully the addition of HDR to decoded surfaces will be completed soon, > so we can add that as well: https://github.com/Intel-Media-SDK/MediaSDK/issues/2597 Pushed, thanks.
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 622750927c..19a6a776db 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -311,7 +311,8 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, mfxVideoParam *param) { int ret; - + mfxExtVideoSignalInfo video_signal_info = { 0 }; + mfxExtBuffer *header_ext_params[1] = { (mfxExtBuffer *)&video_signal_info }; mfxBitstream bs = { 0 }; if (avpkt->size) { @@ -336,6 +337,12 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, return ret; param->mfx.CodecId = ret; + video_signal_info.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO; + video_signal_info.Header.BufferSz = sizeof(video_signal_info); + // The SDK doesn't support other ext buffers when calling MFXVideoDECODE_DecodeHeader, + // so do not append this buffer to the existent buffer array + param->ExtParam = header_ext_params; + param->NumExtParam = 1; ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, param); if (MFX_ERR_MORE_DATA == ret) { return AVERROR(EAGAIN); @@ -344,6 +351,17 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, return ff_qsv_print_error(avctx, ret, "Error decoding stream header"); + avctx->color_range = video_signal_info.VideoFullRange ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; + + if (video_signal_info.ColourDescriptionPresent) { + avctx->color_primaries = video_signal_info.ColourPrimaries; + avctx->color_trc = video_signal_info.TransferCharacteristics; + avctx->colorspace = video_signal_info.MatrixCoefficients; + } + + param->ExtParam = q->ext_buffers; + param->NumExtParam = q->nb_ext_buffers; + return 0; }