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


_______________________________________________
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

Reply via email to