Revision 5e5c247a libavcodec/mpeg12.c

View differences:

libavcodec/mpeg12.c
1010 1010
#define MT_DMV   3
1011 1011

  
1012 1012
static int mpeg_decode_mb(MpegEncContext *s,
1013
                          DCTELEM block[6][64])
1013
                          DCTELEM block[12][64])
1014 1014
{
1015 1015
    int i, j, k, cbp, val, mb_type, motion_type;
1016 1016
    
......
1026 1026
    
1027 1027
        /* skip mb */
1028 1028
        s->mb_intra = 0;
1029
        for(i=0;i<6;i++)
1029
        for(i=0;i<12;i++)
1030 1030
            s->block_last_index[i] = -1;
1031 1031
        if(s->picture_structure == PICT_FRAME)
1032 1032
            s->mv_type = MV_TYPE_16X16;
......
1126 1126
#endif
1127 1127

  
1128 1128
        if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
1129
            for(i=0;i<6;i++) {
1129
            for(i=0;i<4+(1<<s->chroma_format);i++) {
1130 1130
                if (mpeg2_decode_block_intra(s, s->pblocks[i], i) < 0)
1131 1131
                    return -1;
1132 1132
            }
......
1311 1311
                return -1;
1312 1312
            }
1313 1313
            cbp++;
1314
            if(s->chroma_format == 2){//CHROMA422
1315
                 cbp|= ( get_bits(&s->gb,2) ) << 6;
1316
            }else
1317
            if(s->chroma_format >  2){//CHROMA444
1318
                 cbp|= ( get_bits(&s->gb,6) ) << 6;
1319
            }
1314 1320

  
1315 1321
#ifdef HAVE_XVMC
1316 1322
            //on 1 we memcpy blocks in xvmcvideo
......
1324 1330

  
1325 1331
            if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
1326 1332
                for(i=0;i<6;i++) {
1327
                    if (cbp & 32) {
1333
                    if (cbp & (1<<(5-i)) ) {
1328 1334
                        if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
1329 1335
                            return -1;
1330 1336
                    } else {
1331 1337
                        s->block_last_index[i] = -1;
1332 1338
                    }
1333
                    cbp+=cbp;
1339
                }
1340
                if (s->chroma_format >= 2) {
1341
                    if (s->chroma_format == 2) {//CHROMA_422)
1342
                        for(i=6;i<8;i++) {
1343
                            if (cbp & (1<<(6+7-i)) ) {
1344
                                if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
1345
                                    return -1;
1346
                            } else {
1347
                                s->block_last_index[i] = -1;
1348
                            }
1349
                        }
1350
                    }else{ /*CHROMA_444*/
1351
                        for(i=6;i<12;i++) {
1352
                            if (cbp & (1<<(6+11-i)) ) {
1353
                                if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
1354
                                    return -1;
1355
                            } else {
1356
                                s->block_last_index[i] = -1;
1357
                            }
1358
                        }
1359
                    }
1334 1360
                }
1335 1361
            } else {
1336 1362
                for(i=0;i<6;i++) {
......
1654 1680
        component = 0; 
1655 1681
    }else{
1656 1682
        quant_matrix = s->chroma_intra_matrix;
1657
        component = n - 3;
1683
        component = (n&1) + 1;
1658 1684
    }
1659 1685
    diff = decode_dc(&s->gb, component);
1660 1686
    if (diff >= 0xffff)
......
1817 1843
    profile= get_bits(&s->gb, 3);
1818 1844
    level= get_bits(&s->gb, 4);
1819 1845
    s->progressive_sequence = get_bits1(&s->gb); /* progressive_sequence */
1820
    skip_bits(&s->gb, 2); /* chroma_format */
1846
    s->chroma_format = get_bits(&s->gb, 2); /* chroma_format 1=420, 2=422, 3=444 */
1821 1847
    horiz_size_ext = get_bits(&s->gb, 2);
1822 1848
    vert_size_ext = get_bits(&s->gb, 2);
1823 1849
    s->width |= (horiz_size_ext << 12);
1824 1850
    s->height |= (vert_size_ext << 12);
1825 1851
    bit_rate_ext = get_bits(&s->gb, 12);  /* XXX: handle it */
1826
    s->bit_rate = ((s->bit_rate / 400) | (bit_rate_ext << 12)) * 400;
1852
    s->bit_rate += (bit_rate_ext << 12) * 400;
1827 1853
    skip_bits1(&s->gb); /* marker */
1828 1854
    s->avctx->rc_buffer_size += get_bits(&s->gb, 8)*1024*16<<10;
1829 1855

  
......
2556 2582
    }
2557 2583
}
2558 2584

  
2585
static void mpeg_decode_gop(AVCodecContext *avctx, 
2586
                            uint8_t *buf, int buf_size){
2587
    Mpeg1Context *s1 = avctx->priv_data;
2588
    MpegEncContext *s = &s1->mpeg_enc_ctx;
2589

  
2590
    int drop_frame_flag;
2591
    int time_code_hours, time_code_minutes;
2592
    int time_code_seconds, time_code_pictures;
2593
    int broken_link;
2594

  
2595
    s->first_field = 0;
2596

  
2597
    init_get_bits(&s->gb, buf, buf_size*8);
2598

  
2599
    drop_frame_flag = get_bits1(&s->gb);
2600
    
2601
    time_code_hours=get_bits(&s->gb,5);
2602
    time_code_minutes = get_bits(&s->gb,6);
2603
    skip_bits1(&s->gb);//marker bit
2604
    time_code_seconds = get_bits(&s->gb,6);
2605
    time_code_pictures = get_bits(&s->gb,6);
2606
    /*broken_link indicate that after editing the
2607
      reference frames of the first B-Frames after GOP I-Frame
2608
      are missing (open gop)*/
2609
    broken_link = get_bits1(&s->gb);
2610
    if(broken_link == 1){
2611
//        avcodec_flush_buffers(avctx);
2612
        ff_mpeg_flush(avctx);
2613
    }
2614
}
2615

  
2559 2616
/**
2560 2617
 * finds the end of the current frame in the bitstream.
2561 2618
 * @return the position of the first byte of the next frame, or -1
......
2692 2749
                                          buf_ptr, input_size);
2693 2750
                    break;
2694 2751
                case GOP_START_CODE:
2695
                    s2->first_field=0;
2752
    	            mpeg_decode_gop(avctx, buf_ptr, input_size);
2696 2753
                    break;
2697 2754
                default:
2698 2755
                    if (start_code >= SLICE_MIN_START_CODE &&
......
2850 2907
    NULL,
2851 2908
    mpeg_decode_end,
2852 2909
    mpeg_decode_frame,
2853
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED,
2910
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL,
2911
    .flush= ff_mpeg_flush,
2854 2912
};
2855 2913

  
2856 2914
#endif

Also available in: Unified diff