Revision 0bf79634 libavcodec/h264.c

View differences:

libavcodec/h264.c
3477 3477
    int first_mb_in_slice, pps_id;
3478 3478
    int num_ref_idx_active_override_flag;
3479 3479
    static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
3480
    int slice_type;
3481
    int default_ref_list_done = 0;
3480 3482

  
3481 3483
    s->current_picture.reference= h->nal_ref_idc != 0;
3482 3484

  
3483 3485
    first_mb_in_slice= get_ue_golomb(&s->gb);
3484 3486

  
3485
    h->slice_type= get_ue_golomb(&s->gb);
3486
    if(h->slice_type > 9){
3487
    slice_type= get_ue_golomb(&s->gb);
3488
    if(slice_type > 9){
3487 3489
        av_log(h->s.avctx, AV_LOG_ERROR, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y);
3488 3490
        return -1;
3489 3491
    }
3490
    if(h->slice_type > 4){
3491
        h->slice_type -= 5;
3492
    if(slice_type > 4){
3493
        slice_type -= 5;
3492 3494
        h->slice_type_fixed=1;
3493 3495
    }else
3494 3496
        h->slice_type_fixed=0;
3495 3497
    
3496
    h->slice_type= slice_type_map[ h->slice_type ];
3497
    
3498
    slice_type= slice_type_map[ slice_type ];
3499
    if (slice_type == I_TYPE
3500
        || (h->slice_num != 0 && slice_type == h->slice_type) ) {
3501
        default_ref_list_done = 1;
3502
    }
3503
    h->slice_type= slice_type;
3504

  
3498 3505
    s->pict_type= h->slice_type; // to make a few old func happy, its wrong though
3499 3506
        
3500 3507
    pps_id= get_ue_golomb(&s->gb);
......
3623 3630
        }
3624 3631
    }
3625 3632

  
3626
    if(h->slice_num == 0){
3633
    if(!default_ref_list_done){
3627 3634
        fill_default_ref_list(h);
3628 3635
    }
3629 3636

  
......
4342 4349
    if(intra_slice){
4343 4350
        MpegEncContext * const s = &h->s;
4344 4351
        const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
4352
        const int mba_xy = mb_xy - 1;
4353
        const int mbb_xy = mb_xy - s->mb_stride;
4345 4354
        int ctx=0;
4346
        if( s->mb_x > 0 && !IS_INTRA4x4( s->current_picture.mb_type[mb_xy-1] ) )
4355
        if( h->slice_table[mba_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mba_xy] ) )
4347 4356
            ctx++;
4348
        if( s->mb_y > 0 && !IS_INTRA4x4( s->current_picture.mb_type[mb_xy-s->mb_stride] ) )
4357
        if( h->slice_table[mbb_xy] == h->slice_num && !IS_INTRA4x4( s->current_picture.mb_type[mbb_xy] ) )
4349 4358
            ctx++;
4350 4359
        if( get_cabac( &h->cabac, &state[ctx] ) == 0 )
4351 4360
            return 0;   /* I4x4 */
......
4399 4408
        }
4400 4409
    } else if( h->slice_type == B_TYPE ) {
4401 4410
        const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
4411
        const int mba_xy = mb_xy - 1;
4412
        const int mbb_xy = mb_xy - s->mb_stride;
4402 4413
        int ctx = 0;
4403 4414
        int bits;
4404 4415

  
4405
        if( s->mb_x > 0 && !IS_SKIP( s->current_picture.mb_type[mb_xy-1] )
4406
                      && !IS_DIRECT( s->current_picture.mb_type[mb_xy-1] ) )
4416
        if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] )
4417
                      && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) )
4407 4418
            ctx++;
4408
        if( s->mb_y > 0 && !IS_SKIP( s->current_picture.mb_type[mb_xy-s->mb_stride] )
4409
                      && !IS_DIRECT( s->current_picture.mb_type[mb_xy-s->mb_stride] ) )
4419
        if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] )
4420
                      && !IS_DIRECT( s->current_picture.mb_type[mbb_xy] ) )
4410 4421
            ctx++;
4411 4422

  
4412 4423
        if( !get_cabac( &h->cabac, &h->cabac_state[27+ctx] ) )
......
4444 4455
    const int mbb_xy = mb_xy - s->mb_stride;
4445 4456
    int ctx = 0;
4446 4457

  
4447
    if( s->mb_x > 0 && !IS_SKIP( s->current_picture.mb_type[mba_xy] ) )
4458
    if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] ))
4448 4459
        ctx++;
4449
    if( s->mb_y > 0 && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ) )
4460
    if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ))
4450 4461
        ctx++;
4451 4462

  
4452 4463
    if( h->slice_type == P_TYPE || h->slice_type == SP_TYPE)
......
4482 4493
    int ctx = 0;
4483 4494

  
4484 4495
    /* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_mode_table to 0 */
4485
    if( s->mb_x > 0 && h->chroma_pred_mode_table[mba_xy] != 0 )
4496
    if( h->slice_table[mba_xy] == h->slice_num && h->chroma_pred_mode_table[mba_xy] != 0 )
4486 4497
        ctx++;
4487 4498

  
4488
    if( s->mb_y > 0 && h->chroma_pred_mode_table[mbb_xy] != 0 )
4499
    if( h->slice_table[mbb_xy] == h->slice_num && h->chroma_pred_mode_table[mbb_xy] != 0 )
4489 4500
        ctx++;
4490 4501

  
4491 4502
    if( get_cabac( &h->cabac, &h->cabac_state[64+ctx] ) == 0 )
......
4532 4543

  
4533 4544
        if( x > 0 )
4534 4545
            mba_xy = mb_xy;
4535
        else if( s->mb_x > 0 )
4546
        else if( s->mb_x > 0 ) {
4536 4547
            mba_xy = mb_xy - 1;
4548
            if (h->slice_table[mba_xy] != h->slice_num) {
4549
                mba_xy = -1;
4550
            }
4551
        }
4537 4552

  
4538 4553
        if( y > 0 )
4539 4554
            mbb_xy = mb_xy;
4540
        else if( s->mb_y > 0 )
4555
        else if( s->mb_y > 0 ) {
4541 4556
            mbb_xy = mb_xy - s->mb_stride;
4557
            if (h->slice_table[mbb_xy] != h->slice_num) {
4558
                mbb_xy = -1;
4559
            }
4560
        }
4542 4561

  
4543 4562
        /* No need to test for skip as we put 0 for skip block */
4544 4563
        if( mba_xy >= 0 ) {
......
4589 4608
    else
4590 4609
        mbn_xy = s->mb_width - 1 + (s->mb_y-1)*s->mb_stride;
4591 4610

  
4592
    if( mbn_xy >= 0 && h->last_qscale_diff != 0 && ( IS_INTRA16x16(s->current_picture.mb_type[mbn_xy] ) || (h->cbp_table[mbn_xy]&0x3f) ) )
4611
    if( h->last_qscale_diff != 0 && ( IS_INTRA16x16(s->current_picture.mb_type[mbn_xy] ) || (h->cbp_table[mbn_xy]&0x3f) ) )
4593 4612
        ctx++;
4594 4613

  
4595 4614
    while( get_cabac( &h->cabac, &h->cabac_state[60 + ctx] ) ) {

Also available in: Unified diff