Revision 7e2eb4ba libavcodec/mpegvideo.c

View differences:

libavcodec/mpegvideo.c
316 316
    s->prev_pict_types[0]= s->dropable ? FF_B_TYPE : s->pict_type;
317 317
    if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == FF_B_TYPE)
318 318
        pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
319
    pic->owner2 = s;
319 320

  
320 321
    return 0;
321 322
fail: //for the FF_ALLOCZ_OR_GOTO macro
......
946 947
    }
947 948
}
948 949

  
950
void ff_release_unused_pictures(MpegEncContext *s, int remove_current)
951
{
952
    int i;
953

  
954
    /* release non reference frames */
955
    for(i=0; i<s->picture_count; i++){
956
        if(s->picture[i].data[0] && !s->picture[i].reference
957
           && s->picture[i].owner2 == s
958
           && (remove_current || &s->picture[i] != s->current_picture_ptr)
959
           /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
960
            free_frame_buffer(s, &s->picture[i]);
961
        }
962
    }
963
}
964

  
949 965
int ff_find_unused_picture(MpegEncContext *s, int shared){
950 966
    int i;
951 967

  
......
1025 1041
    }
1026 1042

  
1027 1043
    if(!s->encoding){
1028
        /* release non reference frames */
1029
        for(i=0; i<s->picture_count; i++){
1030
            if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
1031
                free_frame_buffer(s, &s->picture[i]);
1032
            }
1033
        }
1044
        ff_release_unused_pictures(s, 1);
1034 1045

  
1035 1046
        if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL)
1036 1047
            pic= s->current_picture_ptr; //we already have a unused image (maybe it was set before reading the header)

Also available in: Unified diff