Mercurial > libavcodec.hg
comparison h264.c @ 2409:26778a857b5b libavcodec
Sort B-frames into display order.
author | lorenm |
---|---|
date | Tue, 04 Jan 2005 01:12:48 +0000 |
parents | 2e90350ff8bc |
children | 9d780478f8a5 |
comparison
equal
deleted
inserted
replaced
2408:a6e4da1c28ee | 2409:26778a857b5b |
---|---|
279 Picture *short_ref[16]; | 279 Picture *short_ref[16]; |
280 Picture *long_ref[16]; | 280 Picture *long_ref[16]; |
281 Picture default_ref_list[2][32]; | 281 Picture default_ref_list[2][32]; |
282 Picture ref_list[2][32]; //FIXME size? | 282 Picture ref_list[2][32]; //FIXME size? |
283 Picture field_ref_list[2][32]; //FIXME size? | 283 Picture field_ref_list[2][32]; //FIXME size? |
284 Picture *delayed_pic[16]; //FIXME size? | |
284 | 285 |
285 /** | 286 /** |
286 * memory management control operations buffer. | 287 * memory management control operations buffer. |
287 */ | 288 */ |
288 MMCO mmco[MAX_MMCO_COUNT]; | 289 MMCO mmco[MAX_MMCO_COUNT]; |
2927 | 2928 |
2928 /** | 2929 /** |
2929 * instantaneous decoder refresh. | 2930 * instantaneous decoder refresh. |
2930 */ | 2931 */ |
2931 static void idr(H264Context *h){ | 2932 static void idr(H264Context *h){ |
2932 int i; | 2933 int i,j; |
2934 | |
2935 #define CHECK_DELAY(pic) \ | |
2936 for(j = 0; h->delayed_pic[j]; j++) \ | |
2937 if(pic == h->delayed_pic[j]){ \ | |
2938 pic->reference=1; \ | |
2939 break; \ | |
2940 } | |
2933 | 2941 |
2934 for(i=0; i<h->long_ref_count; i++){ | 2942 for(i=0; i<h->long_ref_count; i++){ |
2935 h->long_ref[i]->reference=0; | 2943 h->long_ref[i]->reference=0; |
2944 CHECK_DELAY(h->long_ref[i]); | |
2936 h->long_ref[i]= NULL; | 2945 h->long_ref[i]= NULL; |
2937 } | 2946 } |
2938 h->long_ref_count=0; | 2947 h->long_ref_count=0; |
2939 | 2948 |
2940 for(i=0; i<h->short_ref_count; i++){ | 2949 for(i=0; i<h->short_ref_count; i++){ |
2941 h->short_ref[i]->reference=0; | 2950 h->short_ref[i]->reference=0; |
2951 CHECK_DELAY(h->short_ref[i]); | |
2942 h->short_ref[i]= NULL; | 2952 h->short_ref[i]= NULL; |
2943 } | 2953 } |
2944 h->short_ref_count=0; | 2954 h->short_ref_count=0; |
2945 } | 2955 } |
2956 #undef CHECK_DELAY | |
2946 | 2957 |
2947 /** | 2958 /** |
2948 * | 2959 * |
2949 * @return the removed picture or NULL if an error occures | 2960 * @return the removed picture or NULL if an error occures |
2950 */ | 2961 */ |
6086 return -1; | 6097 return -1; |
6087 | 6098 |
6088 //FIXME do something with unavailable reference frames | 6099 //FIXME do something with unavailable reference frames |
6089 | 6100 |
6090 // if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_index, buf_size); | 6101 // if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_index, buf_size); |
6091 #if 0 | |
6092 if(s->pict_type==B_TYPE || s->low_delay){ | |
6093 *pict= *(AVFrame*)&s->current_picture; | |
6094 } else { | |
6095 *pict= *(AVFrame*)&s->last_picture; | |
6096 } | |
6097 #endif | |
6098 if(!s->current_picture_ptr){ | 6102 if(!s->current_picture_ptr){ |
6099 av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n"); | 6103 av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n"); |
6100 return -1; | 6104 return -1; |
6101 } | 6105 } |
6102 | 6106 |
6103 *pict= *(AVFrame*)&s->current_picture; //FIXME | 6107 { |
6108 /* Sort B-frames into display order | |
6109 * FIXME doesn't allow for multiple delayed frames */ | |
6110 Picture *cur = s->current_picture_ptr; | |
6111 Picture *prev = h->delayed_pic[0]; | |
6112 Picture *out; | |
6113 | |
6114 if(cur->pict_type == B_TYPE | |
6115 || (!h->sps.gaps_in_frame_num_allowed_flag | |
6116 && prev && cur->poc - prev->poc > 2)){ | |
6117 s->low_delay = 0; | |
6118 s->avctx->has_b_frames = 1; | |
6119 } | |
6120 | |
6121 if(s->low_delay || !prev || cur->pict_type == B_TYPE) | |
6122 out = cur; | |
6123 else{ | |
6124 out = prev; | |
6125 if(prev->reference == 1) | |
6126 prev->reference = 0; | |
6127 } | |
6128 if(!s->low_delay && (!prev || out == prev)) | |
6129 h->delayed_pic[0] = cur; | |
6130 | |
6131 *pict= *(AVFrame*)out; | |
6132 } | |
6133 | |
6104 ff_print_debug_info(s, pict); | 6134 ff_print_debug_info(s, pict); |
6105 assert(pict->data[0]); | 6135 assert(pict->data[0]); |
6106 //printf("out %d\n", (int)pict->data[0]); | 6136 //printf("out %d\n", (int)pict->data[0]); |
6107 #if 0 //? | 6137 #if 0 //? |
6108 | 6138 |