Revision bbf18b21 libavcodec/mpegvideo.c

View differences:

libavcodec/mpegvideo.c
2018 2018
    return 0;
2019 2019
}
2020 2020

  
2021
static inline int block_max(DCTELEM *block){
2022
    int i, max;
2023
    
2024
    max=0;
2025
    for(i=0; i<64; i++){
2026
        int v= ABS(block[i]);
2027
        if(v>max) max= v;
2028
    }
2029
    return max;
2030
}
2031

  
2032
static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){
2033
    int x, y, plane;
2034
    int score=0;
2035

  
2036
    for(plane=0; plane<3; plane++){
2037
        const int stride= p->linesize[plane];
2038
        const int bw= plane ? 1 : 2;
2039
        for(y=0; y<s->mb_height*bw; y++){
2040
            for(x=0; x<s->mb_width*bw; x++){
2041
                int v;
2042
                
2043
                s->dsp.diff_pixels(s->block[0], p->data[plane] + 8*(x + y*stride), ref->data[plane] + 8*(x + y*stride), stride);
2044
                v= block_max(s->block[0]);
2045
                
2046
                if(v>score) 
2047
                    score=v;
2048
            }
2049
        }
2050
    }
2051

  
2052
    if(score < s->avctx->frame_skip_threshold)
2053
        return 1;
2054
    if(score < ((s->avctx->frame_skip_factor * s->lambda)>>8))
2055
        return 1;
2056
    return 0;
2057
}
2058

  
2021 2059
static void select_input_picture(MpegEncContext *s){
2022 2060
    int i;
2023 2061

  
......
2033 2071
            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
2034 2072
        }else{
2035 2073
            int b_frames;
2074

  
2075
            if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){
2076
                if(skip_check(s, s->input_picture[0], s->next_picture_ptr)){
2077
//av_log(NULL, AV_LOG_DEBUG, "skip %p %Ld\n", s->input_picture[0]->data[0], s->input_picture[0]->pts);
2078
                
2079
                    if(s->input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
2080
                        for(i=0; i<4; i++)
2081
                            s->input_picture[0]->data[i]= NULL;
2082
                        s->input_picture[0]->type= 0;            
2083
                    }else{
2084
                        assert(   s->input_picture[0]->type==FF_BUFFER_TYPE_USER 
2085
                               || s->input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
2036 2086
            
2087
                        s->avctx->release_buffer(s->avctx, (AVFrame*)s->input_picture[0]);
2088
                    }
2089

  
2090
                    goto no_output_pic;
2091
                }
2092
            }
2093

  
2037 2094
            if(s->flags&CODEC_FLAG_PASS2){
2038 2095
                for(i=0; i<s->max_b_frames+1; i++){
2039 2096
                    int pict_num= s->input_picture[0]->display_picture_number + i;
......
2116 2173
            }
2117 2174
        }
2118 2175
    }
2119
    
2176
no_output_pic:
2120 2177
    if(s->reordered_input_picture[0]){
2121 2178
        s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0;
2122 2179

  

Also available in: Unified diff