Revision a4dae92b libavcodec/h264.c

View differences:

libavcodec/h264.c
281 281
    Picture default_ref_list[2][32];
282 282
    Picture ref_list[2][32]; //FIXME size?
283 283
    Picture field_ref_list[2][32]; //FIXME size?
284
    Picture *delayed_pic[16]; //FIXME size?
284 285
    
285 286
    /**
286 287
     * memory management control operations buffer.
......
2929 2930
 * instantaneous decoder refresh.
2930 2931
 */
2931 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 2942
    for(i=0; i<h->long_ref_count; i++){
2935 2943
        h->long_ref[i]->reference=0;
2944
        CHECK_DELAY(h->long_ref[i]);
2936 2945
        h->long_ref[i]= NULL;
2937 2946
    }
2938 2947
    h->long_ref_count=0;
2939 2948

  
2940 2949
    for(i=0; i<h->short_ref_count; i++){
2941 2950
        h->short_ref[i]->reference=0;
2951
        CHECK_DELAY(h->short_ref[i]);
2942 2952
        h->short_ref[i]= NULL;
2943 2953
    }
2944 2954
    h->short_ref_count=0;
2945 2955
}
2956
#undef CHECK_DELAY
2946 2957

  
2947 2958
/**
2948 2959
 *
......
6088 6099
    //FIXME do something with unavailable reference frames    
6089 6100
 
6090 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 6102
    if(!s->current_picture_ptr){
6099 6103
        av_log(h->s.avctx, AV_LOG_DEBUG, "error, NO frame\n");
6100 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 6134
    ff_print_debug_info(s, pict);
6105 6135
    assert(pict->data[0]);
6106 6136
//printf("out %d\n", (int)pict->data[0]);

Also available in: Unified diff