Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 1 | // Copyright 2017 The Chromium OS 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 | // resolution detectors |
| 6 | |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 7 | #if defined(USE_V4L2_CODEC) |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 8 | #include <linux/videodev2.h> |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 9 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 10 | |
| 11 | #if defined(USE_VAAPI) |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 12 | #include <va/va.h> |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 13 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 14 | |
| 15 | #include "label_detect.h" |
| 16 | |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 17 | #if defined(USE_VAAPI) || defined(USE_V4L2_CODEC) |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 18 | static const int32_t width_4k = 3840; |
| 19 | static const int32_t height_4k = 2160; |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 20 | #endif |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 21 | |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 22 | #if defined(USE_VAAPI) |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 23 | #if VA_CHECK_VERSION(0, 35, 0) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 24 | |
| 25 | static const char kDRMDevicePattern[] = "/dev/dri/renderD*"; |
| 26 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 27 | static const VAProfile va_profiles_h264[] = { |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 28 | VAProfileH264Baseline, VAProfileH264Main, VAProfileH264High, |
| 29 | VAProfileH264ConstrainedBaseline, VAProfileNone}; |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 30 | |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 31 | static const VAProfile va_profiles_vp8[] = {VAProfileVP8Version0_3, |
| 32 | VAProfileNone}; |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 33 | |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 34 | static const VAProfile va_profiles_vp9[] = {VAProfileVP9Profile0, |
| 35 | VAProfileNone}; |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 36 | |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 37 | static const VAProfile va_profiles_av1[] = {VAProfileAV1Profile0, |
| 38 | VAProfileNone}; |
| 39 | |
Jeffrey Kardatzke | eab7cc0 | 2021-02-24 12:53:14 -0800 | [diff] [blame] | 40 | static const VAProfile va_profiles_hevc[] = {VAProfileHEVCMain, VAProfileNone}; |
| 41 | |
| 42 | static const VAProfile va_profiles_hevc_10bpp[] = {VAProfileHEVCMain10, |
| 43 | VAProfileNone}; |
| 44 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 45 | /* Determines if a VAAPI device associated with given |fd| supports |
| 46 | * |va_profiles| for |va_entrypoint|, and its maximum resolution is larger |
| 47 | * than 3840x2160. |
| 48 | */ |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 49 | static bool is_vaapi_4k_device(int fd, |
| 50 | const VAProfile* va_profiles, |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 51 | VAEntrypoint va_entrypoint, |
| 52 | bool is_10bpp) { |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 53 | int32_t resolution_width = 0; |
| 54 | int32_t resolution_height = 0; |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 55 | const unsigned int va_format = |
| 56 | is_10bpp ? VA_RT_FORMAT_YUV420_10 : VA_RT_FORMAT_YUV420; |
| 57 | |
| 58 | if (is_vaapi_support_formats(fd, va_profiles, va_entrypoint, va_format)) { |
| 59 | if (get_vaapi_max_resolution(fd, va_profiles, va_entrypoint, va_format, |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 60 | &resolution_width, &resolution_height)) { |
| 61 | return resolution_width >= width_4k && resolution_height >= height_4k; |
| 62 | } |
| 63 | } |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 64 | return false; |
| 65 | } |
| 66 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 67 | // Determines if is_vaapi_4k_device() for H264 decoding. |
| 68 | static bool is_vaapi_4k_device_dec_h264(int fd) { |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 69 | return is_vaapi_4k_device(fd, va_profiles_h264, VAEntrypointVLD, false); |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 70 | } |
| 71 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 72 | // Determines if is_vaapi_4k_device() for H264 encoding. |
| 73 | static bool is_vaapi_4k_device_enc_h264(int fd) { |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 74 | return ( |
| 75 | is_vaapi_4k_device(fd, va_profiles_h264, VAEntrypointEncSlice, false) || |
| 76 | is_vaapi_4k_device(fd, va_profiles_h264, VAEntrypointEncSliceLP, false)); |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 77 | } |
| 78 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 79 | // Determines if is_vaapi_4k_device() for VP8 decoding. |
| 80 | static bool is_vaapi_4k_device_dec_vp8(int fd) { |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 81 | return is_vaapi_4k_device(fd, va_profiles_vp8, VAEntrypointVLD, false); |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | // Determines if is_vaapi_4k_device() for VP8 encoding. |
| 85 | static bool is_vaapi_4k_device_enc_vp8(int fd) { |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 86 | return ( |
| 87 | is_vaapi_4k_device(fd, va_profiles_vp8, VAEntrypointEncSlice, false) || |
| 88 | is_vaapi_4k_device(fd, va_profiles_vp8, VAEntrypointEncSliceLP, false)); |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | // Determines if is_vaapi_4k_device() for VP9 decoding. |
| 92 | static bool is_vaapi_4k_device_dec_vp9(int fd) { |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 93 | return is_vaapi_4k_device(fd, va_profiles_vp9, VAEntrypointVLD, false); |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | // Determines if is_vaapi_4k_device() for VP9 encoding. |
| 97 | static bool is_vaapi_4k_device_enc_vp9(int fd) { |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 98 | return ( |
| 99 | is_vaapi_4k_device(fd, va_profiles_vp9, VAEntrypointEncSlice, false) || |
| 100 | is_vaapi_4k_device(fd, va_profiles_vp9, VAEntrypointEncSliceLP, false)); |
| 101 | } |
| 102 | |
| 103 | // Determines if is_vaapi_4k_device() for AV1 decoding. |
| 104 | static bool is_vaapi_4k_device_dec_av1(int fd) { |
| 105 | return is_vaapi_4k_device(fd, va_profiles_av1, VAEntrypointVLD, false); |
| 106 | } |
| 107 | |
| 108 | // Determines if is_vaapi_4k_device() for AV1 decoding 10BPP. |
| 109 | static bool is_vaapi_4k_device_dec_av1_10bpp(int fd) { |
| 110 | return is_vaapi_4k_device(fd, va_profiles_av1, VAEntrypointVLD, true); |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 111 | } |
Jeffrey Kardatzke | eab7cc0 | 2021-02-24 12:53:14 -0800 | [diff] [blame] | 112 | |
| 113 | // Determines if is_vaapi_4k_device() for HEVC decoding. |
| 114 | static bool is_vaapi_4k_device_dec_hevc(int fd) { |
| 115 | return is_vaapi_4k_device(fd, va_profiles_hevc, VAEntrypointVLD, false); |
| 116 | } |
| 117 | |
| 118 | // Determines if is_vaapi_4k_device() for HEVC decoding 10BPP. |
| 119 | static bool is_vaapi_4k_device_dec_hevc_10bpp(int fd) { |
| 120 | return is_vaapi_4k_device(fd, va_profiles_hevc_10bpp, VAEntrypointVLD, true); |
| 121 | } |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 122 | #endif // VA_CHECK_VERSION(0, 38, 1) |
| 123 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 124 | |
| 125 | #if defined(USE_V4L2_CODEC) |
| 126 | |
| 127 | static const char kVideoDevicePattern[] = "/dev/video*"; |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 128 | |
| 129 | /* Determined if a V4L2 device associated with given |fd| supports |pix_fmt| |
| 130 | * for |buf_type|, and its maximum resolution is larger than 3840x2160. |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 131 | */ |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 132 | static bool is_v4l2_4k_device(int fd, |
| 133 | enum v4l2_buf_type buf_type, |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 134 | uint32_t pix_fmt) { |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 135 | int32_t resolution_width; |
| 136 | int32_t resolution_height; |
| 137 | if (!is_hw_video_acc_device(fd)) { |
| 138 | return false; |
| 139 | } |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 140 | if (is_v4l2_support_format(fd, buf_type, pix_fmt)) { |
| 141 | if (get_v4l2_max_resolution(fd, pix_fmt, &resolution_width, |
| 142 | &resolution_height)) { |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 143 | return resolution_width >= width_4k && resolution_height >= height_4k; |
| 144 | } |
| 145 | } |
| 146 | return false; |
| 147 | } |
| 148 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 149 | // Determines if is_v4l2_4k_device() for H264 decoding. |
| 150 | static bool is_v4l2_4k_device_dec_h264(int fd) { |
| 151 | return is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, |
| 152 | V4L2_PIX_FMT_H264) || |
| 153 | is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, |
| 154 | V4L2_PIX_FMT_H264_SLICE); |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 155 | } |
| 156 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 157 | // Determines if is_v4l2_4k_device() for H264 encoding. |
| 158 | static bool is_v4l2_4k_device_enc_h264(int fd) { |
| 159 | return is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, |
| 160 | V4L2_PIX_FMT_H264); |
| 161 | } |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 162 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 163 | // Determines if is_v4l2_4k_device() for VP8 decoding. |
| 164 | static bool is_v4l2_4k_device_dec_vp8(int fd) { |
| 165 | return is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, |
| 166 | V4L2_PIX_FMT_VP8) || |
| 167 | is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, |
| 168 | V4L2_PIX_FMT_VP8_FRAME); |
| 169 | } |
| 170 | |
| 171 | // Determines if is_v4l2_4k_device() for VP8 encoding. |
| 172 | static bool is_v4l2_4k_device_enc_vp8(int fd) { |
| 173 | return is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, |
| 174 | V4L2_PIX_FMT_VP8); |
| 175 | } |
| 176 | |
| 177 | // Determines if is_v4l2_4k_device() for VP9 decoding. |
| 178 | static bool is_v4l2_4k_device_dec_vp9(int fd) { |
| 179 | return is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, |
| 180 | V4L2_PIX_FMT_VP9) || |
| 181 | is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, |
| 182 | V4L2_PIX_FMT_VP9_FRAME); |
| 183 | } |
| 184 | |
| 185 | // Determines if is_v4l2_4k_device() for VP9 encoding. |
| 186 | static bool is_v4l2_4k_device_enc_vp9(int fd) { |
| 187 | return is_v4l2_4k_device(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, |
| 188 | V4L2_PIX_FMT_VP9); |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 189 | } |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 190 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 191 | |
Hirokazu Honda | b0328c3 | 2017-10-02 13:18:37 +0900 | [diff] [blame] | 192 | /* Determines "4k_video_h264". Return true, if either the VAAPI device |
| 193 | * supports 4k resolution H264 decoding, has decoding entry point, |
| 194 | * and input YUV420 formats. Or there is a |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 195 | * /dev/video* device supporting 4k resolution H264 decoding. |
| 196 | */ |
Hirokazu Honda | b0328c3 | 2017-10-02 13:18:37 +0900 | [diff] [blame] | 197 | bool detect_4k_device_h264(void) { |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 198 | #if defined(USE_VAAPI) |
| 199 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_dec_h264)) |
| 200 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 201 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 202 | |
| 203 | #if defined(USE_V4L2_CODEC) |
| 204 | if (is_any_device(kVideoDevicePattern, is_v4l2_4k_device_dec_h264)) |
| 205 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 206 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 207 | |
| 208 | return false; |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 209 | } |
| 210 | |
Hirokazu Honda | b0328c3 | 2017-10-02 13:18:37 +0900 | [diff] [blame] | 211 | /* Determines "4k_video_vp8". Return true, if either the VAAPI device |
| 212 | * supports 4k resolution VP8 decoding, has decoding entry point, |
| 213 | * and input YUV420 formats. Or there is a |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 214 | * /dev/video* device supporting 4k resolution VP8 decoding. |
| 215 | */ |
Hirokazu Honda | b0328c3 | 2017-10-02 13:18:37 +0900 | [diff] [blame] | 216 | bool detect_4k_device_vp8(void) { |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 217 | #if defined(USE_VAAPI) |
| 218 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_dec_vp8)) |
| 219 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 220 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 221 | |
| 222 | #if defined(USE_V4L2_CODEC) |
| 223 | if (is_any_device(kVideoDevicePattern, is_v4l2_4k_device_dec_vp8)) |
| 224 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 225 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 226 | |
| 227 | return false; |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 228 | } |
| 229 | |
Hirokazu Honda | b0328c3 | 2017-10-02 13:18:37 +0900 | [diff] [blame] | 230 | /* Determines "4k_video_vp9". Return true, if either the VAAPI device |
| 231 | * supports 4k resolution VP9 decoding, has decoding entry point, |
| 232 | * and input YUV420 formats. Or there is a |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 233 | * /dev/video* device supporting 4k resolution VP9 decoding. |
| 234 | */ |
Hirokazu Honda | b0328c3 | 2017-10-02 13:18:37 +0900 | [diff] [blame] | 235 | bool detect_4k_device_vp9(void) { |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 236 | #if defined(USE_VAAPI) |
| 237 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_dec_vp9)) |
| 238 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 239 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 240 | |
| 241 | #if defined(USE_V4L2_CODEC) |
| 242 | if (is_any_device(kVideoDevicePattern, is_v4l2_4k_device_dec_vp9)) |
| 243 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 244 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 245 | |
| 246 | return false; |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 247 | } |
| 248 | |
Steve Cho | 7978486 | 2021-01-22 13:59:00 -0800 | [diff] [blame] | 249 | /* Determines "4k_video_av1". Return true, if either the VAAPI device |
| 250 | * supports 4k resolution AV1 decoding, has decoding entry point, |
| 251 | * and input YUV420 formats. |
| 252 | */ |
| 253 | bool detect_4k_device_av1(void) { |
| 254 | #if defined(USE_VAAPI) |
| 255 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_dec_av1)) |
| 256 | return true; |
| 257 | #endif // defined(USE_VAAPI) |
| 258 | |
| 259 | return false; |
| 260 | } |
| 261 | |
| 262 | /* Determines "4k_video_av1_10bpp". Return true, if either the VAAPI device |
| 263 | * supports 4k resolution AV1 10BPP decoding, has decoding entry point, |
| 264 | * and input YUV420 formats. |
| 265 | */ |
| 266 | bool detect_4k_device_av1_10bpp(void) { |
| 267 | #if defined(USE_VAAPI) |
| 268 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_dec_av1_10bpp)) |
| 269 | return true; |
| 270 | #endif // defined(USE_VAAPI) |
| 271 | |
| 272 | return false; |
| 273 | } |
| 274 | |
Jeffrey Kardatzke | eab7cc0 | 2021-02-24 12:53:14 -0800 | [diff] [blame] | 275 | /* Determines "4k_video_hevc". Return true, if the VAAPI device supports 4k |
| 276 | * resolution HEVC main decoding, has decoding entry point, and outputs YUV420 |
| 277 | * format. |
| 278 | */ |
| 279 | bool detect_4k_device_hevc(void) { |
| 280 | #if defined(USE_VAAPI) |
| 281 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_dec_hevc)) |
| 282 | return true; |
| 283 | #endif // defined(USE_VAAPI) |
| 284 | |
| 285 | return false; |
| 286 | } |
| 287 | |
| 288 | /* Determines "4k_video_hevc_10bpp". Return true, if the VAAPI device supports |
| 289 | * 4k resolution HEVC main10 10BPP decoding, has decoding entry point, and |
| 290 | * outputs YUV420 format. |
| 291 | */ |
| 292 | bool detect_4k_device_hevc_10bpp(void) { |
| 293 | #if defined(USE_VAAPI) |
| 294 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_dec_hevc_10bpp)) |
| 295 | return true; |
| 296 | #endif // defined(USE_VAAPI) |
| 297 | |
| 298 | return false; |
| 299 | } |
| 300 | |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 301 | /* Determines "4k_video_enc_h264". Return true, if either the VAAPI device |
| 302 | * supports 4k resolution H264 encoding, has encoding entry point, |
| 303 | * and input YUV420 formats. Or there is a |
| 304 | * /dev/video* device supporting 4k resolution H264 encoding. |
| 305 | */ |
| 306 | bool detect_4k_device_enc_h264(void) { |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 307 | #if defined(USE_VAAPI) |
| 308 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_enc_h264)) |
| 309 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 310 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 311 | |
| 312 | #if defined(USE_V4L2_CODEC) |
| 313 | if (is_any_device(kVideoDevicePattern, is_v4l2_4k_device_enc_h264)) |
| 314 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 315 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 316 | |
| 317 | return false; |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /* Determines "4k_video_enc_vp8". Return true, if either the VAAPI device |
| 321 | * supports 4k resolution VP8 encoding, has encoding entry point, |
| 322 | * and input YUV420 formats. Or there is a |
| 323 | * /dev/video* device supporting 4k resolution VP8 encoding. |
| 324 | */ |
| 325 | bool detect_4k_device_enc_vp8(void) { |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 326 | #if defined(USE_VAAPI) |
| 327 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_enc_vp8)) |
| 328 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 329 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 330 | |
| 331 | #if defined(USE_V4L2_CODEC) |
| 332 | if (is_any_device(kVideoDevicePattern, is_v4l2_4k_device_enc_vp8)) |
| 333 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 334 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 335 | |
| 336 | return false; |
Pin-chih Lin | 5195fe1 | 2019-03-06 21:20:15 +0800 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | /* Determines "4k_video_enc_vp9". Return true, if either the VAAPI device |
| 340 | * supports 4k resolution VP9 encoding, has encoding entry point, |
| 341 | * and input YUV420 formats. Or there is a |
| 342 | * /dev/video* device supporting 4k resolution VP9 encoding. |
| 343 | */ |
| 344 | bool detect_4k_device_enc_vp9(void) { |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 345 | #if defined(USE_VAAPI) |
| 346 | if (is_any_device(kDRMDevicePattern, is_vaapi_4k_device_enc_vp9)) |
| 347 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 348 | #endif // defined(USE_VAAPI) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 349 | |
| 350 | #if defined(USE_V4L2_CODEC) |
| 351 | if (is_any_device(kVideoDevicePattern, is_v4l2_4k_device_enc_vp9)) |
| 352 | return true; |
Tom Hughes | 0e81695 | 2020-08-24 18:04:24 -0700 | [diff] [blame] | 353 | #endif // defined(USE_V4L2_CODEC) |
Hirokazu Honda | 491b168 | 2019-12-06 14:03:36 +0900 | [diff] [blame] | 354 | |
| 355 | return false; |
Hirokazu Honda | d92e9ac | 2017-09-20 11:33:59 +0900 | [diff] [blame] | 356 | } |