Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
62327e28
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,发现更多精彩内容 >>
提交
62327e28
编写于
1月 21, 2006
作者:
M
Måns Rullgård
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
native ac3 parser
Originally committed as revision 4878 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
13c71451
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
96 addition
and
35 deletion
+96
-35
libavcodec/a52dec.c
libavcodec/a52dec.c
+0
-7
libavcodec/allcodecs.c
libavcodec/allcodecs.c
+0
-2
libavcodec/parser.c
libavcodec/parser.c
+96
-26
未找到文件。
libavcodec/a52dec.c
浏览文件 @
62327e28
...
@@ -76,13 +76,6 @@ static void* dlsymm(void* handle, const char* symbol)
...
@@ -76,13 +76,6 @@ static void* dlsymm(void* handle, const char* symbol)
av_log
(
NULL
,
AV_LOG_ERROR
,
"A52 Decoder - function '%s' can't be resolved
\n
"
,
symbol
);
av_log
(
NULL
,
AV_LOG_ERROR
,
"A52 Decoder - function '%s' can't be resolved
\n
"
,
symbol
);
return
f
;
return
f
;
}
}
int
ff_a52_syncinfo
(
AVCodecContext
*
avctx
,
uint8_t
*
buf
,
int
*
flags
,
int
*
sample_rate
,
int
*
bit_rate
)
{
AC3DecodeState
*
s
=
avctx
->
priv_data
;
return
s
->
a52_syncinfo
(
buf
,
flags
,
sample_rate
,
bit_rate
);
}
#endif
#endif
static
int
a52_decode_init
(
AVCodecContext
*
avctx
)
static
int
a52_decode_init
(
AVCodecContext
*
avctx
)
...
...
libavcodec/allcodecs.c
浏览文件 @
62327e28
...
@@ -614,9 +614,7 @@ PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
...
@@ -614,9 +614,7 @@ PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
av_register_codec_parser
(
&
pnm_parser
);
av_register_codec_parser
(
&
pnm_parser
);
av_register_codec_parser
(
&
mpegaudio_parser
);
av_register_codec_parser
(
&
mpegaudio_parser
);
#ifdef CONFIG_AC3
av_register_codec_parser
(
&
ac3_parser
);
av_register_codec_parser
(
&
ac3_parser
);
#endif
#ifdef CONFIG_DVDSUB_DECODER
#ifdef CONFIG_DVDSUB_DECODER
av_register_codec_parser
(
&
dvdsub_parser
);
av_register_codec_parser
(
&
dvdsub_parser
);
...
...
libavcodec/parser.c
浏览文件 @
62327e28
...
@@ -748,24 +748,106 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
...
@@ -748,24 +748,106 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
return
buf_ptr
-
buf
;
return
buf_ptr
-
buf
;
}
}
#ifdef CONFIG_AC3
#ifdef CONFIG_A52BIN
extern
int
ff_a52_syncinfo
(
AVCodecContext
*
avctx
,
const
uint8_t
*
buf
,
int
*
flags
,
int
*
sample_rate
,
int
*
bit_rate
);
#else
extern
int
a52_syncinfo
(
const
uint8_t
*
buf
,
int
*
flags
,
int
*
sample_rate
,
int
*
bit_rate
);
#endif
typedef
struct
AC3ParseContext
{
typedef
struct
AC3ParseContext
{
uint8_t
inbuf
[
4096
];
/* input buffer */
uint8_t
inbuf
[
4096
];
/* input buffer */
uint8_t
*
inbuf_ptr
;
uint8_t
*
inbuf_ptr
;
int
frame_size
;
int
frame_size
;
int
flags
;
}
AC3ParseContext
;
}
AC3ParseContext
;
#define AC3_HEADER_SIZE 7
#define AC3_HEADER_SIZE 7
#define A52_LFE 16
static
const
int
ac3_sample_rates
[
4
]
=
{
48000
,
44100
,
32000
,
0
};
static
const
int
ac3_frame_sizes
[
64
][
3
]
=
{
{
64
,
69
,
96
},
{
64
,
70
,
96
},
{
80
,
87
,
120
},
{
80
,
88
,
120
},
{
96
,
104
,
144
},
{
96
,
105
,
144
},
{
112
,
121
,
168
},
{
112
,
122
,
168
},
{
128
,
139
,
192
},
{
128
,
140
,
192
},
{
160
,
174
,
240
},
{
160
,
175
,
240
},
{
192
,
208
,
288
},
{
192
,
209
,
288
},
{
224
,
243
,
336
},
{
224
,
244
,
336
},
{
256
,
278
,
384
},
{
256
,
279
,
384
},
{
320
,
348
,
480
},
{
320
,
349
,
480
},
{
384
,
417
,
576
},
{
384
,
418
,
576
},
{
448
,
487
,
672
},
{
448
,
488
,
672
},
{
512
,
557
,
768
},
{
512
,
558
,
768
},
{
640
,
696
,
960
},
{
640
,
697
,
960
},
{
768
,
835
,
1152
},
{
768
,
836
,
1152
},
{
896
,
975
,
1344
},
{
896
,
976
,
1344
},
{
1024
,
1114
,
1536
},
{
1024
,
1115
,
1536
},
{
1152
,
1253
,
1728
},
{
1152
,
1254
,
1728
},
{
1280
,
1393
,
1920
},
{
1280
,
1394
,
1920
},
};
static
const
int
ac3_bitrates
[
64
]
=
{
32
,
32
,
40
,
40
,
48
,
48
,
56
,
56
,
64
,
64
,
80
,
80
,
96
,
96
,
112
,
112
,
128
,
128
,
160
,
160
,
192
,
192
,
224
,
224
,
256
,
256
,
320
,
320
,
384
,
384
,
448
,
448
,
512
,
512
,
576
,
576
,
640
,
640
,
};
static
const
int
ac3_channels
[
8
]
=
{
2
,
1
,
2
,
3
,
3
,
4
,
4
,
5
};
static
int
ac3_sync
(
const
uint8_t
*
buf
,
int
*
channels
,
int
*
sample_rate
,
int
*
bit_rate
)
{
unsigned
int
fscod
,
frmsizecod
,
acmod
,
bsid
,
lfeon
;
GetBitContext
bits
;
init_get_bits
(
&
bits
,
buf
,
AC3_HEADER_SIZE
*
8
);
if
(
get_bits
(
&
bits
,
16
)
!=
0x0b77
)
return
0
;
get_bits
(
&
bits
,
16
);
/* crc */
fscod
=
get_bits
(
&
bits
,
2
);
frmsizecod
=
get_bits
(
&
bits
,
6
);
if
(
!
ac3_sample_rates
[
fscod
])
return
0
;
bsid
=
get_bits
(
&
bits
,
5
);
if
(
bsid
>
8
)
return
0
;
get_bits
(
&
bits
,
3
);
/* bsmod */
acmod
=
get_bits
(
&
bits
,
3
);
if
(
acmod
&
1
&&
acmod
!=
1
)
get_bits
(
&
bits
,
2
);
/* cmixlev */
if
(
acmod
&
4
)
get_bits
(
&
bits
,
2
);
/* surmixlev */
if
(
acmod
&
2
)
get_bits
(
&
bits
,
2
);
/* dsurmod */
lfeon
=
get_bits
(
&
bits
,
1
);
*
sample_rate
=
ac3_sample_rates
[
fscod
];
*
bit_rate
=
ac3_bitrates
[
frmsizecod
]
*
1000
;
*
channels
=
ac3_channels
[
acmod
]
+
lfeon
;
return
ac3_frame_sizes
[
frmsizecod
][
fscod
]
*
2
;
}
static
int
ac3_parse_init
(
AVCodecParserContext
*
s1
)
static
int
ac3_parse_init
(
AVCodecParserContext
*
s1
)
{
{
...
@@ -781,10 +863,7 @@ static int ac3_parse(AVCodecParserContext *s1,
...
@@ -781,10 +863,7 @@ static int ac3_parse(AVCodecParserContext *s1,
{
{
AC3ParseContext
*
s
=
s1
->
priv_data
;
AC3ParseContext
*
s
=
s1
->
priv_data
;
const
uint8_t
*
buf_ptr
;
const
uint8_t
*
buf_ptr
;
int
len
,
sample_rate
,
bit_rate
;
int
len
,
sample_rate
,
bit_rate
,
channels
;
static
const
int
ac3_channels
[
8
]
=
{
2
,
1
,
2
,
3
,
3
,
4
,
4
,
5
};
*
poutbuf
=
NULL
;
*
poutbuf
=
NULL
;
*
poutbuf_size
=
0
;
*
poutbuf_size
=
0
;
...
@@ -802,11 +881,7 @@ static int ac3_parse(AVCodecParserContext *s1,
...
@@ -802,11 +881,7 @@ static int ac3_parse(AVCodecParserContext *s1,
s
->
inbuf_ptr
+=
len
;
s
->
inbuf_ptr
+=
len
;
buf_size
-=
len
;
buf_size
-=
len
;
if
((
s
->
inbuf_ptr
-
s
->
inbuf
)
==
AC3_HEADER_SIZE
)
{
if
((
s
->
inbuf_ptr
-
s
->
inbuf
)
==
AC3_HEADER_SIZE
)
{
#ifdef CONFIG_A52BIN
len
=
ac3_sync
(
s
->
inbuf
,
&
channels
,
&
sample_rate
,
&
bit_rate
);
len
=
ff_a52_syncinfo
(
avctx
,
s
->
inbuf
,
&
s
->
flags
,
&
sample_rate
,
&
bit_rate
);
#else
len
=
a52_syncinfo
(
s
->
inbuf
,
&
s
->
flags
,
&
sample_rate
,
&
bit_rate
);
#endif
if
(
len
==
0
)
{
if
(
len
==
0
)
{
/* no sync found : move by one byte (inefficient, but simple!) */
/* no sync found : move by one byte (inefficient, but simple!) */
memmove
(
s
->
inbuf
,
s
->
inbuf
+
1
,
AC3_HEADER_SIZE
-
1
);
memmove
(
s
->
inbuf
,
s
->
inbuf
+
1
,
AC3_HEADER_SIZE
-
1
);
...
@@ -817,9 +892,7 @@ static int ac3_parse(AVCodecParserContext *s1,
...
@@ -817,9 +892,7 @@ static int ac3_parse(AVCodecParserContext *s1,
avctx
->
sample_rate
=
sample_rate
;
avctx
->
sample_rate
=
sample_rate
;
/* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */
/* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */
if
(
avctx
->
channels
!=
1
&&
avctx
->
channels
!=
2
){
if
(
avctx
->
channels
!=
1
&&
avctx
->
channels
!=
2
){
avctx
->
channels
=
ac3_channels
[
s
->
flags
&
7
];
avctx
->
channels
=
channels
;
if
(
s
->
flags
&
A52_LFE
)
avctx
->
channels
++
;
}
}
avctx
->
bit_rate
=
bit_rate
;
avctx
->
bit_rate
=
bit_rate
;
avctx
->
frame_size
=
6
*
256
;
avctx
->
frame_size
=
6
*
256
;
...
@@ -844,7 +917,6 @@ static int ac3_parse(AVCodecParserContext *s1,
...
@@ -844,7 +917,6 @@ static int ac3_parse(AVCodecParserContext *s1,
}
}
return
buf_ptr
-
buf
;
return
buf_ptr
-
buf
;
}
}
#endif
AVCodecParser
mpegvideo_parser
=
{
AVCodecParser
mpegvideo_parser
=
{
{
CODEC_ID_MPEG1VIDEO
,
CODEC_ID_MPEG2VIDEO
},
{
CODEC_ID_MPEG1VIDEO
,
CODEC_ID_MPEG2VIDEO
},
...
@@ -872,7 +944,6 @@ AVCodecParser mpegaudio_parser = {
...
@@ -872,7 +944,6 @@ AVCodecParser mpegaudio_parser = {
NULL
,
NULL
,
};
};
#ifdef CONFIG_AC3
AVCodecParser
ac3_parser
=
{
AVCodecParser
ac3_parser
=
{
{
CODEC_ID_AC3
},
{
CODEC_ID_AC3
},
sizeof
(
AC3ParseContext
),
sizeof
(
AC3ParseContext
),
...
@@ -880,4 +951,3 @@ AVCodecParser ac3_parser = {
...
@@ -880,4 +951,3 @@ AVCodecParser ac3_parser = {
ac3_parse
,
ac3_parse
,
NULL
,
NULL
,
};
};
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录