[FFmpeg-devel] [PATCH] avformat/h263dec: Reduce H.263 probe score if only one frame is found

Dario Andreani darioandre at gmail.com
Tue Sep 8 12:15:15 EEST 2020


Fixes #6500

I checked the h263 specification and the current implementation is already quite thorough. False positives, like #6500, can happen by pure chance. To improve the situation it would be necessary to further parse and validate additional data from the h263 "picture" layer.
A possible alternative is to add some heuristic in relation with TR (time reference): in all h263 samples which I could find, the first TR is zero and successive ones differ from the previous (mod 0xFF) by a small value, typically 1. The score could be lowered if this doesn't happen (e.g. the value is 214 in #6500).
For now, my proposal is something much simpler, which takes care of #6500 and possibly other "unlucky" cases: the score is reduced to 12 if only a single valid PSC is found. Note that the current implementation already unconditionally reduces the score to 25 if there are less than 4 valid PSCs.

Signed-off-by: Dario Andreani <darioandre at gmail.com>
---
 libavformat/h263dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/h263dec.c b/libavformat/h263dec.c
index 0736158bfe..ff2828ed83 100644
--- a/libavformat/h263dec.c
+++ b/libavformat/h263dec.c
@@ -71,7 +71,7 @@ static int h263_probe(const AVProbeData *p)
     if(valid_psc > 2*invalid_psc + 2*res_change + 3){
         return AVPROBE_SCORE_EXTENSION;
     }else if(valid_psc > 2*invalid_psc)
-        return AVPROBE_SCORE_EXTENSION / 2;
+        return valid_psc > 1 ? AVPROBE_SCORE_EXTENSION / 2 : AVPROBE_SCORE_EXTENSION / 4;
     return 0;
 }
 
-- 
2.28.0



More information about the ffmpeg-devel mailing list