<div dir="ltr">Thanks, I took a look into avi.c and decided to remove the orientation hack.<div><br></div><div>Here is the modified patch. Change to previous is storing a flipped flag that is used to choose</div><div>line order in buffer copy.</div><div><br></div><div><div>---<br></div><div> modules/codec/mft.c | 110 ++++++++++++++++++++++++++++++++++++++++++++--------</div><div> 1 file changed, 93 insertions(+), 17 deletions(-)</div><div><br></div><div>diff --git a/modules/codec/mft.c b/modules/codec/mft.c</div><div>index 24eaaa55cb..9ad000d2a8 100644</div><div>--- a/modules/codec/mft.c</div><div>+++ b/modules/codec/mft.c</div><div>@@ -92,6 +92,8 @@ struct decoder_sys_t</div><div> </div><div>     const GUID* major_type;</div><div>     const GUID* subtype;</div><div>+    /* Container for a dynamically constructed subtype */</div><div>+    GUID custom_subtype;</div><div> </div><div>     /* For asynchronous MFT */</div><div>     bool is_async;</div><div>@@ -102,6 +104,7 @@ struct decoder_sys_t</div><div>     /* Input stream */</div><div>     DWORD input_stream_id;</div><div>     IMFMediaType *input_type;</div><div>+    bool flipped;</div><div> </div><div>     /* Output stream */</div><div>     DWORD output_stream_id;</div><div>@@ -183,6 +186,20 @@ static const pair_format_guid video_format_table[] =</div><div>     { 0, NULL }</div><div> };</div><div> </div><div>+// 8-bit luminance only</div><div>+DEFINE_MEDIATYPE_GUID (MFVideoFormat_L8, 50);</div><div>+</div><div>+/*</div><div>+ * Table to map MF Transform raw 3D3 output formats to native VLC FourCC</div><div>+ */</div><div>+static const pair_format_guid d3d_format_table[] = {</div><div>+    { VLC_CODEC_RGB32, &MFVideoFormat_RGB32  },</div><div>+    { VLC_CODEC_RGB24, &MFVideoFormat_RGB24  },</div><div>+    { VLC_CODEC_RGBA,  &MFVideoFormat_ARGB32 },</div><div>+    { VLC_CODEC_GREY,  &MFVideoFormat_L8     },</div><div>+    { 0, NULL }</div><div>+};</div><div>+</div><div> #if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 4</div><div> DEFINE_GUID(MFAudioFormat_Dolby_AC3, 0xe06d802c, 0xdb46, 0x11cf, 0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea);</div><div> #endif</div><div>@@ -210,6 +227,15 @@ static const GUID *FormatToGUID(const pair_format_guid table[], vlc_fourcc_t fou</div><div>     return NULL;</div><div> }</div><div> </div><div>+static vlc_fourcc_t GUIDToFormat(const pair_format_guid table[], const GUID* guid)</div><div>+{</div><div>+    for (int i = 0; table[i].fourcc; ++i)</div><div>+        if (IsEqualGUID(table[i].guid, guid))</div><div>+            return table[i].fourcc;</div><div>+</div><div>+    return 0;</div><div>+}</div><div>+</div><div> /*</div><div>  * Low latency mode for Windows 8. Without this option, the H264</div><div>  * decoder will fill *all* its internal buffers before returning a</div><div>@@ -272,6 +298,16 @@ static int SetInputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **result</div><div>         hr = IMFMediaType_SetUINT64(input_media_type, &MF_MT_FRAME_SIZE, frame_size);</div><div>         if (FAILED(hr))</div><div>             goto error;</div><div>+</div><div>+        /* Some transforms like to know the frame rate and may reject the input type otherwise. */</div><div>+        UINT64 frame_ratio_num = p_dec->fmt_in.video.i_frame_rate;</div><div>+        UINT64 frame_ratio_dem = p_dec->fmt_in.video.i_frame_rate_base;</div><div>+        if(frame_ratio_num && frame_ratio_dem) {</div><div>+            UINT64 frame_rate = (frame_ratio_num << 32) | frame_ratio_dem;</div><div>+            hr = IMFMediaType_SetUINT64(input_media_type, &MF_MT_FRAME_RATE, frame_rate);</div><div>+            if(FAILED(hr))</div><div>+                goto error;</div><div>+        }</div><div>     }</div><div>     else</div><div>     {</div><div>@@ -356,7 +392,7 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul</div><div>      * preference thus we will use the first one unless YV12/I420 is</div><div>      * available for video or float32 for audio.</div><div>      */</div><div>-    int output_type_index = 0;</div><div>+    int output_type_index = -1;</div><div>     bool found = false;</div><div>     for (int i = 0; !found; ++i)</div><div>     {</div><div>@@ -380,6 +416,10 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul</div><div>         {</div><div>             if (IsEqualGUID(&subtype, &MFVideoFormat_YV12) || IsEqualGUID(&subtype, &MFVideoFormat_I420))</div><div>                 found = true;</div><div>+            /* Transform might offer output in a D3DFMT propietary FCC. If we can</div><div>+             * use it, fall back to it in case we do not find YV12 or I420 */</div><div>+            else if(output_type_index < 0 && GUIDToFormat(d3d_format_table, &subtype) > 0)</div><div>+                    output_type_index = i;</div><div>         }</div><div>         else</div><div>         {</div><div>@@ -399,9 +439,12 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul</div><div>     }</div><div>     /*</div><div>      * It's not an error if we don't find the output type we were</div><div>-     * looking for, in this case we use the first available type which</div><div>-     * is the "preferred" output type for this MFT.</div><div>+     * looking for, in this case we use the first available type.</div><div>      */</div><div>+    if(output_type_index < 0)</div><div>+        /* No output format found we prefer, just pick the first one preferred</div><div>+         * by the MFT */</div><div>+        output_type_index = 0;</div><div> </div><div>     hr = IMFTransform_GetOutputAvailableType(p_sys->mft, stream_id, output_type_index, &output_media_type);</div><div>     if (FAILED(hr))</div><div>@@ -416,10 +459,21 @@ static int SetOutputType(decoder_t *p_dec, DWORD stream_id, IMFMediaType **resul</div><div>     if (FAILED(hr))</div><div>         goto error;</div><div> </div><div>+    p_sys->flipped = false;</div><div>     if (p_dec->fmt_in.i_cat == VIDEO_ES)</div><div>     {</div><div>         video_format_Copy( &p_dec->fmt_out.video, &p_dec->fmt_in.video );</div><div>-        p_dec->fmt_out.i_codec = vlc_fourcc_GetCodec(p_dec->fmt_in.i_cat, subtype.Data1);</div><div>+</div><div>+        /* Transform might offer output in a D3DFMT propietary FCC */</div><div>+        vlc_fourcc_t fcc = GUIDToFormat(d3d_format_table, &subtype);</div><div>+        if(fcc) {</div><div>+            /* D3D formats are upside down */</div><div>+            p_sys->flipped = true;</div><div>+        } else {</div><div>+            fcc = vlc_fourcc_GetCodec(p_dec->fmt_in.i_cat, subtype.Data1);</div><div>+        }</div><div>+</div><div>+        p_dec->fmt_out.i_codec = fcc;</div><div>     }</div><div>     else</div><div>     {</div><div>@@ -620,26 +674,42 @@ error:</div><div> }</div><div> </div><div> /* Copy a packed buffer (no padding) to a picture_t */</div><div>-static void CopyPackedBufferToPicture(picture_t *p_pic, const uint8_t *p_src)</div><div>+static void CopyPackedBufferToPicture(picture_t *p_pic, const uint8_t *p_src, bool flip)</div><div> {</div><div>     for (int i = 0; i < p_pic->i_planes; ++i)</div><div>     {</div><div>         uint8_t *p_dst = p_pic->p[i].p_pixels;</div><div> </div><div>-        if (p_pic->p[i].i_visible_pitch == p_pic->p[i].i_pitch)</div><div>+        if(flip)</div><div>         {</div><div>-            /* Plane is packed, only one memcpy is needed. */</div><div>-            uint32_t plane_size = p_pic->p[i].i_pitch * p_pic->p[i].i_visible_lines;</div><div>-            memcpy(p_dst, p_src, plane_size);</div><div>-            p_src += plane_size;</div><div>-            continue;</div><div>-        }</div><div>+            /* Point p_src to the end of data. */</div><div>+            p_src += p_pic->p[i].i_pitch * p_pic->p[i].i_visible_lines;</div><div> </div><div>-        for (int i_line = 0; i_line < p_pic->p[i].i_visible_lines; i_line++)</div><div>+            for (int i_line = 0; i_line < p_pic->p[i].i_visible_lines; i_line++)</div><div>+            {</div><div>+                /* Point to start of row */</div><div>+                p_src -= p_pic->p[i].i_pitch;</div><div>+                memcpy(p_dst, p_src, p_pic->p[i].i_visible_pitch);</div><div>+                p_dst += p_pic->p[i].i_visible_pitch;</div><div>+            }</div><div>+        }</div><div>+        else</div><div>         {</div><div>-            memcpy(p_dst, p_src, p_pic->p[i].i_visible_pitch);</div><div>-            p_src += p_pic->p[i].i_visible_pitch;</div><div>-            p_dst += p_pic->p[i].i_pitch;</div><div>+            if (p_pic->p[i].i_visible_pitch == p_pic->p[i].i_pitch)</div><div>+            {</div><div>+                /* Plane is packed, only one memcpy is needed. */</div><div>+                uint32_t plane_size = p_pic->p[i].i_pitch * p_pic->p[i].i_visible_lines;</div><div>+                memcpy(p_dst, p_src, plane_size);</div><div>+                p_src += plane_size;</div><div>+                continue;</div><div>+            }</div><div>+</div><div>+            for (int i_line = 0; i_line < p_pic->p[i].i_visible_lines; i_line++)</div><div>+            {</div><div>+                memcpy(p_dst, p_src, p_pic->p[i].i_visible_pitch);</div><div>+                p_src += p_pic->p[i].i_pitch;</div><div>+                p_dst += p_pic->p[i].i_visible_pitch;</div><div>+            }</div><div>         }</div><div>     }</div><div> }</div><div>@@ -715,7 +785,7 @@ static int ProcessOutputStream(decoder_t *p_dec, DWORD stream_id)</div><div>             goto error;</div><div> </div><div>         if (p_dec->fmt_in.i_cat == VIDEO_ES)</div><div>-            CopyPackedBufferToPicture(picture, buffer_start);</div><div>+            CopyPackedBufferToPicture(picture, buffer_start, p_sys->flipped);</div><div>         else</div><div>             memcpy(aout_buffer->p_buffer, buffer_start, total_length);</div><div> </div><div>@@ -1046,6 +1116,12 @@ static int FindMFT(decoder_t *p_dec)</div><div>         category = MFT_CATEGORY_VIDEO_DECODER;</div><div>         p_sys->major_type = &MFMediaType_Video;</div><div>         p_sys->subtype = FormatToGUID(video_format_table, p_dec->fmt_in.i_codec);</div><div>+        if(!p_sys->subtype) {</div><div>+            /* Codec is not well known. Construct a MF transform subtype from the fourcc */</div><div>+            p_sys->custom_subtype = MFVideoFormat_Base;</div><div>+            p_sys->custom_subtype.Data1 = p_dec->fmt_in.i_codec;</div><div>+            p_sys->subtype = &p_sys->custom_subtype;</div><div>+        }</div><div>     }</div><div>     else</div><div>     {</div><div>-- </div><div>2.14.1</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 4, 2018 at 5:45 PM, Jean-Baptiste Kempf <span dir="ltr"><<a href="mailto:jb@videolan.org" target="_blank">jb@videolan.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>





<div><div style="font-family:helvetica,arial,sans-serif">Hello,<br></div><span class="gmail-">
<div><br></div>
<div>On Sun, 4 Mar 2018, at 15:11, Teemu Ikonen wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div><div style="font-family:helvetica,arial,sans-serif"><br></div>
<div><div style="font-family:helvetica,arial,sans-serif">On Sun, Mar 4, 2018 at 2:06 PM, Jean-Baptiste Kempf <span dir="ltr"><<a href="mailto:jb@videolan.org" target="_blank">jb@videolan.org</a>></span> wrote:<br></div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="font-family:helvetica,arial,sans-serif"><u></u><br></div>
<div><div style="font-family:helvetica,arial,sans-serif">Hello,<br></div>
<div style="font-family:helvetica,arial,sans-serif"><span></span><br></div>
<div><span></span><br></div>
<div><span>On Sun, 4 Mar 2018, at 11:53, Teemu Ikonen wrote:</span><br></div>
<blockquote type="cite"><div dir="ltr"><div><span>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. </span><br></div>
</div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><span></span><br></div>
<div style="font-family:helvetica,arial,sans-serif"><span></span><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>
</blockquote><div><br></div>
<div><span class="gmail-m_3877249314687416256highlight" style="background-color:rgb(255,255,255)"><span class="gmail-m_3877249314687416256colour" style="color:rgb(34,34,34)"><span class="gmail-m_3877249314687416256font" style="font-family:arial,sans-serif"><span class="gmail-m_3877249314687416256size" style="font-size:small">Typical use case for them is to allow Windows Media Player to play videos with custom vendor codecs (camera and instrument manufacturers, research, ..).</span></span></span></span> <br></div>
<div>I've done few decoders to support Windows Media Player to play formats (e.g. Y800) and noticed it would be easy to extend VLC mft module to use any MFT compatible decoder instead of only ones in the hardcoded list. (H264, WM9, ..).<br></div>
</div>
</div>
</div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><br></div>
</span><div style="font-family:helvetica,arial,sans-serif">Sure, but I thought maybe you had more precise examples than Y800 (which is just a pixel format, IIRC).<br></div>
<div style="font-family:helvetica,arial,sans-serif"><br></div>
<div style="font-family:helvetica,arial,sans-serif">But ok.<br></div><span class="gmail-">
<div style="font-family:helvetica,arial,sans-serif"><span></span><br></div>
<blockquote type="cite"><div dir="ltr"><div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><blockquote type="cite"><div dir="ltr"><div><span>Internal formats (like MFVideoFormat_RGB32) are bottom up (negative stride). Code just changes the to <span class="gmail-m_3877249314687416256highlight" style="background-color:rgb(255,255,255)"><span class="gmail-m_3877249314687416256colour" style="color:rgb(34,34,34)"><span class="gmail-m_3877249314687416256font" style="font-family:arial,sans-serif"><span class="gmail-m_3877249314687416256size" style="font-size:small">ORIENT_BOTTOM_LEFT in this case and it works, but is this the right thing do?</span></span></span></span></span><br></div>
</div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><span></span><br></div>
<div style="font-family:helvetica,arial,sans-serif">Did you look at the avi code?<br></div>
</div>
</blockquote><div><br></div>
<div>No. I know that the bitmapinfo header member biHeight in AVI stream format can define the orientation but not sure how it applies. AFAIK it's ignored if payload FCC is anything else than 'DIB '. <br></div>
</div>
</div>
</div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><br></div>
</span><div style="font-family:helvetica,arial,sans-serif">In modules/demux/avi/avi.c, we memcpy line by line in those cases (l. 967).<br></div>
<div style="font-family:helvetica,arial,sans-serif"><br></div>
<div style="font-family:helvetica,arial,sans-serif">ORIENT should work, though, but not in all cases (transcoding, maybe)<br></div><span class="gmail-">
<div style="font-family:helvetica,arial,sans-serif"><br></div>
<blockquote type="cite"><div dir="ltr"><div><div><div>This is more a problem of mapping raw RGB format of MF decoder to VLC RGB format. <span class="gmail-m_3877249314687416256highlight" style="background-color:rgb(255,255,255)"><span class="gmail-m_3877249314687416256colour" style="color:rgb(34,34,34)"><span class="gmail-m_3877249314687416256font" style="font-family:arial,sans-serif"><span class="gmail-m_3877249314687416256size" style="font-size:small">Microsoft recommends that MFT Decoders support NV12 as common format but it's optional and custom decoder probably outputs just raw RGB that works fine and all the example code does that.</span></span></span></span><br></div>
</div>
</div>
</div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><br></div>
</span><div style="font-family:helvetica,arial,sans-serif">Seems good to me.<br></div><span class="gmail-">
<div style="font-family:helvetica,arial,sans-serif"><span class="gmail-m_3877249314687416256highlight" style="background-color:rgb(255,255,255)"><span class="gmail-m_3877249314687416256colour" style="color:rgb(34,34,34)"><span class="gmail-m_3877249314687416256font" style="font-family:arial,sans-serif"><span class="gmail-m_3877249314687416256size" style="font-size:small"></span></span></span></span><br></div>
<blockquote type="cite"><div dir="ltr"><div><div><div><span class="gmail-m_3877249314687416256highlight" style="background-color:rgb(255,255,255)"><span class="gmail-m_3877249314687416256colour" style="color:rgb(34,34,34)"><span class="gmail-m_3877249314687416256font" style="font-family:arial,sans-serif"><span class="gmail-m_3877249314687416256size" style="font-size:small">Thank you for the interest!</span></span></span></span><br></div>
</div>
</div>
</div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><br></div>
</span><div style="font-family:helvetica,arial,sans-serif">Thanks for your work.<br></div>
<div style="font-family:helvetica,arial,sans-serif"><br></div>
<div style="font-family:helvetica,arial,sans-serif">Best,<br></div><div><div class="gmail-h5">
<div style="font-family:helvetica,arial,sans-serif"><br></div>
<blockquote type="cite"><div dir="ltr"><div><div><div> <br></div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:helvetica,arial,sans-serif"><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><div><div dir="ltr"><div><br></div>
<div>---<br></div>
<div> modules/codec/mft.c | 66 ++++++++++++++++++++++++++++++<wbr>+++++++++++++++++++----<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_MAJO<wbr>R) && __MINGW64_VERSION_MAJOR < 4<br></div>
<div> DEFINE_GUID(MFAudioFormat_Dol<wbr>by_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_m<wbr>edia_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_ra<wbr>te;<br></div>
<div>+        UINT64 frame_ratio_dem = p_dec->fmt_in.video.i_frame_ra<wbr>te_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_m<wbr>edia_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_GetOutputAvailabl<wbr>eType(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<wbr>_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.orientati<wbr>on = ORIENT_BOTTOM_LEFT;<br></div>
<div>+        } else {<br></div>
<div>+            fcc = vlc_fourcc_GetCodec(p_dec->fmt<wbr>_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_tabl<wbr>e, 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>
</div>
<div><u>______________________________<wbr>_________________</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" target="_blank">https://mailman.videolan.org/l<wbr>istinfo/vlc-devel</a><br></div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><br></div>
<div><div>--<br></div>
<div>Jean-Baptiste Kempf -  President<br></div>
<div>+33 672 704 734<br></div>
<div> <br></div>
<div><br></div>
</div>
<div style="font-family:helvetica,arial,sans-serif"><br></div>
</div>
</blockquote></div>
</div>
</div>
</blockquote><div style="font-family:helvetica,arial,sans-serif"><br></div>
<div id="gmail-m_3877249314687416256sig60240713"><div class="gmail-m_3877249314687416256signature">--<br></div>
<div class="gmail-m_3877249314687416256signature">Jean-Baptiste Kempf -  President<br></div>
<div class="gmail-m_3877249314687416256signature">+33 672 704 734<br></div>
<div class="gmail-m_3877249314687416256signature"> <br></div>
<div class="gmail-m_3877249314687416256signature"><br></div>
</div>
<div style="font-family:helvetica,arial,sans-serif"><br></div>
</div></div></div>

</blockquote></div><br></div></div></div>