鳞状上皮内高度病变什么意思| 处暑吃什么| 嵌甲去医院挂什么科| 长期低血糖对人体有什么危害| 化疗期间吃什么| 女性尿频是什么原因| 每年什么时候征兵| 第一次坐飞机要注意什么| hpv68阳性是什么意思| 一什么窗| 白细胞低是什么原因引起的| 神经炎是什么症状| 甲状腺结节是什么引起的| 包皮过长是什么样的| 芝士可以做什么美食| 缺钾是什么原因引起的| 热毒是什么| 回门带什么礼物| 有代沟是什么意思| 风疹是什么症状| 梦见小男孩是什么预兆| 胃酸烧心吃什么药可以根治| 梦见别人打我是什么意思| 来月经是黑色的是什么原因| 汗斑是什么样的图片| 熬夜吃什么补回来| 9.1号是什么星座| 闰月是什么意思| 猫癣用什么药| 杜甫被人们称为什么| 梦见嫂子是什么意思| fashion什么意思| 月经总是提前是什么原因| 大学没毕业算什么学历| 韩国的思密达是什么意思| 杀阴虱用什么药最快| 长一智的上一句是什么| 本科毕业证是什么颜色| 什么样的夕阳| 什么地站着| 性功能下降吃什么药| 什么食物对眼睛好| 龙凤呈祥是什么生肖| 结婚 为什么| 什么病不能吃鸡蛋| 晚上睡觉流口水什么原因| 罗京什么病| 感冒发烧可以吃什么水果| 吃什么养肝护肝| 生理性厌恶是什么意思| 十点是什么时辰| 完美落幕是什么意思| 老人出汗多是什么原因| 头部挂什么科| 氮肥是什么肥料| 果酱样大便见于什么病| 鸽子是什么意思| 肾结石有什么症状| 霉菌阳性是什么意思| 宇舶手表什么档次| 玄五行属什么| 人的反义词是什么| 天井是什么意思| 庚午日五行属什么| 喝酒后胃疼吃什么药| ch4是什么气体| 胃酸烧心吃什么药可以根治| 万事达卡是什么卡| 嗓子发炎肿痛吃什么药| 力挽狂澜是什么意思| 葡萄糖偏低是什么意思| 白带是黄色是什么原因| 武汉大学校长是什么级别| 火龙果和香蕉榨汁有什么功效| 牙龈发炎用什么药| 红薯和什么不能一起吃| 维生素h是什么| 猫吃什么食物除了猫粮| nokia是什么牌子的手机| 711是什么星座| 邓紫棋和华晨宇什么关系| 三点水加四读什么| 阳痿早泄吃什么| 肉身成圣是什么意思| 吃什么睡眠好| 梦见自己理发是什么意思| 渣渣辉什么意思| 猪寸骨是什么部位| 什么是日记| 儿童肚子疼吃什么药| 肚子冰凉是什么原因| 黄牛用的什么抢票软件| 冰箱为什么结冰| 献完血吃什么东西补血| 什么时候喝咖啡最好| 感冒什么时候传染性最强| 怀孕需要注意什么| 彷徨是什么意思| 绌是什么意思| 高大的动物是什么生肖| 什么叫人| 算计是什么意思| 什么鹦鹉说话能力最强| 阳痿早泄用什么药| 04年是什么生肖| 宝宝反复发烧是什么原因| 哦买噶什么意思| pr值是什么意思| 脖子里面有结节是什么病| 人中长痘痘是什么原因| 为什么会长水痘| 日照有什么好吃的| 哺乳期胃疼可以吃什么药| 腚什么意思| 先兆流产什么意思| 脖子粗大是什么病的症状| 关心则乱是什么意思| 开水烫伤用什么药| 呆板是什么意思| 关节炎吃什么药好得快| 尊字五行属什么| 留守儿童是什么意思| 肛门坠胀吃什么药最好| 生门是什么意思| 老是口渴是什么原因| 企业性质指的是什么| 子宫出血是什么原因| 灰面是什么面粉| 属虎的五行属什么| 代偿是什么意思| 可人是什么意思| 鲸鱼属于什么类动物| 利妥昔单抗是什么药| 什么已经什么| 女人亏气亏血吃什么补的快| 质子治疗是什么意思| 疏肝解郁喝什么茶| 挚爱适合用在什么人| 小郡肝是什么部位| 阴道痛什么原因| 孕中期同房要注意什么| 鼻烟壶是干什么用的| 什么洗发水好| 绝经后吃什么能来月经| 拔牙后吃什么药| 牙龈萎缩用什么药| 绩效工资是什么意思| 落户是什么意思| 总蛋白偏低是什么原因| 忘恩负义的负是什么意思| qt什么意思| 为什么脚臭叫香港脚| 妈妈的姐妹叫什么| 利好是什么意思| 酪朊酸钠是什么| 什么是等位基因| 胃消化不好吃什么调理| 丙类药一般是什么药| 纪委书记是什么级别| hiv是什么病毒| 时刻是什么意思| kaiser是什么品牌| 建议MRI检查是什么意思| 乐属于五行属什么| 齿痕舌是什么原因| 提高免疫力吃什么食物| 胃肠性感冒吃什么药| 什么能美白皮肤而且效果快| 结节是什么病| 肝火旺盛喝什么茶| 噤若寒蝉是什么生肖| 白羊女喜欢什么样的男生| 温碧泉适合什么年龄| 煎中药用什么容器最好| 吃西洋参有什么好处| 孔子孟子什么关系| 初中什么时候开学| 刘秀和刘邦是什么关系| 空调一匹是什么意思| 十月份生日是什么星座| 喝什么酒容易醉| 皮蛋和什么不能一起吃| spiderman是什么意思| 女人梦见鱼是什么意思| 红豆相思是什么动物| 结肠多发憩室是什么意思| 左肾盂分离是什么意思| 什么的狮子| 霜降出什么生肖| 木耳不能和什么食物一起吃| 十二指肠炎吃什么药| 存是什么生肖| joan是什么意思| 如火如荼什么意思| 鹤立鸡群代表什么生肖| 恒源祥属于什么档次| mf是什么| 乐高可以拼什么| 天荒地老什么意思| 急性肠胃炎能吃什么| 睡莲为什么不开花| 春占生女是什么意思| dha什么时候吃最好| 心脏不舒服吃什么药| 窦性心律不齐是什么原因引起的| 裙裤配什么鞋子好看| 1月23日是什么星座| 嘴巴起水泡是什么原因| 赤砂糖是什么糖| 国家电网是什么编制| 嘴贱什么意思| 后背出汗多是什么原因| 突然尿频是什么原因| 血脂稠吃什么食物好| 什么是阻生智齿| 针眼是什么| 胆固醇高是什么症状| 磨人的小妖精是什么意思| beaf什么意思| 吃什么食物下奶快而且奶多| 糖精对人体有什么危害| 腰间盘突出挂什么科室| suan是什么意思| 鹿皮绒是什么面料| 嘌呤是什么东西| 苦衷是什么意思| 孔雀女是什么意思| 维生素b6有什么作用和功效| 子宫动脉阻力高是什么引起的| f4是什么意思| 儿童内热吃什么去内热| 酸奶可以做什么美食| 气血不足吃什么水果| tnt是什么意思| 7月22号是什么日子| 八月底什么星座| 糜烂型脚气用什么药| 手指甲有月牙代表什么| 血清肌酐高说明什么问题| 一什么浮萍| 二月出生是什么星座| 属狗什么命| 血脂高吃什么降血脂| 中将相当于什么级别| 梦见下小雨是什么征兆| 难以启齿什么意思| 叛逆期是什么意思| 做爱什么感觉| 西凤酒是什么香型| 夏花是什么意思| 利好是什么意思| 黄精有什么作用和功效| 胃酸吃什么| 自恋什么意思| 蜘蛛属于什么类动物| 领导喜欢什么样的员工| 生黄瓜吃了有什么好处| 肩周炎挂什么科| 鹅口疮用什么药| 细胞角蛋白19片段是什么意思| 什么军什么马| 纪是什么意思| 阻生牙是什么意思| 老人说胡话是什么征兆| 百度

中华人民共和国海上交通安全法(修订草案征求


Directory: ../../../ffmpeg/
File: src/libavformat/rtpdec_hevc.c
Date: 2025-08-04 00:43:16
Exec Total Coverage
Lines: 0 130 0.0%
Functions: 0 3 0.0%
Branches: 0 70 0.0%

Line Branch Exec Source
1 /*
2 * RTP parser for HEVC/H.265 payload format (draft version 6)
3 * Copyright (c) 2014 Thomas Volkert <thomas@homer-conferencing.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/avstring.h"
24 #include "libavutil/mem.h"
25
26 #include "avformat.h"
27 #include "internal.h"
28 #include "rtpdec.h"
29 #include "rtpdec_formats.h"
30
31 #define RTP_HEVC_PAYLOAD_HEADER_SIZE 2
32 #define RTP_HEVC_FU_HEADER_SIZE 1
33 #define RTP_HEVC_DONL_FIELD_SIZE 2
34 #define RTP_HEVC_DOND_FIELD_SIZE 1
35 #define RTP_HEVC_AP_NALU_LENGTH_FIELD_SIZE 2
36 #define HEVC_SPECIFIED_NAL_UNIT_TYPES 48
37
38 /* SDP out-of-band signaling data */
39 struct PayloadContext {
40 int using_donl_field;
41 int profile_id;
42 uint8_t *sps, *pps, *vps, *sei;
43 int sps_size, pps_size, vps_size, sei_size;
44 };
45
46 static const uint8_t start_sequence[] = { 0x00, 0x00, 0x00, 0x01 };
47
48 static av_cold int hevc_sdp_parse_fmtp_config(AVFormatContext *s,
49 AVStream *stream,
50 PayloadContext *hevc_data,
51 const char *attr, const char *value)
52 {
53 /* profile-space: 0-3 */
54 /* profile-id: 0-31 */
55 if (!strcmp(attr, "profile-id")) {
56 hevc_data->profile_id = atoi(value);
57 av_log(s, AV_LOG_TRACE, "SDP: found profile-id: %d\n", hevc_data->profile_id);
58 }
59
60 /* tier-flag: 0-1 */
61 /* level-id: 0-255 */
62 /* interop-constraints: [base16] */
63 /* profile-compatibility-indicator: [base16] */
64 /* sprop-sub-layer-id: 0-6, defines highest possible value for TID, default: 6 */
65 /* recv-sub-layer-id: 0-6 */
66 /* max-recv-level-id: 0-255 */
67 /* tx-mode: MSM,SSM */
68 /* sprop-vps: [base64] */
69 /* sprop-sps: [base64] */
70 /* sprop-pps: [base64] */
71 /* sprop-sei: [base64] */
72 if (!strcmp(attr, "sprop-vps") || !strcmp(attr, "sprop-sps") ||
73 !strcmp(attr, "sprop-pps") || !strcmp(attr, "sprop-sei")) {
74 uint8_t **data_ptr = NULL;
75 int *size_ptr = NULL;
76 if (!strcmp(attr, "sprop-vps")) {
77 data_ptr = &hevc_data->vps;
78 size_ptr = &hevc_data->vps_size;
79 } else if (!strcmp(attr, "sprop-sps")) {
80 data_ptr = &hevc_data->sps;
81 size_ptr = &hevc_data->sps_size;
82 } else if (!strcmp(attr, "sprop-pps")) {
83 data_ptr = &hevc_data->pps;
84 size_ptr = &hevc_data->pps_size;
85 } else if (!strcmp(attr, "sprop-sei")) {
86 data_ptr = &hevc_data->sei;
87 size_ptr = &hevc_data->sei_size;
88 } else
89 av_assert0(0);
90
91 ff_h264_parse_sprop_parameter_sets(s, data_ptr,
92 size_ptr, value);
93 }
94
95 /* max-lsr, max-lps, max-cpb, max-dpb, max-br, max-tr, max-tc */
96 /* max-fps */
97
98 /* sprop-max-don-diff: 0-32767
99
100 When the RTP stream depends on one or more other RTP
101 streams (in this case tx-mode MUST be equal to "MSM" and
102 MSM is in use), this parameter MUST be present and the
103 value MUST be greater than 0.
104 */
105 if (!strcmp(attr, "sprop-max-don-diff")) {
106 if (atoi(value) > 0)
107 hevc_data->using_donl_field = 1;
108 av_log(s, AV_LOG_TRACE, "Found sprop-max-don-diff in SDP, DON field usage is: %d\n",
109 hevc_data->using_donl_field);
110 }
111
112 /* sprop-depack-buf-nalus: 0-32767 */
113 if (!strcmp(attr, "sprop-depack-buf-nalus")) {
114 if (atoi(value) > 0)
115 hevc_data->using_donl_field = 1;
116 av_log(s, AV_LOG_TRACE, "Found sprop-depack-buf-nalus in SDP, DON field usage is: %d\n",
117 hevc_data->using_donl_field);
118 }
119
120 /* sprop-depack-buf-bytes: 0-4294967295 */
121 /* depack-buf-cap */
122 /* sprop-segmentation-id: 0-3 */
123 /* sprop-spatial-segmentation-idc: [base16] */
124 /* dec-parallel-ca: */
125 /* include-dph */
126
127 return 0;
128 }
129
130 static av_cold int hevc_parse_sdp_line(AVFormatContext *ctx, int st_index,
131 PayloadContext *hevc_data, const char *line)
132 {
133 AVStream *current_stream;
134 AVCodecParameters *par;
135 const char *sdp_line_ptr = line;
136
137 if (st_index < 0)
138 return 0;
139
140 current_stream = ctx->streams[st_index];
141 par = current_stream->codecpar;
142
143 if (av_strstart(sdp_line_ptr, "framesize:", &sdp_line_ptr)) {
144 ff_h264_parse_framesize(par, sdp_line_ptr);
145 } else if (av_strstart(sdp_line_ptr, "fmtp:", &sdp_line_ptr)) {
146 int ret = ff_parse_fmtp(ctx, current_stream, hevc_data, sdp_line_ptr,
147 hevc_sdp_parse_fmtp_config);
148 if (hevc_data->vps_size || hevc_data->sps_size ||
149 hevc_data->pps_size || hevc_data->sei_size) {
150 par->extradata_size = hevc_data->vps_size + hevc_data->sps_size +
151 hevc_data->pps_size + hevc_data->sei_size;
152 if ((ret = ff_alloc_extradata(par, par->extradata_size)) >= 0) {
153 int pos = 0;
154 memcpy(par->extradata + pos, hevc_data->vps, hevc_data->vps_size);
155 pos += hevc_data->vps_size;
156 memcpy(par->extradata + pos, hevc_data->sps, hevc_data->sps_size);
157 pos += hevc_data->sps_size;
158 memcpy(par->extradata + pos, hevc_data->pps, hevc_data->pps_size);
159 pos += hevc_data->pps_size;
160 memcpy(par->extradata + pos, hevc_data->sei, hevc_data->sei_size);
161 }
162
163 av_freep(&hevc_data->vps);
164 av_freep(&hevc_data->sps);
165 av_freep(&hevc_data->pps);
166 av_freep(&hevc_data->sei);
167 hevc_data->vps_size = 0;
168 hevc_data->sps_size = 0;
169 hevc_data->pps_size = 0;
170 hevc_data->sei_size = 0;
171 }
172 return ret;
173 }
174
175 return 0;
176 }
177
178 static int hevc_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_hevc_ctx,
179 AVStream *st, AVPacket *pkt, uint32_t *timestamp,
180 const uint8_t *buf, int len, uint16_t seq,
181 int flags)
182 {
183 const uint8_t *rtp_pl = buf;
184 int tid, lid, nal_type;
185 int first_fragment, last_fragment, fu_type;
186 uint8_t new_nal_header[2];
187 int res = 0;
188
189 /* sanity check for size of input packet: 1 byte payload at least */
190 if (len < RTP_HEVC_PAYLOAD_HEADER_SIZE + 1) {
191 av_log(ctx, AV_LOG_ERROR, "Too short RTP/HEVC packet, got %d bytes\n", len);
192 return AVERROR_INVALIDDATA;
193 }
194
195 /*
196 * decode the HEVC payload header according to section 4 of draft version 6:
197 *
198 * 0 1
199 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
200 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201 * |F| Type | LayerId | TID |
202 * +-------------+-----------------+
203 *
204 * Forbidden zero (F): 1 bit
205 * NAL unit type (Type): 6 bits
206 * NUH layer ID (LayerId): 6 bits
207 * NUH temporal ID plus 1 (TID): 3 bits
208 */
209 nal_type = (buf[0] >> 1) & 0x3f;
210 lid = ((buf[0] << 5) & 0x20) | ((buf[1] >> 3) & 0x1f);
211 tid = buf[1] & 0x07;
212
213 /* sanity check for correct layer ID */
214 if (lid) {
215 /* future scalable or 3D video coding extensions */
216 avpriv_report_missing_feature(ctx, "Multi-layer HEVC coding");
217 return AVERROR_PATCHWELCOME;
218 }
219
220 /* sanity check for correct temporal ID */
221 if (!tid) {
222 av_log(ctx, AV_LOG_ERROR, "Illegal temporal ID in RTP/HEVC packet\n");
223 return AVERROR_INVALIDDATA;
224 }
225
226 /* sanity check for correct NAL unit type */
227 if (nal_type > 50) {
228 av_log(ctx, AV_LOG_ERROR, "Unsupported (HEVC) NAL type (%d)\n", nal_type);
229 return AVERROR_INVALIDDATA;
230 }
231
232 switch (nal_type) {
233 /* video parameter set (VPS) */
234 case 32:
235 /* sequence parameter set (SPS) */
236 case 33:
237 /* picture parameter set (PPS) */
238 case 34:
239 /* supplemental enhancement information (SEI) */
240 case 39:
241 /* single NAL unit packet */
242 default:
243 /* create A/V packet */
244 if ((res = av_new_packet(pkt, sizeof(start_sequence) + len)) < 0)
245 return res;
246 /* A/V packet: copy start sequence */
247 memcpy(pkt->data, start_sequence, sizeof(start_sequence));
248 /* A/V packet: copy NAL unit data */
249 memcpy(pkt->data + sizeof(start_sequence), buf, len);
250
251 break;
252 /* aggregated packet (AP) - with two or more NAL units */
253 case 48:
254 /* pass the HEVC payload header */
255 buf += RTP_HEVC_PAYLOAD_HEADER_SIZE;
256 len -= RTP_HEVC_PAYLOAD_HEADER_SIZE;
257
258 /* pass the HEVC DONL field */
259 if (rtp_hevc_ctx->using_donl_field) {
260 buf += RTP_HEVC_DONL_FIELD_SIZE;
261 len -= RTP_HEVC_DONL_FIELD_SIZE;
262 }
263
264 res = ff_h264_handle_aggregated_packet(ctx, rtp_hevc_ctx, pkt, buf, len,
265 rtp_hevc_ctx->using_donl_field ?
266 RTP_HEVC_DOND_FIELD_SIZE : 0,
267 NULL, 0);
268 if (res < 0)
269 return res;
270 break;
271 /* fragmentation unit (FU) */
272 case 49:
273 /* pass the HEVC payload header */
274 buf += RTP_HEVC_PAYLOAD_HEADER_SIZE;
275 len -= RTP_HEVC_PAYLOAD_HEADER_SIZE;
276
277 /*
278 * decode the FU header
279 *
280 * 0 1 2 3 4 5 6 7
281 * +-+-+-+-+-+-+-+-+
282 * |S|E| FuType |
283 * +---------------+
284 *
285 * Start fragment (S): 1 bit
286 * End fragment (E): 1 bit
287 * FuType: 6 bits
288 */
289 first_fragment = buf[0] & 0x80;
290 last_fragment = buf[0] & 0x40;
291 fu_type = buf[0] & 0x3f;
292
293 /* pass the HEVC FU header */
294 buf += RTP_HEVC_FU_HEADER_SIZE;
295 len -= RTP_HEVC_FU_HEADER_SIZE;
296
297 /* pass the HEVC DONL field */
298 if (rtp_hevc_ctx->using_donl_field) {
299 buf += RTP_HEVC_DONL_FIELD_SIZE;
300 len -= RTP_HEVC_DONL_FIELD_SIZE;
301 }
302
303 av_log(ctx, AV_LOG_TRACE, " FU type %d with %d bytes\n", fu_type, len);
304
305 /* sanity check for size of input packet: 1 byte payload at least */
306 if (len <= 0) {
307 if (len < 0) {
308 av_log(ctx, AV_LOG_ERROR,
309 "Too short RTP/HEVC packet, got %d bytes of NAL unit type %d\n",
310 len, nal_type);
311 return AVERROR_INVALIDDATA;
312 } else {
313 return AVERROR(EAGAIN);
314 }
315 }
316
317 if (first_fragment && last_fragment) {
318 av_log(ctx, AV_LOG_ERROR, "Illegal combination of S and E bit in RTP/HEVC packet\n");
319 return AVERROR_INVALIDDATA;
320 }
321
322 new_nal_header[0] = (rtp_pl[0] & 0x81) | (fu_type << 1);
323 new_nal_header[1] = rtp_pl[1];
324
325 res = ff_h264_handle_frag_packet(pkt, buf, len, first_fragment,
326 new_nal_header, sizeof(new_nal_header));
327
328 break;
329 /* PACI packet */
330 case 50:
331 /* Temporal scalability control information (TSCI) */
332 avpriv_report_missing_feature(ctx, "PACI packets for RTP/HEVC");
333 res = AVERROR_PATCHWELCOME;
334 break;
335 }
336
337 pkt->stream_index = st->index;
338
339 return res;
340 }
341
342 const RTPDynamicProtocolHandler ff_hevc_dynamic_handler = {
343 .enc_name = "H265",
344 .codec_type = AVMEDIA_TYPE_VIDEO,
345 .codec_id = AV_CODEC_ID_HEVC,
346 .need_parsing = AVSTREAM_PARSE_FULL,
347 .priv_data_size = sizeof(PayloadContext),
348 .parse_sdp_a_line = hevc_parse_sdp_line,
349 .parse_packet = hevc_handle_packet,
350 };
351

藏红花有什么功效 痛风该吃什么药好得快 烧仙草粉是什么做的 吃什么中药能降血压 春节吃什么
肝属于五行中的什么 什么是闭口 佩戴沉香有什么好处 8月17号是什么日子 全麻对身体有什么影响
爸爸的外婆叫什么 小熊衣服叫什么牌子 电子证件照是什么 核磁共振是检查什么的 参商是什么意思
点痣后用什么修复最好 美宝莲属于什么档次 吃完避孕药不能吃什么东西 如字五行属什么 乳头为什么是黑的
狮子男和什么星座最配hcv8jop2ns1r.cn 蝎子喜欢吃什么hcv8jop5ns0r.cn 音欠读什么bjhyzcsm.com 什么牌空调好用又省电hkuteam.com 脚汗多是什么原因hcv7jop7ns4r.cn
高梁长什么样子hcv9jop4ns7r.cn 为什么有眼袋是什么原因引起的hcv9jop3ns8r.cn 梦见已故的父母是什么兆头jasonfriends.com 脚真菌感染用什么药hcv9jop6ns3r.cn 什么样的闪电hcv7jop6ns4r.cn
干燥综合症是什么病hcv8jop6ns5r.cn 杂合突变型是什么意思onlinewuye.com 天天拉肚子是什么原因hcv9jop2ns0r.cn 古代人用什么刷牙hcv9jop1ns8r.cn 夏季有什么花hcv7jop5ns2r.cn
1983年属什么生肖hcv8jop8ns7r.cn 孙子的儿子叫什么hcv9jop4ns5r.cn 玹字五行属什么hcv8jop9ns1r.cn 兔跟什么生肖配对最好1949doufunao.com 月经2个月没来是什么原因hcv8jop5ns8r.cn
百度