Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
ecab1c77
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,发现更多精彩内容 >>
提交
ecab1c77
编写于
6月 24, 2012
作者:
N
Nicolas George
提交者:
Anton Khirnov
10月 12, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
oggdec: add support for Opus in Ogg demuxing
上级
ed9245db
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
148 addition
and
2 deletion
+148
-2
Changelog
Changelog
+1
-0
libavformat/Makefile
libavformat/Makefile
+1
-0
libavformat/oggdec.c
libavformat/oggdec.c
+1
-0
libavformat/oggdec.h
libavformat/oggdec.h
+1
-0
libavformat/oggparseopus.c
libavformat/oggparseopus.c
+142
-0
libavformat/version.h
libavformat/version.h
+2
-2
未找到文件。
Changelog
浏览文件 @
ecab1c77
...
...
@@ -37,6 +37,7 @@ version 10:
- Error Resilient AAC syntax (ER AAC LC) decoding
- Low Delay AAC (ER AAC LD) decoding
- mux chapters in ASF files
- Opus in Ogg demuxing
version 9:
...
...
libavformat/Makefile
浏览文件 @
ecab1c77
...
...
@@ -212,6 +212,7 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \
oggparsedirac.o
\
oggparseflac.o
\
oggparseogm.o
\
oggparseopus.o
\
oggparseskeleton.o
\
oggparsespeex.o
\
oggparsetheora.o
\
...
...
libavformat/oggdec.c
浏览文件 @
ecab1c77
...
...
@@ -46,6 +46,7 @@ static const struct ogg_codec * const ogg_codecs[] = {
&
ff_theora_codec
,
&
ff_flac_codec
,
&
ff_celt_codec
,
&
ff_opus_codec
,
&
ff_old_dirac_codec
,
&
ff_old_flac_codec
,
&
ff_ogm_video_codec
,
...
...
libavformat/oggdec.h
浏览文件 @
ecab1c77
...
...
@@ -116,6 +116,7 @@ extern const struct ogg_codec ff_ogm_text_codec;
extern
const
struct
ogg_codec
ff_ogm_video_codec
;
extern
const
struct
ogg_codec
ff_old_dirac_codec
;
extern
const
struct
ogg_codec
ff_old_flac_codec
;
extern
const
struct
ogg_codec
ff_opus_codec
;
extern
const
struct
ogg_codec
ff_skeleton_codec
;
extern
const
struct
ogg_codec
ff_speex_codec
;
extern
const
struct
ogg_codec
ff_theora_codec
;
...
...
libavformat/oggparseopus.c
0 → 100644
浏览文件 @
ecab1c77
/*
* Opus parser for Ogg
* Copyright (c) 2012 Nicolas George
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <string.h>
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "internal.h"
#include "oggdec.h"
struct
oggopus_private
{
int
need_comments
;
unsigned
pre_skip
;
int64_t
cur_dts
;
};
#define OPUS_HEAD_SIZE 19
static
int
opus_header
(
AVFormatContext
*
avf
,
int
idx
)
{
struct
ogg
*
ogg
=
avf
->
priv_data
;
struct
ogg_stream
*
os
=
&
ogg
->
streams
[
idx
];
AVStream
*
st
=
avf
->
streams
[
idx
];
struct
oggopus_private
*
priv
=
os
->
private
;
uint8_t
*
packet
=
os
->
buf
+
os
->
pstart
;
uint8_t
*
extradata
;
if
(
!
priv
)
{
priv
=
os
->
private
=
av_mallocz
(
sizeof
(
*
priv
));
if
(
!
priv
)
return
AVERROR
(
ENOMEM
);
}
if
(
os
->
flags
&
OGG_FLAG_BOS
)
{
if
(
os
->
psize
<
OPUS_HEAD_SIZE
||
(
AV_RL8
(
packet
+
8
)
&
0xF0
)
!=
0
)
return
AVERROR_INVALIDDATA
;
st
->
codec
->
codec_type
=
AVMEDIA_TYPE_AUDIO
;
st
->
codec
->
codec_id
=
AV_CODEC_ID_OPUS
;
st
->
codec
->
channels
=
AV_RL8
(
packet
+
9
);
priv
->
pre_skip
=
AV_RL16
(
packet
+
10
);
extradata
=
av_malloc
(
os
->
psize
+
FF_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
extradata
)
return
AVERROR
(
ENOMEM
);
memcpy
(
extradata
,
packet
,
os
->
psize
);
st
->
codec
->
extradata
=
extradata
;
st
->
codec
->
extradata_size
=
os
->
psize
;
st
->
codec
->
sample_rate
=
48000
;
avpriv_set_pts_info
(
st
,
64
,
1
,
48000
);
priv
->
need_comments
=
1
;
return
1
;
}
if
(
priv
->
need_comments
)
{
if
(
os
->
psize
<
8
||
memcmp
(
packet
,
"OpusTags"
,
8
))
return
AVERROR_INVALIDDATA
;
ff_vorbis_comment
(
avf
,
&
st
->
metadata
,
packet
+
8
,
os
->
psize
-
8
);
priv
->
need_comments
--
;
return
1
;
}
return
0
;
}
static
int
opus_packet
(
AVFormatContext
*
avf
,
int
idx
)
{
struct
ogg
*
ogg
=
avf
->
priv_data
;
struct
ogg_stream
*
os
=
&
ogg
->
streams
[
idx
];
AVStream
*
st
=
avf
->
streams
[
idx
];
struct
oggopus_private
*
priv
=
os
->
private
;
uint8_t
*
packet
=
os
->
buf
+
os
->
pstart
;
unsigned
toc
,
toc_config
,
toc_count
,
frame_size
,
nb_frames
=
1
;
if
(
!
os
->
psize
)
return
AVERROR_INVALIDDATA
;
toc
=
*
packet
;
toc_config
=
toc
>>
3
;
toc_count
=
toc
&
3
;
frame_size
=
toc_config
<
12
?
FFMAX
(
480
,
960
*
(
toc_config
&
3
))
:
toc_config
<
16
?
480
<<
(
toc_config
&
1
)
:
120
<<
(
toc_config
&
3
);
if
(
toc_count
==
3
)
{
if
(
os
->
psize
<
2
)
return
AVERROR_INVALIDDATA
;
nb_frames
=
packet
[
1
]
&
0x3F
;
}
else
if
(
toc_count
)
{
nb_frames
=
2
;
}
os
->
pduration
=
frame_size
*
nb_frames
;
if
(
os
->
lastpts
!=
AV_NOPTS_VALUE
)
{
if
(
st
->
start_time
==
AV_NOPTS_VALUE
)
st
->
start_time
=
os
->
lastpts
;
priv
->
cur_dts
=
os
->
lastdts
=
os
->
lastpts
-=
priv
->
pre_skip
;
}
priv
->
cur_dts
+=
os
->
pduration
;
if
((
os
->
flags
&
OGG_FLAG_EOS
))
{
int64_t
skip
=
priv
->
cur_dts
-
os
->
granule
+
priv
->
pre_skip
;
skip
=
FFMIN
(
skip
,
os
->
pduration
);
if
(
skip
>
0
)
{
os
->
pduration
=
skip
<
os
->
pduration
?
os
->
pduration
-
skip
:
1
;
av_log
(
avf
,
AV_LOG_WARNING
,
"Last packet is truncated to %d (because of unimplemented end trim support).
\n
"
,
os
->
pduration
);
return
AVERROR_PATCHWELCOME
;
}
}
return
0
;
}
const
struct
ogg_codec
ff_opus_codec
=
{
.
name
=
"Opus"
,
.
magic
=
"OpusHead"
,
.
magicsize
=
8
,
.
header
=
opus_header
,
.
packet
=
opus_packet
,
.
granule_is_start
=
1
,
.
nb_header
=
1
,
};
libavformat/version.h
浏览文件 @
ecab1c77
...
...
@@ -30,8 +30,8 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR
5
#define LIBAVFORMAT_VERSION_MICRO
3
#define LIBAVFORMAT_VERSION_MINOR
6
#define LIBAVFORMAT_VERSION_MICRO
0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录