New upstream version 18.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2017-04-19 21:54:15 +02:00
parent 6efda2859e
commit f2cf6cce50
1337 changed files with 41178 additions and 84670 deletions

198
deps/libcaption/caption/avc.h vendored Normal file
View file

@ -0,0 +1,198 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_AVC_H
#define LIBCAPTION_AVC_H
#include "cea708.h"
#include "caption.h"
#include <float.h>
////////////////////////////////////////////////////////////////////////////////
#define MAX_NALU_SIZE (4*1024*1024)
typedef struct {
size_t size;
uint8_t data[MAX_NALU_SIZE];
} avcnalu_t;
void avcnalu_init (avcnalu_t* nalu);
int avcnalu_parse_annexb (avcnalu_t* nalu, const uint8_t** data, size_t* size);
static inline uint8_t avcnalu_type (avcnalu_t* nalu) { return nalu->data[0] & 0x1F; }
static inline uint8_t* avcnalu_data (avcnalu_t* nalu) { return &nalu->data[0]; }
static inline size_t avcnalu_size (avcnalu_t* nalu) { return nalu->size; }
////////////////////////////////////////////////////////////////////////////////
typedef struct _sei_message_t sei_message_t;
typedef enum {
sei_type_buffering_period = 0,
sei_type_pic_timing = 1,
sei_type_pan_scan_rect = 2,
sei_type_filler_payload = 3,
sei_type_user_data_registered_itu_t_t35 = 4,
sei_type_user_data_unregistered = 5,
sei_type_recovery_point = 6,
sei_type_dec_ref_pic_marking_repetition = 7,
sei_type_spare_pic = 8,
sei_type_scene_info = 9,
sei_type_sub_seq_info = 10,
sei_type_sub_seq_layer_characteristics = 11,
sei_type_sub_seq_characteristics = 12,
sei_type_full_frame_freeze = 13,
sei_type_full_frame_freeze_release = 14,
sei_type_full_frame_snapshot = 15,
sei_type_progressive_refinement_segment_start = 16,
sei_type_progressive_refinement_segment_end = 17,
sei_type_motion_constrained_slice_group_set = 18,
sei_type_film_grain_characteristics = 19,
sei_type_deblocking_filter_display_preference = 20,
sei_type_stereo_video_info = 21,
} sei_msgtype_t;
////////////////////////////////////////////////////////////////////////////////
// time in seconds
typedef struct {
double dts;
double cts;
sei_message_t* head;
sei_message_t* tail;
} sei_t;
/*! \brief
\param
*/
void sei_init (sei_t* sei);
/*! \brief
\param
*/
void sei_free (sei_t* sei);
/*! \brief
\param
*/
static inline double sei_dts (sei_t* sei) { return sei->dts; }
static inline double sei_cts (sei_t* sei) { return sei->cts; }
static inline double sei_pts (sei_t* sei) { return sei->dts + sei->cts; }
/*! \brief
\param
*/
int sei_parse_nalu (sei_t* sei, const uint8_t* data, size_t size, double dts, double cts);
/*! \brief
\param
*/
// TODO add dts,cts to nalu
static inline int sei_parse_avcnalu (sei_t* sei, avcnalu_t* nalu, double dts, double cts) { return sei_parse_nalu (sei,avcnalu_data (nalu),avcnalu_size (nalu),dts,cts); }
/*! \brief
\param
*/
static inline int sei_finish (sei_t* sei) { return sei_parse_nalu (sei,0,0,0.0,DBL_MAX); }
/*! \brief
\param
*/
static inline sei_message_t* sei_message_head (sei_t* sei) { return sei->head; }
/*! \brief
\param
*/
static inline sei_message_t* sei_message_tail (sei_t* sei) { return sei->tail; }
/*! \brief
\param
*/
sei_message_t* sei_message_next (sei_message_t* msg);
/*! \brief
\param
*/
sei_msgtype_t sei_message_type (sei_message_t* msg);
/*! \brief
\param
*/
size_t sei_message_size (sei_message_t* msg);
/*! \brief
\param
*/
uint8_t* sei_message_data (sei_message_t* msg);
/*! \brief
\param
*/
sei_message_t* sei_message_new (sei_msgtype_t type, uint8_t* data, size_t size);
/*! \brief
\param
*/
static inline sei_message_t* sei_message_copy (sei_message_t* msg)
{
return sei_message_new (sei_message_type (msg), sei_message_data (msg), sei_message_size (msg));
}
/**
Free message and all accoiated data. Messaged added to sei_t by using sei_append_message MUST NOT be freed
These messages will be freed by calling sei_free()
*/
/*! \brief
\param
*/
void sei_message_free (sei_message_t* msg);
////////////////////////////////////////////////////////////////////////////////
/*! \brief
\param
*/
static inline int sei_decode_cea708 (sei_message_t* msg, cea708_t* cea708)
{
if (sei_type_user_data_registered_itu_t_t35 == sei_message_type (msg)) {
return cea708_parse (sei_message_data (msg), sei_message_size (msg), cea708);
} else {
return 0;
}
}
////////////////////////////////////////////////////////////////////////////////
/*! \brief
\param
*/
size_t sei_render_size (sei_t* sei);
/*! \brief
\param
*/
size_t sei_render (sei_t* sei, uint8_t* data);
/*! \brief
\param
*/
void sei_dump (sei_t* sei);
/*! \brief
\param
*/
void sei_dump_messages (sei_message_t* head);
////////////////////////////////////////////////////////////////////////////////
/*! \brief
\param
*/
int sei_from_caption_frame (sei_t* sei, caption_frame_t* frame);
/*! \brief
\param
*/
libcaption_stauts_t sei_to_caption_frame (sei_t* sei, caption_frame_t* frame);
/*! \brief
\param
*/
static inline int nalu_to_caption_frame (caption_frame_t* frame, const uint8_t* data, size_t size, double pts, double dts)
{
sei_t sei;
sei_init (&sei);
sei_parse_nalu (&sei, data, size, pts, dts);
sei_to_caption_frame (&sei,frame);
sei_free (&sei);
return 1;
}
////////////////////////////////////////////////////////////////////////////////
#endif

141
deps/libcaption/caption/caption.h vendored Normal file
View file

@ -0,0 +1,141 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_H
#define LIBCAPTION_H
#include "utf8.h"
#include "xds.h"
#include "eia608.h"
// ssize_t is POSIX and does not exist on Windows
#if defined(_MSC_VER)
#if defined(_WIN64)
typedef signed long ssize_t;
#else
typedef signed int ssize_t;
#endif
#endif
typedef enum {
LIBCAPTION_OK = 1,
LIBCAPTION_ERROR = 0,
LIBCAPTION_READY = 2
} libcaption_stauts_t;
/*! \brief
\param
*/
static inline libcaption_stauts_t libcaption_status_update (libcaption_stauts_t old_stat, libcaption_stauts_t new_stat) { return (LIBCAPTION_ERROR == old_stat || LIBCAPTION_ERROR == new_stat) ? LIBCAPTION_ERROR : (LIBCAPTION_READY == old_stat) ? LIBCAPTION_READY : new_stat; }
#define SCREEN_ROWS 15
#define SCREEN_COLS 32
typedef struct {
unsigned int uln : 1; //< underline
unsigned int sty : 3; //< style
utf8_char_t data[5]; //< 4 byte utf8 values plus null term
} caption_frame_cell_t;
typedef struct {
caption_frame_cell_t cell[SCREEN_ROWS][SCREEN_COLS];
} caption_frame_buffer_t;
typedef struct {
unsigned int uln : 1; //< underline
unsigned int sty : 3; //< style
unsigned int mod : 3; //< current mode
unsigned int rup : 2; //< roll-up line count minus 1
uint16_t row, col, cc_data;
} caption_frame_state_t;
// timestamp and duration are in seconds
typedef struct {
double timestamp;
double duration;
xds_t xds;
caption_frame_state_t state;
caption_frame_buffer_t front;
caption_frame_buffer_t back;
} caption_frame_t;
// typedef enum {
// eia608_paint_on = 0,
// eia608_pop_on = 1,
// eia608_rollup_2 = 2,
// eia608_rollup_3 = 3,
// eia608_rollup_4 = 4,
// } eia608_display_mode_t;
// eia608_display_mode_t caption_frame_mode (caption_frame_t* frame);
/*!
\brief Initializes an allocated caption_frame_t instance
\param frame Pointer to prealocated caption_frame_t object
*/
void caption_frame_init (caption_frame_t* frame);
/*! \brief Writes a single charcter to a caption_frame_t object
\param frame A pointer to an allocted and initialized caption_frame_t object
\param row Row position to write charcter, must be between 0 and SCREEN_ROWS-1
\param col Column position to write charcter, must be between 0 and SCREEN_ROWS-1
\param style Style to apply to charcter
\param underline Set underline attribute, 0 = off any other value = on
\param c pointer to a single valid utf8 charcter. Bytes are automatically determined, and a NULL terminator is not required
*/
int caption_frame_write_char (caption_frame_t* frame, int row, int col, eia608_style_t style, int underline, const utf8_char_t* c);
/*! \brief
\param
*/
const utf8_char_t* caption_frame_read_char (caption_frame_t* frame, int row, int col, eia608_style_t* style, int* underline);
/*! \brief
\param
*/
/*! \brief
\param
*/
libcaption_stauts_t caption_frame_decode (caption_frame_t* frame, uint16_t cc_data, double timestamp);
/*! \brief
\param
*/
int caption_frame_from_text (caption_frame_t* frame, const utf8_char_t* data);
/*! \brief
\param
*/
#define CAPTION_FRAME_TEXT_BYTES (((2+SCREEN_ROWS)*SCREEN_COLS*4)+1)
void caption_frame_to_text (caption_frame_t* frame, utf8_char_t* data);
/*! \brief
\param
*/
#define CAPTION_FRAME_DUMP_BUF_SIZE 4096
size_t caption_frame_dump_buffer (caption_frame_t* frame, utf8_char_t* buf);
void caption_frame_dump (caption_frame_t* frame);
/*! \brief
\param
*/
#define CAPTION_FRAME_JSON_BUF_SIZE 32768
size_t caption_frame_json (caption_frame_t* frame, utf8_char_t* buf);
#endif

110
deps/libcaption/caption/cea708.h vendored Normal file
View file

@ -0,0 +1,110 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_CEA708_H
#define LIBCAPTION_CEA708_H
#include "caption.h"
#define CEA608_MAX_SIZE (255)
////////////////////////////////////////////////////////////////////////////////
typedef enum {
cc_type_ntsc_cc_field_1 = 0,
cc_type_ntsc_cc_field_2 = 1,
cc_type_dtvcc_packet_data = 2,
cc_type_dtvcc_packet_start = 3,
} cea708_cc_type_t;
typedef struct {
unsigned int marker_bits : 5;
unsigned int cc_valid : 1;
unsigned int cc_type : 2; // castable to cea708_cc_type_t
unsigned int cc_data : 16;
} cc_data_t;
typedef struct {
unsigned int process_em_data_flag : 1;
unsigned int process_cc_data_flag : 1;
unsigned int additional_data_flag : 1;
unsigned int cc_count : 5;
unsigned int em_data : 8;
cc_data_t cc_data[32];
} user_data_t;
/*! \brief
\param
*/
cc_data_t cea708_encode_cc_data (int cc_valid, cea708_cc_type_t type, uint16_t cc_data);
/*! \brief
\param
*/
int cea708_cc_count (user_data_t* data);
/*! \brief
\param
*/
uint16_t cea708_cc_data (user_data_t* data, int index, int* valid, cea708_cc_type_t* type);
////////////////////////////////////////////////////////////////////////////////
typedef enum {
country_united_states = 181,
} itu_t_t35_country_code_t;
typedef enum {
t35_provider_direct_tv = 47,
t35_provider_atsc = 49,
} itu_t_t35_provider_code_t;
typedef struct {
itu_t_t35_country_code_t country;
itu_t_t35_provider_code_t provider;
uint32_t user_identifier;
uint8_t atsc1_data_user_data_type_code;
uint8_t directv_user_data_length;
user_data_t user_data;
} cea708_t;
/*! \brief
\param
*/
int cea708_init (cea708_t* cea708); // will confgure using HLS compatiable defaults
/*! \brief
\param
*/
int cea708_parse (uint8_t* data, size_t size, cea708_t* cea708);
/*! \brief
\param
*/
libcaption_stauts_t cea708_to_caption_frame (caption_frame_t* frame, cea708_t* cea708, double pts);
/*! \brief
\param
*/
int cea708_add_cc_data (cea708_t* cea708, int valid, cea708_cc_type_t type, uint16_t cc_data);
/*! \brief
\param
*/
int cea708_render (cea708_t* cea708, uint8_t* data, size_t size);
/*! \brief
\param
*/
void cea708_dump (cea708_t* cea708);
#endif

206
deps/libcaption/caption/eia608.h vendored Normal file
View file

@ -0,0 +1,206 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_EIA608_H
#define LIBCAPTION_EIA608_H
#include "utf8.h"
#include "eia608_charmap.h"
////////////////////////////////////////////////////////////////////////////////
// Parity
#define EIA608_BX(B,X) (((B)>>X)&0x01)
#define EIA608_BP(B) ((B)&0x7F) | ((EIA608_BX((B),0)^EIA608_BX(B,1)^EIA608_BX((B),2)^EIA608_BX((B),3)^EIA608_BX((B),4)^EIA608_BX((B),5)^EIA608_BX((B),6)^(0x01))<<7)
#define EIA608_B2(B) EIA608_BP((B)+0), EIA608_BP((B)+1), EIA608_BP((B)+2), EIA608_BP((B)+3), EIA608_BP((B)+4), EIA608_BP((B)+5), EIA608_BP((B)+6), EIA608_BP((B)+7)
#define EIA608_B1(B) EIA608_B2((B)+0), EIA608_B2((B)+8), EIA608_B2((B)+16), EIA608_B2((B)+24), EIA608_B2((B)+32), EIA608_B2((B)+40), EIA608_B2((B)+48), EIA608_B2((B)+56)
static const uint8_t eia608_parity_table[] = { EIA608_B1 (0), EIA608_B1 (64) };
extern const char* eia608_mode_map[];
extern const char* eia608_style_map[];
#ifdef _MSC_VER
#ifndef inline
#define inline __inline
#endif
#endif
/*! \brief
\param
*/
static inline uint8_t eia608_parity_byte (uint8_t cc_data) { return eia608_parity_table[0x7F & cc_data]; }
/*! \brief
\param
*/
static inline uint16_t eia608_parity_word (uint16_t cc_data) { return (uint16_t) ( (eia608_parity_byte ( (uint8_t) (cc_data>>8)) <<8) | eia608_parity_byte ( (uint8_t) cc_data)); }
/*! \brief
\param
*/
static inline uint16_t eia608_parity (uint16_t cc_data) { return eia608_parity_word (cc_data); }
/*! \brief
\param
*/
static inline int eia608_parity_varify (uint16_t cc_data) { return eia608_parity_word (cc_data) == cc_data ? 1 : 0; }
/*! \brief
\param
*/
static inline int eia608_parity_strip (uint16_t cc_data) { return cc_data & 0x7F7F; }
/*! \brief
\param
*/
static inline int eia608_test_second_channel_bit (uint16_t cc_data) { return (cc_data & 0x0800); }
////////////////////////////////////////////////////////////////////////////////
// cc_data types
/*! \brief
\param
*/
static inline int eia608_is_basicna (uint16_t cc_data) { return 0x0000 != (0x6000 & cc_data); /*&& 0x1F00 < (0x7F00 & cc_data);*/ }
/*! \brief
\param
*/
static inline int eia608_is_preamble (uint16_t cc_data) { return 0x1040 == (0x7040 & cc_data); }
/*! \brief
\param
*/
static inline int eia608_is_midrowchange (uint16_t cc_data) { return 0x1120 == (0x7770 & cc_data); }
/*! \brief
\param
*/
static inline int eia608_is_specialna (uint16_t cc_data) { return 0x1130 == (0x7770 & cc_data); }
/*! \brief
\param
*/
static inline int eia608_is_xds (uint16_t cc_data) { return 0x0000 == (0x7070 & cc_data) && 0x0000 != (0x0F0F & cc_data); }
/*! \brief
\param
*/
static inline int eia608_is_westeu (uint16_t cc_data) { return 0x1220 == (0x7660 & cc_data); }
/*! \brief
\param
*/
static inline int eia608_is_control (uint16_t cc_data) { return 0x1420 == (0x7670 & cc_data) || 0x1720 == (0x7770 & cc_data); }
/*! \brief
\param
*/
static inline int eia608_is_norpak (uint16_t cc_data) { return 0x1724 == (0x777C & cc_data) || 0x1728 == (0x777C & cc_data); }
/*! \brief
\param
*/
static inline int eia608_is_padding (uint16_t cc_data) { return 0x8080 == cc_data; }
////////////////////////////////////////////////////////////////////////////////
// preamble
typedef enum {
eia608_style_white = 0,
eia608_style_green = 1,
eia608_style_blue = 2,
eia608_style_cyan = 3,
eia608_style_red = 4,
eia608_style_yellow = 5,
eia608_style_magenta = 6,
eia608_style_italics = 7,
} eia608_style_t;
/*! \brief
\param
*/
int eia608_parse_preamble (uint16_t cc_data, int* row, int* col, eia608_style_t* style, int* chan, int* underline);
/*! \brief
\param
*/
int eia608_parse_midrowchange (uint16_t cc_data, int* chan, eia608_style_t* style, int* underline);
/*! \brief
\param
*/
uint16_t eia608_row_column_pramble (int row, int col, int chan, int underline);
/*! \brief
\param
*/
uint16_t eia608_row_style_pramble (int row, eia608_style_t style, int chan, int underline);
////////////////////////////////////////////////////////////////////////////////
// control command
typedef enum { // yes, no?
eia608_tab_offset_0 = 0x1720,
eia608_tab_offset_1 = 0x1721,
eia608_tab_offset_2 = 0x1722,
eia608_tab_offset_3 = 0x1723,
eia608_control_resume_caption_loading = 0x1420,
eia608_control_backspace = 0x1421,
eia608_control_alarm_off = 0x1422,
eia608_control_alarm_on = 0x1423,
eia608_control_delete_to_end_of_row = 0x1424,
eia608_control_roll_up_2 = 0x1425,
eia608_control_roll_up_3 = 0x1426,
eia608_control_roll_up_4 = 0x1427,
eia608_control_resume_direct_captioning = 0x1429,
eia608_control_text_restart = 0x142A,
eia608_control_text_resume_text_display = 0x142B,
eia608_control_erase_display_memory = 0x142C,
eia608_control_carriage_return = 0x142D,
eia608_control_erase_non_displayed_memory = 0x142E,
eia608_control_end_of_caption = 0x142F,
} eia608_control_t;
#define eia608_control_popon eia608_control_resume_caption_loading
#define eia608_control_painton eia608_control_resume_direct_captioning
/*! \brief
\param
*/
uint16_t eia608_control_command (eia608_control_t cmd, int cc);
/*! \brief
\param
*/
static inline uint16_t eia608_tab (int size, int cc) { return eia608_control_command ( (eia608_control_t) (eia608_tab_offset_0 | (size&0x0F)),cc); }
/*! \brief
\param
*/
eia608_control_t eia608_parse_control (uint16_t cc_data, int* cc);
////////////////////////////////////////////////////////////////////////////////
// text
/*! \brief
\param c
*/
uint16_t eia608_from_utf8_1 (const utf8_char_t* c, int chan);
/*! \brief
\param
*/
uint16_t eia608_from_utf8_2 (const utf8_char_t* c1, const utf8_char_t* c2);
/*! \brief
\param
*/
uint16_t eia608_from_basicna (uint16_t bna1, uint16_t bna2);
/*! \brief
\param
*/
int eia608_to_utf8 (uint16_t c, int* chan, utf8_char_t* char1, utf8_char_t* char2);
////////////////////////////////////////////////////////////////////////////////
/*! \brief
\param
*/
void eia608_dump (uint16_t cc_data);
////////////////////////////////////////////////////////////////////////////////
#endif

230
deps/libcaption/caption/eia608_charmap.h vendored Normal file
View file

@ -0,0 +1,230 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_EIA608_CHARMAP_H
#define LIBCAPTION_EIA608_CHARMAP_H
#define EIA608_CHAR_COUNT 176
extern const char* eia608_char_map[EIA608_CHAR_COUNT];
// Helper char
#define EIA608_CHAR_NULL ""
// Basic North American character set
#define EIA608_CHAR_SPACE "\x20"
#define EIA608_CHAR_EXCLAMATION_MARK "\x21"
#define EIA608_CHAR_QUOTATION_MARK "\x22"
#define EIA608_CHAR_NUMBER_SIGN "\x23"
#define EIA608_CHAR_DOLLAR_SIGN "\x24"
#define EIA608_CHAR_PERCENT_SIGN "\x25"
#define EIA608_CHAR_AMPERSAND "\x26"
#define EIA608_CHAR_LEFT_SINGLE_QUOTATION_MARK "\xE2\x80\x98"
#define EIA608_CHAR_LEFT_PARENTHESIS "\x28"
#define EIA608_CHAR_RIGHT_PARENTHESIS "\x29"
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_ACUTE "\xC3\xA1"
#define EIA608_CHAR_PLUS_SIGN "\x2B"
#define EIA608_CHAR_COMMA "\x2C"
#define EIA608_CHAR_HYPHEN_MINUS "\x2D"
#define EIA608_CHAR_FULL_STOP "\x2E"
#define EIA608_CHAR_SOLIDUS "\x2F"
// Basic North American character set
#define EIA608_CHAR_DIGIT_ZERO "\x30"
#define EIA608_CHAR_DIGIT_ONE "\x31"
#define EIA608_CHAR_DIGIT_TWO "\x32"
#define EIA608_CHAR_DIGIT_THREE "\x33"
#define EIA608_CHAR_DIGIT_FOUR "\x34"
#define EIA608_CHAR_DIGIT_FIVE "\x35"
#define EIA608_CHAR_DIGIT_SIX "\x36"
#define EIA608_CHAR_DIGIT_SEVEN "\x37"
#define EIA608_CHAR_DIGIT_EIGHT "\x38"
#define EIA608_CHAR_DIGIT_NINE "\x39"
#define EIA608_CHAR_COLON "\x3A"
#define EIA608_CHAR_SEMICOLON "\x3B"
#define EIA608_CHAR_LESS_THAN_SIGN "\x3C"
#define EIA608_CHAR_EQUALS_SIGN "\x3D"
#define EIA608_CHAR_GREATER_THAN_SIGN "\x3E"
#define EIA608_CHAR_QUESTION_MARK "\x3F"
// Basic North American character set
#define EIA608_CHAR_COMMERCIAL_AT "\x40"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A "\x41"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_B "\x42"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_C "\x43"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_D "\x44"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E "\x45"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_F "\x46"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_G "\x47"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_H "\x48"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I "\x49"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_J "\x4A"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_K "\x4B"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_L "\x4C"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_M "\x4D"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_N "\x4E"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O "\x4F"
// Basic North American character set
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_P "\x50"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_Q "\x51"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_R "\x52"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_S "\x53"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_T "\x54"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U "\x55"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_V "\x56"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_W "\x57"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_X "\x58"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_Y "\x59"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_Z "\x5A"
#define EIA608_CHAR_LEFT_SQUARE_BRACKET "\x5B"
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_ACUTE "\xC3\xA9"
#define EIA608_CHAR_RIGHT_SQUARE_BRACKET "\x5D"
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_ACUTE "\xC3\xAD"
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_ACUTE "\xC3\xB3"
// Basic North American character set
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_ACUTE "\xC3\xBA"
#define EIA608_CHAR_LATIN_SMALL_LETTER_A "\x61"
#define EIA608_CHAR_LATIN_SMALL_LETTER_B "\x62"
#define EIA608_CHAR_LATIN_SMALL_LETTER_C "\x63"
#define EIA608_CHAR_LATIN_SMALL_LETTER_D "\x64"
#define EIA608_CHAR_LATIN_SMALL_LETTER_E "\x65"
#define EIA608_CHAR_LATIN_SMALL_LETTER_F "\x66"
#define EIA608_CHAR_LATIN_SMALL_LETTER_G "\x67"
#define EIA608_CHAR_LATIN_SMALL_LETTER_H "\x68"
#define EIA608_CHAR_LATIN_SMALL_LETTER_I "\x69"
#define EIA608_CHAR_LATIN_SMALL_LETTER_J "\x6A"
#define EIA608_CHAR_LATIN_SMALL_LETTER_K "\x6B"
#define EIA608_CHAR_LATIN_SMALL_LETTER_L "\x6C"
#define EIA608_CHAR_LATIN_SMALL_LETTER_M "\x6D"
#define EIA608_CHAR_LATIN_SMALL_LETTER_N "\x6E"
#define EIA608_CHAR_LATIN_SMALL_LETTER_O "\x6F"
// Basic North American character set
#define EIA608_CHAR_LATIN_SMALL_LETTER_P "\x70"
#define EIA608_CHAR_LATIN_SMALL_LETTER_Q "\x71"
#define EIA608_CHAR_LATIN_SMALL_LETTER_R "\x72"
#define EIA608_CHAR_LATIN_SMALL_LETTER_S "\x73"
#define EIA608_CHAR_LATIN_SMALL_LETTER_T "\x74"
#define EIA608_CHAR_LATIN_SMALL_LETTER_U "\x75"
#define EIA608_CHAR_LATIN_SMALL_LETTER_V "\x76"
#define EIA608_CHAR_LATIN_SMALL_LETTER_W "\x77"
#define EIA608_CHAR_LATIN_SMALL_LETTER_X "\x78"
#define EIA608_CHAR_LATIN_SMALL_LETTER_Y "\x79"
#define EIA608_CHAR_LATIN_SMALL_LETTER_Z "\x7A"
#define EIA608_CHAR_LATIN_SMALL_LETTER_C_WITH_CEDILLA "\xC3\xA7"
#define EIA608_CHAR_DIVISION_SIGN "\xC3\xB7"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_N_WITH_TILDE "\xC3\x91"
#define EIA608_CHAR_LATIN_SMALL_LETTER_N_WITH_TILDE "\xC3\xB1"
#define EIA608_CHAR_FULL_BLOCK "\xE2\x96\x88"
// Special North American character set[edit]
#define EIA608_CHAR_REGISTERED_SIGN "\xC2\xAE"
#define EIA608_CHAR_DEGREE_SIGN "\xC2\xB0"
#define EIA608_CHAR_VULGAR_FRACTION_ONE_HALF "\xC2\xBD"
#define EIA608_CHAR_INVERTED_QUESTION_MARK "\xC2\xBF"
#define EIA608_CHAR_TRADE_MARK_SIGN "\xE2\x84\xA2"
#define EIA608_CHAR_CENT_SIGN "\xC2\xA2"
#define EIA608_CHAR_POUND_SIGN "\xC2\xA3"
#define EIA608_CHAR_EIGHTH_NOTE "\xE2\x99\xAA"
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_GRAVE "\xC3\xA0"
#define EIA608_CHAR_NO_BREAK_SPACE "\xC2\xA0"
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_GRAVE "\xC3\xA8"
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX "\xC3\xA2"
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX "\xC3\xAA"
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX "\xC3\xAE"
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX "\xC3\xB4"
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX "\xC3\xBB"
// Extended Western European character set : Extended Spanish/Miscellaneous
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_ACUTE "\xC3\x81"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_ACUTE "\xC3\x89"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_ACUTE "\xC3\x93"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_ACUTE "\xC3\x9A"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS "\xC3\x9C"
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_DIAERESIS "\xC3\xBC"
#define EIA608_CHAR_RIGHT_SINGLE_QUOTATION_MARK "\xE2\x80\x99"
#define EIA608_CHAR_INVERTED_EXCLAMATION_MARK "\xC2\xA1"
#define EIA608_CHAR_ASTERISK "\x2A"
#define EIA608_CHAR_APOSTROPHE "\x27"
#define EIA608_CHAR_EM_DASH "\xE2\x80\x94"
#define EIA608_CHAR_COPYRIGHT_SIGN "\xC2\xA9"
#define EIA608_CHAR_SERVICE_MARK "\xE2\x84\xA0"
#define EIA608_CHAR_BULLET "\xE2\x80\xA2"
#define EIA608_CHAR_LEFT_DOUBLE_QUOTATION_MARK "\xE2\x80\x9C"
#define EIA608_CHAR_RIGHT_DOUBLE_QUOTATION_MARK "\xE2\x80\x9D"
// Extended Western European character set : Extended French
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_GRAVE "\xC3\x80"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX "\xC3\x82"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_C_WITH_CEDILLA "\xC3\x87"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_GRAVE "\xC3\x88"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX "\xC3\x8A"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS "\xC3\x8B"
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_DIAERESIS "\xC3\xAB"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX "\xC3\x8E"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS "\xC3\x8F"
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_DIAERESIS "\xC3\xAF"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX "\xC3\x94"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_GRAVE "\xC3\x99"
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_GRAVE "\xC3\xB9"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX "\xC3\x9B"
#define EIA608_CHAR_LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK "\xC2\xAB"
#define EIA608_CHAR_RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK "\xC2\xBB"
// Extended Western European character set : Portuguese
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_TILDE "\xC3\x83"
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_TILDE "\xC3\xA3"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_ACUTE "\xC3\x8D"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_GRAVE "\xC3\x8C"
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_GRAVE "\xC3\xAC"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_GRAVE "\xC3\x92"
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_GRAVE "\xC3\xB2"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_TILDE "\xC3\x95"
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_TILDE "\xC3\xB5"
#define EIA608_CHAR_LEFT_CURLY_BRACKET "\x7B"
#define EIA608_CHAR_RIGHT_CURLY_BRACKET "\x7D"
#define EIA608_CHAR_REVERSE_SOLIDUS "\x5C"
#define EIA608_CHAR_CIRCUMFLEX_ACCENT "\x5E"
#define EIA608_CHAR_LOW_LINE "\x5F"
#define EIA608_CHAR_VERTICAL_LINE "\x7C"
#define EIA608_CHAR_TILDE "\x7E"
// Extended Western European character set : German/Danish
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS "\xC3\x84"
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_DIAERESIS "\xC3\xA4"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS "\xC3\x96"
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_DIAERESIS "\xC3\xB6"
#define EIA608_CHAR_LATIN_SMALL_LETTER_SHARP_S "\xC3\x9F"
#define EIA608_CHAR_YEN_SIGN "\xC2\xA5"
#define EIA608_CHAR_CURRENCY_SIGN "\xC2\xA4"
#define EIA608_CHAR_BROKEN_BAR "\xC2\xA6"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE "\xC3\x85"
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_RING_ABOVE "\xC3\xA5"
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_STROKE "\xC3\x98"
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_STROKE "\xC3\xB8"
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT "\xE2\x94\x8C" // top left
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT "\xE2\x94\x90" // top right
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT "\xE2\x94\x94" // lower left
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT "\xE2\x94\x98" // bottom right
#endif

31
deps/libcaption/caption/scc.h vendored Normal file
View file

@ -0,0 +1,31 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_SCC_H
#define LIBCAPTION_SCC_H
#include "eia608.h"
int scc_to_608 (const char* line, double* pts, uint16_t* cc, int cc_max);
#endif

87
deps/libcaption/caption/srt.h vendored Normal file
View file

@ -0,0 +1,87 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_SRT_H
#define LIBCAPTION_SRT_H
#include "eia608.h"
#include "caption.h"
// timestamp and duration are in seconds
typedef struct _srt_t {
struct _srt_t* next;
double timestamp;
double duration;
size_t aloc;
} srt_t;
/*! \brief
\param
*/
srt_t* srt_new (const utf8_char_t* data, size_t size, double timestamp, srt_t* prev, srt_t** head);
/*! \brief
\param
*/
srt_t* srt_free_head (srt_t* head);
// returns the head of the link list. must bee freed when done
/*! \brief
\param
*/
srt_t* srt_parse (const utf8_char_t* data, size_t size);
/*! \brief
\param
*/
void srt_free (srt_t* srt);
/*! \brief
\param
*/
static inline srt_t* srt_next (srt_t* srt) { return srt->next; }
/*! \brief
\param
*/
static inline utf8_char_t* srt_data (srt_t* srt) { return (utf8_char_t*) (srt) + sizeof (srt_t); }
// This only converts teh surrent SRT, It does not walk the list
/*! \brief
\param
*/
int srt_to_caption_frame (srt_t* srt, caption_frame_t* frame);
// returns teh new srt. Head is not tracher internally.
/*! \brief
\param
*/
srt_t* srt_from_caption_frame (caption_frame_t* frame, srt_t* prev, srt_t** head);
/*! \brief
\param
*/
void srt_dump (srt_t* srt);
/*! \brief
\param
*/
void vtt_dump (srt_t* srt);
#endif

97
deps/libcaption/caption/utf8.h vendored Normal file
View file

@ -0,0 +1,97 @@
/**********************************************************************************************/
/* The MIT License */
/* */
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a copy */
/* of this software and associated documentation files (the "Software"), to deal */
/* in the Software without restriction, including without limitation the rights */
/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
/* copies of the Software, and to permit persons to whom the Software is */
/* furnished to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included in */
/* all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN */
/* THE SOFTWARE. */
/**********************************************************************************************/
#ifndef LIBCAPTION_UTF8_H
#define LIBCAPTION_UTF8_H
#include <stddef.h>
#include <inttypes.h>
// These types exist to make the code more self dcoumenting
// utf8_char_t point is a null teminate string of utf8 encodecd chars
//
// utf8_size_t is the length of a string in chars
// size_t is bytes
typedef char utf8_char_t;
typedef size_t utf8_size_t;
/*! \brief
\param
Skiped continuation bytes
*/
const utf8_char_t* utf8_char_next (const char* s);
/*! \brief
\param
returnes the length of the char in bytes
*/
size_t utf8_char_length (const utf8_char_t* c);
/*! \brief
\param
returns length of the string in bytes
size is number of charcter to count (0 to count until NULL term)
*/
size_t utf8_string_length (const utf8_char_t* data, utf8_size_t size);
/*! \brief
\param
*/
size_t utf8_char_copy (utf8_char_t* dst, const utf8_char_t* src);
/*! \brief
\param
returnes the number of utf8 charcters in a string givne the numbe of bytes
to coutn until the a null terminator, pass 0 for size
*/
utf8_size_t utf8_char_count (const char* data, size_t size);
/*! \brief
\param
returnes the length of the line in bytes triming not printable charcters at the end
*/
size_t utf8_trimmed_length (const char* data, size_t size);
/*! \brief
\param
returns the length in bytes of the line including the new line charcter(s)
auto detects between windows(CRLF), unix(LF), mac(CR) and riscos (LFCR) line endings
*/
size_t utf8_line_length (const char* data);
/*! \brief
\param
returns number of chars to include before split
*/
utf8_size_t utf8_wrap_length (const utf8_char_t* data, utf8_size_t size);
/*! \brief
\param
returns number of new lins in teh string
*/
int utf8_line_count (const utf8_char_t* data);
#endif

32
deps/libcaption/caption/xds.h vendored Normal file
View file

@ -0,0 +1,32 @@
/**********************************************************************************************/
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file */
/* except in compliance with the License. A copy of the License is located at */
/* */
/* http://aws.amazon.com/apache2.0/ */
/* */
/* or in the "license" file accompanying this file. This file is distributed on an "AS IS" */
/* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the */
/* License for the specific language governing permissions and limitations under the License. */
/**********************************************************************************************/
#ifndef LIBCAPTION_XDS_H
#define LIBCAPTION_XDS_H
#include <stddef.h>
#include <inttypes.h>
typedef struct {
int state;
uint8_t class;
uint8_t type;
uint32_t size;
uint8_t content[32];
uint8_t checksum;
} xds_t;
void xds_init (xds_t* xds);
int xds_decode (xds_t* xds, uint16_t cc);
#endif