ref: 0484849e8e4fa7c49e415539fae32fa7cb76c9c4
parent: bff7ecc517715af808526bbfb96490497c47010b
author: angiebird <angiebird@google.com>
date: Thu Feb 20 12:26:14 EST 2020
Rename values in RefFrameType and FrameType Replace golden and altref by past and future in RefFrameType. So that we don't get confused with FrameType and RefFrameType. Change-Id: I1be45d49f76c68869fc4bf53ff946fee9ce7eb9d
--- a/vp9/simple_encode.cc
+++ b/vp9/simple_encode.cc
@@ -133,15 +133,15 @@
static INLINE FrameType
get_frame_type_from_update_type(FRAME_UPDATE_TYPE update_type) {
switch (update_type) {
- case KF_UPDATE: return kKeyFrame;
- case ARF_UPDATE: return kAlternateReference;
- case GF_UPDATE: return kGoldenFrame;
- case OVERLAY_UPDATE: return kOverlayFrame;
- case LF_UPDATE: return kInterFrame;
+ case KF_UPDATE: return kFrameTypeKey;
+ case ARF_UPDATE: return kFrameTypeAltRef;
+ case GF_UPDATE: return kFrameTypeGolden;
+ case OVERLAY_UPDATE: return kFrameTypeOverlay;
+ case LF_UPDATE: return kFrameTypeInter;
default:
fprintf(stderr, "Unsupported update_type %d\n", update_type);
abort();
- return kInterFrame;
+ return kFrameTypeInter;
}
}
@@ -161,19 +161,35 @@
}
}
+// translate MV_REFERENCE_FRAME to RefFrameType
+static RefFrameType mv_ref_frame_to_ref_frame_type(
+ MV_REFERENCE_FRAME mv_ref_frame) {
+ switch (mv_ref_frame) {
+ case LAST_FRAME: return kRefFrameTypeLast;
+ case GOLDEN_FRAME: return kRefFrameTypePast;
+ case ALTREF_FRAME: return kRefFrameTypeFuture;
+ default: return kRefFrameTypeNone;
+ }
+}
+
static void update_motion_vector_info(
const MOTION_VECTOR_INFO *input_motion_vector_info, const int num_rows_4x4,
const int num_cols_4x4, MotionVectorInfo *output_motion_vector_info) {
const int num_units_4x4 = num_rows_4x4 * num_cols_4x4;
for (int i = 0; i < num_units_4x4; ++i) {
+ const MV_REFERENCE_FRAME *in_ref_frame =
+ input_motion_vector_info[i].ref_frame;
output_motion_vector_info[i].mv_count =
- (input_motion_vector_info[i].ref_frame[0] == INTRA_FRAME)
- ? 0
- : ((input_motion_vector_info[i].ref_frame[1] == -1) ? 1 : 2);
+ (in_ref_frame[0] == INTRA_FRAME) ? 0
+ : ((in_ref_frame[1] == NONE) ? 1 : 2);
+ if (in_ref_frame[0] == NONE) {
+ fprintf(stderr, "in_ref_frame[0] shouldn't be NONE\n");
+ abort();
+ }
output_motion_vector_info[i].ref_frame[0] =
- static_cast<RefFrameType>(input_motion_vector_info[i].ref_frame[0]);
+ mv_ref_frame_to_ref_frame_type(in_ref_frame[0]);
output_motion_vector_info[i].ref_frame[1] =
- static_cast<RefFrameType>(input_motion_vector_info[i].ref_frame[1]);
+ mv_ref_frame_to_ref_frame_type(in_ref_frame[1]);
output_motion_vector_info[i].mv_row[0] =
(double)input_motion_vector_info[i].mv[0].as_mv.row /
kMotionVectorPrecision;
@@ -523,12 +539,12 @@
// frame.
EncodeFrameInfo encode_frame_info;
if (first_is_key_frame) {
- encode_frame_info.frame_type = kKeyFrame;
+ encode_frame_info.frame_type = kFrameTypeKey;
} else {
if (last_gop_use_alt_ref) {
- encode_frame_info.frame_type = kOverlayFrame;
+ encode_frame_info.frame_type = kFrameTypeOverlay;
} else {
- encode_frame_info.frame_type = kGoldenFrame;
+ encode_frame_info.frame_type = kFrameTypeGolden;
}
}
encode_frame_info.show_idx = first_show_idx;
@@ -541,7 +557,7 @@
// If there is alternate reference, it is always coded at the second place.
// Its show index (or timestamp) is at the last of this group
EncodeFrameInfo encode_frame_info;
- encode_frame_info.frame_type = kAlternateReference;
+ encode_frame_info.frame_type = kFrameTypeAltRef;
encode_frame_info.show_idx = first_show_idx + show_frame_count;
encode_frame_info.coding_index = start_coding_index + 1;
group_of_picture->encode_frame_list.push_back(encode_frame_info);
@@ -550,7 +566,7 @@
// Encode the rest show inter frames.
for (int i = 1; i < show_frame_count; ++i) {
EncodeFrameInfo encode_frame_info;
- encode_frame_info.frame_type = kInterFrame;
+ encode_frame_info.frame_type = kFrameTypeInter;
encode_frame_info.show_idx = first_show_idx + i;
encode_frame_info.coding_index = start_coding_index + use_alt_ref + i;
group_of_picture->encode_frame_list.push_back(encode_frame_info);
--- a/vp9/simple_encode.h
+++ b/vp9/simple_encode.h
@@ -19,22 +19,24 @@
namespace vp9 {
+// TODO(angiebird): Add description for each frame type.
enum FrameType {
- kKeyFrame = 0,
- kInterFrame,
- kAlternateReference,
- kOverlayFrame,
- kGoldenFrame,
+ kFrameTypeKey = 0,
+ kFrameTypeInter,
+ kFrameTypeAltRef,
+ kFrameTypeOverlay,
+ kFrameTypeGolden,
};
-// The enum type is similar to vp9: |MV_REFERENCE_FRAME|.
-// TODO(angiebird): Clarify the difference between FrameType and RefFrameType.
+// TODO(angiebird): Add description for each reference frame type.
+// This enum numbers have to be contiguous and start from zero except
+// kNoneRefFrame.
enum RefFrameType {
- kIntraRefFrame = 0,
- kLastRefFrame = 1,
- kGoldenRefFrame = 2,
- kAltRefFrame = 3,
- kNoneRefRefFrame = -1,
+ kRefFrameTypeLast = 0,
+ kRefFrameTypePast = 1,
+ kRefFrameTypeFuture = 2,
+ kRefFrameTypeMax = 3,
+ kRefFrameTypeNone = -1,
};
// The frame is split to 4x4 blocks.