History

Merge commit 'a17a7661906ba295d67afd80ac0770422e1b02b3'

* commit 'a17a7661906ba295d67afd80ac0770422e1b02b3': lavc: Add data and linesize to AVSubtitleRect

Hendrik Leppkes committed 11 years ago

Commit ee573b42 parents 37498a4 a17a76611 files · +183 −86Browse files

Unified · Split

11 files
  1. doc/APIchanges +4 −0
  2. libavcodec/avcodec.h +11 −2
  3. libavcodec/dvbsub.c +3 −3
  4. libavcodec/dvbsubdec.c +25 −16
  5. libavcodec/dvdsubdec.c +41 −20
  6. libavcodec/dvdsubenc.c +29 −14
  7. libavcodec/pgssubdec.c +19 −8
  8. libavcodec/utils.c +4 −4
  9. libavcodec/version.h +4 −1
  10. libavcodec/xsubdec.c +23 −11
  11. libavcodec/xsubenc.c +20 −7
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2015-10-22 - xxxxxxx - lavc 57.9.100 / lavc 57.5.0 - avcodec.h
19+ Add data and linesize array to AVSubtitleRect, to be used instead of
20+ the ones from the embedded AVPicture.
21+
1822 2015-10-22 - xxxxxxx - lavc 57.8.100 / lavc 57.0.0 - qsv.h
1923 Add an API for allocating opaque surfaces.
2024
libavcodec/avcodec.h+11−2
@@ -3618,11 +3618,20 @@ typedef struct AVSubtitleRect { · 3617 unmodified lines
36183618 int h; ///< height of pict, undefined when pict is not set
36193619 int nb_colors; ///< number of colors in pict, undefined when pict is not set
36203620
3621+#if FF_API_AVPICTURE
36213622 /**
3622− * data+linesize for the bitmap of this subtitle.
3623− * can be set for text/ass as well once they are rendered
3623+ * @deprecated unused
36243624 */
3625+ attribute_deprecated
36253626 AVPicture pict;
3627+#endif
3628+ /**
3629+ * data+linesize for the bitmap of this subtitle.
3630+ * Can be set for text/ass as well once they are rendered.
3631+ */
3632+ uint8_t *data[4];
3633+ int linesize[4];
3634+
36263635 enum AVSubtitleType type;
36273636
36283637 char *text; ///< 0 terminated plain UTF-8 text
libavcodec/dvbsub.c+3−3
@@ -315,7 +315,7 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s, · 314 unmodified lines
315315 *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1; /* 2 bits/pixel full range */
316316 {
317317 int a, r, g, b;
318− uint32_t x= ((uint32_t*)h->rects[clut_id]->pict.data[1])[i];
318+ uint32_t x= ((uint32_t*)h->rects[clut_id]->data[1])[i];
319319 a = (x >> 24) & 0xff;
320320 r = (x >> 16) & 0xff;
321321 g = (x >> 8) & 0xff;
@@ -410,10 +410,10 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s, · 88 unmodified lines
410410 q += 2;
411411
412412 top_ptr = q;
413− dvb_encode_rle(&q, h->rects[object_id]->pict.data[0], h->rects[object_id]->w * 2,
413+ dvb_encode_rle(&q, h->rects[object_id]->data[0], h->rects[object_id]->w * 2,
414414 h->rects[object_id]->w, h->rects[object_id]->h >> 1);
415415 bottom_ptr = q;
416− dvb_encode_rle(&q, h->rects[object_id]->pict.data[0] + h->rects[object_id]->w,
416+ dvb_encode_rle(&q, h->rects[object_id]->data[0] + h->rects[object_id]->w,
417417 h->rects[object_id]->w * 2, h->rects[object_id]->w,
418418 h->rects[object_id]->h >> 1);
419419
libavcodec/dvbsubdec.c+25−16
@@ -761,14 +761,14 @@ static int dvbsub_read_8bit_string(AVCodecContext *avctx, · 760 unmodified lines
761761 return pixels_read;
762762 }
763763
764−static void compute_default_clut(AVPicture *frame, int w, int h)
764+static void compute_default_clut(AVSubtitleRect *rect, int w, int h)
765765 {
766766 uint8_t list[256] = {0};
767767 uint8_t list_inv[256];
768768 int counttab[256] = {0};
769769 int count, i, x, y;
770770
771−#define V(x,y) frame->data[0][(x) + (y)*frame->linesize[0]]
771+#define V(x,y) rect->data[0][(x) + (y)*rect->linesize[0]]
772772 for (y = 0; y<h; y++) {
773773 for (x = 0; x<w; x++) {
774774 int v = V(x,y) + 1;
@@ -779,7 +779,7 @@ static void compute_default_clut(AVPicture *frame, int w, int h) · 4 unmodified lines
779779 counttab[v-1] += !!((v!=vl) + (v!=vr) + (v!=vt) + (v!=vb));
780780 }
781781 }
782−#define L(x,y) list[ frame->data[0][(x) + (y)*frame->linesize[0]] ]
782+#define L(x,y) list[ rect->data[0][(x) + (y)*rect->linesize[0]] ]
783783
784784 for (i = 0; i<256; i++) {
785785 int scoretab[256] = {0};
@@ -787,7 +787,7 @@ static void compute_default_clut(AVPicture *frame, int w, int h) · 1 unmodified line
787787 int bestv = 0;
788788 for (y = 0; y<h; y++) {
789789 for (x = 0; x<w; x++) {
790− int v = frame->data[0][x + y*frame->linesize[0]];
790+ int v = rect->data[0][x + y*rect->linesize[0]];
791791 int l_m = list[v];
792792 int l_l = x ? L(x-1, y) : 1;
793793 int l_r = x+1<w ? L(x+1, y) : 1;
@@ -813,7 +813,7 @@ static void compute_default_clut(AVPicture *frame, int w, int h) · 19 unmodified lines
813813 count = i - 1;
814814 for (i--; i>=0; i--) {
815815 int v = i*255/count;
816− AV_WN32(frame->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));
816+ AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));
817817 }
818818 }
819819
@@ -827,7 +827,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou · 7 unmodified lines
827827 AVSubtitleRect *rect;
828828 DVBSubCLUT *clut;
829829 uint32_t *clut_table;
830− int i;
830+ int i,j;
831831 int offset_x=0, offset_y=0;
832832 int ret = 0;
833833
@@ -884,7 +884,7 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou · 50 unmodified lines
884884 rect->h = region->height;
885885 rect->nb_colors = (1 << region->depth);
886886 rect->type = SUBTITLE_BITMAP;
887− rect->pict.linesize[0] = region->width;
887+ rect->linesize[0] = region->width;
888888
889889 clut = get_clut(ctx, region->clut);
890890
@@ -904,23 +904,32 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou · 13 unmodified lines
904904 break;
905905 }
906906
907− rect->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
908− if (!rect->pict.data[1]) {
907+ rect->data[1] = av_mallocz(AVPALETTE_SIZE);
908+ if (!rect->data[1]) {
909909 ret = AVERROR(ENOMEM);
910910 goto fail;
911911 }
912− memcpy(rect->pict.data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
912+ memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
913913
914− rect->pict.data[0] = av_malloc(region->buf_size);
915− if (!rect->pict.data[0]) {
914+ rect->data[0] = av_malloc(region->buf_size);
915+ if (!rect->data[0]) {
916916 ret = AVERROR(ENOMEM);
917917 goto fail;
918918 }
919919
920− memcpy(rect->pict.data[0], region->pbuf, region->buf_size);
920+ memcpy(rect->data[0], region->pbuf, region->buf_size);
921921
922922 if ((clut == &default_clut && ctx->compute_clut == -1) || ctx->compute_clut == 1)
923− compute_default_clut(&rect->pict, rect->w, rect->h);
923+ compute_default_clut(rect, rect->w, rect->h);
924+
925+#if FF_API_AVPICTURE
926+FF_DISABLE_DEPRECATION_WARNINGS
927+ for (j = 0; j < 4; j++) {
928+ rect->pict.data[j] = rect->data[j];
929+ rect->pict.linesize[j] = rect->linesize[j];
930+ }
931+FF_ENABLE_DEPRECATION_WARNINGS
932+#endif
924933
925934 i++;
926935 }
@@ -932,8 +941,8 @@ fail: · 5 unmodified lines
932941 for(i=0; i<sub->num_rects; i++) {
933942 rect = sub->rects[i];
934943 if (rect) {
935− av_freep(&rect->pict.data[0]);
936− av_freep(&rect->pict.data[1]);
944+ av_freep(&rect->data[0]);
945+ av_freep(&rect->data[1]);
937946 }
938947 av_freep(&sub->rects[i]);
939948 }
libavcodec/dvdsubdec.c+41−20
@@ -206,8 +206,8 @@ static void reset_rects(AVSubtitle *sub_header) · 205 unmodified lines
206206
207207 if (sub_header->rects) {
208208 for (i = 0; i < sub_header->num_rects; i++) {
209− av_freep(&sub_header->rects[i]->pict.data[0]);
210− av_freep(&sub_header->rects[i]->pict.data[1]);
209+ av_freep(&sub_header->rects[i]->data[0]);
210+ av_freep(&sub_header->rects[i]->data[1]);
211211 av_freep(&sub_header->rects[i]);
212212 }
213213 av_freep(&sub_header->rects);
@@ -374,7 +374,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, · 160 unmodified lines
374374 if (!sub_header->rects[0])
375375 goto fail;
376376 sub_header->num_rects = 1;
377− bitmap = sub_header->rects[0]->pict.data[0] = av_malloc(w * h);
377+ bitmap = sub_header->rects[0]->data[0] = av_malloc(w * h);
378378 if (!bitmap)
379379 goto fail;
380380 if (decode_rle(bitmap, w * 2, w, (h + 1) / 2,
@@ -383,17 +383,19 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, · 2 unmodified lines
383383 if (decode_rle(bitmap + w, w * 2, w, h / 2,
384384 buf, offset2, buf_size, is_8bit) < 0)
385385 goto fail;
386− sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
387− if (!sub_header->rects[0]->pict.data[1])
386+ sub_header->rects[0]->data[1] = av_mallocz(AVPALETTE_SIZE);
387+ if (!sub_header->rects[0]->data[1])
388388 goto fail;
389389 if (is_8bit) {
390390 if (!yuv_palette)
391391 goto fail;
392392 sub_header->rects[0]->nb_colors = 256;
393− yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
393+ yuv_a_to_rgba(yuv_palette, alpha,
394+ (uint32_t *)sub_header->rects[0]->data[1],
395+ 256);
394396 } else {
395397 sub_header->rects[0]->nb_colors = 4;
396− guess_palette(ctx, (uint32_t*)sub_header->rects[0]->pict.data[1],
398+ guess_palette(ctx, (uint32_t*)sub_header->rects[0]->data[1],
397399 0xffff00);
398400 }
399401 sub_header->rects[0]->x = x1;
@@ -401,8 +403,17 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, · 1 unmodified line
401403 sub_header->rects[0]->w = w;
402404 sub_header->rects[0]->h = h;
403405 sub_header->rects[0]->type = SUBTITLE_BITMAP;
404− sub_header->rects[0]->pict.linesize[0] = w;
406+ sub_header->rects[0]->linesize[0] = w;
405407 sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0;
408+
409+#if FF_API_AVPICTURE
410+FF_DISABLE_DEPRECATION_WARNINGS
411+ for (i = 0; i < 4; i++) {
412+ sub_header->rects[0]->pict.data[i] = sub_header->rects[0]->data[i];
413+ sub_header->rects[0]->pict.linesize[i] = sub_header->rects[0]->linesize[i];
414+ }
415+FF_ENABLE_DEPRECATION_WARNINGS
416+#endif
406417 }
407418 }
408419 if (next_cmd_pos < cmd_pos) {
@@ -443,29 +454,29 @@ static int find_smallest_bounding_rectangle(AVSubtitle *s) · 34 unmodified lines
443454 return 0;
444455
445456 for(i = 0; i < s->rects[0]->nb_colors; i++) {
446− if ((((uint32_t*)s->rects[0]->pict.data[1])[i] >> 24) == 0)
457+ if ((((uint32_t *)s->rects[0]->data[1])[i] >> 24) == 0)
447458 transp_color[i] = 1;
448459 }
449460 y1 = 0;
450− while (y1 < s->rects[0]->h && is_transp(s->rects[0]->pict.data[0] + y1 * s->rects[0]->pict.linesize[0],
461+ while (y1 < s->rects[0]->h && is_transp(s->rects[0]->data[0] + y1 * s->rects[0]->linesize[0],
451462 1, s->rects[0]->w, transp_color))
452463 y1++;
453464 if (y1 == s->rects[0]->h) {
454− av_freep(&s->rects[0]->pict.data[0]);
465+ av_freep(&s->rects[0]->data[0]);
455466 s->rects[0]->w = s->rects[0]->h = 0;
456467 return 0;
457468 }
458469
459470 y2 = s->rects[0]->h - 1;
460− while (y2 > 0 && is_transp(s->rects[0]->pict.data[0] + y2 * s->rects[0]->pict.linesize[0], 1,
471+ while (y2 > 0 && is_transp(s->rects[0]->data[0] + y2 * s->rects[0]->linesize[0], 1,
461472 s->rects[0]->w, transp_color))
462473 y2--;
463474 x1 = 0;
464− while (x1 < (s->rects[0]->w - 1) && is_transp(s->rects[0]->pict.data[0] + x1, s->rects[0]->pict.linesize[0],
475+ while (x1 < (s->rects[0]->w - 1) && is_transp(s->rects[0]->data[0] + x1, s->rects[0]->linesize[0],
465476 s->rects[0]->h, transp_color))
466477 x1++;
467478 x2 = s->rects[0]->w - 1;
468− while (x2 > 0 && is_transp(s->rects[0]->pict.data[0] + x2, s->rects[0]->pict.linesize[0], s->rects[0]->h,
479+ while (x2 > 0 && is_transp(s->rects[0]->data[0] + x2, s->rects[0]->linesize[0], s->rects[0]->h,
469480 transp_color))
470481 x2--;
471482 w = x2 - x1 + 1;
@@ -474,15 +485,25 @@ static int find_smallest_bounding_rectangle(AVSubtitle *s) · 2 unmodified lines
474485 if (!bitmap)
475486 return 1;
476487 for(y = 0; y < h; y++) {
477− memcpy(bitmap + w * y, s->rects[0]->pict.data[0] + x1 + (y1 + y) * s->rects[0]->pict.linesize[0], w);
488+ memcpy(bitmap + w * y, s->rects[0]->data[0] + x1 + (y1 + y) * s->rects[0]->linesize[0], w);
478489 }
479− av_freep(&s->rects[0]->pict.data[0]);
480− s->rects[0]->pict.data[0] = bitmap;
481− s->rects[0]->pict.linesize[0] = w;
490+ av_freep(&s->rects[0]->data[0]);
491+ s->rects[0]->data[0] = bitmap;
492+ s->rects[0]->linesize[0] = w;
482493 s->rects[0]->w = w;
483494 s->rects[0]->h = h;
484495 s->rects[0]->x += x1;
485496 s->rects[0]->y += y1;
497+
498+#if FF_API_AVPICTURE
499+FF_DISABLE_DEPRECATION_WARNINGS
500+ for (i = 0; i < 4; i++) {
501+ s->rects[0]->pict.data[i] = s->rects[0]->data[i];
502+ s->rects[0]->pict.linesize[i] = s->rects[0]->linesize[i];
503+ }
504+FF_ENABLE_DEPRECATION_WARNINGS
505+#endif
506+
486507 return 1;
487508 }
488509
@@ -583,8 +604,8 @@ static int dvdsub_decode(AVCodecContext *avctx, · 94 unmodified lines
583604 ff_dlog(NULL, "start=%d ms end =%d ms\n",
584605 sub->start_display_time,
585606 sub->end_display_time);
586− ppm_save(ppm_name, sub->rects[0]->pict.data[0],
587− sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]);
607+ ppm_save(ppm_name, sub->rects[0]->data[0],
608+ sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->data[1]);
588609 }
589610 #endif
590611
libavcodec/dvdsubenc.c+29−14
@@ -118,15 +118,15 @@ static void count_colors(AVCodecContext *avctx, unsigned hits[33], · 117 unmodified lines
118118 {
119119 DVDSubtitleContext *dvdc = avctx->priv_data;
120120 unsigned count[256] = { 0 };
121− uint32_t *palette = (uint32_t *)r->pict.data[1];
121+ uint32_t *palette = (uint32_t *)r->data[1];
122122 uint32_t color;
123123 int x, y, i, j, match, d, best_d, av_uninit(best_j);
124− uint8_t *p = r->pict.data[0];
124+ uint8_t *p = r->data[0];
125125
126126 for (y = 0; y < r->h; y++) {
127127 for (x = 0; x < r->w; x++)
128128 count[*(p++)]++;
129− p += r->pict.linesize[0] - r->w;
129+ p += r->linesize[0] - r->w;
130130 }
131131 for (i = 0; i < 256; i++) {
132132 if (!count[i]) /* avoid useless search */
@@ -236,14 +236,14 @@ static void copy_rectangle(AVSubtitleRect *dst, AVSubtitleRect *src, int cmap[]) · 103 unmodified lines
236236 int x, y;
237237 uint8_t *p, *q;
238238
239− p = src->pict.data[0];
240− q = dst->pict.data[0] + (src->x - dst->x) +
241− (src->y - dst->y) * dst->pict.linesize[0];
239+ p = src->data[0];
240+ q = dst->data[0] + (src->x - dst->x) +
241+ (src->y - dst->y) * dst->linesize[0];
242242 for (y = 0; y < src->h; y++) {
243243 for (x = 0; x < src->w; x++)
244244 *(q++) = cmap[*(p++)];
245− p += src->pict.linesize[0] - src->w;
246− q += dst->pict.linesize[0] - src->w;
245+ p += src->linesize[0] - src->w;
246+ q += dst->linesize[0] - src->w;
247247 }
248248 }
249249
@@ -277,6 +277,21 @@ static int encode_dvd_subtitles(AVCodecContext *avctx, · 27 unmodified lines
277277 forced = 1;
278278 break;
279279 }
280+
281+#if FF_API_AVPICTURE
282+FF_DISABLE_DEPRECATION_WARNINGS
283+ for (i = 0; i < rects; i++)
284+ if (!h->rects[i]->data[0]) {
285+ AVSubtitleRect *rect = h->rects[i];
286+ int j;
287+ for (j = 0; j < 4; j++) {
288+ rect->data[j] = rect->pict.data[j];
289+ rect->linesize[j] = rect->pict.linesize[j];
290+ }
291+ }
292+FF_ENABLE_DEPRECATION_WARNINGS
293+#endif
294+
280295 vrect = *h->rects[0];
281296
282297 if (rects > 1) {
@@ -312,17 +327,17 @@ static int encode_dvd_subtitles(AVCodecContext *avctx, · 29 unmodified lines
312327 if (rects > 1) {
313328 if (!(vrect_data = av_calloc(vrect.w, vrect.h)))
314329 return AVERROR(ENOMEM);
315− vrect.pict.data [0] = vrect_data;
316− vrect.pict.linesize[0] = vrect.w;
330+ vrect.data [0] = vrect_data;
331+ vrect.linesize[0] = vrect.w;
317332 for (i = 0; i < rects; i++) {
318− build_color_map(avctx, cmap, (uint32_t *)h->rects[i]->pict.data[1],
333+ build_color_map(avctx, cmap, (uint32_t *)h->rects[i]->data[1],
319334 out_palette, out_alpha);
320335 copy_rectangle(&vrect, h->rects[i], cmap);
321336 }
322337 for (i = 0; i < 4; i++)
323338 cmap[i] = i;
324339 } else {
325− build_color_map(avctx, cmap, (uint32_t *)h->rects[0]->pict.data[1],
340+ build_color_map(avctx, cmap, (uint32_t *)h->rects[0]->data[1],
326341 out_palette, out_alpha);
327342 }
328343
@@ -342,10 +357,10 @@ static int encode_dvd_subtitles(AVCodecContext *avctx, · 13 unmodified lines
342357 ret = AVERROR_BUFFER_TOO_SMALL;
343358 goto fail;
344359 }
345− dvd_encode_rle(&q, vrect.pict.data[0], vrect.w * 2,
360+ dvd_encode_rle(&q, vrect.data[0], vrect.w * 2,
346361 vrect.w, (vrect.h + 1) >> 1, cmap);
347362 offset2 = q - outbuf;
348− dvd_encode_rle(&q, vrect.pict.data[0] + vrect.w, vrect.w * 2,
363+ dvd_encode_rle(&q, vrect.data[0] + vrect.w, vrect.w * 2,
349364 vrect.w, vrect.h >> 1, cmap);
350365
351366 if (dvdc->even_rows_fix && (vrect.h & 1)) {
libavcodec/pgssubdec.c+19−8
@@ -166,9 +166,9 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitleRect *rect, · 165 unmodified lines
166166
167167 rle_bitmap_end = buf + buf_size;
168168
169− rect->pict.data[0] = av_malloc_array(rect->w, rect->h);
169+ rect->data[0] = av_malloc_array(rect->w, rect->h);
170170
171− if (!rect->pict.data[0])
171+ if (!rect->data[0])
172172 return AVERROR(ENOMEM);
173173
174174 pixel_count = 0;
@@ -190,7 +190,7 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitleRect *rect, · 15 unmodified lines
190190 }
191191
192192 if (run > 0 && pixel_count + run <= rect->w * rect->h) {
193− memset(rect->pict.data[0] + pixel_count, color, run);
193+ memset(rect->data[0] + pixel_count, color, run);
194194 pixel_count += run;
195195 } else if (!run) {
196196 /*
@@ -523,6 +523,8 @@ static int display_end_segment(AVCodecContext *avctx, void *data, · 326 unmodified lines
523523 }
524524 for (i = 0; i < ctx->presentation.object_count; i++) {
525525 PGSSubObject *object;
526+ AVSubtitleRect *rect;
527+ int j;
526528
527529 sub->rects[i] = av_mallocz(sizeof(*sub->rects[0]));
528530 if (!sub->rects[i]) {
@@ -553,7 +555,7 @@ static int display_end_segment(AVCodecContext *avctx, void *data, · 24 unmodified lines
553555 sub->rects[i]->w = object->w;
554556 sub->rects[i]->h = object->h;
555557
556− sub->rects[i]->pict.linesize[0] = object->w;
558+ sub->rects[i]->linesize[0] = object->w;
557559
558560 if (object->rle) {
559561 if (object->rle_remaining_len) {
@@ -578,15 +580,24 @@ static int display_end_segment(AVCodecContext *avctx, void *data, · 18 unmodified lines
578580 }
579581 /* Allocate memory for colors */
580582 sub->rects[i]->nb_colors = 256;
581− sub->rects[i]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
582− if (!sub->rects[i]->pict.data[1]) {
583+ sub->rects[i]->data[1] = av_mallocz(AVPALETTE_SIZE);
584+ if (!sub->rects[i]->data[1]) {
583585 avsubtitle_free(sub);
584586 return AVERROR(ENOMEM);
585587 }
586588
587589 if (!ctx->forced_subs_only || ctx->presentation.objects[i].composition_flag & 0x40)
588− memcpy(sub->rects[i]->pict.data[1], palette->clut, sub->rects[i]->nb_colors * sizeof(uint32_t));
589−
590+ memcpy(sub->rects[i]->data[1], palette->clut, sub->rects[i]->nb_colors * sizeof(uint32_t));
591+
592+#if FF_API_AVPICTURE
593+FF_DISABLE_DEPRECATION_WARNINGS
594+ rect = sub->rects[i];
595+ for (j = 0; j < 4; j++) {
596+ rect->pict.data[j] = rect->data[j];
597+ rect->pict.linesize[j] = rect->linesize[j];
598+ }
599+FF_ENABLE_DEPRECATION_WARNINGS
600+#endif
590601 }
591602 return 1;
592603 }
libavcodec/utils.c+4−4
@@ -2480,10 +2480,10 @@ void avsubtitle_free(AVSubtitle *sub) · 2479 unmodified lines
24802480 int i;
24812481
24822482 for (i = 0; i < sub->num_rects; i++) {
2483− av_freep(&sub->rects[i]->pict.data[0]);
2484− av_freep(&sub->rects[i]->pict.data[1]);
2485− av_freep(&sub->rects[i]->pict.data[2]);
2486− av_freep(&sub->rects[i]->pict.data[3]);
2483+ av_freep(&sub->rects[i]->data[0]);
2484+ av_freep(&sub->rects[i]->data[1]);
2485+ av_freep(&sub->rects[i]->data[2]);
2486+ av_freep(&sub->rects[i]->data[3]);
24872487 av_freep(&sub->rects[i]->text);
24882488 av_freep(&sub->rects[i]->ass);
24892489 av_freep(&sub->rects[i]);
libavcodec/version.h+4−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/version.h"
3030
3131 #define LIBAVCODEC_VERSION_MAJOR 57
32−#define LIBAVCODEC_VERSION_MINOR 8
32+#define LIBAVCODEC_VERSION_MINOR 9
3333 #define LIBAVCODEC_VERSION_MICRO 100
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -188,5 +188,8 @@ · 152 unmodified lines
188188 #ifndef FF_API_CONVERGENCE_DURATION
189189 #define FF_API_CONVERGENCE_DURATION (LIBAVCODEC_VERSION_MAJOR < 59)
190190 #endif
191+#ifndef FF_API_AVPICTURE
192+#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
193+#endif
191194
192195 #endif /* AVCODEC_VERSION_H */
libavcodec/xsubdec.c+23−11
@@ -57,6 +57,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 56 unmodified lines
5757 int64_t packet_time = 0;
5858 GetBitContext gb;
5959 int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A');
60+ AVSubtitleRect *rect;
61+ int j;
6062
6163 // check that at least header fits
6264 if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) {
@@ -104,13 +106,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 41 unmodified lines
104106 sub->rects[0]->x = x; sub->rects[0]->y = y;
105107 sub->rects[0]->w = w; sub->rects[0]->h = h;
106108 sub->rects[0]->type = SUBTITLE_BITMAP;
107− sub->rects[0]->pict.linesize[0] = w;
108− sub->rects[0]->pict.data[0] = av_malloc(w * h);
109+ sub->rects[0]->linesize[0] = w;
110+ sub->rects[0]->data[0] = av_malloc(w * h);
109111 sub->rects[0]->nb_colors = 4;
110− sub->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
111− if (!sub->rects[0]->pict.data[0] || !sub->rects[0]->pict.data[1]) {
112− av_freep(&sub->rects[0]->pict.data[1]);
113− av_freep(&sub->rects[0]->pict.data[0]);
112+ sub->rects[0]->data[1] = av_mallocz(AVPALETTE_SIZE);
113+ if (!sub->rects[0]->data[0] || !sub->rects[0]->data[1]) {
114+ av_freep(&sub->rects[0]->data[1]);
115+ av_freep(&sub->rects[0]->data[0]);
114116 av_freep(&sub->rects[0]);
115117 av_freep(&sub->rects);
116118 return AVERROR(ENOMEM);
@@ -119,23 +121,33 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, · 2 unmodified lines
119121
120122 // read palette
121123 for (i = 0; i < sub->rects[0]->nb_colors; i++)
122− ((uint32_t*)sub->rects[0]->pict.data[1])[i] = bytestream_get_be24(&buf);
124+ ((uint32_t*)sub->rects[0]->data[1])[i] = bytestream_get_be24(&buf);
123125
124126 if (!has_alpha) {
125127 // make all except background (first entry) non-transparent
126128 for (i = 1; i < sub->rects[0]->nb_colors; i++)
127− ((uint32_t *)sub->rects[0]->pict.data[1])[i] |= 0xff000000;
129+ ((uint32_t *)sub->rects[0]->data[1])[i] |= 0xff000000;
128130 } else {
129131 for (i = 0; i < sub->rects[0]->nb_colors; i++)
130− ((uint32_t *)sub->rects[0]->pict.data[1])[i] |= *buf++ << 24;
132+ ((uint32_t *)sub->rects[0]->data[1])[i] |= *buf++ << 24;
131133 }
132134
135+#if FF_API_AVPICTURE
136+FF_DISABLE_DEPRECATION_WARNINGS
137+ rect = sub->rects[0];
138+ for (j = 0; j < 4; j++) {
139+ rect->pict.data[j] = rect->data[j];
140+ rect->pict.linesize[j] = rect->linesize[j];
141+ }
142+FF_ENABLE_DEPRECATION_WARNINGS
143+#endif
144+
133145 // process RLE-compressed data
134146 init_get_bits(&gb, buf, (buf_end - buf) * 8);
135− bitmap = sub->rects[0]->pict.data[0];
147+ bitmap = sub->rects[0]->data[0];
136148 for (y = 0; y < h; y++) {
137149 // interlaced: do odd lines
138− if (y == (h + 1) / 2) bitmap = sub->rects[0]->pict.data[0] + w;
150+ if (y == (h + 1) / 2) bitmap = sub->rects[0]->data[0] + w;
139151 for (x = 0; x < w; ) {
140152 int log2 = ff_log2_tab[show_bits(&gb, 8)];
141153 int run = get_bits(&gb, 14 - 4 * (log2 >> 1));
libavcodec/xsubenc.c+20−7
@@ -131,8 +131,21 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, · 130 unmodified lines
131131 if (h->num_rects != 1)
132132 av_log(avctx, AV_LOG_WARNING, "Only single rects supported (%d in subtitle.)\n", h->num_rects);
133133
134+#if FF_API_AVPICTURE
135+FF_DISABLE_DEPRECATION_WARNINGS
136+ if (!h->rects[0]->data[0]) {
137+ AVSubtitleRect *rect = h->rects[0];
138+ int j;
139+ for (j = 0; j < 4; j++) {
140+ rect->data[j] = rect->pict.data[j];
141+ rect->linesize[j] = rect->pict.linesize[j];
142+ }
143+ }
144+FF_ENABLE_DEPRECATION_WARNINGS
145+#endif
146+
134147 // TODO: render text-based subtitles into bitmaps
135− if (!h->rects[0]->pict.data[0] || !h->rects[0]->pict.data[1]) {
148+ if (!h->rects[0]->data[0] || !h->rects[0]->data[1]) {
136149 av_log(avctx, AV_LOG_WARNING, "No subtitle bitmap available.\n");
137150 return -1;
138151 }
@@ -142,7 +155,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, · 3 unmodified lines
142155 av_log(avctx, AV_LOG_WARNING, "No more than 4 subtitle colors supported (%d found.)\n", h->rects[0]->nb_colors);
143156
144157 // TODO: Palette swapping if color zero is not transparent
145− if (((uint32_t *)h->rects[0]->pict.data[1])[0] & 0xff000000)
158+ if (((uint32_t *)h->rects[0]->data[1])[0] & 0xff000000)
146159 av_log(avctx, AV_LOG_WARNING, "Color index 0 is not transparent. Transparency will be messed up.\n");
147160
148161 if (make_tc(startTime, start_tc) || make_tc(endTime, end_tc)) {
@@ -174,19 +187,19 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, · 25 unmodified lines
174187
175188 // Palette
176189 for (i=0; i<4; i++)
177− bytestream_put_be24(&hdr, ((uint32_t *)h->rects[0]->pict.data[1])[i]);
190+ bytestream_put_be24(&hdr, ((uint32_t *)h->rects[0]->data[1])[i]);
178191
179192 // Bitmap
180193 // RLE buffer. Reserve 2 bytes for possible padding after the last row.
181194 init_put_bits(&pb, hdr, bufsize - (hdr - buf) - 2);
182− if (xsub_encode_rle(&pb, h->rects[0]->pict.data[0],
183− h->rects[0]->pict.linesize[0]*2,
195+ if (xsub_encode_rle(&pb, h->rects[0]->data[0],
196+ h->rects[0]->linesize[0] * 2,
184197 h->rects[0]->w, (h->rects[0]->h + 1) >> 1))
185198 return -1;
186199 bytestream_put_le16(&rlelenptr, put_bits_count(&pb) >> 3); // Length of first field
187200
188− if (xsub_encode_rle(&pb, h->rects[0]->pict.data[0] + h->rects[0]->pict.linesize[0],
189− h->rects[0]->pict.linesize[0]*2,
201+ if (xsub_encode_rle(&pb, h->rects[0]->data[0] + h->rects[0]->linesize[0],
202+ h->rects[0]->linesize[0] * 2,
190203 h->rects[0]->w, h->rects[0]->h >> 1))
191204 return -1;
192205

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t