diff mbox series

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

Message ID 20200908091515.4652-1-darioandre@gmail.com
State New
Headers show
Series [FFmpeg-devel] avformat/h263dec: Reduce H.263 probe score if only one frame is found
Related show


Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Dario Andreani Sept. 8, 2020, 9:15 a.m. UTC
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@gmail.com>
 libavformat/h263dec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


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){
     }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;