Revision 43ad88e5

View differences:

libavcodec/h263.c
892 892
    PutBitContext * const dc_pb  = s->data_partitioning && s->pict_type!=FF_I_TYPE ? &s->pb2    : &s->pb;
893 893
    const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1) && !s->data_partitioning ? 1 : 0;
894 894

  
895
    //    printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
896 895
    if (!s->mb_intra) {
897 896
        int i, cbp;
898 897

  
......
1255 1254
    int16_t *dc_ptr[6];
1256 1255
    const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1);
1257 1256

  
1258
    //printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
1259 1257
    if (!s->mb_intra) {
1260 1258
        /* compute cbp */
1261 1259
        cbp= get_p_cbp(s, block, motion_x, motion_y);
......
1788 1786
        }
1789 1787
        code = ((code << 1) | (val < 0)) << 1;
1790 1788
        put_bits(&s->pb, (2*n_bits)+1, code);
1791
        //printf("\nVal = %d\tCode = %d", sval, code);
1792 1789
    }
1793 1790
}
1794 1791

  
......
2452 2449

  
2453 2450
    s->partitioned_frame= s->data_partitioning && s->pict_type!=FF_B_TYPE;
2454 2451

  
2455
//printf("num:%d rate:%d base:%d\n", s->picture_number, s->time_base.den, FRAME_RATE_BASE);
2456

  
2457 2452
    put_bits(&s->pb, 16, 0);                /* vop header */
2458 2453
    put_bits(&s->pb, 16, VOP_STARTCODE);    /* vop header */
2459 2454
    put_bits(&s->pb, 2, s->pict_type - 1);  /* pict type: I = 0 , P = 1 */
......
2489 2484
        put_bits(&s->pb, 3, s->f_code); /* fcode_for */
2490 2485
    if (s->pict_type == FF_B_TYPE)
2491 2486
        put_bits(&s->pb, 3, s->b_code); /* fcode_back */
2492
    //    printf("****frame %d\n", picture_number);
2493 2487
}
2494 2488

  
2495 2489
#endif //CONFIG_ENCODERS
......
2642 2636
static inline void mpeg4_encode_dc(PutBitContext * s, int level, int n)
2643 2637
{
2644 2638
#if 1
2645
//    if(level<-255 || level>255) printf("dc overflow\n");
2646 2639
    level+=256;
2647 2640
    if (n < 4) {
2648 2641
        /* luminance */
......
3235 3228
    }
3236 3229
    //FIXME new-pred stuff
3237 3230

  
3238
//printf("parse ok %d %d %d %d\n", mb_num, s->mb_x + s->mb_y*s->mb_width, get_bits_count(gb), get_bits_count(&s->gb));
3239

  
3240 3231
    return 0;
3241 3232
}
3242 3233

  
......
3761 3752
    /* per-MB end of slice check */
3762 3753

  
3763 3754
    if(--s->mb_num_left <= 0){
3764
//printf("%06X %d\n", show_bits(&s->gb, 24), get_bits_left(&s->gb));
3765 3755
        if(mpeg4_is_resync(s))
3766 3756
            return SLICE_END;
3767 3757
        else
......
3947 3937
                goto end;
3948 3938
            }
3949 3939
            cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
3950
            //fprintf(stderr, "\tCBPC: %d", cbpc);
3951 3940
            if (cbpc < 0){
3952 3941
                av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
3953 3942
                return -1;
......
4223 4212
                goto end;
4224 4213
            }
4225 4214
            cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
4226
            //fprintf(stderr, "\tCBPC: %d", cbpc);
4227 4215
            if (cbpc < 0){
4228 4216
                av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
4229 4217
                return -1;
......
5193 5181
                gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num);
5194 5182
                s->avctx->time_base.den /= gcd;
5195 5183
                s->avctx->time_base.num /= gcd;
5196
//                av_log(s->avctx, AV_LOG_DEBUG, "%d/%d\n", s->avctx->time_base.den, s->avctx->time_base.num);
5197 5184
            }else{
5198 5185
                s->avctx->time_base= (AVRational){1001, 30000};
5199 5186
            }
......
5314 5301
            y=get_xbits(gb, length);
5315 5302
        }
5316 5303
        skip_bits1(gb); /* marker bit */
5317
//printf("%d %d %d %d\n", x, y, i, s->sprite_warping_accuracy);
5318 5304
        s->sprite_traj[i][0]= d[i][0]= x;
5319 5305
        s->sprite_traj[i][1]= d[i][1]= y;
5320 5306
    }
......
5463 5449
    else{
5464 5450
        int shift_y= 16 - s->sprite_shift[0];
5465 5451
        int shift_c= 16 - s->sprite_shift[1];
5466
//printf("shifts %d %d\n", shift_y, shift_c);
5467 5452
        for(i=0; i<2; i++){
5468 5453
            s->sprite_offset[0][i]<<= shift_y;
5469 5454
            s->sprite_offset[1][i]<<= shift_c;
......
5473 5458
        }
5474 5459
        s->real_sprite_warping_points= s->num_sprite_warping_points;
5475 5460
    }
5476
#if 0
5477
printf("vop:%d:%d %d:%d %d:%d, sprite:%d:%d %d:%d %d:%d, virtual: %d:%d %d:%d\n",
5478
    vop_ref[0][0], vop_ref[0][1],
5479
    vop_ref[1][0], vop_ref[1][1],
5480
    vop_ref[2][0], vop_ref[2][1],
5481
    sprite_ref[0][0], sprite_ref[0][1],
5482
    sprite_ref[1][0], sprite_ref[1][1],
5483
    sprite_ref[2][0], sprite_ref[2][1],
5484
    virtual_ref[0][0], virtual_ref[0][1],
5485
    virtual_ref[1][0], virtual_ref[1][1]
5486
    );
5487

  
5488
printf("offset: %d:%d , delta: %d %d %d %d, shift %d\n",
5489
    s->sprite_offset[0][0], s->sprite_offset[0][1],
5490
    s->sprite_delta[0][0], s->sprite_delta[0][1],
5491
    s->sprite_delta[1][0], s->sprite_delta[1][1],
5492
    s->sprite_shift[0]
5493
    );
5494
#endif
5495 5461
}
5496 5462

  
5497 5463
static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){
......
5522 5488
    } else {
5523 5489
        vo_ver_id = 1;
5524 5490
    }
5525
//printf("vo type:%d\n",s->vo_type);
5526 5491
    s->aspect_ratio_info= get_bits(gb, 4);
5527 5492
    if(s->aspect_ratio_info == FF_ASPECT_EXTENDED){
5528 5493
        s->avctx->sample_aspect_ratio.num= get_bits(gb, 8); // par_width
......
5594 5559
            if(width && height && !(s->width && s->codec_tag == AV_RL32("MP4S"))){ /* they should be non zero but who knows ... */
5595 5560
                s->width = width;
5596 5561
                s->height = height;
5597
//                printf("width/height: %d %d\n", width, height);
5598 5562
            }
5599 5563
        }
5600 5564

  
......
5807 5771
            if(   h_sampling_factor_n==0 || h_sampling_factor_m==0
5808 5772
               || v_sampling_factor_n==0 || v_sampling_factor_m==0){
5809 5773

  
5810
//                fprintf(stderr, "illegal scalability header (VERY broken encoder), trying to workaround\n");
5811 5774
                s->scalability=0;
5812 5775

  
5813 5776
                *gb= bak;
......
5875 5838
        s->xvid_build= build;
5876 5839
    }
5877 5840

  
5878
//printf("User Data: %s\n", buf);
5879 5841
    return 0;
5880 5842
}
5881 5843

  
......
5917 5879
    if(IS_3IV1) time_increment= get_bits1(gb); //FIXME investigate further
5918 5880
    else time_increment= get_bits(gb, s->time_increment_bits);
5919 5881

  
5920
//    printf("%d %X\n", s->time_increment_bits, time_increment);
5921
//av_log(s->avctx, AV_LOG_DEBUG, " type:%d modulo_time_base:%d increment:%d t_frame %d\n", s->pict_type, time_incr, time_increment, s->t_frame);
5922 5882
    if(s->pict_type!=FF_B_TYPE){
5923 5883
        s->last_time_base= s->time_base;
5924 5884
        s->time_base+= time_incr;
5925 5885
        s->time= s->time_base*s->avctx->time_base.den + time_increment;
5926 5886
        if(s->workaround_bugs&FF_BUG_UMP4){
5927 5887
            if(s->time < s->last_non_b_time){
5928
//                fprintf(stderr, "header is not mpeg4 compatible, broken encoder, trying to workaround\n");
5929 5888
                s->time_base++;
5930 5889
                s->time+= s->avctx->time_base.den;
5931 5890
            }
......
5936 5895
        s->time= (s->last_time_base + time_incr)*s->avctx->time_base.den + time_increment;
5937 5896
        s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
5938 5897
        if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
5939
//            printf("messed up order, maybe after seeking? skipping current b frame\n");
5940 5898
            return FRAME_SKIPPED;
5941 5899
        }
5942 5900
        ff_mpeg4_init_direct_mv(s);
......
5952 5910
                return FRAME_SKIPPED;
5953 5911
        }
5954 5912
    }
5955
//av_log(s->avctx, AV_LOG_DEBUG, "last nonb %"PRId64" last_base %d time %"PRId64" pp %d pb %d t %d ppf %d pbf %d\n", s->last_non_b_time, s->last_time_base, s->time, s->pp_time, s->pb_time, s->t_frame, s->pp_field_time, s->pb_field_time);
5956 5913

  
5957 5914
    if(s->avctx->time_base.num)
5958 5915
        s->current_picture_ptr->pts= (s->time + s->avctx->time_base.num/2) / s->avctx->time_base.num;
......
5969 5926
            av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
5970 5927
        return FRAME_SKIPPED;
5971 5928
    }
5972
//printf("time %d %d %d || %"PRId64" %"PRId64" %"PRId64"\n", s->time_increment_bits, s->avctx->time_base.den, s->time_base,
5973
//s->time, s->last_non_b_time, s->last_non_b_time - s->pp_time);
5974 5929
    if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == FF_P_TYPE
5975 5930
                          || (s->pict_type == FF_S_TYPE && s->vol_sprite_usage==GMC_SPRITE))) {
5976 5931
        /* rounding type for motion estimation */

Also available in: Unified diff