Revision 3c90abf4

View differences:

libavcodec/vp3.c
1511 1511
    vp3_draw_horiz_band(s, FFMIN((32 << s->chroma_y_shift) * (slice + 1) -16, s->height-16));
1512 1512
}
1513 1513

  
1514
/// Allocate tables for per-frame data in Vp3DecodeContext
1515
static av_cold int allocate_tables(AVCodecContext *avctx)
1516
{
1517
    Vp3DecodeContext *s = avctx->priv_data;
1518
    int y_fragment_count, c_fragment_count;
1519

  
1520
    y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
1521
    c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
1522

  
1523
    s->superblock_coding = av_malloc(s->superblock_count);
1524
    s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
1525
    s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
1526
    s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base));
1527
    s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
1528
    s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
1529

  
1530
    /* work out the block mapping tables */
1531
    s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
1532
    s->macroblock_coding = av_malloc(s->macroblock_count + 1);
1533

  
1534
    if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base ||
1535
        !s->coded_fragment_list[0] || !s->superblock_fragments || !s->macroblock_coding ||
1536
        !s->motion_val[0] || !s->motion_val[1]) {
1537
        vp3_decode_end(avctx);
1538
        return -1;
1539
    }
1540

  
1541
    init_block_mapping(s);
1542

  
1543
    return 0;
1544
}
1545

  
1514 1546
/*
1515 1547
 * This is the ffmpeg/libavcodec API init function.
1516 1548
 */
......
1560 1592
    s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2);
1561 1593
    s->u_superblock_start = s->y_superblock_count;
1562 1594
    s->v_superblock_start = s->u_superblock_start + s->c_superblock_count;
1563
    s->superblock_coding = av_malloc(s->superblock_count);
1564 1595

  
1565 1596
    s->macroblock_width = (s->width + 15) / 16;
1566 1597
    s->macroblock_height = (s->height + 15) / 16;
......
1578 1609
    s->fragment_start[1] = y_fragment_count;
1579 1610
    s->fragment_start[2] = y_fragment_count + c_fragment_count;
1580 1611

  
1581
    s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
1582
    s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
1583
    s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base));
1584
    s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
1585
    s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
1586

  
1587
    if (!s->superblock_coding || !s->all_fragments || !s->dct_tokens_base ||
1588
        !s->coded_fragment_list[0] || !s->motion_val[0] || !s->motion_val[1]) {
1589
        vp3_decode_end(avctx);
1590
        return -1;
1591
    }
1592

  
1593 1612
    if (!s->theora_tables)
1594 1613
    {
1595 1614
        for (i = 0; i < 64; i++) {
......
1689 1708
        &motion_vector_vlc_table[0][1], 2, 1,
1690 1709
        &motion_vector_vlc_table[0][0], 2, 1, 0);
1691 1710

  
1692
    /* work out the block mapping tables */
1693
    s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
1694
    s->macroblock_coding = av_malloc(s->macroblock_count + 1);
1695
    if (!s->superblock_fragments || !s->macroblock_coding) {
1696
        vp3_decode_end(avctx);
1697
        return -1;
1698
    }
1699
    init_block_mapping(s);
1700

  
1701 1711
    for (i = 0; i < 3; i++) {
1702 1712
        s->current_frame.data[i] = NULL;
1703 1713
        s->last_frame.data[i] = NULL;
1704 1714
        s->golden_frame.data[i] = NULL;
1705 1715
    }
1706 1716

  
1707
    return 0;
1717
    return allocate_tables(avctx);
1708 1718

  
1709 1719
vlc_fail:
1710 1720
    av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");

Also available in: Unified diff