diff options
author | Fei Wang <fei.w.wang@intel.com> | 2021-10-12 16:24:03 +0800 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-10-16 19:00:44 -0300 |
commit | dc94f2eaaf0ae623d7dc02e1273c829015c025a3 (patch) | |
tree | 4c19c1518bf57c1a969af85f3a92b9cf260df17c | |
parent | 7871144cf801bc8b9e3b00319dd7c3c3d91dd3fa (diff) | |
download | ffmpeg-dc94f2eaaf0ae623d7dc02e1273c829015c025a3.tar.gz |
avcodec/av1_vaapi: enable segmentation features
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
-rw-r--r-- | libavcodec/vaapi_av1.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavcodec/vaapi_av1.c b/libavcodec/vaapi_av1.c index 26476c7738..c57d1b898a 100644 --- a/libavcodec/vaapi_av1.c +++ b/libavcodec/vaapi_av1.c @@ -126,6 +126,9 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, int err = 0; int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain; uint8_t remap_lr_type[4] = {AV1_RESTORE_NONE, AV1_RESTORE_SWITCHABLE, AV1_RESTORE_WIENER, AV1_RESTORE_SGRPROJ}; + uint8_t segmentation_feature_signed[AV1_SEG_LVL_MAX] = {1, 1, 1, 1, 1, 0, 0, 0}; + uint8_t segmentation_feature_max[AV1_SEG_LVL_MAX] = {255, AV1_MAX_LOOP_FILTER, + AV1_MAX_LOOP_FILTER, AV1_MAX_LOOP_FILTER, AV1_MAX_LOOP_FILTER, 7 , 0 , 0 }; bit_depth_idx = vaapi_av1_get_bit_depth_idx(avctx); if (bit_depth_idx < 0) @@ -293,6 +296,17 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, for (int j = 0; j < 6; j++) pic_param.wm[i - 1].wmmat[j] = s->cur_frame.gm_params[i][j]; } + for (int i = 0; i < AV1_MAX_SEGMENTS; i++) { + for (int j = 0; j < AV1_SEG_LVL_MAX; j++) { + pic_param.seg_info.feature_mask[i] |= (frame_header->feature_enabled[i][j] << j); + if (segmentation_feature_signed[j]) + pic_param.seg_info.feature_data[i][j] = av_clip(frame_header->feature_value[i][j], + -segmentation_feature_max[j], segmentation_feature_max[j]); + else + pic_param.seg_info.feature_data[i][j] = av_clip(frame_header->feature_value[i][j], + 0, segmentation_feature_max[j]); + } + } if (apply_grain) { for (int i = 0; i < film_grain->num_y_points; i++) { pic_param.film_grain_info.point_y_value[i] = |