dxva2 decode h264 output format

老周 杂家 1 Reputation point
2020-08-30T06:03:49.01+00:00

when I use dxva2 decode h264 in ffmpeg,the output format in surface sometimes is nv12,and sometime is nv21,how can I know which format is .D3DSURFACE_DESC Format is same.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,636 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,743 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Rita Han - MSFT 2,166 Reputation points
    2020-09-02T03:02:42.967+00:00

    Hello,

    There is a need to convert NV12 / NV21 to D3D supported surface format like D3DFMT_R8G8B8.

    NV21 is same as NV12, except that Cb and Cr samples are swapped. All you need to do, is to reverse the order.

    More references: "Recommended 8-Bit YUV Formats for Video Rendering", "Color Converter DSP" and "DirectXMath Library color functions ( XMColorYUVToRGB )"

    Thank you!

    0 comments No comments

  2. 老周 杂家 1 Reputation point
    2020-09-02T05:06:11.167+00:00

    FFMPEG call dxva2 APIs decode h264 and return D3D surface,D3DSURFACE_DESC Format is same while decoed frame is NV12 or NV21,if I scale and convert the source frame(include format convert) to NV12,output format and frame data are right.but this will Increase CPU consumption.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.