Revision bbf18b21

View differences:

ffmpeg.c
193 193
static int nsse_weight = 8;
194 194
static int subpel_quality= 8;
195 195
static int lowres= 0;
196
static int frame_skip_threshold= 0;
197
static int frame_skip_factor= 0;
196 198
extern int loop_input; /* currently a hack */
197 199

  
198 200
static int gop_size = 12;
......
3223 3225
                video_enc->level= video_level;
3224 3226
                video_enc->nsse_weight= nsse_weight;
3225 3227
                video_enc->me_subpel_quality= subpel_quality;
3228
                video_enc->frame_skip_threshold= frame_skip_threshold;
3229
                video_enc->frame_skip_factor= frame_skip_factor;
3226 3230

  
3227 3231
                if(packet_size){
3228 3232
                    video_enc->rtp_mode= 1;
......
3949 3953
    { "subq", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&subpel_quality}, "", "" },
3950 3954
    { "lowres", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&lowres}, "", "" },
3951 3955
    { "vtag", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_video_tag}, "force video tag/fourcc", "fourcc/tag" },
3956
    { "skip_threshold", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&frame_skip_threshold}, "frame skip threshold", "threshold" },
3957
    { "skip_factor", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&frame_skip_factor}, "frame skip factor", "factor" },
3952 3958

  
3953 3959
    /* audio options */
3954 3960
    { "ab", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_bitrate}, "set audio bitrate (in kbit/s)", "bitrate", },
libavcodec/avcodec.h
17 17

  
18 18
#define FFMPEG_VERSION_INT     0x000409
19 19
#define FFMPEG_VERSION         "0.4.9-pre1"
20
#define LIBAVCODEC_BUILD       4734
20
#define LIBAVCODEC_BUILD       4735
21 21

  
22 22
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
23 23
#define LIBAVCODEC_VERSION     FFMPEG_VERSION
......
1683 1683
     int lowres;
1684 1684

  
1685 1685
    /**
1686
     * bistream width / height. may be different from width/height if lowres
1686
     * bitsream width / height. may be different from width/height if lowres
1687 1687
     * or other things are used
1688 1688
     * - encoding: unused
1689 1689
     * - decoding: set by user before init if known, codec should override / dynamically change if needed
1690 1690
     */
1691 1691
    int coded_width, coded_height;
1692

  
1693
    /**
1694
     * frame skip threshold
1695
     * - encoding: set by user
1696
     * - decoding: unused
1697
     */
1698
    int frame_skip_threshold;
1699

  
1700
    /**
1701
     * frame skip factor
1702
     * - encoding: set by user
1703
     * - decoding: unused
1704
     */
1705
    int frame_skip_factor;
1692 1706
} AVCodecContext;
1693 1707

  
1694 1708

  
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