Loading media/codec2/components/apv/Android.bp +18 −12 Original line number Diff line number Diff line Loading @@ -12,23 +12,26 @@ cc_library { name: "libcodec2_soft_apvenc", defaults: [ "libcodec2_soft-defaults", "libcodec2_soft_sanitize_signed-defaults", "libcodec2_soft_sanitize_cfi-defaults", "libcodec2_soft_sanitize_signed-defaults", ], static_libs: [ "libopenapv", "android.media.swcodec.flags-aconfig-cc", "libopenapv", ], srcs: ["C2SoftApvEnc.cpp"], srcs: [ "C2SoftApvEnc.cpp", "isAtLeastRelease.cpp", ], cflags: [ "-DOAPV_STATIC_DEFINE", "-Wno-unused-variable", "-Wno-unused-parameter", "-Wno-unused-function", "-Wno-reorder-ctor", "-Wno-unused-function", "-Wno-unused-parameter", "-Wno-unused-variable", ], } Loading @@ -37,22 +40,25 @@ cc_library { name: "libcodec2_soft_apvdec", defaults: [ "libcodec2_soft-defaults", "libcodec2_soft_sanitize_signed-defaults", "libcodec2_soft_sanitize_cfi-defaults", "libcodec2_soft_sanitize_signed-defaults", ], static_libs: [ "libopenapv", "android.media.swcodec.flags-aconfig-cc", "libopenapv", ], srcs: ["C2SoftApvDec.cpp"], srcs: [ "C2SoftApvDec.cpp", "isAtLeastRelease.cpp", ], cflags: [ "-DOAPV_STATIC_DEFINE", "-Wno-unused-variable", "-Wno-unused-parameter", "-Wno-unused-function", "-Wno-reorder-ctor", "-Wno-unused-function", "-Wno-unused-parameter", "-Wno-unused-variable", ], } media/codec2/components/apv/C2SoftApvDec.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <Codec2Mapper.h> #include <SimpleC2Interface.h> #include "C2SoftApvDec.h" #include "isAtLeastRelease.h" #include <cutils/properties.h> Loading Loading @@ -1515,6 +1516,13 @@ __attribute__((cfi_canonical_jump_table)) extern "C" ::C2ComponentFactory* Creat ALOGV("APV SW Codec is not enabled"); return nullptr; } bool enabled = isAtLeastRelease(36, "Baklava"); ALOGD("isAtLeastRelease(36, Baklava) says enable: %s", enabled ? "yes" : "no"); if (!enabled) { return nullptr; } return new ::android::C2SoftApvDecFactory(); } Loading media/codec2/components/apv/C2SoftApvEnc.cpp +25 −23 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <util/C2InterfaceHelper.h> #include <cmath> #include "C2SoftApvEnc.h" #include "isAtLeastRelease.h" namespace android { Loading Loading @@ -1136,13 +1137,14 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, uint8_t profile_idc = 0; uint8_t level_idc = 0; uint8_t band_idc = 0; uint32_t frame_width_minus1 = 0; uint32_t frame_height_minus1 = 0; uint32_t frame_width = 0; uint32_t frame_height = 0; uint8_t chroma_format_idc = 0; uint8_t bit_depth_minus8 = 0; uint8_t capture_time_distance = 0; uint8_t color_primaries = 0; uint8_t transfer_characteristics = 0; uint8_t full_range_flag = 0; uint8_t matrix_coefficients = 0; /* pbu_header() */ Loading @@ -1157,8 +1159,8 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, level_idc = reader.getBits(8); // level_idc band_idc = reader.getBits(3); // band_idc reader.skipBits(5); // reserved_zero_5bits frame_width_minus1 = reader.getBits(32); // width frame_height_minus1 = reader.getBits(32); // height frame_width = reader.getBits(24); // width frame_height = reader.getBits(24); // height chroma_format_idc = reader.getBits(4); // chroma_format_idc bit_depth_minus8 = reader.getBits(4); // bit_depth capture_time_distance = reader.getBits(8); // capture_time_distance Loading @@ -1171,6 +1173,7 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, color_primaries = reader.getBits(8); // color_primaries transfer_characteristics = reader.getBits(8); // transfer_characteristics matrix_coefficients = reader.getBits(8); // matrix_coefficients full_range_flag = reader.getBits(1); // full_range_flag } number_of_configuration_entry = 1; // The real-time encoding on the device is assumed to be 1. Loading @@ -1178,15 +1181,6 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, std::vector<uint8_t> csdData; //TODO(b/392976813): These 4 lines need to be removed once test data are fixed. csdData.push_back((uint8_t)0x0); csdData.push_back((uint8_t)0x0); csdData.push_back((uint8_t)0x0); csdData.push_back((uint8_t)0x0); //TODO(b/392976819) This need to be removed once OpenAPV is fixed. bit_depth_minus8 = 2; csdData.push_back((uint8_t)0x1); csdData.push_back(number_of_configuration_entry); Loading @@ -1199,21 +1193,22 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, csdData.push_back(profile_idc); csdData.push_back(level_idc); csdData.push_back(band_idc); csdData.push_back((uint8_t)((frame_width_minus1 >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_width_minus1 >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_width_minus1 >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_width_minus1 & 0xff)); csdData.push_back((uint8_t)((frame_height_minus1 >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_height_minus1 >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_height_minus1 >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_height_minus1 & 0xff)); csdData.push_back((uint8_t)(((bit_depth_minus8 << 4) & 0xf0) | (chroma_format_idc & 0xf))); csdData.push_back((uint8_t)((frame_width >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_width >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_width >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_width & 0xff)); csdData.push_back((uint8_t)((frame_height >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_height >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_height >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_height & 0xff)); csdData.push_back((uint8_t)(((chroma_format_idc << 4) & 0xf0) | (bit_depth_minus8 & 0xf))); csdData.push_back((uint8_t)(capture_time_distance)); if (color_description_present_flag) { csdData.push_back(color_primaries); csdData.push_back(transfer_characteristics); csdData.push_back(matrix_coefficients); csdData.push_back(full_range_flag << 7); } } } Loading Loading @@ -1403,6 +1398,13 @@ __attribute__((cfi_canonical_jump_table)) extern "C" ::C2ComponentFactory* Creat ALOGV("APV SW Codec is not enabled"); return nullptr; } bool enabled = isAtLeastRelease(36, "Baklava"); ALOGD("isAtLeastRelease(36, Baklava) says enable: %s", enabled ? "yes" : "no"); if (!enabled) { return nullptr; } return new ::android::C2SoftApvEncFactory(); } Loading media/codec2/components/apv/isAtLeastRelease.cpp 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright 2017, 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. */ #define LOG_TAG "isAtLeastRelease" #include <android/api-level.h> #include <android-base/properties.h> #include <utils/Log.h> #include <mutex> #include <string> // current SDK for this device; filled in when initializing the parser. static int mySdk = 0; static std::string myCodeName; // to help address b/388925029 /** * support code so a plugin (currently the APV codecs) can self-manage * whether it is running on a sufficiently new code base. * * this is here because the XMLparser for Media codec definitions has * an off-by-one error in how it handles <MediaCodec name=".." ... minsdk="" > * * we will want to fix that starting in Android B/16, but devices in Android V/15 * still have issues [and we build the codecs into module code so that it goes back * to older releases]. * */ bool isAtLeastRelease(int minsdk, const char *codename) { static std::once_flag sCheckOnce; std::call_once(sCheckOnce, [&](){ mySdk = android_get_device_api_level(); myCodeName = android::base::GetProperty("ro.build.version.codename", "<none>"); }); bool satisfied = false; ALOGI("device sdk %d, minsdk %d", mySdk, minsdk); if (mySdk >= minsdk) { satisfied = true; } // allow the called to skip the codename. if (codename != nullptr) { ALOGI("active codename %s, to match %s", myCodeName.c_str(), codename); if (myCodeName == codename) { satisfied = true; } } return satisfied; } media/codec2/components/apv/isAtLeastRelease.h 0 → 100644 +17 −0 Original line number Diff line number Diff line /* * Copyright 2017, 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. */ bool isAtLeastRelease(int minsdk, const char *codename); Loading
media/codec2/components/apv/Android.bp +18 −12 Original line number Diff line number Diff line Loading @@ -12,23 +12,26 @@ cc_library { name: "libcodec2_soft_apvenc", defaults: [ "libcodec2_soft-defaults", "libcodec2_soft_sanitize_signed-defaults", "libcodec2_soft_sanitize_cfi-defaults", "libcodec2_soft_sanitize_signed-defaults", ], static_libs: [ "libopenapv", "android.media.swcodec.flags-aconfig-cc", "libopenapv", ], srcs: ["C2SoftApvEnc.cpp"], srcs: [ "C2SoftApvEnc.cpp", "isAtLeastRelease.cpp", ], cflags: [ "-DOAPV_STATIC_DEFINE", "-Wno-unused-variable", "-Wno-unused-parameter", "-Wno-unused-function", "-Wno-reorder-ctor", "-Wno-unused-function", "-Wno-unused-parameter", "-Wno-unused-variable", ], } Loading @@ -37,22 +40,25 @@ cc_library { name: "libcodec2_soft_apvdec", defaults: [ "libcodec2_soft-defaults", "libcodec2_soft_sanitize_signed-defaults", "libcodec2_soft_sanitize_cfi-defaults", "libcodec2_soft_sanitize_signed-defaults", ], static_libs: [ "libopenapv", "android.media.swcodec.flags-aconfig-cc", "libopenapv", ], srcs: ["C2SoftApvDec.cpp"], srcs: [ "C2SoftApvDec.cpp", "isAtLeastRelease.cpp", ], cflags: [ "-DOAPV_STATIC_DEFINE", "-Wno-unused-variable", "-Wno-unused-parameter", "-Wno-unused-function", "-Wno-reorder-ctor", "-Wno-unused-function", "-Wno-unused-parameter", "-Wno-unused-variable", ], }
media/codec2/components/apv/C2SoftApvDec.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <Codec2Mapper.h> #include <SimpleC2Interface.h> #include "C2SoftApvDec.h" #include "isAtLeastRelease.h" #include <cutils/properties.h> Loading Loading @@ -1515,6 +1516,13 @@ __attribute__((cfi_canonical_jump_table)) extern "C" ::C2ComponentFactory* Creat ALOGV("APV SW Codec is not enabled"); return nullptr; } bool enabled = isAtLeastRelease(36, "Baklava"); ALOGD("isAtLeastRelease(36, Baklava) says enable: %s", enabled ? "yes" : "no"); if (!enabled) { return nullptr; } return new ::android::C2SoftApvDecFactory(); } Loading
media/codec2/components/apv/C2SoftApvEnc.cpp +25 −23 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <util/C2InterfaceHelper.h> #include <cmath> #include "C2SoftApvEnc.h" #include "isAtLeastRelease.h" namespace android { Loading Loading @@ -1136,13 +1137,14 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, uint8_t profile_idc = 0; uint8_t level_idc = 0; uint8_t band_idc = 0; uint32_t frame_width_minus1 = 0; uint32_t frame_height_minus1 = 0; uint32_t frame_width = 0; uint32_t frame_height = 0; uint8_t chroma_format_idc = 0; uint8_t bit_depth_minus8 = 0; uint8_t capture_time_distance = 0; uint8_t color_primaries = 0; uint8_t transfer_characteristics = 0; uint8_t full_range_flag = 0; uint8_t matrix_coefficients = 0; /* pbu_header() */ Loading @@ -1157,8 +1159,8 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, level_idc = reader.getBits(8); // level_idc band_idc = reader.getBits(3); // band_idc reader.skipBits(5); // reserved_zero_5bits frame_width_minus1 = reader.getBits(32); // width frame_height_minus1 = reader.getBits(32); // height frame_width = reader.getBits(24); // width frame_height = reader.getBits(24); // height chroma_format_idc = reader.getBits(4); // chroma_format_idc bit_depth_minus8 = reader.getBits(4); // bit_depth capture_time_distance = reader.getBits(8); // capture_time_distance Loading @@ -1171,6 +1173,7 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, color_primaries = reader.getBits(8); // color_primaries transfer_characteristics = reader.getBits(8); // transfer_characteristics matrix_coefficients = reader.getBits(8); // matrix_coefficients full_range_flag = reader.getBits(1); // full_range_flag } number_of_configuration_entry = 1; // The real-time encoding on the device is assumed to be 1. Loading @@ -1178,15 +1181,6 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, std::vector<uint8_t> csdData; //TODO(b/392976813): These 4 lines need to be removed once test data are fixed. csdData.push_back((uint8_t)0x0); csdData.push_back((uint8_t)0x0); csdData.push_back((uint8_t)0x0); csdData.push_back((uint8_t)0x0); //TODO(b/392976819) This need to be removed once OpenAPV is fixed. bit_depth_minus8 = 2; csdData.push_back((uint8_t)0x1); csdData.push_back(number_of_configuration_entry); Loading @@ -1199,21 +1193,22 @@ void C2SoftApvEnc::createCsdData(const std::unique_ptr<C2Work>& work, csdData.push_back(profile_idc); csdData.push_back(level_idc); csdData.push_back(band_idc); csdData.push_back((uint8_t)((frame_width_minus1 >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_width_minus1 >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_width_minus1 >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_width_minus1 & 0xff)); csdData.push_back((uint8_t)((frame_height_minus1 >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_height_minus1 >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_height_minus1 >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_height_minus1 & 0xff)); csdData.push_back((uint8_t)(((bit_depth_minus8 << 4) & 0xf0) | (chroma_format_idc & 0xf))); csdData.push_back((uint8_t)((frame_width >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_width >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_width >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_width & 0xff)); csdData.push_back((uint8_t)((frame_height >> 24) & 0xff)); csdData.push_back((uint8_t)((frame_height >> 16) & 0xff)); csdData.push_back((uint8_t)((frame_height >> 8) & 0xff)); csdData.push_back((uint8_t)(frame_height & 0xff)); csdData.push_back((uint8_t)(((chroma_format_idc << 4) & 0xf0) | (bit_depth_minus8 & 0xf))); csdData.push_back((uint8_t)(capture_time_distance)); if (color_description_present_flag) { csdData.push_back(color_primaries); csdData.push_back(transfer_characteristics); csdData.push_back(matrix_coefficients); csdData.push_back(full_range_flag << 7); } } } Loading Loading @@ -1403,6 +1398,13 @@ __attribute__((cfi_canonical_jump_table)) extern "C" ::C2ComponentFactory* Creat ALOGV("APV SW Codec is not enabled"); return nullptr; } bool enabled = isAtLeastRelease(36, "Baklava"); ALOGD("isAtLeastRelease(36, Baklava) says enable: %s", enabled ? "yes" : "no"); if (!enabled) { return nullptr; } return new ::android::C2SoftApvEncFactory(); } Loading
media/codec2/components/apv/isAtLeastRelease.cpp 0 → 100644 +68 −0 Original line number Diff line number Diff line /* * Copyright 2017, 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. */ #define LOG_TAG "isAtLeastRelease" #include <android/api-level.h> #include <android-base/properties.h> #include <utils/Log.h> #include <mutex> #include <string> // current SDK for this device; filled in when initializing the parser. static int mySdk = 0; static std::string myCodeName; // to help address b/388925029 /** * support code so a plugin (currently the APV codecs) can self-manage * whether it is running on a sufficiently new code base. * * this is here because the XMLparser for Media codec definitions has * an off-by-one error in how it handles <MediaCodec name=".." ... minsdk="" > * * we will want to fix that starting in Android B/16, but devices in Android V/15 * still have issues [and we build the codecs into module code so that it goes back * to older releases]. * */ bool isAtLeastRelease(int minsdk, const char *codename) { static std::once_flag sCheckOnce; std::call_once(sCheckOnce, [&](){ mySdk = android_get_device_api_level(); myCodeName = android::base::GetProperty("ro.build.version.codename", "<none>"); }); bool satisfied = false; ALOGI("device sdk %d, minsdk %d", mySdk, minsdk); if (mySdk >= minsdk) { satisfied = true; } // allow the called to skip the codename. if (codename != nullptr) { ALOGI("active codename %s, to match %s", myCodeName.c_str(), codename); if (myCodeName == codename) { satisfied = true; } } return satisfied; }
media/codec2/components/apv/isAtLeastRelease.h 0 → 100644 +17 −0 Original line number Diff line number Diff line /* * Copyright 2017, 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. */ bool isAtLeastRelease(int minsdk, const char *codename);