dvbsuboverlay: scale subtitles according to the display size

Display size is either transmitted in the display definition segment or
implicitly defined to 720x576. The subtitle window information also present in
the display definition segment is not yet used.
This commit is contained in:
Janne Grunau 2010-12-11 17:25:29 +01:00 committed by Sebastian Dröge
parent 83a84ba230
commit 4d8220b033

View File

@ -480,7 +480,7 @@ blit_i420 (GstDVBSubOverlay * overlay, DVBSubtitles * subs, GstBuffer * buffer)
guint32 color; guint32 color;
const guint8 *src; const guint8 *src;
guint8 *dst_y, *dst_y2, *dst_u, *dst_v; guint8 *dst_y, *dst_y2, *dst_u, *dst_v;
gint x, y, w, h; gint x, y;
gint w2, h2; gint w2, h2;
gint width = overlay->width; gint width = overlay->width;
gint height = overlay->height; gint height = overlay->height;
@ -518,7 +518,7 @@ blit_i420 (GstDVBSubOverlay * overlay, DVBSubtitles * subs, GstBuffer * buffer)
v_stride = gst_video_format_get_row_stride (GST_VIDEO_FORMAT_I420, 2, width); v_stride = gst_video_format_get_row_stride (GST_VIDEO_FORMAT_I420, 2, width);
for (counter = 0; counter < subs->num_rects; counter++) { for (counter = 0; counter < subs->num_rects; counter++) {
gint dw, dh; gint dw, dh, dx, dy;
gint32 sx = 0, sy; /* 16.16 fixed point */ gint32 sx = 0, sy; /* 16.16 fixed point */
gint32 xstep, ystep; /* 16.16 fixed point */ gint32 xstep, ystep; /* 16.16 fixed point */
@ -527,18 +527,16 @@ blit_i420 (GstDVBSubOverlay * overlay, DVBSubtitles * subs, GstBuffer * buffer)
continue; continue;
/* blend subtitles onto the video frame */ /* blend subtitles onto the video frame */
w = MIN (sub_region->w, width - sub_region->x); dx = sub_region->x * width / subs->display_def.display_width;
h = MIN (sub_region->h, height - sub_region->y); dy = sub_region->y * height / subs->display_def.display_height;
/* TODO dw = MIN (sub_region->w * width / subs->display_def.display_width,
dw = MIN (sub_region->dw, width - sub_region->x); width - dx);
dh = MIN (sub_region->dh, height - sub_region->y); dh = MIN (sub_region->h * height / subs->display_def.display_height,
*/ height - dy);
dw = w;
dh = h;
xstep = (w << 16) / dw; xstep = (sub_region->w << 16) / dw;
ystep = (h << 16) / dh; ystep = (sub_region->h << 16) / dh;
w2 = (dw + 1) / 2; w2 = (dw + 1) / 2;
h2 = (dh + 1) / 2; h2 = (dh + 1) / 2;
@ -546,21 +544,16 @@ blit_i420 (GstDVBSubOverlay * overlay, DVBSubtitles * subs, GstBuffer * buffer)
src_stride = sub_region->pict.rowstride; src_stride = sub_region->pict.rowstride;
src = sub_region->pict.data; src = sub_region->pict.data;
dst_y = buffer->data + y_offset + sub_region->y * y_stride + sub_region->x; dst_y = buffer->data + y_offset + dy * y_stride + dx;
dst_y2 = dst_y2 = buffer->data + y_offset + (dy + 1) * y_stride + dx;
buffer->data + y_offset + (sub_region->y + 1) * y_stride + dst_u = buffer->data + u_offset + ((dy + 1) / 2) * u_stride + (dx + 1) / 2;
sub_region->x; dst_v = buffer->data + v_offset + ((dy + 1) / 2) * v_stride + (dx + 1) / 2;
dst_u =
buffer->data + u_offset + ((sub_region->y + 1) / 2) * u_stride +
(sub_region->x + 1) / 2;
dst_v =
buffer->data + v_offset + ((sub_region->y + 1) / 2) * v_stride +
(sub_region->x + 1) / 2;
sy = 0; sy = 0;
for (y = 0; y < dh - 1; y += 2) { for (y = 0; y < dh - 1; y += 2) {
sx = 0; sx = 0;
for (x = 0; x < dw - 1; x += 2) { for (x = 0; x < dw - 1; x += 2) {
color = color =
sub_region->pict.palette[src[(sy >> 16) * src_stride + (sx >> 16)]]; sub_region->pict.palette[src[(sy >> 16) * src_stride + (sx >> 16)]];
a1 = (color >> 24) & 0xff; a1 = (color >> 24) & 0xff;