35 #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
96 const uint8_t *buf,
unsigned int buf_size)
99 int pixel_count, line_count;
101 rle_bitmap_end = buf + buf_size;
111 while (buf < rle_bitmap_end && line_count < sub->rects[0]->h) {
115 color = bytestream_get_byte(&buf);
119 flags = bytestream_get_byte(&buf);
122 run = (run << 8) + bytestream_get_byte(&buf);
123 color = flags & 0x80 ? bytestream_get_byte(&buf) : 0;
126 if (run > 0 && pixel_count + run <= sub->rects[0]->w * sub->
rects[0]->
h) {
127 memset(sub->
rects[0]->
pict.
data[0] + pixel_count, color, run);
134 if (pixel_count % sub->
rects[0]->
w > 0)
141 if (pixel_count < sub->rects[0]->w * sub->
rects[0]->
h) {
146 av_dlog(avctx,
"Pixel Count = %d, Area = %d\n", pixel_count, sub->
rects[0]->
w * sub->
rects[0]->
h);
163 const uint8_t *buf,
int buf_size)
178 sequence_desc = bytestream_get_byte(&buf);
180 if (!(sequence_desc & 0x80)) {
197 rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
199 if (buf_size > rle_bitmap_len) {
201 "Buffer dimension %d larger than the expected RLE data %d\n",
202 buf_size, rle_bitmap_len);
207 width = bytestream_get_be16(&buf);
208 height = bytestream_get_be16(&buf);
211 if (avctx->
width < width || avctx->
height < height) {
242 const uint8_t *buf,
int buf_size)
246 const uint8_t *buf_end = buf + buf_size;
249 int y, cb, cr, alpha;
250 int r,
g,
b, r_add, g_add, b_add;
255 while (buf < buf_end) {
256 color_id = bytestream_get_byte(&buf);
257 y = bytestream_get_byte(&buf);
258 cr = bytestream_get_byte(&buf);
259 cb = bytestream_get_byte(&buf);
260 alpha = bytestream_get_byte(&buf);
265 av_dlog(avctx,
"Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
268 ctx->
clut[color_id] =
RGBA(r,g,b,alpha);
285 const uint8_t *buf,
int buf_size,
292 int w = bytestream_get_be16(&buf);
293 int h = bytestream_get_be16(&buf);
297 av_dlog(avctx,
"Video Dimensions %dx%d\n",
329 x = bytestream_get_be16(&buf);
330 y = bytestream_get_be16(&buf);
334 av_dlog(avctx,
"Subtitle Placement x=%d, y=%d\n", x, y);
337 av_log(avctx,
AV_LOG_ERROR,
"Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
365 const uint8_t *buf,
int buf_size)
376 memset(sub, 0,
sizeof(*sub));
423 int buf_size = avpkt->
size;
430 av_dlog(avctx,
"PGS sub packet:\n");
432 for (i = 0; i < buf_size; i++) {
433 av_dlog(avctx,
"%02x ", buf[i]);
447 buf_end = buf + buf_size;
450 while (buf < buf_end) {
451 segment_type = bytestream_get_byte(&buf);
452 segment_length = bytestream_get_be16(&buf);
454 av_dlog(avctx,
"Segment Length %d, Segment Type %x\n", segment_length, segment_type);
459 switch (segment_type) {
486 segment_type, segment_length);
490 buf += segment_length;
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
int x
top left corner of pict, undefined when pict is not set
static int parse_presentation_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int64_t pts)
Parse the presentation segment packet.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
unsigned int rle_remaining_len
int nb_colors
number of colors in pict, undefined when pict is not set
Various defines for YUV<->RGB conversion.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
AVCodec ff_pgssub_decoder
PGSSubPresentation presentation
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int w
width of pict, undefined when pict is not set
8 bit with PIX_FMT_RGB32 palette
uint8_t * data[AV_NUM_DATA_POINTERS]
static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
int h
height of pict, undefined when pict is not set
static int parse_picture_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Parse the picture segment packet.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define YUV_TO_RGB2(r, g, b, y1)
int y
top left corner of pict, undefined when pict is not set
unsigned int rle_buffer_size
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define YUV_TO_RGB1(cb1, cr1)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
uint32_t end_display_time
int64_t pts
Same as packet pts, in AV_TIME_BASE.
A bitmap, pict will be set.
#define AV_SUBTITLE_FLAG_FORCED
AVPicture pict
data+linesize for the bitmap of this subtitle.
static av_cold int close_decoder(AVCodecContext *avctx)
int width
picture width / height.
static av_cold int init_decoder(AVCodecContext *avctx)
static int display_end_segment(AVCodecContext *avctx, void *data, const uint8_t *buf, int buf_size)
Parse the display segment packet.
Libavcodec external API header.
static int decode_rle(AVCodecContext *avctx, AVSubtitle *sub, const uint8_t *buf, unsigned int buf_size)
Decode the RLE data.
main external API structure.
static void close(AVCodecParserContext *s)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
common internal api header.
uint32_t start_display_time
static void parse_palette_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Parse the palette segment packet.
static const uint8_t color[]
static av_cold int init(AVCodecParserContext *s)
unsigned int rle_data_len
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...