Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
e5cfc8fd
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e5cfc8fd
编写于
10月 03, 2014
作者:
M
Martin Storsjö
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sdp: Provide out of bound parameter sets for HEVC if extradata is set
Signed-off-by:
N
Martin Storsjö
<
martin@martin.st
>
上级
9b7f932e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
106 addition
and
2 deletion
+106
-2
libavformat/sdp.c
libavformat/sdp.c
+106
-2
未找到文件。
libavformat/sdp.c
浏览文件 @
e5cfc8fd
...
...
@@ -29,6 +29,7 @@
#include "avformat.h"
#include "internal.h"
#include "avc.h"
#include "hevc.h"
#include "rtp.h"
#if CONFIG_NETWORK
#include "network.h"
...
...
@@ -222,6 +223,107 @@ static char *extradata2psets(AVCodecContext *c)
return
psets
;
}
static
char
*
extradata2psets_hevc
(
AVCodecContext
*
c
)
{
char
*
psets
;
uint8_t
*
extradata
=
c
->
extradata
;
int
extradata_size
=
c
->
extradata_size
;
uint8_t
*
tmpbuf
=
NULL
;
int
ps_pos
[
3
]
=
{
0
};
static
const
char
*
const
ps_names
[
3
]
=
{
"vps"
,
"sps"
,
"pps"
};
int
num_arrays
,
num_nalus
;
int
pos
,
i
,
j
;
// Convert to hvcc format. Since we need to group multiple NALUs of
// the same type, and we might need to convert from one format to the
// other anyway, we get away with a little less work by using the hvcc
// format.
if
(
c
->
extradata
[
0
]
!=
1
)
{
AVIOContext
*
pb
;
if
(
avio_open_dyn_buf
(
&
pb
)
<
0
)
return
NULL
;
if
(
ff_isom_write_hvcc
(
pb
,
c
->
extradata
,
c
->
extradata_size
,
0
)
<
0
)
{
avio_close_dyn_buf
(
pb
,
&
tmpbuf
);
goto
err
;
}
extradata_size
=
avio_close_dyn_buf
(
pb
,
&
extradata
);
tmpbuf
=
extradata
;
}
if
(
extradata_size
<
23
)
goto
err
;
num_arrays
=
extradata
[
22
];
pos
=
23
;
for
(
i
=
0
;
i
<
num_arrays
;
i
++
)
{
int
num_nalus
,
nalu_type
;
if
(
pos
+
3
>
extradata_size
)
goto
err
;
nalu_type
=
extradata
[
pos
]
&
0x3f
;
// Not including libavcodec/hevc.h to avoid confusion between
// NAL_* with the same name for both H264 and HEVC.
if
(
nalu_type
==
32
)
// VPS
ps_pos
[
0
]
=
pos
;
else
if
(
nalu_type
==
33
)
// SPS
ps_pos
[
1
]
=
pos
;
else
if
(
nalu_type
==
34
)
// PPS
ps_pos
[
2
]
=
pos
;
num_nalus
=
AV_RB16
(
&
extradata
[
pos
+
1
]);
pos
+=
3
;
for
(
j
=
0
;
j
<
num_nalus
;
j
++
)
{
int
len
;
if
(
pos
+
2
>
extradata_size
)
goto
err
;
len
=
AV_RB16
(
&
extradata
[
pos
]);
pos
+=
2
;
if
(
pos
+
len
>
extradata_size
)
goto
err
;
pos
+=
len
;
}
}
if
(
!
ps_pos
[
0
]
||
!
ps_pos
[
1
]
||
!
ps_pos
[
2
])
goto
err
;
psets
=
av_mallocz
(
MAX_PSET_SIZE
);
if
(
!
psets
)
goto
err
;
psets
[
0
]
=
'\0'
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
pos
=
ps_pos
[
i
];
if
(
i
>
0
)
av_strlcat
(
psets
,
"; "
,
MAX_PSET_SIZE
);
av_strlcatf
(
psets
,
MAX_PSET_SIZE
,
"sprop-%s="
,
ps_names
[
i
]);
// Skipping boundary checks in the input here; we've already traversed
// the whole hvcc structure above without issues
num_nalus
=
AV_RB16
(
&
extradata
[
pos
+
1
]);
pos
+=
3
;
for
(
j
=
0
;
j
<
num_nalus
;
j
++
)
{
int
len
=
AV_RB16
(
&
extradata
[
pos
]);
int
strpos
;
pos
+=
2
;
if
(
j
>
0
)
av_strlcat
(
psets
,
","
,
MAX_PSET_SIZE
);
strpos
=
strlen
(
psets
);
if
(
!
av_base64_encode
(
psets
+
strpos
,
MAX_PSET_SIZE
-
strpos
,
&
extradata
[
pos
],
len
))
{
av_free
(
psets
);
goto
err
;
}
pos
+=
len
;
}
}
av_free
(
tmpbuf
);
return
psets
;
err:
av_free
(
tmpbuf
);
return
NULL
;
}
static
char
*
extradata2config
(
AVCodecContext
*
c
)
{
char
*
config
;
...
...
@@ -412,9 +514,11 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
break
;
case
AV_CODEC_ID_HEVC
:
if
(
c
->
extradata_size
)
av_log
(
NULL
,
AV_LOG_WARNING
,
"HEVC extradata not currently "
"passed properly through SDP
\n
"
);
config
=
extradata2psets_hevc
(
c
);
av_strlcatf
(
buff
,
size
,
"a=rtpmap:%d H265/90000
\r\n
"
,
payload_type
);
if
(
config
)
av_strlcatf
(
buff
,
size
,
"a=fmtp:%d %s
\r\n
"
,
payload_type
,
config
);
break
;
case
AV_CODEC_ID_MPEG4
:
if
(
c
->
extradata_size
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录