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