<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <br>
    <div class="moz-cite-prefix">On 07/07/2016 11:28 AM, Julien Isorce
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAHWPjbXwX+3uqoscNK8_+8dE3vEsSEX4d3+7mbT_x52QAY_Q8Q@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="ltr">
        <div><span class="">No encoder with nouveau driver so I cannot
            do a tunneling test <br>
            but at least this does not break the decoder part so the 4
            patches are:<br>
            Tested</span>-<span class="">by</span>: Julien <span
            class="">Isorce</span> <<a moz-do-not-send="true"
            href="mailto:j.isorce@samsung.com" target="_blank">j.<span
              class="">isorce</span>@samsung.com</a>><br>
        </div>
        Thx!<br>
        <div><br>
        </div>
      </div>
    </blockquote>
    Thanks for that.<br>
    <br>
    Leo<br>
    <br>
    <blockquote
cite="mid:CAHWPjbXwX+3uqoscNK8_+8dE3vEsSEX4d3+7mbT_x52QAY_Q8Q@mail.gmail.com"
      type="cite">
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On 6 July 2016 at 19:03, Leo Liu <span
            dir="ltr"><<a moz-do-not-send="true"
              href="mailto:leo.liu@amd.com" target="_blank">leo.liu@amd.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">The idea
            of encode tunneling is to use video buffer directly for
            encoder,<br>
            but currently the encoder doesn’t support interlaced
            surface, the OMX<br>
            decoder set progressive surface before on that purpose.<br>
            <br>
            Since now we are polling the driver for interlacing
            information for<br>
            decoder, we got the interlaced as preferred as other
            APIs(VDPAU, VA-API),<br>
            thus breaking the transcode with tunneling.<br>
            <br>
            The solution is when with tunnel detected, re-allocate
            progressive target<br>
            buffers, and then converting the interlaced decoder results
            to there.<br>
            <br>
            This has been tested with transcode results bit to bit
            matching as before<br>
            with surface from progressive to progressive.<br>
            <br>
            Signed-off-by: Leo Liu <<a moz-do-not-send="true"
              href="mailto:leo.liu@amd.com">leo.liu@amd.com</a>><br>
            ---<br>
             src/gallium/state_trackers/omx/vid_dec.c | 65
            +++++++++++++++++++++++++++++++-<br>
             src/gallium/state_trackers/omx/vid_dec.h |  6 ++-<br>
             2 files changed, 68 insertions(+), 3 deletions(-)<br>
            <br>
            diff --git a/src/gallium/state_trackers/omx/vid_dec.c
            b/src/gallium/state_trackers/omx/vid_dec.c<br>
            index a989c10..7842966 100644<br>
            --- a/src/gallium/state_trackers/omx/vid_dec.c<br>
            +++ b/src/gallium/state_trackers/omx/vid_dec.c<br>
            @@ -167,6 +167,19 @@ static OMX_ERRORTYPE
            vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam<br>
                if (!priv->pipe)<br>
                   return OMX_ErrorInsufficientResources;<br>
            <br>
            +   if (!vl_compositor_init(&priv->compositor,
            priv->pipe)) {<br>
            +      priv->pipe->destroy(priv->pipe);<br>
            +      priv->pipe = NULL;<br>
            +      return OMX_ErrorInsufficientResources;<br>
            +   }<br>
            +<br>
            +   if (!vl_compositor_init_state(&priv->cstate,
            priv->pipe)) {<br>
            +      vl_compositor_cleanup(&priv->compositor);<br>
            +      priv->pipe->destroy(priv->pipe);<br>
            +      priv->pipe = NULL;<br>
            +      return OMX_ErrorInsufficientResources;<br>
            +   }<br>
            +<br>
               
            priv->sPortTypesParam[OMX_PortDomainVideo].nStartPortNumber
            = 0;<br>
                priv->sPortTypesParam[OMX_PortDomainVideo].nPorts =
            2;<br>
                priv->ports = CALLOC(2, sizeof(omx_base_PortType *));<br>
            @@ -218,8 +231,11 @@ static OMX_ERRORTYPE
            vid_dec_Destructor(OMX_COMPONENTTYPE *comp)<br>
                   priv->ports=NULL;<br>
                }<br>
            <br>
            -   if (priv->pipe)<br>
            +   if (priv->pipe) {<br>
            +      vl_compositor_cleanup_state(&priv->cstate);<br>
            +      vl_compositor_cleanup(&priv->compositor);<br>
                   priv->pipe->destroy(priv->pipe);<br>
            +   }<br>
            <br>
                if (priv->screen)<br>
                   omx_put_screen();<br>
            @@ -547,6 +563,25 @@ static void
            vid_dec_FillOutput(vid_dec_PrivateType *priv, struct
            pipe_video_buff<br>
                }<br>
             }<br>
            <br>
            +static void vid_dec_deint(vid_dec_PrivateType *priv, struct
            pipe_video_buffer *src_buf,<br>
            +                          struct pipe_video_buffer
            *dst_buf)<br>
            +{<br>
            +   struct vl_compositor *compositor =
            &priv->compositor;<br>
            +   struct vl_compositor_state *s = &priv->cstate;<br>
            +   struct pipe_surface **dst_surface;<br>
            +<br>
            +   dst_surface = dst_buf->get_surfaces(dst_buf);<br>
            +   vl_compositor_clear_layers(s);<br>
            +<br>
            +   vl_compositor_set_yuv_layer(s, compositor, 0, src_buf,
            NULL, NULL, true);<br>
            +   vl_compositor_set_layer_dst_area(s, 0, NULL);<br>
            +   vl_compositor_render(s, compositor, dst_surface[0],
            NULL, false);<br>
            +<br>
            +   vl_compositor_set_yuv_layer(s, compositor, 0, src_buf,
            NULL, NULL, false);<br>
            +   vl_compositor_set_layer_dst_area(s, 0, NULL);<br>
            +   vl_compositor_render(s, compositor, dst_surface[1],
            NULL, false);<br>
            +}<br>
            +<br>
             static void vid_dec_FrameDecoded(OMX_COMPONENTTYPE *comp,
            OMX_BUFFERHEADERTYPE* input,<br>
                                              OMX_BUFFERHEADERTYPE*
            output)<br>
             {<br>
            @@ -562,7 +597,33 @@ static void
            vid_dec_FrameDecoded(OMX_COMPONENTTYPE *comp,
            OMX_BUFFERHEADERTYPE*<br>
            <br>
                if (input->pInputPortPrivate) {<br>
                   if (output->pInputPortPrivate) {<br>
            -         struct pipe_video_buffer *tmp =
            output->pOutputPortPrivate;<br>
            +         struct pipe_video_buffer *tmp, *vbuf, *new_vbuf;<br>
            +<br>
            +         tmp = output->pOutputPortPrivate;<br>
            +         vbuf = input->pInputPortPrivate;<br>
            +         if (vbuf->interlaced) {<br>
            +            /* re-allocate the progressive buffer */<br>
            +            omx_base_video_PortType *port;<br>
            +            struct pipe_video_buffer templat = {};<br>
            +<br>
            +            port = (omx_base_video_PortType *)<br>
            +                   
            priv->ports[OMX_BASE_FILTER_INPUTPORT_INDEX];<br>
            +            memset(&templat, 0, sizeof(templat));<br>
            +            templat.chroma_format =
            PIPE_VIDEO_CHROMA_FORMAT_420;<br>
            +            templat.width =
            port->sPortParam.format.video.nFrameWidth;<br>
            +            templat.height =
            port->sPortParam.format.video.nFrameHeight;<br>
            +            templat.buffer_format = PIPE_FORMAT_NV12;<br>
            +            templat.interlaced = false;<br>
            +            new_vbuf =
            priv->pipe->create_video_buffer(priv->pipe,
            &templat);<br>
            +<br>
            +            /* convert the interlaced to the progressive */<br>
            +            vid_dec_deint(priv,
            input->pInputPortPrivate, new_vbuf);<br>
            +            priv->pipe->flush(priv->pipe, NULL,
            0);<br>
            +<br>
            +            /* set the progrssive buffer for next round */<br>
            +            vbuf->destroy(vbuf);<br>
            +            input->pInputPortPrivate = new_vbuf;<br>
            +         }<br>
                      output->pOutputPortPrivate =
            input->pInputPortPrivate;<br>
                      input->pInputPortPrivate = tmp;<br>
                   } else {<br>
            diff --git a/src/gallium/state_trackers/omx/vid_dec.h
            b/src/gallium/state_trackers/omx/vid_dec.h<br>
            index 649d745..d268925 100644<br>
            --- a/src/gallium/state_trackers/omx/vid_dec.h<br>
            +++ b/src/gallium/state_trackers/omx/vid_dec.h<br>
            @@ -51,6 +51,8 @@<br>
             #include "os/os_thread.h"<br>
             #include "util/list.h"<br>
            <br>
            +#include "vl/vl_compositor.h"<br>
            +<br>
             #define OMX_VID_DEC_BASE_NAME "OMX.mesa.video_decoder"<br>
            <br>
             #define OMX_VID_DEC_MPEG2_NAME
            "OMX.mesa.video_decoder.mpeg2"<br>
            @@ -108,7 +110,9 @@ DERIVEDCLASS(vid_dec_PrivateType,
            omx_base_filter_PrivateType)<br>
                bool frame_finished; \<br>
                bool frame_started; \<br>
                unsigned bytes_left; \<br>
            -   const void *slice;<br>
            +   const void *slice; \<br>
            +   struct vl_compositor compositor; \<br>
            +   struct vl_compositor_state cstate;<br>
             ENDCLASS(vid_dec_PrivateType)<br>
            <br>
             OMX_ERRORTYPE vid_dec_LoaderComponent(stLoaderComponentType
            *comp);<br>
            <span class="HOEnZb"><font color="#888888">--<br>
                1.9.1<br>
                <br>
                _______________________________________________<br>
                mesa-dev mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
                <a moz-do-not-send="true"
                  href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev"
                  rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
              </font></span></blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>