From 9a855abd34c22abc379d5af6cca79373378f77ea Mon Sep 17 00:00:00 2001 From: Sun-woo Nam Date: Tue, 21 Mar 2023 02:04:19 -0700 Subject: [PATCH] [M108 Migration][MM] Clean codes in esplusplayer_util. 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 --- .../media/filters/esplusplayer_util.cc | 31 +++++++++------------- .../media/filters/esplusplayer_util.h | 18 +++---------- .../media/filters/media_player_esplusplayer.cc | 1 + 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc b/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc index c85efb5..a78563a 100644 --- a/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc +++ b/tizen_src/chromium_impl/media/filters/esplusplayer_util.cc @@ -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, diff --git a/tizen_src/chromium_impl/media/filters/esplusplayer_util.h b/tizen_src/chromium_impl/media/filters/esplusplayer_util.h index e4890a7..304d667 100644 --- a/tizen_src/chromium_impl/media/filters/esplusplayer_util.h +++ b/tizen_src/chromium_impl/media/filters/esplusplayer_util.h @@ -14,18 +14,10 @@ #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); diff --git a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc index 1a972fc..5d13de1 100644 --- a/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc +++ b/tizen_src/chromium_impl/media/filters/media_player_esplusplayer.cc @@ -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(); -- 2.7.4