Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
6a6bc43f
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,发现更多精彩内容 >>
提交
6a6bc43f
编写于
9月 03, 2015
作者:
L
Luca Barbato
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dxtory: Factorize slice size checks
They are always the same.
上级
db9fd1e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
76 deletion
+48
-76
libavcodec/dxtory.c
libavcodec/dxtory.c
+48
-76
未找到文件。
libavcodec/dxtory.c
浏览文件 @
6a6bc43f
...
...
@@ -192,6 +192,34 @@ static inline uint8_t decode_sym(GetBitContext *gb, uint8_t lru[8])
return
val
;
}
static
int
check_slice_size
(
AVCodecContext
*
avctx
,
const
uint8_t
*
src
,
int
src_size
,
int
slice_size
,
int
off
)
{
int
cur_slice_size
;
if
(
slice_size
>
src_size
-
off
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
" (only %"
PRIu32
" bytes left)
\n
"
,
slice_size
,
src_size
-
off
);
return
AVERROR_INVALIDDATA
;
}
if
(
slice_size
<=
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
"
\n
"
,
slice_size
);
return
AVERROR_INVALIDDATA
;
}
cur_slice_size
=
AV_RL32
(
src
+
off
);
if
(
cur_slice_size
!=
slice_size
-
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Slice sizes mismatch: got %"
PRIu32
" instead of %"
PRIu32
"
\n
"
,
cur_slice_size
,
slice_size
-
16
);
}
return
0
;
}
static
inline
uint8_t
decode_sym_565
(
GetBitContext
*
gb
,
uint8_t
lru
[
8
],
int
bits
)
{
...
...
@@ -269,22 +297,11 @@ static int dxtory_decode_v2_565(AVCodecContext *avctx, AVFrame *pic,
dst
=
pic
->
data
[
0
];
for
(
slice
=
0
;
slice
<
nslices
;
slice
++
)
{
slice_size
=
bytestream2_get_le32
(
&
gb
);
if
(
slice_size
>
src_size
-
off
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
" (only %"
PRIu32
" bytes left)
\n
"
,
slice_size
,
src_size
-
off
);
return
AVERROR_INVALIDDATA
;
}
if
(
slice_size
<=
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
"
\n
"
,
slice_size
);
return
AVERROR_INVALIDDATA
;
}
if
(
AV_RL32
(
src
+
off
)
!=
slice_size
-
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Slice sizes mismatch: got %"
PRIu32
" instead of %"
PRIu32
"
\n
"
,
AV_RL32
(
src
+
off
),
slice_size
-
16
);
}
ret
=
check_slice_size
(
avctx
,
src
,
src_size
,
slice_size
,
off
);
if
(
ret
<
0
)
return
ret
;
init_get_bits
(
&
gb2
,
src
+
off
+
16
,
(
slice_size
-
16
)
*
8
);
dx2_decode_slice_565
(
&
gb2
,
avctx
->
width
,
slice_height
,
dst
,
pic
->
linesize
[
0
],
is_565
);
...
...
@@ -350,23 +367,11 @@ static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic,
dst
=
pic
->
data
[
0
];
for
(
slice
=
0
;
slice
<
nslices
;
slice
++
)
{
slice_size
=
bytestream2_get_le32
(
&
gb
);
if
(
slice_size
>
src_size
-
off
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
" (only %"
PRIu32
" bytes left)
\n
"
,
slice_size
,
src_size
-
off
);
return
AVERROR_INVALIDDATA
;
}
if
(
slice_size
<=
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
"
\n
"
,
slice_size
);
return
AVERROR_INVALIDDATA
;
}
if
(
AV_RL32
(
src
+
off
)
!=
slice_size
-
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Slice sizes mismatch: got %"
PRIu32
" instead of %"
PRIu32
"
\n
"
,
AV_RL32
(
src
+
off
),
slice_size
-
16
);
}
ret
=
check_slice_size
(
avctx
,
src
,
src_size
,
slice_size
,
off
);
if
(
ret
<
0
)
return
ret
;
init_get_bits
(
&
gb2
,
src
+
off
+
16
,
(
slice_size
-
16
)
*
8
);
dx2_decode_slice_rgb
(
&
gb2
,
avctx
->
width
,
slice_height
,
dst
,
pic
->
linesize
[
0
]);
...
...
@@ -449,22 +454,11 @@ static int dxtory_decode_v2_410(AVCodecContext *avctx, AVFrame *pic,
for
(
slice
=
0
;
slice
<
nslices
;
slice
++
)
{
slice_size
=
bytestream2_get_le32
(
&
gb
);
slice_height
=
(
next_y
&
~
3
)
-
(
cur_y
&
~
3
);
if
(
slice_size
>
src_size
-
off
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
" (only %"
PRIu32
" bytes left)
\n
"
,
slice_size
,
src_size
-
off
);
return
AVERROR_INVALIDDATA
;
}
if
(
slice_size
<=
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
"
\n
"
,
slice_size
);
return
AVERROR_INVALIDDATA
;
}
if
(
AV_RL32
(
src
+
off
)
!=
slice_size
-
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Slice sizes mismatch: got %"
PRIu32
" instead of %"
PRIu32
"
\n
"
,
AV_RL32
(
src
+
off
),
slice_size
-
16
);
}
ret
=
check_slice_size
(
avctx
,
src
,
src_size
,
slice_size
,
off
);
if
(
ret
<
0
)
return
ret
;
init_get_bits
(
&
gb2
,
src
+
off
+
16
,
(
slice_size
-
16
)
*
8
);
dx2_decode_slice_410
(
&
gb2
,
avctx
->
width
,
slice_height
,
Y
,
U
,
V
,
pic
->
linesize
[
0
],
pic
->
linesize
[
1
],
...
...
@@ -553,22 +547,11 @@ static int dxtory_decode_v2_420(AVCodecContext *avctx, AVFrame *pic,
for
(
slice
=
0
;
slice
<
nslices
;
slice
++
)
{
slice_size
=
bytestream2_get_le32
(
&
gb
);
slice_height
=
(
next_y
&
~
1
)
-
(
cur_y
&
~
1
);
if
(
slice_size
>
src_size
-
off
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
" (only %"
PRIu32
" bytes left)
\n
"
,
slice_size
,
src_size
-
off
);
return
AVERROR_INVALIDDATA
;
}
if
(
slice_size
<=
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
"
\n
"
,
slice_size
);
return
AVERROR_INVALIDDATA
;
}
if
(
AV_RL32
(
src
+
off
)
!=
slice_size
-
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Slice sizes mismatch: got %"
PRIu32
" instead of %"
PRIu32
"
\n
"
,
AV_RL32
(
src
+
off
),
slice_size
-
16
);
}
ret
=
check_slice_size
(
avctx
,
src
,
src_size
,
slice_size
,
off
);
if
(
ret
<
0
)
return
ret
;
init_get_bits
(
&
gb2
,
src
+
off
+
16
,
(
slice_size
-
16
)
*
8
);
dx2_decode_slice_420
(
&
gb2
,
avctx
->
width
,
slice_height
,
Y
,
U
,
V
,
pic
->
linesize
[
0
],
pic
->
linesize
[
1
],
...
...
@@ -646,22 +629,11 @@ static int dxtory_decode_v2_444(AVCodecContext *avctx, AVFrame *pic,
for
(
slice
=
0
;
slice
<
nslices
;
slice
++
)
{
slice_size
=
bytestream2_get_le32
(
&
gb
);
if
(
slice_size
>
src_size
-
off
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
" (only %"
PRIu32
" bytes left)
\n
"
,
slice_size
,
src_size
-
off
);
return
AVERROR_INVALIDDATA
;
}
if
(
slice_size
<=
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"invalid slice size %"
PRIu32
"
\n
"
,
slice_size
);
return
AVERROR_INVALIDDATA
;
}
if
(
AV_RL32
(
src
+
off
)
!=
slice_size
-
16
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Slice sizes mismatch: got %"
PRIu32
" instead of %"
PRIu32
"
\n
"
,
AV_RL32
(
src
+
off
),
slice_size
-
16
);
}
ret
=
check_slice_size
(
avctx
,
src
,
src_size
,
slice_size
,
off
);
if
(
ret
<
0
)
return
ret
;
init_get_bits
(
&
gb2
,
src
+
off
+
16
,
(
slice_size
-
16
)
*
8
);
dx2_decode_slice_444
(
&
gb2
,
avctx
->
width
,
slice_height
,
Y
,
U
,
V
,
pic
->
linesize
[
0
],
pic
->
linesize
[
1
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录