[FFmpeg-cvslog] avcodec/av1_vaapi: enable segmentation features

Fei Wang git at videolan.org
Sun Oct 17 01:03:20 EEST 2021


ffmpeg | branch: master | Fei Wang <fei.w.wang at intel.com> | Tue Oct 12 16:24:03 2021 +0800| [dc94f2eaaf0ae623d7dc02e1273c829015c025a3] | committer: James Almer

avcodec/av1_vaapi: enable segmentation features

Signed-off-by: Fei Wang <fei.w.wang at intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc94f2eaaf0ae623d7dc02e1273c829015c025a3
---

 libavcodec/vaapi_av1.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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] =



More information about the ffmpeg-cvslog mailing list