diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index 9868733c..619917b7 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -796,6 +796,19 @@ bool FFmpegVideoDecoder::tryInitializeRenderer(const AVCodec* decoder, const AVCodecHWConfig* hwConfig, std::function createRendererFunc) { + DECODER_PARAMETERS testFrameDecoderParams = *params; + + // Setup the test decoder parameters using the dimensions for the test frame. These are + // used to populate the AVCodecContext fields of the same names. + // + // While most decoders don't care what dimensions we specify here, V4L2M2M seems to puke + // if we pass whatever the native stream resolution is then decode a 720p test frame. + // + // For qcom-venus, it seems to lead to failures allocating capture buffers (bug #1042). + // For wave5 (VisionFive), it leads to an invalid pitch error when calling drmModeAddFB2(). + testFrameDecoderParams.width = 1280; + testFrameDecoderParams.height = 720; + m_HwDecodeCfg = hwConfig; // i == 0 - Indirect via EGL or DRM frontend with zero-copy DMA-BUF passing @@ -807,8 +820,8 @@ bool FFmpegVideoDecoder::tryInitializeRenderer(const AVCodec* decoder, #endif SDL_assert(m_BackendRenderer == nullptr); if ((m_BackendRenderer = createRendererFunc()) != nullptr && - m_BackendRenderer->initialize(params) && - completeInitialization(decoder, params, m_TestOnly || m_BackendRenderer->needsTestFrame(), i == 0 /* EGL/DRM */)) { + m_BackendRenderer->initialize(m_BackendRenderer->needsTestFrame() ? &testFrameDecoderParams : params) && + completeInitialization(decoder, m_BackendRenderer->needsTestFrame() ? &testFrameDecoderParams : params, m_TestOnly || m_BackendRenderer->needsTestFrame(), i == 0 /* EGL/DRM */)) { if (m_TestOnly) { // This decoder is only for testing capabilities, so don't bother // creating a usable renderer diff --git a/app/streaming/video/ffmpeg_videosamples.cpp b/app/streaming/video/ffmpeg_videosamples.cpp index f3f7e944..66f0f8c1 100644 --- a/app/streaming/video/ffmpeg_videosamples.cpp +++ b/app/streaming/video/ffmpeg_videosamples.cpp @@ -1,5 +1,8 @@ #include "ffmpeg.h" +// NOTE: All test frames MUST be 720p in order for us to provide the correct dimensions in the AVCodecContext! +// See FFmpegVideoDecoder::tryInitializeRenderer() for details. + // 720p 60 FPS H.264 with 1 reference frame const uint8_t FFmpegVideoDecoder::k_H264TestFrame[] = { 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x20, 0xac, 0x2b, 0x40, 0x28, 0x02, 0xdd, 0x80, 0xb5, 0x06, 0x06, 0x06, 0xa5, 0x00, 0x00, 0x03, 0x03, 0xe8, 0x00, 0x01, 0xd4, 0xc0, 0x8f, 0x4a, 0xa0,