title: libav: where to get a reference to AV_PIX_FMT_NV12 when using cuda/cuvid?
body: <p>Say I'm using <code>av_hwdevice_find_type_by_name("cuda")</code>, as in <a href="https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/hw_decode.c#L165" rel="nofollow noreferrer">here</a>. I need to convert the decoded frames to RGB using a <code>SwsContext</code>. I know, by experience, that when using the cuda/cuvid decoder I get frames in the <code>AV_PIX_FMT_NV12</code> format, even though every struct I look at says either <code>AV_PIX_FMT_NONE</code> or <code>AV_PIX_FMT_YUV420P</code>.</p>
  
  <p>On what field of what struct can I get the <code>AV_PIX_FMT_NV12</code> value so I can remove my hardcoded source format on my call to <code>SwsContext.sws_scale</code>? Thanks!</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Looks like I can get it by:</p>
  
  <pre><code>AVCodecContext* avctx;
  ...
  frames_ctx = (AVHWFramesContext*)avctx-&gt;hw_frames_ctx-&gt;data;
  AVPixelFormat pixel_fmt = frames_ctx-&gt;sw_format;
  </code></pre>
  
  <p>...once at least one frame has been decoded. Not sure if it's the correct way though.</p>