xine-lib 1.2.13-20230125hg15249
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/time.h>
#include <inttypes.h>
#include <xine/xine_internal.h>
#include <xine/video_out.h>
#include <xine/xineutils.h>
#include <xine/osd.h>
#include "cc_decoder.h"
Data Structures | |
struct | colorinfo_s |
struct | cc_renderer_s |
struct | cc_attribute_s |
struct | cc_char_cell_s |
struct | cc_row_s |
struct | cc_buffer_s |
struct | cc_memory_s |
struct | cc_decoder_s |
Macros | |
#define | NTSC_FRAME_DURATION 3003 |
#define | CC_ROWS 15 |
#define | CC_COLUMNS 32 |
#define | CC_CHANNELS 2 |
#define | CAP_BG_COL 1 |
#define | NUM_FG_COL 7 |
#define | TRANSP_SPACE |
Typedefs | |
typedef struct colorinfo_s | colorinfo_t |
typedef struct cc_attribute_s | cc_attribute_t |
typedef struct cc_char_cell_s | cc_char_cell_t |
typedef struct cc_row_s | cc_row_t |
typedef struct cc_buffer_s | cc_buffer_t |
typedef struct cc_memory_s | cc_memory_t |
Enumerations | |
enum | { WHITE , GREEN , BLUE , CYAN , RED , YELLOW , MAGENTA , BLACK , TRANSPARENT } |
Functions | |
static void | get_font_metrics (osd_renderer_t *renderer, const char *fontname, int font_size, int *maxw, int *maxh) |
static int | good_parity (uint16_t data) |
static clut_t | interpolate_color (clut_t src, clut_t dest, int steps, int current_step) |
static void | ccrow_fill_transp (cc_row_t *rowbuf) |
static int | ccrow_find_next_text_part (cc_row_t *this, int pos) |
static int | ccrow_find_end_of_text_part (cc_row_t *this, int pos) |
static int | ccrow_find_current_attr (cc_row_t *this, int pos) |
static int | ccrow_find_next_attr_change (cc_row_t *this, int pos, int lastpos) |
static void | ccrow_set_attributes (cc_renderer_t *renderer, cc_row_t *this, int pos) |
static void | ccrow_render (cc_renderer_t *renderer, cc_row_t *this, int rownum) |
static int | ccbuf_has_displayable (cc_buffer_t *this) |
static void | ccbuf_add_char (cc_buffer_t *this, uint8_t c) |
static void | ccbuf_set_cursor (cc_buffer_t *this, int row, int column, int underline, int italics, int color) |
static void | ccbuf_apply_attribute (cc_buffer_t *this, cc_attribute_t *attr) |
static void | ccbuf_tab (cc_buffer_t *this, int tabsize) |
static void | ccbuf_render (cc_renderer_t *renderer, cc_buffer_t *this) |
static void | ccmem_clear (cc_memory_t *this) |
static void | ccmem_init (cc_memory_t *this) |
static void | ccmem_exit (cc_memory_t *this) |
static void | cc_renderer_build_palette (cc_renderer_t *this) |
static int64_t | cc_renderer_calc_vpts (cc_renderer_t *this, int64_t pts, uint32_t ntsc_frame_offset) |
static int | cc_renderer_on_display (cc_renderer_t *this) |
static void | cc_renderer_hide_caption (cc_renderer_t *this, int64_t vpts) |
static void | cc_renderer_show_caption (cc_renderer_t *this, cc_buffer_t *buf, int64_t vpts) |
static void | cc_renderer_free_osd_object (cc_renderer_t *this) |
static void | cc_renderer_adjust_osd_object (cc_renderer_t *this) |
cc_renderer_t * | cc_renderer_open (osd_renderer_t *osd_renderer, metronom_t *metronom, cc_state_t *cc_state, int video_width, int video_height) |
void | cc_renderer_close (cc_renderer_t *this_obj) |
void | cc_renderer_update_cfg (cc_renderer_t *this_obj, int video_width, int video_height) |
static void | cc_set_channel (cc_decoder_t *this, int channel) |
static cc_buffer_t * | active_ccbuffer (cc_decoder_t *this) |
static int | cc_onscreen_displayable (cc_decoder_t *this) |
static void | cc_hide_displayed (cc_decoder_t *this) |
static void | cc_show_displayed (cc_decoder_t *this) |
static void | cc_swap_buffers (cc_decoder_t *this) |
static void | cc_decode_standard_char (cc_decoder_t *this, uint8_t c1, uint8_t c2) |
static void | cc_decode_PAC (cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2) |
static void | cc_decode_ext_attribute (cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2) |
static void | cc_decode_special_char (cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2) |
static void | cc_decode_midrow_attr (cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2) |
static void | cc_decode_misc_control_code (cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2) |
static void | cc_decode_tab (cc_decoder_t *this, int channel, uint8_t c1, uint8_t c2) |
static void | cc_decode_EIA608 (cc_decoder_t *this, uint16_t data) |
void | decode_cc (cc_decoder_t *this, uint8_t *buffer, uint32_t buf_len, int64_t pts) |
cc_decoder_t * | cc_decoder_open (cc_state_t *cc_state) |
void | cc_decoder_close (cc_decoder_t *this) |
Variables | |
static const int | text_colormap [7] |
static const colorinfo_t | cc_text_trans [7] |
static const colorinfo_t | cc_text_solid [7] |
static const uint8_t | cc_text_trans_alpha [TEXT_PALETTE_SIZE] |
static const uint8_t | cc_text_solid_alpha [TEXT_PALETTE_SIZE] |
static const colorinfo_t *const | cc_text_palettes [2] |
static const uint8_t *const | cc_alpha_palettes [2] |
static const int | rowdata [] |
static const uint8_t | specialchar [] |
static const int | chartbl [128] |
Character translation table. | |
static const int | parity_table [256] |
Parity table for packets. | |
#define CAP_BG_COL 1 |
Referenced by ccrow_render().
#define CC_CHANNELS 2 |
#define CC_COLUMNS 32 |
Referenced by cc_renderer_update_cfg(), ccbuf_add_char(), ccbuf_tab(), and ccrow_render().
#define CC_ROWS 15 |
Referenced by cc_renderer_update_cfg(), ccbuf_has_displayable(), ccbuf_render(), and ccrow_render().
#define NTSC_FRAME_DURATION 3003 |
Referenced by cc_renderer_calc_vpts().
#define NUM_FG_COL 7 |
Referenced by cc_renderer_build_palette().
#define TRANSP_SPACE |
Referenced by ccrow_fill_transp(), ccrow_find_end_of_text_part(), and ccrow_find_next_text_part().
typedef struct cc_attribute_s cc_attribute_t |
typedef struct cc_buffer_s cc_buffer_t |
typedef struct cc_char_cell_s cc_char_cell_t |
typedef struct cc_memory_s cc_memory_t |
typedef struct colorinfo_s colorinfo_t |
|
static |
References cc_memory_s::channel, and cc_memory_s::channel_no.
Referenced by cc_decode_midrow_attr(), cc_decode_PAC(), cc_decode_special_char(), cc_decode_standard_char(), and cc_decode_tab().
|
static |
References cc_decode_ext_attribute(), cc_decode_midrow_attr(), cc_decode_misc_control_code(), cc_decode_PAC(), cc_decode_special_char(), cc_decode_standard_char(), and cc_decode_tab().
Referenced by decode_cc().
|
static |
References cc_set_channel().
Referenced by cc_decode_EIA608().
|
static |
References active_ccbuffer(), cc_attribute_s::background, BLACK, cc_set_channel(), ccbuf_apply_attribute(), cc_attribute_s::foreground, cc_attribute_s::italic, cc_attribute_s::underline, and WHITE.
Referenced by cc_decode_EIA608().
|
static |
References cc_hide_displayed(), cc_set_channel(), cc_swap_buffers(), and ccmem_clear().
Referenced by cc_decode_EIA608().
|
static |
References active_ccbuffer(), cc_set_channel(), ccbuf_set_cursor(), rowdata, and WHITE.
Referenced by cc_decode_EIA608().
|
static |
References active_ccbuffer(), cc_set_channel(), ccbuf_add_char(), and specialchar.
Referenced by cc_decode_EIA608().
|
static |
References active_ccbuffer(), ccbuf_add_char(), and chartbl.
Referenced by cc_decode_EIA608().
|
static |
References active_ccbuffer(), cc_set_channel(), and ccbuf_tab().
Referenced by cc_decode_EIA608().
void cc_decoder_close | ( | cc_decoder_t * | this | ) |
References ccmem_exit().
Referenced by spucc_do_close().
cc_decoder_t * cc_decoder_open | ( | cc_state_t * | cc_state | ) |
References ccmem_init(), and NULL.
Referenced by spucc_do_init().
|
static |
References cc_renderer_calc_vpts(), cc_renderer_hide_caption(), and cc_renderer_on_display().
Referenced by cc_decode_misc_control_code(), and cc_swap_buffers().
|
static |
References ccbuf_has_displayable().
Referenced by cc_show_displayed().
|
static |
References cc_renderer_free_osd_object(), height, and width.
Referenced by cc_renderer_update_cfg().
|
static |
References cc_alpha_palettes, cc_text_palettes, interpolate_color(), NUM_FG_COL, OSD_TEXT1, and TEXT_PALETTE_SIZE.
Referenced by cc_renderer_update_cfg().
|
static |
References metronom_s::got_spu_packet, and NTSC_FRAME_DURATION.
Referenced by cc_hide_displayed(), and cc_show_displayed().
void cc_renderer_close | ( | cc_renderer_t * | this_obj | ) |
References cc_renderer_free_osd_object().
Referenced by spucc_do_close().
|
static |
References cc_renderer_hide_caption(), and NULL.
Referenced by cc_renderer_adjust_osd_object(), cc_renderer_close(), and cc_renderer_update_cfg().
|
static |
Referenced by cc_hide_displayed(), cc_renderer_free_osd_object(), and cc_renderer_show_caption().
|
static |
Referenced by cc_hide_displayed().
cc_renderer_t * cc_renderer_open | ( | osd_renderer_t * | osd_renderer, |
metronom_t * | metronom, | ||
cc_state_t * | cc_state, | ||
int | video_width, | ||
int | video_height ) |
References cc_renderer_update_cfg(), and NULL.
Referenced by spucc_do_init().
|
static |
References cc_renderer_hide_caption(), ccbuf_render(), and MAX.
Referenced by cc_show_displayed().
void cc_renderer_update_cfg | ( | cc_renderer_t * | this_obj, |
int | video_width, | ||
int | video_height ) |
References cc_state_s::can_cc, cc_state_s::cc_cfg, CC_COLUMNS, cc_renderer_adjust_osd_object(), cc_renderer_build_palette(), cc_renderer_free_osd_object(), CC_ROWS, cc_renderer_s::cc_state, cc_config_s::font, cc_config_s::font_size, get_font_metrics(), cc_renderer_s::height, cc_config_s::italic_font, MAX, cc_renderer_s::max_char_height, cc_renderer_s::max_char_width, cc_renderer_s::osd_renderer, cc_renderer_s::video_height, cc_renderer_s::video_width, cc_renderer_s::width, cc_renderer_s::x, and cc_renderer_s::y.
Referenced by cc_renderer_open(), and spucc_update_intrinsics().
|
static |
|
static |
References cc_onscreen_displayable(), cc_renderer_calc_vpts(), and cc_renderer_show_caption().
Referenced by cc_swap_buffers().
|
static |
References cc_hide_displayed(), and cc_show_displayed().
Referenced by cc_decode_misc_control_code().
|
static |
References cc_row_s::attr_chg, cc_char_cell_s::attributes, cc_char_cell_s::c, CC_COLUMNS, ccrow_fill_transp(), cc_row_s::cells, cc_char_cell_s::midrow_attr, cc_row_s::num_chars, cc_row_s::pac_attr, cc_row_s::pac_attr_chg, and cc_row_s::pos.
Referenced by cc_decode_special_char(), cc_decode_standard_char(), and ccbuf_apply_attribute().
|
static |
References cc_row_s::attr_chg, cc_char_cell_s::attributes, ccbuf_add_char(), cc_row_s::cells, chartbl, and cc_row_s::pos.
Referenced by cc_decode_midrow_attr().
|
static |
References CC_ROWS.
Referenced by cc_onscreen_displayable().
|
static |
References CC_ROWS, and ccrow_render().
Referenced by cc_renderer_show_caption().
|
static |
References cc_row_s::attr_chg, cc_attribute_s::background, BLACK, cc_attribute_s::foreground, cc_attribute_s::italic, cc_row_s::pac_attr, cc_row_s::pac_attr_chg, cc_row_s::pos, and cc_attribute_s::underline.
Referenced by cc_decode_PAC().
|
static |
References CC_COLUMNS, and cc_row_s::pos.
Referenced by cc_decode_tab().
|
static |
Referenced by cc_decode_misc_control_code(), and ccmem_init().
|
static |
Referenced by cc_decoder_close().
|
static |
References ccmem_clear().
Referenced by cc_decoder_open().
|
static |
References cc_char_cell_s::c, cc_row_s::cells, cc_char_cell_s::midrow_attr, cc_row_s::num_chars, cc_row_s::pos, and TRANSP_SPACE.
Referenced by ccbuf_add_char().
|
static |
Referenced by ccrow_render().
|
static |
References TRANSP_SPACE.
Referenced by ccrow_render().
|
static |
Referenced by ccrow_render().
|
static |
References TRANSP_SPACE.
Referenced by ccrow_render().
|
static |
References CAP_BG_COL, cc_renderer_s::cap_display, cc_state_s::cc_cfg, CC_COLUMNS, CC_ROWS, cc_renderer_s::cc_state, ccrow_find_current_attr(), ccrow_find_end_of_text_part(), ccrow_find_next_attr_change(), ccrow_find_next_text_part(), ccrow_set_attributes(), cc_config_s::center, osd_renderer_s::filled_rect, osd_renderer_s::get_text_size, cc_renderer_s::height, cc_renderer_s::max_char_height, cc_renderer_s::max_char_width, cc_renderer_s::osd_renderer, osd_renderer_s::render_text, text_colormap, and cc_renderer_s::width.
Referenced by ccbuf_render().
|
static |
void decode_cc | ( | cc_decoder_t * | this, |
uint8_t * | buffer, | ||
uint32_t | buf_len, | ||
int64_t | pts ) |
References cc_decode_EIA608(), and good_parity().
Referenced by spudec_decode_data().
|
static |
References osd_renderer_s::free_object, osd_renderer_s::get_text_size, MAX, osd_renderer_s::new_object, osd_renderer_s::set_encoding, and osd_renderer_s::set_font.
Referenced by cc_renderer_update_cfg().
|
static |
References parity_table.
Referenced by decode_cc().
References clut_s::cb, CLUT_Y_CR_CB_INIT, clut_s::cr, clut_s::foo, and clut_s::y.
Referenced by cc_renderer_build_palette().
|
static |
Referenced by cc_renderer_build_palette().
|
static |
Referenced by cc_renderer_build_palette().
|
static |
|
static |
|
static |
|
static |
|
static |
Character translation table.
EIA 608 codes are not all the same as ASCII
The code to produce the characters table would be the following:
static void build_char_table(void) { int i; // first the normal ASCII codes for (i = 0; i < 128; i++) chartbl[i] = (char) i; // now the special codes chartbl[0x2a] = 225; // á chartbl[0x5c] = 233; // é chartbl[0x5e] = 237; // í chartbl[0x5f] = 243; // ó chartbl[0x60] = 250; // ú chartbl[0x7b] = 231; // ç chartbl[0x7c] = 247; // ÷ chartbl[0x7d] = 209; // Ñ chartbl[0x7e] = 241; // ñ chartbl[0x7f] = 164; // ¤ FIXME: should be a solid block ('█'; U+2588) }
Referenced by cc_decode_standard_char(), and ccbuf_apply_attribute().
|
static |
Parity table for packets.
CC codes use odd parity for error detection, since they originally were transmitted via noisy video signals.
The code to produce the parity table would be the following:
static int parity(uint8_t byte) { int i; int ones = 0;
for (i = 0; i < 7; i++) { if (byte & (1 << i)) ones++; }
return ones & 1; }
static void build_parity_table(void) { uint8_t byte; int parity_v; for (byte = 0; byte <= 127; byte++) { parity_v = parity(byte); // CC uses odd parity (i.e., # of 1's in byte is odd.) parity_table[byte] = parity_v; parity_table[byte | 0x80] = !parity_v; } }
Referenced by good_parity().
|
static |
Referenced by cc_decode_PAC().
|
static |
Referenced by cc_decode_special_char().
|
static |
Referenced by ccrow_render().