changeset 10006:6293e6f02fe3

display size/aspect adjusting filter
author rfelker
date Sun, 27 Apr 2003 18:55:04 +0000
parents be14ff86b4e5
children b2d257e35577
files libmpcodecs/Makefile libmpcodecs/vf.c libmpcodecs/vf_dsize.c
diffstat 3 files changed, 69 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/Makefile	Sun Apr 27 18:44:23 2003 +0000
+++ b/libmpcodecs/Makefile	Sun Apr 27 18:55:04 2003 +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 vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.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_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.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 ve_nuv.c
 
 NATIVE_SRCS=native/RTjpegN.c native/cinepak.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
--- a/libmpcodecs/vf.c	Sun Apr 27 18:44:23 2003 +0000
+++ b/libmpcodecs/vf.c	Sun Apr 27 18:55:04 2003 +0000
@@ -65,6 +65,7 @@
 extern vf_info_t vf_info_tfields;
 extern vf_info_t vf_info_ivtc;
 extern vf_info_t vf_info_ilpack;
+extern vf_info_t vf_info_dsize;
 
 // list of available filters:
 static vf_info_t* filter_list[]={
@@ -121,6 +122,7 @@
     &vf_info_tfields,
     &vf_info_ivtc,
     &vf_info_ilpack,
+    &vf_info_dsize,
     NULL
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpcodecs/vf_dsize.c	Sun Apr 27 18:55:04 2003 +0000
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "../config.h"
+#include "../mp_msg.h"
+
+#include "img_format.h"
+#include "mp_image.h"
+#include "vf.h"
+
+struct vf_priv_s {
+	int w, h;
+	float aspect;
+};
+
+static int config(struct vf_instance_s* vf,
+	int width, int height, int d_width, int d_height,
+	unsigned int flags, unsigned int outfmt)
+{
+	if (vf->priv->w && vf->priv->h) {
+		d_width = vf->priv->w;
+		d_height = vf->priv->h;
+	} else {
+		if (vf->priv->aspect * height > width) {
+			d_width = height * vf->priv->aspect;
+			d_height = height;
+		} else {
+			d_height = width / vf->priv->aspect;
+			d_width = width;
+		}
+	}
+	return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
+}
+
+static int open(vf_instance_t *vf, char* args)
+{
+	vf->config = config;
+	vf->draw_slice = vf_next_draw_slice;
+	//vf->default_caps = 0;
+	vf->priv = calloc(sizeof(struct vf_priv_s), 1);
+	vf->priv->aspect = 4.0/3.0;
+	if (args) {
+		if (strchr(args, '/')) {
+			int w, h;
+			sscanf(args, "%d/%d", &w, &h);
+			vf->priv->aspect = (float)w/h;
+		} else if (strchr(args, '.')) {
+			sscanf(args, "%f", &vf->priv->aspect);
+		} else {
+			sscanf(args, "%d:%d", &vf->priv->w, &vf->priv->h);
+		}
+	}
+	return 1;
+}
+
+vf_info_t vf_info_dsize = {
+    "reset displaysize/aspect",
+    "dsize",
+    "Rich Felker",
+    "",
+    open,
+    NULL
+};
+