游离是什么意思| 梦到死去的亲人是什么意思| 纳豆是什么豆子| mcv是什么意思| 固体饮料是什么意思| 马桶对着卫生间门有什么不好| 皮肤起小水泡很痒是什么原因| 怀孕乳头会有什么变化| 婀娜多姿是什么动物| 烫伤擦什么药| 癫痫是什么| 女人什么时候是排卵期| 交运是什么意思| 心脏早搏是什么原因造成的| 无常是什么意思| 下岗是什么意思| 这句话是什么意思| 什么品牌的冰箱好| 什么的事| 夫妻合葬有什么讲究| 公卿是什么意思| 9月3号是什么节日| 大骨头炖什么好吃| 春天是什么样子的| 肺结核传染途径是什么| 24节气分别是什么| 什么样的浪花| 白色裤子搭什么颜色上衣| 高血糖可以吃什么水果| 皿是什么意思| 低血糖什么症状有哪些| 止语是什么意思| 私募是做什么的| 细菌性阴道炎是什么原因引起的| 今年是什么| 刘邦是什么生肖| atp 是什么| 甲功五项是什么意思| 醋蛋液主要治什么| 止咳平喘什么药最有效| 什么的尾巴长不了歇后语| lamer是什么牌子| 发烧拉肚子吃什么药| 优思明是什么| 面首是什么| dw手表属于什么档次| 飞天奖是什么奖| 全腹部ct平扫主要检查什么| 做梦梦到牛是什么意思| 多发肿大淋巴结是什么意思| 4月9号是什么星座| 弹性工作制是什么意思| 青蛙长什么样| charging是什么意思| 气血亏虚吃什么中成药| 干扰素是什么| 淋巴结增大是什么原因严重吗| tcl什么牌子| 大姨妈有血块是什么原因| 稽留热常见于什么病| 冬至说什么祝福语| 边缘心电图是什么意思| 肾脏不好吃什么食物好| 婴儿胎毛什么时候剃最好| 果糖胺是什么意思| 妇炎康片有什么副作用| 佛陀是什么意思| 经信局是干什么的| 虾青素有什么作用| 梦见水是什么预兆| 部首和偏旁有什么区别| 一根葱十分钟什么意思| 腰痛去医院挂什么科| 人生赢家什么意思| 鸡胸肉炒什么好吃| 146是什么意思| tablet是什么意思| 关节炎挂什么科| 尿味大是什么原因| sq是什么意思| 白马王子是什么意思| 10月6日什么星座| 怕热易出汗是什么原因| 浆水是什么| 顺铂是什么药| 水瓶座是什么星象| 有什么菜| 松垮是什么意思| 绸缪是什么意思| 15一16岁青少年腰疼是什么病| 肠道ct能检查什么| 依波手表什么档次| 49年属什么生肖| 男孩过生日送什么礼物好| 皮瓣手术是什么意思| 每天坚持跑步有什么好处| 为什么会感染幽门螺杆菌| 便秘吃什么药效果最好| 3的倒数是什么| 避孕套和安全套有什么区别| 俄罗斯的货币叫什么| 后顶焦度是什么意思| 肾和性功能有什么关系| 热闹非凡是什么意思| 梅毒查血查什么项目| 口腔脱皮是什么原因引起的| x代表什么数字| 屋尘螨是什么东西| 八一建军节是什么节日| 粉底液和bb霜有什么区别| 双子座男生喜欢什么样的女生| 行李是什么意思| 艾迪生病是什么病| 三个女人一台戏什么意思| 吃什么油最好| 中国铁塔是干什么的| 于无声处是什么意思| 蚂蚁爱吃什么东西| 混油皮是什么意思| 金钱龟吃什么食物| 年轻人长老年斑是什么原因| 羟基丁酸在淘宝叫什么| 测血糖挂什么科| 千山鸟飞绝的绝是什么意思| 牛肉发绿色是什么原因| 喝酒不能吃什么| 项羽为什么不杀项伯| 心电图窦性心律不齐是什么意思| 青少年长白头发是什么原因| 肝火旺盛吃什么食物好| 胃寒胃痛吃什么食物好| 耳朵嗡嗡的响是什么原因| 伶字五行属什么| scr医学上是什么意思| 子宫内膜粘连有什么症状| 狮子座是什么时候| 庆幸是什么意思| 奔跑吧 什么时候开播| 什么是拓扑| 飞蚊症是什么引起的| 钾低会出现什么症状| 脚脖子抽筋是什么原因| 威胁是什么意思| 大年初一是什么生肖| 去离子水是什么| 人为什么做梦| tab是什么意思| 受戒是什么意思| 孕妇用什么牙膏比较好| 妲己是什么生肖| 堂哥的儿子叫什么| 为什么叫天津卫| 舌头溃疡是什么原因造成的| 超敏c反应蛋白高是什么意思| 痛风是什么意思| 三顾茅庐是什么意思| 为什么会得血管瘤| 佩戴沉香有什么好处| 焯水是什么意思| 满月脸水牛背是什么病| 梦见蛇咬别人是什么意思| 雨淋棺材有什么说法| 家里出现蛇是什么征兆| 尿蛋白2十吃什么药| 什么洗衣液是中性的| 油嘴滑舌指什么生肖| 送葬后回家注意什么| 柠檬泡水有什么好处| 柿子和什么不能一起吃| 丧尸是什么意思| 红红的苹果像什么句子| 贡菜是什么菜做的| 秉字五行属什么| 八月20号是什么星座| 寒食节是什么意思| 甘油三酯高挂什么科| 胎儿右侧脉络丛囊肿是什么意思| 右侧卵巢无回声是什么意思| 只欠东风的上一句是什么| 什么枝什么叶| 福建有什么好吃的| 直男癌是什么意思| 低聚糖是什么| 十二生肖代表什么花| 84是什么意思| 卵巢囊性结构是什么意思| 蔬菜沙拉都放什么菜| 5到7点是什么时辰| 神经性皮炎用什么药膏效果最好| 伏特加兑什么好喝| 代发什么意思| 悻悻然是什么意思| 什么鱼蛋白质含量高| 贫血吃什么水果补血最快| 父亲坐过牢对孩子有什么影响| 吃力不讨好是什么意思| 坚强后盾是什么意思| 牡丹花有什么颜色| 念珠菌用什么药| 高嘌呤是什么意思| 精制盐是什么盐| 因子是什么| 什么是多巴胺| 打卤面都有什么卤| Iud是什么| 鹿的部首是什么| 乌龟为什么不吃东西| 湖面像什么| 霉菌性阴道炎用什么药效果好| 猫不能吃什么| 男人做噩梦是什么预兆| 生殖器疱疹吃什么药| 什么东西最吸引蛇| 肠镜活检意味着什么| 老年人腿肿是什么原因引起的| 保花保果用什么药最好| 浅蓝色是什么颜色| 得了子宫肌瘤注意什么| 急腹症是什么意思| 腿上长水泡是什么原因引起的| 县教育局局长是什么级别| 小鹦鹉吃什么食物| 00属什么生肖| 落英缤纷是什么意思| 什么是易孕体质| 肛门下坠感是什么原因| 小孩查微量元素挂什么科| 晚上十点多是什么时辰| 董卓字什么| 嘴巴麻是什么原因| 身上出现白块什么原因| hpv感染是什么病| 龙的五行属性是什么| 大学团委书记什么级别| 什么叫快闪| 拿什么让你幸福| 心脾两虚吃什么药| 儿童看小鸡挂什么科| 手心痒痒是什么预兆| 邓超的老婆叫什么名字| 蛇为什么会咬人| merry是什么意思| 吃什么代谢快| 诊断是什么意思| 大头鱼吃什么食物| 嫡孙是什么意思| 造影是什么手术| 胃肠感冒可以吃什么水果| 血清载脂蛋白b偏高是什么意思| 风评是什么意思| 青榄配什么煲汤止咳做法| 里急后重吃什么药最好| 睚眦必报是什么意思| 生物工程学什么| 什么叫开门见床头| 双头蛇是什么意思| 贤惠是什么意思| icu和ccu有什么区别| 鼻炎吃什么药见效快| 小孩出冷汗是什么原因| 庆幸是什么意思| 脸部痒是什么原因| 相伴是什么意思| 复方氨酚烷胺片是什么药| 百度

还有这样的操作?! VR水下无人机助你钓鱼满满


Directory: ../../../ffmpeg/
File: src/libavformat/av1.c
Date: 2025-08-04 00:43:16
Exec Total Coverage
Lines: 155 281 55.2%
Functions: 5 8 62.5%
Branches: 62 153 40.5%

Line Branch Exec Source
1 /*
2 * AV1 helper functions for muxers
3 * Copyright (c) 2018 James Almer <jamrial@gmail.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "libavutil/avassert.h"
23 #include "libavutil/mem.h"
24 #include "libavutil/pixfmt.h"
25 #include "libavcodec/av1.h"
26 #include "libavcodec/av1_parse.h"
27 #include "libavcodec/defs.h"
28 #include "libavcodec/put_bits.h"
29 #include "av1.h"
30 #include "avio.h"
31 #include "avio_internal.h"
32
33 60 static int av1_filter_obus(AVIOContext *pb, const uint8_t *buf,
34 int size, int *offset)
35 {
36 60 const uint8_t *start = buf, *end = buf + size;
37 int off;
38 enum {
39 START_NOT_FOUND,
40 START_FOUND,
41 END_FOUND,
42 OFFSET_IMPOSSIBLE,
43 60 } state = START_NOT_FOUND;
44
45 60 off = size = 0;
46
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 60 times.
206 while (buf < end) {
47 int64_t obu_size;
48 int start_pos, type, temporal_id, spatial_id;
49 146 int len = parse_obu_header(buf, end - buf, &obu_size, &start_pos,
50 &type, &temporal_id, &spatial_id);
51
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (len < 0)
52 return len;
53
54
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 86 times.
146 switch (type) {
55 60 case AV1_OBU_TEMPORAL_DELIMITER:
56 case AV1_OBU_REDUNDANT_FRAME_HEADER:
57 case AV1_OBU_TILE_LIST:
58 case AV1_OBU_PADDING:
59
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if (state == START_FOUND)
60 state = END_FOUND;
61 60 break;
62 86 default:
63
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 26 times.
86 if (state == START_NOT_FOUND) {
64 60 off = buf - start;
65 60 state = START_FOUND;
66
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 } else if (state == END_FOUND) {
67 state = OFFSET_IMPOSSIBLE;
68 }
69
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 40 times.
86 if (pb)
70 46 avio_write(pb, buf, len);
71 86 size += len;
72 86 break;
73 }
74 146 buf += len;
75 }
76
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if (offset)
78 *offset = state != OFFSET_IMPOSSIBLE ? off : -1;
79
80 60 return size;
81 }
82
83 60 int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size)
84 {
85 60 return av1_filter_obus(pb, buf, size, NULL);
86 }
87
88 int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out,
89 int *size, int *offset)
90 {
91 FFIOContext pb;
92 uint8_t *buf;
93 int len, off, ret;
94
95 len = ret = av1_filter_obus(NULL, in, *size, &off);
96 if (ret < 0) {
97 return ret;
98 }
99 if (off >= 0) {
100 *out = (uint8_t *)in;
101 *size = len;
102 *offset = off;
103
104 return 0;
105 }
106
107 buf = av_malloc(len + AV_INPUT_BUFFER_PADDING_SIZE);
108 if (!buf)
109 return AVERROR(ENOMEM);
110
111 ffio_init_write_context(&pb, buf, len);
112
113 ret = av1_filter_obus(&pb.pub, in, *size, NULL);
114 av_assert1(ret == len);
115
116 memset(buf + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
117
118 *out = buf;
119 *size = len;
120 *offset = 0;
121
122 return 0;
123 }
124
125 static inline void uvlc(GetBitContext *gb)
126 {
127 int leading_zeros = 0;
128
129 while (get_bits_left(gb)) {
130 if (get_bits1(gb))
131 break;
132 leading_zeros++;
133 }
134
135 if (leading_zeros >= 32)
136 return;
137
138 skip_bits_long(gb, leading_zeros);
139 }
140
141 4 static int parse_color_config(AV1SequenceParameters *seq_params, GetBitContext *gb)
142 {
143 4 int twelve_bit = 0;
144 4 int high_bitdepth = get_bits1(gb);
145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if (seq_params->profile == AV_PROFILE_AV1_PROFESSIONAL && high_bitdepth)
146 twelve_bit = get_bits1(gb);
147
148 4 seq_params->bitdepth = 8 + (high_bitdepth * 2) + (twelve_bit * 2);
149
150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (seq_params->profile == AV_PROFILE_AV1_HIGH)
151 seq_params->monochrome = 0;
152 else
153 4 seq_params->monochrome = get_bits1(gb);
154
155 4 seq_params->color_description_present_flag = get_bits1(gb);
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (seq_params->color_description_present_flag) {
157 seq_params->color_primaries = get_bits(gb, 8);
158 seq_params->transfer_characteristics = get_bits(gb, 8);
159 seq_params->matrix_coefficients = get_bits(gb, 8);
160 } else {
161 4 seq_params->color_primaries = AVCOL_PRI_UNSPECIFIED;
162 4 seq_params->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
163 4 seq_params->matrix_coefficients = AVCOL_SPC_UNSPECIFIED;
164 }
165
166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (seq_params->monochrome) {
167 seq_params->color_range = get_bits1(gb);
168 seq_params->chroma_subsampling_x = 1;
169 seq_params->chroma_subsampling_y = 1;
170 seq_params->chroma_sample_position = 0;
171 return 0;
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 } else if (seq_params->color_primaries == AVCOL_PRI_BT709 &&
173 seq_params->transfer_characteristics == AVCOL_TRC_IEC61966_2_1 &&
174 seq_params->matrix_coefficients == AVCOL_SPC_RGB) {
175 seq_params->chroma_subsampling_x = 0;
176 seq_params->chroma_subsampling_y = 0;
177 } else {
178 4 seq_params->color_range = get_bits1(gb);
179
180
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (seq_params->profile == AV_PROFILE_AV1_MAIN) {
181 4 seq_params->chroma_subsampling_x = 1;
182 4 seq_params->chroma_subsampling_y = 1;
183 } else if (seq_params->profile == AV_PROFILE_AV1_HIGH) {
184 seq_params->chroma_subsampling_x = 0;
185 seq_params->chroma_subsampling_y = 0;
186 } else {
187 if (twelve_bit) {
188 seq_params->chroma_subsampling_x = get_bits1(gb);
189 if (seq_params->chroma_subsampling_x)
190 seq_params->chroma_subsampling_y = get_bits1(gb);
191 else
192 seq_params->chroma_subsampling_y = 0;
193 } else {
194 seq_params->chroma_subsampling_x = 1;
195 seq_params->chroma_subsampling_y = 0;
196 }
197 }
198
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if (seq_params->chroma_subsampling_x && seq_params->chroma_subsampling_y)
199 4 seq_params->chroma_sample_position = get_bits(gb, 2);
200 }
201
202 4 skip_bits1(gb); // separate_uv_delta_q
203
204 4 return 0;
205 }
206
207 4 static int parse_sequence_header(AV1SequenceParameters *seq_params, const uint8_t *buf, int size)
208 {
209 GetBitContext gb;
210 int reduced_still_picture_header;
211 int frame_width_bits_minus_1, frame_height_bits_minus_1;
212 int size_bits, ret;
213
214 4 size_bits = get_obu_bit_length(buf, size, AV1_OBU_SEQUENCE_HEADER);
215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (size_bits < 0)
216 return size_bits;
217
218 4 ret = init_get_bits(&gb, buf, size_bits);
219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (ret < 0)
220 return ret;
221
222 4 memset(seq_params, 0, sizeof(*seq_params));
223
224 4 seq_params->profile = get_bits(&gb, 3);
225
226 4 skip_bits1(&gb); // still_picture
227 4 reduced_still_picture_header = get_bits1(&gb);
228
229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (reduced_still_picture_header) {
230 seq_params->level = get_bits(&gb, 5);
231 seq_params->tier = 0;
232 } else {
233 int initial_display_delay_present_flag, operating_points_cnt_minus_1;
234 int decoder_model_info_present_flag, buffer_delay_length_minus_1;
235
236
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
4 if (get_bits1(&gb)) { // timing_info_present_flag
237 2 skip_bits_long(&gb, 32); // num_units_in_display_tick
238 2 skip_bits_long(&gb, 32); // time_scale
239
240
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (get_bits1(&gb)) // equal_picture_interval
241 uvlc(&gb); // num_ticks_per_picture_minus_1
242
243 2 decoder_model_info_present_flag = get_bits1(&gb);
244
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (decoder_model_info_present_flag) {
245 2 buffer_delay_length_minus_1 = get_bits(&gb, 5);
246 2 skip_bits_long(&gb, 32); // num_units_in_decoding_tick
247 2 skip_bits(&gb, 10); // buffer_removal_time_length_minus_1 (5)
248 // frame_presentation_time_length_minus_1 (5)
249 }
250 } else
251 2 decoder_model_info_present_flag = 0;
252
253 4 initial_display_delay_present_flag = get_bits1(&gb);
254
255 4 operating_points_cnt_minus_1 = get_bits(&gb, 5);
256
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 for (int i = 0; i <= operating_points_cnt_minus_1; i++) {
257 int seq_level_idx, seq_tier;
258
259 4 skip_bits(&gb, 12); // operating_point_idc
260 4 seq_level_idx = get_bits(&gb, 5);
261
262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (seq_level_idx > 7)
263 seq_tier = get_bits1(&gb);
264 else
265 4 seq_tier = 0;
266
267
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (decoder_model_info_present_flag) {
268
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if (get_bits1(&gb)) { // decoder_model_present_for_this_op
269 2 skip_bits_long(&gb, buffer_delay_length_minus_1 + 1); // decoder_buffer_delay
270 2 skip_bits_long(&gb, buffer_delay_length_minus_1 + 1); // encoder_buffer_delay
271 2 skip_bits1(&gb); // low_delay_mode_flag
272 }
273 }
274
275
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (initial_display_delay_present_flag) {
276
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if (get_bits1(&gb)) // initial_display_delay_present_for_this_op
277 2 skip_bits(&gb, 4); // initial_display_delay_minus_1
278 }
279
280
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (i == 0) {
281 4 seq_params->level = seq_level_idx;
282 4 seq_params->tier = seq_tier;
283 }
284 }
285 }
286
287 4 frame_width_bits_minus_1 = get_bits(&gb, 4);
288 4 frame_height_bits_minus_1 = get_bits(&gb, 4);
289
290 4 skip_bits(&gb, frame_width_bits_minus_1 + 1); // max_frame_width_minus_1
291 4 skip_bits(&gb, frame_height_bits_minus_1 + 1); // max_frame_height_minus_1
292
293
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!reduced_still_picture_header) {
294
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (get_bits1(&gb)) // frame_id_numbers_present_flag
295 skip_bits(&gb, 7); // delta_frame_id_length_minus_2 (4), additional_frame_id_length_minus_1 (3)
296 }
297
298 4 skip_bits(&gb, 3); // use_128x128_superblock (1), enable_filter_intra (1), enable_intra_edge_filter (1)
299
300
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!reduced_still_picture_header) {
301 int enable_order_hint, seq_force_screen_content_tools;
302
303 4 skip_bits(&gb, 4); // enable_interintra_compound (1), enable_masked_compound (1)
304 // enable_warped_motion (1), enable_dual_filter (1)
305
306 4 enable_order_hint = get_bits1(&gb);
307
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (enable_order_hint)
308 4 skip_bits(&gb, 2); // enable_jnt_comp (1), enable_ref_frame_mvs (1)
309
310
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 if (get_bits1(&gb)) // seq_choose_screen_content_tools
311 4 seq_force_screen_content_tools = 2;
312 else
313 seq_force_screen_content_tools = get_bits1(&gb);
314
315
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (seq_force_screen_content_tools) {
316
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!get_bits1(&gb)) // seq_choose_integer_mv
317 skip_bits1(&gb); // seq_force_integer_mv
318 }
319
320
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (enable_order_hint)
321 4 skip_bits(&gb, 3); // order_hint_bits_minus_1
322 }
323
324 4 skip_bits(&gb, 3); // enable_superres (1), enable_cdef (1), enable_restoration (1)
325
326 4 parse_color_config(seq_params, &gb);
327
328 4 skip_bits1(&gb); // film_grain_params_present
329
330
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (get_bits_left(&gb))
331 return AVERROR_INVALIDDATA;
332
333 4 return 0;
334 }
335
336 int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int size)
337 {
338 int is_av1c;
339
340 if (size <= 0)
341 return AVERROR_INVALIDDATA;
342
343 is_av1c = !!(buf[0] & 0x80);
344 if (is_av1c) {
345 GetBitContext gb;
346 int ret, version = buf[0] & 0x7F;
347
348 if (version != 1 || size < 4)
349 return AVERROR_INVALIDDATA;
350
351 ret = init_get_bits8(&gb, buf, 4);
352 if (ret < 0)
353 return ret;
354
355 memset(seq, 0, sizeof(*seq));
356
357 skip_bits(&gb, 8);
358 seq->profile = get_bits(&gb, 3);
359 seq->level = get_bits(&gb, 5);
360 seq->tier = get_bits(&gb, 1);
361 seq->bitdepth = get_bits(&gb, 1) * 2 + 8;
362 seq->bitdepth += get_bits(&gb, 1) * 2;
363 seq->monochrome = get_bits(&gb, 1);
364 seq->chroma_subsampling_x = get_bits(&gb, 1);
365 seq->chroma_subsampling_y = get_bits(&gb, 1);
366 seq->chroma_sample_position = get_bits(&gb, 2);
367 seq->color_primaries = AVCOL_PRI_UNSPECIFIED;
368 seq->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
369 seq->matrix_coefficients = AVCOL_SPC_UNSPECIFIED;
370
371 size -= 4;
372 buf += 4;
373 }
374
375 while (size > 0) {
376 int64_t obu_size;
377 int start_pos, type, temporal_id, spatial_id;
378 int len = parse_obu_header(buf, size, &obu_size, &start_pos,
379 &type, &temporal_id, &spatial_id);
380 if (len < 0)
381 return len;
382
383 switch (type) {
384 case AV1_OBU_SEQUENCE_HEADER:
385 if (!obu_size)
386 return AVERROR_INVALIDDATA;
387
388 return parse_sequence_header(seq, buf + start_pos, obu_size);
389 default:
390 break;
391 }
392 size -= len;
393 buf += len;
394 }
395
396 return is_av1c ? 0 : AVERROR_INVALIDDATA;
397 }
398
399 5 int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
400 int write_seq_header)
401 {
402 AVIOContext *meta_pb;
403 AV1SequenceParameters seq_params;
404 PutBitContext pbc;
405 uint8_t header[4], *meta;
406 const uint8_t *seq;
407 5 int ret, nb_seq = 0, seq_size, meta_size;
408
409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (size <= 0)
410 return AVERROR_INVALIDDATA;
411
412
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if (buf[0] & 0x80) {
413 // first bit is nonzero, the passed data does not consist purely of
414 // OBUs. Expect that the data is already in AV1CodecConfigurationRecord
415 // format.
416 1 int config_record_version = buf[0] & 0x7f;
417
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (config_record_version != 1 || size < 4) {
418 return AVERROR_INVALIDDATA;
419 }
420
421 1 avio_write(pb, buf, size);
422
423 1 return 0;
424 }
425
426 4 ret = avio_open_dyn_buf(&meta_pb);
427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (ret < 0)
428 return ret;
429
430
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 while (size > 0) {
431 int64_t obu_size;
432 int start_pos, type, temporal_id, spatial_id;
433 4 int len = parse_obu_header(buf, size, &obu_size, &start_pos,
434 &type, &temporal_id, &spatial_id);
435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (len < 0) {
436 ret = len;
437 goto fail;
438 }
439
440
1/3
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4 switch (type) {
441 4 case AV1_OBU_SEQUENCE_HEADER:
442 4 nb_seq++;
443
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if (!obu_size || nb_seq > 1) {
444 ret = AVERROR_INVALIDDATA;
445 goto fail;
446 }
447 4 ret = parse_sequence_header(&seq_params, buf + start_pos, obu_size);
448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (ret < 0)
449 goto fail;
450
451 4 seq = buf;
452 4 seq_size = len;
453 4 break;
454 case AV1_OBU_METADATA:
455 if (!obu_size) {
456 ret = AVERROR_INVALIDDATA;
457 goto fail;
458 }
459 avio_write(meta_pb, buf, len);
460 break;
461 default:
462 break;
463 }
464 4 size -= len;
465 4 buf += len;
466 }
467
468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!nb_seq) {
469 ret = AVERROR_INVALIDDATA;
470 goto fail;
471 }
472
473 4 init_put_bits(&pbc, header, sizeof(header));
474
475 4 put_bits(&pbc, 1, 1); // marker
476 4 put_bits(&pbc, 7, 1); // version
477 4 put_bits(&pbc, 3, seq_params.profile);
478 4 put_bits(&pbc, 5, seq_params.level);
479 4 put_bits(&pbc, 1, seq_params.tier);
480 4 put_bits(&pbc, 1, seq_params.bitdepth > 8);
481 4 put_bits(&pbc, 1, seq_params.bitdepth == 12);
482 4 put_bits(&pbc, 1, seq_params.monochrome);
483 4 put_bits(&pbc, 1, seq_params.chroma_subsampling_x);
484 4 put_bits(&pbc, 1, seq_params.chroma_subsampling_y);
485 4 put_bits(&pbc, 2, seq_params.chroma_sample_position);
486 4 put_bits(&pbc, 8, 0); // padding
487 4 flush_put_bits(&pbc);
488
489 4 avio_write(pb, header, sizeof(header));
490
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (write_seq_header) {
491 4 avio_write(pb, seq, seq_size);
492 }
493
494 4 meta_size = avio_get_dyn_buf(meta_pb, &meta);
495
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (meta_size)
496 avio_write(pb, meta, meta_size);
497
498 4 fail:
499 4 ffio_free_dyn_buf(&meta_pb);
500
501 4 return ret;
502 }
503

蔻驰手表属于什么档次 调和油是什么油 为什么生理期不能拔牙 芈月和秦始皇什么关系 内瘘是什么意思
篱笆是什么意思 大包子什么馅好吃 豆浆不能和什么一起吃 总胆红素偏高是什么原因 梦见洗脚是什么意思
牛肉粉是什么调料 梦见已故长辈什么预兆 什么时候同房最容易怀孕 三色堇的花语是什么 芥末是什么植物做的
苏武牧羊是什么意思 一个田一个比读什么 女人吃什么排湿气最快 时间h代表什么 是什么为什么怎么办
什么水果上火hcv9jop5ns8r.cn 男占258女占369什么意思hcv9jop2ns7r.cn 腹泻是什么原因hcv8jop7ns7r.cn 不经历风雨怎能见彩虹是什么意思hcv8jop1ns9r.cn 梦见水是什么意思sanhestory.com
右脸长痘是什么原因hcv7jop9ns1r.cn 梦见下暴雨是什么意思hcv8jop1ns7r.cn 寂寞的近义词是什么hcv8jop0ns2r.cn 痛风什么药止痛最快gysmod.com 结婚十一年是什么婚hcv9jop0ns6r.cn
体检前一天要注意什么hcv8jop7ns8r.cn 羊肉和什么菜搭配最好hcv9jop4ns7r.cn 小鸭子吃什么hcv8jop9ns9r.cn 吃完麻辣烫吃什么补救hcv7jop9ns1r.cn 菜心又叫什么菜hkuteam.com
min是什么单位hcv8jop2ns1r.cn 普洱属于什么茶hcv9jop8ns1r.cn 血口喷人是什么意思hcv9jop3ns9r.cn 春天可以干什么hcv8jop8ns5r.cn 糖类抗原ca199偏高是什么原因hcv9jop1ns8r.cn
百度