[M108 Migration][MM] Clean codes in esplusplayer_util. 01/290201/3
authorSun-woo Nam <sunny.nam@samsung.com>
Tue, 21 Mar 2023 09:04:19 +0000 (02:04 -0700)
committerBot Blink <blinkbot@samsung.com>
Wed, 22 Mar 2023 03:59:26 +0000 (03:59 +0000)
It improves readability and reduces unnecessary compiles and errors.

1. Grouping together return values with the same value in a switch statement.
2. Use gfx::Size instead of using width and height separately.
3. Change const to constexpr for performance.

Reference:
https://review.tizen.org/gerrit/#/c/287778/

Change-Id: Ied8dbfcdab4df0112c64cbf7d457be3d59918652
Signed-off-by: Sun-woo Nam <sunny.nam@samsung.com>
tizen_src/chromium_impl/media/filters/esplusplayer_util.cc
tizen_src/chromium_impl/media/filters/esplusplayer_util.h
tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc

index c85efb5..a78563a 100644 (file)
@@ -19,6 +19,10 @@ namespace {
 
 }  // namespace
 
+constexpr gfx::Size kFHDVideoMaxSize(1920, 1080);
+constexpr gfx::Size k4KVideoMaxSize(3840, 2160);
+constexpr gfx::Size k8KVideoMaxSize(7680, 4320);
+
 namespace media {
 
 const char* GetString(media::BufferStatus status) {
@@ -184,35 +188,24 @@ gfx::Size GetMaxCodecResolution(esplusplayer_video_mime_type mime_type,
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_AV1:
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_HEVC:
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP9:
-      return {k8KVideoMaxWidth, k8KVideoMaxHeight};
-    case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP8:
-      return {kFHDVideoMaxWidth, kFHDVideoMaxHeight};
+      return k8KVideoMaxSize;
     case ESPLUSPLAYER_VIDEO_MIME_TYPE_H264:
       if (is_video_hole)
-        return {k4KVideoMaxWidth, k4KVideoMaxHeight};
+        return k4KVideoMaxSize;
       else
-        return {kFHDVideoMaxWidth, kFHDVideoMaxHeight};
+        return kFHDVideoMaxSize;
+    case ESPLUSPLAYER_VIDEO_MIME_TYPE_VP8:
     default:
-      // for all kind of codecs.
-      return {kFHDVideoMaxWidth, kFHDVideoMaxHeight};
+      return kFHDVideoMaxSize;
   }
 }
 
 gfx::Size GetPanelResolution() {
+  gfx::Size panel_size;
 #if BUILDFLAG(IS_TIZEN_TV)
-  int panel_width = GetTVPanelWidth();
-  int panel_height = GetTVPanelHeight();
-#else
-  int panel_width = 0;
-  int panel_height = 0;
+  panel_size = gfx::Size(GetTVPanelWidth(), GetTVPanelHeight());
 #endif
-  if (!panel_width || !panel_height) {
-    panel_width = kFHDVideoMaxWidth;
-    panel_height = kFHDVideoMaxHeight;
-  }
-
-  LOG(INFO) << "Panel resolution: " << panel_width << " x " << panel_height;
-  return {panel_width, panel_height};
+  return panel_size.IsEmpty() ? kFHDVideoMaxSize : panel_size;
 }
 
 gfx::Size GetMaxResolution(esplusplayer_video_mime_type mime_type,
index e4890a7..304d667 100644 (file)
 #include "ui/gfx/geometry/size.h"
 
 namespace media {
-const int kElementryStreamCount = 2;  // Audio, Video only.
-
-const int kVideoFramerateDen = 100;
-const int kVideoFramerateNum = 2997;
-const int kFHDVideoMaxWidth = 1920;
-const int kFHDVideoMaxHeight = 1080;
-const int k4KVideoMaxWidth = 3840;
-const int k4KVideoMaxHeight = 2160;
-const int k8KVideoMaxWidth = 7680;
-const int k8KVideoMaxHeight = 4320;
-const int kMaxFramerate = 60;
-const int kBuffingLimit = 5;  // Seconds
+constexpr int kElementryStreamCount = 2;  // Audio, Video only.
+constexpr int kVideoFramerateDen = 100;
+constexpr int kVideoFramerateNum = 2997;
+constexpr int kMaxFramerate = 60;
 
 const char* GetString(media::BufferStatus status);
 const char* GetString(esplusplayer_submit_status status);
@@ -44,8 +36,6 @@ esplusplayer_stream_type GetESPlusPlayerStreamType(DemuxerStream::Type type);
 
 PipelineStatus GetPipelineError(const esplusplayer_error_type error);
 
-gfx::Size GetMaxCodecResolution(esplusplayer_video_mime_type mime_type,
-                                bool is_video_hole);
 gfx::Size GetPanelResolution();
 gfx::Size GetMaxResolution(esplusplayer_video_mime_type mime_type,
                            bool is_video_hole);
index 1a972fc..5d13de1 100644 (file)
@@ -698,6 +698,7 @@ void MediaPlayerESPlusPlayer::InitializeStreamConfig(DemuxerStream::Type type) {
     }
     auto max_resolution =
         GetMaxResolution(video_stream_info.mime_type, is_video_hole_);
+    LOG(INFO) << "max resolution: " << max_resolution.ToString();
 
     video_stream_info.max_width = max_resolution.width();
     video_stream_info.max_height = max_resolution.height();