rle_bitmap_end = buf + buf_size;
- rect->pict.data[0] = av_malloc(rect->w * rect->h);
+ rect->data[0] = av_malloc(rect->w * rect->h);
- if (!rect->pict.data[0])
+ if (!rect->data[0])
return AVERROR(ENOMEM);
pixel_count = 0;
}
if (run > 0 && pixel_count + run <= rect->w * rect->h) {
- memset(rect->pict.data[0] + pixel_count, color, run);
+ memset(rect->data[0] + pixel_count, color, run);
pixel_count += run;
} else if (!run) {
/*
return AVERROR_INVALIDDATA;
}
- av_dlog(avctx, "Pixel Count = %d, Area = %d\n", pixel_count, rect->w * rect->h);
+ ff_dlog(avctx, "Pixel Count = %d, Area = %d\n", pixel_count, rect->w * rect->h);
return 0;
}
/* Decode rle bitmap length, stored size includes width/height data */
rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
+ if (buf_size > rle_bitmap_len) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Buffer dimension %d larger than the expected RLE data %d\n",
+ buf_size, rle_bitmap_len);
+ return AVERROR_INVALIDDATA;
+ }
+
/* Get bitmap dimensions from data */
width = bytestream_get_be16(&buf);
height = bytestream_get_be16(&buf);
av_fast_malloc(&object->rle, &object->rle_buffer_size, rle_bitmap_len);
- if (!object->rle)
+ if (!object->rle) {
+ object->rle_data_len = 0;
+ object->rle_remaining_len = 0;
return AVERROR(ENOMEM);
+ }
memcpy(object->rle, buf, buf_size);
object->rle_data_len = buf_size;
cb = bytestream_get_byte(&buf);
alpha = bytestream_get_byte(&buf);
- YUV_TO_RGB1(cb, cr);
- YUV_TO_RGB2(r, g, b, y);
+ /* Default to BT.709 colorspace. In case of <= 576 height use BT.601 */
+ if (avctx->height <= 0 || avctx->height > 576) {
+ YUV_TO_RGB1_CCIR_BT709(cb, cr);
+ } else {
+ YUV_TO_RGB1_CCIR(cb, cr);
+ }
- av_dlog(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
+ YUV_TO_RGB2_CCIR(r, g, b, y);
+
+ ff_dlog(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
/* Store color in palette */
palette->clut[color_id] = RGBA(r,g,b,alpha);
ctx->presentation.pts = pts;
- av_dlog(avctx, "Video Dimensions %dx%d\n",
+ ff_dlog(avctx, "Video Dimensions %dx%d\n",
w, h);
ret = ff_set_dimensions(avctx, w, h);
if (ret < 0)
ctx->presentation.objects[i].crop_h = bytestream_get_be16(&buf);
}
- av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n",
+ ff_dlog(avctx, "Subtitle Placement x=%d, y=%d\n",
ctx->presentation.objects[i].x, ctx->presentation.objects[i].y);
if (ctx->presentation.objects[i].x > avctx->width ||
sub->rects[i]->w = object->w;
sub->rects[i]->h = object->h;
- sub->rects[i]->pict.linesize[0] = object->w;
+ sub->rects[i]->linesize[0] = object->w;
if (object->rle) {
if (object->rle_remaining_len) {
}
/* Allocate memory for colors */
sub->rects[i]->nb_colors = 256;
- sub->rects[i]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
- if (!sub->rects[i]->pict.data[1]) {
+ sub->rects[i]->data[1] = av_mallocz(AVPALETTE_SIZE);
+ if (!sub->rects[i]->data[1]) {
avsubtitle_free(sub);
return AVERROR(ENOMEM);
}
- memcpy(sub->rects[i]->pict.data[1], palette->clut, sub->rects[i]->nb_colors * sizeof(uint32_t));
+#if FF_API_AVPICTURE
+FF_DISABLE_DEPRECATION_WARNINGS
+{
+ AVSubtitleRect *rect;
+ int j;
+ rect = sub->rects[i];
+ for (j = 0; j < 4; j++) {
+ rect->pict.data[j] = rect->data[j];
+ rect->pict.linesize[j] = rect->linesize[j];
+ }
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ memcpy(sub->rects[i]->data[1], palette->clut, sub->rects[i]->nb_colors * sizeof(uint32_t));
}
return 1;
int segment_length;
int i, ret;
- av_dlog(avctx, "PGS sub packet:\n");
+ ff_dlog(avctx, "PGS sub packet:\n");
for (i = 0; i < buf_size; i++) {
- av_dlog(avctx, "%02x ", buf[i]);
+ ff_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
}
if (i & 15)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
*data_size = 0;
segment_type = bytestream_get_byte(&buf);
segment_length = bytestream_get_be16(&buf);
- av_dlog(avctx, "Segment Length %d, Segment Type %x\n", segment_length, segment_type);
+ ff_dlog(avctx, "Segment Length %d, Segment Type %x\n", segment_length, segment_type);
if (segment_type != DISPLAY_SEGMENT && segment_length > buf_end - buf)
break;