Module: Mesa
Branch: main
Commit: 6646ae257663685646a19b98bb815678a3de8603
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6646ae257663685646a19b98bb815678a3de8603

Author: Ruijing Dong <[email protected]>
Date:   Sat Sep 10 16:28:19 2022 -0400

frontends/va: change getEncParamPreset location

why:
getEncParamPreset functions overwrite the incoming
messages.

how:
To change a location after the decoder is created,
so that if no incoming message the default ones
will be used otherwise the new messages will
overwrite the default values.

Signed-off-by: Ruijing Dong <[email protected]>
Reviewed-by: Sil Vilerino <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18534>

---

 src/gallium/frontends/va/picture.c          | 17 +++++++++++++----
 src/gallium/frontends/va/picture_h264_enc.c |  2 ++
 src/gallium/frontends/va/picture_hevc_enc.c |  2 ++
 src/gallium/include/pipe/p_video_state.h    |  0
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/gallium/frontends/va/picture.c 
b/src/gallium/frontends/va/picture.c
index 422cd7914a1..7b34a0494e2 100644
--- a/src/gallium/frontends/va/picture.c
+++ b/src/gallium/frontends/va/picture.c
@@ -859,12 +859,21 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID 
context_id)
    }
 
    if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
+      struct pipe_screen *screen = context->decoder->context->screen;
       coded_buf = context->coded_buf;
-      if (u_reduce_video_profile(context->templat.profile) == 
PIPE_VIDEO_FORMAT_MPEG4_AVC) {
-         getEncParamPresetH264(context);
+      if (u_reduce_video_profile(context->templat.profile) == 
PIPE_VIDEO_FORMAT_MPEG4_AVC)
          context->desc.h264enc.frame_num_cnt++;
-      } else if (u_reduce_video_profile(context->templat.profile) == 
PIPE_VIDEO_FORMAT_HEVC)
-         getEncParamPresetH265(context);
+
+      /* keep other path the same way */
+      if (!screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN,
+                                  context->decoder->entrypoint,
+                                  PIPE_VIDEO_CAP_ENC_QUALITY_LEVEL)) {
+
+         if (u_reduce_video_profile(context->templat.profile) == 
PIPE_VIDEO_FORMAT_MPEG4_AVC)
+            getEncParamPresetH264(context);
+         else if (u_reduce_video_profile(context->templat.profile) == 
PIPE_VIDEO_FORMAT_HEVC)
+            getEncParamPresetH265(context);
+      }
 
       context->desc.base.input_format = surf->buffer->buffer_format;
       context->desc.base.output_format = surf->encoder_format;
diff --git a/src/gallium/frontends/va/picture_h264_enc.c 
b/src/gallium/frontends/va/picture_h264_enc.c
index abe9c1ba4e7..3ebfcfa7b31 100644
--- a/src/gallium/frontends/va/picture_h264_enc.c
+++ b/src/gallium/frontends/va/picture_h264_enc.c
@@ -157,6 +157,8 @@ vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver 
*drv, vlVaContext *con
       context->decoder = drv->pipe->create_video_codec(drv->pipe, 
&context->templat);
       if (!context->decoder)
          return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+      getEncParamPresetH264(context);
    }
 
    context->gop_coeff = ((1024 + h264->intra_idr_period - 1) / 
h264->intra_idr_period + 1) / 2 * 2;
diff --git a/src/gallium/frontends/va/picture_hevc_enc.c 
b/src/gallium/frontends/va/picture_hevc_enc.c
index 9fb28ee3a5c..1c6b37baf4b 100644
--- a/src/gallium/frontends/va/picture_hevc_enc.c
+++ b/src/gallium/frontends/va/picture_hevc_enc.c
@@ -134,6 +134,8 @@ vlVaHandleVAEncSequenceParameterBufferTypeHEVC(vlVaDriver 
*drv, vlVaContext *con
 
       if (!context->decoder)
          return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+      getEncParamPresetH265(context);
    }
 
    context->desc.h265enc.seq.general_profile_idc = h265->general_profile_idc;
diff --git a/src/gallium/include/pipe/p_video_state.h 
b/src/gallium/include/pipe/p_video_state.h
old mode 100755
new mode 100644

Reply via email to