Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
4b465299
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,发现更多精彩内容 >>
提交
4b465299
编写于
6月 03, 2003
作者:
M
Michael Niedermayer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4xm adpcm
Originally committed as revision 1928 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
c09948b6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
71 addition
and
8 deletion
+71
-8
libavcodec/adpcm.c
libavcodec/adpcm.c
+57
-1
libavcodec/allcodecs.c
libavcodec/allcodecs.c
+1
-0
libavcodec/avcodec.h
libavcodec/avcodec.h
+1
-0
libavformat/4xm.c
libavformat/4xm.c
+12
-7
未找到文件。
libavcodec/adpcm.c
浏览文件 @
4b465299
...
...
@@ -312,6 +312,33 @@ static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble)
return
(
short
)
predictor
;
}
static
inline
short
adpcm_4xa_expand_nibble
(
ADPCMChannelStatus
*
c
,
char
nibble
)
{
int
step_index
;
int
predictor
;
int
sign
,
delta
,
diff
,
step
;
step
=
step_table
[
c
->
step_index
];
step_index
=
c
->
step_index
+
index_table
[(
unsigned
)
nibble
];
if
(
step_index
<
0
)
step_index
=
0
;
else
if
(
step_index
>
88
)
step_index
=
88
;
sign
=
nibble
&
8
;
delta
=
nibble
&
7
;
diff
=
(
delta
*
step
+
(
step
>>
1
))
>>
3
;
// difference to code above
predictor
=
c
->
predictor
;
if
(
sign
)
predictor
-=
diff
;
else
predictor
+=
diff
;
CLAMP_TO_SHORT
(
predictor
);
c
->
predictor
=
predictor
;
c
->
step_index
=
step_index
;
return
(
short
)
predictor
;
}
static
inline
short
adpcm_ms_expand_nibble
(
ADPCMChannelStatus
*
c
,
char
nibble
)
{
int
predictor
;
...
...
@@ -334,7 +361,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
{
ADPCMContext
*
c
=
avctx
->
priv_data
;
ADPCMChannelStatus
*
cs
;
int
n
,
m
,
channel
;
int
n
,
m
,
channel
,
i
;
int
block_predictor
[
2
];
short
*
samples
;
uint8_t
*
src
;
...
...
@@ -444,6 +471,34 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
}
src
++
;
}
break
;
case
CODEC_ID_ADPCM_4XM
:
cs
=
&
(
c
->
status
[
0
]);
c
->
status
[
0
].
predictor
=
(
int16_t
)(
src
[
0
]
+
(
src
[
1
]
<<
8
));
src
+=
2
;
if
(
st
){
c
->
status
[
1
].
predictor
=
(
int16_t
)(
src
[
0
]
+
(
src
[
1
]
<<
8
));
src
+=
2
;
}
c
->
status
[
0
].
step_index
=
(
int16_t
)(
src
[
0
]
+
(
src
[
1
]
<<
8
));
src
+=
2
;
if
(
st
){
c
->
status
[
1
].
step_index
=
(
int16_t
)(
src
[
0
]
+
(
src
[
1
]
<<
8
));
src
+=
2
;
}
// if (cs->step_index < 0) cs->step_index = 0;
// if (cs->step_index > 88) cs->step_index = 88;
m
=
(
buf_size
-
(
src
-
buf
))
>>
st
;
//printf("%d %d %d %d\n", st, m, c->status[0].predictor, c->status[0].step_index);
//FIXME / XXX decode chanels individual & interleave samples
for
(
i
=
0
;
i
<
m
;
i
++
)
{
*
samples
++
=
adpcm_4xa_expand_nibble
(
&
c
->
status
[
0
],
src
[
i
]
&
0x0F
);
if
(
st
)
*
samples
++
=
adpcm_4xa_expand_nibble
(
&
c
->
status
[
1
],
src
[
i
+
m
]
&
0x0F
);
*
samples
++
=
adpcm_4xa_expand_nibble
(
&
c
->
status
[
0
],
src
[
i
]
>>
4
);
if
(
st
)
*
samples
++
=
adpcm_4xa_expand_nibble
(
&
c
->
status
[
1
],
src
[
i
+
m
]
>>
4
);
}
src
+=
m
<<
st
;
break
;
case
CODEC_ID_ADPCM_MS
:
...
...
@@ -529,6 +584,7 @@ AVCodec name ## _decoder = { \
ADPCM_CODEC
(
CODEC_ID_ADPCM_IMA_QT
,
adpcm_ima_qt
);
ADPCM_CODEC
(
CODEC_ID_ADPCM_IMA_WAV
,
adpcm_ima_wav
);
ADPCM_CODEC
(
CODEC_ID_ADPCM_MS
,
adpcm_ms
);
ADPCM_CODEC
(
CODEC_ID_ADPCM_4XM
,
adpcm_4xm
);
#undef ADPCM_CODEC
libavcodec/allcodecs.c
浏览文件 @
4b465299
...
...
@@ -133,6 +133,7 @@ PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
PCM_CODEC
(
CODEC_ID_ADPCM_IMA_QT
,
adpcm_ima_qt
);
PCM_CODEC
(
CODEC_ID_ADPCM_IMA_WAV
,
adpcm_ima_wav
);
PCM_CODEC
(
CODEC_ID_ADPCM_MS
,
adpcm_ms
);
PCM_CODEC
(
CODEC_ID_ADPCM_4XM
,
adpcm_4xm
);
#undef PCM_CODEC
}
...
...
libavcodec/avcodec.h
浏览文件 @
4b465299
...
...
@@ -1269,6 +1269,7 @@ PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
PCM_CODEC
(
CODEC_ID_ADPCM_IMA_QT
,
adpcm_ima_qt
);
PCM_CODEC
(
CODEC_ID_ADPCM_IMA_WAV
,
adpcm_ima_wav
);
PCM_CODEC
(
CODEC_ID_ADPCM_MS
,
adpcm_ms
);
PCM_CODEC
(
CODEC_ID_ADPCM_4XM
,
adpcm_4xm
);
#undef PCM_CODEC
...
...
libavformat/4xm.c
浏览文件 @
4b465299
...
...
@@ -71,6 +71,7 @@ typedef struct AudioTrack {
int
bits
;
int
channels
;
int
stream_index
;
int
adpcm
;
}
AudioTrack
;
typedef
struct
FourxmDemuxContext
{
...
...
@@ -172,9 +173,11 @@ static int fourxm_read_header(AVFormatContext *s,
return
AVERROR_NOMEM
;
}
}
fourxm
->
tracks
[
current_track
].
adpcm
=
LE_32
(
&
header
[
i
+
12
]);
fourxm
->
tracks
[
current_track
].
channels
=
LE_32
(
&
header
[
i
+
36
]);
fourxm
->
tracks
[
current_track
].
sample_rate
=
LE_32
(
&
header
[
i
+
40
]);
fourxm
->
tracks
[
current_track
].
bits
=
LE_32
(
&
header
[
i
+
44
]);
printf
(
"bps:%d
\n
"
,
fourxm
->
tracks
[
current_track
].
bits
);
i
+=
8
+
size
;
/* allocate a new AVStream */
...
...
@@ -192,7 +195,9 @@ static int fourxm_read_header(AVFormatContext *s,
st
->
codec
.
bit_rate
=
st
->
codec
.
channels
*
st
->
codec
.
sample_rate
*
st
->
codec
.
bits_per_sample
;
st
->
codec
.
block_align
=
st
->
codec
.
channels
*
st
->
codec
.
bits_per_sample
;
if
(
st
->
codec
.
bits_per_sample
==
8
)
if
(
fourxm
->
tracks
[
current_track
].
adpcm
)
st
->
codec
.
codec_id
=
CODEC_ID_ADPCM_4XM
;
else
if
(
st
->
codec
.
bits_per_sample
==
8
)
st
->
codec
.
codec_id
=
CODEC_ID_PCM_U8
;
else
st
->
codec
.
codec_id
=
CODEC_ID_PCM_S16LE
;
...
...
@@ -224,7 +229,7 @@ static int fourxm_read_packet(AVFormatContext *s,
FourxmDemuxContext
*
fourxm
=
s
->
priv_data
;
ByteIOContext
*
pb
=
&
s
->
pb
;
unsigned
int
fourcc_tag
;
unsigned
int
size
;
unsigned
int
size
,
out_size
;
int
ret
=
0
;
int
track_number
;
int
packet_read
=
0
;
...
...
@@ -237,10 +242,9 @@ static int fourxm_read_packet(AVFormatContext *s,
return
ret
;
fourcc_tag
=
LE_32
(
&
header
[
0
]);
size
=
LE_32
(
&
header
[
4
]);
//printf(" %8X %c%c%c%c %d\n", fourcc_tag, fourcc_tag, fourcc_tag>>8, fourcc_tag>>16, fourcc_tag>>24, size);
if
(
url_feof
(
pb
))
return
-
EIO
;
switch
(
fourcc_tag
)
{
case
LIST_TAG
:
...
...
@@ -277,7 +281,7 @@ if (fourcc_tag == cfrm_TAG) {
id
=
LE_32
(
&
pkt
->
data
[
12
]);
whole
=
LE_32
(
&
pkt
->
data
[
16
]);
stats
[
id
]
+=
size
-
12
;
printf
(
" cfrm chunk id:%d size:%d whole:%d until now:%d
\n
"
,
id
,
size
,
whole
,
stats
[
id
]);
//
printf(" cfrm chunk id:%d size:%d whole:%d until now:%d\n", id, size, whole, stats[id]);
}
if
(
ret
<
0
)
...
...
@@ -290,7 +294,9 @@ printf(" cfrm chunk id:%d size:%d whole:%d until now:%d\n", id, size, whole, sta
case
snd__TAG
:
printf
(
" snd_ chunk, "
);
track_number
=
get_le32
(
pb
);
size
=
get_le32
(
pb
);
out_size
=
get_le32
(
pb
);
size
-=
8
;
if
(
track_number
==
fourxm
->
selected_track
)
{
printf
(
"correct track, dispatching...
\n
"
);
if
(
av_new_packet
(
pkt
,
size
))
...
...
@@ -321,7 +327,6 @@ printf ("wrong track, skipping...\n");
break
;
}
}
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录