1 /* GStreamer DVD Sub-Picture Unit
2 * Copyright (C) 2007 Fluendo S.A. <info@fluendo.com>
3 * Copyright (C) 2009 Jan Schmidt <thaytan@noraisin.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
28 #include "gstdvdspu.h"
30 GST_DEBUG_CATEGORY_EXTERN (dvdspu_debug);
31 #define GST_CAT_DEFAULT dvdspu_debug
34 gstspu_vobsub_recalc_palette (GstDVDSpu * dvdspu,
35 SpuColour * dest, guint8 * idx, guint8 * alpha)
37 SpuState *state = &dvdspu->spu_state;
40 if (state->vobsub.current_clut[idx[0]] != 0) {
41 for (i = 0; i < 4; i++, dest++) {
42 guint32 col = state->vobsub.current_clut[idx[i]];
44 /* Convert incoming 4-bit alpha to 8 bit for blending */
45 dest->A = (alpha[i] << 4) | alpha[i];
46 dest->Y = ((guint16) ((col >> 16) & 0xff)) * dest->A;
47 /* U/V are stored as V/U in the clut words, so switch them */
48 dest->V = ((guint16) ((col >> 8) & 0xff)) * dest->A;
49 dest->U = ((guint16) (col & 0xff)) * dest->A;
54 /* The CLUT presumably hasn't been set, so we'll just guess some
55 * values for the non-transparent colors (white, grey, black) */
56 for (i = 0; i < 4; i++, dest++) {
57 dest->A = (alpha[i] << 4) | alpha[i];
59 dest[0].Y = y * dest[0].A;
64 dest[0].U = 128 * dest[0].A;
65 dest[0].V = 128 * dest[0].A;
70 /* Recalculate the main, HL & ChgCol palettes */
72 gstspu_vobsub_update_palettes (GstDVDSpu * dvdspu, SpuState * state)
74 guint8 index[4]; /* Indices for the palette */
75 guint8 alpha[4]; /* Alpha values the palette */
77 if (state->vobsub.main_pal_dirty) {
78 gstspu_vobsub_recalc_palette (dvdspu, state->vobsub.main_pal,
79 state->vobsub.main_idx, state->vobsub.main_alpha);
81 /* Need to refresh the hl_ctrl info copies of the main palette too */
82 memcpy (state->vobsub.hl_ctrl_i.pix_ctrl_i[0].pal_cache,
83 state->vobsub.main_pal, 4 * sizeof (SpuColour));
84 memcpy (state->vobsub.hl_ctrl_i.pix_ctrl_i[2].pal_cache,
85 state->vobsub.main_pal, 4 * sizeof (SpuColour));
87 state->vobsub.main_pal_dirty = FALSE;
90 if (state->vobsub.hl_pal_dirty) {
91 gstspu_vobsub_recalc_palette (dvdspu,
92 state->vobsub.hl_ctrl_i.pix_ctrl_i[1].pal_cache, state->vobsub.hl_idx,
93 state->vobsub.hl_alpha);
94 state->vobsub.hl_pal_dirty = FALSE;
97 /* Update the offset positions for the highlight region */
98 if (state->vobsub.hl_rect.top != -1) {
99 state->vobsub.hl_ctrl_i.top = state->vobsub.hl_rect.top;
100 state->vobsub.hl_ctrl_i.bottom = state->vobsub.hl_rect.bottom;
101 state->vobsub.hl_ctrl_i.n_changes = 3;
102 state->vobsub.hl_ctrl_i.pix_ctrl_i[0].left = 0;
103 state->vobsub.hl_ctrl_i.pix_ctrl_i[1].left = state->vobsub.hl_rect.left;
104 state->vobsub.hl_ctrl_i.pix_ctrl_i[2].left =
105 state->vobsub.hl_rect.right + 1;
108 if (state->vobsub.line_ctrl_i_pal_dirty) {
110 GST_LOG_OBJECT (dvdspu, "Updating chg-col-con palettes");
111 for (l = 0; l < state->vobsub.n_line_ctrl_i; l++) {
112 SpuVobsubLineCtrlI *cur_line_ctrl = state->vobsub.line_ctrl_i + l;
114 for (c = 0; c < cur_line_ctrl->n_changes; c++) {
115 SpuVobsubPixCtrlI *cur = cur_line_ctrl->pix_ctrl_i + c;
117 index[3] = (cur->palette >> 28) & 0x0f;
118 index[2] = (cur->palette >> 24) & 0x0f;
119 index[1] = (cur->palette >> 20) & 0x0f;
120 index[0] = (cur->palette >> 16) & 0x0f;
122 alpha[3] = (cur->palette >> 12) & 0x0f;
123 alpha[2] = (cur->palette >> 8) & 0x0f;
124 alpha[1] = (cur->palette >> 4) & 0x0f;
125 alpha[0] = (cur->palette) & 0x0f;
126 gstspu_vobsub_recalc_palette (dvdspu, cur->pal_cache, index, alpha);
129 state->vobsub.line_ctrl_i_pal_dirty = FALSE;
134 gstspu_vobsub_get_nibble (SpuState * state, guint16 * rle_offset)
138 if (G_UNLIKELY (*rle_offset >= state->vobsub.max_offset))
139 return 0; /* Overran the buffer */
141 ret = state->vobsub.pix_buf_map.data[(*rle_offset) / 2];
143 /* If the offset is even, we shift the answer down 4 bits, otherwise not */
144 if (*rle_offset & 0x01)
154 gstspu_vobsub_get_rle_code (SpuState * state, guint16 * rle_offset)
158 code = gstspu_vobsub_get_nibble (state, rle_offset);
159 if (code < 0x4) { /* 4 .. f */
160 code = (code << 4) | gstspu_vobsub_get_nibble (state, rle_offset);
161 if (code < 0x10) { /* 1x .. 3x */
162 code = (code << 4) | gstspu_vobsub_get_nibble (state, rle_offset);
163 if (code < 0x40) { /* 04x .. 0fx */
164 code = (code << 4) | gstspu_vobsub_get_nibble (state, rle_offset);
171 static inline gboolean
172 gstspu_vobsub_draw_rle_run (SpuState * state, gint16 x, gint16 end,
176 GST_LOG ("Y: %d x: %d end %d col %d %d %d %d",
177 state->vobsub.cur_Y, x, end, colour->Y, colour->U, colour->V, colour->A);
180 if (colour->A != 0) {
181 guint32 inv_A = 0xff - colour->A;
183 /* FIXME: This could be more efficient */
185 state->vobsub.out_Y[x] =
186 (inv_A * state->vobsub.out_Y[x] + colour->Y) / 0xff;
187 state->vobsub.out_U[x / 2] += colour->U;
188 state->vobsub.out_V[x / 2] += colour->V;
189 state->vobsub.out_A[x / 2] += colour->A;
192 /* Update the compositing buffer so we know how much to blend later */
193 *(state->vobsub.comp_last_x_ptr) = end - 1; /* end is the start of the *next* run */
201 rle_end_x (guint16 rle_code, gint16 x, gint16 end)
203 /* run length = rle_code >> 2 */
204 if (G_UNLIKELY (((rle_code >> 2) == 0)))
207 return MIN (end, x + (rle_code >> 2));
210 static gboolean gstspu_vobsub_render_line_with_chgcol (SpuState * state,
211 guint8 * planes[3], guint16 * rle_offset);
212 static gboolean gstspu_vobsub_update_chgcol (SpuState * state);
215 gstspu_vobsub_render_line (SpuState * state, guint8 * planes[3],
216 guint16 * rle_offset)
218 gint16 x, next_x, end, rle_code, next_draw_x;
220 gboolean visible = FALSE;
222 /* Check for special case of chg_col info to use (either highlight or
224 if (state->vobsub.cur_chg_col != NULL) {
225 if (gstspu_vobsub_update_chgcol (state)) {
226 /* Check the top & bottom, because we might not be within the region yet */
227 if (state->vobsub.cur_Y >= state->vobsub.cur_chg_col->top &&
228 state->vobsub.cur_Y <= state->vobsub.cur_chg_col->bottom) {
229 return gstspu_vobsub_render_line_with_chgcol (state, planes,
235 /* No special case. Render as normal */
237 /* Set up our output pointers */
238 state->vobsub.out_Y = planes[0];
239 state->vobsub.out_U = state->comp_bufs[0];
240 state->vobsub.out_V = state->comp_bufs[1];
241 state->vobsub.out_A = state->comp_bufs[2];
242 /* We always need to start our RLE decoding byte_aligned */
243 *rle_offset = GST_ROUND_UP_2 (*rle_offset);
245 x = state->vobsub.disp_rect.left;
246 end = state->vobsub.disp_rect.right + 1;
248 rle_code = gstspu_vobsub_get_rle_code (state, rle_offset);
249 colour = &state->vobsub.main_pal[rle_code & 3];
250 next_x = rle_end_x (rle_code, x, end);
251 next_draw_x = next_x;
252 if (next_draw_x > state->vobsub.clip_rect.right)
253 next_draw_x = state->vobsub.clip_rect.right; /* ensure no overflow */
254 /* Now draw the run between [x,next_x) */
255 if (state->vobsub.cur_Y >= state->vobsub.clip_rect.top &&
256 state->vobsub.cur_Y <= state->vobsub.clip_rect.bottom)
257 visible |= gstspu_vobsub_draw_rle_run (state, x, next_draw_x, colour);
265 gstspu_vobsub_update_chgcol (SpuState * state)
267 if (state->vobsub.cur_chg_col == NULL)
270 if (state->vobsub.cur_Y <= state->vobsub.cur_chg_col->bottom)
273 while (state->vobsub.cur_chg_col < state->vobsub.cur_chg_col_end) {
274 if (state->vobsub.cur_Y >= state->vobsub.cur_chg_col->top &&
275 state->vobsub.cur_Y <= state->vobsub.cur_chg_col->bottom) {
277 g_print ("Stopped @ entry %d with top %d bottom %d, cur_y %d",
278 (gint16) (state->vobsub.cur_chg_col - state->vobsub.line_ctrl_i),
279 state->vobsub.cur_chg_col->top, state->vobsub.cur_chg_col->bottom, y);
283 state->vobsub.cur_chg_col++;
286 /* Finished all our cur_chg_col entries. Use the main palette from here on */
287 state->vobsub.cur_chg_col = NULL;
292 gstspu_vobsub_render_line_with_chgcol (SpuState * state, guint8 * planes[3],
293 guint16 * rle_offset)
295 SpuVobsubLineCtrlI *chg_col = state->vobsub.cur_chg_col;
297 gint16 x, next_x, disp_end, rle_code, run_end, run_draw_end;
299 SpuVobsubPixCtrlI *cur_pix_ctrl;
300 SpuVobsubPixCtrlI *next_pix_ctrl;
301 SpuVobsubPixCtrlI *end_pix_ctrl;
302 SpuVobsubPixCtrlI dummy_pix_ctrl;
303 gboolean visible = FALSE;
307 state->vobsub.out_Y = planes[0];
308 state->vobsub.out_U = state->comp_bufs[0];
309 state->vobsub.out_V = state->comp_bufs[1];
310 state->vobsub.out_A = state->comp_bufs[2];
312 /* We always need to start our RLE decoding byte_aligned */
313 *rle_offset = GST_ROUND_UP_2 (*rle_offset);
315 /* Our run will cover the display rect */
316 x = state->vobsub.disp_rect.left;
317 disp_end = state->vobsub.disp_rect.right + 1;
319 /* Work out the first pixel control info, which may point to the dummy entry if
320 * the global palette/alpha need using initally */
321 cur_pix_ctrl = chg_col->pix_ctrl_i;
322 end_pix_ctrl = chg_col->pix_ctrl_i + chg_col->n_changes;
324 if (cur_pix_ctrl->left != 0) {
325 next_pix_ctrl = cur_pix_ctrl;
326 cur_pix_ctrl = &dummy_pix_ctrl;
327 for (i = 0; i < 4; i++) /* Copy the main palette to our dummy entry */
328 dummy_pix_ctrl.pal_cache[i] = state->vobsub.main_pal[i];
330 next_pix_ctrl = cur_pix_ctrl + 1;
332 if (next_pix_ctrl < end_pix_ctrl)
333 cur_reg_end = next_pix_ctrl->left;
335 cur_reg_end = disp_end;
338 while (x < disp_end) {
339 rle_code = gstspu_vobsub_get_rle_code (state, rle_offset);
340 next_x = rle_end_x (rle_code, x, disp_end);
342 /* Now draw the run between [x,next_x), crossing palette regions as needed */
344 run_end = MIN (next_x, cur_reg_end);
346 run_draw_end = run_end;
347 if (run_draw_end > state->vobsub.clip_rect.right)
348 run_draw_end = state->vobsub.clip_rect.right; /* ensure no overflow */
350 if (G_LIKELY (x < run_end)) {
351 colour = &cur_pix_ctrl->pal_cache[rle_code & 3];
352 visible |= gstspu_vobsub_draw_rle_run (state, x, run_draw_end, colour);
356 if (x >= cur_reg_end) {
357 /* Advance to next region */
358 cur_pix_ctrl = next_pix_ctrl;
361 if (next_pix_ctrl < end_pix_ctrl)
362 cur_reg_end = next_pix_ctrl->left;
364 cur_reg_end = disp_end;
373 gstspu_vobsub_blend_comp_buffers (SpuState * state, guint8 * planes[3])
375 state->comp_left = state->vobsub.disp_rect.left;
377 MAX (state->vobsub.comp_last_x[0], state->vobsub.comp_last_x[1]);
379 state->comp_left = MAX (state->comp_left, state->vobsub.clip_rect.left);
380 state->comp_right = MIN (state->comp_right, state->vobsub.clip_rect.right);
382 gstspu_blend_comp_buffers (state, planes);
386 gstspu_vobsub_clear_comp_buffers (SpuState * state)
388 state->comp_left = state->vobsub.clip_rect.left;
389 state->comp_right = state->vobsub.clip_rect.right;
391 gstspu_clear_comp_buffers (state);
393 state->vobsub.comp_last_x[0] = -1;
394 state->vobsub.comp_last_x[1] = -1;
398 gstspu_vobsub_draw_highlight (SpuState * state,
399 GstVideoFrame * frame, SpuRect * rect)
405 ystride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
407 cur = GST_VIDEO_FRAME_COMP_DATA (frame, 0) + ystride * rect->top;
408 for (pos = rect->left + 1; pos < rect->right; pos++)
409 cur[pos] = (cur[pos] / 2) + 0x8;
410 cur = GST_VIDEO_FRAME_COMP_DATA (frame, 0) + ystride * rect->bottom;
411 for (pos = rect->left + 1; pos < rect->right; pos++)
412 cur[pos] = (cur[pos] / 2) + 0x8;
413 cur = GST_VIDEO_FRAME_COMP_DATA (frame, 0) + ystride * rect->top;
414 for (pos = rect->top; pos <= rect->bottom; pos++) {
415 cur[rect->left] = (cur[rect->left] / 2) + 0x8;
416 cur[rect->right] = (cur[rect->right] / 2) + 0x8;
422 gstspu_vobsub_render (GstDVDSpu * dvdspu, GstVideoFrame * frame)
424 SpuState *state = &dvdspu->spu_state;
425 guint8 *planes[3]; /* YUV frame pointers */
429 gint offset_index = 0;
431 /* Set up our initial state */
432 if (G_UNLIKELY (state->vobsub.pix_buf == NULL))
435 if (!gst_buffer_map (state->vobsub.pix_buf, &state->vobsub.pix_buf_map,
439 /* Store the start of each plane */
440 planes[0] = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
441 planes[1] = GST_VIDEO_FRAME_COMP_DATA (frame, 1);
442 planes[2] = GST_VIDEO_FRAME_COMP_DATA (frame, 2);
444 strides[0] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
445 strides[1] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1);
446 strides[2] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 2);
448 width = GST_VIDEO_FRAME_WIDTH (frame);
449 height = GST_VIDEO_FRAME_HEIGHT (frame);
451 GST_DEBUG_OBJECT (dvdspu,
452 "Rendering SPU. disp_rect %d,%d to %d,%d. hl_rect %d,%d to %d,%d",
453 state->vobsub.disp_rect.left, state->vobsub.disp_rect.top,
454 state->vobsub.disp_rect.right, state->vobsub.disp_rect.bottom,
455 state->vobsub.hl_rect.left, state->vobsub.hl_rect.top,
456 state->vobsub.hl_rect.right, state->vobsub.hl_rect.bottom);
458 GST_DEBUG_OBJECT (dvdspu, "video size %d,%d", width, height);
460 /* When reading RLE data, we track the offset in nibbles... */
461 state->vobsub.cur_offsets[0] = state->vobsub.pix_data[0] * 2;
462 state->vobsub.cur_offsets[1] = state->vobsub.pix_data[1] * 2;
463 state->vobsub.max_offset = state->vobsub.pix_buf_map.size * 2;
465 /* Update all the palette caches */
466 gstspu_vobsub_update_palettes (dvdspu, state);
468 /* Set up HL or Change Color & Contrast rect tracking */
469 if (state->vobsub.hl_rect.top != -1) {
470 state->vobsub.cur_chg_col = &state->vobsub.hl_ctrl_i;
471 state->vobsub.cur_chg_col_end = state->vobsub.cur_chg_col + 1;
472 } else if (state->vobsub.n_line_ctrl_i > 0) {
473 state->vobsub.cur_chg_col = state->vobsub.line_ctrl_i;
474 state->vobsub.cur_chg_col_end =
475 state->vobsub.cur_chg_col + state->vobsub.n_line_ctrl_i;
477 state->vobsub.cur_chg_col = NULL;
479 state->vobsub.clip_rect.left = state->vobsub.disp_rect.left;
480 state->vobsub.clip_rect.right = state->vobsub.disp_rect.right;
482 /* center the image when display rectangle exceeds the video width */
483 if (width <= state->vobsub.disp_rect.right) {
484 gint left, disp_width;
486 disp_width = state->vobsub.disp_rect.right - state->vobsub.disp_rect.left
488 left = (width - disp_width) / 2;
489 state->vobsub.disp_rect.left = left;
490 state->vobsub.disp_rect.right = left + disp_width - 1;
492 /* if it clips to the right, shift it left, but only till zero */
493 if (state->vobsub.disp_rect.right >= width) {
494 gint shift = state->vobsub.disp_rect.right - width - 1;
495 if (shift > state->vobsub.disp_rect.left)
496 shift = state->vobsub.disp_rect.left;
497 state->vobsub.disp_rect.left -= shift;
498 state->vobsub.disp_rect.right -= shift;
501 /* init clip to disp */
502 state->vobsub.clip_rect.left = state->vobsub.disp_rect.left;
503 state->vobsub.clip_rect.right = state->vobsub.disp_rect.right;
505 /* clip right after the shift */
506 if (state->vobsub.clip_rect.right >= width)
507 state->vobsub.clip_rect.right = width - 1;
509 GST_DEBUG_OBJECT (dvdspu,
510 "clipping width to %d,%d", state->vobsub.clip_rect.left,
511 state->vobsub.clip_rect.right);
514 /* for the height, bring it up till it fits as well as it can. We
515 * assume the picture is in the lower part. We should better check where it
516 * is and do something more clever. */
517 state->vobsub.clip_rect.top = state->vobsub.disp_rect.top;
518 state->vobsub.clip_rect.bottom = state->vobsub.disp_rect.bottom;
519 if (height <= state->vobsub.disp_rect.bottom) {
521 /* shift it up, but only till zero */
522 gint shift = state->vobsub.disp_rect.bottom - height - 1;
523 if (shift > state->vobsub.disp_rect.top)
524 shift = state->vobsub.disp_rect.top;
525 state->vobsub.disp_rect.top -= shift;
526 state->vobsub.disp_rect.bottom -= shift;
528 /* start on even line */
529 if (state->vobsub.disp_rect.top & 1) {
530 state->vobsub.disp_rect.top--;
531 state->vobsub.disp_rect.bottom--;
534 /* init clip to disp */
535 state->vobsub.clip_rect.top = state->vobsub.disp_rect.top;
536 state->vobsub.clip_rect.bottom = state->vobsub.disp_rect.bottom;
538 /* clip bottom after the shift */
539 if (state->vobsub.clip_rect.bottom >= height)
540 state->vobsub.clip_rect.bottom = height - 1;
542 GST_DEBUG_OBJECT (dvdspu,
543 "clipping height to %d,%d", state->vobsub.clip_rect.top,
544 state->vobsub.clip_rect.bottom);
547 /* We start rendering from the first line of the display rect */
548 y = state->vobsub.disp_rect.top;
549 /* We render most lines in pairs starting from an even y,
550 * accumulating 2 lines of chroma then blending it. We might need to render a
551 * single line at the start and end if the display rect starts on an odd line
552 * or ends on an even one */
553 if (y > state->vobsub.disp_rect.bottom)
554 return; /* Empty clip rect, nothing to do */
556 /* Update our plane references to the first line of the disp_rect */
557 planes[0] += strides[0] * y;
558 planes[1] += strides[1] * (y / 2);
559 planes[2] += strides[2] * (y / 2);
561 /* If the render rect starts on an odd line, render that only to start */
562 state->vobsub.cur_Y = y;
563 if (state->vobsub.cur_Y & 0x1) {
564 gboolean clip, visible = FALSE;
566 clip = (state->vobsub.cur_Y < state->vobsub.clip_rect.top
567 || state->vobsub.cur_Y > state->vobsub.clip_rect.bottom);
570 /* Render a first odd line. */
571 gstspu_vobsub_clear_comp_buffers (state);
572 state->vobsub.comp_last_x_ptr = state->vobsub.comp_last_x + 1;
574 gstspu_vobsub_render_line (state, planes,
575 &state->vobsub.cur_offsets[offset_index]);
577 gstspu_vobsub_blend_comp_buffers (state, planes);
580 /* Update all the output pointers */
581 state->vobsub.cur_Y++;
582 planes[0] += strides[0];
583 planes[1] += strides[1];
584 planes[2] += strides[2];
585 /* Switch the offset index 0 <=> 1 */
589 last_y = (state->vobsub.disp_rect.bottom - 1) & ~(0x01);
590 for (; state->vobsub.cur_Y <= last_y; state->vobsub.cur_Y++) {
591 gboolean clip, visible = FALSE;
593 clip = (state->vobsub.cur_Y < state->vobsub.clip_rect.top
594 || state->vobsub.cur_Y > state->vobsub.clip_rect.bottom);
596 /* Reset the compositing buffer */
597 gstspu_vobsub_clear_comp_buffers (state);
598 /* Render even line */
599 state->vobsub.comp_last_x_ptr = state->vobsub.comp_last_x;
600 gstspu_vobsub_render_line (state, planes,
601 &state->vobsub.cur_offsets[offset_index]);
603 /* Advance the luminance output pointer */
604 planes[0] += strides[0];
605 /* Switch the offset index 0 <=> 1 */
608 state->vobsub.cur_Y++;
610 /* Render odd line */
611 state->vobsub.comp_last_x_ptr = state->vobsub.comp_last_x + 1;
613 gstspu_vobsub_render_line (state, planes,
614 &state->vobsub.cur_offsets[offset_index]);
616 if (visible && !clip) {
617 /* Blend the accumulated UV compositing buffers onto the output */
618 gstspu_vobsub_blend_comp_buffers (state, planes);
621 /* Update all the output pointers */
622 planes[0] += strides[0];
623 planes[1] += strides[1];
624 planes[2] += strides[2];
625 /* Switch the offset index 0 <=> 1 */
629 if (state->vobsub.cur_Y == state->vobsub.disp_rect.bottom) {
630 gboolean clip, visible = FALSE;
632 clip = (state->vobsub.cur_Y < state->vobsub.clip_rect.top
633 || state->vobsub.cur_Y > state->vobsub.clip_rect.bottom);
635 g_return_if_fail ((state->vobsub.disp_rect.bottom & 0x01) == 0);
638 /* Render a remaining lone last even line. y already has the correct value
639 * after the above loop exited. */
640 gstspu_vobsub_clear_comp_buffers (state);
641 state->vobsub.comp_last_x_ptr = state->vobsub.comp_last_x;
643 gstspu_vobsub_render_line (state, planes,
644 &state->vobsub.cur_offsets[offset_index]);
646 gstspu_vobsub_blend_comp_buffers (state, planes);
650 /* for debugging purposes, draw a faint rectangle at the edges of the disp_rect */
651 if ((dvdspu_debug_flags & GST_DVD_SPU_DEBUG_RENDER_RECTANGLE) != 0) {
652 gstspu_vobsub_draw_highlight (state, frame, &state->vobsub.disp_rect);
654 /* For debugging purposes, draw a faint rectangle around the highlight rect */
655 if ((dvdspu_debug_flags & GST_DVD_SPU_DEBUG_HIGHLIGHT_RECTANGLE) != 0
656 && state->vobsub.hl_rect.top != -1) {
657 gstspu_vobsub_draw_highlight (state, frame, &state->vobsub.hl_rect);
660 gst_buffer_unmap (state->vobsub.pix_buf, &state->vobsub.pix_buf_map);