Merge "Codec2: fix API style for some helpers"
diff --git a/media/libstagefright/C2OMXNode.cpp b/media/libstagefright/C2OMXNode.cpp
index e6f81af..04faa28 100644
--- a/media/libstagefright/C2OMXNode.cpp
+++ b/media/libstagefright/C2OMXNode.cpp
@@ -234,7 +234,7 @@
std::shared_ptr<C2Buffer> c2Buffer(
// TODO: fence
new Buffer2D(block->share(
- C2Rect(block->width(), block->height()), ::android::C2Fence())),
+ C2Rect(block->width(), block->height()), ::C2Fence())),
[handle, buffer, source = getSource()](C2Buffer *ptr) {
delete ptr;
native_handle_delete(handle);
diff --git a/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp b/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp
index 08b5d65..693eeea 100644
--- a/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp
+++ b/media/libstagefright/codec2/1.0/InputSurfaceConnection.cpp
@@ -123,7 +123,7 @@
std::shared_ptr<C2Buffer> c2Buffer(
// TODO: fence
new Buffer2D(block->share(
- C2Rect(block->width(), block->height()), ::android::C2Fence())),
+ C2Rect(block->width(), block->height()), ::C2Fence())),
[handle, bufferId, src = mSource](C2Buffer *ptr) {
delete ptr;
native_handle_delete(handle);
diff --git a/media/libstagefright/codec2/SimpleC2Component.cpp b/media/libstagefright/codec2/SimpleC2Component.cpp
index aaefd31..c345783 100644
--- a/media/libstagefright/codec2/SimpleC2Component.cpp
+++ b/media/libstagefright/codec2/SimpleC2Component.cpp
@@ -373,7 +373,7 @@
std::shared_ptr<C2Buffer> SimpleC2Component::createLinearBuffer(
const std::shared_ptr<C2LinearBlock> &block, size_t offset, size_t size) {
- return C2Buffer::CreateLinearBuffer(block->share(offset, size, ::android::C2Fence()));
+ return C2Buffer::CreateLinearBuffer(block->share(offset, size, ::C2Fence()));
}
std::shared_ptr<C2Buffer> SimpleC2Component::createGraphicBuffer(
@@ -383,7 +383,7 @@
std::shared_ptr<C2Buffer> SimpleC2Component::createGraphicBuffer(
const std::shared_ptr<C2GraphicBlock> &block, const C2Rect &crop) {
- return C2Buffer::CreateGraphicBuffer(block->share(crop, ::android::C2Fence()));
+ return C2Buffer::CreateGraphicBuffer(block->share(crop, ::C2Fence()));
}
} // namespace android
diff --git a/media/libstagefright/codec2/include/C2.h b/media/libstagefright/codec2/include/C2.h
index 508f9ae..e90fe42 100644
--- a/media/libstagefright/codec2/include/C2.h
+++ b/media/libstagefright/codec2/include/C2.h
@@ -141,9 +141,13 @@
/// \defgroup utils Utilities
/// @{
-#define C2_DO_NOT_COPY(type, args...) \
- type args& operator=(const type args&) = delete; \
- type(const type args&) = delete; \
+#define C2_DO_NOT_COPY(type) \
+ type& operator=(const type &) = delete; \
+ type(const type &) = delete; \
+
+#define C2_DEFAULT_MOVE(type) \
+ type& operator=(type &&) = default; \
+ type(type &&) = default; \
#define C2_ALLOW_OVERFLOW __attribute__((no_sanitize("integer")))
#define C2_CONST __attribute__((const))
@@ -274,7 +278,7 @@
/**
* Convert to a smaller counter type. This is always safe.
*/
- template<typename U, typename E=typename std::enable_if<sizeof(U) < sizeof(T)>::type>
+ template<typename U, typename E=typename std::enable_if<(sizeof(U) < sizeof(T))>::type>
inline operator c2_cntr_t<U>() {
return c2_cntr_t<U>(mValue);
}
@@ -295,7 +299,7 @@
return c2_cntr_t<T>(mValue op compat::get(value)); \
} \
\
- template<typename U, typename E=typename std::enable_if<sizeof(U) < sizeof(T)>::type> \
+ template<typename U, typename E=typename std::enable_if<(sizeof(U) < sizeof(T))>::type> \
attrib inline constexpr c2_cntr_t<U> operator op(const c2_cntr_t<U> &value) const { \
return c2_cntr_t<U>(U(mValue) op value.peeku()); \
}
diff --git a/media/libstagefright/codec2/include/C2Buffer.h b/media/libstagefright/codec2/include/C2Buffer.h
index e49f82b..0095800 100644
--- a/media/libstagefright/codec2/include/C2Buffer.h
+++ b/media/libstagefright/codec2/include/C2Buffer.h
@@ -1339,6 +1339,9 @@
uint32_t width;
uint32_t height;
+ constexpr inline C2Rect()
+ : C2Rect(0, 0, 0, 0) { }
+
constexpr inline C2Rect(uint32_t width_, uint32_t height_)
: C2Rect(width_, height_, 0, 0) { }
@@ -2262,10 +2265,4 @@
/// @}
-// expose some objects in android namespace
-namespace android {
- /// \deprecated
- typedef ::C2Fence C2Fence;
-}
-
#endif // C2BUFFER_H_
diff --git a/media/libstagefright/codec2/include/C2Component.h b/media/libstagefright/codec2/include/C2Component.h
index 64bd1cb..61fcfc0 100644
--- a/media/libstagefright/codec2/include/C2Component.h
+++ b/media/libstagefright/codec2/include/C2Component.h
@@ -38,23 +38,29 @@
CURRENT, ///< query currently possible values given dependent settings
};
- const C2ParamField field;
- const type_t type;
+private:
+ C2ParamField _mField;
+ type_t _mType;
+public:
c2_status_t status;
C2FieldSupportedValues values;
C2FieldSupportedValuesQuery(const C2ParamField &field_, type_t type_)
- : field(field_), type(type_), status(C2_NO_INIT) { }
+ : _mField(field_), _mType(type_), status(C2_NO_INIT) { }
- static C2FieldSupportedValuesQuery&&
+ static C2FieldSupportedValuesQuery
Current(const C2ParamField &field_) {
- return std::move(C2FieldSupportedValuesQuery(field_, CURRENT));
+ return C2FieldSupportedValuesQuery(field_, CURRENT);
}
- static C2FieldSupportedValuesQuery&&
+ static C2FieldSupportedValuesQuery
Possible(const C2ParamField &field_) {
- return std::move(C2FieldSupportedValuesQuery(field_, POSSIBLE));
+ return C2FieldSupportedValuesQuery(field_, POSSIBLE);
}
+
+ inline C2ParamField field() const { return _mField; };
+
+ inline type_t type() const { return _mType; }
};
/**
@@ -943,11 +949,4 @@
/// @}
-namespace android {
- /// \deprecated
- typedef ::C2Component C2Component;
- /// \deprecated
- typedef ::C2ComponentInterface C2ComponentInterface;
-}
-
#endif // C2COMPONENT_H_
diff --git a/media/libstagefright/codec2/include/C2Param.h b/media/libstagefright/codec2/include/C2Param.h
index 181697d..e0a743c 100644
--- a/media/libstagefright/codec2/include/C2Param.h
+++ b/media/libstagefright/codec2/include/C2Param.h
@@ -299,7 +299,7 @@
DEFINE_FIELD_BASED_COMPARISON_OPERATORS(Index, mIndex)
private:
- friend struct C2Param; // for setStream, makeStreamId, isValid
+ friend struct C2Param; // for setStream, MakeStreamId, isValid
friend struct _C2ParamInspector; // for testing
/**
@@ -320,7 +320,7 @@
/// returns the streamId bitfield for a given |stream|. If stream is invalid,
/// returns an invalid bitfield.
- inline static uint32_t makeStreamId(unsigned stream) {
+ inline static uint32_t MakeStreamId(unsigned stream) {
// saturate stream ID (max value is invalid)
if (stream > MAX_STREAM_ID) {
stream = MAX_STREAM_ID;
@@ -334,7 +334,7 @@
*/
inline bool setStream(unsigned stream) {
if (forStream()) {
- mIndex = (mIndex & ~STREAM_ID_MASK) | makeStreamId(stream);
+ mIndex = (mIndex & ~STREAM_ID_MASK) | MakeStreamId(stream);
return this->stream() < MAX_STREAM_ID;
}
return false;
@@ -455,7 +455,7 @@
// allow undefined or different direction (e.g. as constructed from C2PortParam() vs.
// C2PortParam::input), but still require equivalent type (stream, port or global); otherwise,
// return null.
- inline static const C2Param* ifSuitable(
+ inline static const C2Param* IfSuitable(
const C2Param* o, size_t size, Type type, size_t flexSize = 0, bool checkDir = true) {
if (o == nullptr || o->_mSize < size || (flexSize && ((o->_mSize - size) % flexSize))) {
return nullptr;
@@ -480,7 +480,7 @@
/// base constructor with stream set
inline C2Param(uint32_t paramSize, Index paramIndex, unsigned stream)
: _mSize(paramSize),
- _mIndex(paramIndex | Index::makeStreamId(stream)) {
+ _mIndex(paramIndex | Index::MakeStreamId(stream)) {
if (paramSize > sizeof(C2Param)) {
memset(this + 1, 0, paramSize - sizeof(C2Param));
}
@@ -664,7 +664,7 @@
template<typename S, typename T>
inline C2ParamField(S* param, T* offset)
: _mIndex(param->index()),
- _mFieldId(offset) {}
+ _mFieldId((T*)((uintptr_t)offset - (uintptr_t)param)) {}
/**
* Create a field identifier using a configuration parameter (variable),
@@ -698,7 +698,7 @@
*/
template<typename S>
inline C2ParamField(S* param)
- : _mIndex(param->index()), _mFieldId(0u, param->size()) {}
+ : _mIndex(param->index()), _mFieldId(0u, param->size()) { }
/**
* Equality operator.
@@ -735,27 +735,27 @@
public:
/// A union of supported primitive types.
union Primitive {
- int32_t i32; ///< int32_t value
- uint32_t u32; ///< uint32_t value
- c2_cntr32_t c32; ///< c2_cntr32_t value
- int64_t i64; ///< int64_t value
+ // first member is always zero initialized so it must be the largest
uint64_t u64; ///< uint64_t value
+ int64_t i64; ///< int64_t value
c2_cntr64_t c64; ///< c2_cntr64_t value
+ uint32_t u32; ///< uint32_t value
+ int32_t i32; ///< int32_t value
+ c2_cntr32_t c32; ///< c2_cntr32_t value
float fp; ///< float value
// constructors - implicit
- Primitive(int32_t value) : i32(value) { }
- Primitive(uint32_t value) : u32(value) { }
- Primitive(c2_cntr32_t value) : c32(value) { }
- Primitive(int64_t value) : i64(value) { }
Primitive(uint64_t value) : u64(value) { }
+ Primitive(int64_t value) : i64(value) { }
Primitive(c2_cntr64_t value) : c64(value) { }
+ Primitive(uint32_t value) : u32(value) { }
+ Primitive(int32_t value) : i32(value) { }
+ Primitive(c2_cntr32_t value) : c32(value) { }
Primitive(float value) : fp(value) { }
Primitive() : u64(0) { }
- private:
- friend class C2Value;
+ /** gets value out of the union */
template<typename T> const T &ref() const;
};
@@ -842,9 +842,9 @@
STRUCT_FLAG = 0x20000, ///< structs. Marked with this flag in addition to their coreIndex.
};
- typedef std::pair<C2String, C2Value::Primitive> named_value_type;
- typedef std::vector<const named_value_type> named_values_type;
- //typedef std::pair<std::vector<C2String>, std::vector<C2Value::Primitive>> named_values_type;
+ typedef std::pair<C2String, C2Value::Primitive> NamedValueType;
+ typedef std::vector<const NamedValueType> NamedValuesType;
+ //typedef std::pair<std::vector<C2String>, std::vector<C2Value::Primitive>> NamedValuesType;
/**
* Template specialization that returns the named values for a type.
@@ -854,15 +854,15 @@
* \return a vector of name-value pairs.
*/
template<typename B>
- static named_values_type namedValuesFor(const B &);
+ static NamedValuesType namedValuesFor(const B &);
- inline C2FieldDescriptor(uint32_t type, uint32_t length, C2StringLiteral name, size_t offset, size_t size)
- : _mType((type_t)type), _mLength(length), _mName(name), _mFieldId(offset, size) { }
+ inline C2FieldDescriptor(uint32_t type, uint32_t extent, C2StringLiteral name, size_t offset, size_t size)
+ : _mType((type_t)type), _mExtent(extent), _mName(name), _mFieldId(offset, size) { }
template<typename T, class B=typename std::remove_extent<T>::type>
inline C2FieldDescriptor(const T* offset, const char *name)
- : _mType(this->getType((B*)nullptr)),
- _mLength(std::is_array<T>::value ? std::extent<T>::value : 1),
+ : _mType(this->GetType((B*)nullptr)),
+ _mExtent(std::is_array<T>::value ? std::extent<T>::value : 1),
_mName(name),
_mNamedValues(namedValuesFor(*(B*)0)),
_mFieldId(offset) {}
@@ -870,8 +870,8 @@
/*
template<typename T, typename B=typename std::remove_extent<T>::type>
inline C2FieldDescriptor<T, B, false>(T* offset, const char *name)
- : _mType(this->getType((B*)nullptr)),
- _mLength(std::is_array<T>::value ? std::extent<T>::value : 1),
+ : _mType(this->GetType((B*)nullptr)),
+ _mExtent(std::is_array<T>::value ? std::extent<T>::value : 1),
_mName(name),
_mFieldId(offset) {}
*/
@@ -879,8 +879,8 @@
/// \deprecated
template<typename T, typename S, class B=typename std::remove_extent<T>::type>
constexpr inline C2FieldDescriptor(S*, T S::* field, const char *name)
- : _mType(this->getType((B*)nullptr)),
- _mLength(std::is_array<T>::value ? std::extent<T>::value : 1),
+ : _mType(this->GetType((B*)nullptr)),
+ _mExtent(std::is_array<T>::value ? std::extent<T>::value : 1),
_mName(name),
_mFieldId(&(((S*)0)->*field)) {}
@@ -888,11 +888,11 @@
inline type_t type() const { return _mType; }
/// returns the length of the field in case it is an array. Returns 0 for
/// T[] arrays, returns 1 for T[1] arrays as well as if the field is not an array.
- inline size_t length() const { return _mLength; }
+ inline size_t extent() const { return _mExtent; }
/// returns the name of the field
inline C2StringLiteral name() const { return _mName; }
- const named_values_type &namedValues() const { return _mNamedValues; }
+ const NamedValuesType &namedValues() const { return _mNamedValues; }
#if defined(FRIEND_TEST)
friend void PrintTo(const C2FieldDescriptor &, ::std::ostream*);
@@ -901,49 +901,51 @@
#endif
private:
- const type_t _mType;
- const uint32_t _mLength; // the last member can be arbitrary length if it is T[] array,
+ type_t _mType;
+ uint32_t _mExtent; // the last member can be arbitrary length if it is T[] array,
// extending to the end of the parameter (this is marked with
// 0). T[0]-s are not fields.
- const C2StringLiteral _mName;
- const named_values_type _mNamedValues;
+ C2StringLiteral _mName;
+ NamedValuesType _mNamedValues;
- const _C2FieldId _mFieldId; // field identifier (offset and size)
+ _C2FieldId _mFieldId; // field identifier (offset and size)
// NOTE: We do not capture default value(s) here as that may depend on the component.
// NOTE: We also do not capture bestEffort, as 1) this should be true for most fields,
// 2) this is at parameter granularity.
// type resolution
- inline static type_t getType(int32_t*) { return INT32; }
- inline static type_t getType(uint32_t*) { return UINT32; }
- inline static type_t getType(c2_cntr32_t*) { return CNTR32; }
- inline static type_t getType(int64_t*) { return INT64; }
- inline static type_t getType(uint64_t*) { return UINT64; }
- inline static type_t getType(c2_cntr64_t*) { return CNTR64; }
- inline static type_t getType(float*) { return FLOAT; }
- inline static type_t getType(char*) { return STRING; }
- inline static type_t getType(uint8_t*) { return BLOB; }
+ inline static type_t GetType(int32_t*) { return INT32; }
+ inline static type_t GetType(uint32_t*) { return UINT32; }
+ inline static type_t GetType(c2_cntr32_t*) { return CNTR32; }
+ inline static type_t GetType(int64_t*) { return INT64; }
+ inline static type_t GetType(uint64_t*) { return UINT64; }
+ inline static type_t GetType(c2_cntr64_t*) { return CNTR64; }
+ inline static type_t GetType(float*) { return FLOAT; }
+ inline static type_t GetType(char*) { return STRING; }
+ inline static type_t GetType(uint8_t*) { return BLOB; }
template<typename T,
class=typename std::enable_if<std::is_enum<T>::value>::type>
- inline static type_t getType(T*) {
+ inline static type_t GetType(T*) {
typename std::underlying_type<T>::type underlying(0);
- return getType(&underlying);
+ return GetType(&underlying);
}
// verify C2Struct by having a FIELD_LIST and a CORE_INDEX.
template<typename T,
class=decltype(T::CORE_INDEX + 1), class=decltype(T::FIELD_LIST)>
- inline static type_t getType(T*) {
+ inline static type_t GetType(T*) {
static_assert(!std::is_base_of<C2Param, T>::value, "cannot use C2Params as fields");
return (type_t)(T::CORE_INDEX | STRUCT_FLAG);
}
+
+ friend struct _C2ParamInspector;
};
#define DEFINE_NO_NAMED_VALUES_FOR(type) \
-template<> inline C2FieldDescriptor::named_values_type C2FieldDescriptor::namedValuesFor(const type &) { \
- return named_values_type(); \
+template<> inline C2FieldDescriptor::NamedValuesType C2FieldDescriptor::namedValuesFor(const type &) { \
+ return NamedValuesType(); \
}
// We cannot subtype constructor for enumerated types so insted define no named values for
@@ -1016,6 +1018,14 @@
*/
inline bool isPersistent() const { return _mAttrib & IS_PERSISTENT; }
+ inline bool isStrict() const { return _mAttrib & IS_STRICT; }
+
+ inline bool isReadOnly() const { return _mAttrib & IS_READ_ONLY; }
+
+ inline bool isVisible() const { return !(_mAttrib & IS_HIDDEN); }
+
+ inline bool isPublic() const { return !(_mAttrib & IS_INTERNAL); }
+
/// 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; }
@@ -1024,31 +1034,52 @@
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; }
+ inline const std::vector<C2Param::Index> &dependencies() const { return _mDependencies; }
- // TODO: add more constructors that allow setting dependencies and attributes
-
+ /// \deprecated
template<typename T>
inline C2ParamDescriptor(bool isRequired, C2StringLiteral name, const T*)
: _mIndex(T::PARAM_TYPE),
_mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
_mName(name) { }
+ /// \deprecated
inline C2ParamDescriptor(
bool isRequired, C2StringLiteral name, C2Param::Index index)
: _mIndex(index),
_mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
_mName(name) { }
-private:
enum attrib_t : uint32_t {
- IS_REQUIRED = 1u << 0,
- IS_PERSISTENT = 1u << 1,
+ // flags that default on
+ IS_REQUIRED = 1u << 0, ///< parameter is required to be specified
+ IS_PERSISTENT = 1u << 1, ///< parameter retains its value
+ // flags that default off
+ IS_STRICT = 1u << 2, ///< parameter is strict
+ IS_READ_ONLY = 1u << 3, ///< parameter is publicly read-only
+ IS_HIDDEN = 1u << 4, ///< parameter shall not be visible to clients
+ IS_INTERNAL = 1u << 5, ///< parameter shall not be used by framework (other than testing)
};
+
+ inline C2ParamDescriptor(
+ C2Param::Index index, attrib_t attrib, C2StringLiteral name)
+ : _mIndex(index),
+ _mAttrib(attrib),
+ _mName(name) { }
+
+ inline C2ParamDescriptor(
+ C2Param::Index index, attrib_t attrib, C2String &&name,
+ std::vector<C2Param::Index> &&dependencies)
+ : _mIndex(index),
+ _mAttrib(attrib),
+ _mName(name),
+ _mDependencies(std::move(dependencies)) { }
+
+private:
const C2Param::Index _mIndex;
const uint32_t _mAttrib;
const C2String _mName;
- std::vector<C2Param::Index> mDependencies;
+ std::vector<C2Param::Index> _mDependencies;
friend struct _C2ParamInspector;
};
@@ -1138,7 +1169,7 @@
* private:
* // may have private constructors taking number of widths as the first argument
* // This is used by the C2Param factory methods, e.g.
- * // C2VideoFlexWidthsGlobalParam::alloc_unique(size_t, int32_t);
+ * // C2VideoFlexWidthsGlobalParam::AllocUnique(size_t, int32_t);
* C2VideoFlexWidthsStruct(size_t flexCount, int32_t value) {
* for (size_t i = 0; i < flexCount; ++i) {
* widths[i] = value;
@@ -1148,7 +1179,7 @@
* // If the last argument is T[N] or std::initializer_list<T>, the flexCount will
* // be automatically calculated and passed by the C2Param factory methods, e.g.
* // int widths[] = { 1, 2, 3 };
- * // C2VideoFlexWidthsGlobalParam::alloc_unique(widths);
+ * // C2VideoFlexWidthsGlobalParam::AllocUnique(widths);
* template<unsigned N>
* C2VideoFlexWidthsStruct(size_t flexCount, const int32_t(&init)[N]) {
* for (size_t i = 0; i < flexCount; ++i) {
@@ -1261,7 +1292,7 @@
* descriptions, but we want to conserve memory if client only wants the description
* of a few indices.
*/
- virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex coreIndex) = 0;
+ virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex coreIndex) const = 0;
protected:
virtual ~C2ParamReflector() = default;
@@ -1270,9 +1301,9 @@
/**
* Generic supported values for a field.
*
- * This can be either a range or a set of values. The range can be linear or geometric with a
- * clear minimum and maximum value, and can have an optional step size or geometric ratio. Values
- * can optionally represent flags.
+ * This can be either a range or a set of values. The range can be a simple range, an arithmetic,
+ * geometric or multiply-accumulate series with a clear minimum and maximum value. Values can
+ * be discrete values, or can optionally represent flags to be or-ed.
*
* \note Do not use flags to represent bitfields. Use individual values or separate fields instead.
*/
@@ -1285,17 +1316,47 @@
FLAGS ///< a list of flags that can be OR-ed
};
- type_t type;
+ type_t type; /** Type of values for this field. */
typedef C2Value::Primitive Primitive;
+ /**
+ * Range specifier for supported value. Used if type is RANGE.
+ *
+ * If step is 0 and num and denom are both 1, the supported values are any value, for which
+ * min <= value <= max.
+ *
+ * Otherwise, the range represents a geometric/arithmetic/multiply-accumulate series, where
+ * successive supported values can be derived from previous values (starting at min), using the
+ * following formula:
+ * v[0] = min
+ * v[i] = v[i-1] * num / denom + step for i >= 1, while min < v[i] <= max.
+ */
struct {
+ /** Lower end of the range (inclusive). */
Primitive min;
+ /** Upper end of the range (inclusive if permitted by series). */
Primitive max;
+ /** Step between supported values. */
Primitive step;
+ /** Numerator of a geometric series. */
Primitive num;
+ /** Denominator of a geometric series. */
Primitive denom;
} range;
+
+ /**
+ * List of values. Used if type is VALUES or FLAGS.
+ *
+ * If type is VALUES, this is the list of supported values in decreasing preference.
+ *
+ * If type is FLAGS, this vector contains { min-mask, flag1, flag2... }. Basically, the first
+ * value is the required set of flags to be set, and the rest of the values are flags that can
+ * be set independently. FLAGS is only supported for integral types. Supported flags should
+ * not overlap, as it can make validation non-deterministic. The standard validation method
+ * is that starting from the original value, if each flag is removed when fully present (the
+ * min-mask must be fully present), we shall arrive at 0.
+ */
std::vector<Primitive> values;
C2FieldSupportedValues()
@@ -1313,14 +1374,21 @@
range{min, max, (T)0, num, den} { }
template<typename T>
+ C2FieldSupportedValues(T min, T max, T step, T num, T den)
+ : type(RANGE),
+ range{min, max, step, num, den} { }
+
+ /// \deprecated
+ template<typename T>
C2FieldSupportedValues(bool flags, std::initializer_list<T> list)
: type(flags ? FLAGS : VALUES),
range{(T)0, (T)0, (T)0, (T)0, (T)0} {
- for(T value : list) {
+ for (T value : list) {
values.emplace_back(value);
}
}
+ /// \deprecated
template<typename T>
C2FieldSupportedValues(bool flags, const std::vector<T>& list)
: type(flags ? FLAGS : VALUES),
@@ -1332,20 +1400,23 @@
/// \internal
/// \todo: create separate values vs. flags initializer as for flags we want
- /// to list both allowed and disallowed flags
+ /// to list both allowed and required flags
template<typename T, typename E=decltype(C2FieldDescriptor::namedValuesFor(*(T*)0))>
C2FieldSupportedValues(bool flags, const T*)
: type(flags ? FLAGS : VALUES),
range{(T)0, (T)0, (T)0, (T)0, (T)0} {
- C2FieldDescriptor::named_values_type named = C2FieldDescriptor::namedValuesFor(*(T*)0);
- for (const C2FieldDescriptor::named_value_type &item : named) {
+ C2FieldDescriptor::NamedValuesType named = C2FieldDescriptor::namedValuesFor(*(T*)0);
+ if (flags) {
+ values.emplace_back(0); // min-mask defaults to 0
+ }
+ for (const C2FieldDescriptor::NamedValueType &item : named){
values.emplace_back(item.second);
}
}
};
/**
- * Spported values for a specific field.
+ * Supported values for a specific field.
*
* This is a pair of the field specifier together with an optional supported values object.
* This structure is used when reporting parameter configuration failures and conflicts.
@@ -1357,6 +1428,41 @@
/// blobs) describe the supported values for each element (character for string, and bytes for
/// blobs). It is optional for read-only strings and blobs.
std::unique_ptr<C2FieldSupportedValues> values;
+
+ // This struct is meant to be move constructed.
+ C2_DEFAULT_MOVE(C2ParamFieldValues);
+
+ // Copy constructor/assignment is also provided as this object may get copied.
+ C2ParamFieldValues(const C2ParamFieldValues &other)
+ : paramOrField(other.paramOrField),
+ values(other.values ? std::make_unique<C2FieldSupportedValues>(*other.values) : nullptr) { }
+
+ C2ParamFieldValues& operator=(const C2ParamFieldValues &other) {
+ paramOrField = other.paramOrField;
+ values = other.values ? std::make_unique<C2FieldSupportedValues>(*other.values) : nullptr;
+ return *this;
+ }
+
+
+ /**
+ * Construct with no values.
+ */
+ C2ParamFieldValues(const C2ParamField ¶mOrField_)
+ : paramOrField(paramOrField_) { }
+
+ /**
+ * Construct with values.
+ */
+ C2ParamFieldValues(const C2ParamField ¶mOrField_, const C2FieldSupportedValues &values_)
+ : paramOrField(paramOrField_),
+ values(std::make_unique<C2FieldSupportedValues>(values_)) { }
+
+ /**
+ * Construct from fields.
+ */
+ C2ParamFieldValues(const C2ParamField ¶mOrField_, std::unique_ptr<C2FieldSupportedValues> &&values_)
+ : paramOrField(paramOrField_),
+ values(std::move(values_)) { }
};
/// @}
diff --git a/media/libstagefright/codec2/include/C2ParamDef.h b/media/libstagefright/codec2/include/C2ParamDef.h
index f0b6223..86c6833 100644
--- a/media/libstagefright/codec2/include/C2ParamDef.h
+++ b/media/libstagefright/codec2/include/C2ParamDef.h
@@ -36,14 +36,14 @@
struct C2_HIDE _C2Comparable_impl
{
template<typename S, typename=decltype(S() == S())>
- static std::true_type __testEQ(int);
+ static std::true_type TestEqual(int);
template<typename>
- static std::false_type __testEQ(...);
+ static std::false_type TestEqual(...);
template<typename S, typename=decltype(S() != S())>
- static std::true_type __testNE(int);
+ static std::true_type TestNotEqual(int);
template<typename>
- static std::false_type __testNE(...);
+ static std::false_type TestNotEqual(...);
};
/**
@@ -53,30 +53,30 @@
*/
template<typename S>
struct C2_HIDE _C2Comparable
- : public std::integral_constant<bool, decltype(_C2Comparable_impl::__testEQ<S>(0))::value
- || decltype(_C2Comparable_impl::__testNE<S>(0))::value> {
+ : public std::integral_constant<bool, decltype(_C2Comparable_impl::TestEqual<S>(0))::value
+ || decltype(_C2Comparable_impl::TestNotEqual<S>(0))::value> {
};
/// Helper class that checks if a type has a CORE_INDEX constant.
struct C2_HIDE _C2CoreIndexHelper_impl
{
template<typename S, int=S::CORE_INDEX>
- static std::true_type __testCoreIndex(int);
+ static std::true_type TestCoreIndex(int);
template<typename>
- static std::false_type __testCoreIndex(...);
+ static std::false_type TestCoreIndex(...);
};
/// Helper template that verifies a type's CORE_INDEX and creates it if the type does not have one.
template<typename S, int CoreIndex,
- bool HasBase=decltype(_C2CoreIndexHelper_impl::__testCoreIndex<S>(0))::value>
-struct C2_HIDE C2CoreIndexOverride {
+ bool HasBase=decltype(_C2CoreIndexHelper_impl::TestCoreIndex<S>(0))::value>
+struct C2_HIDE _C2CoreIndexOverride {
// TODO: what if we allow structs without CORE_INDEX?
static_assert(CoreIndex == S::CORE_INDEX, "CORE_INDEX differs from structure");
};
/// Specialization for types without a CORE_INDEX.
template<typename S, int CoreIndex>
-struct C2_HIDE C2CoreIndexOverride<S, CoreIndex, false> {
+struct C2_HIDE _C2CoreIndexOverride<S, CoreIndex, false> {
public:
enum : uint32_t {
CORE_INDEX = CoreIndex, ///< CORE_INDEX override.
@@ -85,7 +85,7 @@
/// Helper template that adds a CORE_INDEX to a type if it does not have one.
template<typename S, int CoreIndex>
-struct C2_HIDE C2AddCoreIndex : public S, public C2CoreIndexOverride<S, CoreIndex> {};
+struct C2_HIDE _C2AddCoreIndex : public S, public _C2CoreIndexOverride<S, CoreIndex> {};
/**
* \brief Helper class to check struct requirements for parameters.
@@ -95,7 +95,7 @@
* - expose PARAM_TYPE, and non-flex FLEX_SIZE.
*/
template<typename S, int CoreIndex, unsigned TypeFlags>
-struct C2_HIDE C2StructCheck {
+struct C2_HIDE _C2StructCheck {
static_assert(
std::is_default_constructible<S>::value, "C2 structure must have default constructor");
static_assert(!std::is_polymorphic<S>::value, "C2 structure must not have virtual methods");
@@ -116,15 +116,15 @@
struct C2_HIDE _C2Flexible_impl {
/// specialization for types that have a FLEX_SIZE member
template<typename S, unsigned=S::FLEX_SIZE>
- static std::true_type __testFlexSize(int);
+ static std::true_type TestFlexSize(int);
template<typename>
- static std::false_type __testFlexSize(...);
+ static std::false_type TestFlexSize(...);
};
/// Helper template that returns if a type has an integer FLEX_SIZE member.
template<typename S>
struct C2_HIDE _C2Flexible
- : public std::integral_constant<bool, decltype(_C2Flexible_impl::__testFlexSize<S>(0))::value> {
+ : public std::integral_constant<bool, decltype(_C2Flexible_impl::TestFlexSize<S>(0))::value> {
};
/// Macro to test if a type is flexible (has a FLEX_SIZE member).
@@ -165,9 +165,9 @@
* flexible struct, so may not be needed here)
*/
template<typename S, int ParamIndex, unsigned TypeFlags>
-struct C2_HIDE C2FlexStructCheck :
-// add flexible flag as C2StructCheck defines PARAM_TYPE
- public C2StructCheck<S, ParamIndex | C2Param::CoreIndex::IS_FLEX_FLAG, TypeFlags> {
+struct C2_HIDE _C2FlexStructCheck :
+// add flexible flag as _C2StructCheck defines PARAM_TYPE
+ public _C2StructCheck<S, ParamIndex | C2Param::CoreIndex::IS_FLEX_FLAG, TypeFlags> {
public:
enum : uint32_t {
/// \hideinitializer
@@ -177,12 +177,12 @@
const static std::initializer_list<const C2FieldDescriptor> FIELD_LIST; // TODO assign here
// default constructor needed because of the disabled copy constructor
- inline C2FlexStructCheck() = default;
+ inline _C2FlexStructCheck() = default;
protected:
// cannot copy flexible params
- C2FlexStructCheck(const C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
- C2FlexStructCheck& operator= (const C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
+ _C2FlexStructCheck(const _C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
+ _C2FlexStructCheck& operator= (const _C2FlexStructCheck<S, ParamIndex, TypeFlags> &) = delete;
// constants used for helper methods
enum : uint32_t {
@@ -195,7 +195,7 @@
};
/// returns the allocated size of this param with flexCount, or 0 if it would overflow.
- inline static size_t calcSize(size_t flexCount, size_t size = BASE_SIZE) {
+ inline static size_t CalcSize(size_t flexCount, size_t size = BASE_SIZE) {
if (flexCount <= (MAX_SIZE - size) / S::FLEX_SIZE) {
return size + S::FLEX_SIZE * flexCount;
}
@@ -205,7 +205,7 @@
/// dynamic new operator usable for params of type S
inline void* operator new(size_t size, size_t flexCount) noexcept {
// TODO: assert(size == BASE_SIZE);
- size = calcSize(flexCount, size);
+ size = CalcSize(flexCount, size);
if (size > 0) {
return ::operator new(size);
}
@@ -217,12 +217,12 @@
/// Expose FIELD_LIST from subClass;
template<typename S, int ParamIndex, unsigned TypeFlags>
const std::initializer_list<const C2FieldDescriptor>
-C2FlexStructCheck<S, ParamIndex, TypeFlags>::FIELD_LIST = S::FIELD_LIST;
+_C2FlexStructCheck<S, ParamIndex, TypeFlags>::FIELD_LIST = S::FIELD_LIST;
/// Define From() cast operators for params.
#define DEFINE_CAST_OPERATORS(_Type) \
inline static _Type* From(C2Param *other) { \
- return (_Type*)C2Param::ifSuitable( \
+ return (_Type*)C2Param::IfSuitable( \
other, sizeof(_Type), _Type::PARAM_TYPE, _Type::FLEX_SIZE, \
(_Type::PARAM_TYPE & T::Index::DIR_UNDEFINED) != T::Index::DIR_UNDEFINED); \
} \
@@ -232,40 +232,40 @@
inline static _Type* From(std::nullptr_t) { return nullptr; } \
/**
- * Define flexible allocators (alloc_shared or alloc_unique) for flexible params.
- * - P::alloc_xyz(flexCount, args...): allocate for given flex-count.
- * - P::alloc_xyz(args..., T[]): allocate for size of (and with) init array.
- * - P::alloc_xyz(T[]): allocate for size of (and with) init array with no other args.
- * - P::alloc_xyz(args..., std::initializer_list<T>): allocate for size of (and with) initializer
+ * Define flexible allocators (AllocShared or AllocUnique) for flexible params.
+ * - P::AllocXyz(flexCount, args...): allocate for given flex-count.
+ * - P::AllocXyz(args..., T[]): allocate for size of (and with) init array.
+ * - P::AllocXyz(T[]): allocate for size of (and with) init array with no other args.
+ * - P::AllocXyz(args..., std::initializer_list<T>): allocate for size of (and with) initializer
* list.
*/
-#define DEFINE_FLEXIBLE_ALLOC(_Type, S, ptr) \
+#define DEFINE_FLEXIBLE_ALLOC(_Type, S, ptr, Ptr) \
template<typename ...Args> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr(size_t flexCount, const Args(&... args)) { \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr(size_t flexCount, const Args(&... args)) { \
return std::ptr##_ptr<_Type>(new(flexCount) _Type(flexCount, args...)); \
} \
/* NOTE: unfortunately this is not supported by clang yet */ \
template<typename ...Args, typename U=typename S::FlexType, unsigned N> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr(const Args(&... args), const U(&init)[N]) { \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr(const Args(&... args), const U(&init)[N]) { \
return std::ptr##_ptr<_Type>(new(N) _Type(N, args..., init)); \
} \
/* so for now, specialize for no args */ \
template<typename U=typename S::FlexType, unsigned N> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr(const U(&init)[N]) { \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr(const U(&init)[N]) { \
return std::ptr##_ptr<_Type>(new(N) _Type(N, init)); \
} \
template<typename ...Args, typename U=typename S::FlexType> \
- inline static std::ptr##_ptr<_Type> alloc_##ptr( \
+ inline static std::ptr##_ptr<_Type> Alloc##Ptr( \
const Args(&... args), const std::initializer_list<U> &init) { \
return std::ptr##_ptr<_Type>(new(init.size()) _Type(init.size(), args..., init)); \
} \
/**
- * Define flexible methods alloc_shared, alloc_unique and flexCount.
+ * Define flexible methods AllocShared, AllocUnique and flexCount.
*/
#define DEFINE_FLEXIBLE_METHODS(_Type, S) \
- DEFINE_FLEXIBLE_ALLOC(_Type, S, shared) \
- DEFINE_FLEXIBLE_ALLOC(_Type, S, unique) \
+ DEFINE_FLEXIBLE_ALLOC(_Type, S, shared, Shared) \
+ DEFINE_FLEXIBLE_ALLOC(_Type, S, unique, Unique) \
inline size_t flexCount() const { \
static_assert(sizeof(_Type) == _Type::BASE_SIZE, "incorrect BASE_SIZE"); \
size_t sz = this->size(); \
@@ -312,8 +312,8 @@
* structures.
*/
template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
-struct C2_HIDE C2GlobalParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
+struct C2_HIDE C2GlobalParam : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
private:
typedef C2GlobalParam<T, S, ParamIndex> _Type;
@@ -342,14 +342,14 @@
*/
template<typename T, typename S, int ParamIndex>
struct C2_HIDE C2GlobalParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
- : public T, public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
+ : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_GLOBAL> {
private:
typedef C2GlobalParam<T, S, ParamIndex> _Type;
/// Wrapper around base structure's constructor.
template<typename ...Args>
inline C2GlobalParam(size_t flexCount, const Args(&... args))
- : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), _Type::PARAM_TYPE), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -378,8 +378,8 @@
* unspecified port expose a setPort method, and add an initial port parameter to the constructor.
*/
template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
-struct C2_HIDE C2PortParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- private C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_UNDEFINED> {
+struct C2_HIDE C2PortParam : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ private _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_UNDEFINED> {
private:
typedef C2PortParam<T, S, ParamIndex> _Type;
@@ -396,8 +396,8 @@
DEFINE_CAST_OPERATORS(_Type)
/// Specialization for an input port parameter.
- struct input : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
+ struct input : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
/// Wrapper around base structure's constructor.
template<typename ...Args>
inline input(const Args(&... args)) : T(sizeof(_Type), input::PARAM_TYPE), S(args...) { }
@@ -407,8 +407,8 @@
};
/// Specialization for an output port parameter.
- struct output : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
+ struct output : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
/// Wrapper around base structure's constructor.
template<typename ...Args>
inline output(const Args(&... args)) : T(sizeof(_Type), output::PARAM_TYPE), S(args...) { }
@@ -438,16 +438,16 @@
*/
template<typename T, typename S, int ParamIndex>
struct C2_HIDE C2PortParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
- : public T, public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_UNDEFINED> {
+ : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Type::DIR_UNDEFINED> {
private:
typedef C2PortParam<T, S, ParamIndex> _Type;
/// Default constructor for basic allocation: new(flexCount) P.
- inline C2PortParam(size_t flexCount) : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE) { }
+ inline C2PortParam(size_t flexCount) : T(_Type::CalcSize(flexCount), _Type::PARAM_TYPE) { }
template<typename ...Args>
/// Wrapper around base structure's constructor while also specifying port/direction.
inline C2PortParam(size_t flexCount, bool _output, const Args(&... args))
- : T(_Type::calcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE),
+ : T(_Type::CalcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE),
m(flexCount, args...) { }
public:
@@ -461,12 +461,12 @@
/// Specialization for an input port parameter.
struct input : public T,
- public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
+ public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> {
private:
/// Wrapper around base structure's constructor while also specifying port/direction.
template<typename ...Args>
inline input(size_t flexCount, const Args(&... args))
- : T(_Type::calcSize(flexCount), input::PARAM_TYPE), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), input::PARAM_TYPE), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -477,12 +477,12 @@
/// Specialization for an output port parameter.
struct output : public T,
- public C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
+ public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> {
private:
/// Wrapper around base structure's constructor while also specifying port/direction.
template<typename ...Args>
inline output(size_t flexCount, const Args(&... args))
- : T(_Type::calcSize(flexCount), output::PARAM_TYPE), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), output::PARAM_TYPE), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -514,8 +514,8 @@
* parameter to the constructor.
*/
template<typename T, typename S, int ParamIndex=S::CORE_INDEX, class Flex=void>
-struct C2_HIDE C2StreamParam : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- private C2StructCheck<S, ParamIndex,
+struct C2_HIDE C2StreamParam : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ private _C2StructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Index::DIR_UNDEFINED> {
private:
typedef C2StreamParam<T, S, ParamIndex> _Type;
@@ -537,8 +537,8 @@
DEFINE_CAST_OPERATORS(_Type)
/// Specialization for an input stream parameter.
- struct input : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex,
+ struct input : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> {
/// Default constructor. Stream-ID is undefined.
inline input() : T(sizeof(_Type), input::PARAM_TYPE) { }
@@ -553,8 +553,8 @@
};
/// Specialization for an output stream parameter.
- struct output : public T, public S, public C2CoreIndexOverride<S, ParamIndex>,
- public C2StructCheck<S, ParamIndex,
+ struct output : public T, public S, public _C2CoreIndexOverride<S, ParamIndex>,
+ public _C2StructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> {
/// Default constructor. Stream-ID is undefined.
inline output() : T(sizeof(_Type), output::PARAM_TYPE) { }
@@ -593,17 +593,17 @@
template<typename T, typename S, int ParamIndex>
struct C2_HIDE C2StreamParam<T, S, ParamIndex, IF_FLEXIBLE(S)>
: public T,
- public C2FlexStructCheck<S, ParamIndex,
+ public _C2FlexStructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Index::DIR_UNDEFINED> {
private:
typedef C2StreamParam<T, S, ParamIndex> _Type;
/// Default constructor. Port/direction and stream-ID is undefined.
- inline C2StreamParam(size_t flexCount) : T(_Type::calcSize(flexCount), _Type::PARAM_TYPE, 0u) { }
+ inline C2StreamParam(size_t flexCount) : T(_Type::CalcSize(flexCount), _Type::PARAM_TYPE, 0u) { }
/// Wrapper around base structure's constructor while also specifying port/direction and
/// stream-ID.
template<typename ...Args>
inline C2StreamParam(size_t flexCount, bool _output, unsigned stream, const Args(&... args))
- : T(_Type::calcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE, stream),
+ : T(_Type::CalcSize(flexCount), _output ? output::PARAM_TYPE : input::PARAM_TYPE, stream),
m(flexCount, args...) { }
public:
@@ -619,15 +619,15 @@
/// Specialization for an input stream parameter.
struct input : public T,
- public C2FlexStructCheck<S, ParamIndex,
+ public _C2FlexStructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> {
private:
/// Default constructor. Stream-ID is undefined.
- inline input(size_t flexCount) : T(_Type::calcSize(flexCount), input::PARAM_TYPE) { }
+ inline input(size_t flexCount) : T(_Type::CalcSize(flexCount), input::PARAM_TYPE) { }
/// Wrapper around base structure's constructor while also specifying stream-ID.
template<typename ...Args>
inline input(size_t flexCount, unsigned stream, const Args(&... args))
- : T(_Type::calcSize(flexCount), input::PARAM_TYPE, stream), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), input::PARAM_TYPE, stream), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -641,15 +641,15 @@
/// Specialization for an output stream parameter.
struct output : public T,
- public C2FlexStructCheck<S, ParamIndex,
+ public _C2FlexStructCheck<S, ParamIndex,
T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> {
private:
/// Default constructor. Stream-ID is undefined.
- inline output(size_t flexCount) : T(_Type::calcSize(flexCount), output::PARAM_TYPE) { }
+ inline output(size_t flexCount) : T(_Type::CalcSize(flexCount), output::PARAM_TYPE) { }
/// Wrapper around base structure's constructor while also specifying stream-ID.
template<typename ...Args>
inline output(size_t flexCount, unsigned stream, const Args(&... args))
- : T(_Type::calcSize(flexCount), output::PARAM_TYPE, stream), m(flexCount, args...) { }
+ : T(_Type::CalcSize(flexCount), output::PARAM_TYPE, stream), m(flexCount, args...) { }
public:
S m; ///< wrapped flexible structure
@@ -818,19 +818,19 @@
private:
/// Construct from a C2MemoryBlock.
- /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
+ /// Used only by the flexible parameter allocators (AllocUnique & AllocShared).
inline C2SimpleArrayStruct(size_t flexCount, const C2MemoryBlock<T> &block) {
_C2ValueArrayHelper::init(values, flexCount, block);
}
/// Construct from an initializer list.
- /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
+ /// Used only by the flexible parameter allocators (AllocUnique & AllocShared).
inline C2SimpleArrayStruct(size_t flexCount, const std::initializer_list<T> &init) {
_C2ValueArrayHelper::init(values, flexCount, init);
}
/// Construct from another flexible array.
- /// Used only by the flexible parameter allocators (alloc_unique & alloc_shared).
+ /// Used only by the flexible parameter allocators (AllocUnique & AllocShared).
template<unsigned N>
inline C2SimpleArrayStruct(size_t flexCount, const T(&init)[N]) {
_C2ValueArrayHelper::init(values, flexCount, init);
diff --git a/media/libstagefright/codec2/include/C2Work.h b/media/libstagefright/codec2/include/C2Work.h
index a2f02e5..1a35519 100644
--- a/media/libstagefright/codec2/include/C2Work.h
+++ b/media/libstagefright/codec2/include/C2Work.h
@@ -37,17 +37,20 @@
*/
struct C2SettingResult {
enum Failure : uint32_t {
- READ_ONLY, ///< parameter is read-only and cannot be set
- MISMATCH, ///< parameter mismatches input data
- BAD_VALUE, ///< parameter does not accept value
+ /* parameter failures below */
BAD_TYPE, ///< parameter is not supported
BAD_PORT, ///< parameter is not supported on the specific port
BAD_INDEX, ///< parameter is not supported on the specific stream
- CONFLICT, ///< parameter is in conflict with an/other setting(s)
- /// parameter is out of range due to other settings (this failure mode
- /// can only be used for strict parameters)
- UNSUPPORTED,
+ READ_ONLY, ///< parameter is read-only and cannot be set
+ MISMATCH, ///< parameter mismatches input data
+ /* field failures below */
+ BAD_VALUE, ///< parameter does not accept value for the field at all
+ CONFLICT, ///< parameter field value is in conflict with an/other setting(s)
+
+ /// parameter field is out of range due to other settings (this failure mode
+ /// can only be used for strict calculated parameters)
+ UNSUPPORTED,
/// requested parameter value is in conflict with an/other setting(s)
/// and has been corrected to the closest supported value. This failure
@@ -58,14 +61,15 @@
Failure failure; ///< failure code
- /// Failing (or corrected) field. Currently supported values for the field. This is set if
+ /// Failing (or corrected) field or parameterand optionally, currently supported values for the
+ /// field. Values must only be set for field failures other than BAD_VALUE, and only if they are
/// different from the globally supported values (e.g. due to restrictions by another param or
- /// input data)
- /// \todo need to define suggestions for masks to be set and unset.
+ /// input data).
C2ParamFieldValues field;
/// Conflicting parameters or fields with optional suggestions with (optional) suggested values
- /// for any conflicting fields to avoid the conflict.
+ /// for any conflicting fields to avoid the conflict. Must only be set for CONFLICT, UNSUPPORTED
+ /// and INFO_CONFLICT failure codes.
std::vector<C2ParamFieldValues> conflicts;
};
diff --git a/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h b/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h
index e46d03c..b011a06 100644
--- a/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h
+++ b/media/libstagefright/codec2/include/media/stagefright/codec2/1.0/InputSurface.h
@@ -48,7 +48,7 @@
// Methods from IInputSurface
sp<InputSurfaceConnection> connectToComponent(
- const std::shared_ptr<::android::C2Component> &comp);
+ const std::shared_ptr<::C2Component> &comp);
// TODO: intf()
static sp<InputSurface> Create();
diff --git a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
index 7da824b..e555e8c 100644
--- a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
+++ b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
@@ -37,7 +37,7 @@
template <class T> std::unique_ptr<T> alloc_unique_cstr(const char *cstr) {
size_t len = strlen(cstr);
- std::unique_ptr<T> ptr = T::alloc_unique(len);
+ std::unique_ptr<T> ptr = T::AllocUnique(len);
memcpy(ptr->m.value, cstr, len);
return ptr;
}
@@ -182,7 +182,7 @@
template <> std::unique_ptr<C2PortMimeConfig::input> makeParam() {
// TODO(hiroh): Set more precise length.
- return C2PortMimeConfig::input::alloc_unique(100);
+ return C2PortMimeConfig::input::AllocUnique(100);
}
#define TRACED_FAILURE(func) \
diff --git a/media/libstagefright/codec2/tests/C2Param_test.cpp b/media/libstagefright/codec2/tests/C2Param_test.cpp
index 168b889..fcfbafd 100644
--- a/media/libstagefright/codec2/tests/C2Param_test.cpp
+++ b/media/libstagefright/codec2/tests/C2Param_test.cpp
@@ -45,14 +45,14 @@
}
}
*os << " " << fd.name();
- if (fd.length() > 1) {
- *os << "[" << fd.length() << "]";
- } else if (fd.length() == 0) {
+ if (fd.extent() > 1) {
+ *os << "[" << fd.extent() << "]";
+ } else if (fd.extent() == 0) {
*os << "[]";
}
*os << " (";
PrintTo(fd._mFieldId, os);
- *os << "*" << fd.length() << ")";
+ *os << "*" << fd.extent() << ")";
}
enum C2ParamIndexType : C2Param::type_index_t {
@@ -102,7 +102,7 @@
bool operator==(const C2FieldDescriptor &a, const C2FieldDescriptor &b) {
return a.type() == b.type()
- && a.length() == b.length()
+ && a.extent() == b.extent()
&& strcmp(a.name(), b.name()) == 0
&& a._mFieldId == b._mFieldId;
}
@@ -140,7 +140,7 @@
// verify first field descriptor
EXPECT_EQ(FD::INT32, fields[0].type());
EXPECT_STREQ("s32", fields[0].name());
- EXPECT_EQ(1u, fields[0].length());
+ EXPECT_EQ(1u, fields[0].extent());
EXPECT_EQ(_C2FieldId(0, 4), fields[0]._mFieldId);
EXPECT_EQ(expected[0], fields[0]);
@@ -736,7 +736,7 @@
s.value = 11;
s = 12;
(void)C2NumberConfig3::FIELD_LIST;
- std::shared_ptr<C2VideoNameConfig> n = C2VideoNameConfig::alloc_shared(25);
+ std::shared_ptr<C2VideoNameConfig> n = C2VideoNameConfig::AllocShared(25);
strcpy(n->m.value, "lajos");
C2NumberConfig4 t(false, 0, 11);
t.value = 15;
@@ -764,10 +764,10 @@
std::list<const C2FieldDescriptor> myList = C2NumberConfig::FIELD_LIST;
- std::unique_ptr<android::C2ParamDescriptor> __test_describe(uint32_t paramType) {
+ std::unique_ptr<C2ParamDescriptor> __test_describe(uint32_t paramType) {
std::list<const C2FieldDescriptor> fields = describeC2Params<C2NumberConfig>();
- auto widths = C2NumbersInfo::alloc_shared(5);
+ auto widths = C2NumbersInfo::AllocShared(5);
widths->flexCount();
widths->m.mNumbers[4] = 1;
@@ -1110,7 +1110,7 @@
{
C2NumberInfo inf(100);
- std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::alloc_unique(1);
+ std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::AllocUnique(1);
EXPECT_EQ(tun.coreIndex(), inf.coreIndex());
EXPECT_NE(tun.coreIndex(), tun_->coreIndex());
@@ -1661,8 +1661,8 @@
void StaticTestAddCoreIndex() {
struct nobase {};
struct base { enum : uint32_t { CORE_INDEX = 1 }; };
- static_assert(C2AddCoreIndex<nobase, 2>::CORE_INDEX == 2, "should be 2");
- static_assert(C2AddCoreIndex<base, 1>::CORE_INDEX == 1, "should be 1");
+ static_assert(_C2AddCoreIndex<nobase, 2>::CORE_INDEX == 2, "should be 2");
+ static_assert(_C2AddCoreIndex<base, 1>::CORE_INDEX == 1, "should be 1");
}
class TestFlexHelper {
@@ -1709,10 +1709,10 @@
EXPECT_EQ(index.typeIndex(), kParamIndexNumbers);
}
- std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::alloc_unique(1);
+ std::unique_ptr<C2NumbersTuning> tun_ = C2NumbersTuning::AllocUnique(1);
tun_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersTuning> tun = std::move(tun_);
- std::shared_ptr<C2NumbersTuning> btun = C2NumbersTuning::alloc_shared(1);
+ std::shared_ptr<C2NumbersTuning> btun = C2NumbersTuning::AllocShared(1);
{
// flags & invariables
@@ -1774,24 +1774,24 @@
EXPECT_EQ(*(C2Param::Copy(*tun)), *tun);
}
- std::unique_ptr<C2NumbersPortTuning> outp1_(C2NumbersPortTuning::alloc_unique(1, true)),
- inp1_ = C2NumbersPortTuning::alloc_unique(1, false);
+ std::unique_ptr<C2NumbersPortTuning> outp1_(C2NumbersPortTuning::AllocUnique(1, true)),
+ inp1_ = C2NumbersPortTuning::AllocUnique(1, false);
outp1_->m.mNumbers[0] = 100;
inp1_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersPortTuning> outp1 = std::move(outp1_);
std::unique_ptr<const C2NumbersPortTuning> inp1 = std::move(inp1_);
- std::shared_ptr<C2NumbersPortTuning> boutp1(C2NumbersPortTuning::alloc_shared(1)),
- binp1 = C2NumbersPortTuning::alloc_shared(1),
- binp3 = C2NumbersPortTuning::alloc_shared(1, false);
+ std::shared_ptr<C2NumbersPortTuning> boutp1(C2NumbersPortTuning::AllocShared(1)),
+ binp1 = C2NumbersPortTuning::AllocShared(1),
+ binp3 = C2NumbersPortTuning::AllocShared(1, false);
binp3->m.mNumbers[0] = 100;
- std::unique_ptr<C2NumbersPortTuning::input> inp2_(C2NumbersPortTuning::input::alloc_unique(1));
+ std::unique_ptr<C2NumbersPortTuning::input> inp2_(C2NumbersPortTuning::input::AllocUnique(1));
inp2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersPortTuning::input> inp2 = std::move(inp2_);
- std::shared_ptr<C2NumbersPortTuning::input> binp2(C2NumbersPortTuning::input::alloc_shared(1));
- std::unique_ptr<C2NumbersPortTuning::output> outp2_(C2NumbersPortTuning::output::alloc_unique(1));
+ std::shared_ptr<C2NumbersPortTuning::input> binp2(C2NumbersPortTuning::input::AllocShared(1));
+ std::unique_ptr<C2NumbersPortTuning::output> outp2_(C2NumbersPortTuning::output::AllocUnique(1));
outp2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersPortTuning::output> outp2 = std::move(outp2_);
- std::shared_ptr<C2NumbersPortTuning::output> boutp2(C2NumbersPortTuning::output::alloc_shared(1));
+ std::shared_ptr<C2NumbersPortTuning::output> boutp2(C2NumbersPortTuning::output::AllocShared(1));
{
static_assert(canCallSetPort(*binp3), "should be able to");
@@ -1999,24 +1999,24 @@
EXPECT_EQ(*(C2Param::Copy(*outp2)), *outp2);
}
- std::unique_ptr<C2NumbersStreamTuning> outs1_(C2NumbersStreamTuning::alloc_unique(1, true, 1u));
+ std::unique_ptr<C2NumbersStreamTuning> outs1_(C2NumbersStreamTuning::AllocUnique(1, true, 1u));
outs1_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning> outs1 = std::move(outs1_);
- std::unique_ptr<C2NumbersStreamTuning> ins1_(C2NumbersStreamTuning::alloc_unique(1, false, 1u));
+ std::unique_ptr<C2NumbersStreamTuning> ins1_(C2NumbersStreamTuning::AllocUnique(1, false, 1u));
ins1_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning> ins1 = std::move(ins1_);
- std::shared_ptr<C2NumbersStreamTuning> bouts1(C2NumbersStreamTuning::alloc_shared(1));
- std::shared_ptr<C2NumbersStreamTuning> bins1(C2NumbersStreamTuning::alloc_shared(1));
- std::shared_ptr<C2NumbersStreamTuning> bins3(C2NumbersStreamTuning::alloc_shared(1, false, 1u));
+ std::shared_ptr<C2NumbersStreamTuning> bouts1(C2NumbersStreamTuning::AllocShared(1));
+ std::shared_ptr<C2NumbersStreamTuning> bins1(C2NumbersStreamTuning::AllocShared(1));
+ std::shared_ptr<C2NumbersStreamTuning> bins3(C2NumbersStreamTuning::AllocShared(1, false, 1u));
bins3->m.mNumbers[0] = 100;
- std::unique_ptr<C2NumbersStreamTuning::input> ins2_(C2NumbersStreamTuning::input::alloc_unique(1, 1u));
+ std::unique_ptr<C2NumbersStreamTuning::input> ins2_(C2NumbersStreamTuning::input::AllocUnique(1, 1u));
ins2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning::input> ins2 = std::move(ins2_);
- std::shared_ptr<C2NumbersStreamTuning::input> bins2(C2NumbersStreamTuning::input::alloc_shared(1));
- std::unique_ptr<C2NumbersStreamTuning::output> outs2_(C2NumbersStreamTuning::output::alloc_unique(1, 1u));
+ std::shared_ptr<C2NumbersStreamTuning::input> bins2(C2NumbersStreamTuning::input::AllocShared(1));
+ std::unique_ptr<C2NumbersStreamTuning::output> outs2_(C2NumbersStreamTuning::output::AllocUnique(1, 1u));
outs2_->m.mNumbers[0] = 100;
std::unique_ptr<const C2NumbersStreamTuning::output> outs2 = std::move(outs2_);
- std::shared_ptr<C2NumbersStreamTuning::output> bouts2(C2NumbersStreamTuning::output::alloc_shared(1));
+ std::shared_ptr<C2NumbersStreamTuning::output> bouts2(C2NumbersStreamTuning::output::AllocShared(1));
{
static_assert(canCallSetPort(*bins3), "should be able to");
@@ -2239,7 +2239,7 @@
std::list<const C2FieldDescriptor> fields = int32Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::INT32, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2250,7 +2250,7 @@
std::list<const C2FieldDescriptor> fields = uint32Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::UINT32, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2261,7 +2261,7 @@
std::list<const C2FieldDescriptor> fields = int64Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::INT64, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2272,7 +2272,7 @@
std::list<const C2FieldDescriptor> fields = uint64Value.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::UINT64, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
@@ -2283,24 +2283,24 @@
std::list<const C2FieldDescriptor> fields = floatValue.FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::FLOAT, fields.cbegin()->type());
- EXPECT_EQ(1u, fields.cbegin()->length());
+ EXPECT_EQ(1u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
}
{
uint8_t initValue[] = "ABCD";
typedef C2GlobalParam<C2Setting, C2BlobValue, 0> BlobSetting;
- std::unique_ptr<BlobSetting> blobValue = BlobSetting::alloc_unique(6, C2ConstMemoryBlock<uint8_t>(initValue));
+ std::unique_ptr<BlobSetting> blobValue = BlobSetting::AllocUnique(6, C2ConstMemoryBlock<uint8_t>(initValue));
static_assert(std::is_same<decltype(blobValue->m.value), uint8_t[]>::value, "should be uint8_t[]");
EXPECT_EQ(0, memcmp(blobValue->m.value, "ABCD\0", 6));
EXPECT_EQ(6u, blobValue->flexCount());
std::list<const C2FieldDescriptor> fields = blobValue->FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::BLOB, fields.cbegin()->type());
- EXPECT_EQ(0u, fields.cbegin()->length());
+ EXPECT_EQ(0u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
- blobValue = BlobSetting::alloc_unique(3, C2ConstMemoryBlock<uint8_t>(initValue));
+ blobValue = BlobSetting::AllocUnique(3, C2ConstMemoryBlock<uint8_t>(initValue));
EXPECT_EQ(0, memcmp(blobValue->m.value, "ABC", 3));
EXPECT_EQ(3u, blobValue->flexCount());
}
@@ -2308,30 +2308,30 @@
{
constexpr char initValue[] = "ABCD";
typedef C2GlobalParam<C2Setting, C2StringValue, 0> StringSetting;
- std::unique_ptr<StringSetting> stringValue = StringSetting::alloc_unique(6, C2ConstMemoryBlock<char>(initValue));
- stringValue = StringSetting::alloc_unique(6, initValue);
+ std::unique_ptr<StringSetting> stringValue = StringSetting::AllocUnique(6, C2ConstMemoryBlock<char>(initValue));
+ stringValue = StringSetting::AllocUnique(6, initValue);
static_assert(std::is_same<decltype(stringValue->m.value), char[]>::value, "should be char[]");
EXPECT_EQ(0, memcmp(stringValue->m.value, "ABCD\0", 6));
EXPECT_EQ(6u, stringValue->flexCount());
std::list<const C2FieldDescriptor> fields = stringValue->FIELD_LIST;
EXPECT_EQ(1u, fields.size());
EXPECT_EQ(FD::STRING, fields.cbegin()->type());
- EXPECT_EQ(0u, fields.cbegin()->length());
+ EXPECT_EQ(0u, fields.cbegin()->extent());
EXPECT_EQ(C2String("value"), fields.cbegin()->name());
- stringValue = StringSetting::alloc_unique(3, C2ConstMemoryBlock<char>(initValue));
+ stringValue = StringSetting::AllocUnique(3, C2ConstMemoryBlock<char>(initValue));
EXPECT_EQ(0, memcmp(stringValue->m.value, "AB", 3));
EXPECT_EQ(3u, stringValue->flexCount());
- stringValue = StringSetting::alloc_unique(11, "initValue");
+ stringValue = StringSetting::AllocUnique(11, "initValue");
EXPECT_EQ(0, memcmp(stringValue->m.value, "initValue\0", 11));
EXPECT_EQ(11u, stringValue->flexCount());
- stringValue = StringSetting::alloc_unique(initValue);
+ stringValue = StringSetting::AllocUnique(initValue);
EXPECT_EQ(0, memcmp(stringValue->m.value, "ABCD", 5));
EXPECT_EQ(5u, stringValue->flexCount());
- stringValue = StringSetting::alloc_unique({ 'A', 'B', 'C', 'D' });
+ stringValue = StringSetting::AllocUnique({ 'A', 'B', 'C', 'D' });
EXPECT_EQ(0, memcmp(stringValue->m.value, "ABC", 4));
EXPECT_EQ(4u, stringValue->flexCount());
}
@@ -2513,7 +2513,7 @@
public:
MyParamReflector(const MyComponentInstance *i) : instance(i) { }
- virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex paramIndex) override {
+ virtual std::unique_ptr<C2StructDescriptor> describe(C2Param::CoreIndex paramIndex) const override {
switch (paramIndex.typeIndex()) {
case decltype(instance->mDomainInfo)::CORE_INDEX:
default:
@@ -2531,7 +2531,7 @@
c2_blocking_t mayBlock) const override {
(void)mayBlock;
for (C2FieldSupportedValuesQuery &query : fields) {
- if (query.field == C2ParamField(&mDomainInfo, &C2ComponentDomainInfo::value)) {
+ if (query.field() == C2ParamField(&mDomainInfo, &C2ComponentDomainInfo::value)) {
query.values = C2FieldSupportedValues(
false /* flag */,
&mDomainInfo.value
@@ -2702,7 +2702,7 @@
if (f.namedValues().size()) {
cout << ".named(";
const char *sep = "";
- for (const FD::named_value_type &p : f.namedValues()) {
+ for (const FD::NamedValueType &p : f.namedValues()) {
cout << sep << p.first << "=";
switch (f.type()) {
case C2Value::INT32: cout << get(p.second, (int32_t *)0); break;
diff --git a/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h b/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h
index 7168498..f6d8b98 100644
--- a/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h
+++ b/media/libstagefright/codec2/vndk/include/C2ComponentFactory.h
@@ -83,8 +83,5 @@
typedef void (*DestroyCodec2FactoryFunc)(::C2ComponentFactory*);
};
-namespace android {
- typedef ::C2ComponentFactory C2ComponentFactory;
-}
#endif // STAGEFRIGHT_CODEC2_COMPONENT_FACTORY_H_
diff --git a/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h b/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
index 1accc2c..710e74b 100644
--- a/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
+++ b/media/libstagefright/codec2/vndk/include/util/C2ParamUtils.h
@@ -62,7 +62,7 @@
#undef DEFINE_C2_ENUM_VALUE_AUTO_HELPER
#define DEFINE_C2_ENUM_VALUE_AUTO_HELPER(name, type, prefix, ...) \
-template<> C2FieldDescriptor::named_values_type C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
+template<> C2FieldDescriptor::NamedValuesType C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
return C2ParamUtils::sanitizeEnumValues( \
std::vector<C2Value::Primitive> { _C2_MAP(_C2_GET_ENUM_VALUE, type, __VA_ARGS__) }, \
{ _C2_MAP(_C2_GET_ENUM_NAME, type, __VA_ARGS__) }, \
@@ -71,7 +71,7 @@
#undef DEFINE_C2_ENUM_VALUE_CUSTOM_HELPER
#define DEFINE_C2_ENUM_VALUE_CUSTOM_HELPER(name, type, names, ...) \
-template<> C2FieldDescriptor::named_values_type C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
+template<> C2FieldDescriptor::NamedValuesType C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
return C2ParamUtils::customEnumValues( \
std::vector<std::pair<C2StringLiteral, name>> names); \
}
@@ -242,11 +242,11 @@
}
template<typename T>
- static C2FieldDescriptor::named_values_type sanitizeEnumValues(
+ static C2FieldDescriptor::NamedValuesType sanitizeEnumValues(
std::vector<T> values,
std::vector<C2StringLiteral> names,
C2StringLiteral prefix = NULL) {
- C2FieldDescriptor::named_values_type namedValues;
+ C2FieldDescriptor::NamedValuesType namedValues;
std::vector<C2String> sanitizedNames = sanitizeEnumValueNames(names, prefix);
for (size_t i = 0; i < values.size() && i < sanitizedNames.size(); ++i) {
namedValues.emplace_back(sanitizedNames[i], values[i]);
@@ -255,9 +255,9 @@
}
template<typename E>
- static C2FieldDescriptor::named_values_type customEnumValues(
+ static C2FieldDescriptor::NamedValuesType customEnumValues(
std::vector<std::pair<C2StringLiteral, E>> items) {
- C2FieldDescriptor::named_values_type namedValues;
+ C2FieldDescriptor::NamedValuesType namedValues;
for (auto &item : items) {
namedValues.emplace_back(item.first, item.second);
}
diff --git a/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h b/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h
index c805830..34797a9 100644
--- a/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h
+++ b/media/libstagefright/codec2/vndk/internal/C2ParamInternal.h
@@ -20,19 +20,19 @@
#include <C2Param.h>
struct C2_HIDE _C2ParamInspector {
- inline static uint32_t getIndex(const C2ParamField &pf) {
+ inline static uint32_t GetIndex(const C2ParamField &pf) {
return pf._mIndex;
}
- inline static uint32_t getOffset(const C2ParamField &pf) {
+ inline static uint32_t GetOffset(const C2ParamField &pf) {
return pf._mFieldId._mOffset;
}
- inline static uint32_t getSize(const C2ParamField &pf) {
+ inline static uint32_t GetSize(const C2ParamField &pf) {
return pf._mFieldId._mSize;
}
- inline static uint32_t getAttrib(const C2ParamDescriptor &pd) {
+ inline static uint32_t GetAttrib(const C2ParamDescriptor &pd) {
return pd._mAttrib;
}
@@ -40,8 +40,15 @@
C2ParamField CreateParamField(C2Param::Index index, uint32_t offset, uint32_t size) {
return C2ParamField(index, offset, size);
}
-};
+ inline static
+ C2ParamField CreateParamField(C2Param::Index index, _C2FieldId field) {
+ return C2ParamField(index, field._mOffset, field._mSize);
+ }
+
+ // expose attributes
+ typedef C2ParamDescriptor::attrib_t attrib_t;
+};
#endif // ANDROID_STAGEFRIGHT_C2PARAM_INTERNAL_H_
diff --git a/media/libstagefright/codecs/aacdec/C2SoftAac.cpp b/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
index b57c2aa..3f09e0a 100644
--- a/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
+++ b/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
@@ -676,14 +676,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAac("aac", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("aac", id, deleter)
.inputFormat(C2FormatCompressed)
@@ -697,12 +697,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAacDecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
index 6f1b325..74f5a7a 100644
--- a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
+++ b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
@@ -208,7 +208,7 @@
}
std::unique_ptr<C2StreamCsdInfo::output> csd =
- C2StreamCsdInfo::output::alloc_unique(encInfo.confSize, 0u);
+ C2StreamCsdInfo::output::AllocUnique(encInfo.confSize, 0u);
// TODO: check NO_MEMORY
memcpy(csd->m.value, encInfo.confBuf, encInfo.confSize);
ALOGV("put csd");
@@ -382,14 +382,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAacEnc("aacenc", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("aacenc", id, deleter)
.inputFormat(C2FormatAudio)
@@ -403,12 +403,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAacEncFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
index 306d0a5..3c09e37 100644
--- a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
+++ b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
@@ -266,9 +266,9 @@
mBlocksPerSecond(0u, 0),
mParamReflector(new ParamReflector) {
ALOGV("in %s", __func__);
- mInputPortMime = C2PortMimeConfig::input::alloc_unique(strlen(CODEC_MIME_TYPE) + 1);
+ mInputPortMime = C2PortMimeConfig::input::AllocUnique(strlen(CODEC_MIME_TYPE) + 1);
strcpy(mInputPortMime->m.value, CODEC_MIME_TYPE);
- mOutputPortMime = C2PortMimeConfig::output::alloc_unique(strlen(MEDIA_MIMETYPE_VIDEO_RAW) + 1);
+ mOutputPortMime = C2PortMimeConfig::output::AllocUnique(strlen(MEDIA_MIMETYPE_VIDEO_RAW) + 1);
strcpy(mOutputPortMime->m.value, MEDIA_MIMETYPE_VIDEO_RAW);
mVideoSize.width = 320;
@@ -281,7 +281,7 @@
mMaxVideoSizeHint.width = H264_MAX_FRAME_WIDTH;
mMaxVideoSizeHint.height = H264_MAX_FRAME_HEIGHT;
- mOutputBlockPools = C2PortBlockPoolsTuning::output::alloc_unique({});
+ mOutputBlockPools = C2PortBlockPoolsTuning::output::AllocUnique({});
auto insertParam = [¶ms = mParams] (C2Param *param) {
params[param->index()] = param;
@@ -1328,14 +1328,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAvcDec("avc", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("avc", id, deleter)
.inputFormat(C2FormatCompressed)
@@ -1350,12 +1350,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAvcDecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp b/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp
index 9ea3589..e105460 100644
--- a/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp
+++ b/media/libstagefright/codecs/avcenc/C2SoftAvcEnc.cpp
@@ -1044,7 +1044,7 @@
mSpsPpsHeaderReceived = true;
std::unique_ptr<C2StreamCsdInfo::output> csd =
- C2StreamCsdInfo::output::alloc_unique(s_encode_op.s_out_buf.u4_bytes, 0u);
+ C2StreamCsdInfo::output::AllocUnique(s_encode_op.s_out_buf.u4_bytes, 0u);
memcpy(csd->m.value, header, s_encode_op.s_out_buf.u4_bytes);
work->worklets.front()->output.configUpdate.push_back(std::move(csd));
@@ -1210,14 +1210,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftAvcEnc("avcenc", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("avcenc", id, deleter)
.inputFormat(C2FormatVideo)
@@ -1231,12 +1231,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftAvcEncFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/cmds/codec2.cpp b/media/libstagefright/codecs/cmds/codec2.cpp
index 95b0c61..26f96c3 100644
--- a/media/libstagefright/codecs/cmds/codec2.cpp
+++ b/media/libstagefright/codecs/cmds/codec2.cpp
@@ -67,7 +67,7 @@
class LinearBuffer : public C2Buffer {
public:
explicit LinearBuffer(const std::shared_ptr<C2LinearBlock> &block)
- : C2Buffer({ block->share(block->offset(), block->size(), ::android::C2Fence()) }) {}
+ : C2Buffer({ block->share(block->offset(), block->size(), ::C2Fence()) }) {}
};
class Listener;
@@ -215,7 +215,7 @@
(void)component->setListener_vb(mListener, C2_DONT_BLOCK);
std::unique_ptr<C2PortBlockPoolsTuning::output> pools =
- C2PortBlockPoolsTuning::output::alloc_unique({ (uint64_t)C2BlockPool::BASIC_GRAPHIC });
+ C2PortBlockPoolsTuning::output::AllocUnique({ (uint64_t)C2BlockPool::BASIC_GRAPHIC });
std::vector<std::unique_ptr<C2SettingResult>> result;
(void)component->intf()->config_vb({pools.get()}, C2_DONT_BLOCK, &result);
component->start();
diff --git a/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp b/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp
index a26dbb9..e830324 100644
--- a/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp
+++ b/media/libstagefright/codecs/g711/dec/C2SoftG711.cpp
@@ -207,14 +207,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftG711(COMPONENT_NAME, id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder(COMPONENT_NAME, id, deleter)
.inputFormat(C2FormatCompressed)
@@ -228,12 +228,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftG711DecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}
diff --git a/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp
index c34a6f0..9e8b527 100644
--- a/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp
+++ b/media/libstagefright/codecs/mp3dec/C2SoftMP3.cpp
@@ -398,14 +398,14 @@
public:
virtual c2_status_t createComponent(
c2_node_id_t id, std::shared_ptr<C2Component>* const component,
- std::function<void(::android::C2Component*)> deleter) override {
+ std::function<void(::C2Component*)> deleter) override {
*component = std::shared_ptr<C2Component>(new C2SoftMP3("mp3", id), deleter);
return C2_OK;
}
virtual c2_status_t createInterface(
c2_node_id_t id, std::shared_ptr<C2ComponentInterface>* const interface,
- std::function<void(::android::C2ComponentInterface*)> deleter) override {
+ std::function<void(::C2ComponentInterface*)> deleter) override {
*interface =
SimpleC2Interface::Builder("mp3", id, deleter)
.inputFormat(C2FormatCompressed)
@@ -419,12 +419,12 @@
} // namespace android
-extern "C" ::android::C2ComponentFactory* CreateCodec2Factory() {
+extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftMp3DecFactory();
}
-extern "C" void DestroyCodec2Factory(::android::C2ComponentFactory* factory) {
+extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;
}