Mercurial > libavcodec.hg
comparison h264.c @ 5779:ad3168a70fbe libavcodec
Reindent fill_default_ref_list after changes for PAFF
patch by Jeff Downs, heydowns a borg d com
original thread:
Subject: [FFmpeg-devel] [PATCH] Implement PAFF in H.264
Date: 18/09/07 20:30
author | andoma |
---|---|
date | Fri, 05 Oct 2007 13:47:46 +0000 |
parents | c4984d69d373 |
children | bd3d1e4f937a |
comparison
equal
deleted
inserted
replaced
5778:c4984d69d373 | 5779:ad3168a70fbe |
---|---|
2914 smallest_poc_greater_than_current = out_i; | 2914 smallest_poc_greater_than_current = out_i; |
2915 } | 2915 } |
2916 } | 2916 } |
2917 } | 2917 } |
2918 | 2918 |
2919 tprintf(h->s.avctx, "current poc: %d, smallest_poc_greater_than_current: %d\n", s->current_picture_ptr->poc, smallest_poc_greater_than_current); | 2919 tprintf(h->s.avctx, "current poc: %d, smallest_poc_greater_than_current: %d\n", s->current_picture_ptr->poc, smallest_poc_greater_than_current); |
2920 | 2920 |
2921 // find the largest poc | 2921 // find the largest poc |
2922 for(list=0; list<2; list++){ | 2922 for(list=0; list<2; list++){ |
2923 int index = 0; | 2923 int index = 0; |
2924 int j= -99; | 2924 int j= -99; |
2925 int step= list ? -1 : 1; | 2925 int step= list ? -1 : 1; |
2926 | 2926 |
2927 for(i=0; i<h->short_ref_count && index < h->ref_count[list]; i++, j+=step) { | 2927 for(i=0; i<h->short_ref_count && index < h->ref_count[list]; i++, j+=step) { |
2928 int sel; | |
2929 while(j<0 || j>= h->short_ref_count){ | |
2930 if(j != -99 && step == (list ? -1 : 1)) | |
2931 return -1; | |
2932 step = -step; | |
2933 j= smallest_poc_greater_than_current + (step>>1); | |
2934 } | |
2935 sel = sorted_short_ref[j].reference | structure_sel; | |
2936 if(sel != PICT_FRAME) continue; | |
2937 frame_list[list][index ]= sorted_short_ref[j]; | |
2938 frame_list[list][index++].pic_id= sorted_short_ref[j].frame_num; | |
2939 } | |
2940 short_len[list] = index; | |
2941 | |
2942 for(i = 0; i < 16 && index < h->ref_count[ list ]; i++){ | |
2943 int sel; | |
2944 if(h->long_ref[i] == NULL) continue; | |
2945 sel = h->long_ref[i]->reference | structure_sel; | |
2946 if(sel != PICT_FRAME) continue; | |
2947 | |
2948 frame_list[ list ][index ]= *h->long_ref[i]; | |
2949 frame_list[ list ][index++].pic_id= i;; | |
2950 } | |
2951 len[list] = index; | |
2952 | |
2953 if(list && (smallest_poc_greater_than_current<=0 || smallest_poc_greater_than_current>=h->short_ref_count) && (1 < index)){ | |
2954 // swap the two first elements of L1 when | |
2955 // L0 and L1 are identical | |
2956 Picture temp= frame_list[1][0]; | |
2957 frame_list[1][0] = frame_list[1][1]; | |
2958 frame_list[1][1] = temp; | |
2959 } | |
2960 | |
2961 } | |
2962 | |
2963 for(list=0; list<2; list++){ | |
2964 if (FIELD_PICTURE) | |
2965 len[list] = split_field_ref_list(h->default_ref_list[list], | |
2966 h->ref_count[list], | |
2967 frame_list[list], | |
2968 len[list], | |
2969 s->picture_structure, | |
2970 short_len[list]); | |
2971 | |
2972 if(len[list] < h->ref_count[ list ]) | |
2973 memset(&h->default_ref_list[list][len[list]], 0, sizeof(Picture)*(h->ref_count[ list ] - len[list])); | |
2974 } | |
2975 | |
2976 | |
2977 }else{ | |
2978 int index=0; | |
2979 int short_len; | |
2980 for(i=0; i<h->short_ref_count; i++){ | |
2981 int sel; | 2928 int sel; |
2982 sel = h->short_ref[i]->reference | structure_sel; | 2929 while(j<0 || j>= h->short_ref_count){ |
2930 if(j != -99 && step == (list ? -1 : 1)) | |
2931 return -1; | |
2932 step = -step; | |
2933 j= smallest_poc_greater_than_current + (step>>1); | |
2934 } | |
2935 sel = sorted_short_ref[j].reference | structure_sel; | |
2983 if(sel != PICT_FRAME) continue; | 2936 if(sel != PICT_FRAME) continue; |
2984 frame_list[0][index ]= *h->short_ref[i]; | 2937 frame_list[list][index ]= sorted_short_ref[j]; |
2985 frame_list[0][index++].pic_id= h->short_ref[i]->frame_num; | 2938 frame_list[list][index++].pic_id= sorted_short_ref[j].frame_num; |
2986 } | 2939 } |
2987 short_len = index; | 2940 short_len[list] = index; |
2988 for(i = 0; i < 16; i++){ | 2941 |
2942 for(i = 0; i < 16 && index < h->ref_count[ list ]; i++){ | |
2989 int sel; | 2943 int sel; |
2990 if(h->long_ref[i] == NULL) continue; | 2944 if(h->long_ref[i] == NULL) continue; |
2991 sel = h->long_ref[i]->reference | structure_sel; | 2945 sel = h->long_ref[i]->reference | structure_sel; |
2992 if(sel != PICT_FRAME) continue; | 2946 if(sel != PICT_FRAME) continue; |
2993 frame_list[0][index ]= *h->long_ref[i]; | 2947 |
2994 frame_list[0][index++].pic_id= i;; | 2948 frame_list[ list ][index ]= *h->long_ref[i]; |
2995 } | 2949 frame_list[ list ][index++].pic_id= i;; |
2996 | 2950 } |
2951 len[list] = index; | |
2952 | |
2953 if(list && (smallest_poc_greater_than_current<=0 || smallest_poc_greater_than_current>=h->short_ref_count) && (1 < index)){ | |
2954 // swap the two first elements of L1 when | |
2955 // L0 and L1 are identical | |
2956 Picture temp= frame_list[1][0]; | |
2957 frame_list[1][0] = frame_list[1][1]; | |
2958 frame_list[1][1] = temp; | |
2959 } | |
2960 | |
2961 } | |
2962 | |
2963 for(list=0; list<2; list++){ | |
2997 if (FIELD_PICTURE) | 2964 if (FIELD_PICTURE) |
2998 index = split_field_ref_list(h->default_ref_list[0], | 2965 len[list] = split_field_ref_list(h->default_ref_list[list], |
2999 h->ref_count[0], frame_list[0], | 2966 h->ref_count[list], |
3000 index, s->picture_structure, | 2967 frame_list[list], |
3001 short_len); | 2968 len[list], |
3002 | 2969 s->picture_structure, |
3003 if(index < h->ref_count[0]) | 2970 short_len[list]); |
3004 memset(&h->default_ref_list[0][index], 0, sizeof(Picture)*(h->ref_count[0] - index)); | 2971 |
2972 if(len[list] < h->ref_count[ list ]) | |
2973 memset(&h->default_ref_list[list][len[list]], 0, sizeof(Picture)*(h->ref_count[ list ] - len[list])); | |
2974 } | |
2975 | |
2976 | |
2977 }else{ | |
2978 int index=0; | |
2979 int short_len; | |
2980 for(i=0; i<h->short_ref_count; i++){ | |
2981 int sel; | |
2982 sel = h->short_ref[i]->reference | structure_sel; | |
2983 if(sel != PICT_FRAME) continue; | |
2984 frame_list[0][index ]= *h->short_ref[i]; | |
2985 frame_list[0][index++].pic_id= h->short_ref[i]->frame_num; | |
2986 } | |
2987 short_len = index; | |
2988 for(i = 0; i < 16; i++){ | |
2989 int sel; | |
2990 if(h->long_ref[i] == NULL) continue; | |
2991 sel = h->long_ref[i]->reference | structure_sel; | |
2992 if(sel != PICT_FRAME) continue; | |
2993 frame_list[0][index ]= *h->long_ref[i]; | |
2994 frame_list[0][index++].pic_id= i;; | |
2995 } | |
2996 | |
2997 if (FIELD_PICTURE) | |
2998 index = split_field_ref_list(h->default_ref_list[0], | |
2999 h->ref_count[0], frame_list[0], | |
3000 index, s->picture_structure, | |
3001 short_len); | |
3002 | |
3003 if(index < h->ref_count[0]) | |
3004 memset(&h->default_ref_list[0][index], 0, sizeof(Picture)*(h->ref_count[0] - index)); | |
3005 } | 3005 } |
3006 #ifdef TRACE | 3006 #ifdef TRACE |
3007 for (i=0; i<h->ref_count[0]; i++) { | 3007 for (i=0; i<h->ref_count[0]; i++) { |
3008 tprintf(h->s.avctx, "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]); | 3008 tprintf(h->s.avctx, "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]); |
3009 } | 3009 } |