Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
f8a237a3
Commit
f8a237a3
authored
Apr 11, 2012
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swr: add triangular highpass dither
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
1fc4ff22
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
dither.c
libswresample/dither.c
+22
-1
swresample.c
libswresample/swresample.c
+1
-0
swresample.h
libswresample/swresample.h
+1
-0
No files found.
libswresample/dither.c
View file @
f8a237a3
...
...
@@ -23,6 +23,8 @@
void
swri_get_dither
(
void
*
dst
,
int
len
,
unsigned
seed
,
enum
AVSampleFormat
out_fmt
,
enum
AVSampleFormat
in_fmt
,
enum
SwrDitherType
method
)
{
double
scale
=
0
;
#define TMP_EXTRA 2
double
*
tmp
=
av_malloc
((
len
+
TMP_EXTRA
)
*
sizeof
(
double
));
int
i
;
if
(
in_fmt
==
AV_SAMPLE_FMT_FLT
||
in_fmt
==
AV_SAMPLE_FMT_DBL
){
...
...
@@ -34,19 +36,36 @@ void swri_get_dither(void *dst, int len, unsigned seed, enum AVSampleFormat out_
if
(
in_fmt
==
AV_SAMPLE_FMT_S32
&&
out_fmt
==
AV_SAMPLE_FMT_U8
)
scale
=
1L
<<
24
;
if
(
in_fmt
==
AV_SAMPLE_FMT_S16
&&
out_fmt
==
AV_SAMPLE_FMT_U8
)
scale
=
1L
<<
8
;
for
(
i
=
0
;
i
<
len
;
i
++
){
for
(
i
=
0
;
i
<
len
+
TMP_EXTRA
;
i
++
){
double
v
;
seed
=
seed
*
1664525
+
1013904223
;
switch
(
method
){
case
SWR_DITHER_RECTANGULAR
:
v
=
((
double
)
seed
)
/
UINT_MAX
-
0
.
5
;
break
;
case
SWR_DITHER_TRIANGULAR
:
case
SWR_DITHER_TRIANGULAR_HIGHPASS
:
v
=
((
double
)
seed
)
/
UINT_MAX
;
seed
=
seed
*
1664525
+
1013904223
;
v
-=
((
double
)
seed
)
/
UINT_MAX
;
break
;
default:
av_assert0
(
0
);
}
tmp
[
i
]
=
v
;
}
for
(
i
=
0
;
i
<
len
;
i
++
){
double
v
;
switch
(
method
){
case
SWR_DITHER_RECTANGULAR
:
case
SWR_DITHER_TRIANGULAR
:
v
=
tmp
[
i
];
break
;
case
SWR_DITHER_TRIANGULAR_HIGHPASS
:
v
=
(
-
tmp
[
i
]
+
2
*
tmp
[
i
+
1
]
-
tmp
[
i
+
2
])
/
sqrt
(
6
);
break
;
default:
av_assert0
(
0
);
}
v
*=
scale
;
...
...
@@ -58,4 +77,6 @@ void swri_get_dither(void *dst, int len, unsigned seed, enum AVSampleFormat out_
default:
av_assert0
(
0
);
}
}
av_free
(
tmp
);
}
libswresample/swresample.c
View file @
f8a237a3
...
...
@@ -56,6 +56,7 @@ static const AVOption options[]={
{
"dither"
,
"dither method"
,
OFFSET
(
dither_method
),
AV_OPT_TYPE_INT
,
{.
dbl
=
0
},
0
,
SWR_DITHER_NB
-
1
,
0
,
"dither_method"
},
{
"rectangular"
,
"rectangular dither"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
SWR_DITHER_RECTANGULAR
},
INT_MIN
,
INT_MAX
,
0
,
"dither_method"
},
{
"triangular"
,
"triangular dither"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
SWR_DITHER_TRIANGULAR
},
INT_MIN
,
INT_MAX
,
0
,
"dither_method"
},
{
"triangular_hp"
,
"triangular dither with high pass"
,
0
,
AV_OPT_TYPE_CONST
,
{.
dbl
=
SWR_DITHER_TRIANGULAR_HIGHPASS
},
INT_MIN
,
INT_MAX
,
0
,
"dither_method"
},
{
0
}
};
...
...
libswresample/swresample.h
View file @
f8a237a3
...
...
@@ -49,6 +49,7 @@ enum SwrDitherType {
SWR_DITHER_NONE
=
0
,
SWR_DITHER_RECTANGULAR
,
SWR_DITHER_TRIANGULAR
,
SWR_DITHER_TRIANGULAR_HIGHPASS
,
SWR_DITHER_NB
,
///< not part of API/ABI
};
...
...
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