diff mbox series

[FFmpeg-devel] tools/coverity: Phase 1 study of anti-halicogenic for coverity av_rescale()

Message ID 20240705125041.1967554-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel] tools/coverity: Phase 1 study of anti-halicogenic for coverity av_rescale() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer July 5, 2024, 12:50 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 tools/coverity.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Michael Niedermayer July 7, 2024, 8:14 p.m. UTC | #1
On Fri, Jul 05, 2024 at 02:50:41PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  tools/coverity.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/tools/coverity.c b/tools/coverity.c
index 19a132a9767..541e108238d 100644
--- a/tools/coverity.c
+++ b/tools/coverity.c
@@ -31,6 +31,17 @@ 
 
 #define NULL (void *)0
 
+typedef long long int64_t;
+
+enum AVRounding {
+    AV_ROUND_ZERO     = 0,
+    AV_ROUND_INF      = 1,
+    AV_ROUND_DOWN     = 2,
+    AV_ROUND_UP       = 3,
+    AV_ROUND_NEAR_INF = 5,
+    AV_ROUND_PASS_MINMAX = 8192,
+};
+
 // Based on https://scan.coverity.com/models
 void *av_malloc(size_t size) {
     int has_memory;
@@ -77,3 +88,10 @@  void *av_free(void *ptr) {
     __coverity_mark_as_afm_freed__(ptr, "av_free");
 }
 
+
+int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) {
+    __coverity_negative_sink__(b);
+    __coverity_negative_sink__(c);
+
+    return (double)a * (double)b / (double)c;
+}