<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Am 20.07.2016 um 06:12 schrieb Zhang,
      Boyuan:<br>
    </div>
    <blockquote
cite="mid:CY4PR12MB1127CA4361641759E6A0A06887080@CY4PR12MB1127.namprd12.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>
            @@ -150,7 +167,16 @@ vlVaCreateConfig(VADriverContextP ctx,
            VAProfile profile, VAEntrypoint entrypoin</span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>     
            if (entrypoint != VAEntrypointVLD)</span><br style="color:
            rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>
                    return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;</span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>   </span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>
            -   *config_id = p;</span><br style="color: rgb(33, 33, 33);
            font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>
            +   if (entrypoint == VAEntrypointEncSlice || entrypoint ==
            VAEntrypointEncPicture)</span><br style="color: rgb(33, 33,
            33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>
            +      config->entrypoint = PIPE_VIDEO_ENTRYPOINT_ENCODE;</span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>
            +   else</span><br style="color: rgb(33, 33, 33); font-size:
            13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>>
            +      config->entrypoint =
            PIPE_VIDEO_ENTRYPOINT_BITSTREAM;</span><br style="color:
            rgb(33, 33, 33); font-size: 13.3333px;">
          <br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>Well
            that doesn't make much sense here.</span><br style="color:
            rgb(33, 33, 33); font-size: 13.3333px;">
          <br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>First
            we return and error if the entrypoint isn't VAEntrypointVLD
            and </span><br style="color: rgb(33, 33, 33); font-size:
            13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>then
            check if it's an encoding entry point.</span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>Additional
            to that I already wondered if we are really going to
            support </span><br style="color: rgb(33, 33, 33); font-size:
            13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>slice
            level as well as picture level encoding.</span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>I
            think that it should only be one of the two.</span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <br style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>Regards,</span><br
            style="color: rgb(33, 33, 33); font-size: 13.3333px;">
          <span style="color: rgb(33, 33, 33); font-size: 13.3333px;">>Christian.</span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><br>
          </span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;">Hi
            Christian,</span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><br>
          </span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;">Sorry
            for the confusion, The first 2 lines of codes</span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><span
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;">>>     
              if (entrypoint != VAEntrypointVLD)</span><br
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;">
            <span style="font-family: Calibri, Arial, Helvetica,
              sans-serif; color: rgb(33, 33, 33); font-size: 13.3333px;">>>
                      return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;</span><br>
          </span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><span
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;">will
              actually be removed in the last patch where we enable the
              VAAPI Encode (Patch 12/12). In other word, we don't accept
              VAEncode entrypoint until the time we enable VAAPI Encode.
              Therefore, we still only accept VAEntrypointVLD at this
              patch.</span></span></p>
      </div>
    </blockquote>
    <br>
    Makes sense, but I suggest that in this case we should add at least
    a comment why this is still disabled.<br>
    <br>
    And it would look better if we have an "#if 0" or something like
    this in the code which gets explicitly removed with the last patch.<br>
    <br>
    <blockquote
cite="mid:CY4PR12MB1127CA4361641759E6A0A06887080@CY4PR12MB1127.namprd12.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><span
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;"><br>
            </span></span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><span
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;">And we need
              to accept both picture level and slice level entrypoint.
              For some application, e.g. libva h264encode test, if we
              don't enable slice level encode, it will fail the call and
              report h264 encode is not supported. If we enable both, it
              will still use picture level encode. That's why I put both
              here.</span></span></p>
      </div>
    </blockquote>
    <br>
    The problem with slice level encoding is that we haven't fully
    implemented it. E.g. the last time I checked the h264encode test it
    would try to add an SPS and PPS in front of the slice data returned
    from our VA-API driver.<br>
    <br>
    Since our VA-API driver doesn't return slice data, but rather a full
    blown elementary stream you end up with a complete mess which looks
    something like this:<br>
    <br>
    SPS (added by the application), PPS (added by the application),
    Slice Header, SPS (added by the driver), PPS(added by the driver),
    Slice Header/Slice Data.<br>
    <br>
    That might work in some if not most cases, but is certainly not
    complaint to the VA-API specification.<br>
    <br>
    Christian.<br>
    <br>
    <blockquote
cite="mid:CY4PR12MB1127CA4361641759E6A0A06887080@CY4PR12MB1127.namprd12.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><span
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;"><br>
            </span></span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><span
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;">Regards,</span></span></p>
        <p><span style="color: rgb(33, 33, 33); font-size: 13.3333px;"><span
              style="font-family: Calibri, Arial, Helvetica, sans-serif;
              color: rgb(33, 33, 33); font-size: 13.3333px;">Boyuan </span></span></p>
        <div style="color: rgb(0, 0, 0);">
          <div>
            <hr tabindex="-1" style="display:inline-block; width:98%">
            <div id="x_divRplyFwdMsg" dir="ltr"><font
                style="font-size:11pt" face="Calibri, sans-serif"
                color="#000000"><b>From:</b> Christian König
                <a class="moz-txt-link-rfc2396E" href="mailto:deathsimple@vodafone.de"><deathsimple@vodafone.de></a><br>
                <b>Sent:</b> July 19, 2016 4:52 AM<br>
                <b>To:</b> Zhang, Boyuan; <a class="moz-txt-link-abbreviated" href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
                <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:adf.lists@gmail.com">adf.lists@gmail.com</a><br>
                <b>Subject:</b> Re: [PATCH 05/12] st/va: add encode
                entrypoint</font>
              <div> </div>
            </div>
          </div>
          <font size="2"><span style="font-size:10pt;">
              <div class="PlainText">Am 19.07.2016 um 00:43 schrieb
                Boyuan Zhang:<br>
                > VAAPI passes PIPE_VIDEO_ENTRYPOINT_ENCODE as entry
                point for encoding case. We will save this encode entry
                point in config. config_id was used as profile
                previously. Now, config has both profile and entrypoint
                field, and config_id is used to get the config object.
                Later on, we pass this entrypoint to
                context->templat.entrypoint instead of always
                hardcoded to PIPE_VIDEO_ENTRYPOINT_BITSTREAM for
                decoding case previously.<br>
                ><br>
                > Signed-off-by: Boyuan Zhang
                <a class="moz-txt-link-rfc2396E" href="mailto:boyuan.zhang@amd.com"><boyuan.zhang@amd.com></a><br>
                > ---<br>
                >   src/gallium/state_trackers/va/config.c     | 69
                +++++++++++++++++++++++++++---<br>
                >   src/gallium/state_trackers/va/context.c    | 59
                ++++++++++++++-----------<br>
                >   src/gallium/state_trackers/va/surface.c    | 14
                ++++--<br>
                >   src/gallium/state_trackers/va/va_private.h |  5
                +++<br>
                >   4 files changed, 115 insertions(+), 32
                deletions(-)<br>
                ><br>
                > diff --git a/src/gallium/state_trackers/va/config.c
                b/src/gallium/state_trackers/va/config.c<br>
                > index 9ca0aa8..7ea7e24 100644<br>
                > --- a/src/gallium/state_trackers/va/config.c<br>
                > +++ b/src/gallium/state_trackers/va/config.c<br>
                > @@ -34,6 +34,8 @@<br>
                >   <br>
                >   #include "va_private.h"<br>
                >   <br>
                > +#include "util/u_handle_table.h"<br>
                > +<br>
                >   DEBUG_GET_ONCE_BOOL_OPTION(mpeg4,
                "VAAPI_MPEG4_ENABLED", false)<br>
                >   <br>
                >   VAStatus<br>
                > @@ -128,14 +130,29 @@ VAStatus<br>
                >   vlVaCreateConfig(VADriverContextP ctx, VAProfile
                profile, VAEntrypoint entrypoint,<br>
                >                    VAConfigAttrib *attrib_list, int
                num_attribs, VAConfigID *config_id)<br>
                >   {<br>
                > +   vlVaDriver *drv;<br>
                > +   vlVaConfig *config;<br>
                >      struct pipe_screen *pscreen;<br>
                >      enum pipe_video_profile p;<br>
                >   <br>
                >      if (!ctx)<br>
                >         return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                >   <br>
                > +   drv = VL_VA_DRIVER(ctx);<br>
                > +<br>
                > +   if (!drv)<br>
                > +      return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                > +<br>
                > +   config = CALLOC(1, sizeof(vlVaConfig));<br>
                > +   if (!config)<br>
                > +      return VA_STATUS_ERROR_ALLOCATION_FAILED;<br>
                > +<br>
                >      if (profile == VAProfileNone &&
                entrypoint == VAEntrypointVideoProc) {<br>
                > -      *config_id = PIPE_VIDEO_PROFILE_UNKNOWN;<br>
                > +      config->entrypoint =
                VAEntrypointVideoProc;<br>
                > +      config->profile =
                PIPE_VIDEO_PROFILE_UNKNOWN;<br>
                > +      pipe_mutex_lock(drv->mutex);<br>
                > +      *config_id = handle_table_add(drv->htab,
                config);<br>
                > +      pipe_mutex_unlock(drv->mutex);<br>
                >         return VA_STATUS_SUCCESS;<br>
                >      }<br>
                >   <br>
                > @@ -150,7 +167,16 @@
                vlVaCreateConfig(VADriverContextP ctx, VAProfile
                profile, VAEntrypoint entrypoin<br>
                >      if (entrypoint != VAEntrypointVLD)<br>
                >         return
                VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;<br>
                >   <br>
                > -   *config_id = p;<br>
                > +   if (entrypoint == VAEntrypointEncSlice ||
                entrypoint == VAEntrypointEncPicture)<br>
                > +      config->entrypoint =
                PIPE_VIDEO_ENTRYPOINT_ENCODE;<br>
                > +   else<br>
                > +      config->entrypoint =
                PIPE_VIDEO_ENTRYPOINT_BITSTREAM;<br>
                <br>
                Well that doesn't make much sense here.<br>
                <br>
                First we return and error if the entrypoint isn't
                VAEntrypointVLD and <br>
                then check if it's an encoding entry point.<br>
                <br>
                Additional to that I already wondered if we are really
                going to support <br>
                slice level as well as picture level encoding.<br>
                <br>
                I think that it should only be one of the two.<br>
                <br>
                Regards,<br>
                Christian.<br>
                <br>
                > +<br>
                > +   config->profile = p;<br>
                > +<br>
                > +   pipe_mutex_lock(drv->mutex);<br>
                > +   *config_id = handle_table_add(drv->htab,
                config);<br>
                > +   pipe_mutex_unlock(drv->mutex);<br>
                >   <br>
                >      return VA_STATUS_SUCCESS;<br>
                >   }<br>
                > @@ -158,9 +184,27 @@
                vlVaCreateConfig(VADriverContextP ctx, VAProfile
                profile, VAEntrypoint entrypoin<br>
                >   VAStatus<br>
                >   vlVaDestroyConfig(VADriverContextP ctx,
                VAConfigID config_id)<br>
                >   {<br>
                > +   vlVaDriver *drv;<br>
                > +   vlVaConfig *config;<br>
                > +<br>
                >      if (!ctx)<br>
                >         return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                >   <br>
                > +   drv = VL_VA_DRIVER(ctx);<br>
                > +<br>
                > +   if (!drv)<br>
                > +      return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                > +<br>
                > +   pipe_mutex_lock(drv->mutex);<br>
                > +   config = handle_table_get(drv->htab,
                config_id);<br>
                > +<br>
                > +   if (!config)<br>
                > +      return VA_STATUS_ERROR_INVALID_CONFIG;<br>
                > +<br>
                > +   FREE(config);<br>
                > +   handle_table_remove(drv->htab, config_id);<br>
                > +   pipe_mutex_unlock(drv->mutex);<br>
                > +<br>
                >      return VA_STATUS_SUCCESS;<br>
                >   }<br>
                >   <br>
                > @@ -168,18 +212,33 @@ VAStatus<br>
                >   vlVaQueryConfigAttributes(VADriverContextP ctx,
                VAConfigID config_id, VAProfile *profile,<br>
                >                             VAEntrypoint
                *entrypoint, VAConfigAttrib *attrib_list, int
                *num_attribs)<br>
                >   {<br>
                > +   vlVaDriver *drv;<br>
                > +   vlVaConfig *config;<br>
                > +<br>
                >      if (!ctx)<br>
                >         return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                >   <br>
                > -   *profile = PipeToProfile(config_id);<br>
                > +   drv = VL_VA_DRIVER(ctx);<br>
                > +<br>
                > +   if (!drv)<br>
                > +      return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                > +<br>
                > +   pipe_mutex_lock(drv->mutex);<br>
                > +   config = handle_table_get(drv->htab,
                config_id);<br>
                > +   pipe_mutex_unlock(drv->mutex);<br>
                > +<br>
                > +   if (!config)<br>
                > +      return VA_STATUS_ERROR_INVALID_CONFIG;<br>
                > +<br>
                > +   *profile = PipeToProfile(config->profile);<br>
                >   <br>
                > -   if (config_id == PIPE_VIDEO_PROFILE_UNKNOWN) {<br>
                > +   if (config->profile ==
                PIPE_VIDEO_PROFILE_UNKNOWN) {<br>
                >         *entrypoint = VAEntrypointVideoProc;<br>
                >         *num_attribs = 0;<br>
                >         return VA_STATUS_SUCCESS;<br>
                >      }<br>
                >   <br>
                > -   *entrypoint = VAEntrypointVLD;<br>
                > +   *entrypoint = config->entrypoint;<br>
                >   <br>
                >      *num_attribs = 1;<br>
                >      attrib_list[0].type = VAConfigAttribRTFormat;<br>
                > diff --git
                a/src/gallium/state_trackers/va/context.c
                b/src/gallium/state_trackers/va/context.c<br>
                > index 402fbb2..8882cba 100644<br>
                > --- a/src/gallium/state_trackers/va/context.c<br>
                > +++ b/src/gallium/state_trackers/va/context.c<br>
                > @@ -195,18 +195,23 @@
                vlVaCreateContext(VADriverContextP ctx, VAConfigID
                config_id, int picture_width,<br>
                >   {<br>
                >      vlVaDriver *drv;<br>
                >      vlVaContext *context;<br>
                > +   vlVaConfig *config;<br>
                >      int is_vpp;<br>
                >   <br>
                >      if (!ctx)<br>
                >         return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                >   <br>
                > -   is_vpp = config_id ==
                PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width
                &&<br>
                > +   drv = VL_VA_DRIVER(ctx);<br>
                > +   pipe_mutex_lock(drv->mutex);<br>
                > +   config = handle_table_get(drv->htab,
                config_id);<br>
                > +   pipe_mutex_unlock(drv->mutex);<br>
                > +<br>
                > +   is_vpp = config->profile ==
                PIPE_VIDEO_PROFILE_UNKNOWN && !picture_width
                &&<br>
                >               !picture_height && !flag
                && !render_targets &&
                !num_render_targets;<br>
                >   <br>
                >      if (!(picture_width && picture_height)
                && !is_vpp)<br>
                >         return
                VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;<br>
                >   <br>
                > -   drv = VL_VA_DRIVER(ctx);<br>
                >      context = CALLOC(1, sizeof(vlVaContext));<br>
                >      if (!context)<br>
                >         return VA_STATUS_ERROR_ALLOCATION_FAILED;<br>
                > @@ -218,8 +223,8 @@
                vlVaCreateContext(VADriverContextP ctx, VAConfigID
                config_id, int picture_width,<br>
                >            return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                >         }<br>
                >      } else {<br>
                > -      context->templat.profile = config_id;<br>
                > -      context->templat.entrypoint =
                PIPE_VIDEO_ENTRYPOINT_BITSTREAM;<br>
                > +      context->templat.profile =
                config->profile;<br>
                > +      context->templat.entrypoint =
                config->entrypoint;<br>
                >         context->templat.chroma_format =
                PIPE_VIDEO_CHROMA_FORMAT_420;<br>
                >         context->templat.width = picture_width;<br>
                >         context->templat.height =
                picture_height;<br>
                > @@ -234,16 +239,18 @@
                vlVaCreateContext(VADriverContextP ctx, VAConfigID
                config_id, int picture_width,<br>
                >   <br>
                >         case PIPE_VIDEO_FORMAT_MPEG4_AVC:<br>
                >            context->templat.max_references = 0;<br>
                > -         context->desc.h264.pps =
                CALLOC_STRUCT(pipe_h264_pps);<br>
                > -         if (!context->desc.h264.pps) {<br>
                > -            FREE(context);<br>
                > -            return
                VA_STATUS_ERROR_ALLOCATION_FAILED;<br>
                > -         }<br>
                > -         context->desc.h264.pps->sps =
                CALLOC_STRUCT(pipe_h264_sps);<br>
                > -         if (!context->desc.h264.pps->sps) {<br>
                > -            FREE(context->desc.h264.pps);<br>
                > -            FREE(context);<br>
                > -            return
                VA_STATUS_ERROR_ALLOCATION_FAILED;<br>
                > +         if (config->entrypoint !=
                PIPE_VIDEO_ENTRYPOINT_ENCODE) {<br>
                > +            context->desc.h264.pps =
                CALLOC_STRUCT(pipe_h264_pps);<br>
                > +            if (!context->desc.h264.pps) {<br>
                > +               FREE(context);<br>
                > +               return
                VA_STATUS_ERROR_ALLOCATION_FAILED;<br>
                > +            }<br>
                > +            context->desc.h264.pps->sps =
                CALLOC_STRUCT(pipe_h264_sps);<br>
                > +            if
                (!context->desc.h264.pps->sps) {<br>
                > +               FREE(context->desc.h264.pps);<br>
                > +               FREE(context);<br>
                > +               return
                VA_STATUS_ERROR_ALLOCATION_FAILED;<br>
                > +            }<br>
                >            }<br>
                >            break;<br>
                >   <br>
                > @@ -267,7 +274,9 @@
                vlVaCreateContext(VADriverContextP ctx, VAConfigID
                config_id, int picture_width,<br>
                >         }<br>
                >      }<br>
                >   <br>
                > -   context->desc.base.profile = config_id;<br>
                > +   context->desc.base.profile =
                config->profile;<br>
                > +   context->desc.base.entry_point =
                config->entrypoint;<br>
                > +<br>
                >      pipe_mutex_lock(drv->mutex);<br>
                >      *context_id = handle_table_add(drv->htab,
                context);<br>
                >      pipe_mutex_unlock(drv->mutex);<br>
                > @@ -293,15 +302,17 @@
                vlVaDestroyContext(VADriverContextP ctx, VAContextID
                context_id)<br>
                >      }<br>
                >   <br>
                >      if (context->decoder) {<br>
                > -      if
                (u_reduce_video_profile(context->decoder->profile)
                ==<br>
                > -            PIPE_VIDEO_FORMAT_MPEG4_AVC) {<br>
                > -         FREE(context->desc.h264.pps->sps);<br>
                > -         FREE(context->desc.h264.pps);<br>
                > -      }<br>
                > -      if
                (u_reduce_video_profile(context->decoder->profile)
                ==<br>
                > -            PIPE_VIDEO_FORMAT_HEVC) {<br>
                > -         FREE(context->desc.h265.pps->sps);<br>
                > -         FREE(context->desc.h265.pps);<br>
                > +      if (context->desc.base.entry_point !=
                PIPE_VIDEO_ENTRYPOINT_ENCODE) {<br>
                > +         if
                (u_reduce_video_profile(context->decoder->profile)
                ==<br>
                > +               PIPE_VIDEO_FORMAT_MPEG4_AVC) {<br>
                > +           
                FREE(context->desc.h264.pps->sps);<br>
                > +            FREE(context->desc.h264.pps);<br>
                > +         }<br>
                > +         if
                (u_reduce_video_profile(context->decoder->profile)
                ==<br>
                > +               PIPE_VIDEO_FORMAT_HEVC) {<br>
                > +           
                FREE(context->desc.h265.pps->sps);<br>
                > +            FREE(context->desc.h265.pps);<br>
                > +         }<br>
                >         }<br>
                >        
                context->decoder->destroy(context->decoder);<br>
                >      }<br>
                > diff --git
                a/src/gallium/state_trackers/va/surface.c
                b/src/gallium/state_trackers/va/surface.c<br>
                > index 3e74353..8ce4143 100644<br>
                > --- a/src/gallium/state_trackers/va/surface.c<br>
                > +++ b/src/gallium/state_trackers/va/surface.c<br>
                > @@ -319,17 +319,18 @@
                vlVaUnlockSurface(VADriverContextP ctx, VASurfaceID
                surface)<br>
                >   }<br>
                >   <br>
                >   VAStatus<br>
                > -vlVaQuerySurfaceAttributes(VADriverContextP ctx,
                VAConfigID config,<br>
                > +vlVaQuerySurfaceAttributes(VADriverContextP ctx,
                VAConfigID config_id,<br>
                >                              VASurfaceAttrib
                *attrib_list, unsigned int *num_attribs)<br>
                >   {<br>
                >      vlVaDriver *drv;<br>
                > +   vlVaConfig *config;<br>
                >      VASurfaceAttrib *attribs;<br>
                >      struct pipe_screen *pscreen;<br>
                >      int i, j;<br>
                >   <br>
                >      STATIC_ASSERT(ARRAY_SIZE(vpp_surface_formats)
                <= VL_VA_MAX_IMAGE_FORMATS);<br>
                >   <br>
                > -   if (config == VA_INVALID_ID)<br>
                > +   if (config_id == VA_INVALID_ID)<br>
                >         return VA_STATUS_ERROR_INVALID_CONFIG;<br>
                >   <br>
                >      if (!attrib_list && !num_attribs)<br>
                > @@ -348,6 +349,13 @@
                vlVaQuerySurfaceAttributes(VADriverContextP ctx,
                VAConfigID config,<br>
                >      if (!drv)<br>
                >         return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
                >   <br>
                > +   pipe_mutex_lock(drv->mutex);<br>
                > +   config = handle_table_get(drv->htab,
                config_id);<br>
                > +   pipe_mutex_unlock(drv->mutex);<br>
                > +<br>
                > +   if (!config)<br>
                > +      return VA_STATUS_ERROR_INVALID_CONFIG;<br>
                > +<br>
                >      pscreen = VL_VA_PSCREEN(ctx);<br>
                >   <br>
                >      if (!pscreen)<br>
                > @@ -363,7 +371,7 @@
                vlVaQuerySurfaceAttributes(VADriverContextP ctx,
                VAConfigID config,<br>
                >   <br>
                >      /* vlVaCreateConfig returns
                PIPE_VIDEO_PROFILE_UNKNOWN<br>
                >       * only for VAEntrypointVideoProc. */<br>
                > -   if (config == PIPE_VIDEO_PROFILE_UNKNOWN) {<br>
                > +   if (config->profile ==
                PIPE_VIDEO_PROFILE_UNKNOWN) {<br>
                >         for (j = 0; j <
                ARRAY_SIZE(vpp_surface_formats); ++j) {<br>
                >            attribs[i].type =
                VASurfaceAttribPixelFormat;<br>
                >            attribs[i].value.type =
                VAGenericValueTypeInteger;<br>
                > diff --git
                a/src/gallium/state_trackers/va/va_private.h
                b/src/gallium/state_trackers/va/va_private.h<br>
                > index d91de44..723983d 100644<br>
                > --- a/src/gallium/state_trackers/va/va_private.h<br>
                > +++ b/src/gallium/state_trackers/va/va_private.h<br>
                > @@ -244,6 +244,11 @@ typedef struct {<br>
                >   } vlVaContext;<br>
                >   <br>
                >   typedef struct {<br>
                > +   VAEntrypoint entrypoint;<br>
                > +   enum pipe_video_profile profile;<br>
                > +} vlVaConfig;<br>
                > +<br>
                > +typedef struct {<br>
                >      VABufferType type;<br>
                >      unsigned int size;<br>
                >      unsigned int num_elements;<br>
                <br>
              </div>
            </span></font></div>
      </div>
    </blockquote>
    <br>
  </body>
</html>