Android-cuttlefish cvd tool
nvenc_encoder_config.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// Codec-specific configuration for NvencVideoEncoder.
18// Each NVENC provider constructs one of these with the appropriate
19// values for its codec. The encoder uses it without knowing which
20// codec it is encoding.
21//
22// All fields are trivially destructible so this can be used as a
23// namespace-scope constant without dynamic initialization concerns.
24
25#pragma once
26
27#include <nvEncodeAPI.h>
28#include <stdint.h>
29
30#include <type_traits>
31
32#include "api/video/video_codec_type.h"
33#include "api/video_codecs/video_encoder.h"
34
35namespace cuttlefish {
36
40 webrtc::VideoCodecType webrtc_codec_type;
41
42 // Must point to a string literal (static lifetime).
44
45 // Resolution-based bitrate limits for WebRTC rate control.
46 const webrtc::VideoEncoder::ResolutionBitrateLimits* bitrate_limits;
48
49 // Clamping range for SetRates(). min should be the technical
50 // floor NVENC accepts (~50 kbps), not a quality floor — let
51 // WebRTC's bandwidth estimator go as low as needed.
54
55 // Called once during InitNvenc after preset loading.
56 void (*apply_defaults)(NV_ENC_CONFIG* config);
57
58 // Called per frame before nvEncEncodePicture. Must not clobber
59 // encodePicFlags.
60 void (*set_pic_params)(NV_ENC_PIC_PARAMS* params);
61};
62
63static_assert(std::is_trivially_destructible_v<NvencEncoderConfig>,
64 "NvencEncoderConfig must be trivially destructible so "
65 "it can be used as a namespace-scope constant");
66
67} // namespace cuttlefish
Definition: alloc_driver.h:20
Definition: nvenc_encoder_config.h:37
GUID codec_guid
Definition: nvenc_encoder_config.h:38
int32_t max_bitrate_bps
Definition: nvenc_encoder_config.h:53
void(* apply_defaults)(NV_ENC_CONFIG *config)
Definition: nvenc_encoder_config.h:56
webrtc::VideoCodecType webrtc_codec_type
Definition: nvenc_encoder_config.h:40
void(* set_pic_params)(NV_ENC_PIC_PARAMS *params)
Definition: nvenc_encoder_config.h:60
const char * implementation_name
Definition: nvenc_encoder_config.h:43
int32_t min_bitrate_bps
Definition: nvenc_encoder_config.h:52
const webrtc::VideoEncoder::ResolutionBitrateLimits * bitrate_limits
Definition: nvenc_encoder_config.h:46
size_t bitrate_limits_count
Definition: nvenc_encoder_config.h:47
GUID profile_guid
Definition: nvenc_encoder_config.h:39