Mercurial > libavcodec.hg
comparison h264.c @ 2441:358813ec4ca2 libavcodec
H.264 b ref pic list order and long term pictures patch by (Loic Le Loarer <loic.le-loarer polytechnique org>)
author | michael |
---|---|
date | Wed, 19 Jan 2005 17:35:51 +0000 |
parents | cf97353f94c6 |
children | 0237bb5ca0f0 |
comparison
equal
deleted
inserted
replaced
2440:cf97353f94c6 | 2441:358813ec4ca2 |
---|---|
911 . . . L . . . . | 911 . . . L . . . . |
912 */ | 912 */ |
913 | 913 |
914 diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width); | 914 diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width); |
915 match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref); | 915 match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref); |
916 tprintf("pred_motion match_count=%d\n", match_count); | |
916 if(match_count > 1){ //most common | 917 if(match_count > 1){ //most common |
917 *mx= mid_pred(A[0], B[0], C[0]); | 918 *mx= mid_pred(A[0], B[0], C[0]); |
918 *my= mid_pred(A[1], B[1], C[1]); | 919 *my= mid_pred(A[1], B[1], C[1]); |
919 }else if(match_count==1){ | 920 }else if(match_count==1){ |
920 if(left_ref==ref){ | 921 if(left_ref==ref){ |
1073 *mb_type = MB_TYPE_8x8; | 1074 *mb_type = MB_TYPE_8x8; |
1074 } | 1075 } |
1075 if(!is_b8x8) | 1076 if(!is_b8x8) |
1076 *mb_type |= MB_TYPE_DIRECT2; | 1077 *mb_type |= MB_TYPE_DIRECT2; |
1077 | 1078 |
1079 tprintf("mb_type = %08x, sub_mb_type = %08x, is_b8x8 = %d, mb_type_col = %08x\n", *mb_type, sub_mb_type, is_b8x8, mb_type_col); | |
1080 | |
1078 if(h->direct_spatial_mv_pred){ | 1081 if(h->direct_spatial_mv_pred){ |
1079 int ref[2]; | 1082 int ref[2]; |
1080 int mv[2][2]; | 1083 int mv[2][2]; |
1081 int list; | 1084 int list; |
1082 | 1085 |
2598 MpegEncContext * const s = &h->s; | 2601 MpegEncContext * const s = &h->s; |
2599 int i; | 2602 int i; |
2600 | 2603 |
2601 MPV_frame_start(s, s->avctx); | 2604 MPV_frame_start(s, s->avctx); |
2602 ff_er_frame_start(s); | 2605 ff_er_frame_start(s); |
2603 h->mmco_index=0; | |
2604 | 2606 |
2605 assert(s->linesize && s->uvlinesize); | 2607 assert(s->linesize && s->uvlinesize); |
2606 | 2608 |
2607 for(i=0; i<16; i++){ | 2609 for(i=0; i<16; i++){ |
2608 h->block_offset[i]= 4*((scan8[i] - scan8[0])&7) + 4*s->linesize*((scan8[i] - scan8[0])>>3); | 2610 h->block_offset[i]= 4*((scan8[i] - scan8[0])&7) + 4*s->linesize*((scan8[i] - scan8[0])>>3); |
2841 * fills the default_ref_list. | 2843 * fills the default_ref_list. |
2842 */ | 2844 */ |
2843 static int fill_default_ref_list(H264Context *h){ | 2845 static int fill_default_ref_list(H264Context *h){ |
2844 MpegEncContext * const s = &h->s; | 2846 MpegEncContext * const s = &h->s; |
2845 int i; | 2847 int i; |
2848 int smallest_poc_greater_than_current = -1; | |
2846 Picture sorted_short_ref[16]; | 2849 Picture sorted_short_ref[16]; |
2847 | 2850 |
2848 if(h->slice_type==B_TYPE){ | 2851 if(h->slice_type==B_TYPE){ |
2849 int out_i; | 2852 int out_i; |
2850 int limit= -1; | 2853 int limit= -1; |
2851 | 2854 |
2855 /* sort frame according to poc in B slice */ | |
2852 for(out_i=0; out_i<h->short_ref_count; out_i++){ | 2856 for(out_i=0; out_i<h->short_ref_count; out_i++){ |
2853 int best_i=-1; | 2857 int best_i=-1; |
2854 int best_poc=INT_MAX; | 2858 int best_poc=INT_MAX; |
2855 | 2859 |
2856 for(i=0; i<h->short_ref_count; i++){ | 2860 for(i=0; i<h->short_ref_count; i++){ |
2863 | 2867 |
2864 assert(best_i != -1); | 2868 assert(best_i != -1); |
2865 | 2869 |
2866 limit= best_poc; | 2870 limit= best_poc; |
2867 sorted_short_ref[out_i]= *h->short_ref[best_i]; | 2871 sorted_short_ref[out_i]= *h->short_ref[best_i]; |
2872 tprintf("sorted poc: %d->%d poc:%d fn:%d\n", best_i, out_i, sorted_short_ref[out_i].poc, sorted_short_ref[out_i].frame_num); | |
2873 if (-1 == smallest_poc_greater_than_current) { | |
2874 if (h->short_ref[best_i]->poc >= s->current_picture_ptr->poc) { | |
2875 smallest_poc_greater_than_current = out_i; | |
2876 } | |
2877 } | |
2868 } | 2878 } |
2869 } | 2879 } |
2870 | 2880 |
2871 if(s->picture_structure == PICT_FRAME){ | 2881 if(s->picture_structure == PICT_FRAME){ |
2872 if(h->slice_type==B_TYPE){ | 2882 if(h->slice_type==B_TYPE){ |
2873 const int current_poc= s->current_picture_ptr->poc; | |
2874 int list; | 2883 int list; |
2875 | 2884 tprintf("current poc: %d, smallest_poc_greater_than_current: %d\n", s->current_picture_ptr->poc, smallest_poc_greater_than_current); |
2885 | |
2886 // find the largest poc | |
2876 for(list=0; list<2; list++){ | 2887 for(list=0; list<2; list++){ |
2877 int index=0; | 2888 int index = 0; |
2878 | 2889 int swap_first_L1 = 0; |
2879 for(i=0; i<h->short_ref_count && index < h->ref_count[list]; i++){ | 2890 |
2880 const int i2= list ? i : h->short_ref_count - i - 1; | 2891 if (0 == list) { |
2881 const int poc= sorted_short_ref[i2].poc; | 2892 for(i=smallest_poc_greater_than_current-1; i>=0 && index < h->ref_count[list]; i--) { |
2882 | 2893 if(sorted_short_ref[i].reference != 3) continue; |
2883 if(sorted_short_ref[i2].reference != 3) continue; //FIXME refernce field shit | 2894 h->default_ref_list[list][index ]= sorted_short_ref[i]; |
2884 | 2895 h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num; |
2885 if((list==1 && poc > current_poc) || (list==0 && poc < current_poc)){ | |
2886 h->default_ref_list[list][index ]= sorted_short_ref[i2]; | |
2887 h->default_ref_list[list][index++].pic_id= sorted_short_ref[i2].frame_num; | |
2888 } | 2896 } |
2889 } | 2897 for(i=smallest_poc_greater_than_current; i<h->short_ref_count && index < h->ref_count[list]; i++) { |
2890 | 2898 if(sorted_short_ref[i].reference != 3) continue; |
2891 for(i=0; i<h->long_ref_count && index < h->ref_count[ list ]; i++){ | 2899 h->default_ref_list[list][index ]= sorted_short_ref[i]; |
2900 h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num; | |
2901 } | |
2902 } else { | |
2903 for(i=smallest_poc_greater_than_current; i<h->short_ref_count && index < h->ref_count[list]; i++) { | |
2904 if(sorted_short_ref[i].reference != 3) continue; | |
2905 swap_first_L1 |= 1; | |
2906 h->default_ref_list[list][index ]= sorted_short_ref[i]; | |
2907 h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num; | |
2908 } | |
2909 for(i=smallest_poc_greater_than_current-1; i>=0 && index < h->ref_count[list]; i--) { | |
2910 if(sorted_short_ref[i].reference != 3) continue; | |
2911 swap_first_L1 |= 2; | |
2912 h->default_ref_list[list][index ]= sorted_short_ref[i]; | |
2913 h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num; | |
2914 } | |
2915 } | |
2916 | |
2917 for(i = 0; i < 16 && index < h->ref_count[ list ]; i++){ | |
2918 if(h->long_ref[i] == NULL) continue; | |
2892 if(h->long_ref[i]->reference != 3) continue; | 2919 if(h->long_ref[i]->reference != 3) continue; |
2893 | 2920 |
2894 h->default_ref_list[ list ][index ]= *h->long_ref[i]; | 2921 h->default_ref_list[ list ][index ]= *h->long_ref[i]; |
2895 h->default_ref_list[ list ][index++].pic_id= i;; | 2922 h->default_ref_list[ list ][index++].pic_id= i;; |
2896 } | 2923 } |
2897 | 2924 |
2898 if(h->long_ref_count > 1 && h->short_ref_count==0){ | 2925 if(list && (3 == swap_first_L1) && (1 < index)){ |
2926 // swap the two first elements of L1 when | |
2927 // L0 and L1 are identical | |
2899 Picture temp= h->default_ref_list[1][0]; | 2928 Picture temp= h->default_ref_list[1][0]; |
2900 h->default_ref_list[1][0] = h->default_ref_list[1][1]; | 2929 h->default_ref_list[1][0] = h->default_ref_list[1][1]; |
2901 h->default_ref_list[1][0] = temp; | 2930 h->default_ref_list[1][0] = temp; |
2902 } | 2931 } |
2903 | 2932 |
2909 for(i=0; i<h->short_ref_count && index < h->ref_count[0]; i++){ | 2938 for(i=0; i<h->short_ref_count && index < h->ref_count[0]; i++){ |
2910 if(h->short_ref[i]->reference != 3) continue; //FIXME refernce field shit | 2939 if(h->short_ref[i]->reference != 3) continue; //FIXME refernce field shit |
2911 h->default_ref_list[0][index ]= *h->short_ref[i]; | 2940 h->default_ref_list[0][index ]= *h->short_ref[i]; |
2912 h->default_ref_list[0][index++].pic_id= h->short_ref[i]->frame_num; | 2941 h->default_ref_list[0][index++].pic_id= h->short_ref[i]->frame_num; |
2913 } | 2942 } |
2914 for(i=0; i<h->long_ref_count && index < h->ref_count[0]; i++){ | 2943 for(i = 0; i < 16 && index < h->ref_count[0]; i++){ |
2944 if(h->long_ref[i] == NULL) continue; | |
2915 if(h->long_ref[i]->reference != 3) continue; | 2945 if(h->long_ref[i]->reference != 3) continue; |
2916 h->default_ref_list[0][index ]= *h->long_ref[i]; | 2946 h->default_ref_list[0][index ]= *h->long_ref[i]; |
2917 h->default_ref_list[0][index++].pic_id= i;; | 2947 h->default_ref_list[0][index++].pic_id= i;; |
2918 } | 2948 } |
2919 if(index < h->ref_count[0]) | 2949 if(index < h->ref_count[0]) |
2923 if(h->slice_type==B_TYPE){ | 2953 if(h->slice_type==B_TYPE){ |
2924 }else{ | 2954 }else{ |
2925 //FIXME second field balh | 2955 //FIXME second field balh |
2926 } | 2956 } |
2927 } | 2957 } |
2958 #ifdef TRACE | |
2959 for (i=0; i<h->ref_count[0]; i++) { | |
2960 tprintf("List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].data[0]); | |
2961 } | |
2962 if(h->slice_type==B_TYPE){ | |
2963 for (i=0; i<h->ref_count[1]; i++) { | |
2964 tprintf("List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[0][i].data[0]); | |
2965 } | |
2966 } | |
2967 #endif | |
2928 return 0; | 2968 return 0; |
2929 } | 2969 } |
2970 | |
2971 static void print_short_term(H264Context *h); | |
2972 static void print_long_term(H264Context *h); | |
2930 | 2973 |
2931 static int decode_ref_pic_list_reordering(H264Context *h){ | 2974 static int decode_ref_pic_list_reordering(H264Context *h){ |
2932 MpegEncContext * const s = &h->s; | 2975 MpegEncContext * const s = &h->s; |
2933 int list; | 2976 int list; |
2934 | 2977 |
2978 print_short_term(h); | |
2979 print_long_term(h); | |
2935 if(h->slice_type==I_TYPE || h->slice_type==SI_TYPE) return 0; //FIXME move beofre func | 2980 if(h->slice_type==I_TYPE || h->slice_type==SI_TYPE) return 0; //FIXME move beofre func |
2936 | 2981 |
2937 for(list=0; list<2; list++){ | 2982 for(list=0; list<2; list++){ |
2938 memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]); | 2983 memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]); |
2939 | 2984 |
3057 return 0; | 3102 return 0; |
3058 } | 3103 } |
3059 | 3104 |
3060 static void implicit_weight_table(H264Context *h){ | 3105 static void implicit_weight_table(H264Context *h){ |
3061 MpegEncContext * const s = &h->s; | 3106 MpegEncContext * const s = &h->s; |
3062 int list, i; | |
3063 int ref0, ref1; | 3107 int ref0, ref1; |
3064 int cur_poc = s->current_picture_ptr->poc; | 3108 int cur_poc = s->current_picture_ptr->poc; |
3065 | 3109 |
3066 if( h->ref_count[0] == 1 && h->ref_count[1] == 1 | 3110 if( h->ref_count[0] == 1 && h->ref_count[1] == 1 |
3067 && h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2*cur_poc){ | 3111 && h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2*cur_poc){ |
3154 * @return the removed picture or NULL if an error occures | 3198 * @return the removed picture or NULL if an error occures |
3155 */ | 3199 */ |
3156 static Picture * remove_long(H264Context *h, int i){ | 3200 static Picture * remove_long(H264Context *h, int i){ |
3157 Picture *pic; | 3201 Picture *pic; |
3158 | 3202 |
3159 if(i >= h->long_ref_count) return NULL; | |
3160 pic= h->long_ref[i]; | 3203 pic= h->long_ref[i]; |
3161 if(pic==NULL) return NULL; | |
3162 | |
3163 h->long_ref[i]= NULL; | 3204 h->long_ref[i]= NULL; |
3164 memmove(&h->long_ref[i], &h->long_ref[i+1], (h->long_ref_count - i - 1)*sizeof(Picture*)); | 3205 if(pic) h->long_ref_count--; |
3165 h->long_ref_count--; | |
3166 | 3206 |
3167 return pic; | 3207 return pic; |
3208 } | |
3209 | |
3210 /** | |
3211 * print short term list | |
3212 */ | |
3213 static void print_short_term(H264Context *h) { | |
3214 uint32_t i; | |
3215 if(h->s.avctx->debug&FF_DEBUG_MMCO) { | |
3216 av_log(h->s.avctx, AV_LOG_DEBUG, "short term list:\n"); | |
3217 for(i=0; i<h->short_ref_count; i++){ | |
3218 Picture *pic= h->short_ref[i]; | |
3219 av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", i, pic->frame_num, pic->poc, pic->data[0]); | |
3220 } | |
3221 } | |
3222 } | |
3223 | |
3224 /** | |
3225 * print long term list | |
3226 */ | |
3227 static void print_long_term(H264Context *h) { | |
3228 uint32_t i; | |
3229 if(h->s.avctx->debug&FF_DEBUG_MMCO) { | |
3230 av_log(h->s.avctx, AV_LOG_DEBUG, "long term list:\n"); | |
3231 for(i = 0; i < 16; i++){ | |
3232 Picture *pic= h->long_ref[i]; | |
3233 if (pic) { | |
3234 av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n", i, pic->frame_num, pic->poc, pic->data[0]); | |
3235 } | |
3236 } | |
3237 } | |
3168 } | 3238 } |
3169 | 3239 |
3170 /** | 3240 /** |
3171 * Executes the reference picture marking (memory management control operations). | 3241 * Executes the reference picture marking (memory management control operations). |
3172 */ | 3242 */ |
3173 static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ | 3243 static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ |
3174 MpegEncContext * const s = &h->s; | 3244 MpegEncContext * const s = &h->s; |
3175 int i; | 3245 int i, j; |
3176 int current_is_long=0; | 3246 int current_is_long=0; |
3177 Picture *pic; | 3247 Picture *pic; |
3178 | 3248 |
3179 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) | 3249 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) |
3180 av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); | 3250 av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); |
3211 | 3281 |
3212 current_is_long=1; | 3282 current_is_long=1; |
3213 break; | 3283 break; |
3214 case MMCO_SET_MAX_LONG: | 3284 case MMCO_SET_MAX_LONG: |
3215 assert(mmco[i].long_index <= 16); | 3285 assert(mmco[i].long_index <= 16); |
3216 while(mmco[i].long_index < h->long_ref_count){ | 3286 // just remove the long term which index is greater than new max |
3217 pic= remove_long(h, mmco[i].long_index); | 3287 for(j = mmco[i].long_index; j<16; j++){ |
3218 pic->reference=0; | 3288 pic = remove_long(h, j); |
3219 } | 3289 if (pic) pic->reference=0; |
3220 while(mmco[i].long_index > h->long_ref_count){ | |
3221 h->long_ref[ h->long_ref_count++ ]= NULL; | |
3222 } | 3290 } |
3223 break; | 3291 break; |
3224 case MMCO_RESET: | 3292 case MMCO_RESET: |
3225 while(h->short_ref_count){ | 3293 while(h->short_ref_count){ |
3226 pic= remove_short(h, h->short_ref[0]->frame_num); | 3294 pic= remove_short(h, h->short_ref[0]->frame_num); |
3227 pic->reference=0; | 3295 pic->reference=0; |
3228 } | 3296 } |
3229 while(h->long_ref_count){ | 3297 for(j = 0; j < 16; j++) { |
3230 pic= remove_long(h, h->long_ref_count-1); | 3298 pic= remove_long(h, j); |
3231 pic->reference=0; | 3299 if(pic) pic->reference=0; |
3232 } | 3300 } |
3233 break; | 3301 break; |
3234 default: assert(0); | 3302 default: assert(0); |
3235 } | 3303 } |
3236 } | 3304 } |
3248 h->short_ref[0]= s->current_picture_ptr; | 3316 h->short_ref[0]= s->current_picture_ptr; |
3249 h->short_ref[0]->long_ref=0; | 3317 h->short_ref[0]->long_ref=0; |
3250 h->short_ref_count++; | 3318 h->short_ref_count++; |
3251 } | 3319 } |
3252 | 3320 |
3321 print_short_term(h); | |
3322 print_long_term(h); | |
3253 return 0; | 3323 return 0; |
3254 } | 3324 } |
3255 | 3325 |
3256 static int decode_ref_pic_marking(H264Context *h){ | 3326 static int decode_ref_pic_marking(H264Context *h){ |
3257 MpegEncContext * const s = &h->s; | 3327 MpegEncContext * const s = &h->s; |
4770 if( h->sps.mb_aff ) { | 4840 if( h->sps.mb_aff ) { |
4771 av_log( h->s.avctx, AV_LOG_ERROR, "Fields not supported with CABAC\n" ); | 4841 av_log( h->s.avctx, AV_LOG_ERROR, "Fields not supported with CABAC\n" ); |
4772 return -1; | 4842 return -1; |
4773 } | 4843 } |
4774 | 4844 |
4845 tprintf("pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); | |
4775 if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE ) { | 4846 if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE ) { |
4776 /* read skip flags */ | 4847 /* read skip flags */ |
4777 if( decode_cabac_mb_skip( h ) ) { | 4848 if( decode_cabac_mb_skip( h ) ) { |
4778 decode_mb_skip(h); | 4849 decode_mb_skip(h); |
4779 | 4850 |
5271 ABS( q1 - q0 ) < beta ) { | 5342 ABS( q1 - q0 ) < beta ) { |
5272 const int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); | 5343 const int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); |
5273 | 5344 |
5274 pix[-1] = clip_uint8( p0 + i_delta ); /* p0' */ | 5345 pix[-1] = clip_uint8( p0 + i_delta ); /* p0' */ |
5275 pix[0] = clip_uint8( q0 - i_delta ); /* q0' */ | 5346 pix[0] = clip_uint8( q0 - i_delta ); /* q0' */ |
5347 //tprintf("filter_mb_edgecv i:%d d:%d, qp:%d, indexA:%d, alpha:%d, beta:%d, tc:%d\n# bS:%d -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, qp, index_a, alpha, beta, tc, bS[i], pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1); | |
5276 } | 5348 } |
5277 pix += stride; | 5349 pix += stride; |
5278 } | 5350 } |
5279 }else{ | 5351 }else{ |
5280 /* 2px edge length (because we use same bS than the one for luma) */ | 5352 /* 2px edge length (because we use same bS than the one for luma) */ |
5288 ABS( p1 - p0 ) < beta && | 5360 ABS( p1 - p0 ) < beta && |
5289 ABS( q1 - q0 ) < beta ) { | 5361 ABS( q1 - q0 ) < beta ) { |
5290 | 5362 |
5291 pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */ | 5363 pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */ |
5292 pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */ | 5364 pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */ |
5365 //tprintf("filter_mb_edgecv i:%d d:%d\n# bS:4 -> [%02x, %02x, %02x, %02x, %02x, %02x] =>[%02x, %02x, %02x, %02x]\n", i, d, pix[-3], p1, p0, q0, q1, pix[2], p1, pix[-1], pix[0], q1); | |
5293 } | 5366 } |
5294 pix += stride; | 5367 pix += stride; |
5295 } | 5368 } |
5296 } | 5369 } |
5297 } | 5370 } |
5532 ABS( h->mv_cache[0][b_idx][0] - left_mv[0] ) >= 4 || | 5605 ABS( h->mv_cache[0][b_idx][0] - left_mv[0] ) >= 4 || |
5533 ABS( h->mv_cache[0][b_idx][1] - left_mv[1] ) >= 4 ) | 5606 ABS( h->mv_cache[0][b_idx][1] - left_mv[1] ) >= 4 ) |
5534 bS[i] = 1; | 5607 bS[i] = 1; |
5535 else | 5608 else |
5536 bS[i] = 0; | 5609 bS[i] = 0; |
5537 } | 5610 } else { |
5538 else { | |
5539 /* FIXME Add support for B frame */ | 5611 /* FIXME Add support for B frame */ |
5540 return; | 5612 return; |
5541 } | 5613 } |
5542 } | 5614 } |
5543 | 5615 |
5545 continue; | 5617 continue; |
5546 } | 5618 } |
5547 | 5619 |
5548 /* Filter edge */ | 5620 /* Filter edge */ |
5549 qp = ( s->qscale + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; | 5621 qp = ( s->qscale + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1; |
5622 //tprintf("filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp, s->current_picture.qscale_table[mbn_xy]); | |
5550 if( dir == 0 ) { | 5623 if( dir == 0 ) { |
5551 filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp ); | 5624 filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp ); |
5552 if( (edge&1) == 0 ) { | 5625 if( (edge&1) == 0 ) { |
5553 int chroma_qp = ( h->chroma_qp + | 5626 int chroma_qp = ( h->chroma_qp + |
5554 get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; | 5627 get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1; |
6173 h->prev_poc_msb= h->poc_msb; | 6246 h->prev_poc_msb= h->poc_msb; |
6174 h->prev_poc_lsb= h->poc_lsb; | 6247 h->prev_poc_lsb= h->poc_lsb; |
6175 } | 6248 } |
6176 if(s->current_picture_ptr->reference) | 6249 if(s->current_picture_ptr->reference) |
6177 execute_ref_pic_marking(h, h->mmco, h->mmco_index); | 6250 execute_ref_pic_marking(h, h->mmco, h->mmco_index); |
6178 else | |
6179 assert(h->mmco_index==0); | |
6180 | 6251 |
6181 ff_er_frame_end(s); | 6252 ff_er_frame_end(s); |
6182 | 6253 |
6183 MPV_frame_end(s); | 6254 MPV_frame_end(s); |
6184 | 6255 |
6284 av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n"); | 6355 av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n"); |
6285 return -1; | 6356 return -1; |
6286 } | 6357 } |
6287 | 6358 |
6288 { | 6359 { |
6360 //#define DECODE_ORDER | |
6361 Picture *out = s->current_picture_ptr; | |
6362 #ifndef DECODE_ORDER | |
6289 /* Sort B-frames into display order | 6363 /* Sort B-frames into display order |
6290 * FIXME doesn't allow for multiple delayed frames */ | 6364 * FIXME doesn't allow for multiple delayed frames */ |
6291 Picture *cur = s->current_picture_ptr; | 6365 Picture *cur = s->current_picture_ptr; |
6292 Picture *prev = h->delayed_pic[0]; | 6366 Picture *prev = h->delayed_pic[0]; |
6293 Picture *out; | |
6294 | 6367 |
6295 if(s->low_delay | 6368 if(s->low_delay |
6296 && (cur->pict_type == B_TYPE | 6369 && (cur->pict_type == B_TYPE |
6297 || (!h->sps.gaps_in_frame_num_allowed_flag | 6370 || (!h->sps.gaps_in_frame_num_allowed_flag |
6298 && prev && cur->poc - prev->poc > 2))){ | 6371 && prev && cur->poc - prev->poc > 2))){ |
6310 if(s->low_delay || !prev || out == prev){ | 6383 if(s->low_delay || !prev || out == prev){ |
6311 if(prev && prev->reference == 1) | 6384 if(prev && prev->reference == 1) |
6312 prev->reference = 0; | 6385 prev->reference = 0; |
6313 h->delayed_pic[0] = cur; | 6386 h->delayed_pic[0] = cur; |
6314 } | 6387 } |
6388 #endif | |
6315 | 6389 |
6316 *pict= *(AVFrame*)out; | 6390 *pict= *(AVFrame*)out; |
6317 } | 6391 } |
6318 | 6392 |
6319 ff_print_debug_info(s, pict); | 6393 ff_print_debug_info(s, pict); |