# HG changeset patch # User michael # Date 1121377176 0 # Node ID 0a8c847ad5e734d46abaceaf59d691a801e0fa19 # Parent f191093dc8fe14c57099635cf1129f814d8f8794 skip_idct skip_frame skip_loop_filter diff -r f191093dc8fe -r 0a8c847ad5e7 avcodec.h --- a/avcodec.h Thu Jul 14 15:30:39 2005 +0000 +++ b/avcodec.h Thu Jul 14 21:39:36 2005 +0000 @@ -17,7 +17,8 @@ #define FFMPEG_VERSION_INT 0x000409 #define FFMPEG_VERSION "CVS" -#define LIBAVCODEC_BUILD 4757 +#define LIBAVCODEC_BUILD 4758 + #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION @@ -284,6 +285,16 @@ AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero }; +enum AVDiscard{ +//we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames) + AVDISCARD_NONE =-16, ///< discard nothing + AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48, ///< discard all +}; + typedef struct RcOverride{ int start_frame; int end_frame; @@ -858,6 +869,7 @@ /** * hurry up amount. + * deprecated in favor of skip_idct and skip_frame * - encoding: unused * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header */ @@ -1807,6 +1819,27 @@ * - decoding: unused */ int me_penalty_compensation; + + /** + * + * - encoding: unused + * - decoding: set by user. + */ + enum AVDiscard skip_loop_filter; + + /** + * + * - encoding: unused + * - decoding: set by user. + */ + enum AVDiscard skip_idct; + + /** + * + * - encoding: unused + * - decoding: set by user. + */ + enum AVDiscard skip_frame; } AVCodecContext; diff -r f191093dc8fe -r 0a8c847ad5e7 h261.c --- a/h261.c Thu Jul 14 15:30:39 2005 +0000 +++ b/h261.c Thu Jul 14 21:39:36 2005 +0000 @@ -970,6 +970,10 @@ /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return get_consumed_bytes(s, buf_size); if(MPV_frame_start(s, avctx) < 0) return -1; diff -r f191093dc8fe -r 0a8c847ad5e7 h263dec.c --- a/h263dec.c Thu Jul 14 15:30:39 2005 +0000 +++ b/h263dec.c Thu Jul 14 21:39:36 2005 +0000 @@ -673,6 +673,10 @@ if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)) return get_consumed_bytes(s, buf_size); /* skip b frames if we are in a hurry */ if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return get_consumed_bytes(s, buf_size); /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); diff -r f191093dc8fe -r 0a8c847ad5e7 h264.c --- a/h264.c Thu Jul 14 15:30:39 2005 +0000 +++ b/h264.c Thu Jul 14 21:39:36 2005 +0000 @@ -4349,6 +4349,11 @@ h->slice_beta_offset = get_se_golomb(&s->gb) << 1; } } + if( s->avctx->skip_loop_filter >= AVDISCARD_ALL + ||(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && h->slice_type != I_TYPE) + ||(s->avctx->skip_loop_filter >= AVDISCARD_BIDIR && h->slice_type == B_TYPE) + ||(s->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0)) + h->deblocking_filter= 0; #if 0 //FMO if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5) @@ -7245,7 +7250,8 @@ buf_index += consumed; - if( s->hurry_up == 1 && h->nal_ref_idc == 0 ) + if( (s->hurry_up == 1 && h->nal_ref_idc == 0) + ||(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0)) continue; switch(h->nal_unit_type){ @@ -7261,7 +7267,7 @@ av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n"); break; } - if(h->redundant_pic_count==0 && s->hurry_up < 5 ) + if(h->redundant_pic_count==0 && s->hurry_up < 5 && avctx->skip_frame < AVDISCARD_ALL) decode_slice(h); break; case NAL_DPA: @@ -7282,7 +7288,8 @@ init_get_bits(&h->inter_gb, ptr, bit_length); h->inter_gb_ptr= &h->inter_gb; - if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning && s->hurry_up < 5 ) + if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning + && s->hurry_up < 5 && avctx->skip_frame < AVDISCARD_ALL) decode_slice(h); break; case NAL_SEI: diff -r f191093dc8fe -r 0a8c847ad5e7 mpeg12.c --- a/mpeg12.c Thu Jul 14 15:30:39 2005 +0000 +++ b/mpeg12.c Thu Jul 14 21:39:36 2005 +0000 @@ -3086,7 +3086,7 @@ /* find start next code */ start_code = find_start_code(&buf_ptr, buf_end); if (start_code < 0){ - if(s2->pict_type != B_TYPE || avctx->hurry_up==0){ + if(s2->pict_type != B_TYPE || avctx->skip_frame <= AVDISCARD_DEFAULT){ if(avctx->thread_count > 1){ int i; @@ -3146,6 +3146,10 @@ } /* skip b frames if we are in a hurry */ if(avctx->hurry_up && s2->pict_type==B_TYPE) break; + if( (avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + break; /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) break; diff -r f191093dc8fe -r 0a8c847ad5e7 mpegvideo.c --- a/mpegvideo.c Thu Jul 14 15:30:39 2005 +0000 +++ b/mpegvideo.c Thu Jul 14 21:39:36 2005 +0000 @@ -3777,7 +3777,13 @@ } /* skip dequant / idct if we are really late ;) */ - if(s->hurry_up>1) return; + if(s->hurry_up>1) goto skip_idct; + if(s->avctx->skip_idct){ + if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == B_TYPE) + ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != I_TYPE) + || s->avctx->skip_idct >= AVDISCARD_ALL) + goto skip_idct; + } /* add dct residue */ if(s->encoding || !( s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO @@ -3863,6 +3869,7 @@ }//gray } } +skip_idct: if(!readable){ s->dsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16); s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift); diff -r f191093dc8fe -r 0a8c847ad5e7 svq1.c --- a/svq1.c Thu Jul 14 15:30:39 2005 +0000 +++ b/svq1.c Thu Jul 14 21:39:36 2005 +0000 @@ -748,6 +748,10 @@ if(s->pict_type==B_TYPE && s->last_picture_ptr==NULL) return buf_size; if(avctx->hurry_up && s->pict_type==B_TYPE) return buf_size; + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return buf_size; if(MPV_frame_start(s, avctx) < 0) return -1; diff -r f191093dc8fe -r 0a8c847ad5e7 svq3.c --- a/svq3.c Thu Jul 14 15:30:39 2005 +0000 +++ b/svq3.c Thu Jul 14 21:39:36 2005 +0000 @@ -896,6 +896,10 @@ if (avctx->hurry_up && s->pict_type == B_TYPE) return 0; /* skip everything if we are in a hurry >= 5 */ if (avctx->hurry_up >= 5) return 0; + if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) + ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) + || avctx->skip_frame >= AVDISCARD_ALL) + return 0; if (s->next_p_frame_damaged) { if (s->pict_type == B_TYPE)