Update of /cvsroot/mplayer/main/libmpcodecs In directory mail:/var/tmp.root/cvs-serv12888/libmpcodecs Modified Files: vf_scale.c Log Message: generate meaningful d_width & d_height when scaling, rather than useless nonsense. Index: vf_scale.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_scale.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- vf_scale.c 25 Apr 2003 11:26:08 -0000 1.39 +++ vf_scale.c 27 Apr 2003 10:04:39 -0000 1.40 @@ -209,8 +209,17 @@ } if(!opt_screen_size_x && !opt_screen_size_y){ - d_width=d_width*vf->priv->w/width; - d_height=d_height*vf->priv->h/height; + // Compute new d_width and d_height, preserving aspect + // while ensuring that both are >= output size in pixels. + if (vf->priv->h * d_width > vf->priv->w * d_height) { + d_width = vf->priv->h * d_width / d_height; + d_height = vf->priv->h; + } else { + d_height = vf->priv->w * d_height / d_width; + d_width = vf->priv->w; + } + //d_width=d_width*vf->priv->w/width; + //d_height=d_height*vf->priv->h/height; } return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best); }
On Sun, 27 Apr 2003 12:05:03 +0200 Richard Felker CVS <rfelker@mplayerhq.hu> wrote:
Update of /cvsroot/mplayer/main/libmpcodecs In directory mail:/var/tmp.root/cvs-serv12888/libmpcodecs
Modified Files: vf_scale.c Log Message: generate meaningful d_width & d_height when scaling, rather than useless nonsense.
Shouldn't this be done in regard of the vo_x11_keepaspect variable ? Then the user could choose whether he wants to have the same aspect or not. Attila Kinali PS: i know, the variable should be renamed -- Emacs ist für mich kein Editor. Für mich ist das genau das gleiche, als wenn ich nach einem Fahrrad (für die Sonntagbrötchen) frage und einen pangalaktischen Raumkreuzer mit 10 km Gesamtlänge bekomme. Ich weiß nicht, was ich damit soll. -- Frank Klemm, de.comp.os.unix.discussion
On Sun, Apr 27, 2003 at 05:21:16PM +0200, Attila Kinali wrote:
On Sun, 27 Apr 2003 12:05:03 +0200 Richard Felker CVS <rfelker@mplayerhq.hu> wrote:
Update of /cvsroot/mplayer/main/libmpcodecs In directory mail:/var/tmp.root/cvs-serv12888/libmpcodecs
Modified Files: vf_scale.c Log Message: generate meaningful d_width & d_height when scaling, rather than useless nonsense.
Shouldn't this be done in regard of the vo_x11_keepaspect variable ? Then the user could choose whether he wants to have the same aspect or not.
Nope, it's totally unrelated. See my posts on -dev-eng. And BTW, a filter's behavior should *never* depend on global vars, since the filter could be invoked more than once in a chain with different options desired. Basically, it seems vf_scale's output d_width and d_height were never intended to be used, since the usual use of vf_scale would be software scaling for vo's that don't support hardware scaling or for the ve with mencoder (both of which ignore d_width and d_height). So, suppose you have a 480x480 movie with 4:3 aspect, and you use vf_scale to scale it to 640x480. The input d_width/d_height vf_scale gets is 640/480. With the old (broken) code, vf_scale would set the output d_width to 853, for which there is absolutely no logical basis. It was just wrong. My reasoning in making the correction is that scaling the picture should not change the original intended aspect from the file headers or -aspect on the command line. While you alter the pixel dimensions, you don't alter the horizontal or vertical distances the picture spans, so aspect should remain the same. BTW, soon I'm going to write vf_aspect or vf_dsize or something (can't decide what to call it) that lets you set the d_width/d_height at an arbitrary point in the filter chain, so that the rest of the chain can compute with and preserve it properly when cropping, expanding, and scaling. However, before I write it, I need to figure out how to pass get_image, put_image, and draw_slice through properly so it doesn't affect performance in any way... Rich
Hi,
BTW, soon I'm going to write vf_aspect or vf_dsize or something (can't decide what to call it) that lets you set the d_width/d_height at an arbitrary point in the filter chain, so that the rest of the chain can compute with and preserve it properly when cropping, expanding, and scaling. However, before I write it, I need to figure out how to pass get_image, put_image, and draw_slice through properly so it doesn't affect performance in any way...
just don't set them (their function pointers in open()), then it will be assumed as pass-thru filter (see vf_dvbscale for example) A'rpi / Astral & ESP-team -- Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu
On Sun, Apr 27, 2003 at 07:58:20PM +0200, Arpi wrote:
Hi,
BTW, soon I'm going to write vf_aspect or vf_dsize or something (can't decide what to call it) that lets you set the d_width/d_height at an arbitrary point in the filter chain, so that the rest of the chain can compute with and preserve it properly when cropping, expanding, and scaling. However, before I write it, I need to figure out how to pass get_image, put_image, and draw_slice through properly so it doesn't affect performance in any way...
just don't set them (their function pointers in open()), then it will be assumed as pass-thru filter (see vf_dvbscale for example)
Ah, very cool, thanks. libmpcodecs design is very nice, imo! Rich
On Sun, Apr 27, 2003 at 07:58:20PM +0200, Arpi wrote:
Hi,
BTW, soon I'm going to write vf_aspect or vf_dsize or something (can't decide what to call it) that lets you set the d_width/d_height at an arbitrary point in the filter chain, so that the rest of the chain can compute with and preserve it properly when cropping, expanding, and scaling. However, before I write it, I need to figure out how to pass get_image, put_image, and draw_slice through properly so it doesn't affect performance in any way...
just don't set them (their function pointers in open()), then it will be assumed as pass-thru filter (see vf_dvbscale for example)
Actually, it didn't quite work to begin with -- I had to set draw_slice myself. But what's disturbing: before I set draw_slice, I just got a blank picture with mga_vid when using vf_dsize. Apparently the decoder thought it could use slices, but then it wasn't able to...? Is this a problem somewhere in vf.c? Or do filter authors need to explicitly set draw_slice if they're not going to intervene to prevent slice rendering? Rich
Hi! happened in the past too with vf_rotate, that now sets the draw_slice to the next filters draw_slice, which is okay as long as no filter changes it's mind and stops or starts supporting slices.
Actually, it didn't quite work to begin with -- I had to set draw_slice myself. But what's disturbing: before I set draw_slice, I just got a blank picture with mga_vid when using vf_dsize. Apparently the decoder thought it could use slices, but then it wasn't able to...? Is this a problem somewhere in vf.c? Or do filter authors need to explicitly set draw_slice if they're not going to intervene to prevent slice rendering?
Rich
Denes
Hi,
Actually, it didn't quite work to begin with -- I had to set draw_slice myself. But what's disturbing: before I set draw_slice, I just got a blank picture with mga_vid when using vf_dsize. Apparently the decoder thought it could use slices, but then it wasn't able to...? Is this a problem somewhere in vf.c? Or do filter authors need
ah, the evil slices... i forgot to port the slice fix from g2 yet. add this line to mpcodecs_draw_slice(): // skip passthru filters: while(vf && !vf->process_image) vf=vf->next; ah, no... in main it would look sth like this: while(vf && vf->put_image==vf_next_put_image) vf=vf->next; if works, commit.
to explicitly set draw_slice if they're not going to intervene to prevent slice rendering?
slice support in filters is new and it didn't exists when i hacke din passthru filter support (for vf_format, vf_dvbscale etc) A'rpi / Astral & ESP-team -- Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu
participants (5)
-
Arpi -
Attila Kinali -
Balatoni Denes -
D Richard Felker III -
Richard Felker CVS