Revision 0da71265 libavcodec/mpegvideo.c

View differences:

libavcodec/mpegvideo.c
227 227
 * The pixels are allocated/set by calling get_buffer() if shared=0
228 228
 */
229 229
static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
230
    
230
    const int big_mb_num= (s->mb_width+1)*(s->mb_height+1);
231
    int i;
232

  
231 233
    if(shared){
232 234
        assert(pic->data[0]);
233 235
        assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED);
......
268 270

  
269 271
        CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(uint8_t)+1) //the +1 is for the slice end check
270 272
        CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(uint8_t))
273
        if(s->out_format == FMT_H264){
274
            CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(uint16_t))
275
            pic->mb_type= pic->mb_type_base + s->mb_width+2;
276
            for(i=0; i<2; i++){
277
                CHECKED_ALLOCZ(pic->motion_val[i], 2 * 16 * s->mb_num * sizeof(uint16_t))
278
                CHECKED_ALLOCZ(pic->ref_index[i] , 4 * s->mb_num * sizeof(uint8_t))
279
            }
280
        }
271 281
        pic->qstride= s->mb_width;
272 282
    }
273
    
283

  
274 284
    //it might be nicer if the application would keep track of these but it would require a API change
275 285
    memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1);
276 286
    s->prev_pict_types[0]= s->pict_type;
......
298 308
    av_freep(&pic->mb_cmp_score);
299 309
    av_freep(&pic->mbskip_table);
300 310
    av_freep(&pic->qscale_table);
301
    
311
    av_freep(&pic->mb_type_base);
312
    pic->mb_type= NULL;
313
    for(i=0; i<2; i++){
314
        av_freep(&pic->motion_val[i]);
315
        av_freep(&pic->ref_index[i]);
316
    }
317

  
302 318
    if(pic->type == FF_BUFFER_TYPE_INTERNAL){
303 319
        for(i=0; i<4; i++){
304 320
            av_freep(&pic->base[i]);
......
855 871
        }
856 872
    }else{
857 873
        for(i=0; i<MAX_PICTURE_COUNT; i++){
858
            if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) break;
874
            if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) break; //FIXME
859 875
        }
860 876
        for(i=0; i<MAX_PICTURE_COUNT; i++){
861 877
            if(s->picture[i].data[0]==NULL) break;
......
873 889
    AVFrame *pic;
874 890

  
875 891
    s->mb_skiped = 0;
876
    
892

  
893
    assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264);
894
        
877 895
    /* mark&release old frames */
878 896
    if (s->pict_type != B_TYPE && s->last_picture_ptr) {
879 897
        avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
......
895 913
        i= find_unused_picture(s, 0);
896 914
    
897 915
        pic= (AVFrame*)&s->picture[i];
898
        pic->reference= s->pict_type != B_TYPE;
916
        pic->reference= s->pict_type != B_TYPE ? 3 : 0;
899 917

  
900 918
        if(s->current_picture_ptr)
901 919
            pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1;
......
905 923
        s->current_picture_ptr= &s->picture[i];
906 924
    }
907 925

  
926
    s->current_picture= *s->current_picture_ptr;
927
  if(s->out_format != FMT_H264){
908 928
    if (s->pict_type != B_TYPE) {
909 929
        s->last_picture_ptr= s->next_picture_ptr;
910 930
        s->next_picture_ptr= s->current_picture_ptr;
911 931
    }
912
    s->current_picture= *s->current_picture_ptr;
913 932
    if(s->last_picture_ptr) s->last_picture= *s->last_picture_ptr;
914 933
    if(s->next_picture_ptr) s->next_picture= *s->next_picture_ptr;
915 934
    if(s->new_picture_ptr ) s->new_picture = *s->new_picture_ptr;
......
931 950
        assert(s->pict_type != B_TYPE); //these should have been dropped if we dont have a reference
932 951
        goto alloc;
933 952
    }
953
  }
934 954
   
935 955
    s->hurry_up= s->avctx->hurry_up;
936 956
    s->error_resilience= avctx->error_resilience;
......
1059 1079
        i= find_unused_picture(s, 1);
1060 1080

  
1061 1081
        pic= (AVFrame*)&s->picture[i];
1062
        pic->reference= 1;
1082
        pic->reference= 3;
1063 1083
    
1064 1084
        for(i=0; i<4; i++){
1065 1085
            pic->data[i]= pic_arg->data[i];
......
1070 1090
        i= find_unused_picture(s, 0);
1071 1091

  
1072 1092
        pic= (AVFrame*)&s->picture[i];
1073
        pic->reference= 1;
1093
        pic->reference= 3;
1074 1094

  
1075 1095
        alloc_picture(s, (Picture*)pic, 0);
1076 1096
        for(i=0; i<4; i++){
......
1215 1235
    }
1216 1236
    
1217 1237
    if(s->reordered_input_picture[0]){
1218
        s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE;
1238
        s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0;
1219 1239

  
1220 1240
        s->new_picture= *s->reordered_input_picture[0];
1221 1241

  
......
3944 3964
    case P_TYPE: return 'P'; 
3945 3965
    case B_TYPE: return 'B'; 
3946 3966
    case S_TYPE: return 'S'; 
3967
    case SI_TYPE:return 'i'; 
3968
    case SP_TYPE:return 'p'; 
3947 3969
    default:     return '?';
3948 3970
    }
3949 3971
}

Also available in: Unified diff