summaryrefslogtreecommitdiff
path: root/libavcodec/pgssubdec.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-10-14 11:33:25 +0200
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-10-21 12:02:29 +0200
commita17a7661906ba295d67afd80ac0770422e1b02b3 (patch)
tree37dd2b426804d375f7b79f79c1fca43eb2baac8f /libavcodec/pgssubdec.c
parentf890677d05bc4e8b494a73373ab4cc19791bf884 (diff)
lavc: Add data and linesize to AVSubtitleRect
Use the new fields directly instead of the ones from AVPicture. This removes a layer of indirection which serves no pratical purpose whatsoever, and will help in removing AVPicture structure completely later. Every subtitle encoder/decoder seamlessly points to the new arrays, so it is possible to deprecate AVSubtitleRect.pict. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/pgssubdec.c')
-rw-r--r--libavcodec/pgssubdec.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index 72142e6f7c..d58b491ca3 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -163,9 +163,9 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitleRect *rect,
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;
@@ -187,7 +187,7 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitleRect *rect,
}
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) {
/*
@@ -509,6 +509,8 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
}
for (i = 0; i < ctx->presentation.object_count; i++) {
PGSSubObject *object;
+ AVSubtitleRect *rect;
+ int j;
sub->rects[i] = av_mallocz(sizeof(*sub->rects[0]));
if (!sub->rects[i]) {
@@ -539,7 +541,17 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
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 FF_API_AVPICTURE
+FF_DISABLE_DEPRECATION_WARNINGS
+ 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
if (object->rle) {
if (object->rle_remaining_len) {
@@ -564,13 +576,13 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
}
/* 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));
+ memcpy(sub->rects[i]->data[1], palette->clut, sub->rects[i]->nb_colors * sizeof(uint32_t));
}
return 1;