[MPlayer-dev-eng] [PATCH] Re: aspect ratio with OSD

Csillag Kristof fenwick at freemail.hu
Mon Jan 24 05:45:31 CET 2005

2005-01-23, v keltezéssel 12.06-kor D Richard Felker III ezt írta: 
> I vote for option 1. MPlayer already has too many bad hacks with
> global vars.

So, here we go.

The modifications have to be made on three different stages.

1. The VO drivers have to pass the aspect ratio parameter
2. The OSD layer has to reveive it, and pass it on
3. The various OSD elements have to use it.

   * * *

Here come the patches:

I. o0_aspect_framework.patch - This the generic framework.

Here is what I did:

- I took the 3 relevant interface functions
  (vo_draw_text, vo_remove_text and vo_update_osd),
  and added and aspect ration parameter to them.

- I added the necessary code to the OSD layer. 
  (About storing and passing on aspect data.)

- I created wrapper macros for each of theese functions named
  whatever_noaspect, which have the original parameter list,
  and call the modified functions with 0 as aspect rate, and replaced
  all references to the changed functions with these wrappers.

So, the situation after applying this patch is the following:

- The OSD level can handle the aspect rate information, but

- none of the VO drivers actually passes it; they all call the (now
  deprecated) whatever_noaspect wrappers, without the aspect parameter.
  To make them pass on the information, one has to add the aspect
  param, and remove the _noaspect tag.

- The OSD level passes on the aspect data internally, but none of the
  OSD elements use it yet.

The important bit is this: with this patch, everything keeps working
as it worked so far; applying this does _not_ require to fix every VO
driver, it just makes it possible.

  * * *

II. o1_aspect_libvo_x11_xv.patch - vo_x11 and vo_xv support 

(depends on the o0 patch, doesn't make sense without the o2 patch)

This patch adds aspect support to the x11 and the xv vo drivers.
(Or, at least, it tries to.)

<helpless moaning>

*I just don't get it. *

Can someone please explain me the following:

Take a look at this:

mplayer -v clip-2.mkv -vo x11 -zoom

... says this:

VO Config (720x552->1024x552,flags=4,'MPlayer',0x32315659)
VO: [x11] 720x552 => 1024x552 Planar YV12  [zoom]

... and sets the vo_dwidth and vo_dheight variables to 1024 and 552.

VO Config (720x552->1024x552,flags=0,'MPlayer',0x32315659)
VO: [xv] 720x552 => 1024x552 Planar YV12 
[xv] dx: 0 dy: 0 dw: 1024 dh: 588

...and sets vo_dwidth and vo_dheight to 1024 and 588

Where does this 588 come from? I really don't feel like analyzing
vo_xv's internals any more.

Now, what will the aspect on the monitor be?
1024/552 or 1024/588?

If the former, than why is vo_dheight set to a different value?
If the later, than why to vo_xv and vo_x11 produce different results?

  * * *

Someone who is familiar with vo_x11's internals should tell me about

</helpless moaning>

I only use the xv and the x11 drivers, so I guess I should not touch the
others, should I?

III. o2_aspect_spu_subs.patch - aspect rate support for VobSubs

(depends on the o0 patch, doesn't make sense without the o1 patch)

This patch makes the VobSub renderer module use the aspect rate
information passed down by the OSD layer, if available.

(This made some of the assertations of the code false,
so I had to touch it here and there.)

Adds the -spu-noaspect option to switch this feature off; if this
(negative) option is switched on, or if aspect data is not available,
falls back the mplayer's original behavior. (Stretches the SPU frame all
over the movie.)

This o2 patch depends my a0 (positioning cleanup & bugfixes) and a1
(scaling) patches, which I also attached for simplicity.

   * * *

... and ... Da-Dam:

the VobSub subtitles are now shown correctly! To have some fun, run
mplayer with -vo xv and -nokeepaspect, and change size & shape while
running; you can see that the subtitle's aspect doesn't change.


ps0. It's a real pain to try to work on a codebase, and put my changes
into seperate patches, when they depend on other two pending patches of

ps1. My pending packages now (*: included here)

* a0_positioning-fix-and-cleanup.patch
* a1_scaling.patch
* o0_aspect_framework.patch
* o1_aspect_libvo_x11_xv.patch
* o2_aspect_spu_subs

-------------- next part --------------
A non-text attachment was scrubbed...
Name: o0_aspect_framework.patch
Type: text/x-patch
Size: 20654 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20050124/1efaf199/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: o1_aspect_libvo_x11_xv.patch
Type: text/x-patch
Size: 1095 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20050124/1efaf199/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a0_positioning-fix-and-cleanup.patch
Type: text/x-patch
Size: 10681 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20050124/1efaf199/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a1_scaling.patch
Type: text/x-patch
Size: 5609 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20050124/1efaf199/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: o2_aspect_spu_subs
Type: text/x-patch
Size: 12087 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20050124/1efaf199/attachment-0004.bin>

More information about the MPlayer-dev-eng mailing list