1 /* 2 * Copyright (c) 2019 The WebM project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef VPX_VP9_SIMPLE_ENCODE_H_ 12 #define VPX_VP9_SIMPLE_ENCODE_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 #include <cstdio> 17 #include <memory> 18 #include <vector> 19 20 namespace vp9 { 21 22 enum StatusCode { 23 StatusOk = 0, 24 StatusError, 25 }; 26 27 // TODO(angiebird): Add description for each frame type. 28 enum FrameType { 29 kFrameTypeKey = 0, 30 kFrameTypeInter = 1, 31 kFrameTypeAltRef = 2, 32 kFrameTypeOverlay = 3, 33 kFrameTypeGolden = 4, 34 }; 35 36 // TODO(angiebird): Add description for each reference frame type. 37 // This enum numbers have to be contiguous and start from zero except 38 // kNoneRefFrame. 39 enum RefFrameType { 40 kRefFrameTypeLast = 0, 41 kRefFrameTypePast = 1, 42 kRefFrameTypeFuture = 2, 43 kRefFrameTypeMax = 3, 44 kRefFrameTypeNone = -1, 45 }; 46 47 enum VP9_LEVEL { 48 LEVEL_UNKNOWN = 0, 49 LEVEL_AUTO = 1, 50 LEVEL_1 = 10, 51 LEVEL_1_1 = 11, 52 LEVEL_2 = 20, 53 LEVEL_2_1 = 21, 54 LEVEL_3 = 30, 55 LEVEL_3_1 = 31, 56 LEVEL_4 = 40, 57 LEVEL_4_1 = 41, 58 LEVEL_5 = 50, 59 LEVEL_5_1 = 51, 60 LEVEL_5_2 = 52, 61 LEVEL_6 = 60, 62 LEVEL_6_1 = 61, 63 LEVEL_6_2 = 62, 64 LEVEL_MAX = 255 65 }; 66 67 enum GopMapFlag { 68 kGopMapFlagStart = 69 1 << 0, // Indicate this location is the start of a group of pictures. 70 kGopMapFlagUseAltRef = 71 1 << 1, // Indicate this group of pictures will use an alt ref. Only set 72 // this flag when kGopMapFlagStart is set. 73 }; 74 75 // The frame is split to 4x4 blocks. 76 // This structure contains the information of each 4x4 block. 77 struct PartitionInfo { 78 int row; // row pixel offset of current 4x4 block 79 int column; // column pixel offset of current 4x4 block 80 int row_start; // row pixel offset of the start of the prediction block 81 int column_start; // column pixel offset of the start of the prediction block 82 int width; // prediction block width 83 int height; // prediction block height 84 }; 85 86 constexpr int kMotionVectorSubPixelPrecision = 8; 87 constexpr int kMotionVectorFullPixelPrecision = 1; 88 89 // In the first pass. The frame is split to 16x16 blocks. 90 // This structure contains the information of each 16x16 block. 91 // In the second pass. The frame is split to 4x4 blocks. 92 // This structure contains the information of each 4x4 block. 93 struct MotionVectorInfo { 94 // Number of valid motion vectors, always 0 if this block is in the key frame. 95 // For inter frames, it could be 1 or 2. 96 int mv_count; 97 // The reference frame for motion vectors. If the second motion vector does 98 // not exist (mv_count = 1), the reference frame is kNoneRefFrame. 99 // Otherwise, the reference frame is either kRefFrameTypeLast, or 100 // kRefFrameTypePast, or kRefFrameTypeFuture. 101 RefFrameType ref_frame[2]; 102 // The row offset of motion vectors in the unit of pixel. 103 // If the second motion vector does not exist, the value is 0. 104 double mv_row[2]; 105 // The column offset of motion vectors in the unit of pixel. 106 // If the second motion vector does not exist, the value is 0. 107 double mv_column[2]; 108 }; 109 110 // Accumulated tpl stats of all blocks in one frame. 111 // For each frame, the tpl stats are computed per 32x32 block. 112 struct TplStatsInfo { 113 // Intra complexity: the sum of absolute transform difference (SATD) of 114 // intra predicted residuals. 115 int64_t intra_cost; 116 // Inter complexity: the SATD of inter predicted residuals. 117 int64_t inter_cost; 118 // Motion compensated information flow. It measures how much information 119 // is propagated from the current frame to other frames. 120 int64_t mc_flow; 121 // Motion compensated dependency cost. It equals to its own intra_cost 122 // plus the mc_flow. 123 int64_t mc_dep_cost; 124 // Motion compensated reference cost. 125 int64_t mc_ref_cost; 126 }; 127 128 struct RefFrameInfo { 129 int coding_indexes[kRefFrameTypeMax]; 130 131 // Indicate whether the reference frames are available or not. 132 // When the reference frame type is not valid, it means either the to-be-coded 133 // frame is a key frame or the reference frame already appears in other 134 // reference frame type. vp9 always keeps three types of reference frame 135 // available. However, the duplicated reference frames will not be 136 // chosen by the encoder. The priorities of choosing reference frames are 137 // kRefFrameTypeLast > kRefFrameTypePast > kRefFrameTypeFuture. 138 // For example, if kRefFrameTypeLast and kRefFrameTypePast both point to the 139 // same frame, kRefFrameTypePast will be set to invalid. 140 // 1: the ref frame type is available 0: the ref frame type is not available 141 int valid_list[kRefFrameTypeMax]; 142 }; 143 144 bool operator==(const RefFrameInfo &a, const RefFrameInfo &b); 145 146 struct EncodeFrameInfo { 147 int show_idx; 148 149 // Each show or no show frame is assigned with a coding index based on its 150 // coding order (starting from zero) in the coding process of the entire 151 // video. The coding index for each frame is unique. 152 int coding_index; 153 RefFrameInfo ref_frame_info; 154 FrameType frame_type; 155 }; 156 157 // This structure is a copy of vp9 |nmv_component_counts|. 158 struct NewMotionvectorComponentCounts { 159 std::vector<unsigned int> sign; 160 std::vector<unsigned int> classes; 161 std::vector<unsigned int> class0; 162 std::vector<std::vector<unsigned int>> bits; 163 std::vector<std::vector<unsigned int>> class0_fp; 164 std::vector<unsigned int> fp; 165 std::vector<unsigned int> class0_hp; 166 std::vector<unsigned int> hp; 167 }; 168 169 // This structure is a copy of vp9 |nmv_context_counts|. 170 struct NewMotionVectorContextCounts { 171 std::vector<unsigned int> joints; 172 std::vector<NewMotionvectorComponentCounts> comps; 173 }; 174 175 using UintArray2D = std::vector<std::vector<unsigned int>>; 176 using UintArray3D = std::vector<std::vector<std::vector<unsigned int>>>; 177 using UintArray5D = std::vector< 178 std::vector<std::vector<std::vector<std::vector<unsigned int>>>>>; 179 using UintArray6D = std::vector<std::vector< 180 std::vector<std::vector<std::vector<std::vector<unsigned int>>>>>>; 181 182 // This structure is a copy of vp9 |tx_counts|. 183 struct TransformSizeCounts { 184 // Transform size found in blocks of partition size 32x32. 185 // First dimension: transform size contexts (2). 186 // Second dimension: transform size type (3: 32x32, 16x16, 8x8) 187 UintArray2D p32x32; 188 // Transform size found in blocks of partition size 16x16. 189 // First dimension: transform size contexts (2). 190 // Second dimension: transform size type (2: 16x16, 8x8) 191 UintArray2D p16x16; 192 // Transform size found in blocks of partition size 8x8. 193 // First dimension: transform size contexts (2). 194 // Second dimension: transform size type (1: 8x8) 195 UintArray2D p8x8; 196 // Overall transform size count. 197 std::vector<unsigned int> tx_totals; 198 }; 199 200 // This structure is a copy of vp9 |FRAME_COUNTS|. 201 struct FrameCounts { 202 // Intra prediction mode for luma plane. First dimension: block size (4). 203 // Second dimension: intra prediction mode (10). 204 UintArray2D y_mode; 205 // Intra prediction mode for chroma plane. First and second dimension: 206 // intra prediction mode (10). 207 UintArray2D uv_mode; 208 // Partition type. First dimension: partition contexts (16). 209 // Second dimension: partition type (4). 210 UintArray2D partition; 211 // Transform coefficient. 212 UintArray6D coef; 213 // End of block (the position of the last non-zero transform coefficient) 214 UintArray5D eob_branch; 215 // Interpolation filter type. First dimension: switchable filter contexts (4). 216 // Second dimension: filter types (3). 217 UintArray2D switchable_interp; 218 // Inter prediction mode (the motion vector type). 219 // First dimension: inter mode contexts (7). 220 // Second dimension: mode type (4). 221 UintArray2D inter_mode; 222 // Block is intra or inter predicted. First dimension: contexts (4). 223 // Second dimension: type (0 for intra, 1 for inter). 224 UintArray2D intra_inter; 225 // Block is compound predicted (predicted from average of two blocks). 226 // First dimension: contexts (5). 227 // Second dimension: type (0 for single, 1 for compound prediction). 228 UintArray2D comp_inter; 229 // Type of the reference frame. Only one reference frame. 230 // First dimension: context (5). Second dimension: context (2). 231 // Third dimension: count (2). 232 UintArray3D single_ref; 233 // Type of the two reference frames. 234 // First dimension: context (5). Second dimension: count (2). 235 UintArray2D comp_ref; 236 // Block skips transform and quantization, uses prediction as reconstruction. 237 // First dimension: contexts (3). Second dimension: type (0 not skip, 1 skip). 238 UintArray2D skip; 239 // Transform size. 240 TransformSizeCounts tx; 241 // New motion vector. 242 NewMotionVectorContextCounts mv; 243 }; 244 245 struct ImageBuffer { 246 // The image data is stored in raster order, 247 // i.e. image[plane][r][c] = 248 // plane_buffer[plane][r * plane_width[plane] + plane_height[plane]]. 249 std::unique_ptr<unsigned char[]> plane_buffer[3]; 250 int plane_width[3]; 251 int plane_height[3]; 252 }; 253 254 void output_image_buffer(const ImageBuffer &image_buffer, std::FILE *out_file); 255 256 struct EncodeFrameResult { 257 int show_idx; 258 FrameType frame_type; 259 int coding_idx; 260 RefFrameInfo ref_frame_info; 261 size_t coding_data_bit_size; 262 size_t coding_data_byte_size; 263 // The EncodeFrame will allocate a buffer, write the coding data into the 264 // buffer and give the ownership of the buffer to coding_data. 265 std::unique_ptr<unsigned char[]> coding_data; 266 double psnr; 267 uint64_t sse; 268 int quantize_index; 269 FrameCounts frame_counts; 270 int num_rows_4x4; // number of row units, in size of 4. 271 int num_cols_4x4; // number of column units, in size of 4. 272 // A vector of the partition information of the frame. 273 // The number of elements is |num_rows_4x4| * |num_cols_4x4|. 274 // The frame is divided 4x4 blocks of |num_rows_4x4| rows and 275 // |num_cols_4x4| columns. 276 // Each 4x4 block contains the current pixel position (|row|, |column|), 277 // the start pixel position of the partition (|row_start|, |column_start|), 278 // and the |width|, |height| of the partition. 279 // The current pixel position can be the same as the start pixel position 280 // if the 4x4 block is the top-left block in the partition. Otherwise, they 281 // are different. 282 // Within the same partition, all 4x4 blocks have the same |row_start|, 283 // |column_start|, |width| and |height|. 284 // For example, if the frame is partitioned to a 32x32 block, 285 // starting at (0, 0). Then, there're 64 4x4 blocks within this partition. 286 // They all have the same |row_start|, |column_start|, |width|, |height|, 287 // which can be used to figure out the start of the current partition and 288 // the start of the next partition block. 289 // Horizontal next: |column_start| + |width|, 290 // Vertical next: |row_start| + |height|. 291 std::vector<PartitionInfo> partition_info; 292 // A vector of the motion vector information of the frame. 293 // The number of elements is |num_rows_4x4| * |num_cols_4x4|. 294 // The frame is divided into 4x4 blocks of |num_rows_4x4| rows and 295 // |num_cols_4x4| columns. 296 // Each 4x4 block contains 0 motion vector if this is an intra predicted 297 // frame (for example, the key frame). If the frame is inter predicted, 298 // each 4x4 block contains either 1 or 2 motion vectors. 299 // Similar to partition info, all 4x4 blocks inside the same partition block 300 // share the same motion vector information. 301 std::vector<MotionVectorInfo> motion_vector_info; 302 // A vector of the tpl stats information. 303 // The tpl stats measure the complexity of a frame, as well as the 304 // information propagated along the motion trajectory between frames, in 305 // the reference frame structure. 306 // The tpl stats could be used as a more accurate spatial and temporal 307 // complexity measure in addition to the first pass stats. 308 // The vector contains tpl stats for all show frames in a GOP. 309 // The tpl stats stored in the vector is according to the encoding order. 310 // For example, suppose there are N show frames for the current GOP. 311 // Then tpl_stats_info[0] stores the information of the first frame to be 312 // encoded for this GOP, i.e, the AltRef frame. 313 std::vector<TplStatsInfo> tpl_stats_info; 314 ImageBuffer coded_frame; 315 316 // recode_count, q_index_history and rate_history are only available when 317 // EncodeFrameWithTargetFrameBits() is used. 318 int recode_count; 319 std::vector<int> q_index_history; 320 std::vector<int> rate_history; 321 }; 322 323 struct GroupOfPicture { 324 // This list will be updated internally in StartEncode() and 325 // EncodeFrame()/EncodeFrameWithQuantizeIndex(). 326 // In EncodeFrame()/EncodeFrameWithQuantizeIndex(), the update will only be 327 // triggered when the coded frame is the last one in the previous group of 328 // pictures. 329 std::vector<EncodeFrameInfo> encode_frame_list; 330 331 // Indicates the index of the next coding frame in encode_frame_list. 332 // In other words, EncodeFrameInfo of the next coding frame can be 333 // obtained with encode_frame_list[next_encode_frame_index]. 334 // Internally, next_encode_frame_index will be set to zero after the last 335 // frame of the group of pictures is coded. Otherwise, next_encode_frame_index 336 // will be increased after each EncodeFrame()/EncodeFrameWithQuantizeIndex() 337 // call. 338 int next_encode_frame_index; 339 340 // Number of show frames in this group of pictures. 341 int show_frame_count; 342 343 // The show index/timestamp of the earliest show frame in the group of 344 // pictures. 345 int start_show_index; 346 347 // The coding index of the first coding frame in the group of pictures. 348 int start_coding_index; 349 350 // Indicates whether this group of pictures starts with a key frame. 351 int first_is_key_frame; 352 353 // Indicates whether this group of pictures uses an alt ref. 354 int use_alt_ref; 355 356 // Indicates whether previous group of pictures used an alt ref. 357 int last_gop_use_alt_ref; 358 }; 359 360 class SimpleEncode { 361 public: 362 // When outfile_path is set, the encoder will output the bitstream in ivf 363 // format. 364 SimpleEncode(int frame_width, int frame_height, int frame_rate_num, 365 int frame_rate_den, int target_bitrate, int num_frames, 366 int target_level, const char *infile_path, 367 const char *outfile_path = nullptr); 368 ~SimpleEncode(); 369 SimpleEncode(SimpleEncode &) = delete; 370 SimpleEncode &operator=(const SimpleEncode &) = delete; 371 372 // Adjusts the encoder's coding speed. 373 // If this function is not called, the encoder will use default encode_speed 374 // 0. Call this function before ComputeFirstPassStats() if needed. 375 // The encode_speed is equivalent to --cpu-used of the vpxenc command. 376 // The encode_speed's range should be [0, 9]. 377 // Setting the encode_speed to a higher level will yield faster coding 378 // at the cost of lower compression efficiency. 379 void SetEncodeSpeed(int encode_speed); 380 381 // Set encoder config 382 // The following configs in VP9EncoderConfig are allowed to change in this 383 // function. See https://ffmpeg.org/ffmpeg-codecs.html#libvpx for each 384 // config's meaning. 385 // Configs in VP9EncoderConfig: Equivalent configs in ffmpeg: 386 // 1 key_freq -g 387 // 2 two_pass_vbrmin_section -minrate * 100LL / bit_rate 388 // 3 two_pass_vbrmax_section -maxrate * 100LL / bit_rate 389 // 4 under_shoot_pct -undershoot-pct 390 // 5 over_shoot_pct -overshoot-pct 391 // 6 max_threads -threads 392 // 7 frame_parallel_decoding_mode -frame-parallel 393 // 8 tile_column -tile-columns 394 // 9 arnr_max_frames -arnr-maxframes 395 // 10 arnr_strength -arnr-strength 396 // 11 lag_in_frames -rc_lookahead 397 // 12 encode_breakout -static-thresh 398 // 13 enable_tpl_model -enable-tpl 399 // 14 enable_auto_arf -auto-alt-ref 400 // 15 rc_mode 401 // Possible Settings: 402 // 0 - Variable Bit Rate (VPX_VBR) -b:v <bit_rate> 403 // 1 - Constant Bit Rate (VPX_CBR) -b:v <bit_rate> -minrate <bit_rate> 404 // -maxrate <bit_rate> 405 // two_pass_vbrmin_section == 100 i.e. bit_rate == minrate == maxrate 406 // two_pass_vbrmax_section == 100 407 // 2 - Constrained Quality (VPX_CQ) -crf <cq_level> -b:v bit_rate 408 // 3 - Constant Quality (VPX_Q) -crf <cq_level> -b:v 0 409 // See https://trac.ffmpeg.org/wiki/Encode/VP9 for more details. 410 // 16 cq_level see rc_mode for details. 411 StatusCode SetEncodeConfig(const char *name, const char *value); 412 413 // A debug function that dumps configs from VP9EncoderConfig 414 // pass = 1: first pass, pass = 2: second pass 415 // fp: file pointer for dumping config 416 StatusCode DumpEncodeConfigs(int pass, FILE *fp); 417 418 // Makes encoder compute the first pass stats and store it at 419 // impl_ptr_->first_pass_stats. key_frame_map_ is also computed based on the 420 // first pass stats. 421 void ComputeFirstPassStats(); 422 423 // Outputs the first pass stats represented by a 2-D vector. 424 // One can use the frame index at first dimension to retrieve the stats for 425 // each video frame. The stats of each video frame is a vector of 25 double 426 // values. For details, please check FIRSTPASS_STATS in vp9_firstpass.h 427 std::vector<std::vector<double>> ObserveFirstPassStats(); 428 429 // Outputs the first pass motion vectors represented by a 2-D vector. 430 // One can use the frame index at first dimension to retrieve the mvs for 431 // each video frame. The frame is divided into 16x16 blocks. The number of 432 // elements is round_up(|num_rows_4x4| / 4) * round_up(|num_cols_4x4| / 4). 433 std::vector<std::vector<MotionVectorInfo>> ObserveFirstPassMotionVectors(); 434 435 // Ouputs a copy of key_frame_map_, a binary vector with size equal to the 436 // number of show frames in the video. For each entry in the vector, 1 437 // indicates the position is a key frame and 0 indicates it's not a key frame. 438 // This function should be called after ComputeFirstPassStats() 439 std::vector<int> ObserveKeyFrameMap() const; 440 441 // Sets group of pictures map for coding the entire video. 442 // Each entry in the gop_map corresponds to a show frame in the video. 443 // Therefore, the size of gop_map should equal to the number of show frames in 444 // the entire video. 445 // If a given entry's kGopMapFlagStart is set, it means this is the start of a 446 // gop. Once kGopMapFlagStart is set, one can set kGopMapFlagUseAltRef to 447 // indicate whether this gop use altref. 448 // If a given entry is zero, it means it's in the middle of a gop. 449 // This function should be called only once after ComputeFirstPassStats(), 450 // before StartEncode(). 451 // This API will check and modify the gop_map to satisfy the following 452 // constraints. 453 // 1) Each key frame position should be at the start of a gop. 454 // 2) The last gop should not use an alt ref. 455 void SetExternalGroupOfPicturesMap(int *gop_map, int gop_map_size); 456 457 // Observe the group of pictures map set through 458 // SetExternalGroupOfPicturesMap(). This function should be called after 459 // SetExternalGroupOfPicturesMap(). 460 std::vector<int> ObserveExternalGroupOfPicturesMap(); 461 462 // Initializes the encoder for actual encoding. 463 // This function should be called after ComputeFirstPassStats(). 464 void StartEncode(); 465 466 // Frees the encoder. 467 // This function should be called after StartEncode() or EncodeFrame(). 468 void EndEncode(); 469 470 // The key frame group size includes one key frame plus the number of 471 // following inter frames. Note that the key frame group size only counts the 472 // show frames. The number of no show frames like alternate refereces are not 473 // counted. 474 int GetKeyFrameGroupSize() const; 475 476 // Provides the group of pictures that the next coding frame is in. 477 // Only call this function between StartEncode() and EndEncode() 478 GroupOfPicture ObserveGroupOfPicture() const; 479 480 // Gets encode_frame_info for the next coding frame. 481 // Only call this function between StartEncode() and EndEncode() 482 EncodeFrameInfo GetNextEncodeFrameInfo() const; 483 484 // Encodes a frame 485 // This function should be called after StartEncode() and before EndEncode(). 486 void EncodeFrame(EncodeFrameResult *encode_frame_result); 487 488 // Encodes a frame with a specific quantize index. 489 // This function should be called after StartEncode() and before EndEncode(). 490 void EncodeFrameWithQuantizeIndex(EncodeFrameResult *encode_frame_result, 491 int quantize_index); 492 493 // Encode a frame with target frame bits usage. 494 // The encoder will find a quantize index to make the actual frame bits usage 495 // match the target. EncodeFrameWithTargetFrameBits() will recode the frame 496 // up to 7 times to find a q_index to make the actual_frame_bits satisfy the 497 // following inequality. |actual_frame_bits - target_frame_bits| * 100 / 498 // target_frame_bits 499 // <= percent_diff. 500 void EncodeFrameWithTargetFrameBits(EncodeFrameResult *encode_frame_result, 501 int target_frame_bits, 502 double percent_diff); 503 504 // Gets the number of coding frames for the video. The coding frames include 505 // show frame and no show frame. 506 // This function should be called after ComputeFirstPassStats(). 507 int GetCodingFrameNum() const; 508 509 // Gets the total number of pixels of YUV planes per frame. 510 uint64_t GetFramePixelCount() const; 511 512 private: 513 // Compute the key frame locations of the video based on first pass stats. 514 // The results are returned as a binary vector with 1s indicating keyframes 515 // and 0s indicating non keyframes. 516 // It has to be called after impl_ptr_->first_pass_stats is computed. 517 std::vector<int> ComputeKeyFrameMap() const; 518 519 // Updates key_frame_group_size_, reset key_frame_group_index_ and init 520 // ref_frame_info_. 521 void UpdateKeyFrameGroup(int key_frame_show_index); 522 523 // Update key_frame_group_index_. 524 void PostUpdateKeyFrameGroupIndex(FrameType frame_type); 525 526 void PostUpdateState(const EncodeFrameResult &encode_frame_result); 527 528 class EncodeImpl; 529 530 int frame_width_; // frame width in pixels. 531 int frame_height_; // frame height in pixels. 532 int frame_rate_num_; 533 int frame_rate_den_; 534 int target_bitrate_; 535 int num_frames_; 536 int encode_speed_; 537 int target_level_; 538 539 std::FILE *in_file_; 540 std::FILE *out_file_; 541 std::unique_ptr<EncodeImpl> impl_ptr_; 542 543 std::vector<int> key_frame_map_; 544 std::vector<int> gop_map_; 545 GroupOfPicture group_of_picture_; 546 547 // The key frame group size includes one key frame plus the number of 548 // following inter frames. Note that the key frame group size only counts the 549 // show frames. The number of no show frames like alternate references are not 550 // counted. 551 int key_frame_group_size_; 552 553 // The index for the to-be-coded show frame in the key frame group. 554 int key_frame_group_index_; 555 556 // Each show or no show frame is assigned with a coding index based on its 557 // coding order (starting from zero) in the coding process of the entire 558 // video. The coding index of the to-be-coded frame. 559 int frame_coding_index_; 560 561 // Number of show frames we have coded so far. 562 int show_frame_count_; 563 564 // TODO(angiebird): Do we need to reset ref_frames_info_ when the next key 565 // frame appears? 566 // Reference frames info of the to-be-coded frame. 567 RefFrameInfo ref_frame_info_; 568 569 // A 2-D vector of motion vector information of the frame collected 570 // from the first pass. The first dimension is the frame index. 571 // Each frame is divided into 16x16 blocks. The number of elements is 572 // round_up(|num_rows_4x4| / 4) * round_up(|num_cols_4x4| / 4). 573 // Each 16x16 block contains 0 motion vector if this is an intra predicted 574 // frame (for example, the key frame). If the frame is inter predicted, 575 // each 16x16 block contains either 1 or 2 motion vectors. 576 // The first motion vector is always from the LAST_FRAME. 577 // The second motion vector is always from the GOLDEN_FRAME. 578 std::vector<std::vector<MotionVectorInfo>> fp_motion_vector_info_; 579 }; 580 581 } // namespace vp9 582 583 #endif // VPX_VP9_SIMPLE_ENCODE_H_ 584