Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
a5117a24
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,发现更多精彩内容 >>
提交
a5117a24
编写于
5月 07, 2012
作者:
A
Anton Khirnov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lavc: pad last audio frame with silence when needed.
上级
6d7f6177
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
80 addition
and
16 deletion
+80
-16
avconv.c
avconv.c
+0
-8
doc/APIchanges
doc/APIchanges
+6
-0
libavcodec/avcodec.h
libavcodec/avcodec.h
+3
-7
libavcodec/internal.h
libavcodec/internal.h
+6
-0
libavcodec/utils.c
libavcodec/utils.c
+64
-0
libavcodec/version.h
libavcodec/version.h
+1
-1
未找到文件。
avconv.c
浏览文件 @
a5117a24
...
...
@@ -2048,14 +2048,6 @@ static void flush_encoders(void)
av_fifo_generic_read
(
ost
->
fifo
,
audio_buf
,
fifo_bytes
,
NULL
);
/* pad last frame with silence if needed */
if
(
!
(
enc
->
codec
->
capabilities
&
CODEC_CAP_SMALL_LAST_FRAME
))
{
frame_bytes
=
enc
->
frame_size
*
enc
->
channels
*
av_get_bytes_per_sample
(
enc
->
sample_fmt
);
if
(
allocated_audio_buf_size
<
frame_bytes
)
exit_program
(
1
);
generate_silence
(
audio_buf
+
fifo_bytes
,
enc
->
sample_fmt
,
frame_bytes
-
fifo_bytes
);
}
encode_audio_frame
(
os
,
ost
,
audio_buf
,
frame_bytes
);
}
else
{
/* flush encoder with NULL frames until it is done
...
...
doc/APIchanges
浏览文件 @
a5117a24
...
...
@@ -13,6 +13,12 @@ libavutil: 2011-04-18
API changes, most recent first:
2012-xx-xx - xxxxxxx - lavc 54.13.1
For audio formats with fixed frame size, the last frame
no longer needs to be padded with silence, libavcodec
will handle this internally (effectively all encoders
behave as if they had CODEC_CAP_SMALL_LAST_FRAME set).
2012-xx-xx - xxxxxxx - lavc 54.13.0 - avcodec.h
Add sample_rate and channel_layout fields to AVFrame.
...
...
libavcodec/avcodec.h
浏览文件 @
a5117a24
...
...
@@ -3860,15 +3860,11 @@ int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
* @param[in] frame AVFrame containing the raw audio data to be encoded.
* May be NULL when flushing an encoder that has the
* CODEC_CAP_DELAY capability set.
* There are 2 codec capabilities that affect the allowed
* values of frame->nb_samples.
* If CODEC_CAP_SMALL_LAST_FRAME is set, then only the final
* frame may be smaller than avctx->frame_size, and all other
* frames must be equal to avctx->frame_size.
* If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
* can have any number of samples.
* If neither is set, frame->nb_samples must be equal to
* avctx->frame_size for all frames.
* If it is not set, frame->nb_samples must be equal to
* avctx->frame_size for all frames except the last.
* The final frame may be smaller than avctx->frame_size.
* @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
* output packet is non-empty, and to 0 if it is
* empty. If the function returns an error, the
...
...
libavcodec/internal.h
浏览文件 @
a5117a24
...
...
@@ -70,6 +70,12 @@ typedef struct AVCodecInternal {
*/
int
sample_count
;
#endif
/**
* An audio frame with less than required samples has been submitted and
* padded with silence. Reject all subsequent frames.
*/
int
last_audio_frame
;
}
AVCodecInternal
;
struct
AVCodecDefault
{
...
...
libavcodec/utils.c
浏览文件 @
a5117a24
...
...
@@ -857,11 +857,58 @@ int ff_alloc_packet(AVPacket *avpkt, int size)
}
}
/**
* Pad last frame with silence.
*/
static
int
pad_last_frame
(
AVCodecContext
*
s
,
AVFrame
**
dst
,
const
AVFrame
*
src
)
{
AVFrame
*
frame
=
NULL
;
uint8_t
*
buf
=
NULL
;
int
ret
;
if
(
!
(
frame
=
avcodec_alloc_frame
()))
return
AVERROR
(
ENOMEM
);
*
frame
=
*
src
;
if
((
ret
=
av_samples_get_buffer_size
(
&
frame
->
linesize
[
0
],
s
->
channels
,
s
->
frame_size
,
s
->
sample_fmt
,
0
))
<
0
)
goto
fail
;
if
(
!
(
buf
=
av_malloc
(
ret
)))
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
frame
->
nb_samples
=
s
->
frame_size
;
if
((
ret
=
avcodec_fill_audio_frame
(
frame
,
s
->
channels
,
s
->
sample_fmt
,
buf
,
ret
,
0
))
<
0
)
goto
fail
;
if
((
ret
=
av_samples_copy
(
frame
->
extended_data
,
src
->
extended_data
,
0
,
0
,
src
->
nb_samples
,
s
->
channels
,
s
->
sample_fmt
))
<
0
)
goto
fail
;
if
((
ret
=
av_samples_set_silence
(
frame
->
extended_data
,
src
->
nb_samples
,
frame
->
nb_samples
-
src
->
nb_samples
,
s
->
channels
,
s
->
sample_fmt
))
<
0
)
goto
fail
;
*
dst
=
frame
;
return
0
;
fail:
if
(
frame
->
extended_data
!=
frame
->
data
)
av_freep
(
&
frame
->
extended_data
);
av_freep
(
&
buf
);
av_freep
(
&
frame
);
return
ret
;
}
int
attribute_align_arg
avcodec_encode_audio2
(
AVCodecContext
*
avctx
,
AVPacket
*
avpkt
,
const
AVFrame
*
frame
,
int
*
got_packet_ptr
)
{
AVFrame
*
padded_frame
=
NULL
;
int
ret
;
int
user_packet
=
!!
avpkt
->
data
;
...
...
@@ -879,6 +926,16 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
if
(
frame
->
nb_samples
>
avctx
->
frame_size
)
return
AVERROR
(
EINVAL
);
}
else
if
(
!
(
avctx
->
codec
->
capabilities
&
CODEC_CAP_VARIABLE_FRAME_SIZE
))
{
if
(
frame
->
nb_samples
<
avctx
->
frame_size
&&
!
avctx
->
internal
->
last_audio_frame
)
{
ret
=
pad_last_frame
(
avctx
,
&
padded_frame
,
frame
);
if
(
ret
<
0
)
return
ret
;
frame
=
padded_frame
;
avctx
->
internal
->
last_audio_frame
=
1
;
}
if
(
frame
->
nb_samples
!=
avctx
->
frame_size
)
return
AVERROR
(
EINVAL
);
}
...
...
@@ -919,6 +976,13 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
here to simplify things */
avpkt
->
flags
|=
AV_PKT_FLAG_KEY
;
if
(
padded_frame
)
{
av_freep
(
&
padded_frame
->
data
[
0
]);
if
(
padded_frame
->
extended_data
!=
padded_frame
->
data
)
av_freep
(
&
padded_frame
->
extended_data
);
av_freep
(
&
padded_frame
);
}
return
ret
;
}
...
...
libavcodec/version.h
浏览文件 @
a5117a24
...
...
@@ -28,7 +28,7 @@
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 13
#define LIBAVCODEC_VERSION_MICRO
0
#define LIBAVCODEC_VERSION_MICRO
1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录