if (cm->show_frame) {
vp9_swap_mi_and_prev_mi(cm);
- // Don't increment frame counters if this was an altref buffer
- // update not a real frame
- update_frame_indexes(cm, cm->show_frame);
if (cpi->use_svc) vp9_inc_frame_in_layer(cpi);
}
+ update_frame_indexes(cm, cm->show_frame);
if (cpi->use_svc) {
cpi->svc
encode_frame_result->ref_frame_coding_indexes[i] =
ref_frame_bufs[i]->frame_coding_index;
encode_frame_result->ref_frame_valid_list[i] =
- !(ref_frame_flags & inter_ref_flags[i]);
+ (ref_frame_flags & inter_ref_flags[i]) != 0;
}
} else {
// No reference frame is available when this is a key frame.
encode_frame_result->coding_data_byte_size * 8;
encode_frame_result->show_idx = encode_frame_info->show_idx;
encode_frame_result->coding_idx = encode_frame_info->frame_coding_index;
+ assert(kRefFrameTypeMax == MAX_INTER_REF_FRAMES);
for (int i = 0; i < kRefFrameTypeMax; ++i) {
- assert(kRefFrameTypeMax == MAX_INTER_REF_FRAMES);
encode_frame_result->ref_frame_info.coding_indexes[i] =
encode_frame_info->ref_frame_coding_indexes[i];
encode_frame_result->ref_frame_info.valid_list[i] =
group_of_picture.encode_frame_list.size();
}
+bool operator==(const RefFrameInfo &a, const RefFrameInfo &b) {
+ bool match = true;
+ for (int i = 0; i < kRefFrameTypeMax; ++i) {
+ match &= a.coding_indexes[i] == b.coding_indexes[i];
+ match &= a.valid_list[i] == b.valid_list[i];
+ }
+ return match;
+}
+
static void InitRefFrameInfo(RefFrameInfo *ref_frame_info) {
for (int i = 0; i < kRefFrameTypeMax; ++i) {
- ref_frame_info->coding_indexes[i] = 0;
+ ref_frame_info->coding_indexes[i] = -1;
ref_frame_info->valid_list[i] = 0;
}
}
}
if (past_index == last_index) {
- ref_frame_valid_list[kRefFrameTypeLast] = 0;
+ ref_frame_valid_list[kRefFrameTypePast] = 0;
}
if (future_index == last_index) {
&cpi->oxcf, &cpi->frame_info, &cpi->twopass.first_pass_info,
key_frame_show_index, cpi->rc.min_gf_interval);
assert(key_frame_group_size_ > 0);
+ // Init the reference frame info when a new key frame group appears.
+ InitRefFrameInfo(&ref_frame_info_);
}
void SimpleEncode::PostUpdateKeyFrameGroupIndex(FrameType frame_type) {
// Only kFrameTypeAltRef is not a show frame
++show_frame_count_;
}
- IncreaseGroupOfPictureIndex(&group_of_picture_);
- if (IsGroupOfPictureFinished(group_of_picture_)) {
- UpdateGroupOfPicture(impl_ptr_->cpi, frame_coding_index_, ref_frame_info_,
- &group_of_picture_);
- }
PostUpdateKeyFrameGroupIndex(encode_frame_result.frame_type);
if (key_frame_group_index_ == key_frame_group_size_) {
UpdateKeyFrameGroup(show_frame_count_);
}
+
+ IncreaseGroupOfPictureIndex(&group_of_picture_);
+ if (IsGroupOfPictureFinished(group_of_picture_)) {
+ // This function needs to be called after ref_frame_info_ is updated
+ // properly in PostUpdateRefFrameInfo() and UpdateKeyFrameGroup().
+ UpdateGroupOfPicture(impl_ptr_->cpi, frame_coding_index_, ref_frame_info_,
+ &group_of_picture_);
+ }
}
void SimpleEncode::EncodeFrame(EncodeFrameResult *encode_frame_result) {
int valid_list[kRefFrameTypeMax];
};
+bool operator==(const RefFrameInfo &a, const RefFrameInfo &b);
+
struct EncodeFrameInfo {
int show_idx;
// The index for the to-be-coded show frame in the key frame group.
int key_frame_group_index_;
- // Update key_frame_group_size_ and reset key_frame_group_index_.
+ // Update key_frame_group_size_, reset key_frame_group_index_ and init
+ // ref_frame_info_.
void UpdateKeyFrameGroup(int key_frame_show_index);
// Update key_frame_group_index_.