[FFmpeg-cvslog] swr: add triangular dither support
Michael Niedermayer
git at videolan.org
Tue Apr 10 21:31:40 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Apr 10 21:10:14 2012 +0200| [b1ef4dc406e8a0bd9acea40d880aa4e74412075b] | committer: Michael Niedermayer
swr: add triangular dither support
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1ef4dc406e8a0bd9acea40d880aa4e74412075b
---
libswresample/dither.c | 5 +++++
libswresample/swresample.c | 1 +
libswresample/swresample.h | 1 +
3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/libswresample/dither.c b/libswresample/dither.c
index 4e39cce..663e200 100644
--- a/libswresample/dither.c
+++ b/libswresample/dither.c
@@ -40,6 +40,11 @@ void swri_get_dither(void *dst, int len, unsigned seed, enum AVSampleFormat out_
switch(method){
case SWR_DITHER_RECTANGULAR: v= ((double)seed) / UINT_MAX - 0.5; break;
+ case SWR_DITHER_TRIANGULAR :
+ v = ((double)seed) / UINT_MAX;
+ seed = seed*1664525 + 1013904223;
+ v-= ((double)seed) / UINT_MAX;
+ break;
default: av_assert0(0);
}
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 8b06061..58096b3 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -55,6 +55,7 @@ static const AVOption options[]={
{"res", "force resampling", 0, AV_OPT_TYPE_CONST, {.dbl=SWR_FLAG_RESAMPLE}, INT_MIN, INT_MAX, 0, "flags"},
{"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"},
{0}
};
diff --git a/libswresample/swresample.h b/libswresample/swresample.h
index 1f87617..9bd5b67 100644
--- a/libswresample/swresample.h
+++ b/libswresample/swresample.h
@@ -48,6 +48,7 @@
enum SwrDitherType {
SWR_DITHER_NONE = 0,
SWR_DITHER_RECTANGULAR,
+ SWR_DITHER_TRIANGULAR,
SWR_DITHER_NB, ///< not part of API/ABI
};
More information about the ffmpeg-cvslog
mailing list