<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">
      <blockquote type="cite">
        <div>I don't understand the compositor code fully yet. How can I
          create a unscaled image with it?</div>
      </blockquote>
      You allocate a temporary surface with the original size of the
      input video surface. Then call vl_compositor_render() with the
      temporary surface instead of the real destination.<br>
      <br>
      This is what we should actually do for the noise reduction and
      sharpness filter as well, but so far I was just to lazy to
      implement that. There is also a comment in the code about that in
      the right location if I remember correctly.<br>
      <br>
      E.g. pipeline should be:<br>
      1. Normal compositor setup except dst clip rect setup.<br>
      2. Rendering the compositor to a temporary texture with the same
      size as the input image.<br>
      3. Apply noise reduction.<br>
      4. Apply sharpness filter.<br>
      5. Apply scaling and write the result to the real destination.<br>
      <br>
      Regards,<br>
      Christian.<br>
      <br>
      Am 18.06.2016 um 06:24 schrieb Nayan Deshmukh:<br>
    </div>
    <blockquote
cite="mid:CAFd4ddwhE4q088PJsi8iRaR=wTjw34HkJZjOD2V1f7VHu74X6g@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Christian,
        <div><br>
        </div>
        <div>Thanks for the review.</div>
        <div><br>
        </div>
        <div>I don't understand the compositor code fully yet. How can I
          create a unscaled image with it?</div>
        <div><br>
        </div>
        <div>Regards,</div>
        <div>Nayan.</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, Jun 17, 2016 at 9:15 PM,
          Christian König <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:deathsimple@vodafone.de" target="_blank">deathsimple@vodafone.de</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">Really
            nice work. I now understand where your problem is with the
            scaled surface.<br>
            <br>
            Please see the further comments below.
            <div>
              <div class="h5"><br>
                <br>
                Am 16.06.2016 um 20:15 schrieb Nayan Deshmukh:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  v2: fix a typo and add a newline to code<br>
                  <br>
                  Signed-off-by: Nayan Deshmukh <<a
                    moz-do-not-send="true"
                    href="mailto:nayan26deshmukh@gmail.com"
                    target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:nayan26deshmukh@gmail.com">nayan26deshmukh@gmail.com</a></a>><br>
                  ---<br>
                    src/gallium/state_trackers/vdpau/mixer.c         |
                  53 +++++++++++++++++++++---<br>
                    src/gallium/state_trackers/vdpau/vdpau_private.h | 
                  6 +++<br>
                    2 files changed, 54 insertions(+), 5 deletions(-)<br>
                  <br>
                  diff --git a/src/gallium/state_trackers/vdpau/mixer.c
                  b/src/gallium/state_trackers/vdpau/mixer.c<br>
                  index 65c3ce2..751c7e5 100644<br>
                  --- a/src/gallium/state_trackers/vdpau/mixer.c<br>
                  +++ b/src/gallium/state_trackers/vdpau/mixer.c<br>
                  @@ -82,7 +82,6 @@ vlVdpVideoMixerCreate(VdpDevice
                  device,<br>
                          switch (features[i]) {<br>
                          /* they are valid, but we doesn't support them
                  */<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:<br>
                  -      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:<br>
                  @@ -110,6 +109,9 @@ vlVdpVideoMixerCreate(VdpDevice
                  device,<br>
                             vmixer->luma_key.supported = true;<br>
                             break;<br>
                    +      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                  +         vmixer->bicubic.supported = true;<br>
                  +         break;<br>
                          default: goto no_params;<br>
                          }<br>
                       }<br>
                  @@ -202,6 +204,11 @@
                  vlVdpVideoMixerDestroy(VdpVideoMixer mixer)<br>
                         
                  vl_matrix_filter_cleanup(vmixer->sharpness.filter);<br>
                          FREE(vmixer->sharpness.filter);<br>
                       }<br>
                  +<br>
                  +   if (vmixer->bicubic.filter) {<br>
                  +     
                  vl_bicubic_filter_cleanup(vmixer->bicubic.filter);<br>
                  +      FREE(vmixer->bicubic.filter);<br>
                  +   }<br>
                       pipe_mutex_unlock(vmixer->device->mutex);<br>
                       DeviceReference(&vmixer->device, NULL);<br>
                    @@ -344,7 +351,7 @@ VdpStatus
                  vlVdpVideoMixerRender(VdpVideoMixer mixer,<br>
                       }<br>
                       
                   vl_compositor_set_dst_clip(&vmixer->cstate,
                  RectToPipe(destination_rect, &clip));<br>
                  -   if (!vmixer->noise_reduction.filter &&
                  !vmixer->sharpness.filter)<br>
                  +   if (!vmixer->noise_reduction.filter &&
                  !vmixer->sharpness.filter &&
                  !vmixer->bicubic.filter)<br>
                          vlVdpSave4DelayedRendering(vmixer->device,
                  destination_surface, &vmixer->cstate);<br>
                       else {<br>
                          vl_compositor_render(&vmixer->cstate,
                  compositor, dst->surface, &dst->dirty_area,
                  true);<br>
                  @@ -359,6 +366,10 @@ VdpStatus
                  vlVdpVideoMixerRender(VdpVideoMixer mixer,<br>
                          if (vmixer->sharpness.filter)<br>
                           
                   vl_matrix_filter_render(vmixer->sharpness.filter,<br>
                                                   
                   dst->sampler_view, dst->surface);<br>
                  +<br>
                  +      if (vmixer->bicubic.filter)<br>
                  +       
                   vl_bicubic_filter_render(vmixer->bicubic.filter,<br>
                  +                               
                   dst->sampler_view, dst->surface);<br>
                </blockquote>
                <br>
              </div>
            </div>
            What you do here is first using the compositor to merge and
            scale the surfaces and then apply bicubic filtering on the
            already scaled surface.<br>
            <br>
            That is rather suboptimal. It would be better to let the
            compositor create an unscaled image and then scale it using
            bicubic filtering.<br>
            <br>
            Regards,<br>
            Christian.
            <div class="HOEnZb">
              <div class="h5"><br>
                <br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                       }<br>
                       pipe_mutex_unlock(vmixer->device->mutex);<br>
                    @@ -461,6 +472,28 @@
                  vlVdpVideoMixerUpdateSharpnessFilter(vlVdpVideoMixer
                  *vmixer)<br>
                    }<br>
                      /**<br>
                  + * Update the bicubic filter<br>
                  + */<br>
                  +static void<br>
                  +vlVdpVideoMixerUpdateBicubicFilter(vlVdpVideoMixer
                  *vmixer)<br>
                  +{<br>
                  +   assert(vmixer);<br>
                  +<br>
                  +   /* if present remove the old filter first */<br>
                  +   if (vmixer->bicubic.filter) {<br>
                  +     
                  vl_bicubic_filter_cleanup(vmixer->bicubic.filter);<br>
                  +      FREE(vmixer->bicubic.filter);<br>
                  +      vmixer->bicubic.filter = NULL;<br>
                  +   }<br>
                  +   /* and create a new filter as needed */<br>
                  +   if (vmixer->bicubic.enabled) {<br>
                  +      vmixer->bicubic.filter =
                  MALLOC(sizeof(struct vl_bicubic_filter));<br>
                  +     
                  vl_bicubic_filter_init(vmixer->bicubic.filter,
                  vmixer->device->context,<br>
                  +                            vmixer->video_width,
                  vmixer->video_height);<br>
                  +   }<br>
                  +}<br>
                  +<br>
                  +/**<br>
                     * Retrieve whether features were requested at
                  creation time.<br>
                     */<br>
                    VdpStatus<br>
                  @@ -483,7 +516,6 @@
                  vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,<br>
                          switch (features[i]) {<br>
                          /* they are valid, but we doesn't support them
                  */<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:<br>
                  -      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:<br>
                  @@ -512,6 +544,10 @@
                  vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,<br>
                             feature_supports[i] =
                  vmixer->luma_key.supported;<br>
                             break;<br>
                    +      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                  +         feature_supports[i] =
                  vmixer->bicubic.supported;<br>
                  +         break;<br>
                  +<br>
                          default:<br>
                             return
                  VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;<br>
                          }<br>
                  @@ -544,7 +580,6 @@
                  vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,<br>
                          switch (features[i]) {<br>
                          /* they are valid, but we doesn't support them
                  */<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:<br>
                  -      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:<br>
                  @@ -578,6 +613,11 @@
                  vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,<br>
                                                           
                   vmixer->luma_key.luma_min,
                  vmixer->luma_key.luma_max);<br>
                             break;<br>
                    +      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                  +         vmixer->bicubic.enabled =
                  feature_enables[i];<br>
                  +         vlVdpVideoMixerUpdateBicubicFilter(vmixer);<br>
                  +         break;<br>
                  +<br>
                          default:<br>
                           
                   pipe_mutex_unlock(vmixer->device->mutex);<br>
                             return
                  VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;<br>
                  @@ -612,7 +652,6 @@
                  vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,<br>
                          /* they are valid, but we doesn't support them
                  */<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:<br>
                  -      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:<br>
                          case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:<br>
                  @@ -636,6 +675,10 @@
                  vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,<br>
                             feature_enables[i] =
                  vmixer->luma_key.enabled;<br>
                             break;<br>
                    +      case
                  VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:<br>
                  +         feature_enables[i] =
                  vmixer->bicubic.enabled;<br>
                  +         break;<br>
                  +<br>
                          default:<br>
                             return
                  VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;<br>
                          }<br>
                  diff --git
                  a/src/gallium/state_trackers/vdpau/vdpau_private.h
                  b/src/gallium/state_trackers/vdpau/vdpau_private.h<br>
                  index 8673c6a..bcd4bb1 100644<br>
                  --- a/src/gallium/state_trackers/vdpau/vdpau_private.h<br>
                  +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h<br>
                  @@ -45,6 +45,7 @@<br>
                    #include "os/os_thread.h"<br>
                      #include "vl/vl_video_buffer.h"<br>
                  +#include "vl/vl_bicubic_filter.h"<br>
                    #include "vl/vl_compositor.h"<br>
                    #include "vl/vl_csc.h"<br>
                    #include "vl/vl_deint_filter.h"<br>
                  @@ -373,6 +374,11 @@ typedef struct<br>
                       } deint;<br>
                         struct {<br>
                  +         bool supported, enabled;<br>
                  +         struct vl_bicubic_filter *filter;<br>
                  +   } bicubic;<br>
                  +<br>
                  +   struct {<br>
                          bool supported, enabled;<br>
                          unsigned level;<br>
                          struct vl_median_filter *filter;<br>
                </blockquote>
                <br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>