[FFmpeg-devel] [PATCH 1/2] av_rescale: support passing MIN/MAX through
Michael Niedermayer
michaelni at gmx.at
Wed Jan 2 23:32:59 CET 2013
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavutil/mathematics.c | 8 +++++++-
libavutil/mathematics.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 6c2f6c0..746414b 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -61,7 +61,13 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
int64_t r=0;
av_assert2(c > 0);
av_assert2(b >=0);
- av_assert2((unsigned)rnd<=5 && rnd!=4);
+ av_assert2((unsigned)(rnd&~8)<=5 && (rnd&~8)!=4);
+
+ if (rnd & AV_ROUND_PASS_MINMAX) {
+ if (a == INT64_MIN || a == INT64_MAX)
+ return a;
+ rnd -= AV_ROUND_PASS_MINMAX;
+ }
if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h
index 0021d52..c4c33a9 100644
--- a/libavutil/mathematics.h
+++ b/libavutil/mathematics.h
@@ -70,6 +70,7 @@ enum AVRounding {
AV_ROUND_DOWN = 2, ///< Round toward -infinity.
AV_ROUND_UP = 3, ///< Round toward +infinity.
AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero.
+ AV_ROUND_PASS_MINMAX = 8, ///< Flag to pass INT64_MIN/MAX through instead of rescaling, this avoids special cases for AV_NOPTS_VALUE
};
/**
--
1.7.9.5
More information about the ffmpeg-devel
mailing list