media: fix "prepend-sps-pps-to-idr-frames" behavior
- Add constant.
- ACodec: Check for support only for video encoders, ignore otherwise.
- codec2: fix C2PrependHeaderModeSetting definition.
- CCodec: fail configure if the feature is not supported.
- CCodec: fix mapping between SDK and codec2
Bug: 32746212
Test: atest CtsMediaTestCases:MediaCodecTest#testPrependHeadersToSyncFrames
Change-Id: I8b86b4c8c139d6addbafc1a3558c640b1add42c9
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 8474ce8..8a2b3fe 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -859,11 +859,12 @@
std::vector<std::unique_ptr<C2Param>> params;
C2StreamUsageTuning::input usage(0u, 0u);
C2StreamMaxBufferSizeInfo::input maxInputSize(0u, 0u);
+ C2PrependHeaderModeSetting prepend(PREPEND_HEADER_TO_NONE);
std::initializer_list<C2Param::Index> indices {
};
c2_status_t c2err = comp->query(
- { &usage, &maxInputSize },
+ { &usage, &maxInputSize, &prepend },
indices,
C2_DONT_BLOCK,
¶ms);
@@ -931,6 +932,16 @@
}
}
+ int32_t clientPrepend;
+ if ((config->mDomain & Config::IS_VIDEO)
+ && (config->mDomain & Config::IS_ENCODER)
+ && msg->findInt32(KEY_PREPEND_HEADERS_TO_SYNC_FRAMES, &clientPrepend)
+ && clientPrepend
+ && (!prepend || prepend.value != PREPEND_HEADER_TO_ALL_SYNC)) {
+ ALOGE("Failed to set KEY_PREPEND_HEADERS_TO_SYNC_FRAMES");
+ return BAD_VALUE;
+ }
+
if ((config->mDomain & (Config::IS_VIDEO | Config::IS_IMAGE))) {
// propagate HDR static info to output format for both encoders and decoders
// if component supports this info, we will update from component, but only the raw port,