summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder/vp9_firstpass.c')
-rw-r--r--vp9/encoder/vp9_firstpass.c75
1 files changed, 33 insertions, 42 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 3a48174c7..88c3e84bf 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2508,9 +2508,6 @@ typedef struct RANGE {
* structs.
*/
static int get_gop_coding_frame_num(
-#if CONFIG_RATE_CTRL
- const int *external_arf_indexes,
-#endif
int *use_alt_ref, const FRAME_INFO *frame_info,
const FIRST_PASS_INFO *first_pass_info, const RATE_CONTROL *rc,
int gf_start_show_idx, const RANGE *active_gf_interval,
@@ -2526,24 +2523,6 @@ static int get_gop_coding_frame_num(
(frame_info->frame_height + frame_info->frame_width) / 4.0;
double zero_motion_accumulator = 1.0;
int gop_coding_frames;
-#if CONFIG_RATE_CTRL
- (void)mv_ratio_accumulator_thresh;
- (void)active_gf_interval;
- (void)gop_intra_factor;
-
- if (external_arf_indexes != NULL && rc->frames_to_key > 1) {
- // gop_coding_frames = 1 is necessary to filter out the overlay frame,
- // since the arf is in this group of picture and its overlay is in the next.
- gop_coding_frames = 1;
- *use_alt_ref = 1;
- while (gop_coding_frames < rc->frames_to_key) {
- const int frame_index = gf_start_show_idx + gop_coding_frames;
- ++gop_coding_frames;
- if (external_arf_indexes[frame_index] == 1) break;
- }
- return gop_coding_frames;
- }
-#endif // CONFIG_RATE_CTRL
*use_alt_ref = 1;
gop_coding_frames = 0;
@@ -2770,15 +2749,26 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) {
gop_intra_factor = 1.0;
}
- {
- gop_coding_frames = get_gop_coding_frame_num(
#if CONFIG_RATE_CTRL
- cpi->encode_command.external_arf_indexes,
-#endif
- &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx,
- &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames);
- use_alt_ref &= allow_alt_ref;
+ {
+ const GOP_COMMAND *gop_command = &cpi->encode_command.gop_command;
+ assert(allow_alt_ref == 1);
+ if (gop_command->use) {
+ gop_coding_frames = gop_command_coding_frame_count(gop_command);
+ use_alt_ref = gop_command->use_alt_ref;
+ } else {
+ gop_coding_frames = get_gop_coding_frame_num(
+ &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx,
+ &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames);
+ use_alt_ref &= allow_alt_ref;
+ }
}
+#else
+ gop_coding_frames = get_gop_coding_frame_num(
+ &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx,
+ &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames);
+ use_alt_ref &= allow_alt_ref;
+#endif
// Was the group length constrained by the requirement for a new KF?
rc->constrained_gf_group = (gop_coding_frames >= rc->frames_to_key) ? 1 : 0;
@@ -3704,6 +3694,7 @@ void vp9_get_next_group_of_picture(const VP9_COMP *cpi, int *first_is_key_frame,
int *use_alt_ref, int *coding_frame_count,
int *first_show_idx,
int *last_gop_use_alt_ref) {
+ const GOP_COMMAND *gop_command = &cpi->encode_command.gop_command;
// We make a copy of rc here because we want to get information from the
// encoder without changing its state.
// TODO(angiebird): Avoid copying rc here.
@@ -3726,14 +3717,19 @@ void vp9_get_next_group_of_picture(const VP9_COMP *cpi, int *first_is_key_frame,
*first_is_key_frame = 1;
}
- *coding_frame_count = vp9_get_gop_coding_frame_count(
- cpi->encode_command.external_arf_indexes, &cpi->oxcf, &cpi->frame_info,
- &cpi->twopass.first_pass_info, &rc, *first_show_idx, multi_layer_arf,
- allow_alt_ref, *first_is_key_frame, *last_gop_use_alt_ref, use_alt_ref);
+ if (gop_command->use) {
+ *coding_frame_count = gop_command_coding_frame_count(gop_command);
+ *use_alt_ref = gop_command->use_alt_ref;
+ assert(*coding_frame_count < rc.frames_to_key);
+ } else {
+ *coding_frame_count = vp9_get_gop_coding_frame_count(
+ &cpi->oxcf, &cpi->frame_info, &cpi->twopass.first_pass_info, &rc,
+ *first_show_idx, multi_layer_arf, allow_alt_ref, *first_is_key_frame,
+ *last_gop_use_alt_ref, use_alt_ref);
+ }
}
-int vp9_get_gop_coding_frame_count(const int *external_arf_indexes,
- const VP9EncoderConfig *oxcf,
+int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf,
const FRAME_INFO *frame_info,
const FIRST_PASS_INFO *first_pass_info,
const RATE_CONTROL *rc, int show_idx,
@@ -3756,9 +3752,6 @@ int vp9_get_gop_coding_frame_count(const int *external_arf_indexes,
}
frame_count = get_gop_coding_frame_num(
-#if CONFIG_RATE_CTRL
- external_arf_indexes,
-#endif
use_alt_ref, frame_info, first_pass_info, rc, show_idx,
&active_gf_interval, gop_intra_factor, oxcf->lag_in_frames);
*use_alt_ref &= allow_alt_ref;
@@ -3767,8 +3760,7 @@ int vp9_get_gop_coding_frame_count(const int *external_arf_indexes,
// Under CONFIG_RATE_CTRL, once the first_pass_info is ready, the number of
// coding frames (including show frame and alt ref) can be determined.
-int vp9_get_coding_frame_num(const int *external_arf_indexes,
- const VP9EncoderConfig *oxcf,
+int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf,
const FRAME_INFO *frame_info,
const FIRST_PASS_INFO *first_pass_info,
int multi_layer_arf, int allow_alt_ref) {
@@ -3792,9 +3784,8 @@ int vp9_get_coding_frame_num(const int *external_arf_indexes,
}
gop_coding_frame_count = vp9_get_gop_coding_frame_count(
- external_arf_indexes, oxcf, frame_info, first_pass_info, &rc, show_idx,
- multi_layer_arf, allow_alt_ref, first_is_key_frame,
- last_gop_use_alt_ref, &use_alt_ref);
+ oxcf, frame_info, first_pass_info, &rc, show_idx, multi_layer_arf,
+ allow_alt_ref, first_is_key_frame, last_gop_use_alt_ref, &use_alt_ref);
rc.source_alt_ref_active = use_alt_ref;
last_gop_use_alt_ref = use_alt_ref;