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

Commit c073b574 authored by Yushin Cho's avatar Yushin Cho Committed by Gerrit Code Review
Browse files

Merge changes from topic "Video Enc Stats for T"

* changes:
  enc stat: map encoding stat level to enc stats
  enc stat: Add corresponding MediaFormat keys to Ndk
  enc stat: Add Encoding Statistics keys to CCodecConfig
  enc stat: Add Encoding Statistics keys to Codec2 layer
parents 3c401859 91873b54
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -270,6 +270,9 @@ enum C2ParamIndexKind : C2Param::type_index_t {

    // encoding quality requirements
    kParamIndexEncodingQualityLevel, // encoders, enum

    // encoding statistics, average block qp of a frame
    kParamIndexAverageBlockQuantization, // int32
};

}
@@ -2411,6 +2414,17 @@ C2ENUM(C2PlatformConfig::encoding_quality_level_t, uint32_t,
    S_HANDHELD = 1              // corresponds to VMAF=70
);

/**
 * Video Encoding Statistics Export
 */

/**
 * Average block QP exported from video encoder.
 */
typedef C2StreamParam<C2Info, C2SimpleValueStruct<int32_t>, kParamIndexAverageBlockQuantization>
        C2AndroidStreamAverageBlockQuantizationInfo;
constexpr char C2_PARAMKEY_AVERAGE_QP[] = "coded.average-qp";

/// @}

#endif  // C2CONFIG_H_
+21 −0
Original line number Diff line number Diff line
@@ -1443,6 +1443,27 @@ void CCodec::configure(const sp<AMessage> &msg) {
            config->mOutputFormat->setInt32("android._tunneled", 1);
        }

        // Convert an encoding statistics level to corresponding encoding statistics
        // kinds
        int32_t encodingStatisticsLevel = VIDEO_ENCODING_STATISTICS_LEVEL_NONE;
        if ((config->mDomain & Config::IS_ENCODER)
            && (config->mDomain & Config::IS_VIDEO)
            && msg->findInt32(KEY_VIDEO_ENCODING_STATISTICS_LEVEL, &encodingStatisticsLevel)) {
            // Higher level include all the enc stats belong to lower level.
            switch (encodingStatisticsLevel) {
                // case VIDEO_ENCODING_STATISTICS_LEVEL_2: // reserved for the future level 2
                                                           // with more enc stat kinds
                // Future extended encoding statistics for the level 2 should be added here
                case VIDEO_ENCODING_STATISTICS_LEVEL_1:
                    config->subscribeToConfigUpdate(comp,
                        {kParamIndexAverageBlockQuantization, kParamIndexPictureType});
                    break;
                case VIDEO_ENCODING_STATISTICS_LEVEL_NONE:
                    break;
            }
        }
        ALOGD("encoding statistics level = %d", encodingStatisticsLevel);

        ALOGD("setup formats input: %s",
                config->mInputFormat->debugString().c_str());
        ALOGD("setup formats output: %s",
+6 −0
Original line number Diff line number Diff line
@@ -953,6 +953,12 @@ void CCodecConfig::initializeStandardParams() {
            return value == 0 ? C2_FALSE : C2_TRUE;
        }));

    add(ConfigMapper(KEY_VIDEO_QP_AVERAGE, C2_PARAMKEY_AVERAGE_QP, "value")
        .limitTo(D::ENCODER & D::VIDEO & D::READ));

    add(ConfigMapper(KEY_PICTURE_TYPE, C2_PARAMKEY_PICTURE_TYPE, "value")
        .limitTo(D::ENCODER & D::VIDEO & D::READ));

    /* still to do
    constexpr char KEY_PUSH_BLANK_BUFFERS_ON_STOP[] = "push-blank-buffers-on-shutdown";

+5 −5
Original line number Diff line number Diff line
@@ -363,11 +363,6 @@ struct CCodecConfig {
            const std::vector<std::string> &names,
            c2_blocking_t blocking = C2_DONT_BLOCK);

private:

    /// initializes the standard MediaCodec to Codec 2.0 params mapping
    void initializeStandardParams();

    /// Adds indices to the subscribed indices, and updated subscription to component
    /// \param blocking blocking mode to use with the component
    status_t subscribeToConfigUpdate(
@@ -375,6 +370,11 @@ private:
            const std::vector<C2Param::Index> &indices,
            c2_blocking_t blocking = C2_DONT_BLOCK);

private:

    /// initializes the standard MediaCodec to Codec 2.0 params mapping
    void initializeStandardParams();

    /// Gets SDK format from codec 2.0 reflected configuration
    /// \param domain input/output bitmask
    sp<AMessage> getFormatForDomain(
+12 −0
Original line number Diff line number Diff line
@@ -684,6 +684,7 @@ inline static const char *asString_ColorFormat(int32_t i, const char *def = "??"
}

constexpr char FEATURE_AdaptivePlayback[]       = "adaptive-playback";
constexpr char FEATURE_EncodingStatistics[]     = "encoding-statistics";
constexpr char FEATURE_IntraRefresh[] = "intra-refresh";
constexpr char FEATURE_PartialFrame[] = "partial-frame";
constexpr char FEATURE_QpBounds[] = "qp-bounds";
@@ -737,6 +738,14 @@ constexpr int32_t COLOR_TRANSFER_LINEAR = 1;
constexpr int32_t COLOR_TRANSFER_SDR_VIDEO = 3;
constexpr int32_t COLOR_TRANSFER_ST2084 = 6;

constexpr int32_t PICTURE_TYPE_I = 1;
constexpr int32_t PICTURE_TYPE_P = 2;
constexpr int32_t PICTURE_TYPE_B = 3;
constexpr int32_t PICTURE_TYPE_UNKNOWN = 0;

constexpr int32_t VIDEO_ENCODING_STATISTICS_LEVEL_1 = 1;
constexpr int32_t VIDEO_ENCODING_STATISTICS_LEVEL_NONE = 0;

constexpr char KEY_AAC_DRC_ALBUM_MODE[] = "aac-drc-album-mode";
constexpr char KEY_AAC_DRC_ATTENUATION_FACTOR[] = "aac-drc-cut-level";
constexpr char KEY_AAC_DRC_BOOST_FACTOR[] = "aac-drc-boost-level";
@@ -795,6 +804,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_PICTURE_TYPE[] = "picture_type";
constexpr char KEY_PIXEL_ASPECT_RATIO_HEIGHT[] = "sar-height";
constexpr char KEY_PIXEL_ASPECT_RATIO_WIDTH[] = "sar-width";
constexpr char KEY_PREPEND_HEADER_TO_SYNC_FRAMES[] = "prepend-sps-pps-to-idr-frames";
@@ -811,6 +821,8 @@ constexpr char KEY_TEMPORAL_LAYERING[] = "ts-schema";
constexpr char KEY_TILE_HEIGHT[] = "tile-height";
constexpr char KEY_TILE_WIDTH[] = "tile-width";
constexpr char KEY_TRACK_ID[] = "track-id";
constexpr char KEY_VIDEO_ENCODING_STATISTICS_LEVEL[] = "video-encoding-statistics-level";
constexpr char KEY_VIDEO_QP_AVERAGE[] = "video-qp-average";
constexpr char KEY_VIDEO_QP_B_MAX[] = "video-qp-b-max";
constexpr char KEY_VIDEO_QP_B_MIN[] = "video-qp-b-min";
constexpr char KEY_VIDEO_QP_I_MAX[] = "video-qp-i-max";
Loading