diff options
author | Cheng Chen <chengchen@google.com> | 2020-07-29 12:49:51 -0700 |
---|---|---|
committer | Cheng Chen <chengchen@google.com> | 2020-08-03 22:46:38 -0700 |
commit | f9ab864199a7a4d94df8c3ba3492d4feb3cfa90d (patch) | |
tree | f116f17515e496d76940bba5c9ce3ce819a778aa /vp9/simple_encode.h | |
parent | 8a8e780b584cef07e3615ff41707145afd429b8a (diff) | |
download | libvpx-f9ab864199a7a4d94df8c3ba3492d4feb3cfa90d.tar.gz |
L2E: Add ObserveFirstPassMotionVector
Store motion vectors for each 16x16 block found in the first pass
motion search.
Provide an api "ObserveFirstPassMotionVector()" in SimpleEncode
class, similar to "ObserveFirstPassStats()".
Change-Id: Ia86386b7e4aa549f7000e7965c287380bf52e62c
Diffstat (limited to 'vp9/simple_encode.h')
-rw-r--r-- | vp9/simple_encode.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/vp9/simple_encode.h b/vp9/simple_encode.h index ae36eb2c5..6c66aafda 100644 --- a/vp9/simple_encode.h +++ b/vp9/simple_encode.h @@ -60,7 +60,9 @@ struct PartitionInfo { constexpr int kMotionVectorPrecision = 8; -// The frame is split to 4x4 blocks. +// In the first pass. The frame is split to 16x16 blocks. +// This structure contains the information of each 16x16 block. +// In the second pass. The frame is split to 4x4 blocks. // This structure contains the information of each 4x4 block. struct MotionVectorInfo { // Number of valid motion vectors, always 0 if this block is in the key frame. @@ -68,8 +70,8 @@ struct MotionVectorInfo { int mv_count; // The reference frame for motion vectors. If the second motion vector does // not exist (mv_count = 1), the reference frame is kNoneRefFrame. - // Otherwise, the reference frame is either kLastFrame, or kGoldenFrame, - // or kAltRefFrame. + // Otherwise, the reference frame is either kRefFrameTypeLast, or + // kRefFrameTypePast, or kRefFrameTypeFuture. RefFrameType ref_frame[2]; // The row offset of motion vectors in the unit of pixel. // If the second motion vector does not exist, the value is 0. @@ -245,7 +247,7 @@ struct EncodeFrameResult { std::vector<PartitionInfo> partition_info; // A vector of the motion vector information of the frame. // The number of elements is |num_rows_4x4| * |num_cols_4x4|. - // The frame is divided 4x4 blocks of |num_rows_4x4| rows and + // The frame is divided into 4x4 blocks of |num_rows_4x4| rows and // |num_cols_4x4| columns. // Each 4x4 block contains 0 motion vector if this is an intra predicted // frame (for example, the key frame). If the frame is inter predicted, @@ -324,6 +326,12 @@ class SimpleEncode { // values. For details, please check FIRSTPASS_STATS in vp9_firstpass.h std::vector<std::vector<double>> ObserveFirstPassStats(); + // Outputs the first pass motion vectors represented by a 2-D vector. + // One can use the frame index at first dimension to retrieve the mvs for + // each video frame. The frame is divided into 16x16 blocks. The number of + // elements is round_up(|num_rows_4x4| / 4) * round_up(|num_cols_4x4| / 4). + std::vector<std::vector<MotionVectorInfo>> ObserveFirstPassMotionVectors(); + // Ouputs a copy of key_frame_map_, a binary vector with size equal to the // number of show frames in the video. For each entry in the vector, 1 // indicates the position is a key frame and 0 indicates it's not a key frame. @@ -451,6 +459,17 @@ class SimpleEncode { // frame appears? // Reference frames info of the to-be-coded frame. RefFrameInfo ref_frame_info_; + + // A 2-D vector of motion vector information of the frame collected + // from the first pass. The first dimension is the frame index. + // Each frame is divided into 16x16 blocks. The number of elements is + // round_up(|num_rows_4x4| / 4) * round_up(|num_cols_4x4| / 4). + // Each 16x16 block contains 0 motion vector if this is an intra predicted + // frame (for example, the key frame). If the frame is inter predicted, + // each 16x16 block contains either 1 or 2 motion vectors. + // The first motion vector is always from the LAST_FRAME. + // The second motion vector is always from the GOLDEN_FRAME. + std::vector<std::vector<MotionVectorInfo>> fp_motion_vector_info_; }; } // namespace vp9 |