xine-lib: xine-lib-1.2.13/src/spu_dec/spudvb_decoder.c File Reference

xine-lib 1.2.13-20230125hg15249

Data Structures | Macros | Typedefs | Functions | Variables
spudvb_decoder.c File Reference
`#include <time.h>`
`#include <pthread.h>`
`#include <errno.h>`
`#include <xine/xine_internal.h>`
`#include <xine/spu.h>`
`#include <xine/osd.h>`
`#include "xine-engine/bswap.h"`

## Data Structures
struct | sparse_array_entry_t
struct | _sparse_array_entry_t
struct | sparse_array_t
struct | page_t
struct | region_t
union | clut_union_t
struct | dds_t
struct | dvbsub_func_t
struct | dvbsub_func_t::_lut_group_s
struct | dvb_spu_decoder_s

## Macros
#define | LOG_MODULE "spudvb"
#define | MAX_REGIONS 16
#define | SPU_MAX_WIDTH 1920
#define | SPU_MAX_HEIGHT 1080
#define | INT64_MAX ((int64_t)((~(uint64_t)0) >> 1))
#define | _REGION_FLAG_CHANGED 1
#define | _REGION_FLAG_FILL 2
#define | _REGION_FLAG_SHOW 4
#define | _REGION_FLAG_VISIBLE 8

## Typedefs
typedef struct dvb_spu_decoder_s | dvb_spu_decoder_t

## Functions
static void | sparse_array_new (sparse_array_t *sa)
static void | sparse_array_clear (sparse_array_t *sa)
static void | sparse_array_delete (sparse_array_t *sa)
static uint32_t | _sparse_array_find (sparse_array_t *sa, uint32_t key)
static void | _sparse_array_sort (sparse_array_t *sa)
static int | sparse_array_set (sparse_array_t *sa, uint32_t key, uint32_t value)
static sparse_array_entry_t * | sparse_array_get (sparse_array_t *sa, uint32_t key)
static void | sparse_array_unset (sparse_array_t *sa, uint32_t key, uint32_t mask)
static void | _region_init (dvbsub_func_t *dvbsub)
static void | _region_deinit (dvbsub_func_t *dvbsub)
static uint32_t | _region_find (dvbsub_func_t *dvbsub, uint32_t id, int new)
static void | _clut_init (dvbsub_func_t *dvbsub)
static void | _clut_deinit (dvbsub_func_t *dvbsub)
static clut_union_t * | _clut_find (dvbsub_func_t *dvbsub, uint32_t id, int new)
static void | _clut_reset (dvbsub_func_t *dvbsub)
static void | update_region (region_t *reg, uint32_t region_id, int32_t region_width, int32_t region_height, int32_t fill_color)
static void | plot (dvbsub_func_t *dvbsub, int r, uint32_t run_length, uint8_t pixel)
static const uint8_t * | lookup_lut (const dvbsub_func_t *dvbsub, int r)
static unsigned char | next_datum (dvbsub_func_t *dvbsub, int width)
static void | decode_2bit_pixel_code_string (dvbsub_func_t *dvbsub, int r, int n)
static void | decode_4bit_pixel_code_string (dvbsub_func_t *dvbsub, int r, int n)
static void | decode_8bit_pixel_code_string (dvbsub_func_t *dvbsub, int r, int n)
static void | process_alt_CLUT_segment (dvbsub_func_t *dvbsub)
static void | process_CLUT_definition_segment (dvbsub_func_t *dvbsub)
static void | process_pixel_data_sub_block (dvbsub_func_t *dvbsub, int r, unsigned int pos, int ofs, int n)
static void | process_page_composition_segment (dvbsub_func_t *dvbsub)
static void | process_region_composition_segment (dvbsub_func_t *dvbsub)
static void | process_object_data_segment (dvbsub_func_t *dvbsub)
static void | process_display_definition_segment (dvbsub_func_t *dvbsub)
static void | _hide_overlays (dvb_spu_decoder_t *this)
static void | update_osd (dvb_spu_decoder_t *this, region_t *reg)
static void | downscale_region_image (region_t *reg, unsigned char *dest, int dest_width)
static void | recalculate_trans (dvb_spu_decoder_t *this)
static void | draw_subtitles (dvb_spu_decoder_t *this)
static void | spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf)
static void | spudec_reset (spu_decoder_t *this_gen)
static void | spudec_discontinuity (spu_decoder_t *this_gen)
static void | spudec_dispose (spu_decoder_t *this_gen)
static void | _spudvb_set_timeout (void *data, xine_cfg_entry_t *entry)
static spu_decoder_t * | dvb_spu_class_open_plugin (spu_decoder_class_t *class_gen, xine_stream_t *stream)
static void * | init_spu_decoder_plugin (xine_t *xine, const void *data)

## Variables
static const uint32_t | supported_types [] = { BUF_SPU_DVB, 0 }
static const decoder_info_t | spudec_info
const plugin_info_t xine_plugin_info[] | EXPORTED

## Macro Definition Documentation

## ◆ _REGION_FLAG_CHANGED

#define _REGION_FLAG_CHANGED 1

Referenced by draw_subtitles(), plot(), process_page_composition_segment(), and process_region_composition_segment().

## ◆ _REGION_FLAG_FILL

#define _REGION_FLAG_FILL 2

Referenced by draw_subtitles(), and update_region().

## ◆ _REGION_FLAG_SHOW

#define _REGION_FLAG_SHOW 4

Referenced by draw_subtitles(), and process_page_composition_segment().

## ◆ _REGION_FLAG_VISIBLE

#define _REGION_FLAG_VISIBLE 8

Referenced by draw_subtitles().

## ◆ INT64_MAX

#define INT64_MAX ((int64_t)((~(uint64_t)0) >> 1))

## ◆ LOG_MODULE

#define LOG_MODULE "spudvb"

Referenced by draw_subtitles(), spudec_decode_data(), and spudec_reset().

## ◆ MAX_REGIONS

#define MAX_REGIONS 16

Referenced by _clut_find(), _clut_reset(), _region_find(), dvb_spu_class_open_plugin(), recalculate_trans(), spudec_dispose(), and spudec_reset().

## ◆ SPU_MAX_HEIGHT

#define SPU_MAX_HEIGHT 1080

Referenced by update_region().

## ◆ SPU_MAX_WIDTH

#define SPU_MAX_WIDTH 1920

Referenced by update_region().

## Typedef Documentation

## ◆ dvb_spu_decoder_t

typedef struct dvb_spu_decoder_s dvb_spu_decoder_t

## Function Documentation

## ◆ _clut_deinit()

static void _clut_deinit | ( | dvbsub_func_t * | dvbsub | ) |
| static

Referenced by spudec_dispose().

## ◆ _clut_find()

static clut_union_t * _clut_find | ( | dvbsub_func_t * | dvbsub,
|  | uint32_t | id,
|  | int | new )
| static

References dvbsub_func_t::clut_ids, dvbsub_func_t::clut_num, dvbsub_func_t::colours, and MAX_REGIONS.

Referenced by draw_subtitles(), process_alt_CLUT_segment(), and process_CLUT_definition_segment().

## ◆ _clut_init()

static void _clut_init | ( | dvbsub_func_t * | dvbsub | ) |
| static

References dvbsub_func_t::clut_ids, and dvbsub_func_t::clut_num.

Referenced by _clut_reset().

## ◆ _clut_reset()

static void _clut_reset | ( | dvbsub_func_t * | dvbsub | ) |
| static

look at the output of $ gcc -DGEN_DEFAULT_CLUT -o ~/bin/default_clut spudvb_decoder.c $ default_clut $ rm ~/bin/default_clut

References _clut_init(), dvbsub_func_t::clut_cm, dvbsub_func_t::clut_gen, dvbsub_func_t::colours, default_clut, dvbsub_func_t::lut, and MAX_REGIONS.

Referenced by dvb_spu_class_open_plugin().

## ◆ _hide_overlays()

static void _hide_overlays | ( | dvb_spu_decoder_t * | this | ) |
| static

Referenced by spudec_decode_data(), and spudec_reset().

## ◆ _region_deinit()

static void _region_deinit | ( | dvbsub_func_t * | dvbsub | ) |
| static

Referenced by spudec_dispose().

## ◆ _region_find()

static uint32_t _region_find | ( | dvbsub_func_t * | dvbsub,
|  | uint32_t | id,
|  | int | new )
| static

References MAX_REGIONS, dvbsub_func_t::region_ids, and dvbsub_func_t::region_num.

Referenced by process_page_composition_segment(), and process_region_composition_segment().

## ◆ _region_init()

static void _region_init | ( | dvbsub_func_t * | dvbsub | ) |
| static

References dvbsub_func_t::region_ids, and dvbsub_func_t::region_num.

Referenced by dvb_spu_class_open_plugin().

## ◆ _sparse_array_find()

static uint32_t _sparse_array_find | ( | sparse_array_t * | sa,
|  | uint32_t | key )
| static

References key, and sparse_array_t::sorted_entries.

Referenced by _sparse_array_sort(), and sparse_array_get().

## ◆ _sparse_array_sort()

static void _sparse_array_sort | ( | sparse_array_t * | sa | ) |
| static

References _sparse_array_find(), sparse_array_t::entries, _sparse_array_entry_t::key, lprintf, sparse_array_t::max_entries, sparse_array_t::sorted_entries, sparse_array_t::used_entries, and _sparse_array_entry_t::value.

Referenced by sparse_array_get(), and sparse_array_unset().

## ◆ _spudvb_set_timeout()

static void _spudvb_set_timeout | ( | void * | data,
|  | xine_cfg_entry_t * | entry )
| static

References xine_cfg_entry_s::num_value.

Referenced by dvb_spu_class_open_plugin().

## ◆ decode_2bit_pixel_code_string()

static void decode_2bit_pixel_code_string | ( | dvbsub_func_t * | dvbsub,
|  | int | r,
|  | int | n )
| static

References dvbsub_func_t::i, dvbsub_func_t::i_bits, lookup_lut(), next_datum(), and plot().

Referenced by process_pixel_data_sub_block().

## ◆ decode_4bit_pixel_code_string()

static void decode_4bit_pixel_code_string | ( | dvbsub_func_t * | dvbsub,
|  | int | r,
|  | int | n )
| static

References dvbsub_func_t::i, dvbsub_func_t::i_bits, lookup_lut(), next_datum(), and plot().

Referenced by process_pixel_data_sub_block().

## ◆ decode_8bit_pixel_code_string()

static void decode_8bit_pixel_code_string | ( | dvbsub_func_t * | dvbsub,
|  | int | r,
|  | int | n )
| static

References dvbsub_func_t::buf, dvbsub_func_t::i, and plot().

Referenced by process_pixel_data_sub_block().

## ◆ downscale_region_image()

static void downscale_region_image | ( | region_t * | reg,
|  | unsigned char * | dest,
|  | int | dest_width )
| static

References region_t::height, region_t::img, and region_t::width.

Referenced by draw_subtitles().

## ◆ draw_subtitles()

static void draw_subtitles | ( | dvb_spu_decoder_t * | this | ) |
| static

f***ing complex timing rule:

1. When user_timeout == 0, do exactly what the stream says. This often leads to very hectic flicker. There will be gaps between parts of the same sentece, and short texts will disappear right when viewer starts reading them.
2. When user_timeout > 0, use stream hide time or user timeout, whatever is later. When new regions appear, hide all earlier regions whose stream hide time has roughly expired. This will close gaps, and it will still allow stream intended overlaps.

References _clut_find(), _REGION_FLAG_CHANGED, _REGION_FLAG_FILL, _REGION_FLAG_SHOW, _REGION_FLAG_VISIBLE, _X_SET_CLUT_CM, region_t::CLUT_id, downscale_region_image(), region_t::flags, region_t::height, region_t::hide_vpts, region_t::img, LOG_MODULE, lprintf, mode(), NULL, region_t::osd, region_t::show_vpts, region_t::stream_hide_vpts, clut_union_t::u32, update_osd(), VO_CAP_CUSTOM_EXTENT_OVERLAY, osd_object_s::width, region_t::width, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by spudec_decode_data().

## ◆ dvb_spu_class_open_plugin()

static spu_decoder_t * dvb_spu_class_open_plugin | ( | spu_decoder_class_t * | class_gen,
|  | xine_stream_t * | stream )
| static

References _clut_reset(), _region_init(), _spudvb_set_timeout(), xine_s::config, MAX_REGIONS, NULL, config_values_s::register_num, sparse_array_new(), spudec_decode_data(), spudec_discontinuity(), spudec_dispose(), spudec_reset(), and xine_stream_s::xine.

Referenced by init_spu_decoder_plugin().

## ◆ init_spu_decoder_plugin()

static void * init_spu_decoder_plugin | ( | xine_t * | xine,
|  | const void * | data )
| static

References _, xine_s::config, spu_decoder_s::dispose, dvb_spu_class_open_plugin(), N_, NULL, spu_decoder_class_s::open_plugin, and config_values_s::register_num.

## ◆ lookup_lut()

static const uint8_t * lookup_lut | ( | const dvbsub_func_t * | dvbsub,
|  | int | r )
| static

References dvbsub_func_t::compat_depth, dvbsub_func_t::lut, dvbsub_func_t::_lut_group_s::lut24, dvbsub_func_t::_lut_group_s::lut28, and dvbsub_func_t::_lut_group_s::lut48.

Referenced by decode_2bit_pixel_code_string(), and decode_4bit_pixel_code_string().

## ◆ next_datum()

static unsigned char next_datum | ( | dvbsub_func_t * | dvbsub,
|  | int | width )
| static

References dvbsub_func_t::buf, dvbsub_func_t::i, dvbsub_func_t::i_bits, next_datum(), and width.

Referenced by decode_2bit_pixel_code_string(), decode_4bit_pixel_code_string(), and next_datum().

## ◆ plot()

static void plot | ( | dvbsub_func_t * | dvbsub,
|  | int | r,
|  | uint32_t | run_length,
|  | uint8_t | pixel )
| static

References _REGION_FLAG_CHANGED, region_t::flags, region_t::height, region_t::img, dvbsub_func_t::regions, region_t::width, dvbsub_func_t::x, and dvbsub_func_t::y.

Referenced by decode_2bit_pixel_code_string(), decode_4bit_pixel_code_string(), and decode_8bit_pixel_code_string().

## ◆ process_alt_CLUT_segment()

static void process_alt_CLUT_segment | ( | dvbsub_func_t * | dvbsub | ) |
| static

References _clut_find(), _X_BE_16, _X_BE_32, dvbsub_func_t::buf, clut_union_t::c, clut_s::cb, dvbsub_func_t::clut_cm, dvbsub_func_t::clut_gen, dvbsub_func_t::colours, clut_s::cr, clut_s::foo, dvbsub_func_t::i, lprintf, clut_union_t::u32, v, and clut_s::y.

Referenced by spudec_decode_data().

## ◆ process_CLUT_definition_segment()

static void process_CLUT_definition_segment | ( | dvbsub_func_t * | dvbsub | ) |
| static

References _clut_find(), _X_BE_16, dvbsub_func_t::buf, clut_union_t::c, clut_s::cb, dvbsub_func_t::clut_cm, dvbsub_func_t::clut_gen, dvbsub_func_t::colours, clut_s::cr, clut_s::foo, dvbsub_func_t::i, lprintf, clut_union_t::u32, v, and clut_s::y.

Referenced by spudec_decode_data().

## ◆ process_display_definition_segment()

static void process_display_definition_segment | ( | dvbsub_func_t * | dvbsub | ) |
| static

References _X_BE_16, dvbsub_func_t::buf, dvbsub_func_t::dds, dds_t::height, dvbsub_func_t::i, lprintf, dds_t::version_number, dds_t::width, and dds_t::windowed.

Referenced by spudec_decode_data().

## ◆ process_object_data_segment()

static void process_object_data_segment | ( | dvbsub_func_t * | dvbsub | ) |
| static

References _X_BE_16, dvbsub_func_t::buf, dvbsub_func_t::curr_obj, dvbsub_func_t::i, page_t::id, region_t::img, sparse_array_entry_t::key, dvbsub_func_t::object_pos, dvbsub_func_t::page, process_pixel_data_sub_block(), dvbsub_func_t::region_num, dvbsub_func_t::regions, sparse_array_get(), and sparse_array_entry_t::value.

Referenced by spudec_decode_data().

## ◆ process_page_composition_segment()

static void process_page_composition_segment | ( | dvbsub_func_t * | dvbsub | ) |
| static

References _region_find(), _REGION_FLAG_CHANGED, _REGION_FLAG_SHOW, _X_BE_16, dvbsub_func_t::buf, region_t::flags, dvbsub_func_t::i, page_t::id, lprintf, dvbsub_func_t::page, dvbsub_func_t::region_num, dvbsub_func_t::regions, page_t::regions, page_t::state, page_t::time_out, page_t::version, page_t::x, and page_t::y.

Referenced by spudec_decode_data().

## ◆ process_pixel_data_sub_block()

static void process_pixel_data_sub_block | ( | dvbsub_func_t * | dvbsub,
|  | int | r,
|  | unsigned int | pos,
|  | int | ofs,
|  | int | n )
| static

References dvbsub_func_t::buf, decode_2bit_pixel_code_string(), decode_4bit_pixel_code_string(), decode_8bit_pixel_code_string(), dvbsub_func_t::i, lprintf, dvbsub_func_t::lut, dvbsub_func_t::_lut_group_s::lut24, dvbsub_func_t::_lut_group_s::lut28, dvbsub_func_t::_lut_group_s::lut48, dvbsub_func_t::x, and dvbsub_func_t::y.

Referenced by process_object_data_segment().

## ◆ process_region_composition_segment()

static void process_region_composition_segment | ( | dvbsub_func_t * | dvbsub | ) |
| static

References _region_find(), _REGION_FLAG_CHANGED, _X_BE_16, dvbsub_func_t::buf, region_t::CLUT_id, dvbsub_func_t::compat_depth, region_t::flags, dvbsub_func_t::i, page_t::id, lprintf, dvbsub_func_t::object_pos, dvbsub_func_t::page, dvbsub_func_t::regions, sparse_array_set(), sparse_array_unset(), update_region(), and region_t::version.

Referenced by spudec_decode_data().

## ◆ recalculate_trans()

static void recalculate_trans | ( | dvb_spu_decoder_t * | this | ) |
| static

References _x_spu_dvb_opacity(), MAX_REGIONS, and v.

Referenced by spudec_decode_data().

## ◆ sparse_array_clear()

static void sparse_array_clear | ( | sparse_array_t * | sa | ) |
| static

References sparse_array_t::max_entries, sparse_array_t::sorted_entries, and sparse_array_t::used_entries.

Referenced by spudec_reset().

## ◆ sparse_array_delete()

static void sparse_array_delete | ( | sparse_array_t * | sa | ) |
| static

References _x_freep(), sparse_array_t::entries, sparse_array_t::max_entries, sparse_array_t::sorted_entries, and sparse_array_t::used_entries.

Referenced by spudec_dispose().

## ◆ sparse_array_get()

static sparse_array_entry_t * sparse_array_get | ( | sparse_array_t * | sa,
|  | uint32_t | key )
| static

References _sparse_array_find(), _sparse_array_sort(), sparse_array_t::entries, key, sparse_array_t::sorted_entries, and sparse_array_t::used_entries.

Referenced by process_object_data_segment().

## ◆ sparse_array_new()

static void sparse_array_new | ( | sparse_array_t * | sa | ) |
| static

References sparse_array_t::entries, sparse_array_t::max_entries, NULL, sparse_array_t::sorted_entries, and sparse_array_t::used_entries.

Referenced by dvb_spu_class_open_plugin().

## ◆ sparse_array_set()

static int sparse_array_set | ( | sparse_array_t * | sa,
|  | uint32_t | key,
|  | uint32_t | value )
| static

References sparse_array_t::entries, _sparse_array_entry_t::key, key, sparse_array_t::max_entries, sparse_array_t::used_entries, and _sparse_array_entry_t::value.

Referenced by process_region_composition_segment().

## ◆ sparse_array_unset()

static void sparse_array_unset | ( | sparse_array_t * | sa,
|  | uint32_t | key,
|  | uint32_t | mask )
| static

References _sparse_array_sort(), sparse_array_t::entries, _sparse_array_entry_t::key, key, NULL, sparse_array_t::sorted_entries, and sparse_array_t::used_entries.

Referenced by process_region_composition_segment().

## ◆ spudec_decode_data()

static void spudec_decode_data | ( | spu_decoder_t * | this_gen,
|  | buf_element_t * | buf )
| static

References _hide_overlays(), _X_BE_16, BUF_FLAG_SPECIAL, BUF_SPECIAL_SPU_DVB_DESCRIPTOR, BUF_SPU_DVB, buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, buf_element_s::decoder_info_ptr, draw_subtitles(), metronom_s::got_spu_packet, LOG_MODULE, lprintf, process_alt_CLUT_segment(), process_CLUT_definition_segment(), process_display_definition_segment(), process_object_data_segment(), process_page_composition_segment(), process_region_composition_segment(), buf_element_s::pts, recalculate_trans(), buf_element_s::size, buf_element_s::type, xine_fast_memcpy, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by dvb_spu_class_open_plugin().

## ◆ spudec_discontinuity()

static void spudec_discontinuity | ( | spu_decoder_t * | this_gen | ) |
| static

Referenced by dvb_spu_class_open_plugin().

## ◆ spudec_dispose()

static void spudec_dispose | ( | spu_decoder_t * | this_gen | ) |
| static

References _clut_deinit(), _region_deinit(), _x_freep(), MAX_REGIONS, NULL, and sparse_array_delete().

Referenced by dvb_spu_class_open_plugin().

## ◆ spudec_reset()

static void spudec_reset | ( | spu_decoder_t * | this_gen | ) |
| static

References _hide_overlays(), LOG_MODULE, MAX_REGIONS, sparse_array_clear(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by dvb_spu_class_open_plugin().

## ◆ update_osd()

static void update_osd | ( | dvb_spu_decoder_t * | this,
|  | region_t * | reg )
| static

References osd_object_s::height, region_t::height, region_t::img, NULL, region_t::osd, osd_object_s::width, and region_t::width.

Referenced by draw_subtitles().

## ◆ update_region()

static void update_region | ( | region_t * | reg,
|  | uint32_t | region_id,
|  | int32_t | region_width,
|  | int32_t | region_height,
|  | int32_t | fill_color )
| static

References _REGION_FLAG_FILL, _x_freep(), region_t::flags, region_t::height, region_t::img, lprintf, SPU_MAX_HEIGHT, SPU_MAX_WIDTH, and region_t::width.

Referenced by process_region_composition_segment().

## Variable Documentation

## ◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED

Initial value:
= {
{PLUGIN_SPU_DECODER, 17, "spudvb", XINE_VERSION_CODE, &spudec_info,
&init_spu_decoder_plugin},
{PLUGIN_NONE, 0, NULL, 0, NULL, NULL}
}
init_spu_decoder_plugin
static void * init_spu_decoder_plugin(xine_t *xine, const void *data)
Definition spudvb_decoder.c:1802
spudec_info
static const decoder_info_t spudec_info
Definition spudvb_decoder.c:1831
XINE_VERSION_CODE
#define XINE_VERSION_CODE
Definition xine_internal.h:57
NULL
NULL
Definition xine_plugin.c:78
PLUGIN_NONE
#define PLUGIN_NONE
Definition xine_plugin.h:29
PLUGIN_SPU_DECODER
#define PLUGIN_SPU_DECODER
Definition xine_plugin.h:34

## ◆ spudec_info

const decoder_info_t spudec_info
| static

Initial value:
= {
.supported_types = supported_types,
.priority = 1,
}
supported_types
static const uint32_t supported_types[]
Definition spudvb_decoder.c:1829

## ◆ supported_types

const uint32_t supported_types[] = { BUF_SPU_DVB, 0 }
| static