changeset 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 7dc7f1a9f5d6
children bfa9192a22ce
files h264.c
diffstat 1 files changed, 11 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/h264.c	Sat Jan 22 18:00:36 2005 +0000
+++ b/h264.c	Sun Jan 23 03:49:36 2005 +0000
@@ -2886,32 +2886,17 @@
             // find the largest poc
             for(list=0; list<2; list++){
                 int index = 0;
-                int swap_first_L1 = 0;
-
-                if (0 == list) {
-                    for(i=smallest_poc_greater_than_current-1; i>=0 && index < h->ref_count[list]; i--) {
-                        if(sorted_short_ref[i].reference != 3) continue;
-                        h->default_ref_list[list][index  ]= sorted_short_ref[i];
-                        h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num;
-                    }
-                    for(i=smallest_poc_greater_than_current; i<h->short_ref_count && index < h->ref_count[list]; i++) {
-                        if(sorted_short_ref[i].reference != 3) continue;
-                        h->default_ref_list[list][index  ]= sorted_short_ref[i];
-                        h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num;
+                int j= -99;
+                int step= list ? -1 : 1;
+
+                for(i=0; i<h->short_ref_count && index < h->ref_count[list]; i++, j+=step) {
+                    while(j<0 || j>= h->short_ref_count){
+                        step = -step;
+                        j= smallest_poc_greater_than_current + (step>>1);
                     }
-                } else {
-                    for(i=smallest_poc_greater_than_current; i<h->short_ref_count && index < h->ref_count[list]; i++) {
-                        if(sorted_short_ref[i].reference != 3) continue;
-                        swap_first_L1 |= 1;
-                        h->default_ref_list[list][index  ]= sorted_short_ref[i];
-                        h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num;
-                    }
-                    for(i=smallest_poc_greater_than_current-1; i>=0 && index < h->ref_count[list]; i--) {
-                        if(sorted_short_ref[i].reference != 3) continue;
-                        swap_first_L1 |= 2;
-                        h->default_ref_list[list][index  ]= sorted_short_ref[i];
-                        h->default_ref_list[list][index++].pic_id= sorted_short_ref[i].frame_num;
-                    }
+                    if(sorted_short_ref[j].reference != 3) continue;
+                    h->default_ref_list[list][index  ]= sorted_short_ref[j];
+                    h->default_ref_list[list][index++].pic_id= sorted_short_ref[j].frame_num;
                 }
 
                 for(i = 0; i < 16 && index < h->ref_count[ list ]; i++){
@@ -2922,7 +2907,7 @@
                     h->default_ref_list[ list ][index++].pic_id= i;;
                 }
                 
-                if(list && (3 == swap_first_L1) && (1 < index)){
+                if(list && (smallest_poc_greater_than_current<=0 || smallest_poc_greater_than_current>=h->short_ref_count) && (1 < index)){
                     // swap the two first elements of L1 when
                     // L0 and L1 are identical
                     Picture temp= h->default_ref_list[1][0];