1 // Copyright 2024 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <v4l2_codec2/common/H264.h> 6 7 #include <log/log.h> 8 9 namespace android { 10 maxFramerateForLevelH264(C2Config::level_t level,const ui::Size & videoSize)11uint32_t maxFramerateForLevelH264(C2Config::level_t level, const ui::Size& videoSize) { 12 uint32_t maxFramerate = std::numeric_limits<uint32_t>::max(); 13 14 bool found = false; 15 for (const H264LevelLimits& limit : kH264Limits) { 16 if (limit.level != level) continue; 17 18 uint64_t frameSizeMB = 19 static_cast<uint64_t>((videoSize.width + 15) / 16) * ((videoSize.height + 15) / 16); 20 maxFramerate = limit.maxMBPS / frameSizeMB; 21 found = true; 22 break; 23 } 24 25 if (!found) ALOGW("%s - failed to find matching H264 level=%d", __func__, level); 26 27 return maxFramerate; 28 } 29 30 } // namespace android 31