mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
dvbsuboverlay: use GST_LOG etc. for logging
The dvbsub routines were originally designed as a mini lib with a log callback (which from the looks of it in our case would always be called and always assemble the string even with debug output disabled). Some of these debug statements can probably be removed or cleaned up some more.
This commit is contained in:
parent
c64df2ebc2
commit
767c29cc2f
3 changed files with 139 additions and 244 deletions
|
@ -36,51 +36,14 @@
|
||||||
#include <gst/base/gstbitreader.h> /* GstBitReader */
|
#include <gst/base/gstbitreader.h> /* GstBitReader */
|
||||||
#include "ffmpeg-colorspace.h" /* YUV_TO_RGB1_CCIR */ /* FIXME: Just give YUV data to gstreamer then? */
|
#include "ffmpeg-colorspace.h" /* YUV_TO_RGB1_CCIR */ /* FIXME: Just give YUV data to gstreamer then? */
|
||||||
|
|
||||||
/* FIXME: Convert to GST_LOG and clean up */
|
GST_DEBUG_CATEGORY_STATIC (dvbsub_debug);
|
||||||
void (*g_log_callback) (GLogLevelFlags log_level, const gchar * format,
|
#define GST_CAT_DEFAULT dvbsub_debug
|
||||||
va_list args, gpointer user_data) = NULL;
|
|
||||||
gpointer g_log_callback_user_data = NULL;
|
|
||||||
|
|
||||||
#define DEBUG
|
void
|
||||||
#ifdef DEBUG
|
dvb_sub_init_debug (void)
|
||||||
#define dvb_log(log_type, log_level, format...) real_dvb_log(log_type, log_level, ## format)
|
|
||||||
typedef enum
|
|
||||||
{
|
{
|
||||||
/* dvb_log types // DVB_LOG environment variable string */
|
GST_DEBUG_CATEGORY_INIT (dvbsub_debug, "dvbsub", 0, "dvbsuboverlay parser");
|
||||||
DVB_LOG_GENERAL, /* GENERAL */
|
|
||||||
DVB_LOG_PAGE, /* PAGE */
|
|
||||||
DVB_LOG_REGION, /* REGION */
|
|
||||||
DVB_LOG_CLUT, /* CLUT */
|
|
||||||
DVB_LOG_OBJECT, /* OBJECT */
|
|
||||||
DVB_LOG_PIXEL, /* PIXEL */
|
|
||||||
DVB_LOG_RUNLEN, /* RUNLEN */
|
|
||||||
DVB_LOG_DISPLAY, /* DISPLAY */
|
|
||||||
DVB_LOG_STREAM, /* STREAM - issues in the encoded stream (TV service provider encoder problem) */
|
|
||||||
DVB_LOG_PACKET, /* PACKET - messages during raw demuxer data packet handling */
|
|
||||||
DVB_LOG_LAST /* sentinel use only */
|
|
||||||
} DvbLogTypes;
|
|
||||||
|
|
||||||
static void
|
|
||||||
real_dvb_log (const gint log_type, GLogLevelFlags log_level,
|
|
||||||
const gchar * format, ...)
|
|
||||||
{
|
|
||||||
if (g_log_callback) {
|
|
||||||
va_list va;
|
|
||||||
va_start (va, format);
|
|
||||||
switch (log_type) {
|
|
||||||
default:
|
|
||||||
g_log_callback (log_level, format, va, g_log_callback_user_data);
|
|
||||||
break;
|
|
||||||
case DVB_LOG_PIXEL:
|
|
||||||
case DVB_LOG_RUNLEN:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
va_end (va);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define dvb_log(log_type, log_level, format...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* FIXME: Are we waiting for an acquisition point before trying to do things? */
|
/* FIXME: Are we waiting for an acquisition point before trying to do things? */
|
||||||
/* FIXME: In the end convert some of the guint8/16 (especially stack variables) back to gint for access efficiency */
|
/* FIXME: In the end convert some of the guint8/16 (especially stack variables) back to gint for access efficiency */
|
||||||
|
@ -452,14 +415,8 @@ _dvb_sub_parse_page_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
guint8 region_id;
|
guint8 region_id;
|
||||||
guint8 page_state;
|
guint8 page_state;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef GST_DISABLE_GST_DEBUG
|
||||||
static int counter = 0;
|
static int counter = 0; /* FIXME: static counter? I think not.. */
|
||||||
static const gchar *page_state_str[] = {
|
|
||||||
"Normal case",
|
|
||||||
"ACQUISITION POINT",
|
|
||||||
"Mode Change",
|
|
||||||
"RESERVED"
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (buf_size < 1)
|
if (buf_size < 1)
|
||||||
|
@ -468,12 +425,17 @@ _dvb_sub_parse_page_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
priv->page_time_out = *buf++;
|
priv->page_time_out = *buf++;
|
||||||
page_state = ((*buf++) >> 2) & 3;
|
page_state = ((*buf++) >> 2) & 3;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifndef GST_DISABLE_GST_DEBUG
|
||||||
++counter;
|
{
|
||||||
dvb_log (DVB_LOG_PAGE, G_LOG_LEVEL_DEBUG,
|
static const gchar *page_state_str[4] = {
|
||||||
"%d: page_id = %u, length = %d, page_time_out = %u seconds, page_state = %s",
|
"Normal case", "ACQUISITION POINT", "Mode Change", "RESERVED"
|
||||||
counter, page_id, buf_size, priv->page_time_out,
|
};
|
||||||
page_state_str[page_state]);
|
|
||||||
|
++counter;
|
||||||
|
GST_DEBUG ("PAGE: %d: page_id = %u, length = %d, page_time_out = %u secs, "
|
||||||
|
"page_state = %s", counter, page_id, buf_size, priv->page_time_out,
|
||||||
|
page_state_str[page_state]);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (page_state == 2) { /* Mode change */
|
if (page_state == 2) { /* Mode change */
|
||||||
|
@ -512,8 +474,7 @@ _dvb_sub_parse_page_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
priv->display_list = display;
|
priv->display_list = display;
|
||||||
priv->display_list_size++;
|
priv->display_list_size++;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_PAGE, G_LOG_LEVEL_DEBUG,
|
GST_LOG ("PAGE %d: REGION information: ID = %u, address = %ux%u",
|
||||||
"%d: REGION information: ID = %u, address = %ux%u",
|
|
||||||
counter, region_id, display->x_pos, display->y_pos);
|
counter, region_id, display->x_pos, display->y_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,7 +535,7 @@ _dvb_sub_parse_region_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
|
|
||||||
region->depth = 1 << (((*buf++) >> 2) & 7);
|
region->depth = 1 << (((*buf++) >> 2) & 7);
|
||||||
if (region->depth < 2 || region->depth > 8) {
|
if (region->depth < 2 || region->depth > 8) {
|
||||||
g_warning ("region depth %d is invalid\n", region->depth);
|
GST_WARNING ("region depth %d is invalid", region->depth);
|
||||||
region->depth = 4; /* FIXME: Check from spec this is the default? */
|
region->depth = 4; /* FIXME: Check from spec this is the default? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,14 +552,13 @@ _dvb_sub_parse_region_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
region->bgcolor = (((*buf++) >> 2) & 3);
|
region->bgcolor = (((*buf++) >> 2) & 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
dvb_log (DVB_LOG_REGION, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("REGION: id = %u, (%ux%u)@%u-bit", region_id, region->width,
|
||||||
"id = %u, (%ux%u)@%u-bit",
|
region->height, region->depth);
|
||||||
region_id, region->width, region->height, region->depth);
|
|
||||||
|
|
||||||
if (fill) {
|
if (fill) {
|
||||||
memset (region->pbuf, region->bgcolor, region->buf_size);
|
memset (region->pbuf, region->bgcolor, region->buf_size);
|
||||||
dvb_log (DVB_LOG_REGION, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("REGION: filling region (%u) with bgcolor = %u", region->id,
|
||||||
"Filling region (%u) with bgcolor = %u", region->id, region->bgcolor);
|
region->bgcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_region_display_list (dvb_sub, region); /* Delete the region display list for current region - FIXME: why? */
|
delete_region_display_list (dvb_sub, region); /* Delete the region display list for current region - FIXME: why? */
|
||||||
|
@ -641,14 +601,14 @@ _dvb_sub_parse_region_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
object_display->object_list_next = object->display_list;
|
object_display->object_list_next = object->display_list;
|
||||||
object->display_list = object_display;
|
object->display_list = object_display;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_REGION, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("REGION DATA: object_id = %u, region_id = %u, pos = %ux%u, "
|
||||||
"REGION DATA: object_id = %u, region_id = %u, pos = %ux%u, obj_type = %u",
|
"obj_type = %u", object->id, region->id, object_display->x_pos,
|
||||||
object->id, region->id, object_display->x_pos, object_display->y_pos,
|
object_display->y_pos, object->type);
|
||||||
object->type);
|
|
||||||
if (object->type == 1 || object->type == 2)
|
if (object->type == 1 || object->type == 2) {
|
||||||
dvb_log (DVB_LOG_REGION, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("REGION DATA: fgcolor = %u, bgcolor = %u",
|
||||||
"REGION DATA: fgcolor = %u, bgcolor = %u\n", object_display->fgcolor,
|
object_display->fgcolor, object_display->bgcolor);
|
||||||
object_display->bgcolor);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,10 +625,7 @@ _dvb_sub_parse_clut_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
int y, cr, cb, alpha;
|
int y, cr, cb, alpha;
|
||||||
int r, g, b, r_add, g_add, b_add;
|
int r, g, b, r_add, g_add, b_add;
|
||||||
|
|
||||||
#ifdef DEBUG_PACKET_CONTENTS
|
GST_MEMDUMP ("DVB clut packet", buf, buf_size);
|
||||||
g_print ("DVB clut packet:\n");
|
|
||||||
gst_util_dump_mem (buf, buf_size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clut_id = *buf++;
|
clut_id = *buf++;
|
||||||
buf += 1;
|
buf += 1;
|
||||||
|
@ -692,7 +649,7 @@ _dvb_sub_parse_clut_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
depth = (*buf) & 0xe0;
|
depth = (*buf) & 0xe0;
|
||||||
|
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
g_warning ("Invalid clut depth 0x%x!", *buf);
|
GST_WARNING ("Invalid clut depth 0x%x!", *buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,8 +675,8 @@ _dvb_sub_parse_clut_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
YUV_TO_RGB1_CCIR (cb, cr);
|
YUV_TO_RGB1_CCIR (cb, cr);
|
||||||
YUV_TO_RGB2_CCIR (r, g, b, y);
|
YUV_TO_RGB2_CCIR (r, g, b, y);
|
||||||
|
|
||||||
dvb_log (DVB_LOG_CLUT, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("CLUT DEFINITION: clut %d := (%d,%d,%d,%d)", entry_id, r, g, b,
|
||||||
"CLUT DEFINITION: clut %d := (%d,%d,%d,%d)", entry_id, r, g, b, alpha);
|
alpha);
|
||||||
|
|
||||||
if (depth & 0x80)
|
if (depth & 0x80)
|
||||||
clut->clut4[entry_id] = RGBA (r, g, b, 255 - alpha);
|
clut->clut4[entry_id] = RGBA (r, g, b, 255 - alpha);
|
||||||
|
@ -745,13 +702,13 @@ _dvb_sub_read_2bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
|
|
||||||
static gboolean warning_shown = FALSE;
|
static gboolean warning_shown = FALSE;
|
||||||
if (!warning_shown) {
|
if (!warning_shown) {
|
||||||
g_warning
|
g_warning ("Parsing 2bit color DVB sub-picture. This is not tested at all. "
|
||||||
("Parsing 2bit color DVB sub-picture. This is not tested at all. If you see this message, "
|
"If you see this message, please provide the developers with sample "
|
||||||
"please provide the developers with sample media with these subtitles, if possible.");
|
"media with these subtitles, if possible.");
|
||||||
warning_shown = TRUE;
|
warning_shown = TRUE;
|
||||||
}
|
}
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
|
||||||
"(n=2): Inside %s with dbuf_len = %d", __PRETTY_FUNCTION__, dbuf_len);
|
GST_TRACE ("dbuf_len = %d", dbuf_len);
|
||||||
|
|
||||||
while (!stop_parsing && (gst_bit_reader_get_remaining (&gb) > 0)) {
|
while (!stop_parsing && (gst_bit_reader_get_remaining (&gb) > 0)) {
|
||||||
guint run_length = 0, clut_index = 0;
|
guint run_length = 0, clut_index = 0;
|
||||||
|
@ -811,9 +768,9 @@ _dvb_sub_read_2bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
|
|
||||||
/* Now we can simply memset run_length count of destination bytes
|
/* Now we can simply memset run_length count of destination bytes
|
||||||
* to clut_index, but only if not non_modifying */
|
* to clut_index, but only if not non_modifying */
|
||||||
dvb_log (DVB_LOG_RUNLEN, G_LOG_LEVEL_DEBUG,
|
GST_TRACE ("RUNLEN: setting %u pixels to color 0x%x in destination buffer, "
|
||||||
"Setting %u pixels to color 0x%x in destination buffer; dbuf_len left is %d pixels",
|
"dbuf_len left is %d pixels", run_length, clut_index, dbuf_len);
|
||||||
run_length, clut_index, dbuf_len);
|
|
||||||
if (!(non_mod == 1 && bits == 1))
|
if (!(non_mod == 1 && bits == 1))
|
||||||
memset (destbuf, clut_index, run_length);
|
memset (destbuf, clut_index, run_length);
|
||||||
|
|
||||||
|
@ -825,8 +782,7 @@ _dvb_sub_read_2bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
//gst_bit_reader_skip_to_byte (&gb);
|
//gst_bit_reader_skip_to_byte (&gb);
|
||||||
*srcbuf += (gst_bit_reader_get_pos (&gb) + 7) >> 3;
|
*srcbuf += (gst_bit_reader_get_pos (&gb) + 7) >> 3;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_TRACE ("PIXEL: returning, read %u pixels", pixels_read);
|
||||||
"Returning from 2bit_string parser with %u pixels read", pixels_read);
|
|
||||||
// FIXME: Shouldn't need this variable if tracking things in the loop better
|
// FIXME: Shouldn't need this variable if tracking things in the loop better
|
||||||
return pixels_read;
|
return pixels_read;
|
||||||
}
|
}
|
||||||
|
@ -843,9 +799,8 @@ _dvb_sub_read_4bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
guint32 bits = 0;
|
guint32 bits = 0;
|
||||||
guint32 pixels_read = 0;
|
guint32 pixels_read = 0;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_RUNLEN, G_LOG_LEVEL_DEBUG,
|
GST_TRACE ("RUNLEN: srcbuf position %p, buf_size = %d; destination buffer "
|
||||||
"Entering 4bit_string parser at srcbuf position %p with buf_size = %d; destination buffer size is %d @ %p",
|
"size is %d @ %p", *srcbuf, buf_size, dbuf_len, destbuf);
|
||||||
*srcbuf, buf_size, dbuf_len, destbuf);
|
|
||||||
|
|
||||||
while (!stop_parsing && (gst_bit_reader_get_remaining (&gb) > 0)) {
|
while (!stop_parsing && (gst_bit_reader_get_remaining (&gb) > 0)) {
|
||||||
guint run_length = 0, clut_index = 0;
|
guint run_length = 0, clut_index = 0;
|
||||||
|
@ -910,9 +865,9 @@ _dvb_sub_read_4bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
|
|
||||||
/* Now we can simply memset run_length count of destination bytes
|
/* Now we can simply memset run_length count of destination bytes
|
||||||
* to clut_index, but only if not non_modifying */
|
* to clut_index, but only if not non_modifying */
|
||||||
dvb_log (DVB_LOG_RUNLEN, G_LOG_LEVEL_DEBUG,
|
GST_TRACE ("RUNLEN: setting %u pixels to color 0x%x in destination buffer; "
|
||||||
"Setting %u pixels to color 0x%x in destination buffer; dbuf_len left is %d pixels",
|
"dbuf_len left is %d pixels", run_length, clut_index, dbuf_len);
|
||||||
run_length, clut_index, dbuf_len);
|
|
||||||
if (!(non_mod == 1 && bits == 1))
|
if (!(non_mod == 1 && bits == 1))
|
||||||
memset (destbuf, clut_index, run_length);
|
memset (destbuf, clut_index, run_length);
|
||||||
|
|
||||||
|
@ -924,8 +879,8 @@ _dvb_sub_read_4bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
//gst_bit_reader_skip_to_byte (&gb);
|
//gst_bit_reader_skip_to_byte (&gb);
|
||||||
*srcbuf += (gst_bit_reader_get_pos (&gb) + 7) >> 3;
|
*srcbuf += (gst_bit_reader_get_pos (&gb) + 7) >> 3;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_LOG ("Returning with %u pixels read", pixels_read);
|
||||||
"Returning from 4bit_string parser with %u pixels read", pixels_read);
|
|
||||||
// FIXME: Shouldn't need this variable if tracking things in the loop better
|
// FIXME: Shouldn't need this variable if tracking things in the loop better
|
||||||
return pixels_read;
|
return pixels_read;
|
||||||
}
|
}
|
||||||
|
@ -948,8 +903,8 @@ _dvb_sub_read_8bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
"please provide the developers with sample media with these subtitles, if possible.");
|
"please provide the developers with sample media with these subtitles, if possible.");
|
||||||
warning_shown = TRUE;
|
warning_shown = TRUE;
|
||||||
}
|
}
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
|
||||||
"(n=8): Inside %s with dbuf_len = %d", __PRETTY_FUNCTION__, dbuf_len);
|
GST_LOG ("dbuf_len = %d", dbuf_len);
|
||||||
|
|
||||||
/* FFMPEG-FIXME: ffmpeg uses a manual byte walking algorithm, which might be more performant,
|
/* FFMPEG-FIXME: ffmpeg uses a manual byte walking algorithm, which might be more performant,
|
||||||
* FFMPEG-FIXME: but it does almost absolutely no buffer length checking, so could walk over
|
* FFMPEG-FIXME: but it does almost absolutely no buffer length checking, so could walk over
|
||||||
|
@ -977,14 +932,11 @@ _dvb_sub_read_8bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
/* run_length_3-127 */
|
/* run_length_3-127 */
|
||||||
gst_bit_reader_get_bits_uint32 (&gb, &run_length, 7);
|
gst_bit_reader_get_bits_uint32 (&gb, &run_length, 7);
|
||||||
gst_bit_reader_get_bits_uint32 (&gb, &clut_index, 8);
|
gst_bit_reader_get_bits_uint32 (&gb, &clut_index, 8);
|
||||||
#ifdef DEBUG
|
|
||||||
/* Emit a debugging message about stream not following specification */
|
|
||||||
if (run_length < 3) {
|
if (run_length < 3) {
|
||||||
dvb_log (DVB_LOG_STREAM, G_LOG_LEVEL_WARNING,
|
GST_WARNING ("runlength value was %u, but the spec requires it "
|
||||||
"8-bit/pixel_code_string::run_length_3-127 value was %u, but the spec requires it must be >=3",
|
"must be >=3", run_length);
|
||||||
run_length);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,9 +957,9 @@ _dvb_sub_read_8bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
|
|
||||||
/* Now we can simply memset run_length count of destination bytes
|
/* Now we can simply memset run_length count of destination bytes
|
||||||
* to clut_index, but only if not non_modifying */
|
* to clut_index, but only if not non_modifying */
|
||||||
dvb_log (DVB_LOG_RUNLEN, G_LOG_LEVEL_DEBUG,
|
GST_TRACE ("RUNLEN: setting %u pixels to color 0x%x in destination buffer; "
|
||||||
"Setting %u pixels to color 0x%x in destination buffer; dbuf_len left is %d pixels",
|
"dbuf_len left is %d pixels", run_length, clut_index, dbuf_len);
|
||||||
run_length, clut_index, dbuf_len);
|
|
||||||
if (!(non_mod == 1 && bits == 1))
|
if (!(non_mod == 1 && bits == 1))
|
||||||
memset (destbuf, clut_index, run_length);
|
memset (destbuf, clut_index, run_length);
|
||||||
|
|
||||||
|
@ -1015,8 +967,8 @@ _dvb_sub_read_8bit_string (guint8 * destbuf, gint dbuf_len,
|
||||||
pixels_read += run_length;
|
pixels_read += run_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_LOG ("Returning with %u pixels read", pixels_read);
|
||||||
"Returning from 8bit_string parser with %u pixels read", pixels_read);
|
|
||||||
// FIXME: Shouldn't need this variable if tracking things in the loop better
|
// FIXME: Shouldn't need this variable if tracking things in the loop better
|
||||||
return pixels_read;
|
return pixels_read;
|
||||||
}
|
}
|
||||||
|
@ -1040,16 +992,13 @@ _dvb_sub_parse_pixel_data_block (DvbSub * dvb_sub,
|
||||||
};
|
};
|
||||||
guint8 *map_table;
|
guint8 *map_table;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_LOG ("DVB pixel block size %d, %s field:", buf_size,
|
||||||
"(parse_block): DVB pixel block size %d, %s field:",
|
top_bottom ? "bottom" : "top");
|
||||||
buf_size, top_bottom ? "bottom" : "top");
|
|
||||||
|
|
||||||
#ifdef DEBUG_PACKET_CONTENTS
|
GST_MEMDUMP ("packet", buf, buf_size);
|
||||||
gst_util_dump_mem (buf, buf_size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (region == NULL) {
|
if (region == NULL) {
|
||||||
g_print ("Region is NULL, returning\n");
|
GST_LOG ("Region is NULL, returning");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1062,11 +1011,11 @@ _dvb_sub_parse_pixel_data_block (DvbSub * dvb_sub,
|
||||||
y_pos++;
|
y_pos++;
|
||||||
|
|
||||||
while (buf < buf_end) {
|
while (buf < buf_end) {
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_LOG ("Iteration start, %u bytes missing from end; buf = %p, "
|
||||||
"Iteration start, %u bytes missing from end; buf = %p, buf_end = %p; "
|
"buf_end = %p; Region is number %u, with a dimension of %dx%d; "
|
||||||
"Region is number %u, with a dimension of %dx%d; We are at position %dx%d",
|
"We are at position %dx%d", (guint) (buf_end - buf), buf, buf_end,
|
||||||
buf_end - buf, buf, buf_end,
|
|
||||||
region->id, region->width, region->height, x_pos, y_pos);
|
region->id, region->width, region->height, x_pos, y_pos);
|
||||||
|
|
||||||
// FFMPEG-FIXME: ffmpeg doesn't check for equality and so can overflow destination buffer later on with bad input data
|
// FFMPEG-FIXME: ffmpeg doesn't check for equality and so can overflow destination buffer later on with bad input data
|
||||||
// FFMPEG-FIXME: However that makes it warn on end_of_object_line and map tables as well, so we add the dest_buf_filled tracking
|
// FFMPEG-FIXME: However that makes it warn on end_of_object_line and map tables as well, so we add the dest_buf_filled tracking
|
||||||
// FIXME: Removed x_pos checking here, because we don't want to turn dest_buf_filled to TRUE permanently in that case
|
// FIXME: Removed x_pos checking here, because we don't want to turn dest_buf_filled to TRUE permanently in that case
|
||||||
|
@ -1079,9 +1028,11 @@ _dvb_sub_parse_pixel_data_block (DvbSub * dvb_sub,
|
||||||
switch (*buf++) {
|
switch (*buf++) {
|
||||||
case 0x10:
|
case 0x10:
|
||||||
if (dest_buf_filled) {
|
if (dest_buf_filled) {
|
||||||
g_warning ("Invalid object location for data_type 0x%x!\n", *(buf - 1)); /* FIXME: Be more verbose */
|
/* FIXME: Be more verbose */
|
||||||
g_print ("Remaining data after invalid object location:\n");
|
GST_WARNING ("Invalid object location for data_type 0x%x!",
|
||||||
gst_util_dump_mem (buf, buf_end - buf);
|
*(buf - 1));
|
||||||
|
GST_MEMDUMP ("Remaining data after invalid object location:", buf,
|
||||||
|
(guint) (buf_end - buf));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,14 +1051,16 @@ _dvb_sub_parse_pixel_data_block (DvbSub * dvb_sub,
|
||||||
break;
|
break;
|
||||||
case 0x11:
|
case 0x11:
|
||||||
if (dest_buf_filled) {
|
if (dest_buf_filled) {
|
||||||
g_warning ("Invalid object location for data_type 0x%x!\n", *(buf - 1)); /* FIXME: Be more verbose */
|
/* FIXME: Be more verbose */
|
||||||
g_print ("Remaining data after invalid object location:\n");
|
GST_WARNING ("Invalid object location for data_type 0x%x!",
|
||||||
gst_util_dump_mem (buf, buf_end - buf);
|
*(buf - 1));
|
||||||
|
GST_MEMDUMP ("Remaining data after invalid object location:", buf,
|
||||||
|
buf_end - buf);
|
||||||
return; // FIXME: Perhaps tell read_nbit_string that dbuf_len is zero and let it walk the bytes regardless? (Same FIXME for 2bit and 8bit)
|
return; // FIXME: Perhaps tell read_nbit_string that dbuf_len is zero and let it walk the bytes regardless? (Same FIXME for 2bit and 8bit)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region->depth < 4) {
|
if (region->depth < 4) {
|
||||||
g_warning ("4-bit pixel string in %d-bit region!\n", region->depth);
|
GST_WARNING ("4-bit pixel string in %d-bit region!", region->depth);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,27 +1069,27 @@ _dvb_sub_parse_pixel_data_block (DvbSub * dvb_sub,
|
||||||
else
|
else
|
||||||
map_table = NULL;
|
map_table = NULL;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_LOG ("READ_4BIT_STRING: String data into position %dx%d; "
|
||||||
"READ_nBIT_STRING (4): String data into position %dx%d; buf before is %p\n",
|
"buf before is %p", x_pos, y_pos, buf);
|
||||||
x_pos, y_pos, buf);
|
|
||||||
// FFMPEG-FIXME: ffmpeg code passes buf_size instead of buf_end - buf, and could
|
// FFMPEG-FIXME: ffmpeg code passes buf_size instead of buf_end - buf, and could
|
||||||
// FFMPEG-FIXME: therefore potentially walk over the memory area we own
|
// FFMPEG-FIXME: therefore potentially walk over the memory area we own
|
||||||
x_pos +=
|
x_pos +=
|
||||||
_dvb_sub_read_4bit_string (pbuf + (y_pos * region->width) + x_pos,
|
_dvb_sub_read_4bit_string (pbuf + (y_pos * region->width) + x_pos,
|
||||||
region->width - x_pos, &buf, buf_end - buf, non_mod, map_table);
|
region->width - x_pos, &buf, buf_end - buf, non_mod, map_table);
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("READ_4BIT_STRING finished: buf pointer now %p", buf);
|
||||||
"READ_nBIT_STRING (4) finished: buf pointer now %p", buf);
|
|
||||||
break;
|
break;
|
||||||
case 0x12:
|
case 0x12:
|
||||||
if (dest_buf_filled) {
|
if (dest_buf_filled) {
|
||||||
g_warning ("Invalid object location for data_type 0x%x!\n", *(buf - 1)); /* FIXME: Be more verbose */
|
/* FIXME: Be more verbose */
|
||||||
g_print ("Remaining data after invalid object location:\n");
|
GST_WARNING ("Invalid object location for data_type 0x%x!",
|
||||||
gst_util_dump_mem (buf, buf_end - buf);
|
*(buf - 1));
|
||||||
|
GST_MEMDUMP ("Remaining data after invalid object location:",
|
||||||
|
buf, (guint) (buf_end - buf));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region->depth < 8) {
|
if (region->depth < 8) {
|
||||||
g_warning ("8-bit pixel string in %d-bit region!\n", region->depth);
|
GST_WARNING ("8-bit pixel string in %d-bit region!", region->depth);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// FFMPEG-FIXME: ffmpeg code passes buf_size instead of buf_end - buf, and could
|
// FFMPEG-FIXME: ffmpeg code passes buf_size instead of buf_end - buf, and could
|
||||||
|
@ -1147,8 +1100,7 @@ _dvb_sub_parse_pixel_data_block (DvbSub * dvb_sub,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x20:
|
case 0x20:
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("handling map2to4 table data");
|
||||||
"(parse_block): handling map2to4 table data");
|
|
||||||
/* FIXME: I don't see any guards about buffer size here - buf++ happens with the switch, but
|
/* FIXME: I don't see any guards about buffer size here - buf++ happens with the switch, but
|
||||||
* FIXME: buffer is walked without length checks? Same deal in other map table cases */
|
* FIXME: buffer is walked without length checks? Same deal in other map table cases */
|
||||||
map2to4[0] = (*buf) >> 4;
|
map2to4[0] = (*buf) >> 4;
|
||||||
|
@ -1157,27 +1109,23 @@ _dvb_sub_parse_pixel_data_block (DvbSub * dvb_sub,
|
||||||
map2to4[3] = (*buf++) & 0xf;
|
map2to4[3] = (*buf++) & 0xf;
|
||||||
break;
|
break;
|
||||||
case 0x21:
|
case 0x21:
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("handling map2to8 table data");
|
||||||
"(parse_block): handling map2to8 table data");
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
map2to8[i] = *buf++;
|
map2to8[i] = *buf++;
|
||||||
break;
|
break;
|
||||||
case 0x22:
|
case 0x22:
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("handling map4to8 table data");
|
||||||
"(parse_block): handling map4to8 table data");
|
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
map4to8[i] = *buf++;
|
map4to8[i] = *buf++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xf0:
|
case 0xf0:
|
||||||
dvb_log (DVB_LOG_PIXEL, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("end of object line code encountered");
|
||||||
"(parse_block): end of object line code encountered");
|
|
||||||
x_pos = display->x_pos;
|
x_pos = display->x_pos;
|
||||||
y_pos += 2;
|
y_pos += 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* FIXME: Do we consume word align stuffing byte that could follow top/bottom data? */
|
/* FIXME: Do we consume word align stuffing byte that could follow top/bottom data? */
|
||||||
g_warning ("Unknown/unsupported pixel block 0x%x", *(buf - 1));
|
GST_WARNING ("Unknown/unsupported pixel block 0x%x", *(buf - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1197,13 +1145,11 @@ _dvb_sub_parse_object_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
|
|
||||||
object = get_object (dvb_sub, object_id);
|
object = get_object (dvb_sub, object_id);
|
||||||
|
|
||||||
dvb_log (DVB_LOG_OBJECT, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("OBJECT: a new object segment has occurred for object_id = %u",
|
||||||
"parse_object_segment: A new object segment has occurred for object_id = %u",
|
|
||||||
object_id);
|
object_id);
|
||||||
|
|
||||||
if (!object) {
|
if (!object) {
|
||||||
g_warning
|
GST_WARNING ("Nothing known about object with ID %u yet, bailing out",
|
||||||
("Nothing known about object with ID %u yet inside parse_object_segment, bailing out",
|
|
||||||
object_id);
|
object_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1222,7 +1168,7 @@ _dvb_sub_parse_object_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
buf += 2;
|
buf += 2;
|
||||||
|
|
||||||
if (buf + top_field_len + bottom_field_len > buf_end) {
|
if (buf + top_field_len + bottom_field_len > buf_end) {
|
||||||
g_warning ("%s: Field data size too large\n", __PRETTY_FUNCTION__);
|
GST_WARNING ("Field data size too large");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1232,9 +1178,10 @@ _dvb_sub_parse_object_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
display = display->object_list_next) {
|
display = display->object_list_next) {
|
||||||
block = buf;
|
block = buf;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_OBJECT, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("OBJECT: parsing top and bottom part of object id %d; "
|
||||||
"Parsing top and bottom part of object id %d; top_field_len = %u, bottom_field_len = %u",
|
"top_field_len = %u, bottom_field_len = %u",
|
||||||
display->object_id, top_field_len, bottom_field_len);
|
display->object_id, top_field_len, bottom_field_len);
|
||||||
|
|
||||||
_dvb_sub_parse_pixel_data_block (dvb_sub, display, block, top_field_len,
|
_dvb_sub_parse_pixel_data_block (dvb_sub, display, block, top_field_len,
|
||||||
TOP_FIELD, non_modifying_color);
|
TOP_FIELD, non_modifying_color);
|
||||||
|
|
||||||
|
@ -1248,10 +1195,9 @@ _dvb_sub_parse_object_segment (DvbSub * dvb_sub, guint16 page_id, guint8 * buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (coding_method == 1) {
|
} else if (coding_method == 1) {
|
||||||
g_warning ("'a string of characters' coding method not supported (yet?)!");
|
GST_FIXME ("'a string of characters' coding method not supported yet!");
|
||||||
} else {
|
} else {
|
||||||
g_warning ("%s: Unknown object coding 0x%x\n", __PRETTY_FUNCTION__,
|
GST_WARNING ("Unknown object coding 0x%x", coding_method);
|
||||||
coding_method);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,10 +1256,9 @@ _dvb_sub_parse_end_of_display_set (DvbSub * dvb_sub, guint16 page_id,
|
||||||
guint32 *clut_table;
|
guint32 *clut_table;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
static unsigned counter = 0; /* DEBUG use only */
|
static unsigned counter = 0; /* DEBUG use only *//* FIXME: get rid */
|
||||||
|
|
||||||
dvb_log (DVB_LOG_DISPLAY, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("DISPLAY SET END: page_id = %u, length = %d", page_id, buf_size);
|
||||||
"END OF DISPLAY SET: page_id = %u, length = %d\n", page_id, buf_size);
|
|
||||||
|
|
||||||
sub->rects = NULL;
|
sub->rects = NULL;
|
||||||
#if 0 /* FIXME: PTS stuff not figured out yet */
|
#if 0 /* FIXME: PTS stuff not figured out yet */
|
||||||
|
@ -1379,23 +1324,19 @@ _dvb_sub_parse_end_of_display_set (DvbSub * dvb_sub, guint16 page_id,
|
||||||
rect->pict.palette = g_malloc ((1 << region->depth) * sizeof (guint32)); /* FIXME: Can we use GSlice here? */
|
rect->pict.palette = g_malloc ((1 << region->depth) * sizeof (guint32)); /* FIXME: Can we use GSlice here? */
|
||||||
memcpy (rect->pict.palette, clut_table,
|
memcpy (rect->pict.palette, clut_table,
|
||||||
(1 << region->depth) * sizeof (guint32));
|
(1 << region->depth) * sizeof (guint32));
|
||||||
#if 0
|
|
||||||
g_print ("rect->pict.data.palette content:\n");
|
GST_MEMDUMP ("rect->pict.data.palette content",
|
||||||
gst_util_dump_mem (rect->pict.palette,
|
(guint8 *) rect->pict.palette, (1 << region->depth) * sizeof (guint32));
|
||||||
(1 << region->depth) * sizeof (guint32));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rect->pict.data = g_malloc (region->buf_size); /* FIXME: Can we use GSlice here? */
|
rect->pict.data = g_malloc (region->buf_size); /* FIXME: Can we use GSlice here? */
|
||||||
memcpy (rect->pict.data, region->pbuf, region->buf_size);
|
memcpy (rect->pict.data, region->pbuf, region->buf_size);
|
||||||
|
|
||||||
++counter;
|
++counter;
|
||||||
dvb_log (DVB_LOG_DISPLAY, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("DISPLAY: an object rect created: number %u, iteration %u, "
|
||||||
"An object rect created: number %u, iteration %u, pos: %d:%d, size: %dx%d",
|
"pos: %d:%d, size: %dx%d", counter, i, rect->x, rect->y, rect->w,
|
||||||
counter, i, rect->x, rect->y, rect->w, rect->h);
|
rect->h);
|
||||||
#if 0
|
|
||||||
g_print ("rect->pict.data content:\n");
|
GST_MEMDUMP ("rect->pict.data content", rect->pict.data, region->buf_size);
|
||||||
gst_util_dump_mem (rect->pict.data, region->buf_size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
@ -1484,50 +1425,46 @@ dvb_sub_feed_with_pts (DvbSub * dvb_sub, guint64 pts, guint8 * data, gint len)
|
||||||
guint16 segment_len;
|
guint16 segment_len;
|
||||||
guint16 page_id;
|
guint16 page_id;
|
||||||
|
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("pts=%" G_GUINT64_FORMAT " and length %d", pts, len);
|
||||||
"Inside dvb_sub_feed_with_pts with pts=%" G_GUINT64_FORMAT
|
|
||||||
" and length %d", pts, len);
|
|
||||||
|
|
||||||
g_return_val_if_fail (data != NULL, -1);
|
g_return_val_if_fail (data != NULL, -1);
|
||||||
|
|
||||||
if (len <= 3) { /* len(0x20 0x00 end_of_PES_data_field_marker) */
|
if (len <= 3) { /* len(0x20 0x00 end_of_PES_data_field_marker) */
|
||||||
g_warning ("Data length too short");
|
GST_WARNING ("Data length too short");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data[pos++] != 0x20) {
|
if (data[pos++] != 0x20) {
|
||||||
g_warning
|
GST_WARNING ("Tried to handle a PES packet private data that isn't a "
|
||||||
("Tried to handle a PES packet private data that isn't a subtitle packet (does not start with 0x20)");
|
"subtitle packet (does not start with 0x20)");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data[pos++] != 0x00) {
|
if (data[pos++] != 0x00) {
|
||||||
g_warning
|
GST_WARNING ("'Subtitle stream in this PES packet' was not 0x00, so this "
|
||||||
("'Subtitle stream in this PES packet' was not 0x00, so this is in theory not a DVB subtitle stream (but some other subtitle standard?); bailing out");
|
"is in theory not a DVB subtitle stream (but some other subtitle "
|
||||||
|
"standard?); bailing out");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (data[pos++] == DVB_SUB_SYNC_BYTE) {
|
while (data[pos++] == DVB_SUB_SYNC_BYTE) {
|
||||||
if ((len - pos) < (2 * 2 + 1)) {
|
if ((len - pos) < (2 * 2 + 1)) {
|
||||||
g_warning
|
GST_WARNING ("Data after SYNC BYTE too short, less than needed to "
|
||||||
("Data after SYNC BYTE too short, less than needed to even get to segment_length");
|
"even get to segment_length");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
segment_type = data[pos++];
|
segment_type = data[pos++];
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("=== Segment type is 0x%x", segment_type);
|
||||||
"=== Segment type is 0x%x", segment_type);
|
|
||||||
page_id = (data[pos] << 8) | data[pos + 1];
|
page_id = (data[pos] << 8) | data[pos + 1];
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG, "page_id is 0x%x", page_id);
|
GST_DEBUG ("page_id is 0x%x", page_id);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
segment_len = (data[pos] << 8) | data[pos + 1];
|
segment_len = (data[pos] << 8) | data[pos + 1];
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("segment_length is %d (0x%x 0x%x)", segment_len, data[pos],
|
||||||
"segment_length is %d (0x%x 0x%x)", segment_len, data[pos],
|
|
||||||
data[pos + 1]);
|
data[pos + 1]);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
if ((len - pos) < segment_len) {
|
if ((len - pos) < segment_len) {
|
||||||
g_warning
|
GST_WARNING ("segment_length was told to be %u, but we only have "
|
||||||
("segment_length was told to be %u, but we only have %d bytes left",
|
"%d bytes left", segment_len, len - pos);
|
||||||
segment_len, len - pos);
|
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
// TODO: Parse the segment per type (this is probably a leftover TODO that is now done?)
|
// TODO: Parse the segment per type (this is probably a leftover TODO that is now done?)
|
||||||
|
@ -1535,50 +1472,44 @@ dvb_sub_feed_with_pts (DvbSub * dvb_sub, guint64 pts, guint8 * data, gint len)
|
||||||
* FIXME: but we let it slip and just take it for granted in end_of_display_set */
|
* FIXME: but we let it slip and just take it for granted in end_of_display_set */
|
||||||
switch (segment_type) {
|
switch (segment_type) {
|
||||||
case DVB_SUB_SEGMENT_PAGE_COMPOSITION:
|
case DVB_SUB_SEGMENT_PAGE_COMPOSITION:
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("Page composition segment at buffer pos %u", pos);
|
||||||
"Page composition segment at buffer pos %u\n", pos);
|
|
||||||
_dvb_sub_parse_page_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
_dvb_sub_parse_page_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
||||||
break;
|
break;
|
||||||
case DVB_SUB_SEGMENT_REGION_COMPOSITION:
|
case DVB_SUB_SEGMENT_REGION_COMPOSITION:
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("Region composition segment at buffer pos %u", pos);
|
||||||
"Region composition segment at buffer pos %u\n", pos);
|
|
||||||
_dvb_sub_parse_region_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
_dvb_sub_parse_region_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
||||||
break;
|
break;
|
||||||
case DVB_SUB_SEGMENT_CLUT_DEFINITION:
|
case DVB_SUB_SEGMENT_CLUT_DEFINITION:
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("CLUT definition segment at buffer pos %u", pos);
|
||||||
"CLUT definition segment at buffer pos %u\n", pos);
|
|
||||||
_dvb_sub_parse_clut_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
_dvb_sub_parse_clut_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
||||||
break;
|
break;
|
||||||
case DVB_SUB_SEGMENT_OBJECT_DATA:
|
case DVB_SUB_SEGMENT_OBJECT_DATA:
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("Object data segment at buffer pos %u", pos);
|
||||||
"Object data segment at buffer pos %u\n", pos);
|
|
||||||
_dvb_sub_parse_object_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
_dvb_sub_parse_object_segment (dvb_sub, page_id, data + pos, segment_len); /* FIXME: Not sure about args */
|
||||||
break;
|
break;
|
||||||
case DVB_SUB_SEGMENT_DISPLAY_DEFINITION:
|
case DVB_SUB_SEGMENT_DISPLAY_DEFINITION:
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("display definition segment at buffer pos %u", pos);
|
||||||
"display definition segment at buffer pos %u\n", pos);
|
|
||||||
_dvb_sub_parse_display_definition_segment (dvb_sub, data + pos,
|
_dvb_sub_parse_display_definition_segment (dvb_sub, data + pos,
|
||||||
segment_len);
|
segment_len);
|
||||||
break;
|
break;
|
||||||
case DVB_SUB_SEGMENT_END_OF_DISPLAY_SET:
|
case DVB_SUB_SEGMENT_END_OF_DISPLAY_SET:
|
||||||
dvb_log (DVB_LOG_PACKET, G_LOG_LEVEL_DEBUG,
|
GST_DEBUG ("End of display set at buffer pos %u", pos);
|
||||||
"End of display set at buffer pos %u\n", pos);
|
|
||||||
_dvb_sub_parse_end_of_display_set (dvb_sub, page_id, data + pos, segment_len, pts); /* FIXME: Not sure about args */
|
_dvb_sub_parse_end_of_display_set (dvb_sub, page_id, data + pos, segment_len, pts); /* FIXME: Not sure about args */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("Unhandled segment type 0x%x", segment_type);
|
GST_FIXME ("Unhandled segment type 0x%x", segment_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += segment_len;
|
pos += segment_len;
|
||||||
|
|
||||||
if (pos == len) {
|
if (pos == len) {
|
||||||
g_warning ("Data ended without a PES data end marker");
|
GST_WARNING ("Data ended without a PES data end marker");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_warning ("Processed %d bytes out of %d\n", pos, len);
|
GST_LOG ("Processed %d bytes out of %d", pos, len);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1605,14 +1536,3 @@ dvb_sub_set_callbacks (DvbSub * dvb_sub, DvbSubCallbacks * callbacks,
|
||||||
priv->callbacks = *callbacks;
|
priv->callbacks = *callbacks;
|
||||||
priv->user_data = user_data;
|
priv->user_data = user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
dvb_sub_set_global_log_cb (void (*log_cb) (GLogLevelFlags log_level,
|
|
||||||
const gchar * format, va_list args, gpointer user_data),
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
if (log_cb) {
|
|
||||||
g_log_callback = log_cb;
|
|
||||||
g_log_callback_user_data = user_data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -153,15 +153,14 @@ typedef struct {
|
||||||
gpointer _dvb_sub_reserved[3];
|
gpointer _dvb_sub_reserved[3];
|
||||||
} DvbSubCallbacks;
|
} DvbSubCallbacks;
|
||||||
|
|
||||||
|
void dvb_sub_init_debug (void);
|
||||||
|
|
||||||
GType dvb_sub_get_type (void) G_GNUC_CONST;
|
GType dvb_sub_get_type (void) G_GNUC_CONST;
|
||||||
DvbSub *dvb_sub_new (void);
|
DvbSub *dvb_sub_new (void);
|
||||||
gint dvb_sub_feed_with_pts (DvbSub *dvb_sub, guint64 pts, guint8 *data, gint len);
|
gint dvb_sub_feed_with_pts (DvbSub *dvb_sub, guint64 pts, guint8 *data, gint len);
|
||||||
void dvb_sub_set_callbacks (DvbSub *dvb_sub, DvbSubCallbacks *callbacks, gpointer user_data);
|
void dvb_sub_set_callbacks (DvbSub *dvb_sub, DvbSubCallbacks *callbacks, gpointer user_data);
|
||||||
void dvb_subtitles_free (DVBSubtitles *sub);
|
void dvb_subtitles_free (DVBSubtitles *sub);
|
||||||
|
|
||||||
void dvb_sub_set_global_log_cb (void (*log_cb) (GLogLevelFlags log_level, const gchar *format, va_list args, gpointer user_data),
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _DVB_SUB_H_ */
|
#endif /* _DVB_SUB_H_ */
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_dvbsub_overlay_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_dvbsub_overlay_debug);
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_dvbsub_overlay_lib_debug);
|
|
||||||
#define GST_CAT_DEFAULT gst_dvbsub_overlay_debug
|
#define GST_CAT_DEFAULT gst_dvbsub_overlay_debug
|
||||||
|
|
||||||
/* Filter signals and props */
|
/* Filter signals and props */
|
||||||
|
@ -158,27 +157,6 @@ gst_dvbsub_overlay_class_init (GstDVBSubOverlayClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_dvbsub_overlay_change_state);
|
GST_DEBUG_FUNCPTR (gst_dvbsub_overlay_change_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_dvbsub_log_cb (GLogLevelFlags level, const gchar * fmt, va_list args,
|
|
||||||
gpointer render)
|
|
||||||
{
|
|
||||||
gchar *message = g_strdup_vprintf (fmt, args);
|
|
||||||
|
|
||||||
if (level & G_LOG_LEVEL_ERROR)
|
|
||||||
GST_CAT_ERROR (gst_dvbsub_overlay_lib_debug, "%s", message);
|
|
||||||
else if (level & G_LOG_LEVEL_WARNING)
|
|
||||||
GST_CAT_WARNING (gst_dvbsub_overlay_lib_debug, "%s", message);
|
|
||||||
else if (level & G_LOG_LEVEL_INFO)
|
|
||||||
GST_CAT_INFO (gst_dvbsub_overlay_lib_debug, "%s", message);
|
|
||||||
else if (level & G_LOG_LEVEL_DEBUG)
|
|
||||||
GST_CAT_DEBUG (gst_dvbsub_overlay_lib_debug, "%s", message);
|
|
||||||
else
|
|
||||||
GST_CAT_LOG (gst_dvbsub_overlay_lib_debug,
|
|
||||||
"log level %d: %s", level, message);
|
|
||||||
|
|
||||||
g_free (message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dvbsub_overlay_flush_subtitles (GstDVBSubOverlay * render)
|
gst_dvbsub_overlay_flush_subtitles (GstDVBSubOverlay * render)
|
||||||
{
|
{
|
||||||
|
@ -1178,10 +1156,8 @@ plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_dvbsub_overlay_debug, "dvbsuboverlay",
|
GST_DEBUG_CATEGORY_INIT (gst_dvbsub_overlay_debug, "dvbsuboverlay",
|
||||||
0, "DVB subtitle overlay");
|
0, "DVB subtitle overlay");
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_dvbsub_overlay_lib_debug, "dvbsub_library",
|
|
||||||
0, "libdvbsub library");
|
|
||||||
|
|
||||||
dvb_sub_set_global_log_cb (_dvbsub_log_cb, NULL);
|
dvb_sub_init_debug ();
|
||||||
|
|
||||||
return gst_element_register (plugin, "dvbsuboverlay",
|
return gst_element_register (plugin, "dvbsuboverlay",
|
||||||
GST_RANK_PRIMARY, GST_TYPE_DVBSUB_OVERLAY);
|
GST_RANK_PRIMARY, GST_TYPE_DVBSUB_OVERLAY);
|
||||||
|
|
Loading…
Reference in a new issue