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

Commit 51b94f9e authored by Linus Nilsson's avatar Linus Nilsson Committed by Android (Google) Code Review
Browse files

Merge "Transcoder: Add HDR -> SDR unit test using sample plugin." into sc-dev

parents 587f5496 52df71c2
Loading
Loading
Loading
Loading
+579 KiB

File added.

No diff preview for this file type.

+25 −6
Original line number Diff line number Diff line
@@ -145,12 +145,12 @@ struct AsyncCodecCallbackDispatch {
        VideoTrackTranscoder::CodecWrapper* wrapper =
                static_cast<VideoTrackTranscoder::CodecWrapper*>(userdata);
        if (auto transcoder = wrapper->getTranscoder()) {
            const char* kCodecName = (codec == transcoder->mDecoder ? "Decoder" : "Encoder");
            const bool isDecoder = codec == transcoder->mDecoder;
            const char* kCodecName = (isDecoder ? "Decoder" : "Encoder");
            LOG(DEBUG) << kCodecName << " format changed: " << AMediaFormat_toString(format);
            if (codec == transcoder->mEncoder->getCodec()) {
                transcoder->mCodecMessageQueue.push(
                        [transcoder, format] { transcoder->updateTrackFormat(format); });
            }
            transcoder->mCodecMessageQueue.push([transcoder, format, isDecoder] {
                transcoder->updateTrackFormat(format, isDecoder);
            });
        }
    }

@@ -507,7 +507,25 @@ void VideoTrackTranscoder::dequeueOutputSample(int32_t bufferIndex,
    }
}

void VideoTrackTranscoder::updateTrackFormat(AMediaFormat* outputFormat) {
void VideoTrackTranscoder::updateTrackFormat(AMediaFormat* outputFormat, bool fromDecoder) {
    if (fromDecoder) {
        static const AMediaFormatUtils::EntryCopier kValuesToCopy[] = {
                ENTRY_COPIER(AMEDIAFORMAT_KEY_COLOR_RANGE, Int32),
                ENTRY_COPIER(AMEDIAFORMAT_KEY_COLOR_STANDARD, Int32),
                ENTRY_COPIER(AMEDIAFORMAT_KEY_COLOR_TRANSFER, Int32),
        };
        AMediaFormat* params = AMediaFormat_new();
        if (params != nullptr) {
            AMediaFormatUtils::CopyFormatEntries(outputFormat, params, kValuesToCopy,
                                                 std::size(kValuesToCopy));
            if (AMediaCodec_setParameters(mEncoder->getCodec(), params) != AMEDIA_OK) {
                LOG(WARNING) << "Unable to update encoder with color information";
            }
            AMediaFormat_delete(params);
        }
        return;
    }

    if (mActualOutputFormat != nullptr) {
        LOG(WARNING) << "Ignoring duplicate format change.";
        return;
@@ -571,6 +589,7 @@ void VideoTrackTranscoder::updateTrackFormat(AMediaFormat* outputFormat) {
    // TODO: transfer other fields as required.

    mActualOutputFormat = std::shared_ptr<AMediaFormat>(formatCopy, &AMediaFormat_delete);
    LOG(DEBUG) << "Actual output format: " << AMediaFormat_toString(formatCopy);

    notifyTrackFormatAvailable();
}
+2 −2
Original line number Diff line number Diff line
@@ -83,8 +83,8 @@ private:
    // Dequeues an encoded buffer from the encoder and adds it to the output queue.
    void dequeueOutputSample(int32_t bufferIndex, AMediaCodecBufferInfo bufferInfo);

    // Updates the video track's actual format based on encoder output format.
    void updateTrackFormat(AMediaFormat* outputFormat);
    // Updates the video track's actual format based on encoder and decoder output format.
    void updateTrackFormat(AMediaFormat* outputFormat, bool fromDecoder);

    AMediaCodec* mDecoder = nullptr;
    std::shared_ptr<CodecWrapper> mEncoder;
+15 −5
Original line number Diff line number Diff line
@@ -2,19 +2,29 @@

if [ $# -ne 1 ]
then
    echo Usage: $0 loglevel
    echo "Usage 1: $0 <loglevel>"
    echo "  Set all transcoder log tags to <loglevel>"
    echo "Usage 2: $0 -l"
    echo "  List all transcoder log tags and exit"
    exit 1
fi

level=$1
echo Setting transcoder log level to $level

# List all log tags
declare -a tags=(
  MediaTranscoder MediaTrackTranscoder VideoTrackTranscoder PassthroughTrackTranscoder
  MediaSampleWriter MediaSampleReader MediaSampleQueue MediaTranscoderTests
  MediaTrackTranscoderTests VideoTrackTranscoderTests PassthroughTrackTranscoderTests
  MediaSampleWriterTests MediaSampleReaderNDKTests MediaSampleQueueTests)
  MediaSampleWriterTests MediaSampleReaderNDKTests MediaSampleQueueTests HdrTranscodeTests)

if [ "$1" == "-l" ]; then
  echo "Transcoder log tags:"
  for tag in "${tags[@]}"; do echo -n "$tag "; done
  echo
  exit 0
fi

level=$1
echo Setting transcoder log level to $level

# Set log level for all tags
for tag in "${tags[@]}"
+7 −0
Original line number Diff line number Diff line
@@ -89,6 +89,13 @@ cc_test {
    srcs: ["MediaSampleWriterTests.cpp"],
}

// HDR Transcode unit test
cc_test {
    name: "HdrTranscodeTests",
    defaults: ["testdefaults"],
    srcs: ["HdrTranscodeTests.cpp"],
}

// MediaTranscoder unit test
cc_test {
    name: "MediaTranscoderTests",
Loading