Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW
@ 2024-04-21 23:06 Michael Niedermayer
  2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch Michael Niedermayer
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michael Niedermayer @ 2024-04-21 23:06 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Fixes: CID1403227 Division or modulo by float zero

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavfilter/signature_lookup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index ab7320d47f4..a3086b38cca 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -496,10 +496,10 @@ static MatchingInfo evaluate_parameters(AVFilterContext *ctx, SignatureContext *
             continue; /* matching sequence is too short */
         if ((double) goodfcount / (double) fcount < sc->thit)
             continue;
-        if ((double) goodfcount*0.5 < FFMAX(gooda, goodb))
+        if ((double) goodfcount*0.5 <= FFMAX(gooda, goodb))
             continue;
 
-        meandist = (double) goodfcount / (double) distsum;
+        meandist = (double) distsum / (double) goodfcount;
 
         if (meandist < minmeandist ||
                 status == (STATUS_END_REACHED | STATUS_BEGIN_REACHED) ||
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch
  2024-04-21 23:06 [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW Michael Niedermayer
@ 2024-04-21 23:07 ` Michael Niedermayer
  2024-04-21 23:10   ` Andreas Rheinhardt
  2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 3/3] avfilter/signature_lookup: Dont copy uninitialized stuff around Michael Niedermayer
  2024-04-24  0:49 ` [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW Michael Niedermayer
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Niedermayer @ 2024-04-21 23:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Fixes: CID1500345 Uninitialized scalar variable

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavfilter/signature_lookup.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index a3086b38cca..dc0a2ef2b24 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -535,16 +535,14 @@ static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc
 {
     CoarseSignature *cs, *cs2;
     MatchingInfo *infos;
-    MatchingInfo bestmatch;
+    MatchingInfo bestmatch = {0};
     MatchingInfo *i;
 
     cs = first->coarsesiglist;
     cs2 = second->coarsesiglist;
 
     /* score of bestmatch is 0, if no match is found */
-    bestmatch.score = 0;
     bestmatch.meandist = 99999;
-    bestmatch.whole = 0;
 
     fill_l1distlut(sc->l1distlut);
 
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 3/3] avfilter/signature_lookup: Dont copy uninitialized stuff around
  2024-04-21 23:06 [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW Michael Niedermayer
  2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch Michael Niedermayer
@ 2024-04-21 23:07 ` Michael Niedermayer
  2024-04-24  0:49   ` Michael Niedermayer
  2024-04-24  0:49 ` [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW Michael Niedermayer
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Niedermayer @ 2024-04-21 23:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Fixes: CID1403238 Uninitialized pointer read
Fixes: CID1403239 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavfilter/signature_lookup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index dc0a2ef2b24..380723e92a4 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -448,14 +448,14 @@ static MatchingInfo evaluate_parameters(AVFilterContext *ctx, SignatureContext *
                 }
 
                 if (tolerancecount > 2) {
-                    a = aprev;
-                    b = bprev;
                     if (dir == DIR_NEXT) {
                         /* turn around */
                         a = infos->first;
                         b = infos->second;
                         dir = DIR_PREV;
                     } else {
+                        a = aprev;
+                        b = bprev;
                         break;
                     }
                 }
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch
  2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch Michael Niedermayer
@ 2024-04-21 23:10   ` Andreas Rheinhardt
  2024-04-22  2:09     ` Michael Niedermayer
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Rheinhardt @ 2024-04-21 23:10 UTC (permalink / raw)
  To: ffmpeg-devel

Michael Niedermayer:
> Fixes: CID1500345 Uninitialized scalar variable
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavfilter/signature_lookup.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
> index a3086b38cca..dc0a2ef2b24 100644
> --- a/libavfilter/signature_lookup.c
> +++ b/libavfilter/signature_lookup.c
> @@ -535,16 +535,14 @@ static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc
>  {
>      CoarseSignature *cs, *cs2;
>      MatchingInfo *infos;
> -    MatchingInfo bestmatch;
> +    MatchingInfo bestmatch = {0};
>      MatchingInfo *i;
>  
>      cs = first->coarsesiglist;
>      cs2 = second->coarsesiglist;
>  
>      /* score of bestmatch is 0, if no match is found */
> -    bestmatch.score = 0;
>      bestmatch.meandist = 99999;
> -    bestmatch.whole = 0;
>  
>      fill_l1distlut(sc->l1distlut);
>  

Does this fix an actual bug or just suppress a Coverity warning?

- Andreas

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch
  2024-04-21 23:10   ` Andreas Rheinhardt
@ 2024-04-22  2:09     ` Michael Niedermayer
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Niedermayer @ 2024-04-22  2:09 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1932 bytes --]

On Mon, Apr 22, 2024 at 01:10:47AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: CID1500345 Uninitialized scalar variable
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavfilter/signature_lookup.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
> > index a3086b38cca..dc0a2ef2b24 100644
> > --- a/libavfilter/signature_lookup.c
> > +++ b/libavfilter/signature_lookup.c
> > @@ -535,16 +535,14 @@ static MatchingInfo lookup_signatures(AVFilterContext *ctx, SignatureContext *sc
> >  {
> >      CoarseSignature *cs, *cs2;
> >      MatchingInfo *infos;
> > -    MatchingInfo bestmatch;
> > +    MatchingInfo bestmatch = {0};
> >      MatchingInfo *i;
> >  
> >      cs = first->coarsesiglist;
> >      cs2 = second->coarsesiglist;
> >  
> >      /* score of bestmatch is 0, if no match is found */
> > -    bestmatch.score = 0;
> >      bestmatch.meandist = 99999;
> > -    bestmatch.whole = 0;
> >  
> >      fill_l1distlut(sc->l1distlut);
> >  
> 
> Does this fix an actual bug or just suppress a Coverity warning?

returning partially initialized structs is IMHO bad practice
it is strictly not a bug i guess.
But its similar to not initializing pointers to NULL and then
having to track if all paths initialize them before freeing.

This is similar. With passing partially initialized structs around,
one would have to ensure that nothing is touched that isnt initialized.
Ive marked the issue as false positive now as that is in fact more
correct.

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW
  2024-04-21 23:06 [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW Michael Niedermayer
  2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch Michael Niedermayer
  2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 3/3] avfilter/signature_lookup: Dont copy uninitialized stuff around Michael Niedermayer
@ 2024-04-24  0:49 ` Michael Niedermayer
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Niedermayer @ 2024-04-24  0:49 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 679 bytes --]

On Mon, Apr 22, 2024 at 01:06:59AM +0200, Michael Niedermayer wrote:
> Fixes: CID1403227 Division or modulo by float zero
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavfilter/signature_lookup.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/3] avfilter/signature_lookup: Dont copy uninitialized stuff around
  2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 3/3] avfilter/signature_lookup: Dont copy uninitialized stuff around Michael Niedermayer
@ 2024-04-24  0:49   ` Michael Niedermayer
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Niedermayer @ 2024-04-24  0:49 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 590 bytes --]

On Mon, Apr 22, 2024 at 01:07:01AM +0200, Michael Niedermayer wrote:
> Fixes: CID1403238 Uninitialized pointer read
> Fixes: CID1403239 Uninitialized pointer read
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavfilter/signature_lookup.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-24  0:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-21 23:06 [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW Michael Niedermayer
2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 2/3] avfilter/signature_lookup: Initialize bestmatch Michael Niedermayer
2024-04-21 23:10   ` Andreas Rheinhardt
2024-04-22  2:09     ` Michael Niedermayer
2024-04-21 23:07 ` [FFmpeg-devel] [PATCH 3/3] avfilter/signature_lookup: Dont copy uninitialized stuff around Michael Niedermayer
2024-04-24  0:49   ` Michael Niedermayer
2024-04-24  0:49 ` [FFmpeg-devel] [PATCH 1/3] avfilter/signature_lookup: Fix 2 differences to the refernce SW Michael Niedermayer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git