Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ca01d38 authored by Wonsik Kim's avatar Wonsik Kim
Browse files

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
parent 0e5a1b3b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1194,7 +1194,8 @@ C2ENUM(C2Config::prepend_header_mode_t, uint32_t,
    PREPEND_HEADER_TO_ALL_SYNC,
)

typedef C2GlobalParam<C2Setting, C2BoolValue, kParamIndexPrependHeaderMode>
typedef C2GlobalParam<C2Setting, C2SimpleValueStruct<C2Config::prepend_header_mode_t>,
                kParamIndexPrependHeaderMode>
        C2PrependHeaderModeSetting;
constexpr char C2_PARAMKEY_PREPEND_HEADER_MODE[] = "output.buffers.prepend-header";

+12 −1
Original line number Diff line number Diff line
@@ -859,11 +859,12 @@ void CCodec::configure(const sp<AMessage> &msg) {
        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,
                &params);
@@ -931,6 +932,16 @@ void CCodec::configure(const sp<AMessage> &msg) {
            }
        }

        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,
+19 −7
Original line number Diff line number Diff line
@@ -486,19 +486,31 @@ void CCodecConfig::initializeStandardParams() {
    add(ConfigMapper(std::string(KEY_FEATURE_) + FEATURE_SecurePlayback,
                     C2_PARAMKEY_SECURE_MODE, "value"));

    add(ConfigMapper("prepend-sps-pps-to-idr-frames",
    add(ConfigMapper(KEY_PREPEND_HEADERS_TO_SYNC_FRAMES,
                     C2_PARAMKEY_PREPEND_HEADER_MODE, "value")
        .limitTo(D::ENCODER & D::VIDEO)
        .withMapper([](C2Value v) -> C2Value {
        .withMappers([](C2Value v) -> C2Value {
            int32_t value;
            if (v.get(&value) && value) {
                return C2Value(C2Config::PREPEND_HEADER_TO_ALL_SYNC);
            } else {
                return C2Value(C2Config::PREPEND_HEADER_TO_NONE);
            if (v.get(&value)) {
                return value ? C2Value(C2Config::PREPEND_HEADER_TO_ALL_SYNC)
                             : C2Value(C2Config::PREPEND_HEADER_TO_NONE);
            }
            return C2Value();
        }, [](C2Value v) -> C2Value {
            C2Config::prepend_header_mode_t value;
            using C2ValueType=typename _c2_reduce_enum_to_underlying_type<decltype(value)>::type;
            if (v.get((C2ValueType *)&value)) {
                switch (value) {
                    case C2Config::PREPEND_HEADER_TO_NONE:      return 0;
                    case C2Config::PREPEND_HEADER_TO_ALL_SYNC:  return 1;
                    case C2Config::PREPEND_HEADER_ON_CHANGE:    [[fallthrough]];
                    default:                                    return C2Value();
                }
            }
            return C2Value();
        }));
    // remove when codecs switch to PARAMKEY
    deprecated(ConfigMapper("prepend-sps-pps-to-idr-frames",
    deprecated(ConfigMapper(KEY_PREPEND_HEADERS_TO_SYNC_FRAMES,
                            "coding.add-csd-to-sync-frames", "value")
               .limitTo(D::ENCODER & D::VIDEO));
    // convert to timestamp base
+1 −1
Original line number Diff line number Diff line
@@ -1776,7 +1776,7 @@ status_t ACodec::configureCodec(
    }

    int32_t prependSPSPPS = 0;
    if (encoder
    if (encoder && mIsVideo
            && msg->findInt32("prepend-sps-pps-to-idr-frames", &prependSPSPPS)
            && prependSPSPPS != 0) {
        OMX_INDEXTYPE index;
+1 −0
Original line number Diff line number Diff line
@@ -783,6 +783,7 @@ constexpr char KEY_MIME[] = "mime";
constexpr char KEY_OPERATING_RATE[] = "operating-rate";
constexpr char KEY_OUTPUT_REORDER_DEPTH[] = "output-reorder-depth";
constexpr char KEY_PCM_ENCODING[] = "pcm-encoding";
constexpr char KEY_PREPEND_HEADERS_TO_SYNC_FRAMES[] = "prepend-sps-pps-to-idr-frames";
constexpr char KEY_PRIORITY[] = "priority";
constexpr char KEY_PROFILE[] = "profile";
constexpr char KEY_PUSH_BLANK_BUFFERS_ON_STOP[] = "push-blank-buffers-on-shutdown";