33 #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
94 const uint8_t *buf,
unsigned int buf_size)
97 int pixel_count, line_count;
99 rle_bitmap_end = buf + buf_size;
109 while (buf < rle_bitmap_end && line_count < sub->rects[0]->h) {
113 color = bytestream_get_byte(&buf);
117 flags = bytestream_get_byte(&buf);
120 run = (run << 8) + bytestream_get_byte(&buf);
121 color = flags & 0x80 ? bytestream_get_byte(&buf) : 0;
124 if (run > 0 && pixel_count + run <= sub->rects[0]->w * sub->
rects[0]->
h) {
125 memset(sub->
rects[0]->
pict.
data[0] + pixel_count, color, run);
132 if (pixel_count % sub->
rects[0]->
w > 0)
139 if (pixel_count < sub->rects[0]->w * sub->
rects[0]->
h) {
144 av_dlog(avctx,
"Pixel Count = %d, Area = %d\n", pixel_count, sub->
rects[0]->
w * sub->
rects[0]->
h);
161 const uint8_t *buf,
int buf_size)
176 sequence_desc = bytestream_get_byte(&buf);
178 if (!(sequence_desc & 0x80)) {
195 rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
198 width = bytestream_get_be16(&buf);
199 height = bytestream_get_be16(&buf);
202 if (avctx->
width < width || avctx->
height < height) {
233 const uint8_t *buf,
int buf_size)
237 const uint8_t *buf_end = buf + buf_size;
240 int y, cb, cr, alpha;
241 int r,
g,
b, r_add, g_add, b_add;
246 while (buf < buf_end) {
247 color_id = bytestream_get_byte(&buf);
248 y = bytestream_get_byte(&buf);
249 cr = bytestream_get_byte(&buf);
250 cb = bytestream_get_byte(&buf);
251 alpha = bytestream_get_byte(&buf);
256 av_dlog(avctx,
"Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
259 ctx->
clut[color_id] =
RGBA(r,g,b,alpha);
276 const uint8_t *buf,
int buf_size,
283 int w = bytestream_get_be16(&buf);
284 int h = bytestream_get_be16(&buf);
288 av_dlog(avctx,
"Video Dimensions %dx%d\n",
319 x = bytestream_get_be16(&buf);
320 y = bytestream_get_be16(&buf);
324 av_dlog(avctx,
"Subtitle Placement x=%d, y=%d\n", x, y);
327 av_log(avctx,
AV_LOG_ERROR,
"Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
353 const uint8_t *buf,
int buf_size)
364 memset(sub, 0,
sizeof(*sub));
411 int buf_size = avpkt->
size;
418 av_dlog(avctx,
"PGS sub packet:\n");
420 for (i = 0; i < buf_size; i++) {
421 av_dlog(avctx,
"%02x ", buf[i]);
435 buf_end = buf + buf_size;
438 while (buf < buf_end) {
439 segment_type = bytestream_get_byte(&buf);
440 segment_length = bytestream_get_be16(&buf);
442 av_dlog(avctx,
"Segment Length %d, Segment Type %x\n", segment_length, segment_type);
447 switch (segment_type) {
472 segment_type, segment_length);
476 buf += segment_length;