[vdr] [PATCH] TT6400 dvbhddevice ScaleVideo aspect ratio correction

Udo Richter udo_richter at gmx.de
Fri Apr 5 21:35:26 CEST 2013


Am 05.04.2013 19:37, schrieb Lucian Muresan:
> I wrote a patch for the ScaleVideo implementation in the dvbhddevice,
> for keeping the actual aspect ratio of the video material when scaling.

My initial thought on the code was that it seemed to unnecessary do too
many double to int conversions, plus not doing any of them with proper
rounding. But I also thought, this might turn out simpler when
transforming it a bit. So I just did some math transforms, and it came
out quite embarrassingly simple:

// Scale to units of 1/1000 osd, with rounding
int x = (Rect.X() * 1000 + osdWidth / 2) / osdWidth;
int y = (Rect.Y() * 1000 + osdHeight / 2) / osdHeight;
int w = (Rect.Width() * 1000 + osdWidth / 2) / osdWidth;
int h = (Rect.Height() * 1000 + osdHeight / 2) / osdHeight;

// make aspect corrections
if (w > h) {
    x += (w - h) / 2;
    w = h;
}
else if (w < h) {
    y += (h - w) / 2;
    h = w;
}
mHdffCmdIf->CmdAvSetVideoWindow(0, true, x, y, w, h);


This should be functionally identical to the original code, except for
less rounding errors. I haven't tested it though.

Cheers,

Udo




More information about the vdr mailing list