GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
596 stars 148 forks source link

[Question]: AMF MJPEG decoder returns NV12 with green bar #310

Open toruishihara opened 2 years ago

toruishihara commented 2 years ago

I use AMF MJPEG MFT for decoding MJPEG data from USB camera. I set input frame 320x240, output is 320x256 NV12, because vertical alignment is 32. Output NV12 frame has 16 extra lines. But Y and UV value of these line are all zero. That add high luminance green bar on bottom.

I can copy frame to CPU and remove 16 line and back to GPU, but it takes time. Because GPU-CPU copy is slow. It become slower than software MJPEG decoder.

I like to know one of these option is possible.

MFT DLL location on my Windows10 PC. C:\Windows\System32\DriverStore\FileRepository\u0361313.inf_amd64_07132764fbaf152d\B361334\amf-mft-mjpeg-decoder64.dll

MikhailAMD commented 2 years ago

This is not unique for MJPEG but rather common for all HW decoders: they need aligned output textures in video memory. Some codecs need 16 pixels, some like MJPEG - 32 pixels. Note, that it could be horizontal and/or vertical alignment. The common practice is that HW decoder returns cropping area and it is up to the calling app to deal with it (MF_MT_MINIMUM_DISPLAY_APERTURE for MFTs). Adding GPU copy for solely removing borders in the HW decoder is inefficient. As you said, using CPU to remove lines is also inefficient. The usual solution is, that the component after the decoder should recognize cropping and deal with it: if it is color converter, it should remove borders. But implementation depends on your pipeline. The next component could be Video Processor MFT (from MSFT) or your custom code. If the latter, you can run D3D11 compute shader to remove lines or combine the removal with other processing.