33 #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
92 const uint8_t *buf,
unsigned int buf_size)
94 const uint8_t *rle_bitmap_end;
95 int pixel_count, line_count;
97 rle_bitmap_end = buf + buf_size;
107 while (buf < rle_bitmap_end && line_count < sub->rects[0]->h) {
111 color = bytestream_get_byte(&buf);
115 flags = bytestream_get_byte(&buf);
118 run = (run << 8) + bytestream_get_byte(&buf);
119 color = flags & 0x80 ? bytestream_get_byte(&buf) : 0;
122 if (run > 0 && pixel_count + run <= sub->rects[0]->w * sub->
rects[0]->
h) {
123 memset(sub->
rects[0]->
pict.
data[0] + pixel_count, color, run);
130 if (pixel_count % sub->
rects[0]->
w > 0)
137 if (pixel_count < sub->rects[0]->w * sub->
rects[0]->
h) {
142 av_dlog(avctx,
"Pixel Count = %d, Area = %d\n", pixel_count, sub->
rects[0]->
w * sub->
rects[0]->
h);
159 const uint8_t *buf,
int buf_size)
163 uint8_t sequence_desc;
174 sequence_desc = bytestream_get_byte(&buf);
176 if (!(sequence_desc & 0x80)) {
193 rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
195 if (buf_size > rle_bitmap_len) {
197 "Buffer dimension %d larger than the expected RLE data %d\n",
198 buf_size, rle_bitmap_len);
203 width = bytestream_get_be16(&buf);
204 height = bytestream_get_be16(&buf);
207 if (avctx->
width < width || avctx->
height < height) {
238 const uint8_t *buf,
int buf_size)
242 const uint8_t *buf_end = buf + buf_size;
245 int y, cb, cr, alpha;
246 int r,
g,
b, r_add, g_add, b_add;
251 while (buf < buf_end) {
252 color_id = bytestream_get_byte(&buf);
253 y = bytestream_get_byte(&buf);
254 cr = bytestream_get_byte(&buf);
255 cb = bytestream_get_byte(&buf);
256 alpha = bytestream_get_byte(&buf);
261 av_dlog(avctx,
"Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
264 ctx->
clut[color_id] =
RGBA(r,g,b,alpha);
281 const uint8_t *buf,
int buf_size)
287 int w = bytestream_get_be16(&buf);
288 int h = bytestream_get_be16(&buf);
290 av_dlog(avctx,
"Video Dimensions %dx%d\n",
320 x = bytestream_get_be16(&buf);
321 y = bytestream_get_be16(&buf);
325 av_dlog(avctx,
"Subtitle Placement x=%d, y=%d\n", x, y);
328 av_log(avctx,
AV_LOG_ERROR,
"Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
354 const uint8_t *buf,
int buf_size)
365 memset(sub, 0,
sizeof(*sub));
406 const uint8_t *buf = avpkt->
data;
407 int buf_size = avpkt->
size;
409 const uint8_t *buf_end;
410 uint8_t segment_type;
414 av_dlog(avctx,
"PGS sub packet:\n");
416 for (i = 0; i < buf_size; i++) {
417 av_dlog(avctx,
"%02x ", buf[i]);
431 buf_end = buf + buf_size;
434 while (buf < buf_end) {
435 segment_type = bytestream_get_byte(&buf);
436 segment_length = bytestream_get_be16(&buf);
438 av_dlog(avctx,
"Segment Length %d, Segment Type %x\n", segment_length, segment_type);
443 switch (segment_type) {
468 segment_type, segment_length);
472 buf += segment_length;