[PATCH v2 07/18] winegstreamer: Translate H.264 caps to attributes.

Derek Lesho dlesho at codeweavers.com
Wed Apr 1 17:05:28 CDT 2020


Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
---
 dlls/winegstreamer/mfplat.c | 67 +++++++++++++++++++++++++++++++++++++
 include/codecapi.h          | 38 +++++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 include/codecapi.h

diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c
index 09266ffab4..b76714c482 100644
--- a/dlls/winegstreamer/mfplat.c
+++ b/dlls/winegstreamer/mfplat.c
@@ -26,6 +26,7 @@
 #include "gst_private.h"
 #include "mfapi.h"
 #include "mfidl.h"
+#include "codecapi.h"
 
 #include "wine/debug.h"
 #include "wine/heap.h"
@@ -525,6 +526,72 @@ static IMFMediaType* transform_to_media_type(GstCaps *caps)
                     FIXME("Unrecognized format.\n");
             }
         }
+        else if (!(strcmp(mime_type, "video/x-h264")))
+        {
+            const char *profile, *level;
+
+            IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_H264);
+            IMFMediaType_SetUINT32(media_type, &MF_MT_COMPRESSED, TRUE);
+
+            if ((profile = gst_structure_get_string(info, "profile")))
+            {
+                if (!(strcmp(profile, "main")))
+                    IMFMediaType_SetUINT32(media_type, &MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_Main);
+                else if (!(strcmp(profile, "high")))
+                    IMFMediaType_SetUINT32(media_type, &MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_High);
+                else if (!(strcmp(profile, "high-4:4:4")))
+                    IMFMediaType_SetUINT32(media_type, &MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_444);
+                else
+                    FIXME("Unrecognized profile %s\n", profile);
+            }
+            if ((level = gst_structure_get_string(info, "level")))
+            {
+                unsigned int i;
+
+                const static struct
+                {
+                    const char *name;
+                    enum eAVEncH264VLevel val;
+                } levels[] =
+                {
+                    {"1",   eAVEncH264VLevel1},
+                    {"1.1", eAVEncH264VLevel1_1},
+                    {"1.2", eAVEncH264VLevel1_2},
+                    {"1.3", eAVEncH264VLevel1_3},
+                    {"2",   eAVEncH264VLevel2},
+                    {"2.1", eAVEncH264VLevel2_1},
+                    {"2.2", eAVEncH264VLevel2_2},
+                    {"3",   eAVEncH264VLevel3},
+                    {"3.1", eAVEncH264VLevel3_1},
+                    {"3.2", eAVEncH264VLevel3_2},
+                    {"4",   eAVEncH264VLevel4},
+                    {"4.1", eAVEncH264VLevel4_1},
+                    {"4.2", eAVEncH264VLevel4_2},
+                    {"5",   eAVEncH264VLevel5},
+                    {"5.1", eAVEncH264VLevel5_1},
+                    {"5.2", eAVEncH264VLevel5_2},
+                };
+                for (i = 0 ; i < ARRAY_SIZE(levels); i++)
+                {
+                    if (!(strcmp(level, levels[i].name)))
+                    {
+                        IMFMediaType_SetUINT32(media_type, &MF_MT_MPEG2_LEVEL, levels[i].val);
+                        break;
+                    }
+                }
+                if (i == ARRAY_SIZE(levels))
+                {
+                    FIXME("Unrecognized level %s", level);
+                }
+            }
+            gst_caps_set_simple(caps, "stream-format", G_TYPE_STRING, "byte-stream", NULL);
+            gst_caps_set_simple(caps, "alignment", G_TYPE_STRING, "au", NULL);
+            for (unsigned int i = 0; i < gst_caps_get_size(caps); i++)
+            {
+                GstStructure *structure = gst_caps_get_structure (caps, i);
+                gst_structure_remove_field(structure, "codec_data");
+            }
+        }
         else
             FIXME("Unrecognized video format %s\n", mime_type);
     }
diff --git a/include/codecapi.h b/include/codecapi.h
new file mode 100644
index 0000000000..307f40cb27
--- /dev/null
+++ b/include/codecapi.h
@@ -0,0 +1,38 @@
+#ifndef __WINE_CODECAPI_H
+#define __WINE_CODECAPI_H
+
+enum eAVEncH264VProfile
+{
+    eAVEncH264VProfile_unknown  = 0,
+    eAVEncH264VProfile_Simple   = 66,
+    eAVEncH264VProfile_Base     = 66,
+    eAVEncH264VProfile_Main     = 77,
+    eAVEncH264VProfile_High     = 100,
+    eAVEncH264VProfile_422      = 122,
+    eAVEncH264VProfile_High10   = 110,
+    eAVEncH264VProfile_444      = 244,
+    eAVEncH264VProfile_Extended = 88,
+};
+
+enum eAVEncH264VLevel
+{
+    eAVEncH264VLevel1   = 10,
+    eAVEncH264VLevel1_b = 11,
+    eAVEncH264VLevel1_1 = 11,
+    eAVEncH264VLevel1_2 = 12,
+    eAVEncH264VLevel1_3 = 13,
+    eAVEncH264VLevel2   = 20,
+    eAVEncH264VLevel2_1 = 21,
+    eAVEncH264VLevel2_2 = 22,
+    eAVEncH264VLevel3   = 30,
+    eAVEncH264VLevel3_1 = 31,
+    eAVEncH264VLevel3_2 = 32,
+    eAVEncH264VLevel4   = 40,
+    eAVEncH264VLevel4_1 = 41,
+    eAVEncH264VLevel4_2 = 42,
+    eAVEncH264VLevel5   = 50,
+    eAVEncH264VLevel5_1 = 51,
+    eAVEncH264VLevel5_2 = 52
+};
+
+#endif
\ No newline at end of file
-- 
2.26.0




More information about the wine-devel mailing list