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

Commit 47594d4b authored by Wonsik Kim's avatar Wonsik Kim
Browse files

codec2: read codec capabilities for c2.* components

Test: adb push frameworks/av/media/libstagefright/data/media_codecs_google_c2_*.xml /etc/
Test: adb push frameworks/av/media/libstagefright/data/media_codecs_google_c2.xml /etc/media_codecs_c2.xml
Test: setprop debug.stagefright.ccodec yes
Test: killall mediaserver
Test: cts-tradefed run cts -m CtsMediaTestCases -t android.media.cts.MediaCodecListTest
Change-Id: I131164a6c210cbafc1f989b22c56eebb1560d860
parent 78165d3f
Loading
Loading
Loading
Loading
+34 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include <cutils/properties.h>
#include <media/stagefright/foundation/MediaDefs.h>
#include <media/stagefright/xmlparser/MediaCodecsXmlParser.h>
#include <media/stagefright/Codec2InfoBuilder.h>

namespace android {
@@ -51,14 +52,45 @@ status_t Codec2InfoBuilder::buildMediaCodecList(MediaCodecListWriter* writer) {
        }
    }

    MediaCodecsXmlParser parser(
            MediaCodecsXmlParser::defaultSearchDirs,
            "media_codecs_c2.xml");
    if (parser.getParsingStatus() != OK) {
        ALOGD("XML parser no good");
        return OK;
    }
    for (const ConstTraitsPtr &trait : traits) {
        if (parser.getCodecMap().count(trait->name.c_str()) == 0) {
            ALOGD("%s not found in xml", trait->name.c_str());
            continue;
        }
        const MediaCodecsXmlParser::CodecProperties &codec = parser.getCodecMap().at(trait->name);
        std::unique_ptr<MediaCodecInfoWriter> codecInfo = writer->addMediaCodecInfo();
        codecInfo->setName(trait->name.c_str());
        codecInfo->setOwner("dummy");
        // TODO: get this from trait->kind
        codecInfo->setEncoder(trait->name.find("encoder") != std::string::npos);
        bool encoder = (trait->name.find("encoder") != std::string::npos);
        codecInfo->setEncoder(encoder);
        codecInfo->setRank(trait->rank);
        (void)codecInfo->addMime(trait->mediaType.c_str());
        for (auto typeIt = codec.typeMap.begin(); typeIt != codec.typeMap.end(); ++typeIt) {
            const std::string &mediaType = typeIt->first;
            const MediaCodecsXmlParser::AttributeMap &attrMap = typeIt->second;
            std::unique_ptr<MediaCodecInfo::CapabilitiesWriter> caps =
                codecInfo->addMime(mediaType.c_str());
            for (auto attrIt = attrMap.begin(); attrIt != attrMap.end(); ++attrIt) {
                std::string key, value;
                std::tie(key, value) = *attrIt;
                if (key.find("feature-") == 0 && key.find("feature-bitrate-modes") != 0) {
                    caps->addDetail(key.c_str(), std::stoi(value));
                } else {
                    caps->addDetail(key.c_str(), value.c_str());
                }
            }
            // TODO: get this from intf().
            if (mediaType.find("video") != std::string::npos && !encoder) {
                caps->addColorFormat(0x7F420888);  // COLOR_FormatYUV420Flexible
            }
        }
    }
    return OK;
}
+19 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2018 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<MediaCodecs>
    <Include href="media_codecs_google_c2_audio.xml" />
    <Include href="media_codecs_google_c2_video.xml" />
</MediaCodecs>
+97 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (C) 2014 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<Included>
    <Decoders>
        <MediaCodec name="c2.google.mp3.decoder" type="audio/mpeg">
            <Limit name="channel-count" max="2" />
            <Limit name="sample-rate" ranges="8000,11025,12000,16000,22050,24000,32000,44100,48000" />
            <Limit name="bitrate" range="8000-320000" />
        </MediaCodec>
        <MediaCodec name="c2.google.amrnb.decoder" type="audio/3gpp">
            <Limit name="channel-count" max="1" />
            <Limit name="sample-rate" ranges="8000" />
            <Limit name="bitrate" range="4750-12200" />
        </MediaCodec>
        <MediaCodec name="c2.google.amrwb.decoder" type="audio/amr-wb">
            <Limit name="channel-count" max="1" />
            <Limit name="sample-rate" ranges="16000" />
            <Limit name="bitrate" range="6600-23850" />
        </MediaCodec>
        <MediaCodec name="c2.google.aac.decoder" type="audio/mp4a-latm">
            <Limit name="channel-count" max="8" />
            <Limit name="sample-rate" ranges="7350,8000,11025,12000,16000,22050,24000,32000,44100,48000" />
            <Limit name="bitrate" range="8000-960000" />
        </MediaCodec>
        <MediaCodec name="c2.google.g711.alaw.decoder" type="audio/g711-alaw">
            <Limit name="channel-count" max="1" />
            <Limit name="sample-rate" ranges="8000-48000" />
            <Limit name="bitrate" range="64000" />
        </MediaCodec>
        <MediaCodec name="c2.google.g711.mlaw.decoder" type="audio/g711-mlaw">
            <Limit name="channel-count" max="1" />
            <Limit name="sample-rate" ranges="8000-48000" />
            <Limit name="bitrate" range="64000" />
        </MediaCodec>
        <MediaCodec name="c2.google.vorbis.decoder" type="audio/vorbis">
            <Limit name="channel-count" max="8" />
            <Limit name="sample-rate" ranges="8000-96000" />
            <Limit name="bitrate" range="32000-500000" />
        </MediaCodec>
        <MediaCodec name="c2.google.opus.decoder" type="audio/opus">
            <Limit name="channel-count" max="8" />
            <Limit name="sample-rate" ranges="48000" />
            <Limit name="bitrate" range="6000-510000" />
        </MediaCodec>
        <MediaCodec name="c2.google.raw.decoder" type="audio/raw">
            <Limit name="channel-count" max="8" />
            <Limit name="sample-rate" ranges="8000-96000" />
            <Limit name="bitrate" range="1-10000000" />
        </MediaCodec>
        <MediaCodec name="c2.google.flac.decoder" type="audio/flac">
            <Limit name="channel-count" max="8" />
            <Limit name="sample-rate" ranges="1-655350" />
            <Limit name="bitrate" range="1-21000000" />
        </MediaCodec>
    </Decoders>
    <Encoders>
        <MediaCodec name="c2.google.aac.encoder" type="audio/mp4a-latm">
            <Limit name="channel-count" max="6" />
            <Limit name="sample-rate" ranges="8000,11025,12000,16000,22050,24000,32000,44100,48000" />
            <!-- also may support 64000, 88200  and 96000 Hz -->
            <Limit name="bitrate" range="8000-960000" />
        </MediaCodec>
        <MediaCodec name="c2.google.amrnb.encoder" type="audio/3gpp">
            <Limit name="channel-count" max="1" />
            <Limit name="sample-rate" ranges="8000" />
            <Limit name="bitrate" range="4750-12200" />
            <Feature name="bitrate-modes" value="CBR" />
        </MediaCodec>
        <MediaCodec name="c2.google.amrwb.encoder" type="audio/amr-wb">
            <Limit name="channel-count" max="1" />
            <Limit name="sample-rate" ranges="16000" />
            <Limit name="bitrate" range="6600-23850" />
            <Feature name="bitrate-modes" value="CBR" />
        </MediaCodec>
        <MediaCodec name="c2.google.flac.encoder" type="audio/flac">
            <Limit name="channel-count" max="2" />
            <Limit name="sample-rate" ranges="1-655350" />
            <Limit name="bitrate" range="1-21000000" />
            <Limit name="complexity" range="0-8"  default="5" />
            <Feature name="bitrate-modes" value="CQ" />
        </MediaCodec>
    </Encoders>
</Included>
+122 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (C) 2014 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<Included>
    <Decoders>
        <MediaCodec name="c2.google.mpeg4.decoder" type="video/mp4v-es">
            <!-- profiles and levels:  ProfileSimple : Level3 -->
            <Limit name="size" min="2x2" max="352x288" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="12-11880" />
            <Limit name="bitrate" range="1-384000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="c2.google.h263.decoder" type="video/3gpp">
            <!-- profiles and levels:  ProfileBaseline : Level30, ProfileBaseline : Level45
                    ProfileISWV2 : Level30, ProfileISWV2 : Level45 -->
            <Limit name="size" min="2x2" max="352x288" />
            <Limit name="alignment" value="2x2" />
            <Limit name="bitrate" range="1-384000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="c2.google.avc.decoder" type="video/avc">
            <!-- profiles and levels:  ProfileHigh : Level52 -->
            <Limit name="size" min="2x2" max="4080x4080" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="block-count" range="1-32768" /> <!-- max 4096x2048 equivalent -->
            <Limit name="blocks-per-second" range="1-1966080" />
            <Limit name="bitrate" range="1-48000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="c2.google.hevc.decoder" type="video/hevc">
            <!-- profiles and levels:  ProfileMain : MainTierLevel51 -->
            <Limit name="size" min="2x2" max="4096x4096" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="8x8" />
            <Limit name="block-count" range="1-196608" /> <!-- max 4096x3072 -->
            <Limit name="blocks-per-second" range="1-2000000" />
            <Limit name="bitrate" range="1-10000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="c2.google.vp8.decoder" type="video/x-vnd.on2.vp8">
            <Limit name="size" min="2x2" max="2048x2048" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="block-count" range="1-16384" />
            <Limit name="blocks-per-second" range="1-1000000" />
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
        <MediaCodec name="c2.google.vp9.decoder" type="video/x-vnd.on2.vp9">
            <Limit name="size" min="2x2" max="2048x2048" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="block-count" range="1-16384" />
            <Limit name="blocks-per-second" range="1-500000" />
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="adaptive-playback" />
        </MediaCodec>
    </Decoders>

    <Encoders>
        <MediaCodec name="c2.google.h263.encoder" type="video/3gpp">
            <!-- profiles and levels:  ProfileBaseline : Level45 -->
            <Limit name="size" min="176x144" max="176x144" />
            <Limit name="alignment" value="16x16" />
            <Limit name="bitrate" range="1-128000" />
        </MediaCodec>
        <MediaCodec name="c2.google.avc.encoder" type="video/avc">
            <!-- profiles and levels:  ProfileBaseline : Level41 -->
            <Limit name="size" min="16x16" max="2048x2048" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <Limit name="block-count" range="1-8192" /> <!-- max 2048x1024 -->
            <Limit name="blocks-per-second" range="1-245760" />
            <Limit name="bitrate" range="1-12000000" />
            <Feature name="intra-refresh" />
        </MediaCodec>
        <MediaCodec name="c2.google.mpeg4.encoder" type="video/mp4v-es">
            <!-- profiles and levels:  ProfileCore : Level2 -->
            <Limit name="size" min="16x16" max="176x144" />
            <Limit name="alignment" value="16x16" />
            <Limit name="block-size" value="16x16" />
            <Limit name="blocks-per-second" range="12-1485" />
            <Limit name="bitrate" range="1-64000" />
        </MediaCodec>
        <MediaCodec name="c2.google.vp8.encoder" type="video/x-vnd.on2.vp8">
            <!-- profiles and levels:  ProfileMain : Level_Version0-3 -->
            <Limit name="size" min="2x2" max="2048x2048" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <!-- 2016 devices can encode at about 10fps at this block count -->
            <Limit name="block-count" range="1-16384" />
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="bitrate-modes" value="VBR,CBR" />
        </MediaCodec>
        <MediaCodec name="c2.google.vp9.encoder" type="video/x-vnd.on2.vp9">
            <!-- profiles and levels:  ProfileMain : Level_Version0-3 -->
            <Limit name="size" min="2x2" max="2048x2048" />
            <Limit name="alignment" value="2x2" />
            <Limit name="block-size" value="16x16" />
            <!-- 2016 devices can encode at about 8fps at this block count -->
            <Limit name="block-count" range="1-3600" /> <!-- max 1280x720 -->
            <Limit name="bitrate" range="1-40000000" />
            <Feature name="bitrate-modes" value="VBR,CBR" />
        </MediaCodec>
    </Encoders>
</Included>