V4L2DecodeInterface: add C2_PARAMKEY_OUTPUT_DELAY for H264 C2_PARAMKEY_OUTPUT_DELAY is the number of additional output frames that needs to be generated before an output can be released by the component. H264 may reorder the output frames, so we set C2_PARAMKEY_OUTPUT_DELAY to the possible maximum number of reoder frames. Bug: 153403351 Test: pass E2E test TestSimpleDecode for H264 Change-Id: I13ad1dc60bb8674e09250163ec6c6b186fec26a4
diff --git a/components/V4L2DecodeInterface.cpp b/components/V4L2DecodeInterface.cpp index c83d297..487a70f 100644 --- a/components/V4L2DecodeInterface.cpp +++ b/components/V4L2DecodeInterface.cpp
@@ -56,6 +56,21 @@ return kInputBufferSizeFor1080p; } +uint32_t getOutputDelay(VideoCodec codec) { + switch (codec) { + case VideoCodec::H264: + // Due to frame reordering an H264 decoder might need multiple additional input frames to be + // queued before being able to output the associated decoded buffers. We need to tell the + // codec2 framework that it should not stop queuing new work items until the maximum number + // of frame reordering is reached, to avoid stalling the decoder. + return 16; + case VideoCodec::VP8: + return 0; + case VideoCodec::VP9: + return 0; + } +} + } // namespace // static @@ -211,6 +226,10 @@ .withConstValue( new C2StreamBufferTypeSetting::output(0u, C2BufferData::GRAPHIC)) .build()); + addParameter( + DefineParam(mOutputDelay, C2_PARAMKEY_OUTPUT_DELAY) + .withConstValue(new C2PortDelayTuning::output(getOutputDelay(*mVideoCodec))) + .build()); addParameter(DefineParam(mInputMediaType, C2_PARAMKEY_INPUT_MEDIA_TYPE) .withConstValue(AllocSharedString<C2PortMediaTypeSetting::input>(