~ubuntu-branches/ubuntu/utopic/ffmpeg-debian/utopic

« back to all changes in this revision

Viewing changes to libavcodec/dvbsub.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
    for (region_id = 0; region_id < h->num_rects; region_id++) {
229
229
        *q++ = region_id;
230
230
        *q++ = 0xff; /* reserved */
231
 
        bytestream_put_be16(&q, h->rects[region_id].x); /* left pos */
232
 
        bytestream_put_be16(&q, h->rects[region_id].y); /* top pos */
 
231
        bytestream_put_be16(&q, h->rects[region_id]->x); /* left pos */
 
232
        bytestream_put_be16(&q, h->rects[region_id]->y); /* top pos */
233
233
    }
234
234
 
235
235
    bytestream_put_be16(&pseg_len, q - pseg_len - 2);
239
239
 
240
240
            /* CLUT segment */
241
241
 
242
 
            if (h->rects[clut_id].nb_colors <= 4) {
 
242
            if (h->rects[clut_id]->nb_colors <= 4) {
243
243
                /* 2 bpp, some decoders do not support it correctly */
244
244
                bpp_index = 0;
245
 
            } else if (h->rects[clut_id].nb_colors <= 16) {
 
245
            } else if (h->rects[clut_id]->nb_colors <= 16) {
246
246
                /* 4 bpp, standard encoding */
247
247
                bpp_index = 1;
248
248
            } else {
257
257
            *q++ = clut_id;
258
258
            *q++ = (0 << 4) | 0xf; /* version = 0 */
259
259
 
260
 
            for(i = 0; i < h->rects[clut_id].nb_colors; i++) {
 
260
            for(i = 0; i < h->rects[clut_id]->nb_colors; i++) {
261
261
                *q++ = i; /* clut_entry_id */
262
262
                *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1; /* 2 bits/pixel full range */
263
263
                {
264
264
                    int a, r, g, b;
265
 
                    a = (h->rects[clut_id].rgba_palette[i] >> 24) & 0xff;
266
 
                    r = (h->rects[clut_id].rgba_palette[i] >> 16) & 0xff;
267
 
                    g = (h->rects[clut_id].rgba_palette[i] >> 8) & 0xff;
268
 
                    b = (h->rects[clut_id].rgba_palette[i] >> 0) & 0xff;
 
265
                    uint32_t x= ((uint32_t*)h->rects[clut_id]->pict.data[1])[i];
 
266
                    a = (x >> 24) & 0xff;
 
267
                    r = (x >> 16) & 0xff;
 
268
                    g = (x >>  8) & 0xff;
 
269
                    b = (x >>  0) & 0xff;
269
270
 
270
271
                    *q++ = RGB_TO_Y_CCIR(r, g, b);
271
272
                    *q++ = RGB_TO_V_CCIR(r, g, b, 0);
282
283
 
283
284
        /* region composition segment */
284
285
 
285
 
        if (h->rects[region_id].nb_colors <= 4) {
 
286
        if (h->rects[region_id]->nb_colors <= 4) {
286
287
            /* 2 bpp, some decoders do not support it correctly */
287
288
            bpp_index = 0;
288
 
        } else if (h->rects[region_id].nb_colors <= 16) {
 
289
        } else if (h->rects[region_id]->nb_colors <= 16) {
289
290
            /* 4 bpp, standard encoding */
290
291
            bpp_index = 1;
291
292
        } else {
299
300
        q += 2; /* segment length */
300
301
        *q++ = region_id;
301
302
        *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */
302
 
        bytestream_put_be16(&q, h->rects[region_id].w); /* region width */
303
 
        bytestream_put_be16(&q, h->rects[region_id].h); /* region height */
 
303
        bytestream_put_be16(&q, h->rects[region_id]->w); /* region width */
 
304
        bytestream_put_be16(&q, h->rects[region_id]->h); /* region height */
304
305
        *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
305
306
        *q++ = region_id; /* clut_id == region_id */
306
307
        *q++ = 0; /* 8 bit fill colors */
322
323
        for (object_id = 0; object_id < h->num_rects; object_id++) {
323
324
            /* Object Data segment */
324
325
 
325
 
            if (h->rects[object_id].nb_colors <= 4) {
 
326
            if (h->rects[object_id]->nb_colors <= 4) {
326
327
                /* 2 bpp, some decoders do not support it correctly */
327
328
                bpp_index = 0;
328
 
            } else if (h->rects[object_id].nb_colors <= 16) {
 
329
            } else if (h->rects[object_id]->nb_colors <= 16) {
329
330
                /* 4 bpp, standard encoding */
330
331
                bpp_index = 1;
331
332
            } else {
358
359
                    dvb_encode_rle = dvb_encode_rle4;
359
360
 
360
361
                top_ptr = q;
361
 
                dvb_encode_rle(&q, h->rects[object_id].bitmap, h->rects[object_id].w * 2,
362
 
                                    h->rects[object_id].w, h->rects[object_id].h >> 1);
 
362
                dvb_encode_rle(&q, h->rects[object_id]->pict.data[0], h->rects[object_id]->w * 2,
 
363
                                    h->rects[object_id]->w, h->rects[object_id]->h >> 1);
363
364
                bottom_ptr = q;
364
 
                dvb_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w,
365
 
                                    h->rects[object_id].w * 2, h->rects[object_id].w,
366
 
                                    h->rects[object_id].h >> 1);
 
365
                dvb_encode_rle(&q, h->rects[object_id]->pict.data[0] + h->rects[object_id]->w,
 
366
                                    h->rects[object_id]->w * 2, h->rects[object_id]->w,
 
367
                                    h->rects[object_id]->h >> 1);
367
368
 
368
369
                bytestream_put_be16(&ptop_field_len, bottom_ptr - top_ptr);
369
370
                bytestream_put_be16(&pbottom_field_len, q - bottom_ptr);