~ubuntu-branches/ubuntu/quantal/libav/quantal-updates

« back to all changes in this revision

Viewing changes to libavcodec/rv34.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-03-21 21:18:24 UTC
  • mfrom: (1.2.10)
  • Revision ID: package-import@ubuntu.com-20120321211824-n63p3v3s99q3mxrb
Tags: 4:0.8.1-0ubuntu1
* New upstream bug and security fix release (FFe: LP: #960949)
  - fixes the following CVEs:
    CVE-2012-0848, CVE-2012-0853, CVE-2012-0858, CVE-2011-3929,
    CVE-2011-3936, CVE-2011-3937, CVE-2011-3940, CVE-2011-3945,
    CVE-2011-3947, CVE-2011-3951, CVE-2011-3952

* Pull fix from Debian git to fix installation of avserver.conf and
  recordshow.sh into libav-tools; Thanks to Julien Cristau for spotting this!
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
711
711
 
712
712
    if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
713
713
        /* wait for the referenced mb row to be finished */
714
 
        int mb_row = FFMIN(s->mb_height - 1,
715
 
                           s->mb_y + ((yoff + my + 5 + 8 * height) >> 4));
 
714
        int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4);
716
715
        AVFrame *f = dir ? &s->next_picture_ptr->f : &s->last_picture_ptr->f;
717
716
        ff_thread_await_progress(f, mb_row, 0);
718
717
    }
1361
1360
    return 0;
1362
1361
}
1363
1362
 
 
1363
 
 
1364
static void rv34_decoder_free(RV34DecContext *r)
 
1365
{
 
1366
    av_freep(&r->intra_types_hist);
 
1367
    r->intra_types = NULL;
 
1368
    av_freep(&r->tmp_b_block_base);
 
1369
    av_freep(&r->mb_type);
 
1370
    av_freep(&r->cbp_luma);
 
1371
    av_freep(&r->cbp_chroma);
 
1372
    av_freep(&r->deblock_coefs);
 
1373
}
 
1374
 
 
1375
 
 
1376
static int rv34_decoder_alloc(RV34DecContext *r)
 
1377
{
 
1378
    r->intra_types_stride = r->s.mb_width * 4 + 4;
 
1379
 
 
1380
    r->cbp_chroma       = av_malloc(r->s.mb_stride * r->s.mb_height *
 
1381
                                    sizeof(*r->cbp_chroma));
 
1382
    r->cbp_luma         = av_malloc(r->s.mb_stride * r->s.mb_height *
 
1383
                                    sizeof(*r->cbp_luma));
 
1384
    r->deblock_coefs    = av_malloc(r->s.mb_stride * r->s.mb_height *
 
1385
                                    sizeof(*r->deblock_coefs));
 
1386
    r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 *
 
1387
                                    sizeof(*r->intra_types_hist));
 
1388
    r->mb_type          = av_mallocz(r->s.mb_stride * r->s.mb_height *
 
1389
                                     sizeof(*r->mb_type));
 
1390
 
 
1391
    if (!(r->cbp_chroma       && r->cbp_luma && r->deblock_coefs &&
 
1392
          r->intra_types_hist && r->mb_type)) {
 
1393
        rv34_decoder_free(r);
 
1394
        return AVERROR(ENOMEM);
 
1395
    }
 
1396
 
 
1397
    r->intra_types = r->intra_types_hist + r->intra_types_stride * 4;
 
1398
 
 
1399
    return 0;
 
1400
}
 
1401
 
 
1402
 
 
1403
static int rv34_decoder_realloc(RV34DecContext *r)
 
1404
{
 
1405
    rv34_decoder_free(r);
 
1406
    return rv34_decoder_alloc(r);
 
1407
}
 
1408
 
 
1409
 
1364
1410
static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size)
1365
1411
{
1366
1412
    MpegEncContext *s = &r->s;
1376
1422
    }
1377
1423
 
1378
1424
    if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr==NULL) {
1379
 
        if(s->width != r->si.width || s->height != r->si.height){
1380
 
            av_log(s->avctx, AV_LOG_DEBUG, "Changing dimensions to %dx%d\n", r->si.width,r->si.height);
 
1425
        if (s->width != r->si.width || s->height != r->si.height) {
 
1426
            int err;
 
1427
 
 
1428
            av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n",
 
1429
                   r->si.width, r->si.height);
1381
1430
            MPV_common_end(s);
1382
1431
            s->width  = r->si.width;
1383
1432
            s->height = r->si.height;
1384
1433
            avcodec_set_dimensions(s->avctx, s->width, s->height);
1385
 
            if(MPV_common_init(s) < 0)
1386
 
                return -1;
1387
 
            r->intra_types_stride = s->mb_width*4 + 4;
1388
 
            r->intra_types_hist = av_realloc(r->intra_types_hist, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist));
1389
 
            r->intra_types = r->intra_types_hist + r->intra_types_stride * 4;
1390
 
            r->mb_type = av_realloc(r->mb_type, r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
1391
 
            r->cbp_luma   = av_realloc(r->cbp_luma,   r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
1392
 
            r->cbp_chroma = av_realloc(r->cbp_chroma, r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
1393
 
            r->deblock_coefs = av_realloc(r->deblock_coefs, r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
1394
 
            av_freep(&r->tmp_b_block_base);
 
1434
            if ((err = MPV_common_init(s)) < 0)
 
1435
                return err;
 
1436
            if ((err = rv34_decoder_realloc(r)) < 0)
 
1437
                return err;
1395
1438
        }
1396
1439
        s->pict_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
1397
1440
        if(MPV_frame_start(s, s->avctx) < 0)
1496
1539
{
1497
1540
    RV34DecContext *r = avctx->priv_data;
1498
1541
    MpegEncContext *s = &r->s;
 
1542
    int ret;
1499
1543
 
1500
1544
    MPV_decode_defaults(s);
1501
1545
    s->avctx      = avctx;
1512
1556
    avctx->has_b_frames = 1;
1513
1557
    s->low_delay = 0;
1514
1558
 
1515
 
    if (MPV_common_init(s) < 0)
1516
 
        return -1;
 
1559
    if ((ret = MPV_common_init(s)) < 0)
 
1560
        return ret;
1517
1561
 
1518
1562
    ff_h264_pred_init(&r->h, CODEC_ID_RV40, 8, 1);
1519
1563
 
1526
1570
        ff_rv40dsp_init(&r->rdsp, &r->s.dsp);
1527
1571
#endif
1528
1572
 
1529
 
    r->intra_types_stride = 4*s->mb_stride + 4;
1530
 
    r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist));
1531
 
    r->intra_types = r->intra_types_hist + r->intra_types_stride * 4;
1532
 
 
1533
 
    r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height * sizeof(*r->mb_type));
1534
 
 
1535
 
    r->cbp_luma   = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_luma));
1536
 
    r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->cbp_chroma));
1537
 
    r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height * sizeof(*r->deblock_coefs));
 
1573
    if ((ret = rv34_decoder_alloc(r)) < 0)
 
1574
        return ret;
1538
1575
 
1539
1576
    if(!intra_vlcs[0].cbppattern[0].bits)
1540
1577
        rv34_init_tables();
1544
1581
 
1545
1582
int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
1546
1583
{
 
1584
    int err;
1547
1585
    RV34DecContext *r = avctx->priv_data;
1548
1586
 
1549
1587
    r->s.avctx = avctx;
1550
1588
 
1551
1589
    if (avctx->internal->is_copy) {
1552
 
        r->cbp_chroma       = av_malloc(r->s.mb_stride * r->s.mb_height *
1553
 
                                        sizeof(*r->cbp_chroma));
1554
 
        r->cbp_luma         = av_malloc(r->s.mb_stride * r->s.mb_height *
1555
 
                                        sizeof(*r->cbp_luma));
1556
 
        r->deblock_coefs    = av_malloc(r->s.mb_stride * r->s.mb_height *
1557
 
                                        sizeof(*r->deblock_coefs));
1558
 
        r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 *
1559
 
                                        sizeof(*r->intra_types_hist));
1560
 
        r->mb_type          = av_malloc(r->s.mb_stride * r->s.mb_height *
1561
 
                                        sizeof(*r->mb_type));
1562
 
 
1563
 
        if (!(r->cbp_chroma       && r->cbp_luma && r->deblock_coefs &&
1564
 
              r->intra_types_hist && r->mb_type)) {
1565
 
            av_freep(&r->cbp_chroma);
1566
 
            av_freep(&r->cbp_luma);
1567
 
            av_freep(&r->deblock_coefs);
1568
 
            av_freep(&r->intra_types_hist);
1569
 
            av_freep(&r->mb_type);
1570
 
            r->intra_types = NULL;
1571
 
            return AVERROR(ENOMEM);
1572
 
        }
1573
 
 
1574
 
        r->intra_types      = r->intra_types_hist + r->intra_types_stride * 4;
1575
1590
        r->tmp_b_block_base = NULL;
1576
 
 
1577
 
        memset(r->mb_type, 0,  r->s.mb_stride * r->s.mb_height *
1578
 
               sizeof(*r->mb_type));
1579
 
 
1580
 
        MPV_common_init(&r->s);
 
1591
        if ((err = MPV_common_init(&r->s)) < 0)
 
1592
            return err;
 
1593
        if ((err = rv34_decoder_alloc(r)) < 0)
 
1594
            return err;
1581
1595
    }
1582
1596
    return 0;
1583
1597
}
1591
1605
    if (dst == src || !s1->context_initialized)
1592
1606
        return 0;
1593
1607
 
 
1608
    if (s->height != s1->height || s->width != s1->width) {
 
1609
        MPV_common_end(s);
 
1610
        s->height = s1->height;
 
1611
        s->width  = s1->width;
 
1612
        if ((err = MPV_common_init(s)) < 0)
 
1613
            return err;
 
1614
        if ((err = rv34_decoder_realloc(r)) < 0)
 
1615
            return err;
 
1616
    }
 
1617
 
1594
1618
    if ((err = ff_mpeg_update_thread_context(dst, src)))
1595
1619
        return err;
1596
1620
 
1708
1732
    if(last && s->current_picture_ptr){
1709
1733
        if(r->loop_filter)
1710
1734
            r->loop_filter(r, s->mb_height - 1);
1711
 
        if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
1712
 
            ff_thread_report_progress(&s->current_picture_ptr->f,
1713
 
                                      s->mb_height - 1, 0);
1714
1735
        ff_er_frame_end(s);
1715
1736
        MPV_frame_end(s);
 
1737
 
 
1738
        if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
 
1739
            ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
 
1740
 
1716
1741
        if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
1717
1742
            *pict = *(AVFrame*)s->current_picture_ptr;
1718
1743
        } else if (s->last_picture_ptr != NULL) {
1733
1758
    RV34DecContext *r = avctx->priv_data;
1734
1759
 
1735
1760
    MPV_common_end(&r->s);
1736
 
 
1737
 
    av_freep(&r->intra_types_hist);
1738
 
    r->intra_types = NULL;
1739
 
    av_freep(&r->tmp_b_block_base);
1740
 
    av_freep(&r->mb_type);
1741
 
    av_freep(&r->cbp_luma);
1742
 
    av_freep(&r->cbp_chroma);
1743
 
    av_freep(&r->deblock_coefs);
 
1761
    rv34_decoder_free(r);
1744
1762
 
1745
1763
    return 0;
1746
1764
}