* [FFmpeg-devel] [PATCH v2] lavc/vaapi_hevc: fill rext luma/chroma offset in the right way
@ 2022-06-10 12:47 Fei Wang
2022-06-17 5:14 ` Xiang, Haihao
0 siblings, 1 reply; 2+ messages in thread
From: Fei Wang @ 2022-06-10 12:47 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Xu Guangxin, Linjie Fu, Fei Wang
From: Xu Guangxin <guangxin.xu@intel.com>
For range extension, the luma/chroma offset is larger than 8 bits, we
need fill the 16 bits version.
Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
update:
1. Add some warning log.
libavcodec/vaapi_hevc.c | 55 +++++++++++++++++++++++++++++------------
1 file changed, 39 insertions(+), 16 deletions(-)
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 9083331c45..d82975979a 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -322,11 +322,20 @@ fail:
return ret;
}
-static void fill_pred_weight_table(const HEVCContext *h,
+static void fill_pred_weight_table(AVCodecContext *avctx,
+ const HEVCContext *h,
const SliceHeader *sh,
VASliceParameterBufferHEVC *slice_param)
{
int i;
+#if VA_CHECK_VERSION(1, 2, 0)
+ int is_rext = avctx->profile >= FF_PROFILE_HEVC_REXT;
+#else
+ int is_rext = 0;
+ if (avctx->profile >= FF_PROFILE_HEVC_REXT)
+ av_log(avctx, AV_LOG_WARNING, "Please consider to update to VAAPI 1.2.0 "
+ "or above, which can support REXT related setting correctly.\n");
+#endif
memset(slice_param->delta_luma_weight_l0, 0, sizeof(slice_param->delta_luma_weight_l0));
memset(slice_param->delta_luma_weight_l1, 0, sizeof(slice_param->delta_luma_weight_l1));
@@ -353,21 +362,25 @@ static void fill_pred_weight_table(const HEVCContext *h,
for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
slice_param->delta_luma_weight_l0[i] = sh->luma_weight_l0[i] - (1 << sh->luma_log2_weight_denom);
- slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
slice_param->delta_chroma_weight_l0[i][0] = sh->chroma_weight_l0[i][0] - (1 << sh->chroma_log2_weight_denom);
slice_param->delta_chroma_weight_l0[i][1] = sh->chroma_weight_l0[i][1] - (1 << sh->chroma_log2_weight_denom);
- slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
- slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+ if (!is_rext) {
+ slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
+ slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
+ slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+ }
}
if (sh->slice_type == HEVC_SLICE_B) {
for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
slice_param->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - (1 << sh->luma_log2_weight_denom);
- slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
slice_param->delta_chroma_weight_l1[i][0] = sh->chroma_weight_l1[i][0] - (1 << sh->chroma_log2_weight_denom);
slice_param->delta_chroma_weight_l1[i][1] = sh->chroma_weight_l1[i][1] - (1 << sh->chroma_log2_weight_denom);
- slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
- slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+ if (!is_rext) {
+ slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
+ slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
+ slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+ }
}
}
}
@@ -462,7 +475,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h, rpl->ref[i]);
}
- fill_pred_weight_table(h, sh, last_slice_param);
+ fill_pred_weight_table(avctx, h, sh, last_slice_param);
#if VA_CHECK_VERSION(1, 2, 0)
if (avctx->profile == FF_PROFILE_HEVC_REXT) {
@@ -471,15 +484,25 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
.cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag,
},
};
+ for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
+ pic->last_slice_param.rext.luma_offset_l0[i] = sh->luma_offset_l0[i];
+ pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
+ pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+ }
+
+ for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
+ pic->last_slice_param.rext.luma_offset_l0[i] = sh->luma_offset_l0[i];
+ pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
+ pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
+ }
- memcpy(pic->last_slice_param.rext.luma_offset_l0, pic->last_slice_param.base.luma_offset_l0,
- sizeof(pic->last_slice_param.base.luma_offset_l0));
- memcpy(pic->last_slice_param.rext.luma_offset_l1, pic->last_slice_param.base.luma_offset_l1,
- sizeof(pic->last_slice_param.base.luma_offset_l1));
- memcpy(pic->last_slice_param.rext.ChromaOffsetL0, pic->last_slice_param.base.ChromaOffsetL0,
- sizeof(pic->last_slice_param.base.ChromaOffsetL0));
- memcpy(pic->last_slice_param.rext.ChromaOffsetL1, pic->last_slice_param.base.ChromaOffsetL1,
- sizeof(pic->last_slice_param.base.ChromaOffsetL1));
+ if (sh->slice_type == HEVC_SLICE_B) {
+ for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
+ pic->last_slice_param.rext.luma_offset_l1[i] = sh->luma_offset_l1[i];
+ pic->last_slice_param.rext.ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
+ pic->last_slice_param.rext.ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
+ }
+ }
}
#endif
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] lavc/vaapi_hevc: fill rext luma/chroma offset in the right way
2022-06-10 12:47 [FFmpeg-devel] [PATCH v2] lavc/vaapi_hevc: fill rext luma/chroma offset in the right way Fei Wang
@ 2022-06-17 5:14 ` Xiang, Haihao
0 siblings, 0 replies; 2+ messages in thread
From: Xiang, Haihao @ 2022-06-17 5:14 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Xu, Guangxin, linjie.justin.fu, Wang, Fei W
On Fri, 2022-06-10 at 20:47 +0800, Fei Wang wrote:
> From: Xu Guangxin <guangxin.xu@intel.com>
>
> For range extension, the luma/chroma offset is larger than 8 bits, we
> need fill the 16 bits version.
>
> Signed-off-by: Xu Guangxin <guangxin.xu@intel.com>
> Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
> update:
> 1. Add some warning log.
>
> libavcodec/vaapi_hevc.c | 55 +++++++++++++++++++++++++++++------------
> 1 file changed, 39 insertions(+), 16 deletions(-)
>
> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> index 9083331c45..d82975979a 100644
> --- a/libavcodec/vaapi_hevc.c
> +++ b/libavcodec/vaapi_hevc.c
> @@ -322,11 +322,20 @@ fail:
> return ret;
> }
>
> -static void fill_pred_weight_table(const HEVCContext *h,
> +static void fill_pred_weight_table(AVCodecContext *avctx,
> + const HEVCContext *h,
> const SliceHeader *sh,
> VASliceParameterBufferHEVC *slice_param)
> {
> int i;
> +#if VA_CHECK_VERSION(1, 2, 0)
> + int is_rext = avctx->profile >= FF_PROFILE_HEVC_REXT;
> +#else
> + int is_rext = 0;
> + if (avctx->profile >= FF_PROFILE_HEVC_REXT)
> + av_log(avctx, AV_LOG_WARNING, "Please consider to update to VAAPI
> 1.2.0 "
> + "or above, which can support REXT related setting
> correctly.\n");
> +#endif
>
> memset(slice_param->delta_luma_weight_l0, 0, sizeof(slice_param-
> >delta_luma_weight_l0));
> memset(slice_param->delta_luma_weight_l1, 0, sizeof(slice_param-
> >delta_luma_weight_l1));
> @@ -353,21 +362,25 @@ static void fill_pred_weight_table(const HEVCContext *h,
>
> for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
> slice_param->delta_luma_weight_l0[i] = sh->luma_weight_l0[i] - (1 <<
> sh->luma_log2_weight_denom);
> - slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
> slice_param->delta_chroma_weight_l0[i][0] = sh-
> >chroma_weight_l0[i][0] - (1 << sh->chroma_log2_weight_denom);
> slice_param->delta_chroma_weight_l0[i][1] = sh-
> >chroma_weight_l0[i][1] - (1 << sh->chroma_log2_weight_denom);
> - slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
> - slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
> + if (!is_rext) {
> + slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
> + slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
> + slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
> + }
> }
>
> if (sh->slice_type == HEVC_SLICE_B) {
> for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
> slice_param->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - (1
> << sh->luma_log2_weight_denom);
> - slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
> slice_param->delta_chroma_weight_l1[i][0] = sh-
> >chroma_weight_l1[i][0] - (1 << sh->chroma_log2_weight_denom);
> slice_param->delta_chroma_weight_l1[i][1] = sh-
> >chroma_weight_l1[i][1] - (1 << sh->chroma_log2_weight_denom);
> - slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
> - slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
> + if (!is_rext) {
> + slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
> + slice_param->ChromaOffsetL1[i][0] = sh-
> >chroma_offset_l1[i][0];
> + slice_param->ChromaOffsetL1[i][1] = sh-
> >chroma_offset_l1[i][1];
> + }
> }
> }
> }
> @@ -462,7 +475,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
> last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h,
> rpl->ref[i]);
> }
>
> - fill_pred_weight_table(h, sh, last_slice_param);
> + fill_pred_weight_table(avctx, h, sh, last_slice_param);
>
> #if VA_CHECK_VERSION(1, 2, 0)
> if (avctx->profile == FF_PROFILE_HEVC_REXT) {
> @@ -471,15 +484,25 @@ static int vaapi_hevc_decode_slice(AVCodecContext
> *avctx,
> .cu_chroma_qp_offset_enabled_flag = sh-
> >cu_chroma_qp_offset_enabled_flag,
> },
> };
> + for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
> + pic->last_slice_param.rext.luma_offset_l0[i] = sh-
> >luma_offset_l0[i];
> + pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh-
> >chroma_offset_l0[i][0];
> + pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh-
> >chroma_offset_l0[i][1];
> + }
> +
> + for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
> + pic->last_slice_param.rext.luma_offset_l0[i] = sh-
> >luma_offset_l0[i];
> + pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh-
> >chroma_offset_l0[i][0];
> + pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh-
> >chroma_offset_l0[i][1];
> + }
>
> - memcpy(pic->last_slice_param.rext.luma_offset_l0, pic-
> >last_slice_param.base.luma_offset_l0,
> - sizeof(pic-
> >last_slice_param.base.luma_offset_l0));
> - memcpy(pic->last_slice_param.rext.luma_offset_l1, pic-
> >last_slice_param.base.luma_offset_l1,
> - sizeof(pic-
> >last_slice_param.base.luma_offset_l1));
> - memcpy(pic->last_slice_param.rext.ChromaOffsetL0, pic-
> >last_slice_param.base.ChromaOffsetL0,
> - sizeof(pic-
> >last_slice_param.base.ChromaOffsetL0));
> - memcpy(pic->last_slice_param.rext.ChromaOffsetL1, pic-
> >last_slice_param.base.ChromaOffsetL1,
> - sizeof(pic-
> >last_slice_param.base.ChromaOffsetL1));
> + if (sh->slice_type == HEVC_SLICE_B) {
> + for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
> + pic->last_slice_param.rext.luma_offset_l1[i] = sh-
> >luma_offset_l1[i];
> + pic->last_slice_param.rext.ChromaOffsetL1[i][0] = sh-
> >chroma_offset_l1[i][0];
> + pic->last_slice_param.rext.ChromaOffsetL1[i][1] = sh-
> >chroma_offset_l1[i][1];
> + }
> + }
> }
> #endif
LGTM, will apply.
-Haihao
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-17 5:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 12:47 [FFmpeg-devel] [PATCH v2] lavc/vaapi_hevc: fill rext luma/chroma offset in the right way Fei Wang
2022-06-17 5:14 ` Xiang, Haihao
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git