54 #define STC_FREQ 90000 55 #define QUARTER_SEC_STC_FREQ (STC_FREQ / 4) 57 #define QUARTER_SEC_STC_FREQ_MSB (QUARTER_SEC_STC_FREQ >> 8) 59 #ifdef STB_DEBUG_PRINT_REQUIRED 60 #ifdef STB_DEBUG_CHANNEL_DEBUG_REQUIRED 61 #define STB_DBG_PRINT(x) DEBUG_PRINTX_CONDITIONAL(DEBUG_STB_OSD) x 63 #define STB_DBG_PRINT(x) STB_SPDebugWrite x 66 #define STB_DBG_PRINT(x) 69 #ifdef STB_ERROR_PRINT_REQUIRED 70 #ifdef STB_ERROR_CHANNEL_DEBUG_REQUIRED 71 #define STB_ERROR_PRINT(x) DEBUG_PRINTX_CONDITIONAL(DEBUG_STB_OSD) x 73 #define STB_ERROR_PRINT(x) STB_SPDebugWrite x 76 #define STB_ERROR_PRINT(x) 79 #ifdef STB_TIMING_PRINT_REQUIRED 80 #ifdef STB_TIMING_CHANNEL_DEBUG_REQUIRED 81 #define STB_TIMING_PRINT(x) DEBUG_PRINTX_CONDITIONAL(DEBUG_STB_OSD) x 83 #define STB_TIMING_PRINT(x) STB_SPDebugWrite x 86 #define STB_TIMING_PRINT(x) 89 #ifdef STB_DISPLAY_PRINT_REQUIRED 90 #ifdef STB_DISPLAY_MOVE_CHANNEL_DEBUG_REQUIRED 91 #define STB_DISPLAY_PRINT(x) DEBUG_PRINTX_CONDITIONAL(DEBUG_STB_OSD) x 93 #define STB_DISPLAY_PRINT(x) STB_SPDebugWrite x 96 #define STB_DISPLAY_PRINT(x) 99 #ifdef STB_PIXEL_PRINT_REQUIRED 100 #ifdef STB_PIXEL_MOVE_CHANNEL_DEBUG_REQUIRED 101 #define STB_PIXEL_PRINT(x) DEBUG_PRINTX_CONDITIONAL(DEBUG_STB_OSD) x 103 #define STB_PIXEL_PRINT(x) STB_SPDebugWrite x 106 #define STB_PIXEL_PRINT(x) 110 #define STB_GetMemory(x) STB_DSGetMemory(x) 111 #define STB_FreeMemory(x) STB_DSFreeMemory(x) 121 U8BIT region_version_number;
127 U16BIT region_height;
128 U16BIT region_colour_depth;
137 static BOOLEAN terminate_subtitles;
138 static BOOLEAN show_subtitles;
140 static BOOLEAN time_diff_set = FALSE;
141 static U32BIT time_diff_value;
148 static void (*CreateBitmapCallback)(U8BIT *bitmap, U16BIT width, U16BIT height, U8BIT *char_array,
149 U8BIT *tycrcb_palette, U8BIT fgnd_col, U8BIT bkgnd_col);
153 static U32BIT shown_time;
154 static U32BIT diff_ms;
156 static BOOLEAN do_timing;
162 static BOOLEAN DetectPcrDiscontinuity(U8BIT path);
164 static void HideAllShownRegions(
S_REGION *region_list);
168 static void CompleteCompositionList(
S_DISPLAY_SET *subtitle_display_set);
169 static void MoveRegions(
S_REGION *region_list);
170 static void UpdateDisplaySet(U8BIT path,
S_DISPLAY_SET *subtitle_display_set);
171 static void ColourDepthAdjustTo2Bits(U8BIT **region_adjusted_bitmap, U8BIT *bitmap,
172 U16BIT width, U16BIT height);
173 static void ColourDepthAdjustTo4Bits(U8BIT **region_adjusted_bitmap, U8BIT *bitmap,
174 U16BIT width, U16BIT height);
176 static void ShowDisplaySet(
S_REGION *region_list);
178 #ifdef STB_DISPLAY_PRINT_REQUIRED 179 void dump_physical_regions(
const char *label);
195 static BOOLEAN DetectPcrDiscontinuity(U8BIT path)
197 static U32BIT last_time;
198 static U8BIT last_stc[5];
200 U32BIT stc_timestamp;
203 U32BIT projected_stc;
205 U32BIT diff_last_time;
211 FUNCTION_START(DetectPcrDiscontinuity);
216 diff_stc_ms = ((diff_last_time * 90) >> 8);
221 stc_timestamp = ((last_stc[0] << 24) + (last_stc[1] << 16) + (last_stc[2] << 8) + last_stc[3]);
222 projected_stc = stc_timestamp + diff_stc_ms;
223 stc_timestamp = ((new_stc[0] << 24) + (new_stc[1] << 16) + (new_stc[2] << 8) + new_stc[3]);
224 stc_err = abs(projected_stc - stc_timestamp);
227 if (stc_err > ((STC_FREQ >> 8) * 60))
229 STB_TIMING_PRINT((
"DetectPcrDiscontinuity"));
237 memcpy((
void *)last_stc, (
void *)new_stc, (
size_t)5);
238 last_time = new_time;
240 FUNCTION_FINISH(DetectPcrDiscontinuity);
263 U32BIT stc_timestamp;
264 U32BIT difference_seconds;
269 FUNCTION_START(WaitToDisplay);
271 ASSERT(pg_disp_buff != NULL);
272 ASSERT(pg_comp_buff != NULL);
278 pg_timestamp = ((pg_comp_buff->pts[0] << 24) +
279 (pg_comp_buff->pts[1] << 16) +
280 (pg_comp_buff->pts[2] << 8) +
281 (pg_comp_buff->pts[3]));
284 stc_timestamp = ((stc[0] << 24) + (stc[1] << 16) + (stc[2] << 8) + stc[3]);
286 if (!time_diff_set && (stc_timestamp != 0) && (pg_timestamp != 0))
288 if ((stc[0] == 0) && (pg_comp_buff->pts[0] == 1))
291 pg_timestamp &= 0x00ffffff;
293 else if ((stc[0] == 1) && (pg_comp_buff->pts[0] == 0))
296 pg_timestamp |= 0x01000000;
301 if (pg_timestamp > stc_timestamp)
303 if ((pg_timestamp - stc_timestamp) > 0x10000)
305 time_diff_value = (pg_timestamp & 0xffffff00) - (stc_timestamp & 0xffffff00);
310 if ((stc_timestamp - pg_timestamp) > 0x10000)
312 time_diff_value = (stc_timestamp & 0xffffff00) - (pg_timestamp & 0xffffff00);
316 time_diff_set = TRUE;
324 pg_timestamp &= 0x00ffffff;
327 if (pg_timestamp > stc_timestamp)
329 if ((pg_timestamp - stc_timestamp) > 0x10000)
331 pg_timestamp -= time_diff_value;
336 if ((stc_timestamp - pg_timestamp) > 0x10000)
338 pg_timestamp += time_diff_value;
347 if (terminate_subtitles)
349 terminate_subtitles = FALSE;
353 if (DetectPcrDiscontinuity(path))
361 if ((pg_disp_buff->display_set_shown) && (!pg_disp_buff->display_set_removed))
363 if (pg_disp_buff->page_time_out <= difference_seconds)
366 STB_TIMING_PRINT((
"$ WaitToDisplay @ %d, expired clear OSD", __LINE__));
367 HideAllShownRegions(pg_disp_buff->region_list);
369 pg_disp_buff->display_set_removed = TRUE;
377 STB_TIMING_PRINT((
"$ WaitToDisplay @ %d, %d > %d",
378 __LINE__, pg_disp_buff->page_time_out, difference_seconds));
383 STB_TIMING_PRINT((
"$ WaitToDisplay @ %d, !shown || removed", __LINE__));
387 stc_timestamp = ((stc[0] << 24) + (stc[1] << 16) + (stc[2] << 8) + stc[3]);
390 STB_TIMING_PRINT((
"Time=%lu, pres_time=%lu, PTS=0x%lx, STC=0x%lx, PTS-STC=%ld\n", time_ms,
391 pg_comp_buff->presentation_time_ms, pg_timestamp, stc_timestamp,
392 (S32BIT)(pg_timestamp - stc_timestamp)));
397 STB_TIMING_PRINT((
"%d >? %d ~%d || %d >?= %d ~%d",
398 stc_timestamp, pg_timestamp, (stc_timestamp >= pg_timestamp),
399 time_ms, pg_comp_buff->presentation_time_ms,
400 (time_ms >= pg_comp_buff->presentation_time_ms)));
402 if (stc_timestamp == 0)
408 if ((stc_timestamp >= pg_timestamp) || (time_ms >= pg_comp_buff->presentation_time_ms))
410 STB_TIMING_PRINT((
"$ WaitToDisplay, PTS now"));
415 if ((waitdelay = pg_comp_buff->presentation_time_ms - time_ms) > 250)
423 FUNCTION_FINISH(WaitToDisplay);
440 static void HideAllShownRegions(
S_REGION *region_list)
445 FUNCTION_START(HideAllShownRegions);
447 if ((region_list != NULL) && (physical_display_region_list != NULL))
449 region = region_list;
450 while (region != NULL)
452 physical_region = physical_display_region_list;
453 while (physical_region != NULL)
455 ASSERT(region != NULL);
457 if ((physical_region->region_id == region->region_id) && physical_region->visible)
459 STB_DISPLAY_PRINT((
"%s: Hide region pr%d, %x", __FUNCTION__, physical_region->region_id,
460 physical_region->handle));
463 physical_region->visible = FALSE;
466 physical_region = physical_region->next;
468 region = region->next;
472 FUNCTION_FINISH(HideAllShownRegions);
492 FUNCTION_START(SwapDisplayAndCompositionBuffers);
494 ASSERT(*buff_1 != NULL);
495 ASSERT(*buff_2 != NULL);
499 if ((*buff_1)->dds_present && ((*buff_1)->dds_version != (*buff_2)->dds_version))
501 (*buff_2)->dds_present = (*buff_1)->dds_present;
502 (*buff_2)->dds_version = (*buff_1)->dds_version;
503 (*buff_2)->display_width = (*buff_1)->display_width;
504 (*buff_2)->display_height = (*buff_1)->display_height;
505 (*buff_2)->display_window = (*buff_1)->display_window;
506 if ((*buff_1)->display_window)
508 (*buff_2)->window_x = (*buff_1)->window_x;
509 (*buff_2)->window_y = (*buff_1)->window_y;
510 (*buff_2)->window_width = (*buff_1)->window_width;
511 (*buff_2)->window_height = (*buff_1)->window_height;
520 temp = physical_display_region_list;
521 physical_display_region_list = physical_composition_region_list;
522 physical_composition_region_list = temp;
524 FUNCTION_FINISH(SwapDisplayAndCompositionBuffers);
544 while ((region != NULL) && (region->region_id != physical_region->region_id))
546 region = region->next;
553 STB_DISPLAY_PRINT((
"%s: Hide region pr%d, %x", __FUNCTION__, physical_region->region_id,
554 physical_region->handle));
557 physical_region->visible = FALSE;
574 static void CompleteCompositionList(
S_DISPLAY_SET *subtitle_display_set)
581 FUNCTION_START(CompleteCompositionList);
586 legal_region = subtitle_display_set->region_list;
588 while (legal_region != NULL)
590 composition_region = physical_composition_region_list;
592 while (composition_region != NULL)
594 if (legal_region->region_id == composition_region->region_id)
598 composition_region = composition_region->next;
601 if (composition_region == NULL)
605 display_region = physical_display_region_list;
606 prev_display_region = NULL;
608 while (display_region != NULL)
611 if (legal_region->region_id == display_region->region_id)
614 if (prev_display_region == NULL)
617 physical_display_region_list = display_region->next;
621 prev_display_region->next = display_region->next;
623 display_region->next = physical_composition_region_list;
624 physical_composition_region_list = display_region;
627 if (display_region->visible)
629 CheckToHideCopiedRegion(display_region,
630 subtitle_display_set->page_composition_buffer->region_list);
634 prev_display_region = display_region;
635 display_region = display_region->next;
640 legal_region = legal_region->next;
645 FUNCTION_FINISH(CompleteCompositionList);
659 static void MoveRegions(
S_REGION *region_list)
667 FUNCTION_START(MoveRegions);
669 if (region_list != NULL)
671 if (physical_composition_region_list != NULL)
674 region = region_list;
675 while (region != NULL)
677 region_id = region->region_id;
680 physical_composition_region = physical_composition_region_list;
681 while (physical_composition_region != NULL)
683 if (physical_composition_region->region_id == region_id)
685 if ((physical_composition_region->current_x != region->region_horizontal_address) ||
686 (physical_composition_region->current_y != region->region_vertical_address))
689 region->region_horizontal_address,
690 region->region_vertical_address);
691 physical_composition_region->current_x = region->region_horizontal_address;
692 physical_composition_region->current_y = region->region_vertical_address;
693 STB_DISPLAY_PRINT((
"Move region %d (%x)",
694 region->region_id, physical_composition_region->handle));
698 physical_composition_region = physical_composition_region->next;
700 region = region->next;
703 else if (physical_display_region_list != NULL)
706 region = region_list;
707 while (region != NULL)
709 region_id = region->region_id;
712 physical_composition_region = physical_display_region_list;
713 while (physical_composition_region != NULL)
715 if (physical_composition_region->region_id == region_id)
717 if ((physical_composition_region->current_x != region->region_horizontal_address) ||
718 (physical_composition_region->current_y != region->region_vertical_address))
721 region->region_horizontal_address,
722 region->region_vertical_address);
723 physical_composition_region->current_x = region->region_horizontal_address;
724 physical_composition_region->current_y = region->region_vertical_address;
725 STB_DISPLAY_PRINT((
"Move region %d (%x)",
726 region->region_id, physical_composition_region->handle));
730 physical_composition_region = physical_composition_region->next;
732 region = region->next;
737 FUNCTION_FINISH(MoveRegions);
752 static void UpdateDisplaySet(U8BIT path,
S_DISPLAY_SET *subtitle_display_set)
754 FUNCTION_START(UpdateDisplaySet);
756 ASSERT(subtitle_display_set != NULL);
758 USE_UNWANTED_PARAM(path);
769 if (subtitle_display_set->page_display_buffer->region_list != NULL)
771 STB_TIMING_PRINT((
"# pg.ver %02d shown for %04dms %04dms late ms_clk 0x%08x",
772 subtitle_display_set->page_display_buffer->page_version_number,
777 STB_TIMING_PRINT((
" pg.ver %02d shown for %04dms %04dms late ms_clk 0x%08x",
778 subtitle_display_set->page_display_buffer->page_version_number,
787 if (subtitle_display_set->page_composition_buffer->page_state != MODE_CHANGE)
792 CompleteCompositionList(subtitle_display_set);
798 HideAllShownRegions(subtitle_display_set->page_display_buffer->region_list);
799 subtitle_display_set->page_display_buffer->display_set_removed = TRUE;
801 SwapDisplayAndCompositionBuffers(&subtitle_display_set->page_composition_buffer,
802 &subtitle_display_set->page_display_buffer);
804 ShowDisplaySet(subtitle_display_set->page_display_buffer->region_list);
806 subtitle_display_set->page_display_buffer->display_set_shown = TRUE;
817 U32BIT stc_timestamp;
820 pg_timestamp = ((subtitle_display_set->page_display_buffer->pts[0] << 24) +
821 (subtitle_display_set->page_display_buffer->pts[1] << 16) +
822 (subtitle_display_set->page_display_buffer->pts[2] << 8) +
823 (subtitle_display_set->page_display_buffer->pts[3]));
827 stc_timestamp = ((stc[0] << 24) + (stc[1] << 16) + (stc[2] << 8) + stc[3]);
828 delay = ((((S32BIT)stc_timestamp - (S32BIT)pg_timestamp) << 8) / 90);
834 FUNCTION_FINISH(UpdateDisplaySet);
852 static void ColourDepthAdjustTo2Bits(U8BIT **region_adjusted_bitmap, U8BIT *bitmap,
853 U16BIT width, U16BIT height)
864 FUNCTION_START(ColourDepthAdjustTo2Bits);
866 ASSERT(*region_adjusted_bitmap != NULL);
867 ASSERT(bitmap != NULL);
876 p2 = *region_adjusted_bitmap;
879 if (*region_adjusted_bitmap != NULL)
883 STB_PIXEL_PRINT((
"To2 No padding (%dx%d) @ %d", width, height, __LINE__));
885 size = height * width;
886 for (i = 0; i < size; i += 4)
888 static U8BIT lastcolin = 0xff;
890 if (lastcolin != *p8)
892 STB_PIXEL_PRINT((
" in %02x -cda2-> %02x",
893 *p8, (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0))));
897 tmp_byte = (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 6;
899 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 4;
901 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 2;
903 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0));
911 STB_PIXEL_PRINT((
"To2 Padding (%dx%d) @ %d", width, height, __LINE__));
912 for (i = 0; i < height; i++)
914 for (j = 0; j <= width; j += 4)
916 if ((j + 3) <= width)
918 tmp_byte = (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 6;
920 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 4;
922 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 2;
924 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0));
929 tmp_byte = (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 6;
934 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 4;
939 tmp_byte |= (((*p8 & 0x80) >> 6) | ((*p8 & 0x70) != 0)) << 2;
951 FUNCTION_FINISH(ColourDepthAdjustTo2Bits);
969 static void ColourDepthAdjustTo4Bits(U8BIT **region_adjusted_bitmap, U8BIT *bitmap,
970 U16BIT width, U16BIT height)
981 FUNCTION_START(ColourDepthAdjustTo4Bits);
983 ASSERT(*region_adjusted_bitmap != NULL);
984 ASSERT(bitmap != NULL);
991 if (*region_adjusted_bitmap != NULL)
993 p4 = *region_adjusted_bitmap;
999 STB_PIXEL_PRINT((
"To4 No Padding (%dx%d) @ %d", width, height, __LINE__));
1001 size = height * width;
1002 for (i = 0; i < size; i += 2)
1004 STB_PIXEL_PRINT((
" in %02x + %02x -cda4-> %02x @ %x",
1005 *p8, *(p8 + 1), ((*p8 & 0xf0) | (((*(p8 + 1) & 0xf0)) >> 4)), p4));
1007 tmp_byte = (*p8 & 0xf0);
1009 tmp_byte |= ((*p8 & 0xf0) >> 4);
1017 STB_PIXEL_PRINT((
"To4 Padding (%dx%d) @ %d", width, height, __LINE__));
1018 for (i = 0; i < height; i++)
1020 for (j = 0; j <= width; j += 2)
1022 STB_PIXEL_PRINT((
" in %02x + %02x -cda4-> %02x @ %x",
1023 *p8, *(p8 + 1), ((*p8 & 0xf0) | (((*(p8 + 1) & 0xf0)) >> 4)), p4));
1025 if ((j + 1) < width)
1027 tmp_byte = (*p8 & 0xf0);
1029 tmp_byte |= ((*p8 & 0xf0) >> 4);
1034 tmp_byte = (*p8 & 0xf0);
1044 FUNCTION_FINISH(ColourDepthAdjustTo4Bits);
1066 FUNCTION_START(LoadPalettesIntoRegions);
1068 physical_region = physical_composition_region_list;
1069 while (physical_region != NULL)
1071 region = region_list;
1075 ASSERT(region_list != NULL);
1077 if (physical_region->region_id == region->region_id)
1081 ASSERT(clut_list != NULL);
1083 switch (physical_region->region_colour_depth)
1105 region = region->next;
1107 physical_region = physical_region->next;
1110 FUNCTION_FINISH(LoadPalettesIntoRegions);
1124 static void ShowDisplaySet(
S_REGION *region_list)
1130 FUNCTION_START(ShowDisplaySet);
1132 if ((region_list != NULL) && (physical_display_region_list != NULL))
1135 region = region_list;
1136 while (region != NULL)
1138 region_id = region->region_id;
1141 physical_display_region = physical_display_region_list;
1142 while (physical_display_region != NULL)
1144 if (physical_display_region->region_id == region_id)
1146 if (show_subtitles && !physical_display_region->visible)
1149 STB_DISPLAY_PRINT((
" Show region %d, %x", physical_display_region->region_id,
1150 physical_display_region->handle));
1151 physical_display_region->visible = TRUE;
1155 physical_display_region = physical_display_region->next;
1157 region = region->next;
1161 FUNCTION_FINISH(ShowDisplaySet);
1179 U32BIT difference_seconds;
1183 ASSERT(subtitle_display_set != NULL);
1185 if ((subtitle_display_set->page_display_buffer->region_list != NULL) &&
1186 (subtitle_display_set->page_display_buffer->display_set_shown) &&
1187 (!subtitle_display_set->page_display_buffer->display_set_removed))
1189 difference_seconds = (
STB_OSGetClockDiff(subtitle_display_set->page_display_buffer->timeout_start) / 1000) + 1;
1191 if ((subtitle_display_set->page_display_buffer->page_time_out <= difference_seconds) || timeout_override)
1194 STB_TIMING_PRINT((
" CheckDisplay, cleared OSD"));
1195 HideAllShownRegions(subtitle_display_set->page_display_buffer->region_list);
1196 subtitle_display_set->page_display_buffer->display_set_removed = TRUE;
1220 ASSERT(subtitle_display_set != NULL);
1222 if (!subtitle_display_set->page_composition_buffer->display_set_shown)
1226 subtitle_display_set->page_composition_buffer->display_height + 1);
1228 LoadPalettesIntoRegions(subtitle_display_set->region_list, subtitle_display_set->clut_list);
1230 MoveRegions(subtitle_display_set->page_composition_buffer->region_list);
1232 if (WaitToDisplay(path, subtitle_display_set->page_display_buffer,
1233 subtitle_display_set->page_composition_buffer))
1235 UpdateDisplaySet(path, subtitle_display_set);
1255 U8BIT *tycrcb_palette, U8BIT fgnd_col, U8BIT bkgnd_col))
1259 ASSERT(DSCreateBitmap != NULL);
1261 CreateBitmapCallback = DSCreateBitmap;
1281 show_subtitles = TRUE;
1282 time_diff_set = FALSE;
1303 show_subtitles = FALSE;
1304 time_diff_set = FALSE;
1328 physical_region = physical_display_region_list;
1329 while (physical_region != NULL)
1331 STB_DISPLAY_PRINT((
" STB_DSResetPhysicalDisplayRegions pr%d %x", physical_region->region_id,
1332 physical_region->handle));
1334 temp = physical_region->next;
1336 physical_region = temp;
1338 physical_display_region_list = NULL;
1361 physical_region = physical_composition_region_list;
1362 while (physical_region != NULL)
1364 STB_DISPLAY_PRINT((
" STB_DSResetPhysicalCompositionRegions pr%d %x", physical_region->region_id,
1365 physical_region->handle));
1367 temp = physical_region->next;
1369 physical_region = temp;
1371 physical_composition_region_list = NULL;
1391 terminate_subtitles = TRUE;
1419 ASSERT(region != NULL);
1424 physical_region = NULL;
1429 physical_region = physical_display_region_list;
1432 while (physical_region != NULL)
1434 if (physical_region->region_id == region->region_id)
1436 reference_region = physical_region;
1439 physical_region = physical_region->next;
1442 if ((physical_region != NULL) &&
1443 ((physical_region->region_width != region->region_width) ||
1444 (physical_region->region_height != region->region_height) ||
1445 (physical_region->region_colour_depth != region->region_colour_depth)))
1450 STB_ERROR_PRINT((
"!! STB_DSCreateCompositionRegion - SIZE MISMATCH %s @ %d !!",
1451 __FILE__, __LINE__));
1453 physical_region = NULL;
1455 reference_region = NULL;
1458 if ((physical_region == NULL) ||
1459 (physical_region->region_version_number != region->region_version_number))
1467 if (physical_region != NULL)
1470 region->region_height,
1471 region->region_colour_depth);
1473 if (physical_region->handle != 0)
1475 physical_region->next = physical_composition_region_list;
1476 physical_composition_region_list = physical_region;
1478 physical_region->region_id = region->region_id;
1479 physical_region->region_version_number = region->region_version_number;
1480 physical_region->region_width = region->region_width;
1481 physical_region->region_height = region->region_height;
1482 physical_region->region_colour_depth = region->region_colour_depth;
1484 physical_region->current_x = 0;
1485 physical_region->current_y = 0;
1487 physical_region->visible = FALSE;
1489 if (region->region_fill_flag)
1492 STB_DISPLAY_PRINT((
" STB_DSCreateCompositionRegion pr%d (%dx%d) NEW %x - FILL",
1493 region->region_id, region->region_width, region->region_height,
1494 physical_region->handle));
1495 switch (region->region_colour_depth)
1508 region->region_fill_flag = FALSE;
1511 else if (reference_region != NULL)
1513 STB_DISPLAY_PRINT((
" STB_DSCreateCompositionRegion r%d (%dx%d) Copy %x <- %x",
1514 region->region_id, region->region_width, region->region_height,
1515 physical_region->handle, reference_region->handle));
1520 STB_DISPLAY_PRINT((
" STB_DSCreateCompositionRegion pr%d (%dx%d) NEW %x - no fill",
1521 region->region_id, region->region_width, region->region_height,
1522 physical_region->handle));
1530 physical_region = NULL;
1531 STB_ERROR_PRINT((
"!! STB_DSCreateCompositionRegion - STB_OSDCreateRegion failed %s @ %d !!",
1532 __FILE__, __LINE__));
1538 STB_ERROR_PRINT((
"!! STB_DSCreateCompositionRegion - STB_GetMemory failed %s @ %d !!",
1539 __FILE__, __LINE__));
1544 physical_region->region_version_number = region->region_version_number;
1546 STB_DISPLAY_PRINT((
" STB_DSCreateCompositionRegion pr%d (%dx%d) Reuse",
1547 region->region_id, region->region_width, region->region_height));
1550 remove_entry_from_list(physical_region, &physical_display_region_list);
1551 physical_region->next = physical_composition_region_list;
1552 physical_composition_region_list = physical_region;
1577 U16BIT y, U16BIT w, U16BIT h)
1583 U8BIT *region_adjusted_bitmap;
1587 ASSERT(
object != NULL);
1588 ASSERT(bitmap != NULL);
1590 region_adjusted_bitmap = NULL;
1592 region = region_list;
1595 region_object = region->region_object_list;
1596 while (region_object)
1598 if (region_object->object_id == object->object_id)
1600 physical_composition_region = physical_composition_region_list;
1601 while (physical_composition_region != NULL)
1603 if (physical_composition_region->region_id == region->region_id)
1605 switch (physical_composition_region->region_colour_depth)
1609 size = (h * (w + 4)) / 4;
1612 ColourDepthAdjustTo2Bits(®ion_adjusted_bitmap, bitmap, w, h);
1618 size = (h * (w + 2)) / 2;
1621 ColourDepthAdjustTo4Bits(®ion_adjusted_bitmap, bitmap, w, h);
1627 region_adjusted_bitmap = bitmap;
1632 if ((region_object->object_horizontal_position < physical_composition_region->region_width) &&
1633 (region_object->object_vertical_position + y < physical_composition_region->region_height))
1635 if ((region_object->object_horizontal_position + w) > physical_composition_region->region_width)
1637 STB_DISPLAY_PRINT((
" o%d Truncate w - %d + %d > %d ==> %d",
1639 region_object->object_horizontal_position,
1641 physical_composition_region->region_width,
1642 physical_composition_region->region_width - region_object->object_horizontal_position));
1644 w = physical_composition_region->region_width - region_object->object_horizontal_position;
1647 if ((region_object->object_vertical_position + h) > physical_composition_region->region_height)
1649 STB_DISPLAY_PRINT((
" o%d Truncate h - %d + %d > %d ==> %d",
1651 region_object->object_vertical_position,
1653 physical_composition_region->region_height,
1654 physical_composition_region->region_height - region_object->object_vertical_position));
1656 h = physical_composition_region->region_height - region_object->object_vertical_position;
1659 if ((y < physical_composition_region->region_height) &&
1660 ((region_object->object_vertical_position + y) < physical_composition_region->region_height))
1662 if ((region_object->object_vertical_position + y + h) >
1663 physical_composition_region->region_height)
1665 h = (region_object->object_vertical_position + y + h) -
1666 physical_composition_region->region_height;
1671 physical_composition_region->region_version_number = region->region_version_number;
1674 region_object->object_horizontal_position,
1675 region_object->object_vertical_position + y,
1678 region_adjusted_bitmap,
1679 object->non_modifying_colour_flag);
1684 STB_DISPLAY_PRINT((
" o%d Out of region's height", object->object_id));
1689 STB_DISPLAY_PRINT((
" o%d Outside of region", object->object_id));
1692 if ((physical_composition_region->region_colour_depth == 2) ||
1693 (physical_composition_region->region_colour_depth == 4))
1699 physical_composition_region = physical_composition_region->next;
1702 region_object = region_object->next;
1704 region = region->next;
1729 physical_composition_region = physical_composition_region_list;
1730 while (physical_composition_region != NULL)
1732 if (physical_composition_region->region_id == region_id)
1734 STB_DISPLAY_PRINT((
" STB_DSFillRegion r%d (%x) with %d",
1735 region_id, physical_composition_region->handle, fillcode));
1739 physical_composition_region = physical_composition_region->next;
1760 U32BIT pixel_operations;
1765 pixel_operations = 0;
1768 tmp = subtitle_display_set->page_display_buffer->region_list;
1771 temp = subtitle_display_set->region_list;
1772 while (temp != NULL)
1774 if (tmp->region_id == temp->region_id)
1776 pixel_operations += temp->region_width * temp->region_height * temp->region_colour_depth;
1785 tmp = subtitle_display_set->page_composition_buffer->region_list;
1788 temp = subtitle_display_set->region_list;
1789 while (temp != NULL)
1791 if (tmp->region_id == temp->region_id)
1793 pixel_operations += temp->region_width * temp->region_height * temp->region_colour_depth;
1803 return(pixel_operations);
1812 *list = entry->next;
1818 while ((itor != NULL) && (itor->next != entry))
1825 itor->next = entry->next;
1829 STB_ERROR_PRINT((
"Couldn't find entry %d in list %s @ %d",
1830 entry->region_id, __FILE__, __LINE__));
1835 #ifdef STB_DISPLAY_PRINT_REQUIRED 1836 void dump_physical_regions(
const char *label)
1840 FUNCTION_START(dump_physical_regions);
1842 STB_DISPLAY_PRINT((
"%s - Dump OSD resources\n Display", label));
1843 region = physical_display_region_list;
1844 while (region != NULL)
1846 STB_DISPLAY_PRINT((
" r%d (v%d) (w%d h%d d%d) @ (%d %d) %c",
1847 (
int) region->region_id,
1848 (
int) region->region_version_number,
1849 (
int) region->region_width,
1850 (
int) region->region_height,
1851 (
int) region->region_colour_depth,
1852 (
int) region->current_x,
1853 (
int) region->current_y,
1854 (region->visible ?
'V' :
'.')));
1855 region = region->next;
1857 STB_DISPLAY_PRINT((
" <END>\n Composition"));
1858 region = physical_composition_region_list;
1859 while (region != NULL)
1861 STB_DISPLAY_PRINT((
" r%d (v%d) (w%d h%d d%d) @ (%d %d) %c",
1862 (
int) region->region_id,
1863 (
int) region->region_version_number,
1864 (
int) region->region_width,
1865 (
int) region->region_height,
1866 (
int) region->region_colour_depth,
1867 (
int) region->current_x,
1868 (
int) region->current_y,
1869 (region->visible ?
'v' :
'.')));
1870 region = region->next;
1872 STB_DISPLAY_PRINT((
" <END>"));
1874 FUNCTION_FINISH(dump_physical_regions);
void STB_DSResetPhysicalCompositionRegions(void)
Deletes all regions and clears serice_aquired flag.
void * STB_GetMemory(U32BIT bytes)
Attempts to allocate memory from the heap.
void STB_DSRenderBitmapToRegion(S_EPOCH_REGION *region_list, S_OBJECT *object, U8BIT *bitmap, U16BIT y, U16BIT w, U16BIT h)
For the passed region list [PCS specified] get region handle, load the region with the correct CLUT...
S_CLUT * STB_DSGetClut(S_CLUT *clut_list, U16BIT clut_id)
Finds or malloc's a new CLUT and assigns the family pointers to the default data. version_id is set t...
U32BIT STB_OSGetClockDiff(U32BIT timestamp)
Get Difference between Given Time and Current Time.
Header file - macros and function prototypes for public use.
void STB_OSDUpdateRegions(void)
Updates the display of all subtitle regions.
Header file - Function prototypes for OSD control.
void STB_AVGetSTC(U8BIT path, U8BIT stc[5])
Returns the current 33-bit System Time Clock from the PCR PES. On some systems, this information may ...
U8BIT STB_DPGetPathVideoDecoder(U8BIT path)
Returns the video decoder ID acquired by the given decode path.
void STB_OSDFillRegion(void *handle, U8BIT colour)
Fill a region with a colour.
Header file - Function prototypes for A/V control.
BOOLEAN STB_OSDDisableUIRegion(void)
Disables (makes invisible) the OSD. This function needs to be implemented on platforms that cannot di...
void STB_DSTerminateDisplayCycle(void)
Sets flag to exit display wait while loop.
void STB_DSShow(void)
Allows subtitles to display what it has decoded.
void STB_DSHide(void)
Prevents subtitles to display what it has decoded.
Header file - Function prototypes for DVB subtitles.
void STB_DSCheckDisplaySetTimeout(S_DISPLAY_SET *subtitle_display_set, BOOLEAN timeout_override)
It checks the timeout of the current display set, and removes if/when necessary.
void STB_OSDShowRegion(void *handle)
Makes a region visible.
void STB_OSDSetYCrCbPalette(void *region_handle, U32BIT *tycrcb)
Sets a regions entire palette to a T,Y,CR,CB clut.
void STB_OSDDrawBitmapInRegion(void *handle, U16BIT x, U16BIT y, U16BIT w, U16BIT h, U8BIT *bitmap, BOOLEAN non_modifying_colour)
Draw a bitmap in a specified region.
void STB_FreeMemory(void *addr)
Releases previously allocated heap memory.
Debug functions header file.
void STB_DSFillRegion(U16BIT region_id, U8BIT fillcode)
Flood fills the identified region, with the specified colour index.
U32BIT STB_DSNumPixelOperations(S_DISPLAY_SET *subtitle_display_set)
Calculates the number of individual pixels in volved in the next display set.
void STB_DSResetPhysicalDisplayRegions(void)
Deletes all regions and clears serice_aquired flag.
void STB_DSDisplay(U8BIT path, S_DISPLAY_SET *subtitle_display_set)
The subtitle display function. Provides timing of display and clean up when necessary.
void STB_OSDMoveRegion(void *handle, U16BIT x, U16BIT y)
Move a region to new coordinates.
void STB_DSCreateCompositionRegion(S_EPOCH_REGION *region, BOOLEAN page_reset)
By end of call ensures that the specified region has a suitable physical region waiting in the physic...
Header file - Function prototypes for operating system.
System Wide Global Technical Data Type Definitions.
void * STB_OSDCreateRegion(U16BIT width, U16BIT height, U8BIT depth)
Creates a new OSD region (for subtitling)
void STB_OSDSetRegionDisplaySize(U16BIT width, U16BIT height)
Should be called to set the size of the display so that SD subtitles can be scaled correctly for an H...
Header file - Function prototypes for heap memory.
void STB_OSDHideRegion(void *handle)
Makes a region invisible.
void STB_OSDDestroyRegion(void *handle)
Destroys (free the resources used by) a region.
void STB_OSTaskDelay(U16BIT timeout)
Delay Task for Specifed Time Period.
BOOLEAN STB_OSDEnableUIRegion(void)
Disables (makes invisible) the OSD. This function needs to be implemented on platforms that cannot di...
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
void STB_DSRegisterCharRenderFunction(void(*DSCreateBitmap)(U8BIT *bitmap, U16BIT width, U16BIT height, U8BIT *char_array, U8BIT *tycrcb_palette, U8BIT fgnd_col, U8BIT bkgnd_col))
Registers a STBUI function to use whatever font tool is present [if any] for the creation of a bitmap...
void STB_OSDRegionToRegionCopy(void *handle_new, void *handle_orig)
Copy a region to another region, including palette.