comparison h264.c @ 1598:932d306bf1dc libavcodec

av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
author michael
date Mon, 03 Nov 2003 13:26:22 +0000
parents dd544554ed42
children d9d98cdcfcde
comparison
equal deleted inserted replaced
1597:4c9165372ab3 1598:932d306bf1dc
641 641
642 if(!(h->top_samples_available&0x8000)){ 642 if(!(h->top_samples_available&0x8000)){
643 for(i=0; i<4; i++){ 643 for(i=0; i<4; i++){
644 int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ]; 644 int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ];
645 if(status<0){ 645 if(status<0){
646 fprintf(stderr, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y); 646 av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
647 return -1; 647 return -1;
648 } else if(status){ 648 } else if(status){
649 h->intra4x4_pred_mode_cache[scan8[0] + i]= status; 649 h->intra4x4_pred_mode_cache[scan8[0] + i]= status;
650 } 650 }
651 } 651 }
653 653
654 if(!(h->left_samples_available&0x8000)){ 654 if(!(h->left_samples_available&0x8000)){
655 for(i=0; i<4; i++){ 655 for(i=0; i<4; i++){
656 int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ]; 656 int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ];
657 if(status<0){ 657 if(status<0){
658 fprintf(stderr, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y); 658 av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y);
659 return -1; 659 return -1;
660 } else if(status){ 660 } else if(status){
661 h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status; 661 h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status;
662 } 662 }
663 } 663 }
675 static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8}; 675 static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8};
676 676
677 if(!(h->top_samples_available&0x8000)){ 677 if(!(h->top_samples_available&0x8000)){
678 mode= top[ mode ]; 678 mode= top[ mode ];
679 if(mode<0){ 679 if(mode<0){
680 fprintf(stderr, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y); 680 av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
681 return -1; 681 return -1;
682 } 682 }
683 } 683 }
684 684
685 if(!(h->left_samples_available&0x8000)){ 685 if(!(h->left_samples_available&0x8000)){
686 mode= left[ mode ]; 686 mode= left[ mode ];
687 if(mode<0){ 687 if(mode<0){
688 fprintf(stderr, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y); 688 av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y);
689 return -1; 689 return -1;
690 } 690 }
691 } 691 }
692 692
693 return mode; 693 return mode;
2445 int pic_id; 2445 int pic_id;
2446 int i; 2446 int i;
2447 2447
2448 2448
2449 if(index >= h->ref_count[list]){ 2449 if(index >= h->ref_count[list]){
2450 fprintf(stderr, "reference count overflow\n"); 2450 av_log(h->s.avctx, AV_LOG_ERROR, "reference count overflow\n");
2451 return -1; 2451 return -1;
2452 } 2452 }
2453 2453
2454 if(reordering_of_pic_nums_idc<3){ 2454 if(reordering_of_pic_nums_idc<3){
2455 if(reordering_of_pic_nums_idc<2){ 2455 if(reordering_of_pic_nums_idc<2){
2456 const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1; 2456 const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
2457 2457
2458 if(abs_diff_pic_num >= h->max_pic_num){ 2458 if(abs_diff_pic_num >= h->max_pic_num){
2459 fprintf(stderr, "abs_diff_pic_num overflow\n"); 2459 av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
2460 return -1; 2460 return -1;
2461 } 2461 }
2462 2462
2463 if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num; 2463 if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num;
2464 else pred+= abs_diff_pic_num; 2464 else pred+= abs_diff_pic_num;
2476 break; 2476 break;
2477 } 2477 }
2478 } 2478 }
2479 2479
2480 if(i < index){ 2480 if(i < index){
2481 fprintf(stderr, "reference picture missing during reorder\n"); 2481 av_log(h->s.avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
2482 memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME 2482 memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
2483 }else if(i > index){ 2483 }else if(i > index){
2484 Picture tmp= h->ref_list[list][i]; 2484 Picture tmp= h->ref_list[list][i];
2485 for(; i>index; i--){ 2485 for(; i>index; i--){
2486 h->ref_list[list][i]= h->ref_list[list][i-1]; 2486 h->ref_list[list][i]= h->ref_list[list][i-1];
2488 h->ref_list[list][index]= tmp; 2488 h->ref_list[list][index]= tmp;
2489 } 2489 }
2490 }else if(reordering_of_pic_nums_idc==3) 2490 }else if(reordering_of_pic_nums_idc==3)
2491 break; 2491 break;
2492 else{ 2492 else{
2493 fprintf(stderr, "illegal reordering_of_pic_nums_idc\n"); 2493 av_log(h->s.avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
2494 return -1; 2494 return -1;
2495 } 2495 }
2496 } 2496 }
2497 } 2497 }
2498 2498
2558 static Picture * remove_short(H264Context *h, int frame_num){ 2558 static Picture * remove_short(H264Context *h, int frame_num){
2559 MpegEncContext * const s = &h->s; 2559 MpegEncContext * const s = &h->s;
2560 int i; 2560 int i;
2561 2561
2562 if(s->avctx->debug&FF_DEBUG_MMCO) 2562 if(s->avctx->debug&FF_DEBUG_MMCO)
2563 printf("remove short %d count %d\n", frame_num, h->short_ref_count); 2563 av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
2564 2564
2565 for(i=0; i<h->short_ref_count; i++){ 2565 for(i=0; i<h->short_ref_count; i++){
2566 Picture *pic= h->short_ref[i]; 2566 Picture *pic= h->short_ref[i];
2567 if(s->avctx->debug&FF_DEBUG_MMCO) 2567 if(s->avctx->debug&FF_DEBUG_MMCO)
2568 printf("%d %d %p\n", i, pic->frame_num, pic); 2568 av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
2569 if(pic->frame_num == frame_num){ 2569 if(pic->frame_num == frame_num){
2570 h->short_ref[i]= NULL; 2570 h->short_ref[i]= NULL;
2571 memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i - 1)*sizeof(Picture*)); 2571 memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i - 1)*sizeof(Picture*));
2572 h->short_ref_count--; 2572 h->short_ref_count--;
2573 return pic; 2573 return pic;
2602 int i; 2602 int i;
2603 int current_is_long=0; 2603 int current_is_long=0;
2604 Picture *pic; 2604 Picture *pic;
2605 2605
2606 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) 2606 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
2607 printf("no mmco here\n"); 2607 av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
2608 2608
2609 for(i=0; i<mmco_count; i++){ 2609 for(i=0; i<mmco_count; i++){
2610 if(s->avctx->debug&FF_DEBUG_MMCO) 2610 if(s->avctx->debug&FF_DEBUG_MMCO)
2611 printf("mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index); 2611 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index);
2612 2612
2613 switch(mmco[i].opcode){ 2613 switch(mmco[i].opcode){
2614 case MMCO_SHORT2UNUSED: 2614 case MMCO_SHORT2UNUSED:
2615 pic= remove_short(h, mmco[i].short_frame_num); 2615 pic= remove_short(h, mmco[i].short_frame_num);
2616 if(pic==NULL) return -1; 2616 if(pic==NULL) return -1;
2664 2664
2665 if(!current_is_long){ 2665 if(!current_is_long){
2666 pic= remove_short(h, s->current_picture_ptr->frame_num); 2666 pic= remove_short(h, s->current_picture_ptr->frame_num);
2667 if(pic){ 2667 if(pic){
2668 pic->reference=0; 2668 pic->reference=0;
2669 fprintf(stderr, "illegal short term buffer state detected\n"); 2669 av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
2670 } 2670 }
2671 2671
2672 if(h->short_ref_count) 2672 if(h->short_ref_count)
2673 memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*)); 2673 memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*));
2674 2674
2707 }*/ 2707 }*/
2708 } 2708 }
2709 if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ 2709 if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
2710 h->mmco[i].long_index= get_ue_golomb(&s->gb); 2710 h->mmco[i].long_index= get_ue_golomb(&s->gb);
2711 if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ h->mmco[i].long_index >= 16){ 2711 if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ h->mmco[i].long_index >= 16){
2712 fprintf(stderr, "illegal long ref in memory management control operation %d\n", opcode); 2712 av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
2713 return -1; 2713 return -1;
2714 } 2714 }
2715 } 2715 }
2716 2716
2717 if(opcode > MMCO_LONG){ 2717 if(opcode > MMCO_LONG){
2718 fprintf(stderr, "illegal memory management control operation %d\n", opcode); 2718 av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
2719 return -1; 2719 return -1;
2720 } 2720 }
2721 } 2721 }
2722 h->mmco_index= i; 2722 h->mmco_index= i;
2723 }else{ 2723 }else{
2833 2833
2834 first_mb_in_slice= get_ue_golomb(&s->gb); 2834 first_mb_in_slice= get_ue_golomb(&s->gb);
2835 2835
2836 h->slice_type= get_ue_golomb(&s->gb); 2836 h->slice_type= get_ue_golomb(&s->gb);
2837 if(h->slice_type > 9){ 2837 if(h->slice_type > 9){
2838 fprintf(stderr, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y); 2838 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);
2839 } 2839 }
2840 if(h->slice_type > 4){ 2840 if(h->slice_type > 4){
2841 h->slice_type -= 5; 2841 h->slice_type -= 5;
2842 h->slice_type_fixed=1; 2842 h->slice_type_fixed=1;
2843 }else 2843 }else
2847 2847
2848 s->pict_type= h->slice_type; // to make a few old func happy, its wrong though 2848 s->pict_type= h->slice_type; // to make a few old func happy, its wrong though
2849 2849
2850 pps_id= get_ue_golomb(&s->gb); 2850 pps_id= get_ue_golomb(&s->gb);
2851 if(pps_id>255){ 2851 if(pps_id>255){
2852 fprintf(stderr, "pps_id out of range\n"); 2852 av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
2853 return -1; 2853 return -1;
2854 } 2854 }
2855 h->pps= h->pps_buffer[pps_id]; 2855 h->pps= h->pps_buffer[pps_id];
2856 if(h->pps.slice_group_count == 0){ 2856 if(h->pps.slice_group_count == 0){
2857 fprintf(stderr, "non existing PPS referenced\n"); 2857 av_log(h->s.avctx, AV_LOG_ERROR, "non existing PPS referenced\n");
2858 return -1; 2858 return -1;
2859 } 2859 }
2860 2860
2861 h->sps= h->sps_buffer[ h->pps.sps_id ]; 2861 h->sps= h->sps_buffer[ h->pps.sps_id ];
2862 if(h->sps.log2_max_frame_num == 0){ 2862 if(h->sps.log2_max_frame_num == 0){
2863 fprintf(stderr, "non existing SPS referenced\n"); 2863 av_log(h->s.avctx, AV_LOG_ERROR, "non existing SPS referenced\n");
2864 return -1; 2864 return -1;
2865 } 2865 }
2866 2866
2867 s->mb_width= h->sps.mb_width; 2867 s->mb_width= h->sps.mb_width;
2868 s->mb_height= h->sps.mb_height; 2868 s->mb_height= h->sps.mb_height;
2958 h->ref_count[0]= get_ue_golomb(&s->gb) + 1; 2958 h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
2959 if(h->slice_type==B_TYPE) 2959 if(h->slice_type==B_TYPE)
2960 h->ref_count[1]= get_ue_golomb(&s->gb) + 1; 2960 h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
2961 2961
2962 if(h->ref_count[0] > 32 || h->ref_count[1] > 32){ 2962 if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
2963 fprintf(stderr, "reference overflow\n"); 2963 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
2964 return -1; 2964 return -1;
2965 } 2965 }
2966 } 2966 }
2967 } 2967 }
2968 2968
3002 if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5) 3002 if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5)
3003 slice_group_change_cycle= get_bits(&s->gb, ?); 3003 slice_group_change_cycle= get_bits(&s->gb, ?);
3004 #endif 3004 #endif
3005 3005
3006 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ 3006 if(s->avctx->debug&FF_DEBUG_PICT_INFO){
3007 printf("mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n", 3007 av_log(h->s.avctx, AV_LOG_DEBUG, "mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n",
3008 first_mb_in_slice, 3008 first_mb_in_slice,
3009 av_get_pict_type_char(h->slice_type), 3009 av_get_pict_type_char(h->slice_type),
3010 pps_id, h->frame_num, 3010 pps_id, h->frame_num,
3011 s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1], 3011 s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1],
3012 h->ref_count[0], h->ref_count[1], 3012 h->ref_count[0], h->ref_count[1],
3104 level_code= prefix + get_bits(gb, 4); //part 3104 level_code= prefix + get_bits(gb, 4); //part
3105 }else if(prefix==15){ 3105 }else if(prefix==15){
3106 level_code= (prefix<<suffix_length) + get_bits(gb, 12); //part 3106 level_code= (prefix<<suffix_length) + get_bits(gb, 12); //part
3107 if(suffix_length==0) level_code+=15; //FIXME doesnt make (much)sense 3107 if(suffix_length==0) level_code+=15; //FIXME doesnt make (much)sense
3108 }else{ 3108 }else{
3109 fprintf(stderr, "prefix too large at %d %d\n", s->mb_x, s->mb_y); 3109 av_log(h->s.avctx, AV_LOG_ERROR, "prefix too large at %d %d\n", s->mb_x, s->mb_y);
3110 return -1; 3110 return -1;
3111 } 3111 }
3112 3112
3113 if(i==trailing_ones && i<3) level_code+= 2; //FIXME split first iteration 3113 if(i==trailing_ones && i<3) level_code+= 2; //FIXME split first iteration
3114 3114
3145 } 3145 }
3146 zeros_left -= run[i]; 3146 zeros_left -= run[i];
3147 } 3147 }
3148 3148
3149 if(zeros_left<0){ 3149 if(zeros_left<0){
3150 fprintf(stderr, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y); 3150 av_log(h->s.avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y);
3151 return -1; 3151 return -1;
3152 } 3152 }
3153 3153
3154 for(; i<total_coeff-1; i++){ 3154 for(; i<total_coeff-1; i++){
3155 run[i]= 0; 3155 run[i]= 0;
3255 } 3255 }
3256 }else{ 3256 }else{
3257 assert(h->slice_type == I_TYPE); 3257 assert(h->slice_type == I_TYPE);
3258 decode_intra_mb: 3258 decode_intra_mb:
3259 if(mb_type > 25){ 3259 if(mb_type > 25){
3260 fprintf(stderr, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y); 3260 av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y);
3261 return -1; 3261 return -1;
3262 } 3262 }
3263 partition_count=0; 3263 partition_count=0;
3264 cbp= i_mb_type_info[mb_type].cbp; 3264 cbp= i_mb_type_info[mb_type].cbp;
3265 h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; 3265 h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
3351 3351
3352 if(h->slice_type == B_TYPE){ 3352 if(h->slice_type == B_TYPE){
3353 for(i=0; i<4; i++){ 3353 for(i=0; i<4; i++){
3354 h->sub_mb_type[i]= get_ue_golomb(&s->gb); 3354 h->sub_mb_type[i]= get_ue_golomb(&s->gb);
3355 if(h->sub_mb_type[i] >=13){ 3355 if(h->sub_mb_type[i] >=13){
3356 fprintf(stderr, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); 3356 av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
3357 return -1; 3357 return -1;
3358 } 3358 }
3359 sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; 3359 sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
3360 h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type; 3360 h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
3361 } 3361 }
3362 }else{ 3362 }else{
3363 assert(h->slice_type == P_TYPE || h->slice_type == SP_TYPE); //FIXME SP correct ? 3363 assert(h->slice_type == P_TYPE || h->slice_type == SP_TYPE); //FIXME SP correct ?
3364 for(i=0; i<4; i++){ 3364 for(i=0; i<4; i++){
3365 h->sub_mb_type[i]= get_ue_golomb(&s->gb); 3365 h->sub_mb_type[i]= get_ue_golomb(&s->gb);
3366 if(h->sub_mb_type[i] >=4){ 3366 if(h->sub_mb_type[i] >=4){
3367 fprintf(stderr, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); 3367 av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
3368 return -1; 3368 return -1;
3369 } 3369 }
3370 sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; 3370 sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
3371 h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type; 3371 h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
3372 } 3372 }
3506 write_back_motion(h, mb_type); 3506 write_back_motion(h, mb_type);
3507 3507
3508 if(!IS_INTRA16x16(mb_type)){ 3508 if(!IS_INTRA16x16(mb_type)){
3509 cbp= get_ue_golomb(&s->gb); 3509 cbp= get_ue_golomb(&s->gb);
3510 if(cbp > 47){ 3510 if(cbp > 47){
3511 fprintf(stderr, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y); 3511 av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y);
3512 return -1; 3512 return -1;
3513 } 3513 }
3514 3514
3515 if(IS_INTRA4x4(mb_type)) 3515 if(IS_INTRA4x4(mb_type))
3516 cbp= golomb_to_intra4x4_cbp[cbp]; 3516 cbp= golomb_to_intra4x4_cbp[cbp];
3535 } 3535 }
3536 3536
3537 dquant= get_se_golomb(&s->gb); 3537 dquant= get_se_golomb(&s->gb);
3538 3538
3539 if( dquant > 25 || dquant < -26 ){ 3539 if( dquant > 25 || dquant < -26 ){
3540 fprintf(stderr, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y); 3540 av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y);
3541 return -1; 3541 return -1;
3542 } 3542 }
3543 3543
3544 s->qscale += dquant; 3544 s->qscale += dquant;
3545 if(((unsigned)s->qscale) > 51){ 3545 if(((unsigned)s->qscale) > 51){
3632 hl_decode_mb(h); 3632 hl_decode_mb(h);
3633 s->mb_y--; 3633 s->mb_y--;
3634 } 3634 }
3635 3635
3636 if(ret<0){ 3636 if(ret<0){
3637 fprintf(stderr, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); 3637 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
3638 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); 3638 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
3639 3639
3640 return -1; 3640 return -1;
3641 } 3641 }
3642 3642
3731 sps->sar.num= get_bits(&s->gb, 16); 3731 sps->sar.num= get_bits(&s->gb, 16);
3732 sps->sar.den= get_bits(&s->gb, 16); 3732 sps->sar.den= get_bits(&s->gb, 16);
3733 }else if(aspect_ratio_idc < 16){ 3733 }else if(aspect_ratio_idc < 16){
3734 sps->sar= pixel_aspect[aspect_ratio_idc]; 3734 sps->sar= pixel_aspect[aspect_ratio_idc];
3735 }else{ 3735 }else{
3736 fprintf(stderr, "illegal aspect ratio\n"); 3736 av_log(h->s.avctx, AV_LOG_ERROR, "illegal aspect ratio\n");
3737 return -1; 3737 return -1;
3738 } 3738 }
3739 }else{ 3739 }else{
3740 sps->sar.num= 3740 sps->sar.num=
3741 sps->sar.den= 0; 3741 sps->sar.den= 0;
3823 3823
3824 for(i=0; i<sps->poc_cycle_length; i++) 3824 for(i=0; i<sps->poc_cycle_length; i++)
3825 sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb); 3825 sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
3826 } 3826 }
3827 if(sps->poc_type > 2){ 3827 if(sps->poc_type > 2){
3828 fprintf(stderr, "illegal POC type %d\n", sps->poc_type); 3828 av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
3829 return -1; 3829 return -1;
3830 } 3830 }
3831 3831
3832 sps->ref_frame_count= get_ue_golomb(&s->gb); 3832 sps->ref_frame_count= get_ue_golomb(&s->gb);
3833 sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb); 3833 sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
3846 sps->crop_left = get_ue_golomb(&s->gb); 3846 sps->crop_left = get_ue_golomb(&s->gb);
3847 sps->crop_right = get_ue_golomb(&s->gb); 3847 sps->crop_right = get_ue_golomb(&s->gb);
3848 sps->crop_top = get_ue_golomb(&s->gb); 3848 sps->crop_top = get_ue_golomb(&s->gb);
3849 sps->crop_bottom= get_ue_golomb(&s->gb); 3849 sps->crop_bottom= get_ue_golomb(&s->gb);
3850 if(sps->crop_left || sps->crop_top){ 3850 if(sps->crop_left || sps->crop_top){
3851 fprintf(stderr, "insane croping not completly supported, this could look slightly wrong ...\n"); 3851 av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completly supported, this could look slightly wrong ...\n");
3852 } 3852 }
3853 }else{ 3853 }else{
3854 sps->crop_left = 3854 sps->crop_left =
3855 sps->crop_right = 3855 sps->crop_right =
3856 sps->crop_top = 3856 sps->crop_top =
3860 sps->vui_parameters_present_flag= get_bits1(&s->gb); 3860 sps->vui_parameters_present_flag= get_bits1(&s->gb);
3861 if( sps->vui_parameters_present_flag ) 3861 if( sps->vui_parameters_present_flag )
3862 decode_vui_parameters(h, sps); 3862 decode_vui_parameters(h, sps);
3863 3863
3864 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ 3864 if(s->avctx->debug&FF_DEBUG_PICT_INFO){
3865 printf("sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n", 3865 av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
3866 sps_id, sps->profile_idc, sps->level_idc, 3866 sps_id, sps->profile_idc, sps->level_idc,
3867 sps->poc_type, 3867 sps->poc_type,
3868 sps->ref_frame_count, 3868 sps->ref_frame_count,
3869 sps->mb_width, sps->mb_height, 3869 sps->mb_width, sps->mb_height,
3870 sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"), 3870 sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
3886 pps->cabac= get_bits1(&s->gb); 3886 pps->cabac= get_bits1(&s->gb);
3887 pps->pic_order_present= get_bits1(&s->gb); 3887 pps->pic_order_present= get_bits1(&s->gb);
3888 pps->slice_group_count= get_ue_golomb(&s->gb) + 1; 3888 pps->slice_group_count= get_ue_golomb(&s->gb) + 1;
3889 if(pps->slice_group_count > 1 ){ 3889 if(pps->slice_group_count > 1 ){
3890 pps->mb_slice_group_map_type= get_ue_golomb(&s->gb); 3890 pps->mb_slice_group_map_type= get_ue_golomb(&s->gb);
3891 fprintf(stderr, "FMO not supported\n"); 3891 av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n");
3892 switch(pps->mb_slice_group_map_type){ 3892 switch(pps->mb_slice_group_map_type){
3893 case 0: 3893 case 0:
3894 #if 0 3894 #if 0
3895 | for( i = 0; i <= num_slice_groups_minus1; i++ ) | | | 3895 | for( i = 0; i <= num_slice_groups_minus1; i++ ) | | |
3896 | run_length[ i ] |1 |ue(v) | 3896 | run_length[ i ] |1 |ue(v) |
3924 } 3924 }
3925 } 3925 }
3926 pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; 3926 pps->ref_count[0]= get_ue_golomb(&s->gb) + 1;
3927 pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; 3927 pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;
3928 if(pps->ref_count[0] > 32 || pps->ref_count[1] > 32){ 3928 if(pps->ref_count[0] > 32 || pps->ref_count[1] > 32){
3929 fprintf(stderr, "reference overflow (pps)\n"); 3929 av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
3930 return -1; 3930 return -1;
3931 } 3931 }
3932 3932
3933 pps->weighted_pred= get_bits1(&s->gb); 3933 pps->weighted_pred= get_bits1(&s->gb);
3934 pps->weighted_bipred_idc= get_bits(&s->gb, 2); 3934 pps->weighted_bipred_idc= get_bits(&s->gb, 2);
3938 pps->deblocking_filter_parameters_present= get_bits1(&s->gb); 3938 pps->deblocking_filter_parameters_present= get_bits1(&s->gb);
3939 pps->constrained_intra_pred= get_bits1(&s->gb); 3939 pps->constrained_intra_pred= get_bits1(&s->gb);
3940 pps->redundant_pic_cnt_present = get_bits1(&s->gb); 3940 pps->redundant_pic_cnt_present = get_bits1(&s->gb);
3941 3941
3942 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ 3942 if(s->avctx->debug&FF_DEBUG_PICT_INFO){
3943 printf("pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n", 3943 av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n",
3944 pps_id, pps->sps_id, 3944 pps_id, pps->sps_id,
3945 pps->cabac ? "CABAC" : "CAVLC", 3945 pps->cabac ? "CABAC" : "CAVLC",
3946 pps->slice_group_count, 3946 pps->slice_group_count,
3947 pps->ref_count[0], pps->ref_count[1], 3947 pps->ref_count[0], pps->ref_count[1],
3948 pps->weighted_pred ? "weighted" : "", 3948 pps->weighted_pred ? "weighted" : "",
4014 ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, buf_size - buf_index); 4014 ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, buf_size - buf_index);
4015 if(ptr[dst_length - 1] == 0) dst_length--; 4015 if(ptr[dst_length - 1] == 0) dst_length--;
4016 bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1); 4016 bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
4017 4017
4018 if(s->avctx->debug&FF_DEBUG_STARTCODE){ 4018 if(s->avctx->debug&FF_DEBUG_STARTCODE){
4019 printf("NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length); 4019 av_log(h->s.avctx, AV_LOG_DEBUG, "NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length);
4020 } 4020 }
4021 4021
4022 buf_index += consumed; 4022 buf_index += consumed;
4023 4023
4024 if(h->nal_ref_idc < s->hurry_up) 4024 if(h->nal_ref_idc < s->hurry_up)
4164 } else { 4164 } else {
4165 *pict= *(AVFrame*)&s->last_picture; 4165 *pict= *(AVFrame*)&s->last_picture;
4166 } 4166 }
4167 #endif 4167 #endif
4168 if(!s->current_picture_ptr){ 4168 if(!s->current_picture_ptr){
4169 fprintf(stderr, "error, NO frame\n"); 4169 av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n");
4170 return -1; 4170 return -1;
4171 } 4171 }
4172 4172
4173 *pict= *(AVFrame*)&s->current_picture; //FIXME 4173 *pict= *(AVFrame*)&s->current_picture; //FIXME
4174 ff_print_debug_info(s, s->current_picture_ptr); 4174 ff_print_debug_info(s, s->current_picture_ptr);