Merge changes from topic "c2-more-adjustments"

* changes:
  Codec2/AUtils: rename nom to num for 'numerator'
  Codec2: C2ParamDescriptor fixes
  Codec2: use std::list only for C2Work/C2Worklet
  Codec2: codec2_vndk is now a shared lib, plus, add internal headers
gugelfrei
Lajos Molnar 7 years ago committed by Android (Google) Code Review
commit 4b8dbfc9e8

@ -126,6 +126,7 @@ cc_library_shared {
"libutils",
"libmedia_helper",
"libstagefright_codec2",
"libstagefright_codec2_vndk",
"libstagefright_foundation",
"libstagefright_gbs",
"libstagefright_omx",
@ -154,8 +155,6 @@ cc_library_shared {
"libstagefright_esds",
"libstagefright_id3",
"libFLAC",
"libstagefright_codec2_vndk",
],
export_shared_lib_headers: [

@ -117,7 +117,7 @@ public:
virtual void onWorkDone_nb(
std::weak_ptr<C2Component> component,
std::vector<std::unique_ptr<C2Work>> workItems) override {
std::list<std::unique_ptr<C2Work>> workItems) override {
(void)component;
sp<CCodec> codec(mCodec.promote());
if (!codec) {
@ -601,7 +601,7 @@ void CCodec::signalRequestIDRFrame() {
// TODO
}
void CCodec::onWorkDone(std::vector<std::unique_ptr<C2Work>> &workItems) {
void CCodec::onWorkDone(std::list<std::unique_ptr<C2Work>> &workItems) {
Mutexed<std::list<std::unique_ptr<C2Work>>>::Locked queue(mWorkDoneQueue);
for (std::unique_ptr<C2Work> &item : workItems) {
queue->push_back(std::move(item));

@ -237,8 +237,8 @@ std::shared_ptr<C2ComponentInterface> SimpleC2Component::intf() {
namespace {
std::vector<std::unique_ptr<C2Work>> vec(std::unique_ptr<C2Work> &work) {
std::vector<std::unique_ptr<C2Work>> ret;
std::list<std::unique_ptr<C2Work>> vec(std::unique_ptr<C2Work> &work) {
std::list<std::unique_ptr<C2Work>> ret;
ret.push_back(std::move(work));
return ret;
}

@ -332,7 +332,7 @@ public:
class Listener {
public:
virtual void onWorkDone_nb(std::weak_ptr<C2Component> component,
std::vector<std::unique_ptr<C2Work>> workItems) = 0;
std::list<std::unique_ptr<C2Work>> workItems) = 0;
virtual void onTripped_nb(std::weak_ptr<C2Component> component,
std::vector<std::shared_ptr<C2SettingResult>> settingResult) = 0;

@ -1020,7 +1020,7 @@ public:
* For vendor-defined components, it can be true even for vendor-defined params,
* but it is not recommended, in case the component becomes platform-defined.
*/
inline bool isRequired() const { return _mIsRequired; }
inline bool isRequired() const { return _mAttrib & IS_REQUIRED; }
/**
* Returns whether this parameter is persistent. This is always true for C2Tuning and C2Setting,
@ -1029,35 +1029,43 @@ public:
* current frame and is not assumed to have the same value (or even be present) on subsequent
* frames, unless it is specified for those frames.
*/
inline bool isPersistent() const { return _mIsPersistent; }
inline bool isPersistent() const { return _mAttrib & IS_PERSISTENT; }
/// Returns the name of this param.
/// This defaults to the underlying C2Struct's name, but could be altered for a component.
inline C2String name() const { return _mName; }
/// Returns the parameter type
/// \todo fix this
inline C2Param::Type type() const { return _mType; }
/// Returns the parameter index
inline C2Param::Index index() const { return _mIndex; }
/// Returns the indices of parameters that this parameter has a dependency on
inline const std::vector<C2Param::Index> &dependencies() const { return mDependencies; }
// TODO: add more constructors that allow setting dependencies and attributes
template<typename T>
inline C2ParamDescriptor(bool isRequired, C2StringLiteral name, const T*)
: _mIsRequired(isRequired),
_mIsPersistent(true),
_mName(name),
_mType(T::PARAM_TYPE) { }
: _mIndex(T::PARAM_TYPE),
_mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
_mName(name) { }
inline C2ParamDescriptor(
bool isRequired, C2StringLiteral name, C2Param::Type type)
: _mIsRequired(isRequired),
_mIsPersistent(true),
_mName(name),
_mType(type) { }
bool isRequired, C2StringLiteral name, C2Param::Index index)
: _mIndex(index),
_mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
_mName(name) { }
private:
const bool _mIsRequired;
const bool _mIsPersistent;
enum attrib_t : uint32_t {
IS_REQUIRED = 1u << 0,
IS_PERSISTENT = 1u << 1,
};
const C2Param::Index _mIndex;
const uint32_t _mAttrib;
const C2String _mName;
const C2Param::Type _mType;
std::vector<C2Param::Index> mDependencies;
friend struct _C2ParamInspector;
};
/// \ingroup internal
@ -1300,7 +1308,7 @@ struct C2FieldSupportedValues {
Primitive min;
Primitive max;
Primitive step;
Primitive nom;
Primitive num;
Primitive denom;
} range;
std::vector<Primitive> values;
@ -1315,9 +1323,9 @@ struct C2FieldSupportedValues {
range{min, max, step, (T)1, (T)1} { }
template<typename T>
C2FieldSupportedValues(T min, T max, T nom, T den) :
C2FieldSupportedValues(T min, T max, T num, T den) :
type(RANGE),
range{min, max, (T)0, nom, den} { }
range{min, max, (T)0, num, den} { }
template<typename T>
C2FieldSupportedValues(bool flags, std::initializer_list<T> list)

@ -225,7 +225,7 @@ C2FlexStructCheck<S, ParamIndex, TypeFlags>::FIELD_LIST = S::FIELD_LIST;
#define DEFINE_CAST_OPERATORS(_Type) \
inline static _Type* From(C2Param *other) { \
return (_Type*)C2Param::ifSuitable( \
other, sizeof(_Type),_Type::PARAM_TYPE, _Type::FLEX_SIZE, \
other, sizeof(_Type), _Type::PARAM_TYPE, _Type::FLEX_SIZE, \
(_Type::PARAM_TYPE & T::Index::DIR_UNDEFINED) != T::Index::DIR_UNDEFINED); \
} \
inline static const _Type* From(const C2Param *other) { \

@ -68,7 +68,7 @@ struct C2SettingResult {
/// Conflicting parameters or fields with optional suggestions with (optional) suggested values
/// for any conflicting fields to avoid the conflict.
std::list<C2ParamFieldValues> conflicts;
std::vector<C2ParamFieldValues> conflicts;
};
// ================================================================================================
@ -206,7 +206,7 @@ struct C2Work {
struct C2WorkOutline {
//public:
C2WorkOrdinalStruct ordinal;
std::list<c2_node_id_t> chain;
std::vector<c2_node_id_t> chain;
};
/// @}

@ -410,17 +410,17 @@ void C2CompIntfTest::getTestValues(
// 1. integer geometric case
// 2. float geometric case
auto nom = prim2Value(range.nom);
auto num = prim2Value(range.num);
auto denom = prim2Value(range.denom);
// If both range.nom and range.denom are 1 and step is 0, we should use
// If both range.num and range.denom are 1 and step is 0, we should use
// VALUES, shouldn't we?
ASSERT_FALSE(nom == 1 && denom == 1);
ASSERT_FALSE(num == 1 && denom == 1);
// (nom / denom) is not less than 1.
// (num / denom) is not less than 1.
ASSERT_FALSE(denom == 0);
ASSERT_LE(denom, nom);
for (auto v = rmin; v <= rmax; v = v * nom / denom) {
ASSERT_LE(denom, num);
for (auto v = rmin; v <= rmax; v = v * num / denom) {
validValues->emplace_back(v);
}
@ -529,7 +529,7 @@ bool isSupportedParam(
const C2Param &param,
const std::vector<std::shared_ptr<C2ParamDescriptor>> &sParams) {
for (const auto &pd : sParams) {
if (param.type() == pd->type().type()) {
if (param.type() == pd->index().type()) {
return true;
}
}

@ -2622,8 +2622,8 @@ void dumpFSV(const C2FieldSupportedValues &sv, T*t) {
if (get(sv.range.step, t) != std::is_integral<T>::value) {
cout << ":" << get(sv.range.step, t);
}
if (get(sv.range.nom, t) != 1 || get(sv.range.denom, t) != 1) {
cout << ":" << get(sv.range.nom, t) << "/" << get(sv.range.denom, t);
if (get(sv.range.num, t) != 1 || get(sv.range.denom, t) != 1) {
cout << ":" << get(sv.range.num, t) << "/" << get(sv.range.denom, t);
}
cout << get(sv.range.max, t) << ")";
}
@ -2736,7 +2736,7 @@ void dumpDesc(const C2ParamDescriptor &pd) {
cout << "persistent ";
}
cout << "struct ";
dumpType(pd.type());
dumpType(C2Param::Type(pd.index().type()));
cout << " " << pd.name() << ";" << endl;
}
@ -2769,7 +2769,7 @@ TEST_F(C2ParamTest, FieldSupportedValuesTest) {
Uint32TestInfo t;
std::vector<C2FieldSupportedValues> values;
values.push_back(C2FieldSupportedValues(0, 10, 1)); // min, max, step
values.push_back(C2FieldSupportedValues(1, 64, 2, 1)); // min, max, nom, den
values.push_back(C2FieldSupportedValues(1, 64, 2, 1)); // min, max, num, den
values.push_back(C2FieldSupportedValues(false, {1, 2, 3})); // flags, std::initializer_list
uint32_t val[] = {1, 3, 5, 7};
std::vector<uint32_t> v(std::begin(val), std::end(val));

@ -1,4 +1,14 @@
cc_library {
cc_library_headers {
name: "libstagefright_codec2_internal",
export_include_dirs: [
"internal",
],
vendor_available: false,
}
cc_library_shared {
name: "libstagefright_codec2_vndk",
srcs: [
@ -13,6 +23,10 @@ cc_library {
"include",
],
header_libs:[
"libstagefright_codec2_internal",
],
include_dirs: [
"frameworks/av/media/libstagefright/codec2/include",
"frameworks/native/include/media/hardware",

@ -22,7 +22,7 @@
namespace android {
struct C2_HIDE _C2ParamInspector {
inline static uint32_t getIndex(const C2ParamField &pf) {
inline static uint32_t getIndex(const C2ParamField &pf) {
return pf._mIndex;
}
@ -34,6 +34,10 @@ struct C2_HIDE _C2ParamInspector {
return pf._mFieldId._mSize;
}
inline static uint32_t getAttrib(const C2ParamDescriptor &pd) {
return pd._mAttrib;
}
inline static
C2ParamField CreateParamField(C2Param::Index index, uint32_t offset, uint32_t size) {
return C2ParamField(index, offset, size);

@ -25,7 +25,6 @@ cc_library_shared {
static_libs: [
"libFraunhoferAAC",
"libstagefright_codec2_vndk"
],
shared_libs: [
@ -33,6 +32,7 @@ cc_library_shared {
"libion",
"liblog",
"libstagefright_codec2",
"libstagefright_codec2_vndk",
"libstagefright_foundation",
"libstagefright_simple_c2component",
"libutils",

@ -22,7 +22,6 @@ cc_library_shared {
static_libs: [
"libFraunhoferAAC",
"libstagefright_codec2_vndk"
],
shared_libs: [
@ -30,6 +29,7 @@ cc_library_shared {
"libion",
"liblog",
"libstagefright_codec2",
"libstagefright_codec2_vndk",
"libstagefright_foundation",
"libstagefright_simple_c2component",
"libutils",

@ -99,7 +99,7 @@ struct ValidateParam {
}
case C2FieldSupportedValues::RANGE:
{
// TODO: handle step, nom, denom
// TODO: handle step, num, denom
return Getter<T>::get(supportedValues.range.min) <= value
&& value <= Getter<T>::get(supportedValues.range.max);
}

@ -83,7 +83,7 @@ public:
~SimplePlayer();
void onWorkDone(std::weak_ptr<C2Component> component,
std::vector<std::unique_ptr<C2Work>> workItems);
std::list<std::unique_ptr<C2Work>> workItems);
void onTripped(std::weak_ptr<C2Component> component,
std::vector<std::shared_ptr<C2SettingResult>> settingResult);
void onError(std::weak_ptr<C2Component> component, uint32_t errorCode);
@ -120,7 +120,7 @@ public:
virtual ~Listener() = default;
virtual void onWorkDone_nb(std::weak_ptr<C2Component> component,
std::vector<std::unique_ptr<C2Work>> workItems) override {
std::list<std::unique_ptr<C2Work>> workItems) override {
mThis->onWorkDone(component, std::move(workItems));
}
@ -174,7 +174,7 @@ SimplePlayer::~SimplePlayer() {
}
void SimplePlayer::onWorkDone(
std::weak_ptr<C2Component> component, std::vector<std::unique_ptr<C2Work>> workItems) {
std::weak_ptr<C2Component> component, std::list<std::unique_ptr<C2Work>> workItems) {
ALOGV("SimplePlayer::onWorkDone");
(void) component;
ULock l(mProcessedLock);

@ -22,28 +22,28 @@
/* T must be integer type, den must not be 0 */
template<class T>
inline static const T divRound(const T &nom, const T &den) {
if ((nom >= 0) ^ (den >= 0)) {
return (nom - den / 2) / den;
inline static const T divRound(const T &num, const T &den) {
if ((num >= 0) ^ (den >= 0)) {
return (num - den / 2) / den;
} else {
return (nom + den / 2) / den;
return (num + den / 2) / den;
}
}
/* == ceil(nom / den). T must be integer type, den must not be 0 */
/* == ceil(num / den). T must be integer type, den must not be 0 */
template<class T>
inline static const T divUp(const T &nom, const T &den) {
inline static const T divUp(const T &num, const T &den) {
if (den < 0) {
return (nom < 0 ? nom + den + 1 : nom) / den;
return (num < 0 ? num + den + 1 : num) / den;
} else {
return (nom < 0 ? nom : nom + den - 1) / den;
return (num < 0 ? num : num + den - 1) / den;
}
}
/* == ceil(nom / den) * den. T must be integer type, alignment must be positive power of 2 */
/* == ceil(num / den) * den. T must be integer type, alignment must be positive power of 2 */
template<class T, class U>
inline static const T align(const T &nom, const U &den) {
return (nom + (T)(den - 1)) & (T)~(den - 1);
inline static const T align(const T &num, const U &den) {
return (num + (T)(den - 1)) & (T)~(den - 1);
}
template<class T>

@ -59,7 +59,7 @@ public:
virtual void signalRequestIDRFrame() override;
void initiateReleaseIfStuck();
void onWorkDone(std::vector<std::unique_ptr<C2Work>> &workItems);
void onWorkDone(std::list<std::unique_ptr<C2Work>> &workItems);
protected:
virtual ~CCodec();

Loading…
Cancel
Save