[MPlayer-dev-eng] [PATCH] video filter: aspect correction
Christian Ohm
chr.ohm at gmx.net
Tue Dec 17 01:30:35 CET 2002
hi.
i wrote a little video filter to change the aspect ratio of movies
indepentently of monitor aspect etc. it's based on dvbscale which does
something similar but which i couldn't get to do what i wanted. just add
'aspectcorrection=f' (where f is a float) and the vertical resolution will
be scaled by f. don't know if anyone else has a use for it; i use it on a tv
screen where the aspect ratio isn't quite 4:3. but it shouldn't break
anything. the name is a bit long, feel free to change it if you can think of
a better one. (see filter.diff and vf_aspectcorrection.c).
i attached another patch i made while trying to implement this in vf_scale.c
(scale.diff). this reduces the code for the parameter calculation a bit. i
don't know if you call this cosmetics, if so, just ignore it :)
bye
christian ohm
--
A fool must now and then be right by chance.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf_aspectcorrection.c
Type: text/x-csrc
Size: 864 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20021217/8d5fcf0e/attachment.c>
-------------- next part --------------
Index: libmpcodecs/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.82
diff -u -r1.82 Makefile
--- libmpcodecs/Makefile 16 Dec 2002 01:49:39 -0000 1.82
+++ libmpcodecs/Makefile 17 Dec 2002 00:37:09 -0000
@@ -14,7 +14,7 @@
VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_xanim.c vd_xvid.c vd_libdv.c vd_qtvideo.c
VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT)
-VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c
+VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_aspectcorrection.c
ENCODER_SRCS=ve.c ve_divx4.c ve_lavc.c ve_vfw.c ve_rawrgb.c ve_libdv.c ve_xvid.c ve_qtvideo.c
NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/cyuv.c native/fli.c native/minilzo.c native/msvidc.c native/nuppelvideo.c native/qtrle.c native/qtrpza.c native/qtsmc.c native/roqav.c native/xa_gsm.c native/svq1.c
Index: libmpcodecs/vf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf.c,v
retrieving revision 1.63
diff -u -r1.63 vf.c
--- libmpcodecs/vf.c 5 Dec 2002 00:22:37 -0000 1.63
+++ libmpcodecs/vf.c 17 Dec 2002 00:37:15 -0000
@@ -52,6 +52,7 @@
extern vf_info_t vf_info_sab;
extern vf_info_t vf_info_smartblur;
extern vf_info_t vf_info_perspective;
+extern vf_info_t vf_info_aspectcorrection;
char** vo_plugin_args=(char**) NULL;
@@ -97,6 +98,7 @@
&vf_info_sab,
&vf_info_smartblur,
&vf_info_perspective,
+ &vf_info_aspectcorrection,
NULL
};
-------------- next part --------------
Index: libmpcodecs/vf_scale.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_scale.c,v
retrieving revision 1.27
diff -u -r1.27 vf_scale.c
--- libmpcodecs/vf_scale.c 17 Oct 2002 21:53:30 -0000 1.27
+++ libmpcodecs/vf_scale.c 17 Dec 2002 00:57:40 -0000
@@ -110,33 +110,21 @@
}
// calculate the missing parameters:
- switch(best) {
- case IMGFMT_YUY2: /* YUY2 needs w rounded to 2 */
- if(vf->priv->w==-3) vf->priv->w=(vf->priv->h*width/height+1)&~1; else
- if(vf->priv->w==-2) vf->priv->w=(vf->priv->h*d_width/d_height+1)&~1;
- if(vf->priv->w<0) vf->priv->w=width; else
- if(vf->priv->w==0) vf->priv->w=d_width;
- if(vf->priv->h==-3) vf->priv->h=vf->priv->w*height/width; else
- if(vf->priv->h==-2) vf->priv->h=vf->priv->w*d_height/d_width;
- break;
- case IMGFMT_YV12: /* YV12 needs w & h rounded to 2 */
- if(vf->priv->w==-3) vf->priv->w=(vf->priv->h*width/height+1)&~1; else
- if(vf->priv->w==-2) vf->priv->w=(vf->priv->h*d_width/d_height+1)&~1;
- if(vf->priv->w<0) vf->priv->w=width; else
- if(vf->priv->w==0) vf->priv->w=d_width;
- if(vf->priv->h==-3) vf->priv->h=(vf->priv->w*height/width+1)&~1; else
- if(vf->priv->h==-2) vf->priv->h=(vf->priv->w*d_height/d_width+1)&~1;
- break;
- default:
if(vf->priv->w==-3) vf->priv->w=vf->priv->h*width/height; else
if(vf->priv->w==-2) vf->priv->w=vf->priv->h*d_width/d_height;
if(vf->priv->w<0) vf->priv->w=width; else
if(vf->priv->w==0) vf->priv->w=d_width;
if(vf->priv->h==-3) vf->priv->h=vf->priv->w*height/width; else
if(vf->priv->h==-2) vf->priv->h=vf->priv->w*d_height/d_width;
- break;
- }
+ // YUY2 needs w, YV12 needs w and h rounded to 2
+ if (best == IMGFMT_YUY2) {
+ vf->priv->w &= ~1;
+ } else if (best == IMGFMT_YV12) {
+ vf->priv->w &= ~1;
+ vf->priv->h &= ~1;
+ }
+
if(vf->priv->h<0) vf->priv->h=height; else
if(vf->priv->h==0) vf->priv->h=d_height;
More information about the MPlayer-dev-eng
mailing list