mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 15:48:23 +00:00
ttml: Replace assertions
Remove assertions and replace, where necessary, with code that handles the error cases. https://bugzilla.gnome.org/show_bug.cgi?id=776436
This commit is contained in:
parent
141f3b2f4d
commit
4ac2a8d6a6
2 changed files with 41 additions and 31 deletions
|
@ -2164,11 +2164,12 @@ gst_ttml_render_render_text_region (GstTtmlRender * render,
|
||||||
gst_ttml_render_rendered_image_free (blocks_image);
|
gst_ttml_render_rendered_image_free (blocks_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (region_image) {
|
||||||
GST_CAT_DEBUG (ttmlrender_debug, "Height of rendered region: %u",
|
GST_CAT_DEBUG (ttmlrender_debug, "Height of rendered region: %u",
|
||||||
region_image->height);
|
region_image->height);
|
||||||
|
|
||||||
ret = gst_ttml_render_compose_overlay (region_image);
|
ret = gst_ttml_render_compose_overlay (region_image);
|
||||||
gst_ttml_render_rendered_image_free (region_image);
|
gst_ttml_render_rendered_image_free (region_image);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2324,12 +2325,12 @@ wait_for_text_buf:
|
||||||
}
|
}
|
||||||
|
|
||||||
subtitle_meta = gst_buffer_get_subtitle_meta (render->text_buffer);
|
subtitle_meta = gst_buffer_get_subtitle_meta (render->text_buffer);
|
||||||
g_assert (subtitle_meta != NULL);
|
if (!subtitle_meta) {
|
||||||
|
GST_CAT_WARNING (ttmlrender_debug, "Failed to get subtitle meta.");
|
||||||
|
} else {
|
||||||
for (i = 0; i < subtitle_meta->regions->len; ++i) {
|
for (i = 0; i < subtitle_meta->regions->len; ++i) {
|
||||||
GstVideoOverlayComposition *composition;
|
GstVideoOverlayComposition *composition;
|
||||||
region = g_ptr_array_index (subtitle_meta->regions, i);
|
region = g_ptr_array_index (subtitle_meta->regions, i);
|
||||||
g_assert (region != NULL);
|
|
||||||
composition = gst_ttml_render_render_text_region (render, region,
|
composition = gst_ttml_render_render_text_region (render, region,
|
||||||
render->text_buffer);
|
render->text_buffer);
|
||||||
if (composition) {
|
if (composition) {
|
||||||
|
@ -2337,6 +2338,7 @@ wait_for_text_buf:
|
||||||
composition);
|
composition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
render->need_render = FALSE;
|
render->need_render = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1513,9 +1513,7 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
TtmlElement *element;
|
TtmlElement *element;
|
||||||
GNode *node;
|
GNode *node;
|
||||||
|
|
||||||
element = tree->data;
|
element = tree->data; /* Region element */
|
||||||
g_assert (element->type == TTML_ELEMENT_TYPE_REGION);
|
|
||||||
|
|
||||||
region_style = gst_subtitle_style_set_new ();
|
region_style = gst_subtitle_style_set_new ();
|
||||||
ttml_update_style_set (region_style, element->style_set, cellres_x,
|
ttml_update_style_set (region_style, element->style_set, cellres_x,
|
||||||
cellres_y);
|
cellres_y);
|
||||||
|
@ -1525,9 +1523,7 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
if (!node)
|
if (!node)
|
||||||
return region;
|
return region;
|
||||||
|
|
||||||
g_assert (node->next == NULL);
|
element = node->data; /* Body element */
|
||||||
element = node->data;
|
|
||||||
g_assert (element->type == TTML_ELEMENT_TYPE_BODY);
|
|
||||||
block_color =
|
block_color =
|
||||||
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
|
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
|
||||||
"backgroundColor"));
|
"backgroundColor"));
|
||||||
|
@ -1537,7 +1533,12 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
GstSubtitleColor div_color;
|
GstSubtitleColor div_color;
|
||||||
|
|
||||||
element = node->data;
|
element = node->data;
|
||||||
g_assert (element->type == TTML_ELEMENT_TYPE_DIV);
|
if (element->type != TTML_ELEMENT_TYPE_DIV) {
|
||||||
|
GST_CAT_WARNING (ttmlparse_debug,
|
||||||
|
"Ignoring %s child of body element: only a div is allowed here.",
|
||||||
|
ttml_get_element_type_string (element));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
div_color =
|
div_color =
|
||||||
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
|
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
|
||||||
"backgroundColor"));
|
"backgroundColor"));
|
||||||
|
@ -1550,7 +1551,12 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
GstSubtitleColor p_color;
|
GstSubtitleColor p_color;
|
||||||
|
|
||||||
element = p_node->data;
|
element = p_node->data;
|
||||||
g_assert (element->type == TTML_ELEMENT_TYPE_P);
|
if (element->type != TTML_ELEMENT_TYPE_P) {
|
||||||
|
GST_CAT_WARNING (ttmlparse_debug,
|
||||||
|
"Ignoring %s child of div element: only a p is allowed here.",
|
||||||
|
ttml_get_element_type_string (element));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
p_color =
|
p_color =
|
||||||
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
|
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
|
||||||
"backgroundColor"));
|
"backgroundColor"));
|
||||||
|
@ -1561,7 +1567,6 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
cellres_y);
|
cellres_y);
|
||||||
block_style->background_color = block_color;
|
block_style->background_color = block_color;
|
||||||
block = gst_subtitle_block_new (block_style);
|
block = gst_subtitle_block_new (block_style);
|
||||||
g_assert (block != NULL);
|
|
||||||
|
|
||||||
for (content_node = p_node->children; content_node;
|
for (content_node = p_node->children; content_node;
|
||||||
content_node = content_node->next) {
|
content_node = content_node->next) {
|
||||||
|
@ -1581,19 +1586,21 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
|| element->type == TTML_ELEMENT_TYPE_ANON_SPAN) {
|
|| element->type == TTML_ELEMENT_TYPE_ANON_SPAN) {
|
||||||
ttml_add_element (block, element, buf, cellres_x, cellres_y);
|
ttml_add_element (block, element, buf, cellres_x, cellres_y);
|
||||||
} else {
|
} else {
|
||||||
GST_CAT_ERROR (ttmlparse_debug,
|
GST_CAT_WARNING (ttmlparse_debug,
|
||||||
"Element type not allowed at this level of document.");
|
"Ignoring illegally positioned %s element.",
|
||||||
|
ttml_get_element_type_string (element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GST_CAT_ERROR (ttmlparse_debug,
|
GST_CAT_WARNING (ttmlparse_debug,
|
||||||
"Element type not allowed at this level of document.");
|
"Ignoring illegally positioned %s element.",
|
||||||
|
ttml_get_element_type_string (element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_subtitle_region_add_block (region, block);
|
gst_subtitle_region_add_block (region, block);
|
||||||
GST_CAT_DEBUG (ttmlparse_debug,
|
GST_CAT_DEBUG (ttmlparse_debug,
|
||||||
"Added block to region; there are now %u blocks" " in the region.",
|
"Added block to region; there are now %u blocks in the region.",
|
||||||
gst_subtitle_region_get_block_count (region));
|
gst_subtitle_region_get_block_count (region));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1628,6 +1635,7 @@ ttml_attach_scene_metadata (GList * scenes, guint cellres_x, guint cellres_y)
|
||||||
|
|
||||||
region = ttml_create_subtitle_region (tree, scene->buf, cellres_x,
|
region = ttml_create_subtitle_region (tree, scene->buf, cellres_x,
|
||||||
cellres_y);
|
cellres_y);
|
||||||
|
if (region)
|
||||||
g_ptr_array_add (regions, region);
|
g_ptr_array_add (regions, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue