comparison h264.c @ 2447:0237bb5ca0f0 libavcodec

simplify reference list 1 swaping fix? seems its not used by any samples i found though
author michael
date Sun, 23 Jan 2005 03:49:36 +0000
parents 358813ec4ca2
children 6f719184e2b9
comparison
equal deleted inserted replaced
2446:7dc7f1a9f5d6 2447:0237bb5ca0f0
2884 tprintf("current poc: %d, smallest_poc_greater_than_current: %d\n", s->current_picture_ptr->poc, smallest_poc_greater_than_current); 2884 tprintf("current poc: %d, smallest_poc_greater_than_current: %d\n", s->current_picture_ptr->poc, smallest_poc_greater_than_current);
2885 2885
2886 // find the largest poc 2886 // find the largest poc
2887 for(list=0; list<2; list++){ 2887 for(list=0; list<2; list++){
2888 int index = 0; 2888 int index = 0;
2889 int swap_first_L1 = 0; 2889 int j= -99;
2890 2890 int step= list ? -1 : 1;
2891 if (0 == list) { 2891
2892 for(i=smallest_poc_greater_than_current-1; i>=0 && index < h->ref_count[list]; i--) { 2892 for(i=0; i<h->short_ref_count && index < h->ref_count[list]; i++, j+=step) {
2893 if(sorted_short_ref[i].reference != 3) continue; 2893 while(j<0 || j>= h->short_ref_count){
2894 h->default_ref_list[list][index ]= sorted_short_ref[i]; 2894 step = -step;
2895 h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num; 2895 j= smallest_poc_greater_than_current + (step>>1);
2896 } 2896 }
2897 for(i=smallest_poc_greater_than_current; i<h->short_ref_count && index < h->ref_count[list]; i++) { 2897 if(sorted_short_ref[j].reference != 3) continue;
2898 if(sorted_short_ref[i].reference != 3) continue; 2898 h->default_ref_list[list][index ]= sorted_short_ref[j];
2899 h->default_ref_list[list][index ]= sorted_short_ref[i]; 2899 h->default_ref_list[list][index++].pic_id= sorted_short_ref[j].frame_num;
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 } 2900 }
2916 2901
2917 for(i = 0; i < 16 && index < h->ref_count[ list ]; i++){ 2902 for(i = 0; i < 16 && index < h->ref_count[ list ]; i++){
2918 if(h->long_ref[i] == NULL) continue; 2903 if(h->long_ref[i] == NULL) continue;
2919 if(h->long_ref[i]->reference != 3) continue; 2904 if(h->long_ref[i]->reference != 3) continue;
2920 2905
2921 h->default_ref_list[ list ][index ]= *h->long_ref[i]; 2906 h->default_ref_list[ list ][index ]= *h->long_ref[i];
2922 h->default_ref_list[ list ][index++].pic_id= i;; 2907 h->default_ref_list[ list ][index++].pic_id= i;;
2923 } 2908 }
2924 2909
2925 if(list && (3 == swap_first_L1) && (1 < index)){ 2910 if(list && (smallest_poc_greater_than_current<=0 || smallest_poc_greater_than_current>=h->short_ref_count) && (1 < index)){
2926 // swap the two first elements of L1 when 2911 // swap the two first elements of L1 when
2927 // L0 and L1 are identical 2912 // L0 and L1 are identical
2928 Picture temp= h->default_ref_list[1][0]; 2913 Picture temp= h->default_ref_list[1][0];
2929 h->default_ref_list[1][0] = h->default_ref_list[1][1]; 2914 h->default_ref_list[1][0] = h->default_ref_list[1][1];
2930 h->default_ref_list[1][0] = temp; 2915 h->default_ref_list[1][0] = temp;