Revision 396a5e68 libavcodec/snow.c

View differences:

libavcodec/snow.c
439 439
    int always_reset;
440 440
    int version;
441 441
    int spatial_decomposition_type;
442
    int last_spatial_decomposition_type;
442 443
    int temporal_decomposition_type;
443 444
    int spatial_decomposition_count;
444 445
    int temporal_decomposition_count;
......
452 453
    int chroma_v_shift;
453 454
    int spatial_scalability;
454 455
    int qlog;
456
    int last_qlog;
455 457
    int lambda;
456 458
    int lambda2;
457 459
    int pass1_rc;
458 460
    int mv_scale;
461
    int last_mv_scale;
459 462
    int qbias;
463
    int last_qbias;
460 464
#define QBIAS_SHIFT 3
461 465
    int b_width;
462 466
    int b_height;
463 467
    int block_max_depth;
468
    int last_block_max_depth;
464 469
    Plane plane[MAX_PLANES];
465 470
    BlockNode *block;
466 471
#define ME_CACHE_SIZE 1024
......
1849 1854
    return;
1850 1855
}
1851 1856

  
1852
static void reset_contexts(SnowContext *s){
1857
static void reset_contexts(SnowContext *s){ //FIXME better initial contexts
1853 1858
    int plane_index, level, orientation;
1854 1859

  
1855 1860
    for(plane_index=0; plane_index<3; plane_index++){
......
3603 3608
    memset(kstate, MID_STATE, sizeof(kstate));
3604 3609

  
3605 3610
    put_rac(&s->c, kstate, s->keyframe);
3606
    if(s->keyframe || s->always_reset)
3611
    if(s->keyframe || s->always_reset){
3607 3612
        reset_contexts(s);
3613
        s->last_spatial_decomposition_type=
3614
        s->last_qlog=
3615
        s->last_qbias=
3616
        s->last_mv_scale=
3617
        s->last_block_max_depth= 0;
3618
    }
3608 3619
    if(s->keyframe){
3609 3620
        put_symbol(&s->c, s->header_state, s->version, 0);
3610 3621
        put_rac(&s->c, s->header_state, s->always_reset);
......
3627 3638
            }
3628 3639
        }
3629 3640
    }
3630
    put_symbol(&s->c, s->header_state, s->spatial_decomposition_type, 0);
3631
    put_symbol(&s->c, s->header_state, s->qlog, 1);
3632
    put_symbol(&s->c, s->header_state, s->mv_scale, 0);
3633
    put_symbol(&s->c, s->header_state, s->qbias, 1);
3634
    put_symbol(&s->c, s->header_state, s->block_max_depth, 0);
3641
    put_symbol(&s->c, s->header_state, s->spatial_decomposition_type - s->last_spatial_decomposition_type, 1);
3642
    put_symbol(&s->c, s->header_state, s->qlog            - s->last_qlog    , 1);
3643
    put_symbol(&s->c, s->header_state, s->mv_scale        - s->last_mv_scale, 1);
3644
    put_symbol(&s->c, s->header_state, s->qbias           - s->last_qbias   , 1);
3645
    put_symbol(&s->c, s->header_state, s->block_max_depth - s->last_block_max_depth, 1);
3646

  
3647
    s->last_spatial_decomposition_type= s->spatial_decomposition_type;
3648
    s->last_qlog                      = s->qlog;
3649
    s->last_qbias                     = s->qbias;
3650
    s->last_mv_scale                  = s->mv_scale;
3651
    s->last_block_max_depth           = s->block_max_depth;
3635 3652
}
3636 3653

  
3637 3654
static int decode_header(SnowContext *s){
......
3641 3658
    memset(kstate, MID_STATE, sizeof(kstate));
3642 3659

  
3643 3660
    s->keyframe= get_rac(&s->c, kstate);
3644
    if(s->keyframe || s->always_reset)
3661
    if(s->keyframe || s->always_reset){
3645 3662
        reset_contexts(s);
3663
        s->spatial_decomposition_type=
3664
        s->qlog=
3665
        s->qbias=
3666
        s->mv_scale=
3667
        s->block_max_depth= 0;
3668
    }
3646 3669
    if(s->keyframe){
3647 3670
        s->version= get_symbol(&s->c, s->header_state, 0);
3648 3671
        if(s->version>0){
......
3673 3696
        }
3674 3697
    }
3675 3698

  
3676
    s->spatial_decomposition_type= get_symbol(&s->c, s->header_state, 0);
3699
    s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1);
3677 3700
    if(s->spatial_decomposition_type > 2){
3678 3701
        av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported", s->spatial_decomposition_type);
3679 3702
        return -1;
3680 3703
    }
3681 3704

  
3682
    s->qlog= get_symbol(&s->c, s->header_state, 1);
3683
    s->mv_scale= get_symbol(&s->c, s->header_state, 0);
3684
    s->qbias= get_symbol(&s->c, s->header_state, 1);
3685
    s->block_max_depth= get_symbol(&s->c, s->header_state, 0);
3705
    s->qlog           += get_symbol(&s->c, s->header_state, 1);
3706
    s->mv_scale       += get_symbol(&s->c, s->header_state, 1);
3707
    s->qbias          += get_symbol(&s->c, s->header_state, 1);
3708
    s->block_max_depth+= get_symbol(&s->c, s->header_state, 1);
3686 3709
    if(s->block_max_depth > 1 || s->block_max_depth < 0){
3687 3710
        av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large", s->block_max_depth);
3688 3711
        s->block_max_depth= 0;
......
4170 4193
            pict->pict_type= FF_I_TYPE;
4171 4194
            s->keyframe=1;
4172 4195
            s->current_picture.key_frame=1;
4173
            reset_contexts(s);
4174 4196
            goto redo_frame;
4175 4197
        }
4176 4198

  

Also available in: Unified diff