xine-lib: xine-lib-1.2.12/src/spu_dec/sputext_decoder.c File Reference

xine-lib 1.2.12

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
sputext_decoder.c File Reference
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <sys/types.h>`
`#include <ctype.h>`
`#include <xine/buffer.h>`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/osd.h>`
`#include "xine-engine/bswap.h"`
`#include "sputext_demuxer.h"`

## Data Structures
struct | sputext_class_s
struct | video2wnd_s
struct | sputext_decoder_s

## Macros
#define | LOG_MODULE "libsputext"
#define | LOG_VERBOSE
#define | SUB_MAX_TEXT 5 /* lines */
#define | SUB_BUFSIZE 256 /* chars per line */
#define | ALIGN_LEFT 1
#define | ALIGN_CENTER 2
#define | ALIGN_RIGHT 3
#define | ALIGN_BOTTOM 0
#define | ALIGN_TOP 4
#define | ALIGN_MIDDLE 8
#define | GET_X_ALIGNMENT(a) ((a) & 3)
#define | GET_Y_ALIGNMENT(a) ((a) - ((a) & 3))
#define | SPU_PROJECTION_X 384
#define | SPU_PROJECTION_Y 288
#define | rgb2yuv(R, G, B) ((((((66*R+129*G+25*B+128)>>8)+16)<<8)|(((112*R-94*G-18*B+128)>>8)+128))<<8|(((-38*R-74*G+112*B+128)>>8)+128))

## Typedefs
typedef struct sputext_class_s | sputext_class_t
typedef struct video2wnd_s | video2wnd_t
typedef struct sputext_decoder_s | sputext_decoder_t

## Enumerations
enum | subtitle_size { SUBTITLE_SIZE_SMALL = 0 , SUBTITLE_SIZE_NORMAL , SUBTITLE_SIZE_LARGE , SUBTITLE_SIZE_NUM , SUBTITLE_SIZE_TINY = 0 , SUBTITLE_SIZE_SMALL , SUBTITLE_SIZE_NORMAL , SUBTITLE_SIZE_LARGE , SUBTITLE_SIZE_VERY_LARGE , SUBTITLE_SIZE_HUGE , SUBTITLE_SIZE_NUM }

## Functions
static int | update_font (sputext_decoder_t *this)
static const char * | get_font (sputext_decoder_t *this)
static void | update_font_size (sputext_decoder_t *this, int force_update)
static void | update_output_size (sputext_decoder_t *this)
static int | parse_utf8_size (const void *buf)
static int | ogm_render_line_internal (sputext_decoder_t *this, int x, int y, const char *text, int render)
static int | ogm_get_width (sputext_decoder_t *this, char *text)
static void | ogm_render_line (sputext_decoder_t *this, int x, int y, char *text)
static void | read_ssa_tag (sputext_decoder_t *this, const char *text, int *alignment, int *sub_x, int *sub_y, int *max_width)
static int | is_cjk_encoding (const char *enc)
static void | draw_subtitle (sputext_decoder_t *this, int64_t sub_start, int64_t sub_end)
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 | update_vertical_offset (void *class_gen, xine_cfg_entry_t *entry)
static void | update_osd_font (void *class_gen, xine_cfg_entry_t *entry)
static void | update_subtitle_size (void *class_gen, xine_cfg_entry_t *entry)
static void | update_use_unscaled (void *class_gen, xine_cfg_entry_t *entry)
static spu_decoder_t * | sputext_class_open_plugin (spu_decoder_class_t *class_gen, xine_stream_t *stream)
static void | sputext_class_dispose (spu_decoder_class_t *class_gen)
static void | update_src_encoding (void *class_gen, xine_cfg_entry_t *entry)
static void * | init_spu_decoder_plugin (xine_t *xine, const void *data)

## Variables
static const uint32_t | sub_palette [22]
static const uint8_t | sub_trans [22]
static const uint32_t | supported_types [] = { BUF_SPU_TEXT, BUF_SPU_OGM, 0 }
static const decoder_info_t | spudec_info
const plugin_info_t xine_plugin_info[] | EXPORTED

## Macro Definition Documentation

## ◆ ALIGN_BOTTOM

#define ALIGN_BOTTOM 0

## ◆ ALIGN_CENTER

#define ALIGN_CENTER 2

## ◆ ALIGN_LEFT

#define ALIGN_LEFT 1

## ◆ ALIGN_MIDDLE

#define ALIGN_MIDDLE 8

## ◆ ALIGN_RIGHT

#define ALIGN_RIGHT 3

## ◆ ALIGN_TOP

#define ALIGN_TOP 4

## ◆ GET_X_ALIGNMENT

#define GET_X_ALIGNMENT | ( |  | a | ) | ((a) & 3)

## ◆ GET_Y_ALIGNMENT

#define GET_Y_ALIGNMENT | ( |  | a | ) | ((a) - ((a) & 3))

## ◆ LOG_MODULE

#define LOG_MODULE "libsputext"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ rgb2yuv

#define rgb2yuv | ( |  | R,
|  |  | G,
|  |  | B
| ) |  | ((((((66*R+129*G+25*B+128)>>8)+16)<<8)|(((112*R-94*G-18*B+128)>>8)+128))<<8|(((-38*R-74*G+112*B+128)>>8)+128))

## ◆ SPU_PROJECTION_X

#define SPU_PROJECTION_X 384

## ◆ SPU_PROJECTION_Y

#define SPU_PROJECTION_Y 288

## ◆ SUB_BUFSIZE

#define SUB_BUFSIZE 256 /* chars per line */

## ◆ SUB_MAX_TEXT

#define SUB_MAX_TEXT 5 /* lines */

## Typedef Documentation

## ◆ sputext_class_t

typedef struct sputext_class_s sputext_class_t

## ◆ sputext_decoder_t

typedef struct sputext_decoder_s sputext_decoder_t

## ◆ video2wnd_t

typedef struct video2wnd_s video2wnd_t

## Enumeration Type Documentation

## ◆ subtitle_size

enum subtitle_size

Enumerator
SUBTITLE_SIZE_SMALL |
SUBTITLE_SIZE_NORMAL |
SUBTITLE_SIZE_LARGE |
SUBTITLE_SIZE_NUM |
SUBTITLE_SIZE_TINY |
SUBTITLE_SIZE_SMALL |
SUBTITLE_SIZE_NORMAL |
SUBTITLE_SIZE_LARGE |
SUBTITLE_SIZE_VERY_LARGE |
SUBTITLE_SIZE_HUGE |
SUBTITLE_SIZE_NUM |

## Function Documentation

## ◆ draw_subtitle()

static void draw_subtitle | ( | sputext_decoder_t * | this,
|  | int64_t | sub_start,
|  | int64_t | sub_end
| ) |  |
| static

References _x_assert, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, get_font(), GET_X_ALIGNMENT, GET_Y_ALIGNMENT, height, is_cjk_encoding(), lprintf, NULL, ogm_get_width(), ogm_render_line(), OSD_TEXT1, OSD_TEXT2, read_ssa_tag(), SUB_BUFSIZE, SUB_MAX_TEXT, sub_palette, sub_trans, update_font(), update_font_size(), width, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by spudec_decode_data().

## ◆ get_font()

static const char * get_font | ( | sputext_decoder_t * | this | ) |
| inlinestatic

References update_font().

Referenced by draw_subtitle(), and update_font_size().

## ◆ init_spu_decoder_plugin()

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

References _, xine_s::config, lprintf, N_, NULL, config_values_s::register_bool, config_values_s::register_enum, config_values_s::register_filename, config_values_s::register_num, config_values_s::register_string, sputext_class_dispose(), sputext_class_open_plugin(), update_osd_font(), update_src_encoding(), update_subtitle_size(), update_use_unscaled(), update_vertical_offset(), XINE_CONFIG_STRING_IS_FILENAME, and xine_guess_spu_encoding().

## ◆ is_cjk_encoding()

static int is_cjk_encoding | ( | const char * | enc | ) |
| static

Referenced by draw_subtitle().

## ◆ ogm_get_width()

static int ogm_get_width | ( | sputext_decoder_t * | this,
|  | char * | text
| ) |  |
| inlinestatic

References ogm_render_line_internal().

Referenced by draw_subtitle().

## ◆ ogm_render_line()

static void ogm_render_line | ( | sputext_decoder_t * | this,
|  | int | x,
|  | int | y,
|  | char * | text
| ) |  |
| inlinestatic

References ogm_render_line_internal().

Referenced by draw_subtitle().

## ◆ ogm_render_line_internal()

static int ogm_render_line_internal | ( | sputext_decoder_t * | this,
|  | int | x,
|  | int | y,
|  | const char * | text,
|  | int | render
| ) |  |
| static

References OSD_TEXT1, OSD_TEXT2, OSD_TEXT3, and parse_utf8_size().

Referenced by ogm_get_width(), and ogm_render_line().

## ◆ parse_utf8_size()

static int parse_utf8_size | ( | const void * | buf | ) |
| static

Referenced by ogm_render_line_internal().

## ◆ read_ssa_tag()

static void read_ssa_tag | ( | sputext_decoder_t * | this,
|  | const char * | text,
|  | int * | alignment,
|  | int * | sub_x,
|  | int * | sub_y,
|  | int * | max_width
| ) |  |
| static

References ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, GET_X_ALIGNMENT, height, width, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by draw_subtitle().

## ◆ spudec_decode_data()

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

References _x_get_current_info(), _X_ME_32, _x_spu_decoder_sleep(), BUF_FLAG_HEADER, BUF_FLAG_PREVIEW, BUF_FLAG_SPECIAL, BUF_SPECIAL_CHARSET_ENCODING, BUF_SPU_OGM, buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, buf_element_s::decoder_info_ptr, draw_subtitle(), extra_info_s::frame_number, height, extra_info_s::input_normpos, extra_info_s::input_time, lprintf, METRONOM_SPU_OFFSET, NULL, OSD_TEXT1, SUB_BUFSIZE, SUB_MAX_TEXT, buf_element_s::type, update_output_size(), VO_PROP_DISCARD_FRAMES, extra_info_s::vpts, width, xine_get_status(), XINE_STATUS_PLAY, xine_usec_sleep(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by sputext_class_open_plugin().

## ◆ spudec_discontinuity()

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

Referenced by sputext_class_open_plugin().

## ◆ spudec_dispose()

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

References _x_freep(), and NULL.

Referenced by sputext_class_open_plugin().

## ◆ spudec_reset()

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

References height, lprintf, and width.

Referenced by sputext_class_open_plugin().

## ◆ sputext_class_dispose()

static void sputext_class_dispose | ( | spu_decoder_class_t * | class_gen | ) |
| static

References _x_freep(), and NULL.

Referenced by init_spu_decoder_plugin().

## ◆ sputext_class_open_plugin()

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

References NULL, spudec_decode_data(), spudec_discontinuity(), spudec_dispose(), and spudec_reset().

Referenced by init_spu_decoder_plugin().

## ◆ update_font()

static int update_font | ( | sputext_decoder_t * | this | ) |
| inlinestatic

Referenced by draw_subtitle(), and get_font().

## ◆ update_font_size()

static void update_font_size | ( | sputext_decoder_t * | this,
|  | int | force_update
| ) |  |
| static

References get_font(), height, SUBTITLE_SIZE_NUM, and width.

Referenced by draw_subtitle(), and update_output_size().

## ◆ update_osd_font()

static void update_osd_font | ( | void * | class_gen,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References xine_cfg_entry_s::str_value, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by init_spu_decoder_plugin().

## ◆ update_output_size()

static void update_output_size | ( | sputext_decoder_t * | this | ) |
| static

References height, NULL, SPU_PROJECTION_X, SPU_PROJECTION_Y, update_font_size(), VO_CAP_UNSCALED_OVERLAY, VO_PROP_OUTPUT_HEIGHT, VO_PROP_OUTPUT_WIDTH, VO_PROP_OUTPUT_XOFFSET, VO_PROP_OUTPUT_YOFFSET, VO_PROP_WINDOW_HEIGHT, VO_PROP_WINDOW_WIDTH, and width.

Referenced by spudec_decode_data().

## ◆ update_src_encoding()

static void update_src_encoding | ( | void * | class_gen,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References sputext_class_s::src_encoding, xine_cfg_entry_s::str_value, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by init_spu_decoder_plugin().

## ◆ update_subtitle_size()

static void update_subtitle_size | ( | void * | class_gen,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References xine_cfg_entry_s::num_value, and sputext_class_s::subtitle_size.

Referenced by init_spu_decoder_plugin().

## ◆ update_use_unscaled()

static void update_use_unscaled | ( | void * | class_gen,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References xine_cfg_entry_s::num_value, and sputext_class_s::use_unscaled.

Referenced by init_spu_decoder_plugin().

## ◆ update_vertical_offset()

static void update_vertical_offset | ( | void * | class_gen,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References xine_cfg_entry_s::num_value, and sputext_class_s::vertical_offset.

Referenced by init_spu_decoder_plugin().

## Variable Documentation

## ◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED

Initial value:
= {
{ PLUGIN_SPU_DECODER | PLUGIN_MUST_PRELOAD, 17, "sputext", XINE_VERSION_CODE, &spudec_info, &init_spu_decoder_plugin },
{ PLUGIN_DEMUX, 27, "sputext", XINE_VERSION_CODE, NULL, &init_sputext_demux_class },
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
init_spu_decoder_plugin
static void * init_spu_decoder_plugin(xine_t *xine, const void *data)
Definition: sputext_decoder.c:1148
spudec_info
static const decoder_info_t spudec_info
Definition: sputext_decoder.c:1236
init_sputext_demux_class
void * init_sputext_demux_class(xine_t *xine, const void *data)
Definition: sputext_demuxer.c:1473
XINE_VERSION_CODE
#define XINE_VERSION_CODE
Definition: xine_internal.h:57
NULL
NULL
Definition: xine_plugin.c:78
PLUGIN_DEMUX
#define PLUGIN_DEMUX
Definition: xine_plugin.h:31
PLUGIN_NONE
#define PLUGIN_NONE
Definition: xine_plugin.h:29
PLUGIN_SPU_DECODER
#define PLUGIN_SPU_DECODER
Definition: xine_plugin.h:34
PLUGIN_MUST_PRELOAD
#define PLUGIN_MUST_PRELOAD
Definition: xine_plugin.h:46

## ◆ 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: sputext_decoder.c:1234

## ◆ sub_palette

const uint32_t sub_palette[22]
| static

Initial value:
={
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 50 +129* 10 +25* 10 +128)>>8)+16)<<8)|(((112* 50 -94* 10 -18* 10 +128)>>8)+128))<<8|(((-38* 50 -74* 10 +112* 10 +128)>>8)+128)),
((((((66* 120 +129* 20 +25* 20 +128)>>8)+16)<<8)|(((112* 120 -94* 20 -18* 20 +128)>>8)+128))<<8|(((-38* 120 -74* 20 +112* 20 +128)>>8)+128)),
((((((66* 185 +129* 50 +25* 50 +128)>>8)+16)<<8)|(((112* 185 -94* 50 -18* 50 +128)>>8)+128))<<8|(((-38* 185 -74* 50 +112* 50 +128)>>8)+128)),
((((((66* 255 +129* 70 +25* 70 +128)>>8)+16)<<8)|(((112* 255 -94* 70 -18* 70 +128)>>8)+128))<<8|(((-38* 255 -74* 70 +112* 70 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 0 +25* 0 +128)>>8)+16)<<8)|(((112* 0 -94* 0 -18* 0 +128)>>8)+128))<<8|(((-38* 0 -74* 0 +112* 0 +128)>>8)+128)),
((((((66* 0 +129* 30 +25* 50 +128)>>8)+16)<<8)|(((112* 0 -94* 30 -18* 50 +128)>>8)+128))<<8|(((-38* 0 -74* 30 +112* 50 +128)>>8)+128)),
((((((66* 0 +129* 90 +25* 120 +128)>>8)+16)<<8)|(((112* 0 -94* 90 -18* 120 +128)>>8)+128))<<8|(((-38* 0 -74* 90 +112* 120 +128)>>8)+128)),
((((((66* 0 +129* 140 +25* 185 +128)>>8)+16)<<8)|(((112* 0 -94* 140 -18* 185 +128)>>8)+128))<<8|(((-38* 0 -74* 140 +112* 185 +128)>>8)+128)),
((((((66* 0 +129* 170 +25* 255 +128)>>8)+16)<<8)|(((112* 0 -94* 170 -18* 255 +128)>>8)+128))<<8|(((-38* 0 -74* 170 +112* 255 +128)>>8)+128))
}

Referenced by draw_subtitle().

## ◆ sub_trans

const uint8_t sub_trans[22]
| static

Initial value:
={
0, 0, 3, 6, 8, 10, 12, 14, 15, 15, 15,
0, 0, 3, 6, 8, 10, 12, 14, 15, 15, 15
}

Referenced by draw_subtitle().

## ◆ supported_types

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