FFmpeg
Loading...
Searching...
No Matches
av1_levels.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Intel Corporation
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <stddef.h>
22#include <inttypes.h>
23#include "libavutil/log.h"
25
26static const struct {
27 int width;
28 int height;
29 float framerate;
31} test_sizes[] = {
32 { 426, 240, 30.0, 0 },
33 { 640, 360, 30.0, 1 },
34 { 854, 480, 30.0, 4 },
35 { 1280, 720, 30.0, 5 },
36 { 1920, 1080, 30.0, 8 },
37 { 1920, 1080, 60.0, 9 },
38 { 3840, 2160, 30.0, 12 },
39 { 3840, 2160, 60.0, 13 },
40 { 3840, 2160, 120.0, 14 },
41 { 7680, 4320, 30.0, 16 },
42 { 7680, 4320, 60.0, 17 },
43 { 7680, 4320, 120.0, 18 },
44};
45
46static const struct {
48 int tier;
49 int level_idx;
50} test_bitrate[] = {
51 { 1500000, 0, 0 },
52 { 3000000, 0, 1 },
53 { 6000000, 0, 4 },
54 { 10000000, 0, 5 },
55 { 12000000, 0, 8 },
56 { 30000000, 1, 8 },
57 { 20000000, 0, 9 },
58 { 50000000, 1, 9 },
59 { 30000000, 0, 12 },
60 { 100000000, 1, 12 },
61 { 40000000, 0, 13 },
62 { 160000000, 1, 13 },
63 { 60000000, 0, 14 },
64 { 240000000, 1, 14 },
65 { 100000000, 0, 17 },
66 { 480000000, 1, 17 },
67 { 160000000, 0, 18 },
68 { 800000000, 1, 18 },
69};
70
71static const struct {
72 int tiles;
74 int level_idx;
75} test_tiles[] = {
76 { 8, 4, 0 },
77 { 16, 6, 4 },
78 { 32, 8, 8 },
79 { 64, 8, 12 },
80 { 128, 16, 16 },
81};
82
83int main(void)
84{
86 int i;
87
88#define CHECK(expected, format, ...) do { \
89 if (level ? (level->level_idx != expected) \
90 : !level) { \
91 av_log(NULL, AV_LOG_ERROR, "Incorrect level for " \
92 format ": expected %d, got %d.\n", __VA_ARGS__, \
93 expected, level ? level->level_idx : -1); \
94 return 1; \
95 } \
96 } while (0)
97
98 for (i = 0; i < FF_ARRAY_ELEMS(test_sizes); i++) {
102 0, 0, test_sizes[i].framerate);
103 CHECK(test_sizes[i].level_idx, "size %dx%d, framerate %f",
105 }
106
107 for (i = 0; i < FF_ARRAY_ELEMS(test_bitrate); i++) {
110 0, 0, 0, 0, 0);
111 CHECK(test_bitrate[i].level_idx, "bitrate %"PRId64" tier %d",
113 }
114
115 for (i = 0; i < FF_ARRAY_ELEMS(test_tiles); i++) {
116 level = ff_av1_guess_level(0, 0, 0, 0,
119 0);
120 CHECK(test_tiles[i].level_idx, "tiles %d, tile cols %d",
123 }
124
125 return 0;
126}
const AV1LevelDescriptor * ff_av1_guess_level(int64_t bitrate, int tier, int width, int height, int tiles, int tile_cols, float fps)
Guess the level of a stream from some parameters.
Definition av1_levels.c:48
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
long long int64_t
Definition coverity.c:34
#define FF_ARRAY_ELEMS(a)
uint8_t level
Definition svq3.c:208
int tiles
Definition av1_levels.c:72
static const struct @373317350235113237103321367343237240077250064253 test_sizes[]
static const struct @306004356063346133342272312040301006006145257205 test_tiles[]
float framerate
Definition av1_levels.c:29
int tier
Definition av1_levels.c:48
#define CHECK(expected, format,...)
int64_t bitrate
Definition av1_levels.c:47
int main(void)
Definition av1_levels.c:83
int tile_cols
Definition av1_levels.c:73
static const struct @356122215220367331355043245070051071314054161356 test_bitrate[]
int level_idx
Definition av1_levels.c:30
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89