diff options
author | John Koleszar <jkoleszar@google.com> | 2011-04-25 15:02:54 -0400 |
---|---|---|
committer | John Koleszar <jkoleszar@google.com> | 2011-04-26 16:49:54 -0400 |
commit | 81d2206ff863fbac1da7a9496ec30512532e08eb (patch) | |
tree | 9b9d652f25aa3e3d7ecde674b3a1427656b9da4b /vp8/encoder/onyx_if.c | |
parent | 0da77a840b79c8037272687ba5fa8c3e01885572 (diff) | |
download | libvpx-81d2206ff863fbac1da7a9496ec30512532e08eb.tar libvpx-81d2206ff863fbac1da7a9496ec30512532e08eb.tar.gz libvpx-81d2206ff863fbac1da7a9496ec30512532e08eb.tar.bz2 libvpx-81d2206ff863fbac1da7a9496ec30512532e08eb.zip |
Move pick_frame_size() to ratectrl.c
This is a first step in cleaning up the redundancies between
vp8_calc_{auto_,}iframe_target_size. The pick_frame_size() function is
moved to ratectrl.c, and made to be the primary interface. This means
that the various calc_*_target_size functions can be made private.
Change-Id: I66a9a62a5f9c23c818015e03f92f3757bf3bb5c8
Diffstat (limited to 'vp8/encoder/onyx_if.c')
-rw-r--r-- | vp8/encoder/onyx_if.c | 82 |
1 files changed, 6 insertions, 76 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index c7579e83a..10115986d 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -56,7 +56,6 @@ extern void vp8_loop_filter_frame(VP8_COMMON *cm, MACROBLOCKD *mbd, int filt extern void vp8_loop_filter_frame_yonly(VP8_COMMON *cm, MACROBLOCKD *mbd, int filt_val, int sharpness_lvl); extern void vp8_dmachine_specific_config(VP8_COMP *cpi); extern void vp8_cmachine_specific_config(VP8_COMP *cpi); -extern void vp8_calc_auto_iframe_target_size(VP8_COMP *cpi); extern void vp8_deblock_frame(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *post, int filt_lvl, int low_var_thresh, int flag); extern void print_parms(VP8_CONFIG *ocf, char *filenam); extern unsigned int vp8_get_processor_freq(); @@ -2646,78 +2645,7 @@ static void resize_key_frame(VP8_COMP *cpi) #endif } -// return of 0 means drop frame -static int pick_frame_size(VP8_COMP *cpi) -{ - VP8_COMMON *cm = &cpi->common; - - // First Frame is a special case - if (cm->current_video_frame == 0) - { -#if !(CONFIG_REALTIME_ONLY) - - if (cpi->pass == 2) - vp8_calc_auto_iframe_target_size(cpi); - - else -#endif - { - /* 1 Pass there is no information on which to base size so use - * bandwidth per second * fraction of the initial buffer - * level - */ - cpi->this_frame_target = cpi->oxcf.starting_buffer_level / 2; - - if(cpi->this_frame_target > cpi->oxcf.target_bandwidth * 3 / 2) - cpi->this_frame_target = cpi->oxcf.target_bandwidth * 3 / 2; - } - - // Key frame from VFW/auto-keyframe/first frame - cm->frame_type = KEY_FRAME; - - } - // Special case for forced key frames - // The frame sizing here is still far from ideal for 2 pass. - else if (cm->frame_flags & FRAMEFLAGS_KEY) - { - cm->frame_type = KEY_FRAME; - resize_key_frame(cpi); - vp8_calc_iframe_target_size(cpi); - } - else if (cm->frame_type == KEY_FRAME) - { - vp8_calc_auto_iframe_target_size(cpi); - } - else - { - // INTER frame: compute target frame size - cm->frame_type = INTER_FRAME; - vp8_calc_pframe_target_size(cpi); - // Check if we're dropping the frame: - if (cpi->drop_frame) - { - cpi->drop_frame = FALSE; - cpi->drop_count++; - return 0; - } - } - - /* Apply limits on keyframe target. - * - * TODO: move this after consolidating - * vp8_calc_iframe_target_size() and vp8_calc_auto_iframe_target_size() - */ - if (cm->frame_type == KEY_FRAME && cpi->oxcf.rc_max_intra_bitrate_pct) - { - unsigned int max_rate = cpi->av_per_frame_bandwidth - * cpi->oxcf.rc_max_intra_bitrate_pct / 100; - - if (cpi->this_frame_target > max_rate) - cpi->this_frame_target = max_rate; - } - return 1; -} static void set_quantizer(VP8_COMP *cpi, int Q) { @@ -3506,7 +3434,7 @@ static void encode_frame_to_data_rate } // Decide how big to make the frame - if (!pick_frame_size(cpi)) + if (!vp8_pick_frame_size(cpi)) { cm->current_video_frame++; cpi->frames_since_key++; @@ -3834,7 +3762,10 @@ static void encode_frame_to_data_rate } if (cm->frame_type == KEY_FRAME) + { + resize_key_frame(cpi); vp8_setup_key_frame(cpi); + } // transform / motion compensation build reconstruction frame vp8_encode_frame(cpi); @@ -3858,11 +3789,11 @@ static void encode_frame_to_data_rate #else if (decide_key_frame(cpi)) { - vp8_calc_auto_iframe_target_size(cpi); - // Reset all our sizing numbers and recode cm->frame_type = KEY_FRAME; + vp8_pick_frame_size(cpi); + // Clear the Alt reference frame active flag when we have a key frame cpi->source_alt_ref_active = FALSE; @@ -3891,7 +3822,6 @@ static void encode_frame_to_data_rate loop_count++; Loop = TRUE; - resize_key_frame(cpi); continue; } #endif |