From 84b357dd5f64a612d5f0f40602379c57c49dc6c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= <scerveau@collabora.com>
Date: Thu, 16 Sep 2021 15:18:24 +0200
Subject: [PATCH] typefindfunctions: differentiate h265 from h264

in some cases, the algo gives the same probability
to h264 and h265 for h26x stream resulting in a h265
stream detected as a h264.
if sps/pps/vps detected, increase the probabilty.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/957>
---
 .../gst/typefind/gsttypefindfunctions.c            | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c b/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c
index 68ee3cdd4e..d5f466d912 100644
--- a/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c
+++ b/subprojects/gst-plugins-base/gst/typefind/gsttypefindfunctions.c
@@ -2887,7 +2887,12 @@ h264_video_type_find (GstTypeFind * tf, gpointer unused)
       seen_pps, seen_sps, seen_idr, seen_ssps);
 
   if (good >= 2 && bad == 0) {
-    gst_type_find_suggest (tf, GST_TYPE_FIND_POSSIBLE, H264_VIDEO_CAPS);
+    GstTypeFindProbability probability = GST_TYPE_FIND_POSSIBLE;
+
+    if (seen_pps && seen_sps)
+      probability = GST_TYPE_FIND_LIKELY;
+
+    gst_type_find_suggest (tf, probability, H264_VIDEO_CAPS);
   }
 }
 
@@ -2980,7 +2985,12 @@ h265_video_type_find (GstTypeFind * tf, gpointer unused)
       seen_pps, seen_sps, seen_vps, seen_irap);
 
   if (good >= 2 && bad == 0) {
-    gst_type_find_suggest (tf, GST_TYPE_FIND_POSSIBLE, H265_VIDEO_CAPS);
+    GstTypeFindProbability probability = GST_TYPE_FIND_POSSIBLE;
+
+    if (seen_pps && seen_sps && seen_vps)
+      probability = GST_TYPE_FIND_LIKELY;
+
+    gst_type_find_suggest (tf, probability, H265_VIDEO_CAPS);
   }
 }