40 if (buf[2] !=
':' || buf[5] !=
':' || buf[8] !=
'.')
47 return ms - packet_time;
53 int buf_size = avpkt->
size;
55 const uint8_t *buf_end = buf + buf_size;
57 int w,
h, x, y,
i, ret;
61 int64_t start_display_time, end_display_time;
64 if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) {
70 if (buf[0] !=
'[' || buf[13] !=
'-' || buf[26] !=
']') {
77 sub->start_display_time = start_display_time =
parse_timecode(buf + 1, packet_time);
79 if (
sub->start_display_time != start_display_time ||
80 sub-> end_display_time != end_display_time) {
87 w = bytestream_get_le16(&buf);
88 h = bytestream_get_le16(&buf);
91 x = bytestream_get_le16(&buf);
92 y = bytestream_get_le16(&buf);
94 bytestream_get_le16(&buf);
95 bytestream_get_le16(&buf);
100 bytestream_get_le16(&buf);
102 if (buf_end - buf <
h + 3*4)
111 if (!
sub->rects[0]) {
115 sub->rects[0]->x = x;
sub->rects[0]->y = y;
116 sub->rects[0]->w =
w;
sub->rects[0]->h =
h;
118 sub->rects[0]->linesize[0] =
w;
120 sub->rects[0]->nb_colors = 4;
122 if (!
sub->rects[0]->data[0] || !
sub->rects[0]->data[1]) {
132 for (
i = 0;
i <
sub->rects[0]->nb_colors;
i++)
133 ((uint32_t*)
sub->rects[0]->data[1])[
i] = bytestream_get_be24(&buf);
137 for (
i = 1;
i <
sub->rects[0]->nb_colors;
i++)
138 ((uint32_t *)
sub->rects[0]->data[1])[
i] |= 0xff000000;
140 for (
i = 0;
i <
sub->rects[0]->nb_colors;
i++)
141 ((uint32_t *)
sub->rects[0]->data[1])[
i] |= (unsigned)*buf++ << 24;
150 for (j = 0; j < 4; j++) {
152 rect->pict.linesize[j] =
rect->linesize[j];
161 bitmap =
sub->rects[0]->data[0];
162 for (y = 0; y <
h; y++) {
164 if (y == (
h + 1) / 2) bitmap =
sub->rects[0]->data[0] +
w;
165 for (x = 0; x <
w; ) {
Libavcodec external API header.
#define MKTAG(a, b, c, d)
static float sub(float src0, float src1)
bitstream reader API header.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const uint8_t * align_get_bits(GetBitContext *s)
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.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
@ 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').
const char * name
Name of the codec implementation.
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).
static av_cold int decode_init(AVCodecContext *avctx)
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]
static int decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)