Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
c0279956
Commit
c0279956
authored
12 years ago
by
Anton Khirnov
Browse files
Options
Downloads
Patches
Plain Diff
vf_fade: use the name 's' for the pointer to the private context
This is shorter and consistent across filters.
parent
d3735f7a
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavfilter/vf_fade.c
+28
-28
28 additions, 28 deletions
libavfilter/vf_fade.c
with
28 additions
and
28 deletions
libavfilter/vf_fade.c
+
28
−
28
View file @
c0279956
...
...
@@ -47,21 +47,21 @@ typedef struct {
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
{
FadeContext
*
fade
=
ctx
->
priv
;
fade
->
fade_per_frame
=
(
1
<<
16
)
/
fade
->
nb_frames
;
if
(
fade
->
type
==
FADE_IN
)
{
fade
->
factor
=
0
;
}
else
if
(
fade
->
type
==
FADE_OUT
)
{
fade
->
fade_per_frame
=
-
fade
->
fade_per_frame
;
fade
->
factor
=
(
1
<<
16
);
FadeContext
*
s
=
ctx
->
priv
;
s
->
fade_per_frame
=
(
1
<<
16
)
/
s
->
nb_frames
;
if
(
s
->
type
==
FADE_IN
)
{
s
->
factor
=
0
;
}
else
if
(
s
->
type
==
FADE_OUT
)
{
s
->
fade_per_frame
=
-
s
->
fade_per_frame
;
s
->
factor
=
(
1
<<
16
);
}
fade
->
stop_frame
=
fade
->
start_frame
+
fade
->
nb_frames
;
s
->
stop_frame
=
s
->
start_frame
+
s
->
nb_frames
;
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"type:%s start_frame:%d nb_frames:%d
\n
"
,
fade
->
type
==
FADE_IN
?
"in"
:
"out"
,
fade
->
start_frame
,
fade
->
nb_frames
);
s
->
type
==
FADE_IN
?
"in"
:
"out"
,
s
->
start_frame
,
s
->
nb_frames
);
return
0
;
}
...
...
@@ -82,31 +82,31 @@ static int query_formats(AVFilterContext *ctx)
static
int
config_props
(
AVFilterLink
*
inlink
)
{
FadeContext
*
fade
=
inlink
->
dst
->
priv
;
FadeContext
*
s
=
inlink
->
dst
->
priv
;
const
AVPixFmtDescriptor
*
pixdesc
=
av_pix_fmt_desc_get
(
inlink
->
format
);
fade
->
hsub
=
pixdesc
->
log2_chroma_w
;
fade
->
vsub
=
pixdesc
->
log2_chroma_h
;
s
->
hsub
=
pixdesc
->
log2_chroma_w
;
s
->
vsub
=
pixdesc
->
log2_chroma_h
;
fade
->
bpp
=
av_get_bits_per_pixel
(
pixdesc
)
>>
3
;
s
->
bpp
=
av_get_bits_per_pixel
(
pixdesc
)
>>
3
;
return
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
{
FadeContext
*
fade
=
inlink
->
dst
->
priv
;
FadeContext
*
s
=
inlink
->
dst
->
priv
;
uint8_t
*
p
;
int
i
,
j
,
plane
;
if
(
fade
->
factor
<
UINT16_MAX
)
{
if
(
s
->
factor
<
UINT16_MAX
)
{
/* luma or rgb plane */
for
(
i
=
0
;
i
<
frame
->
height
;
i
++
)
{
p
=
frame
->
data
[
0
]
+
i
*
frame
->
linesize
[
0
];
for
(
j
=
0
;
j
<
inlink
->
w
*
fade
->
bpp
;
j
++
)
{
/*
fade
->factor is using 16 lower-order bits for decimal
for
(
j
=
0
;
j
<
inlink
->
w
*
s
->
bpp
;
j
++
)
{
/*
s
->factor is using 16 lower-order bits for decimal
* places. 32768 = 1 << 15, it is an integer representation
* of 0.5 and is for rounding. */
*
p
=
(
*
p
*
fade
->
factor
+
32768
)
>>
16
;
*
p
=
(
*
p
*
s
->
factor
+
32768
)
>>
16
;
p
++
;
}
}
...
...
@@ -115,12 +115,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
/* chroma planes */
for
(
plane
=
1
;
plane
<
3
;
plane
++
)
{
for
(
i
=
0
;
i
<
frame
->
height
;
i
++
)
{
p
=
frame
->
data
[
plane
]
+
(
i
>>
fade
->
vsub
)
*
frame
->
linesize
[
plane
];
for
(
j
=
0
;
j
<
inlink
->
w
>>
fade
->
hsub
;
j
++
)
{
p
=
frame
->
data
[
plane
]
+
(
i
>>
s
->
vsub
)
*
frame
->
linesize
[
plane
];
for
(
j
=
0
;
j
<
inlink
->
w
>>
s
->
hsub
;
j
++
)
{
/* 8421367 = ((128 << 1) + 1) << 15. It is an integer
* representation of 128.5. The .5 is for rounding
* purposes. */
*
p
=
((
*
p
-
128
)
*
fade
->
factor
+
8421367
)
>>
16
;
*
p
=
((
*
p
-
128
)
*
s
->
factor
+
8421367
)
>>
16
;
p
++
;
}
}
...
...
@@ -128,11 +128,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
}
}
if
(
fade
->
frame_index
>=
fade
->
start_frame
&&
fade
->
frame_index
<=
fade
->
stop_frame
)
fade
->
factor
+=
fade
->
fade_per_frame
;
fade
->
factor
=
av_clip_uint16
(
fade
->
factor
);
fade
->
frame_index
++
;
if
(
s
->
frame_index
>=
s
->
start_frame
&&
s
->
frame_index
<=
s
->
stop_frame
)
s
->
factor
+=
s
->
fade_per_frame
;
s
->
factor
=
av_clip_uint16
(
s
->
factor
);
s
->
frame_index
++
;
return
ff_filter_frame
(
inlink
->
dst
->
outputs
[
0
],
frame
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment