<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Mark,</p>
    <p>I did misread that bit of documentation, thanks! <br>
    </p>
    <p>I'm trying to understand the supported_formats array found in <a
        moz-do-not-send="true"
href="https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/hwcontext_cuda.c#L35">hwcontext_cuda.c</a>.
      Can the hw context be initialized so that the decoder returns
      YUV420P instead of NV12?<br>
    </p>
    <div class="moz-signature">
      <p>Saludos / Best regards, <br>
        <br>
        <b>Sergio Basurco</b> <br>
        Coherent Synchro</p>
    </div>
    <div class="moz-cite-prefix">On 05/06/2018 22:23, Mark Thompson
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:9984439a-bfaf-2a3e-6079-513bf0c0713e@jkqxz.net">
      <pre wrap="">On 05/06/18 11:15, Sergio Basurco wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">I'm decoding h264 with ffmpeg. I want to use the hwaccel decoders. I'm using the cuvid decoder via API. In the fftools code there's a function "hwaccel_retrieve_data" that is supposed to convert the decoded frame (NV12) into any other format, I'm trying YUV420P.

The conversion does not return any error, however the resulting data is not correct. Here's the original NV12 frame:

<a class="moz-txt-link-freetext" href="https://imgur.com/a/jAb8h12">https://imgur.com/a/jAb8h12</a>

And here's the conversion to YUV420P (only avframe->data[0] and avframe->data[1] have any data, data[2] is expected to have the V data but it is missing).

<a class="moz-txt-link-freetext" href="https://imgur.com/a/ihQeJ0M">https://imgur.com/a/ihQeJ0M</a>


I think I'm on the right track, based on the code in hwcontext_cuda.c aparently YUV420P is a supported format, I cannot get my head around how I can tell the decoder to convert from NV12 to YUV420P though.

Any tips will be appreciated, I'll update if I find anything.
</pre>
      </blockquote>
      <pre wrap="">
See the documentation for av_hwframe_transfer_data() (<a class="moz-txt-link-rfc2396E" href="http://ffmpeg.org/doxygen/trunk/hwcontext_8h.html#abf1b1664b8239d953ae2cac8b643815a"><http://ffmpeg.org/doxygen/trunk/hwcontext_8h.html#abf1b1664b8239d953ae2cac8b643815a></a>), in particular:

"If src has an AVHWFramesContext attached, then the format of dst (if set) must use one of the formats returned by av_hwframe_transfer_get_formats(src, AV_HWFRAME_TRANSFER_DIRECTION_FROM). If dst has an AVHWFramesContext attached, then the format of src must use one of the formats returned by av_hwframe_transfer_get_formats(dst, AV_HWFRAME_TRANSFER_DIRECTION_TO)"

For CUDA, no conversion during transfer is supported so the only usable output format returned by av_hwframe_transfer_get_formats() is the same format as the GPU-side frame itself (NV12 in your case): <a class="moz-txt-link-rfc2396E" href="http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavutil/hwcontext_cuda.c#l176"><http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavutil/hwcontext_cuda.c#l176></a>.

- Mark
_______________________________________________
Libav-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a>
<a class="moz-txt-link-freetext" href="http://ffmpeg.org/mailman/listinfo/libav-user">http://ffmpeg.org/mailman/listinfo/libav-user</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>