~ubuntu-branches/ubuntu/trusty/libav/trusty-proposed

« back to all changes in this revision

Viewing changes to libavcodec/pgssubdec.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2013-10-22 23:24:08 UTC
  • mfrom: (1.3.36 sid)
  • Revision ID: package-import@ubuntu.com-20131022232408-b8tvvn4pyzri9mi3
Tags: 6:9.10-1ubuntu1
* Build all -extra flavors from this source package, as libav got demoted
  from main to universe, cf LP: #1243235
* Simplify debian/rules to follow exactly the code that debian executes
* New upstream (LP: #1180288) fixes lots of security issues (LP: #1242802)
* Merge from unstable, remaining changes:
  - build-depend on libtiff5-dev rather than libtiff4-dev,
    avoids FTBFS caused by imlib
  - follow the regular debian codepaths

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    int y;
46
46
    int id_number;
47
47
    int object_number;
 
48
    uint8_t composition_flag;
 
49
    int64_t pts;
48
50
} PGSSubPresentation;
49
51
 
50
52
typedef struct PGSSubPicture {
63
65
 
64
66
static av_cold int init_decoder(AVCodecContext *avctx)
65
67
{
66
 
    avctx->pix_fmt = PIX_FMT_PAL8;
 
68
    avctx->pix_fmt = AV_PIX_FMT_PAL8;
67
69
 
68
70
    return 0;
69
71
}
271
273
 * @todo TODO: Implement forcing of subtitles
272
274
 */
273
275
static void parse_presentation_segment(AVCodecContext *avctx,
274
 
                                       const uint8_t *buf, int buf_size)
 
276
                                       const uint8_t *buf, int buf_size,
 
277
                                       int64_t pts)
275
278
{
276
279
    PGSSubContext *ctx = avctx->priv_data;
277
280
 
280
283
    int w = bytestream_get_be16(&buf);
281
284
    int h = bytestream_get_be16(&buf);
282
285
 
 
286
    ctx->presentation.pts = pts;
 
287
 
283
288
    av_dlog(avctx, "Video Dimensions %dx%d\n",
284
289
            w, h);
285
290
    if (av_image_check_size(w, h, 0, avctx) >= 0)
299
304
    buf += 3;
300
305
 
301
306
    ctx->presentation.object_number = bytestream_get_byte(&buf);
 
307
    ctx->presentation.composition_flag = 0;
302
308
    if (!ctx->presentation.object_number)
303
309
        return;
304
310
 
305
311
    /*
306
 
     * Skip 4 bytes of unknown:
 
312
     * Skip 3 bytes of unknown:
307
313
     *     object_id_ref (2 bytes),
308
314
     *     window_id_ref,
309
 
     *     composition_flag (0x80 - object cropped, 0x40 - object forced)
310
315
     */
311
 
    buf += 4;
 
316
    buf += 3;
 
317
    ctx->presentation.composition_flag = bytestream_get_byte(&buf);
312
318
 
313
319
    x = bytestream_get_be16(&buf);
314
320
    y = bytestream_get_be16(&buf);
356
362
     */
357
363
 
358
364
    memset(sub, 0, sizeof(*sub));
 
365
    sub->pts = ctx->presentation.pts;
 
366
 
359
367
    // Blank if last object_number was 0.
360
368
    // Note that this may be wrong for more complex subtitles.
361
369
    if (!ctx->presentation.object_number)
368
376
    sub->rects[0]  = av_mallocz(sizeof(*sub->rects[0]));
369
377
    sub->num_rects = 1;
370
378
 
 
379
    if (ctx->presentation.composition_flag & 0x40)
 
380
        sub->rects[0]->flags |= AV_SUBTITLE_FLAG_FORCED;
 
381
 
371
382
    sub->rects[0]->x    = ctx->presentation.x;
372
383
    sub->rects[0]->y    = ctx->presentation.y;
373
384
    sub->rects[0]->w    = ctx->picture.w;
441
452
            parse_picture_segment(avctx, buf, segment_length);
442
453
            break;
443
454
        case PRESENTATION_SEGMENT:
444
 
            parse_presentation_segment(avctx, buf, segment_length);
 
455
            parse_presentation_segment(avctx, buf, segment_length, avpkt->pts);
445
456
            break;
446
457
        case WINDOW_SEGMENT:
447
458
            /*
448
459
             * Window Segment Structure (No new information provided):
449
 
             *     2 bytes: Unkown,
 
460
             *     2 bytes: Unknown,
450
461
             *     2 bytes: X position of subtitle,
451
462
             *     2 bytes: Y position of subtitle,
452
463
             *     2 bytes: Width of subtitle,
471
482
AVCodec ff_pgssub_decoder = {
472
483
    .name           = "pgssub",
473
484
    .type           = AVMEDIA_TYPE_SUBTITLE,
474
 
    .id             = CODEC_ID_HDMV_PGS_SUBTITLE,
 
485
    .id             = AV_CODEC_ID_HDMV_PGS_SUBTITLE,
475
486
    .priv_data_size = sizeof(PGSSubContext),
476
487
    .init           = init_decoder,
477
488
    .close          = close_decoder,
478
489
    .decode         = decode,
479
 
    .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
 
490
    .long_name      = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
480
491
};