Bug 6493 - [r128] Xv vertical scaling problem, fix attached but needs attention
Summary: [r128] Xv vertical scaling problem, fix attached but needs attention
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/rage128 (show other bugs)
Version: 7.0.0
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard: 2011BRB_Reviewed
Keywords: patch
Depends on:
Blocks:
 
Reported: 2006-04-04 10:15 UTC by Conn
Modified: 2012-08-31 07:33 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Hack to fix r128 Xv output using resolution of 1024x768 *only* (623 bytes, text/plain)
2006-04-04 10:16 UTC, Conn
no flags Details
Hack to fix r128 Xv output using resolution of 1024x768 *only* (623 bytes, patch)
2006-04-04 10:17 UTC, Conn
no flags Details | Splinter Review
r128_video.c radeon patches try1 (727 bytes, patch)
2006-04-04 12:45 UTC, Conn
no flags Details | Splinter Review
r128_video.c with radeon patches try2 (1.60 KB, patch)
2006-04-04 23:16 UTC, Conn
no flags Details | Splinter Review

Description Conn 2006-04-04 10:15:49 UTC
Hello,

I have an issue with the r128 driver on my Dell Inspiron 8000 laptop with an ATI
Mobility M4 video card. When playing movies using Xv, the vertical width is
incorrect, leading to vertically squashed output and a black band at the bottom.
I have identified the problem in the source and made a fix which works; at the
moment is should be considered a crude hack that only works in 1024x768, but I
am reporting my findings here so someone can hopefully come up with a definitive
fix.

My modification changes both occurances of "v_inc = (src_h << 20) / drw_h;" in
r128_video.c to "v_inc = (src_h << 20) / (drw_h + 128);", which will result in
proper Xv scaling *only* when using a resolution of 1024x768.

With the stock driver, Xv output with a resolution of 800x600 results in a much
larger black band, and using 1280x1024, the band is smaller (and hence Xv output
is closest to normal out of all possible resolutions), but still present. Based
on this observation, drw_h is being calculated incorrectly on the vertical axis,
but horizontal width is fine under all resolutions.

Someone else may need to fix this properly, I'm afraid my programming experience
is virtually non-existant, but I will try.. :)

Regards,
Conn
Comment 1 Conn 2006-04-04 10:16:58 UTC
Created attachment 5191 [details]
Hack to fix r128 Xv output using resolution of 1024x768 *only*
Comment 2 Conn 2006-04-04 10:17:11 UTC
Created attachment 5192 [details] [review]
Hack to fix r128 Xv output using resolution of 1024x768 *only*
Comment 3 Conn 2006-04-04 11:11:59 UTC
Unfortunately, the problem is more complicated than I thought. Adding 128 gave
almost perfect results for a 480x360 video, but trying a different video at
512x384 produces a more pronounced black band at the bottom. No matter how I
manually adjust the lines as mentioned above, it seems that the result will vary
from video to video, depending on the Xv output resolution. Can someone shed
some light on this?
Comment 4 Conn 2006-04-04 12:45:43 UTC
Created attachment 5193 [details] [review]
r128_video.c radeon patches try1

This patch works much better. I borrowed code from radeon_video.c and modified
it slightly. I replaced v_inc_shift with 20, simply to remove the need to
incorporate the interlace/doublescan checks - but the next time I will try to
add this part too. Also, I made a slight adjustment, (drw_h + 1).

This patch gives better scaling under all resolutions, but the quality is not
good, meaning that the vertical scale is still imperfect (but only by a few
pixels). I changed the end of the line to (drw_h + 1) for testing purposes, and
with this modification under 640x480, the scaling quality goes from bad to very
good. Under 800x600 onwards, though, the quality is bad again, but it differs
from the previous patch considerably, there is *no* black border noticeable. I
imagine that tweaking this using low values such as (drw_h + 2), 3, 4 will
produce good results under higher resolutions, but what is really needed is to
incorporate more changes from the radeon driver (probably y_mult, x_off and
y_off variables), which I will try tomorrow. If someone can provide feedback to
help me in the meantime, I would appreciate it.
Comment 5 Conn 2006-04-04 23:16:57 UTC
Created attachment 5197 [details] [review]
r128_video.c with radeon patches try2

This patch appears to solve my problem under all resolutions and video sizes,
however, I am not satisfied with the results. I have also incorporated a
doublescan/interlace fix by Marc La France, see
http://cvsweb.xfree86.org/cvsweb/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_video.c.diff?r1=1.31&r2=1.32


Vertical scaling appears to be correct, but on closer inspection, the quality
of Xv output is bad compared to output from X11 video (using eg., mplayer).

Can someone have a look and see if anything else needs to be changed?
Comment 6 Alex Deucher 2006-04-07 01:58:38 UTC
Nice work.  I'll take a look at it as soon as I get through my current patch queue.
Comment 7 Conn 2006-04-24 09:32:42 UTC
Hi Alex,

I've made a few observations. My laptop LCD screen's native resolution is
1400x1050. Using the default driver (without my patch), here's my observations:

1. X running at 1400x1050: Xv output is perfect. Image quality is great (almost
identical to X11 output from mplayer), scaling seems perfect (no black border at
the bottom of the video).

2. X running at 1280x1024: Xv output bad. Image is squashed vertically, but only
by a few dozen pixels, as a slight black border is noticeable at the bottom.

The resolutions 1024x768, 800x600 and 640x480 follow this pattern too, with Xv's
vertical output becoming progressively more squashed as the resolution is lowered.

Using a patched driver with my latest patch, here's my observations:

1. X running at 1400x1050 - Xv output perfect, same as with default driver 

2. X running at 1280x1024 - Xv output very good. The vertical scale *seems*
perfect, there is no black border any more, and hence the image no longer
appears distorted. However, close visual inspection shows some inperfections
with the scaling, but hardly noticeable at all.

3. X running at 1024x768 - Xv output is good. Again, the vertical scale seems
fine, but the image quality has taken a hit. It's tough to explain, but looks as
 though the picture is slightly interlaced. Watching a cartoon (Family Guy), the
black outline of characters looks jagged or pixellated, whereas using x11
output, the characters have solid looking outlines with no hint of jaggedness.

Both 800x600 and 640x480 exhibit the same problem, but it seems to my eyes that
1024x768 has the worst image quality of all resolutions with my patched driver.
Vertical scaling seems fine under all resolutions, as there are no longer any
black borders under any resolution.

I've been looking through radeon_video.c and tried substituting more code from
there, but I've had no luck. Although my patch is "adequate", I would prefer to
have the best possible image quality at all resolutions (especially 1024x768),
due to my card not having enough videoram to work at 1400x1050, as DRI would be
disabled.


 
Comment 8 Conn 2006-05-11 22:54:08 UTC
I've figured out the problem in more depth, but not the solution.

My Dell Inspiron 8000 has a special function key that scales the screen from the
native resolution. The laptop panel's native size is 1400x1050, under lower
resolutions you can have the display unscaled (with borders around the picture)
or scaled (filling the entire panel) - you can toggle this with the key combo Fn+F7.

If the panel is unscaled, the default driver plays videos perfectly, but when
it's scaled (which is the default and most favourable setting) then Xv output's
vertical height is incorrect.

The patch I posted solves the problem at the expense of "dirty" Xv output; the
default driver works perfectly with clear Xv output when the panel is unscaled.
I'd like for it to work as intended with the panel scaled. Is there any logs I
can post to help solve this?
Comment 9 Alex Deucher 2006-05-12 05:15:56 UTC
(In reply to comment #8)

> 
> If the panel is unscaled, the default driver plays videos perfectly, but when
> it's scaled (which is the default and most favourable setting) then Xv output's
> vertical height is incorrect.
> 
> The patch I posted solves the problem at the expense of "dirty" Xv output; the
> default driver works perfectly with clear Xv output when the panel is unscaled.
> I'd like for it to work as intended with the panel scaled. Is there any logs I
> can post to help solve this?


Take a look at the radeon code.  there is code there to deal with the overlay
when RMX enabled.  RMX is the ati scaling cell.
Comment 10 Daniel Stone 2007-02-27 01:31:23 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 11 Corbin Simpson 2010-03-27 04:44:39 UTC
Tagging to avoid patch lossage; will triage later.
Comment 12 Jeremy Huddleston Sequoia 2011-10-17 00:30:40 UTC
Can you please email your patch to xorg-devel for review.
Comment 13 Connor Behan 2012-08-31 07:33:11 UTC
You mention slight imperfections that show up in the video once you scale it properly. Has another change solved this by now? I tried your patch and video still looks fine. I guess it's possible that my eyesight isn't good enough or that it only happens with certain cards.

Anyway, I committed this with xf86-video-r128 commit 	4ecd6e67fbbfd52e0ac77a6c48bd3c6a6d5598e7 which should be easy to undo if another dev thinks this is premature. Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.