comparison h264.c @ 2713:16258de8ae06 libavcodec

fix crash on negative POC
author lorenm
date Thu, 19 May 2005 04:48:06 +0000
parents 360024d31dab
children 4e71804a0c92
comparison
equal deleted inserted replaced
2712:9c1a436dac6b 2713:16258de8ae06
3154 int smallest_poc_greater_than_current = -1; 3154 int smallest_poc_greater_than_current = -1;
3155 Picture sorted_short_ref[32]; 3155 Picture sorted_short_ref[32];
3156 3156
3157 if(h->slice_type==B_TYPE){ 3157 if(h->slice_type==B_TYPE){
3158 int out_i; 3158 int out_i;
3159 int limit= -1; 3159 int limit= INT_MIN;
3160 3160
3161 /* sort frame according to poc in B slice */ 3161 /* sort frame according to poc in B slice */
3162 for(out_i=0; out_i<h->short_ref_count; out_i++){ 3162 for(out_i=0; out_i<h->short_ref_count; out_i++){
3163 int best_i=-1; 3163 int best_i=INT_MIN;
3164 int best_poc=INT_MAX; 3164 int best_poc=INT_MAX;
3165 3165
3166 for(i=0; i<h->short_ref_count; i++){ 3166 for(i=0; i<h->short_ref_count; i++){
3167 const int poc= h->short_ref[i]->poc; 3167 const int poc= h->short_ref[i]->poc;
3168 if(poc > limit && poc < best_poc){ 3168 if(poc > limit && poc < best_poc){
3169 best_poc= poc; 3169 best_poc= poc;
3170 best_i= i; 3170 best_i= i;
3171 } 3171 }
3172 } 3172 }
3173 3173
3174 assert(best_i != -1); 3174 assert(best_i != INT_MIN);
3175 3175
3176 limit= best_poc; 3176 limit= best_poc;
3177 sorted_short_ref[out_i]= *h->short_ref[best_i]; 3177 sorted_short_ref[out_i]= *h->short_ref[best_i];
3178 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); 3178 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);
3179 if (-1 == smallest_poc_greater_than_current) { 3179 if (-1 == smallest_poc_greater_than_current) {