Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
e10fe34e
Commit
e10fe34e
authored
Oct 08, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/f_reverse: add packed sample format support to areverse
parent
3cbf37bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
37 deletions
+87
-37
f_reverse.c
libavfilter/f_reverse.c
+87
-37
No files found.
libavfilter/f_reverse.c
View file @
e10fe34e
...
...
@@ -154,7 +154,7 @@ static int query_formats(AVFilterContext *ctx)
if
(
ret
<
0
)
return
ret
;
ret
=
ff_set_common_formats
(
ctx
,
ff_
planar_sample_fmts
(
));
ret
=
ff_set_common_formats
(
ctx
,
ff_
all_formats
(
AVMEDIA_TYPE_AUDIO
));
if
(
ret
<
0
)
return
ret
;
...
...
@@ -164,11 +164,92 @@ static int query_formats(AVFilterContext *ctx)
return
ff_set_common_samplerates
(
ctx
,
formats
);
}
static
void
reverse_samples_planar
(
AVFrame
*
out
)
{
for
(
int
p
=
0
;
p
<
out
->
channels
;
p
++
)
{
switch
(
out
->
format
)
{
case
AV_SAMPLE_FMT_U8P
:
{
uint8_t
*
dst
=
(
uint8_t
*
)
out
->
extended_data
[
p
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
uint8_t
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_S16P
:
{
int16_t
*
dst
=
(
int16_t
*
)
out
->
extended_data
[
p
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
int16_t
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_S32P
:
{
int32_t
*
dst
=
(
int32_t
*
)
out
->
extended_data
[
p
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
int32_t
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_FLTP
:
{
float
*
dst
=
(
float
*
)
out
->
extended_data
[
p
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
float
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_DBLP
:
{
double
*
dst
=
(
double
*
)
out
->
extended_data
[
p
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
double
,
dst
[
i
],
dst
[
j
]);
}
break
;
}
}
}
static
void
reverse_samples_packed
(
AVFrame
*
out
)
{
const
int
channels
=
out
->
channels
;
switch
(
out
->
format
)
{
case
AV_SAMPLE_FMT_U8
:
{
uint8_t
*
dst
=
(
uint8_t
*
)
out
->
extended_data
[
0
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
for
(
int
p
=
0
;
p
<
channels
;
p
++
)
FFSWAP
(
uint8_t
,
dst
[
i
*
channels
+
p
],
dst
[
j
*
channels
+
p
]);
}
break
;
case
AV_SAMPLE_FMT_S16
:
{
int16_t
*
dst
=
(
int16_t
*
)
out
->
extended_data
[
0
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
for
(
int
p
=
0
;
p
<
channels
;
p
++
)
FFSWAP
(
int16_t
,
dst
[
i
*
channels
+
p
],
dst
[
j
*
channels
+
p
]);
}
break
;
case
AV_SAMPLE_FMT_S32
:
{
int32_t
*
dst
=
(
int32_t
*
)
out
->
extended_data
[
0
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
for
(
int
p
=
0
;
p
<
channels
;
p
++
)
FFSWAP
(
int32_t
,
dst
[
i
*
channels
+
p
],
dst
[
j
*
channels
+
p
]);
}
break
;
case
AV_SAMPLE_FMT_FLT
:
{
float
*
dst
=
(
float
*
)
out
->
extended_data
[
0
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
for
(
int
p
=
0
;
p
<
channels
;
p
++
)
FFSWAP
(
float
,
dst
[
i
*
channels
+
p
],
dst
[
j
*
channels
+
p
]);
}
break
;
case
AV_SAMPLE_FMT_DBL
:
{
double
*
dst
=
(
double
*
)
out
->
extended_data
[
0
];
for
(
int
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
for
(
int
p
=
0
;
p
<
channels
;
p
++
)
FFSWAP
(
double
,
dst
[
i
*
channels
+
p
],
dst
[
j
*
channels
+
p
]);
}
break
;
}
}
static
int
areverse_request_frame
(
AVFilterLink
*
outlink
)
{
AVFilterContext
*
ctx
=
outlink
->
src
;
ReverseContext
*
s
=
ctx
->
priv
;
int
ret
,
p
,
i
,
j
;
int
ret
;
ret
=
ff_request_frame
(
ctx
->
inputs
[
0
]);
...
...
@@ -176,41 +257,10 @@ static int areverse_request_frame(AVFilterLink *outlink)
AVFrame
*
out
=
s
->
frames
[
s
->
nb_frames
-
1
];
out
->
pts
=
s
->
pts
[
s
->
flush_idx
++
];
for
(
p
=
0
;
p
<
outlink
->
channels
;
p
++
)
{
switch
(
outlink
->
format
)
{
case
AV_SAMPLE_FMT_U8P
:
{
uint8_t
*
dst
=
(
uint8_t
*
)
out
->
extended_data
[
p
];
for
(
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
uint8_t
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_S16P
:
{
int16_t
*
dst
=
(
int16_t
*
)
out
->
extended_data
[
p
];
for
(
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
int16_t
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_S32P
:
{
int32_t
*
dst
=
(
int32_t
*
)
out
->
extended_data
[
p
];
for
(
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
int32_t
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_FLTP
:
{
float
*
dst
=
(
float
*
)
out
->
extended_data
[
p
];
for
(
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
float
,
dst
[
i
],
dst
[
j
]);
}
break
;
case
AV_SAMPLE_FMT_DBLP
:
{
double
*
dst
=
(
double
*
)
out
->
extended_data
[
p
];
for
(
i
=
0
,
j
=
out
->
nb_samples
-
1
;
i
<
j
;
i
++
,
j
--
)
FFSWAP
(
double
,
dst
[
i
],
dst
[
j
]);
}
break
;
}
}
if
(
av_sample_fmt_is_planar
(
out
->
format
))
reverse_samples_planar
(
out
);
else
reverse_samples_packed
(
out
);
ret
=
ff_filter_frame
(
outlink
,
out
);
s
->
nb_frames
--
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment