Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
1b4f17fa
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,发现更多精彩内容 >>
提交
1b4f17fa
编写于
8月 28, 2006
作者:
M
Michael Niedermayer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix buffer handling
Originally committed as revision 6116 to
svn://svn.ffmpeg.org/ffmpeg/trunk
上级
00b2fa86
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
14 deletion
+23
-14
libavcodec/mpegaudiodec.c
libavcodec/mpegaudiodec.c
+23
-14
未找到文件。
libavcodec/mpegaudiodec.c
浏览文件 @
1b4f17fa
...
...
@@ -90,7 +90,7 @@ static always_inline int MULH(int a, int b){
struct
GranuleDef
;
typedef
struct
MPADecodeContext
{
DECLARE_ALIGNED_8
(
uint8_t
,
last_buf
[
BACKSTEP_SIZE
+
EXTRABYTES
+
MPA_MAX_CODED_FRAME_SIZE
]);
//FIXME we dont need that much
DECLARE_ALIGNED_8
(
uint8_t
,
last_buf
[
2
*
BACKSTEP_SIZE
+
EXTRABYTES
]);
int
last_buf_size
;
int
frame_size
;
int
free_format_frame_size
;
/* frame size in case of free format
...
...
@@ -1688,6 +1688,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
s
->
in_gb
.
buffer
=
NULL
;
assert
((
get_bits_count
(
&
s
->
gb
)
&
7
)
==
0
);
skip_bits_long
(
&
s
->
gb
,
pos
-
end_pos
);
end_pos2
=
end_pos
=
end_pos2
+
get_bits_count
(
&
s
->
gb
)
-
pos
;
pos
=
get_bits_count
(
&
s
->
gb
);
}
...
...
@@ -1756,23 +1757,25 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
int
pos
,
code
;
pos
=
get_bits_count
(
&
s
->
gb
);
if
(
pos
>=
end_pos
)
{
if
(
pos
>
end_pos2
&&
last_pos
){
/* some encoders generate an incorrect size for this
part. We must go back into the data */
s_index
-=
4
;
skip_bits_long
(
&
s
->
gb
,
last_pos
-
pos
);
av_log
(
NULL
,
AV_LOG_INFO
,
"overread, skip %d enddists: %d %d
\n
"
,
last_pos
-
pos
,
end_pos
-
pos
,
end_pos2
-
pos
);
break
;
}
// av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index);
if
(
s
->
in_gb
.
buffer
&&
pos
>=
s
->
gb
.
size_in_bits
){
s
->
gb
=
s
->
in_gb
;
s
->
in_gb
.
buffer
=
NULL
;
assert
((
get_bits_count
(
&
s
->
gb
)
&
7
)
==
0
);
skip_bits_long
(
&
s
->
gb
,
pos
-
end_pos
);
end_pos2
=
end_pos
=
end_pos2
+
get_bits_count
(
&
s
->
gb
)
-
pos
;
pos
=
get_bits_count
(
&
s
->
gb
);
}
// av_log(NULL, AV_LOG_ERROR, "new pos2: %d %d %d\n", pos, end_pos, s_index);
if
(
pos
>
end_pos
&&
last_pos
){
//FIXME last_pos is messed if we switch buffers
/* some encoders generate an incorrect size for this
part. We must go back into the data */
s_index
-=
4
;
skip_bits_long
(
&
s
->
gb
,
last_pos
-
pos
);
av_log
(
NULL
,
AV_LOG_DEBUG
,
"overread, skip %d
\n
"
,
last_pos
-
pos
);
}
if
(
pos
>=
end_pos
)
break
;
}
...
...
@@ -2318,11 +2321,14 @@ static int mp_decode_layer3(MPADecodeContext *s)
if
(
!
s
->
adu_mode
)
{
const
uint8_t
*
ptr
=
s
->
gb
.
buffer
+
(
get_bits_count
(
&
s
->
gb
)
>>
3
);
assert
((
get_bits_count
(
&
s
->
gb
)
&
7
)
==
0
);
/* now we get bits from the main_data_begin offset */
dprintf
(
"seekback: %d
\n
"
,
main_data_begin
);
//av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size);
if
(
main_data_begin
>
s
->
last_buf_size
)
if
(
main_data_begin
>
s
->
last_buf_size
){
av_log
(
NULL
,
AV_LOG_ERROR
,
"backstep:%d, lastbuf:%d
\n
"
,
main_data_begin
,
s
->
last_buf_size
);
s
->
last_buf_size
=
main_data_begin
;
}
memcpy
(
s
->
last_buf
+
s
->
last_buf_size
,
ptr
,
EXTRABYTES
);
s
->
in_gb
=
s
->
gb
;
...
...
@@ -2521,10 +2527,11 @@ static int mp_decode_frame(MPADecodeContext *s,
if
(
s
->
in_gb
.
buffer
){
align_get_bits
(
&
s
->
gb
);
i
=
(
s
->
gb
.
size_in_bits
-
get_bits_count
(
&
s
->
gb
))
>>
3
;
if
(
i
>
0
&&
i
<=
BACKSTEP_SIZE
){
if
(
i
>
=
0
&&
i
<=
BACKSTEP_SIZE
){
memmove
(
s
->
last_buf
,
s
->
gb
.
buffer
+
(
get_bits_count
(
&
s
->
gb
)
>>
3
),
i
);
s
->
last_buf_size
=
i
;
}
}
else
av_log
(
NULL
,
AV_LOG_ERROR
,
"invalid old backstep %d
\n
"
,
i
);
s
->
gb
=
s
->
in_gb
;
}
...
...
@@ -2532,10 +2539,12 @@ static int mp_decode_frame(MPADecodeContext *s,
assert
((
get_bits_count
(
&
s
->
gb
)
&
7
)
==
0
);
i
=
(
s
->
gb
.
size_in_bits
-
get_bits_count
(
&
s
->
gb
))
>>
3
;
if
(
i
<
0
||
s
->
last_buf_size
+
i
>
BACKSTEP_SIZE
||
nb_frames
<
0
)
i
=
FFMIN
(
BACKSTEP_SIZE
-
s
->
last_buf_size
,
buf_size
-
HEADER_SIZE
);
if
(
i
<
0
||
i
>
BACKSTEP_SIZE
||
nb_frames
<
0
){
av_log
(
NULL
,
AV_LOG_ERROR
,
"invalid new backstep %d
\n
"
,
i
);
i
=
FFMIN
(
BACKSTEP_SIZE
,
buf_size
-
HEADER_SIZE
);
}
assert
(
i
<=
buf_size
-
HEADER_SIZE
&&
i
>=
0
);
memcpy
(
s
->
last_buf
+
s
->
last_buf_size
,
s
->
gb
.
buffer
+
buf_size
-
HEADER_SIZE
-
i
,
i
);
memcpy
(
s
->
last_buf
+
s
->
last_buf_size
,
s
->
gb
.
buffer
+
buf_size
-
HEADER_SIZE
-
i
,
i
);
s
->
last_buf_size
+=
i
;
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录