]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_wrapper.c
Clean up crop/aspect ratio changes and associated video format.
[vlc] / src / video_output / vout_wrapper.c
index eebe517b109186a4f75127d0439fae470e13f5d7..5130e9dc73e20930c35e5d606eb98d39db2b8027 100644 (file)
@@ -66,7 +66,7 @@ int vout_OpenWrapper(vout_thread_t *vout, const char *name)
     sys->display.title = var_CreateGetNonEmptyString(vout, "video-title");
 
     /* */
-    video_format_t source   = vout->p->fmt_render;
+    video_format_t source   = vout->p->original;
     source.i_visible_width  = source.i_width;
     source.i_visible_height = source.i_height;
     source.i_x_offset       = 0;
@@ -131,37 +131,8 @@ int vout_InitWrapper(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = vout->p;
     vout_display_t *vd = sys->display.vd;
-
-    /* */
     video_format_t source = vd->source;
 
-    vout->p->fmt_out.i_chroma         = source.i_chroma;
-    vout->p->fmt_out.i_width          =
-    vout->p->fmt_out.i_visible_width  = source.i_width;
-    vout->p->fmt_out.i_height         =
-    vout->p->fmt_out.i_visible_height = source.i_height;
-    if (source.i_sar_num > 0 && source.i_sar_den > 0) {
-        vlc_ureduce(&vout->p->fmt_out.i_sar_num, &vout->p->fmt_out.i_sar_den,
-                    source.i_sar_num, source.i_sar_den, 0);
-    } else {
-        vout->p->fmt_out.i_sar_num    = 1;
-        vout->p->fmt_out.i_sar_den    = 1;
-    }
-    vout->p->fmt_out.i_sar_num        = source.i_sar_num;
-    vout->p->fmt_out.i_sar_den        = source.i_sar_den;
-    vout->p->fmt_out.i_x_offset       = 0;
-    vout->p->fmt_out.i_y_offset       = 0;
-    vout->p->fmt_out.i_rmask          = source.i_rmask;
-    vout->p->fmt_out.i_gmask          = source.i_gmask;
-    vout->p->fmt_out.i_bmask          = source.i_bmask;
-    video_format_FixRgb(&vout->p->fmt_out);
-
-    if (vout->p->fmt_in.i_visible_width  != source.i_visible_width ||
-        vout->p->fmt_in.i_visible_height != source.i_visible_height ||
-        vout->p->fmt_in.i_x_offset       != source.i_x_offset ||
-        vout->p->fmt_in.i_y_offset       != source.i_y_offset )
-        sys->i_changes |= VOUT_CROP_CHANGE;
-
     /* XXX For non dr case, the current vout implementation force us to
      * create at most 1 direct picture (otherwise the buffers will be kept
      * referenced even through the Init/End.
@@ -213,44 +184,6 @@ int vout_ManageWrapper(vout_thread_t *vout)
     vout_thread_sys_t *sys = vout->p;
     vout_display_t *vd = sys->display.vd;
 
-    while (sys->i_changes & (VOUT_ASPECT_CHANGE |
-                              VOUT_CROP_CHANGE)) {
-        /* */
-        if (sys->i_changes & VOUT_ASPECT_CHANGE) {
-            vout->p->fmt_out.i_sar_num = vout->p->fmt_in.i_sar_num;
-            vout->p->fmt_out.i_sar_den = vout->p->fmt_in.i_sar_den;
-
-            vout_SetDisplayAspect(vd, vout->p->fmt_in.i_sar_num, vout->p->fmt_in.i_sar_den);
-
-            sys->i_changes &= ~VOUT_ASPECT_CHANGE;
-        }
-        if (sys->i_changes & VOUT_CROP_CHANGE) {
-            const video_format_t crop = vout->p->fmt_in;
-            const video_format_t org = vout->p->fmt_render;
-            /* FIXME because of rounding errors, the reconstructed ratio is wrong */
-            unsigned num = 0;
-            unsigned den = 0;
-            if (crop.i_x_offset == org.i_x_offset &&
-                crop.i_visible_width == org.i_visible_width &&
-                crop.i_y_offset == org.i_y_offset + (org.i_visible_height - crop.i_visible_height)/2) {
-                vlc_ureduce(&num, &den,
-                            crop.i_visible_width * crop.i_sar_num,
-                            crop.i_visible_height * crop.i_sar_den, 0);
-            } else if (crop.i_y_offset == org.i_y_offset &&
-                       crop.i_visible_height == org.i_visible_height &&
-                       crop.i_x_offset == org.i_x_offset + (org.i_visible_width - crop.i_visible_width)/2) {
-                vlc_ureduce(&num, &den,
-                            crop.i_visible_width * crop.i_sar_num,
-                            crop.i_visible_height * crop.i_sar_den, 0);
-            }
-            vout_SetDisplayCrop(vd, num, den,
-                                crop.i_x_offset, crop.i_y_offset,
-                                crop.i_visible_width, crop.i_visible_height);
-            sys->i_changes &= ~VOUT_CROP_CHANGE;
-        }
-
-    }
-
     bool reset_display_pool = sys->display.use_dr && vout_AreDisplayPicturesInvalid(vd);
     vout_ManageDisplay(vd, !sys->display.use_dr || reset_display_pool);