const int i2= list ? h->short_ref_count - i - 1 : i;
const int i2= list ? i : h->short_ref_count - i - 1;
static int fill_default_ref_list(H264Context *h){    MpegEncContext * const s = &h->s;    int i;    Picture sorted_short_ref[16];        if(h->slice_type==B_TYPE){        int out_i;        int limit= -1;        for(out_i=0; out_i<h->short_ref_count; out_i++){            int best_i=-1;            int best_poc=INT_MAX;            for(i=0; i<h->short_ref_count; i++){                const int poc= h->short_ref[i]->poc;                if(poc > limit && poc < best_poc){                    best_poc= poc;                    best_i= i;                }            }                        assert(best_i != -1);                        limit= best_poc;            sorted_short_ref[out_i]= *h->short_ref[best_i];        }    }    if(s->picture_structure == PICT_FRAME){        if(h->slice_type==B_TYPE){            const int current_poc= s->current_picture_ptr->poc;            int list;            for(list=0; list<2; list++){                int index=0;                for(i=0; i<h->short_ref_count && index < h->ref_count[list]; i++){                    const int i2= list ? h->short_ref_count - i - 1 : i;                    const int poc= sorted_short_ref[i2].poc;                                        if(sorted_short_ref[i2].reference != 3) continue; //FIXME refernce field shit                    if((list==1 && poc > current_poc) || (list==0 && poc < current_poc)){                        h->default_ref_list[list][index  ]= sorted_short_ref[i2];                        h->default_ref_list[list][index++].pic_id= sorted_short_ref[i2].frame_num;                    }                }                for(i=0; i<h->long_ref_count && index < h->ref_count[ list ]; i++){                    if(h->long_ref[i]->reference != 3) continue;                    h->default_ref_list[ list ][index  ]= *h->long_ref[i];                    h->default_ref_list[ list ][index++].pic_id= i;;                }                                if(h->long_ref_count > 1 && h->short_ref_count==0){                    Picture temp= h->default_ref_list[1][0];                    h->default_ref_list[1][0] = h->default_ref_list[1][1];                    h->default_ref_list[1][0] = temp;                }                if(index < h->ref_count[ list ])                    memset(&h->default_ref_list[list][index], 0, sizeof(Picture)*(h->ref_count[ list ] - index));            }        }else{            int index=0;            for(i=0; i<h->short_ref_count && index < h->ref_count[0]; i++){                if(h->short_ref[i]->reference != 3) continue; //FIXME refernce field shit                h->default_ref_list[0][index  ]= *h->short_ref[i];                h->default_ref_list[0][index++].pic_id= h->short_ref[i]->frame_num;            }            for(i=0; i<h->long_ref_count && index < h->ref_count[0]; i++){                if(h->long_ref[i]->reference != 3) continue;                h->default_ref_list[0][index  ]= *h->long_ref[i];                h->default_ref_list[0][index++].pic_id= i;;            }            if(index < h->ref_count[0])                memset(&h->default_ref_list[0][index], 0, sizeof(Picture)*(h->ref_count[0] - index));        }    }else{ //FIELD        if(h->slice_type==B_TYPE){        }else{            //FIXME second field balh        }    }    return 0;}