Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
0f711126
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,发现更多精彩内容 >>
提交
0f711126
编写于
8月 28, 2015
作者:
G
Ganesh Ajjanagadde
提交者:
Paul B Mahol
9月 15, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avfilter/vsrc_cellauto: use the name 's' for the pointer to the private context
Signed-off-by:
N
Ganesh Ajjanagadde
<
gajjanagadde@gmail.com
>
上级
a62d4a01
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
75 deletion
+75
-75
libavfilter/vsrc_cellauto.c
libavfilter/vsrc_cellauto.c
+75
-75
未找到文件。
libavfilter/vsrc_cellauto.c
浏览文件 @
0f711126
...
...
@@ -86,55 +86,55 @@ AVFILTER_DEFINE_CLASS(cellauto);
#ifdef DEBUG
static
void
show_cellauto_row
(
AVFilterContext
*
ctx
)
{
CellAutoContext
*
cellauto
=
ctx
->
priv
;
CellAutoContext
*
s
=
ctx
->
priv
;
int
i
;
uint8_t
*
row
=
cellauto
->
buf
+
cellauto
->
w
*
cellauto
->
buf_row_idx
;
char
*
line
=
av_malloc
(
cellauto
->
w
+
1
);
uint8_t
*
row
=
s
->
buf
+
s
->
w
*
s
->
buf_row_idx
;
char
*
line
=
av_malloc
(
s
->
w
+
1
);
if
(
!
line
)
return
;
for
(
i
=
0
;
i
<
cellauto
->
w
;
i
++
)
for
(
i
=
0
;
i
<
s
->
w
;
i
++
)
line
[
i
]
=
row
[
i
]
?
'@'
:
' '
;
line
[
i
]
=
0
;
av_log
(
ctx
,
AV_LOG_DEBUG
,
"generation:%"
PRId64
" row:%s|
\n
"
,
cellauto
->
generation
,
line
);
av_log
(
ctx
,
AV_LOG_DEBUG
,
"generation:%"
PRId64
" row:%s|
\n
"
,
s
->
generation
,
line
);
av_free
(
line
);
}
#endif
static
int
init_pattern_from_string
(
AVFilterContext
*
ctx
)
{
CellAutoContext
*
cellauto
=
ctx
->
priv
;
CellAutoContext
*
s
=
ctx
->
priv
;
char
*
p
;
int
i
,
w
=
0
;
w
=
strlen
(
cellauto
->
pattern
);
w
=
strlen
(
s
->
pattern
);
av_log
(
ctx
,
AV_LOG_DEBUG
,
"w:%d
\n
"
,
w
);
if
(
cellauto
->
w
)
{
if
(
w
>
cellauto
->
w
)
{
if
(
s
->
w
)
{
if
(
w
>
s
->
w
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"The specified width is %d which cannot contain the provided string width of %d
\n
"
,
cellauto
->
w
,
w
);
s
->
w
,
w
);
return
AVERROR
(
EINVAL
);
}
}
else
{
/* width was not specified, set it to width of the provided row */
cellauto
->
w
=
w
;
cellauto
->
h
=
(
double
)
cellauto
->
w
*
M_PHI
;
s
->
w
=
w
;
s
->
h
=
(
double
)
s
->
w
*
M_PHI
;
}
cellauto
->
buf
=
av_mallocz_array
(
sizeof
(
uint8_t
)
*
cellauto
->
w
,
cellauto
->
h
);
if
(
!
cellauto
->
buf
)
s
->
buf
=
av_mallocz_array
(
sizeof
(
uint8_t
)
*
s
->
w
,
s
->
h
);
if
(
!
s
->
buf
)
return
AVERROR
(
ENOMEM
);
/* fill buf */
p
=
cellauto
->
pattern
;
for
(
i
=
(
cellauto
->
w
-
w
)
/
2
;;
i
++
)
{
p
=
s
->
pattern
;
for
(
i
=
(
s
->
w
-
w
)
/
2
;;
i
++
)
{
av_log
(
ctx
,
AV_LOG_DEBUG
,
"%d %c
\n
"
,
i
,
*
p
==
'\n'
?
'N'
:
*
p
);
if
(
*
p
==
'\n'
||
!*
p
)
break
;
else
cellauto
->
buf
[
i
]
=
!!
av_isgraph
(
*
(
p
++
));
s
->
buf
[
i
]
=
!!
av_isgraph
(
*
(
p
++
));
}
return
0
;
...
...
@@ -142,165 +142,165 @@ static int init_pattern_from_string(AVFilterContext *ctx)
static
int
init_pattern_from_file
(
AVFilterContext
*
ctx
)
{
CellAutoContext
*
cellauto
=
ctx
->
priv
;
CellAutoContext
*
s
=
ctx
->
priv
;
int
ret
;
ret
=
av_file_map
(
cellauto
->
filename
,
&
cellauto
->
file_buf
,
&
cellauto
->
file_bufsize
,
0
,
ctx
);
ret
=
av_file_map
(
s
->
filename
,
&
s
->
file_buf
,
&
s
->
file_bufsize
,
0
,
ctx
);
if
(
ret
<
0
)
return
ret
;
/* create a string based on the read file */
cellauto
->
pattern
=
av_malloc
(
cellauto
->
file_bufsize
+
1
);
if
(
!
cellauto
->
pattern
)
s
->
pattern
=
av_malloc
(
s
->
file_bufsize
+
1
);
if
(
!
s
->
pattern
)
return
AVERROR
(
ENOMEM
);
memcpy
(
cellauto
->
pattern
,
cellauto
->
file_buf
,
cellauto
->
file_bufsize
);
cellauto
->
pattern
[
cellauto
->
file_bufsize
]
=
0
;
memcpy
(
s
->
pattern
,
s
->
file_buf
,
s
->
file_bufsize
);
s
->
pattern
[
s
->
file_bufsize
]
=
0
;
return
init_pattern_from_string
(
ctx
);
}
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
{
CellAutoContext
*
cellauto
=
ctx
->
priv
;
CellAutoContext
*
s
=
ctx
->
priv
;
int
ret
;
if
(
!
cellauto
->
w
&&
!
cellauto
->
filename
&&
!
cellauto
->
pattern
)
av_opt_set
(
cellauto
,
"size"
,
"320x518"
,
0
);
if
(
!
s
->
w
&&
!
s
->
filename
&&
!
s
->
pattern
)
av_opt_set
(
s
,
"size"
,
"320x518"
,
0
);
if
(
cellauto
->
filename
&&
cellauto
->
pattern
)
{
if
(
s
->
filename
&&
s
->
pattern
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Only one of the filename or pattern options can be used
\n
"
);
return
AVERROR
(
EINVAL
);
}
if
(
cellauto
->
filename
)
{
if
(
s
->
filename
)
{
if
((
ret
=
init_pattern_from_file
(
ctx
))
<
0
)
return
ret
;
}
else
if
(
cellauto
->
pattern
)
{
}
else
if
(
s
->
pattern
)
{
if
((
ret
=
init_pattern_from_string
(
ctx
))
<
0
)
return
ret
;
}
else
{
/* fill the first row randomly */
int
i
;
cellauto
->
buf
=
av_mallocz_array
(
sizeof
(
uint8_t
)
*
cellauto
->
w
,
cellauto
->
h
);
if
(
!
cellauto
->
buf
)
s
->
buf
=
av_mallocz_array
(
sizeof
(
uint8_t
)
*
s
->
w
,
s
->
h
);
if
(
!
s
->
buf
)
return
AVERROR
(
ENOMEM
);
if
(
cellauto
->
random_seed
==
-
1
)
cellauto
->
random_seed
=
av_get_random_seed
();
if
(
s
->
random_seed
==
-
1
)
s
->
random_seed
=
av_get_random_seed
();
av_lfg_init
(
&
cellauto
->
lfg
,
cellauto
->
random_seed
);
av_lfg_init
(
&
s
->
lfg
,
s
->
random_seed
);
for
(
i
=
0
;
i
<
cellauto
->
w
;
i
++
)
{
double
r
=
(
double
)
av_lfg_get
(
&
cellauto
->
lfg
)
/
UINT32_MAX
;
if
(
r
<=
cellauto
->
random_fill_ratio
)
cellauto
->
buf
[
i
]
=
1
;
for
(
i
=
0
;
i
<
s
->
w
;
i
++
)
{
double
r
=
(
double
)
av_lfg_get
(
&
s
->
lfg
)
/
UINT32_MAX
;
if
(
r
<=
s
->
random_fill_ratio
)
s
->
buf
[
i
]
=
1
;
}
}
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d seed:%u
\n
"
,
cellauto
->
w
,
cellauto
->
h
,
cellauto
->
frame_rate
.
num
,
cellauto
->
frame_rate
.
den
,
cellauto
->
rule
,
cellauto
->
stitch
,
cellauto
->
scroll
,
cellauto
->
start_full
,
cellauto
->
random_seed
);
s
->
w
,
s
->
h
,
s
->
frame_rate
.
num
,
s
->
frame_rate
.
den
,
s
->
rule
,
s
->
stitch
,
s
->
scroll
,
s
->
start_full
,
s
->
random_seed
);
return
0
;
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
CellAutoContext
*
cellauto
=
ctx
->
priv
;
CellAutoContext
*
s
=
ctx
->
priv
;
av_file_unmap
(
cellauto
->
file_buf
,
cellauto
->
file_bufsize
);
av_freep
(
&
cellauto
->
buf
);
av_freep
(
&
cellauto
->
pattern
);
av_file_unmap
(
s
->
file_buf
,
s
->
file_bufsize
);
av_freep
(
&
s
->
buf
);
av_freep
(
&
s
->
pattern
);
}
static
int
config_props
(
AVFilterLink
*
outlink
)
{
CellAutoContext
*
cellauto
=
outlink
->
src
->
priv
;
CellAutoContext
*
s
=
outlink
->
src
->
priv
;
outlink
->
w
=
cellauto
->
w
;
outlink
->
h
=
cellauto
->
h
;
outlink
->
time_base
=
av_inv_q
(
cellauto
->
frame_rate
);
outlink
->
w
=
s
->
w
;
outlink
->
h
=
s
->
h
;
outlink
->
time_base
=
av_inv_q
(
s
->
frame_rate
);
return
0
;
}
static
void
evolve
(
AVFilterContext
*
ctx
)
{
CellAutoContext
*
cellauto
=
ctx
->
priv
;
CellAutoContext
*
s
=
ctx
->
priv
;
int
i
,
v
,
pos
[
3
];
uint8_t
*
row
,
*
prev_row
=
cellauto
->
buf
+
cellauto
->
buf_row_idx
*
cellauto
->
w
;
uint8_t
*
row
,
*
prev_row
=
s
->
buf
+
s
->
buf_row_idx
*
s
->
w
;
enum
{
NW
,
N
,
NE
};
cellauto
->
buf_prev_row_idx
=
cellauto
->
buf_row_idx
;
cellauto
->
buf_row_idx
=
cellauto
->
buf_row_idx
==
cellauto
->
h
-
1
?
0
:
cellauto
->
buf_row_idx
+
1
;
row
=
cellauto
->
buf
+
cellauto
->
w
*
cellauto
->
buf_row_idx
;
s
->
buf_prev_row_idx
=
s
->
buf_row_idx
;
s
->
buf_row_idx
=
s
->
buf_row_idx
==
s
->
h
-
1
?
0
:
s
->
buf_row_idx
+
1
;
row
=
s
->
buf
+
s
->
w
*
s
->
buf_row_idx
;
for
(
i
=
0
;
i
<
cellauto
->
w
;
i
++
)
{
if
(
cellauto
->
stitch
)
{
pos
[
NW
]
=
i
-
1
<
0
?
cellauto
->
w
-
1
:
i
-
1
;
for
(
i
=
0
;
i
<
s
->
w
;
i
++
)
{
if
(
s
->
stitch
)
{
pos
[
NW
]
=
i
-
1
<
0
?
s
->
w
-
1
:
i
-
1
;
pos
[
N
]
=
i
;
pos
[
NE
]
=
i
+
1
==
cellauto
->
w
?
0
:
i
+
1
;
pos
[
NE
]
=
i
+
1
==
s
->
w
?
0
:
i
+
1
;
v
=
prev_row
[
pos
[
NW
]]
<<
2
|
prev_row
[
pos
[
N
]]
<<
1
|
prev_row
[
pos
[
NE
]];
}
else
{
v
=
0
;
v
|=
i
-
1
>=
0
?
prev_row
[
i
-
1
]
<<
2
:
0
;
v
|=
prev_row
[
i
]
<<
1
;
v
|=
i
+
1
<
cellauto
->
w
?
prev_row
[
i
+
1
]
:
0
;
v
|=
i
+
1
<
s
->
w
?
prev_row
[
i
+
1
]
:
0
;
}
row
[
i
]
=
!!
(
cellauto
->
rule
&
(
1
<<
v
));
row
[
i
]
=
!!
(
s
->
rule
&
(
1
<<
v
));
ff_dlog
(
ctx
,
"i:%d context:%c%c%c -> cell:%d
\n
"
,
i
,
v
&
4
?
'@'
:
' '
,
v
&
2
?
'@'
:
' '
,
v
&
1
?
'@'
:
' '
,
row
[
i
]);
}
cellauto
->
generation
++
;
s
->
generation
++
;
}
static
void
fill_picture
(
AVFilterContext
*
ctx
,
AVFrame
*
picref
)
{
CellAutoContext
*
cellauto
=
ctx
->
priv
;
CellAutoContext
*
s
=
ctx
->
priv
;
int
i
,
j
,
k
,
row_idx
=
0
;
uint8_t
*
p0
=
picref
->
data
[
0
];
if
(
cellauto
->
scroll
&&
cellauto
->
generation
>=
cellauto
->
h
)
if
(
s
->
scroll
&&
s
->
generation
>=
s
->
h
)
/* show on top the oldest row */
row_idx
=
(
cellauto
->
buf_row_idx
+
1
)
%
cellauto
->
h
;
row_idx
=
(
s
->
buf_row_idx
+
1
)
%
s
->
h
;
/* fill the output picture with the whole buffer */
for
(
i
=
0
;
i
<
cellauto
->
h
;
i
++
)
{
for
(
i
=
0
;
i
<
s
->
h
;
i
++
)
{
uint8_t
byte
=
0
;
uint8_t
*
row
=
cellauto
->
buf
+
row_idx
*
cellauto
->
w
;
uint8_t
*
row
=
s
->
buf
+
row_idx
*
s
->
w
;
uint8_t
*
p
=
p0
;
for
(
k
=
0
,
j
=
0
;
j
<
cellauto
->
w
;
j
++
)
{
for
(
k
=
0
,
j
=
0
;
j
<
s
->
w
;
j
++
)
{
byte
|=
row
[
j
]
<<
(
7
-
k
++
);
if
(
k
==
8
||
j
==
cellauto
->
w
-
1
)
{
if
(
k
==
8
||
j
==
s
->
w
-
1
)
{
k
=
0
;
*
p
++
=
byte
;
byte
=
0
;
}
}
row_idx
=
(
row_idx
+
1
)
%
cellauto
->
h
;
row_idx
=
(
row_idx
+
1
)
%
s
->
h
;
p0
+=
picref
->
linesize
[
0
];
}
}
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
CellAutoContext
*
cellauto
=
outlink
->
src
->
priv
;
AVFrame
*
picref
=
ff_get_video_buffer
(
outlink
,
cellauto
->
w
,
cellauto
->
h
);
CellAutoContext
*
s
=
outlink
->
src
->
priv
;
AVFrame
*
picref
=
ff_get_video_buffer
(
outlink
,
s
->
w
,
s
->
h
);
if
(
!
picref
)
return
AVERROR
(
ENOMEM
);
picref
->
sample_aspect_ratio
=
(
AVRational
)
{
1
,
1
};
if
(
cellauto
->
generation
==
0
&&
cellauto
->
start_full
)
{
if
(
s
->
generation
==
0
&&
s
->
start_full
)
{
int
i
;
for
(
i
=
0
;
i
<
cellauto
->
h
-
1
;
i
++
)
for
(
i
=
0
;
i
<
s
->
h
-
1
;
i
++
)
evolve
(
outlink
->
src
);
}
fill_picture
(
outlink
->
src
,
picref
);
evolve
(
outlink
->
src
);
picref
->
pts
=
cellauto
->
pts
++
;
picref
->
pts
=
s
->
pts
++
;
#ifdef DEBUG
show_cellauto_row
(
outlink
->
src
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录