Mercurial > libavcodec.hg
comparison xsubdec.c @ 8516:315b302fcd1d libavcodec
Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
author | michael |
---|---|
date | Sat, 03 Jan 2009 19:17:18 +0000 |
parents | aa45029f5cd7 |
children | 6fc3497dc81f |
comparison
equal
deleted
inserted
replaced
8515:45506d633cdc | 8516:315b302fcd1d |
---|---|
82 if (!sub->rects) { | 82 if (!sub->rects) { |
83 sub->rects = av_mallocz(sizeof(*sub->rects)); | 83 sub->rects = av_mallocz(sizeof(*sub->rects)); |
84 sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); | 84 sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); |
85 sub->num_rects = 1; | 85 sub->num_rects = 1; |
86 } | 86 } |
87 av_freep(&sub->rects[0]->bitmap); | 87 av_freep(&sub->rects[0]->pict.data[0]); |
88 sub->rects[0]->x = x; sub->rects[0]->y = y; | 88 sub->rects[0]->x = x; sub->rects[0]->y = y; |
89 sub->rects[0]->w = w; sub->rects[0]->h = h; | 89 sub->rects[0]->w = w; sub->rects[0]->h = h; |
90 sub->rects[0]->linesize = w; | 90 sub->rects[0]->pict.linesize[0] = w; |
91 sub->rects[0]->bitmap = av_malloc(w * h); | 91 sub->rects[0]->pict.data[0] = av_malloc(w * h); |
92 sub->rects[0]->nb_colors = 4; | 92 sub->rects[0]->nb_colors = 4; |
93 sub->rects[0]->rgba_palette = av_malloc(sub->rects[0]->nb_colors * 4); | 93 sub->rects[0]->pict.data[1] = av_malloc(sub->rects[0]->nb_colors * 4); |
94 | 94 |
95 // read palette | 95 // read palette |
96 for (i = 0; i < sub->rects[0]->nb_colors; i++) | 96 for (i = 0; i < sub->rects[0]->nb_colors; i++) |
97 sub->rects[0]->rgba_palette[i] = bytestream_get_be24(&buf); | 97 ((uint32_t*)sub->rects[0]->pict.data[1])[i] = bytestream_get_be24(&buf); |
98 // make all except background (first entry) non-transparent | 98 // make all except background (first entry) non-transparent |
99 for (i = 1; i < sub->rects[0]->nb_colors; i++) | 99 for (i = 1; i < sub->rects[0]->nb_colors; i++) |
100 sub->rects[0]->rgba_palette[i] |= 0xff000000; | 100 ((uint32_t*)sub->rects[0]->pict.data[1])[i] |= 0xff000000; |
101 | 101 |
102 // process RLE-compressed data | 102 // process RLE-compressed data |
103 rlelen = FFMIN(rlelen, buf_end - buf); | 103 rlelen = FFMIN(rlelen, buf_end - buf); |
104 init_get_bits(&gb, buf, rlelen * 8); | 104 init_get_bits(&gb, buf, rlelen * 8); |
105 bitmap = sub->rects[0]->bitmap; | 105 bitmap = sub->rects[0]->pict.data[0]; |
106 for (y = 0; y < h; y++) { | 106 for (y = 0; y < h; y++) { |
107 // interlaced: do odd lines | 107 // interlaced: do odd lines |
108 if (y == (h + 1) / 2) bitmap = sub->rects[0]->bitmap + w; | 108 if (y == (h + 1) / 2) bitmap = sub->rects[0]->pict.data[0] + w; |
109 for (x = 0; x < w; ) { | 109 for (x = 0; x < w; ) { |
110 int log2 = ff_log2_tab[show_bits(&gb, 8)]; | 110 int log2 = ff_log2_tab[show_bits(&gb, 8)]; |
111 int run = get_bits(&gb, 14 - 4 * (log2 >> 1)); | 111 int run = get_bits(&gb, 14 - 4 * (log2 >> 1)); |
112 int color = get_bits(&gb, 2); | 112 int color = get_bits(&gb, 2); |
113 run = FFMIN(run, w - x); | 113 run = FFMIN(run, w - x); |