summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_encoder.h
diff options
context:
space:
mode:
authorCheng Chen <chengchen@google.com>2020-01-27 12:58:10 -0800
committerCheng Chen <chengchen@google.com>2020-02-02 13:54:46 -0800
commite582df23378c9510dee41b43ec12725f0da89bc6 (patch)
tree7113e0317a46be31649828850225d5581e57e8a6 /vp9/encoder/vp9_encoder.h
parent5be37810d26d224f1ec75ff688d21aeadb863501 (diff)
downloadlibvpx-e582df23378c9510dee41b43ec12725f0da89bc6.tar
libvpx-e582df23378c9510dee41b43ec12725f0da89bc6.tar.gz
libvpx-e582df23378c9510dee41b43ec12725f0da89bc6.tar.bz2
libvpx-e582df23378c9510dee41b43ec12725f0da89bc6.zip
Store frame motion vector info
Allocate motion vector information for the frame, and store it when a superblock (64x64) is encoded. The unit size of the smallest block is 4x4. A special requirement by the vp9 spec is that sub 8x8 blocks of a 8x8 block must have the same reference frame. There is no such requirement for blocks large or equal to 8x8. Change-Id: Iba17c568c450361e5d059503c6fb7bc458184c31
Diffstat (limited to 'vp9/encoder/vp9_encoder.h')
-rw-r--r--vp9/encoder/vp9_encoder.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h
index b1f49d8fa..be02494d9 100644
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -532,6 +532,11 @@ typedef struct PARTITION_INFO {
int height; // prediction block height
} PARTITION_INFO;
+typedef struct MOTION_VECTOR_INFO {
+ MV_REFERENCE_FRAME ref_frame[2];
+ int_mv mv[2];
+} MOTION_VECTOR_INFO;
+
static INLINE void encode_command_init(ENCODE_COMMAND *encode_command) {
vp9_zero(*encode_command);
encode_command->use_external_quantize_index = 0;
@@ -862,6 +867,7 @@ typedef struct VP9_COMP {
#if CONFIG_RATE_CTRL
ENCODE_COMMAND encode_command;
PARTITION_INFO *partition_info;
+ MOTION_VECTOR_INFO *motion_vector_info;
#endif
} VP9_COMP;
@@ -886,6 +892,27 @@ static INLINE void free_partition_info(struct VP9_COMP *cpi) {
vpx_free(cpi->partition_info);
cpi->partition_info = NULL;
}
+
+// Allocates memory for the motion vector information.
+// The unit size is each 4x4 block.
+// Only called once in vp9_create_compressor().
+static INLINE void motion_vector_info_init(struct VP9_COMP *cpi) {
+ VP9_COMMON *const cm = &cpi->common;
+ const int unit_width = get_num_unit_4x4(cpi->frame_info.frame_width);
+ const int unit_height = get_num_unit_4x4(cpi->frame_info.frame_height);
+ CHECK_MEM_ERROR(cm, cpi->motion_vector_info,
+ (MOTION_VECTOR_INFO *)vpx_calloc(unit_width * unit_height,
+ sizeof(MOTION_VECTOR_INFO)));
+ memset(cpi->motion_vector_info, 0,
+ unit_width * unit_height * sizeof(MOTION_VECTOR_INFO));
+}
+
+// Frees memory of the motion vector information.
+// Only called once in dealloc_compressor_data().
+static INLINE void free_motion_vector_info(struct VP9_COMP *cpi) {
+ vpx_free(cpi->motion_vector_info);
+ cpi->motion_vector_info = NULL;
+}
#endif // CONFIG_RATE_CTRL
typedef struct ENCODE_FRAME_RESULT {
@@ -896,6 +923,7 @@ typedef struct ENCODE_FRAME_RESULT {
uint64_t sse;
FRAME_COUNTS frame_counts;
const PARTITION_INFO *partition_info;
+ const MOTION_VECTOR_INFO *motion_vector_info;
#endif // CONFIG_RATE_CTRL
int quantize_index;
} ENCODE_FRAME_RESULT;