Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
9294f5b4
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,发现更多精彩内容 >>
提交
9294f5b4
编写于
6月 18, 2020
作者:
L
Limin Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avcodec/utils: add ff_alloc_timecode_sei() for hevc timecode sei
Signed-off-by:
N
Limin Wang
<
lance.lmwang@gmail.com
>
上级
5151f6d2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
78 addition
and
0 deletion
+78
-0
libavcodec/internal.h
libavcodec/internal.h
+15
-0
libavcodec/utils.c
libavcodec/utils.c
+63
-0
未找到文件。
libavcodec/internal.h
浏览文件 @
9294f5b4
...
...
@@ -379,6 +379,21 @@ AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx);
int
ff_alloc_a53_sei
(
const
AVFrame
*
frame
,
size_t
prefix_len
,
void
**
data
,
size_t
*
sei_size
);
/**
* Check AVFrame for S12M timecode side data and allocate and fill TC SEI message with timecode info
*
* @param frame Raw frame to get S12M timecode side data from
* @param prefix_len Number of bytes to allocate before SEI message
* @param data Pointer to a variable to store allocated memory
* Upon return the variable will hold NULL on error or if frame has no S12M timecode info.
* Otherwise it will point to prefix_len uninitialized bytes followed by
* *sei_size SEI message
* @param sei_size Pointer to a variable to store generated SEI message length
* @return Zero on success, negative error code on failure
*/
int
ff_alloc_timecode_sei
(
const
AVFrame
*
frame
,
size_t
prefix_len
,
void
**
data
,
size_t
*
sei_size
);
/**
* Get an estimated video bitrate based on frame size, frame rate and coded
* bits per pixel.
...
...
libavcodec/utils.c
浏览文件 @
9294f5b4
...
...
@@ -50,6 +50,7 @@
#include "thread.h"
#include "frame_thread_encoder.h"
#include "internal.h"
#include "put_bits.h"
#include "raw.h"
#include "bytestream.h"
#include "version.h"
...
...
@@ -2244,6 +2245,68 @@ int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
return
0
;
}
static
unsigned
bcd2uint
(
uint8_t
bcd
)
{
unsigned
low
=
bcd
&
0xf
;
unsigned
high
=
bcd
>>
4
;
if
(
low
>
9
||
high
>
9
)
return
0
;
return
low
+
10
*
high
;
}
int
ff_alloc_timecode_sei
(
const
AVFrame
*
frame
,
size_t
prefix_len
,
void
**
data
,
size_t
*
sei_size
)
{
AVFrameSideData
*
sd
=
NULL
;
uint8_t
*
sei_data
;
PutBitContext
pb
;
uint32_t
*
tc
;
int
m
;
if
(
frame
)
sd
=
av_frame_get_side_data
(
frame
,
AV_FRAME_DATA_S12M_TIMECODE
);
if
(
!
sd
)
{
*
data
=
NULL
;
return
0
;
}
tc
=
(
uint32_t
*
)
sd
->
data
;
m
=
tc
[
0
]
&
3
;
*
sei_size
=
sizeof
(
uint32_t
)
*
4
;
*
data
=
av_mallocz
(
*
sei_size
+
prefix_len
);
if
(
!*
data
)
return
AVERROR
(
ENOMEM
);
sei_data
=
(
uint8_t
*
)
*
data
+
prefix_len
;
init_put_bits
(
&
pb
,
sei_data
,
*
sei_size
);
put_bits
(
&
pb
,
2
,
m
);
// num_clock_ts
for
(
int
j
=
1
;
j
<=
m
;
j
++
)
{
uint32_t
tcsmpte
=
tc
[
j
];
unsigned
hh
=
bcd2uint
(
tcsmpte
&
0x3f
);
// 6-bit hours
unsigned
mm
=
bcd2uint
(
tcsmpte
>>
8
&
0x7f
);
// 7-bit minutes
unsigned
ss
=
bcd2uint
(
tcsmpte
>>
16
&
0x7f
);
// 7-bit seconds
unsigned
ff
=
bcd2uint
(
tcsmpte
>>
24
&
0x3f
);
// 6-bit frames
unsigned
drop
=
tcsmpte
&
1
<<
30
&&
!
0
;
// 1-bit drop if not arbitrary bit
put_bits
(
&
pb
,
1
,
1
);
// clock_timestamp_flag
put_bits
(
&
pb
,
1
,
1
);
// units_field_based_flag
put_bits
(
&
pb
,
5
,
0
);
// counting_type
put_bits
(
&
pb
,
1
,
1
);
// full_timestamp_flag
put_bits
(
&
pb
,
1
,
0
);
// discontinuity_flag
put_bits
(
&
pb
,
1
,
drop
);
put_bits
(
&
pb
,
9
,
ff
);
put_bits
(
&
pb
,
6
,
ss
);
put_bits
(
&
pb
,
6
,
mm
);
put_bits
(
&
pb
,
5
,
hh
);
put_bits
(
&
pb
,
5
,
0
);
}
flush_put_bits
(
&
pb
);
return
0
;
}
int64_t
ff_guess_coded_bitrate
(
AVCodecContext
*
avctx
)
{
AVRational
framerate
=
avctx
->
framerate
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录