#include "libavutil/colorspace.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
-#include "libavutil/avstring.h"
#include "libavutil/bswap.h"
typedef struct DVDSubContext
{
int len;
int has_run = get_bits1(gb);
- if (get_bits1(gb))
- *color = get_bits(gb, 8);
- else
- *color = get_bits(gb, 2);
+ *color = get_bits(gb, 2 + 6*get_bits1(gb));
if (has_run) {
if (get_bits1(gb)) {
len = get_bits(gb, 7);
len = decode_run_8bit(&gb, &color);
else
len = decode_run_2bit(&gb, &color);
+ if (len != INT_MAX && len > w - x)
+ return AVERROR_INVALIDDATA;
len = FFMIN(len, w - x);
memset(d + x, color, len);
used_color[color] = 1;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->linesize[0] = w;
sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0;
-
-#if FF_API_AVPICTURE
-FF_DISABLE_DEPRECATION_WARNINGS
- for (i = 0; i < 4; i++) {
- sub_header->rects[0]->pict.data[i] = sub_header->rects[0]->data[i];
- sub_header->rects[0]->pict.linesize[i] = sub_header->rects[0]->linesize[i];
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
}
}
if (next_cmd_pos < cmd_pos) {
s->rects[0]->x += x1;
s->rects[0]->y += y1;
-#if FF_API_AVPICTURE
-FF_DISABLE_DEPRECATION_WARNINGS
- for (i = 0; i < 4; i++) {
- s->rects[0]->pict.data[i] = s->rects[0]->data[i];
- s->rects[0]->pict.linesize[i] = s->rects[0]->linesize[i];
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
return 1;
}
}
if (is_menu < 0) {
+ ctx->buf_size = 0;
no_subtitle:
reset_rects(sub);
*data_size = 0;
return buf_size;
}
-static void parse_palette(DVDSubContext *ctx, char *p)
-{
- int i;
-
- ctx->has_palette = 1;
- for(i=0;i<16;i++) {
- ctx->palette[i] = strtoul(p, &p, 16);
- while(*p == ',' || av_isspace(*p))
- p++;
- }
-}
-
static int parse_ifo_palette(DVDSubContext *ctx, char *p)
{
FILE *ifo;
break;
if (strncmp("palette:", data, 8) == 0) {
- parse_palette(ctx, data + 8);
+ ctx->has_palette = 1;
+ ff_dvdsub_parse_palette(ctx->palette, data + 8);
} else if (strncmp("size:", data, 5) == 0) {
int w, h;
if (sscanf(data + 5, "%dx%d", &w, &h) == 2) {
if (ctx->ifo_str)
parse_ifo_palette(ctx, ctx->ifo_str);
- if (ctx->palette_str)
- parse_palette(ctx, ctx->palette_str);
+ if (ctx->palette_str) {
+ ctx->has_palette = 1;
+ ff_dvdsub_parse_palette(ctx->palette, ctx->palette_str);
+ }
if (ctx->has_palette) {
int i;
av_log(avctx, AV_LOG_DEBUG, "palette:");
.version = LIBAVUTIL_VERSION_INT,
};
-AVCodec ff_dvdsub_decoder = {
+const AVCodec ff_dvdsub_decoder = {
.name = "dvdsub",
.long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"),
.type = AVMEDIA_TYPE_SUBTITLE,