]> granicus.if.org Git - libvpx/commitdiff
Add GetFramePixelCount to SimpleEncode
authorangiebird <angiebird@google.com>
Wed, 11 Dec 2019 23:43:48 +0000 (15:43 -0800)
committerangiebird <angiebird@google.com>
Thu, 12 Dec 2019 20:03:28 +0000 (12:03 -0800)
Gets the total number of pixels of YUV planes per frame.

Change-Id: Ifdf35190cdde1378de6d7e93ab4428868a5795fa

test/simple_encode_test.cc
vp9/simple_encode.cc
vp9/simple_encode.h

index cc5012efdca8b13f9f2d80e322101a7cf8e4d533..33a66ed156c9c9b03871738e39284d8844c86420 100644 (file)
@@ -168,5 +168,12 @@ TEST(SimpleEncode, GetEncodeFrameInfo) {
   simple_encode.EndEncode();
 }
 
+TEST(SimpleEncode, GetFramePixelCount) {
+  SimpleEncode simple_encode(w, h, frame_rate_num, frame_rate_den,
+                             target_bitrate, num_frames, infile_path);
+  EXPECT_EQ(simple_encode.GetFramePixelCount(),
+            static_cast<uint64_t>(w * h * 3 / 2));
+}
+
 }  // namespace
 }  // namespace vp9
index fc5bb4a6c332e40e20eaf748b350a8e7eeb6951b..f756a888202aacc4c05c70efdb1338c63bc3953f 100644 (file)
@@ -377,6 +377,22 @@ int SimpleEncode::GetCodingFrameNum() const {
                                   multi_layer_arf, allow_alt_ref);
 }
 
+uint64_t SimpleEncode::GetFramePixelCount() const {
+  assert(frame_width_ % 2 == 0);
+  assert(frame_heigh_ % 2 == 0);
+  switch (impl_ptr_->img_fmt) {
+    case VPX_IMG_FMT_I420: return frame_width_ * frame_height_ * 3 / 2;
+    case VPX_IMG_FMT_I422: return frame_width_ * frame_height_ * 2;
+    case VPX_IMG_FMT_I444: return frame_width_ * frame_height_ * 3;
+    case VPX_IMG_FMT_I440: return frame_width_ * frame_height_ * 2;
+    case VPX_IMG_FMT_I42016: return frame_width_ * frame_height_ * 3 / 2;
+    case VPX_IMG_FMT_I42216: return frame_width_ * frame_height_ * 2;
+    case VPX_IMG_FMT_I44416: return frame_width_ * frame_height_ * 3;
+    case VPX_IMG_FMT_I44016: return frame_width_ * frame_height_ * 2;
+    default: return 0;
+  }
+}
+
 SimpleEncode::~SimpleEncode() {
   if (this->file_ != NULL) {
     fclose(this->file_);
index b8085298b65082209a6e29f3607f3c2fa2a46a6b..33f6138e7b03f5bd0f6dc8c2525a07a890d45a7c 100644 (file)
@@ -104,6 +104,9 @@ class SimpleEncode {
   // This function should be called after ComputeFirstPassStats().
   int GetCodingFrameNum() const;
 
+  // Gets the total number of pixels of YUV planes per frame.
+  uint64_t GetFramePixelCount() const;
+
  private:
   class EncodeImpl;