Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
7684a361
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,发现更多精彩内容 >>
提交
7684a361
编写于
8月 02, 2013
作者:
A
Alexandra Khirnova
提交者:
Anton Khirnov
8月 04, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mxfenc: switch to av_reallocp_array() and check allocation errors
Signed-off-by:
N
Anton Khirnov
<
anton@khirnov.net
>
上级
a10c4ce2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
18 deletion
+29
-18
libavformat/mxfenc.c
libavformat/mxfenc.c
+29
-18
未找到文件。
libavformat/mxfenc.c
浏览文件 @
7684a361
...
...
@@ -1182,7 +1182,7 @@ static void mxf_write_klv_fill(AVFormatContext *s)
}
}
static
void
mxf_write_partition
(
AVFormatContext
*
s
,
int
bodysid
,
static
int
mxf_write_partition
(
AVFormatContext
*
s
,
int
bodysid
,
int
indexsid
,
const
uint8_t
*
key
,
int
write_metadata
)
{
...
...
@@ -1191,6 +1191,7 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
int64_t
header_byte_count_offset
;
unsigned
index_byte_count
=
0
;
uint64_t
partition_offset
=
avio_tell
(
pb
);
int
err
;
if
(
!
mxf
->
edit_unit_byte_count
&&
mxf
->
edit_units_count
)
index_byte_count
=
85
+
12
+
(
s
->
nb_streams
+
1
)
*
6
+
...
...
@@ -1205,10 +1206,11 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
}
if
(
!
memcmp
(
key
,
body_partition_key
,
16
))
{
mxf
->
body_partition_offset
=
av_realloc
(
mxf
->
body_partition_offset
,
(
mxf
->
body_partitions_count
+
1
)
*
sizeof
(
*
mxf
->
body_partition_offset
));
if
((
err
=
av_reallocp_array
(
&
mxf
->
body_partition_offset
,
mxf
->
body_partitions_count
+
1
,
sizeof
(
*
mxf
->
body_partition_offset
)))
<
0
)
{
mxf
->
body_partitions_count
=
0
;
return
err
;
}
mxf
->
body_partition_offset
[
mxf
->
body_partitions_count
++
]
=
partition_offset
;
}
...
...
@@ -1273,6 +1275,8 @@ static void mxf_write_partition(AVFormatContext *s, int bodysid,
}
avio_flush
(
pb
);
return
0
;
}
static
const
UID
mxf_mpeg2_codec_uls
[]
=
{
...
...
@@ -1673,13 +1677,14 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
AVStream
*
st
=
s
->
streams
[
pkt
->
stream_index
];
MXFStreamContext
*
sc
=
st
->
priv_data
;
MXFIndexEntry
ie
=
{
0
};
int
err
;
if
(
!
mxf
->
edit_unit_byte_count
&&
!
(
mxf
->
edit_units_count
%
EDIT_UNITS_PER_BODY
))
{
mxf
->
index_entries
=
av_realloc
(
mxf
->
index_entries
,
(
mxf
->
edit_units_count
+
EDIT_UNITS_PER_BODY
)
*
sizeof
(
*
mxf
->
index_entries
));
if
(
!
mxf
->
index_entries
)
{
if
((
err
=
av_reallocp_array
(
&
mxf
->
index_entries
,
mxf
->
edit_units_count
+
EDIT_UNITS_PER_BODY
,
sizeof
(
*
mxf
->
index_entries
)))
<
0
)
{
mxf
->
edit_units_count
=
0
;
av_log
(
s
,
AV_LOG_ERROR
,
"could not allocate index entries
\n
"
);
return
-
1
;
return
err
;
}
}
...
...
@@ -1692,11 +1697,13 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
if
(
!
mxf
->
header_written
)
{
if
(
mxf
->
edit_unit_byte_count
)
{
mxf_write_partition
(
s
,
1
,
2
,
header_open_partition_key
,
1
);
if
((
err
=
mxf_write_partition
(
s
,
1
,
2
,
header_open_partition_key
,
1
))
<
0
)
return
err
;
mxf_write_klv_fill
(
s
);
mxf_write_index_table_segment
(
s
);
}
else
{
mxf_write_partition
(
s
,
0
,
0
,
header_open_partition_key
,
1
);
if
((
err
=
mxf_write_partition
(
s
,
0
,
0
,
header_open_partition_key
,
1
))
<
0
)
return
err
;
}
mxf
->
header_written
=
1
;
}
...
...
@@ -1706,8 +1713,8 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
(
!
mxf
->
edit_units_count
||
mxf
->
edit_units_count
>
EDIT_UNITS_PER_BODY
)
&&
!
(
ie
.
flags
&
0x33
))
{
// I frame, Gop start
mxf_write_klv_fill
(
s
);
mxf_write_partition
(
s
,
1
,
2
,
body_partition_key
,
0
);
if
((
err
=
mxf_write_partition
(
s
,
1
,
2
,
body_partition_key
,
0
))
<
0
)
return
err
;
mxf_write_klv_fill
(
s
);
mxf_write_index_table_segment
(
s
);
}
...
...
@@ -1776,16 +1783,18 @@ static int mxf_write_footer(AVFormatContext *s)
{
MXFContext
*
mxf
=
s
->
priv_data
;
AVIOContext
*
pb
=
s
->
pb
;
int
err
;
mxf
->
duration
=
mxf
->
last_indexed_edit_unit
+
mxf
->
edit_units_count
;
mxf_write_klv_fill
(
s
);
mxf
->
footer_partition_offset
=
avio_tell
(
pb
);
if
(
mxf
->
edit_unit_byte_count
)
{
// no need to repeat index
mxf_write_partition
(
s
,
0
,
0
,
footer_partition_key
,
0
);
if
((
err
=
mxf_write_partition
(
s
,
0
,
0
,
footer_partition_key
,
0
))
<
0
)
return
err
;
}
else
{
mxf_write_partition
(
s
,
0
,
2
,
footer_partition_key
,
0
);
if
((
err
=
mxf_write_partition
(
s
,
0
,
2
,
footer_partition_key
,
0
))
<
0
)
return
err
;
mxf_write_klv_fill
(
s
);
mxf_write_index_table_segment
(
s
);
}
...
...
@@ -1796,11 +1805,13 @@ static int mxf_write_footer(AVFormatContext *s)
if
(
s
->
pb
->
seekable
)
{
avio_seek
(
pb
,
0
,
SEEK_SET
);
if
(
mxf
->
edit_unit_byte_count
)
{
mxf_write_partition
(
s
,
1
,
2
,
header_closed_partition_key
,
1
);
if
((
err
=
mxf_write_partition
(
s
,
1
,
2
,
header_closed_partition_key
,
1
))
<
0
)
return
err
;
mxf_write_klv_fill
(
s
);
mxf_write_index_table_segment
(
s
);
}
else
{
mxf_write_partition
(
s
,
0
,
0
,
header_closed_partition_key
,
1
);
if
((
err
=
mxf_write_partition
(
s
,
0
,
0
,
header_closed_partition_key
,
1
))
<
0
)
return
err
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录