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

Commit 4aef0de9 authored by Linus Nilsson's avatar Linus Nilsson
Browse files

Transcoder: Default benchmark to AVC output.

Also fixes an issue where floating point operating-rate got
overwritten.

Fixes: 178876290
Test: Running benchmark, verifying output.
Change-Id: Icc4e7adf139c5d99238b955925bf1ec5ce185f7f
parent 82aff675
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -238,7 +238,12 @@ media_status_t VideoTrackTranscoder::configureDestinationFormat(
    int32_t operatingRate = getDefaultOperatingRate(encoderFormat);

    if (operatingRate != -1) {
        SetDefaultFormatValueInt32(AMEDIAFORMAT_KEY_OPERATING_RATE, encoderFormat, operatingRate);
        float tmpf;
        int32_t tmpi;
        if (!AMediaFormat_getFloat(encoderFormat, AMEDIAFORMAT_KEY_OPERATING_RATE, &tmpf) &&
            !AMediaFormat_getInt32(encoderFormat, AMEDIAFORMAT_KEY_OPERATING_RATE, &tmpi)) {
            AMediaFormat_setInt32(encoderFormat, AMEDIAFORMAT_KEY_OPERATING_RATE, operatingRate);
        }
    }

    SetDefaultFormatValueInt32(AMEDIAFORMAT_KEY_PRIORITY, encoderFormat, kDefaultCodecPriority);
+3 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <binder/ProcessState.h>
#include <fcntl.h>
#include <media/MediaTranscoder.h>
#include <media/NdkCommon.h>

#include <iostream>

@@ -87,6 +88,7 @@ static AMediaFormat* CreateDefaultVideoFormat() {

    AMediaFormat* videoFormat = AMediaFormat_new();
    AMediaFormat_setInt32(videoFormat, AMEDIAFORMAT_KEY_BIT_RATE, kVideoBitRate);
    AMediaFormat_setString(videoFormat, AMEDIAFORMAT_KEY_MIME, AMEDIA_MIMETYPE_VIDEO_AVC);
    return videoFormat;
}

@@ -222,7 +224,7 @@ static void TranscodeMediaFile(benchmark::State& state, const std::string& srcFi
}

static void SetMaxOperatingRate(AMediaFormat* format) {
    AMediaFormat_setFloat(format, AMEDIAFORMAT_KEY_OPERATING_RATE, INT32_MAX);
    AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_OPERATING_RATE, INT32_MAX);
    AMediaFormat_setInt32(format, AMEDIAFORMAT_KEY_PRIORITY, 1);
}