<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
</head>
<body><div style="font-family:helvetica, arial, sans-serif;">Hello,<br></div>
<div><br></div>
<div>On Sun, 4 Mar 2018, at 11:53, Teemu Ikonen wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div>Adds support in Media Foundation (MFT) module to use decoders whose FCC is not found from the hardcoded list. Improves compatibility and adds support for common uncompressed formats decoders might prefer. <br></div>
</div>
</blockquote><div style="font-family:helvetica, arial, sans-serif;"><br></div>
<div style="font-family:helvetica, arial, sans-serif;">This looks cool, but how do you have examples of such things?<br></div>
<div style="font-family:helvetica, arial, sans-serif;"><br></div>
<blockquote type="cite"><div dir="ltr"><div>Internal formats (like MFVideoFormat_RGB32) are bottom up (negative stride). Code just changes the to <span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="colour" style="color:rgb(34, 34, 34)"><span class="font" style="font-family:arial, sans-serif"><span class="size" style="font-size:small">ORIENT_BOTTOM_LEFT in this case and it works, but is this the right thing do?</span></span></span></span><br></div>
</div>
</blockquote><div style="font-family:helvetica, arial, sans-serif;"><br></div>
<div style="font-family:helvetica, arial, sans-serif;">Did you look at the avi code?<br></div>
<div style="font-family:helvetica, arial, sans-serif;"><br></div>
<div style="font-family:helvetica, arial, sans-serif;">Best,<br></div>
<blockquote type="cite"><div dir="ltr"><div><br></div>
<div>---<br></div>
<div> modules/codec/mft.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++----<br></div>
<div> 1 file changed, 62 insertions(+), 4 deletions(-)<br></div>
<div><br></div>
<div>diff --git a/modules/codec/mft.c b/modules/codec/mft.c<br></div>
<div>index 24eaaa55cb..3cf6aa494d 100644<br></div>
<div>--- a/modules/codec/mft.c<br></div>
<div>+++ b/modules/codec/mft.c<br></div>
<div>@@ -92,6 +92,8 @@ struct decoder_sys_t<br></div>
<div> <br></div>
<div>     const GUID* major_type;<br></div>
<div>     const GUID* subtype;<br></div>
<div>+    /* Container for a dynamically constructed subtype */<br></div>
<div>+    GUID custom_subtype;<br></div>
<div> <br></div>
<div>     /* For asynchronous MFT */<br></div>
<div>     bool is_async;<br></div>
<div>@@ -183,6 +185,20 @@ static const pair_format_guid video_format_table[] =<br></div>
<div>     { 0, NULL }<br></div>
<div> };<br></div>
<div> <br></div>
<div>+// 8-bit luminance only<br></div>
<div>+DEFINE_MEDIATYPE_GUID (MFVideoFormat_L8, 50);<br></div>
<div>+<br></div>
<div>+/*<br></div>
<div>+ * Table to map MF Transform raw 3D3 output formats to native VLC FourCC<br></div>
<div>+ */<br></div>
<div>+static const pair_format_guid d3d_format_table[] = {<br></div>
<div>+    { VLC_CODEC_RGB32, &MFVideoFormat_RGB32  },<br></div>
<div>+    { VLC_CODEC_RGB24, &MFVideoFormat_RGB24  },<br></div>
<div>+    { VLC_CODEC_RGBA,  &MFVideoFormat_ARGB32 },<br></div>
<div>+    { VLC_CODEC_GREY,  &MFVideoFormat_L8     },<br></div>
<div>+    { 0, NULL }<br></div>
<div>+};<br></div>
<div>+<br></div>
<div> #if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 4<br></div>
<div> DEFINE_GUID(MFAudioFormat_Dolby_AC3, 0xe06d802c, 0xdb46, 0x11cf, 0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea);<br></div>
<div> #endif<br></div>
<div>@@ -210,6 +226,15 @@ static const GUID *FormatToGUID(const pair_format_guid table[], vlc_fourcc_t fou<br></div>
<div>     return NULL;<br></div>
<div> }<br></div>
<div> <br></div>
<div>+static vlc_fourcc_t GUIDToFormat(const pair_format_guid table[], const GUID* guid)<br></div>
<div>+{<br></div>
<div>+    for (int i = 0; table[i].fourcc; ++i)<br></div>
<div>+        if (IsEqualGUID(table[i].guid, guid))<br></div>
<div>+            return table[i].fourcc;<br></div>
<div>+<br></div>
<div>+    return 0;<br></div>
<div>+}<br></div>
<div>+<br></div>
<div> /*<br></div>
<div>  * Low latency mode for Windows 8. Without this option, the H264<br></div>
<div>  * decoder will fill *all* its internal buffers before returning a<br></div>
<div>@@ -272,6 +297,16 @@ static int SetInputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **result<br></div>
<div>         hr = IMFMediaType_SetUINT64(input_media_type, &MF_MT_FRAME_SIZE, frame_size);<br></div>
<div>         if (FAILED(hr))<br></div>
<div>             goto error;<br></div>
<div>+<br></div>
<div>+        /* Some transforms like to know the frame rate and may reject the input type otherwise. */<br></div>
<div>+        UINT64 frame_ratio_num = p_dec->fmt_in.video.i_frame_rate;<br></div>
<div>+        UINT64 frame_ratio_dem = p_dec->fmt_in.video.i_frame_rate_base;<br></div>
<div>+        if(frame_ratio_num && frame_ratio_dem) {<br></div>
<div>+            UINT64 frame_rate = (frame_ratio_num << 32) | frame_ratio_dem;<br></div>
<div>+            hr = IMFMediaType_SetUINT64(input_media_type, &MF_MT_FRAME_RATE, frame_rate);<br></div>
<div>+            if(FAILED(hr))<br></div>
<div>+                goto error;<br></div>
<div>+        }<br></div>
<div>     }<br></div>
<div>     else<br></div>
<div>     {<br></div>
<div>@@ -356,7 +391,7 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul<br></div>
<div>      * preference thus we will use the first one unless YV12/I420 is<br></div>
<div>      * available for video or float32 for audio.<br></div>
<div>      */<br></div>
<div>-    int output_type_index = 0;<br></div>
<div>+    int output_type_index = -1;<br></div>
<div>     bool found = false;<br></div>
<div>     for (int i = 0; !found; ++i)<br></div>
<div>     {<br></div>
<div>@@ -380,6 +415,10 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul<br></div>
<div>         {<br></div>
<div>             if (IsEqualGUID(&subtype, &MFVideoFormat_YV12) || IsEqualGUID(&subtype, &MFVideoFormat_I420))<br></div>
<div>                 found = true;<br></div>
<div>+            /* Transform might offer output in a D3DFMT propietary FCC. If we can<br></div>
<div>+             * use it, fall back to it in case we do not find YV12 or I420 */<br></div>
<div>+            else if(output_type_index < 0 && GUIDToFormat(d3d_format_table, &subtype) > 0)<br></div>
<div>+                    output_type_index = i;<br></div>
<div>         }<br></div>
<div>         else<br></div>
<div>         {<br></div>
<div>@@ -399,9 +438,12 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul<br></div>
<div>     }<br></div>
<div>     /*<br></div>
<div>      * It's not an error if we don't find the output type we were<br></div>
<div>-     * looking for, in this case we use the first available type which<br></div>
<div>-     * is the "preferred" output type for this MFT.<br></div>
<div>+     * looking for, in this case we use the first available type.<br></div>
<div>      */<br></div>
<div>+    if(output_type_index < 0)<br></div>
<div>+        /* No output format found we prefer, just pick the first one preferred<br></div>
<div>+         * by the MFT */<br></div>
<div>+        output_type_index = 0;<br></div>
<div> <br></div>
<div>     hr = IMFTransform_GetOutputAvailableType(p_sys->mft, stream_id, output_type_index, &output_media_type);<br></div>
<div>     if (FAILED(hr))<br></div>
<div>@@ -419,7 +461,17 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul<br></div>
<div>     if (p_dec->fmt_in.i_cat == VIDEO_ES)<br></div>
<div>     {<br></div>
<div>         video_format_Copy( &p_dec->fmt_out.video, &p_dec->fmt_in.video );<br></div>
<div>-        p_dec->fmt_out.i_codec = vlc_fourcc_GetCodec(p_dec->fmt_in.i_cat, subtype.Data1);<br></div>
<div>+<br></div>
<div>+        /* Transform might offer output in a D3DFMT propietary FCC */<br></div>
<div>+        vlc_fourcc_t fcc = GUIDToFormat(d3d_format_table, &subtype);<br></div>
<div>+        if(fcc) {<br></div>
<div>+            /* D3D formats are upside down */<br></div>
<div>+            p_dec->fmt_out.video.orientation = ORIENT_BOTTOM_LEFT;<br></div>
<div>+        } else {<br></div>
<div>+            fcc = vlc_fourcc_GetCodec(p_dec->fmt_in.i_cat, subtype.Data1);<br></div>
<div>+        }<br></div>
<div>+<br></div>
<div>+        p_dec->fmt_out.i_codec = fcc;<br></div>
<div>     }<br></div>
<div>     else<br></div>
<div>     {<br></div>
<div>@@ -1046,6 +1098,12 @@ static int FindMFT(decoder_t *p_dec)<br></div>
<div>         category = MFT_CATEGORY_VIDEO_DECODER;<br></div>
<div>         p_sys->major_type = &MFMediaType_Video;<br></div>
<div>         p_sys->subtype = FormatToGUID(video_format_table, p_dec->fmt_in.i_codec);<br></div>
<div>+        if(!p_sys->subtype) {<br></div>
<div>+            /* Codec is not well known. Construct a MF transform subtype from the fourcc */<br></div>
<div>+            p_sys->custom_subtype = MFVideoFormat_Base;<br></div>
<div>+            p_sys->custom_subtype.Data1 = p_dec->fmt_in.i_codec;<br></div>
<div>+            p_sys->subtype = &p_sys->custom_subtype;<br></div>
<div>+        }<br></div>
<div>     }<br></div>
<div>     else<br></div>
<div>     {<br></div>
<div>-- <br></div>
<div>2.14.1<br></div>
<div><br></div>
</div>
<div><u>_______________________________________________</u><br></div>
<div>vlc-devel mailing list<br></div>
<div>To unsubscribe or modify your subscription options:<br></div>
<div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div>
</blockquote><div style="font-family:helvetica, arial, sans-serif;"><br></div>
<div id="sig60240713"><div class="signature">--<br></div>
<div class="signature">Jean-Baptiste Kempf -  President<br></div>
<div class="signature">+33 672 704 734<br></div>
<div class="signature"> <br></div>
<div class="signature"><br></div>
</div>
<div style="font-family:helvetica, arial, sans-serif;"><br></div>
</body>
</html>