35static const uint8_t
tc_offsets[9] = { 0, 1, 3, 4, 6, 7, 9, 10, 11 };
36static const uint8_t
tc_muls[9] = { 10, 6, 10, 6, 10, 10, 10, 10, 1 };
41 if (buf[2] !=
':' || buf[5] !=
':' || buf[8] !=
'.')
48 return ms - packet_time;
52 int *got_sub_ptr,
const AVPacket *avpkt)
54 const uint8_t *buf = avpkt->
data;
55 int buf_size = avpkt->
size;
57 const uint8_t *buf_end = buf + buf_size;
59 int w,
h, x, y,
i, ret;
63 int64_t start_display_time, end_display_time;
66 if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) {
72 if (buf[0] !=
'[' || buf[13] !=
'-' || buf[26] !=
']') {
82 sub-> end_display_time != end_display_time) {
89 w = bytestream_get_le16(&buf);
90 h = bytestream_get_le16(&buf);
93 x = bytestream_get_le16(&buf);
94 y = bytestream_get_le16(&buf);
96 bytestream_get_le16(&buf);
97 bytestream_get_le16(&buf);
102 bytestream_get_le16(&buf);
104 if (buf_end - buf <
h + 3*4)
119 rect->linesize[0] =
w;
123 if (!
rect->data[0] || !
rect->data[1])
127 for (
i = 0;
i <
rect->nb_colors;
i++)
128 ((uint32_t*)
rect->data[1])[
i] = bytestream_get_be24(&buf);
132 for (
i = 1;
i <
rect->nb_colors;
i++)
133 ((uint32_t *)
rect->data[1])[
i] |= 0xff000000;
135 for (
i = 0;
i <
rect->nb_colors;
i++)
136 ((uint32_t *)
rect->data[1])[
i] |= (unsigned)*buf++ << 24;
142 bitmap =
rect->data[0];
143 for (y = 0; y <
h; y++) {
145 if (y == (
h + 1) / 2) bitmap =
rect->data[0] +
w;
146 for (x = 0; x <
w; ) {
const FFCodec ff_xsub_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_DECODE_SUB_CB(func)
bitstream reader API header.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint8_t * align_get_bits(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
const uint8_t ff_log2_tab[256]
static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
#define MKTAG(a, b, c, d)
Memory handling functions.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Rational number (pair of numerator and denominator).
uint32_t start_display_time
uint32_t end_display_time
static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
static const uint8_t tc_muls[9]
static int64_t parse_timecode(const uint8_t *buf, int64_t packet_time)
static const uint8_t tc_offsets[9]