Merge "Codec2: tweak C2Work struct and rename C2BufferPack to C2FrameData"
diff --git a/media/libstagefright/CCodecBufferChannel.cpp b/media/libstagefright/CCodecBufferChannel.cpp
index eea9c78..ebc9b0a 100644
--- a/media/libstagefright/CCodecBufferChannel.cpp
+++ b/media/libstagefright/CCodecBufferChannel.cpp
@@ -665,16 +665,16 @@
int32_t flags = 0;
int32_t tmp = 0;
if (buffer->meta()->findInt32("eos", &tmp) && tmp) {
- flags |= C2BufferPack::FLAG_END_OF_STREAM;
+ flags |= C2FrameData::FLAG_END_OF_STREAM;
ALOGV("input EOS");
}
if (buffer->meta()->findInt32("csd", &tmp) && tmp) {
- flags |= C2BufferPack::FLAG_CODEC_CONFIG;
+ flags |= C2FrameData::FLAG_CODEC_CONFIG;
}
std::unique_ptr<C2Work> work(new C2Work);
- work->input.flags = (C2BufferPack::flags_t)flags;
+ work->input.flags = (C2FrameData::flags_t)flags;
work->input.ordinal.timestamp = timeUs;
- work->input.ordinal.frame_index = mFrameIndex++;
+ work->input.ordinal.frameIndex = mFrameIndex++;
work->input.buffers.clear();
{
Mutexed<std::unique_ptr<InputBuffers>>::Locked buffers(mInputBuffers);
@@ -724,7 +724,7 @@
return OK;
}
- std::list<C2ConstGraphicBlock> blocks = c2Buffer->data().graphicBlocks();
+ std::vector<C2ConstGraphicBlock> blocks = c2Buffer->data().graphicBlocks();
if (blocks.size() != 1u) {
ALOGE("# of graphic blocks expected to be 1, but %zu", blocks.size());
return UNKNOWN_ERROR;
@@ -881,7 +881,7 @@
}
const std::unique_ptr<C2Worklet> &worklet = work->worklets.front();
- if (worklet->output.ordinal.frame_index < mFirstValidFrameIndex) {
+ if ((worklet->output.ordinal.frameIndex - mFirstValidFrameIndex.load()).peek() < 0) {
// Discard frames from previous generation.
continue;
}
@@ -897,7 +897,7 @@
if (buffer) {
// TODO: transfer infos() into buffer metadata
}
- for (const auto &info : worklet->output.infos) {
+ for (const auto &info : worklet->output.configUpdate) {
if (info->coreIndex() == C2StreamCsdInfo::output::CORE_INDEX) {
ALOGV("csd found");
csdInfo = static_cast<const C2StreamCsdInfo::output *>(info.get());
@@ -905,7 +905,7 @@
}
int32_t flags = 0;
- if (worklet->output.flags & C2BufferPack::FLAG_END_OF_STREAM) {
+ if (worklet->output.flags & C2FrameData::FLAG_END_OF_STREAM) {
flags |= MediaCodec::BUFFER_FLAG_EOS;
ALOGV("output EOS");
}
@@ -914,7 +914,7 @@
if (csdInfo != nullptr) {
Mutexed<std::unique_ptr<OutputBuffers>>::Locked buffers(mOutputBuffers);
if ((*buffers)->registerCsd(csdInfo, &index, &outBuffer)) {
- outBuffer->meta()->setInt64("timeUs", worklet->output.ordinal.timestamp);
+ outBuffer->meta()->setInt64("timeUs", worklet->output.ordinal.timestamp.peek());
outBuffer->meta()->setInt32("flags", flags | MediaCodec::BUFFER_FLAG_CODECCONFIG);
ALOGV("csd index = %zu", index);
@@ -947,7 +947,7 @@
}
}
- outBuffer->meta()->setInt64("timeUs", worklet->output.ordinal.timestamp);
+ outBuffer->meta()->setInt64("timeUs", worklet->output.ordinal.timestamp.peek());
outBuffer->meta()->setInt32("flags", flags);
ALOGV("index = %zu", index);
mCallback->onOutputBufferAvailable(index, outBuffer);
diff --git a/media/libstagefright/codec2/SimpleC2Component.cpp b/media/libstagefright/codec2/SimpleC2Component.cpp
index 4d75a31..c3ae00e 100644
--- a/media/libstagefright/codec2/SimpleC2Component.cpp
+++ b/media/libstagefright/codec2/SimpleC2Component.cpp
@@ -342,7 +342,7 @@
return;
}
}
- if (work->worklets_processed != 0u) {
+ if (work->workletsProcessed != 0u) {
Mutexed<ExecState>::Locked state(mExecState);
ALOGV("returning this work");
state->mListener->onWorkDone_nb(shared_from_this(), vec(work));
@@ -351,7 +351,7 @@
std::unique_ptr<C2Work> unexpected;
{
Mutexed<PendingWork>::Locked pending(mPendingWork);
- uint64_t frameIndex = work->input.ordinal.frame_index;
+ uint64_t frameIndex = work->input.ordinal.frameIndex.peeku();
if (pending->count(frameIndex) != 0) {
unexpected = std::move(pending->at(frameIndex));
pending->erase(frameIndex);
diff --git a/media/libstagefright/codec2/include/C2Buffer.h b/media/libstagefright/codec2/include/C2Buffer.h
index cd90978..2ca8222 100644
--- a/media/libstagefright/codec2/include/C2Buffer.h
+++ b/media/libstagefright/codec2/include/C2Buffer.h
@@ -679,14 +679,14 @@
*
* \param size number of bytes to share
* \param fence fence to be used for the section
- * \param blocks list where the blocks of the section are appended to
+ * \param blocks vector where the blocks of the section are appended to
*
* \retval C2_OK the portion was successfully shared
* \retval C2_NO_MEMORY not enough memory to share the portion
* \retval C2_TIMED_OUT the operation timed out (unexpected)
* \retval C2_CORRUPTED some unknown error prevented sharing the data (unexpected)
*/
- c2_status_t share(size_t size, C2Fence fence, std::list<C2ConstLinearBlock> &blocks);
+ c2_status_t share(size_t size, C2Fence fence, std::vector<C2ConstLinearBlock> &blocks);
/**
* Returns the beginning offset of this segment from the start of this circular block.
@@ -1203,14 +1203,14 @@
* \return a constant list of const linear blocks of this buffer.
* \retval empty list if this buffer does not contain linear block(s).
*/
- const std::list<C2ConstLinearBlock> linearBlocks() const;
+ const std::vector<C2ConstLinearBlock> linearBlocks() const;
/**
* Gets the graphic blocks of this buffer.
* \return a constant list of const graphic blocks of this buffer.
* \retval empty list if this buffer does not contain graphic block(s).
*/
- const std::list<C2ConstGraphicBlock> graphicBlocks() const;
+ const std::vector<C2ConstGraphicBlock> graphicBlocks() const;
private:
class Impl;
@@ -1218,8 +1218,8 @@
protected:
// no public constructor
- explicit C2BufferData(const std::list<C2ConstLinearBlock> &blocks);
- explicit C2BufferData(const std::list<C2ConstGraphicBlock> &blocks);
+ explicit C2BufferData(const std::vector<C2ConstLinearBlock> &blocks);
+ explicit C2BufferData(const std::vector<C2ConstGraphicBlock> &blocks);
};
/**
@@ -1301,7 +1301,7 @@
*
* \return a constant list of info objects associated with this buffer.
*/
- const std::list<std::shared_ptr<const C2Info>> infos() const;
+ const std::vector<std::shared_ptr<const C2Info>> info() const;
/**
* Attaches (or updates) an (existing) metadata for this buffer.
@@ -1328,8 +1328,8 @@
protected:
// no public constructor
- explicit C2Buffer(const std::list<C2ConstLinearBlock> &blocks);
- explicit C2Buffer(const std::list<C2ConstGraphicBlock> &blocks);
+ explicit C2Buffer(const std::vector<C2ConstLinearBlock> &blocks);
+ explicit C2Buffer(const std::vector<C2ConstGraphicBlock> &blocks);
private:
class Impl;
diff --git a/media/libstagefright/codec2/include/C2Component.h b/media/libstagefright/codec2/include/C2Component.h
index a2168a0..e023db4 100644
--- a/media/libstagefright/codec2/include/C2Component.h
+++ b/media/libstagefright/codec2/include/C2Component.h
@@ -682,7 +682,7 @@
*/
virtual c2_status_t reset() { return C2_OK; }
- virtual c2_status_t parseFrame(C2BufferPack &frame);
+ virtual c2_status_t parseFrame(C2FrameData &frame);
virtual ~C2FrameInfoParser() = default;
};
diff --git a/media/libstagefright/codec2/include/C2Param.h b/media/libstagefright/codec2/include/C2Param.h
index 0540155..e2df62d 100644
--- a/media/libstagefright/codec2/include/C2Param.h
+++ b/media/libstagefright/codec2/include/C2Param.h
@@ -721,6 +721,10 @@
DEFINE_OTHER_COMPARISON_OPERATORS(C2ParamField)
+protected:
+ inline C2ParamField(C2Param::Index index, uint32_t offset, uint32_t size)
+ : _mIndex(index), _mFieldId(offset, size) {}
+
private:
friend struct _C2ParamInspector;
@@ -729,6 +733,17 @@
};
/**
+ * Structure uniquely specifying a field, an array element of a field, or a
+ * parameter in a configuration
+ */
+struct C2ParamOrField : public C2ParamField {
+//public:
+ template<typename S>
+ inline C2ParamOrField(S* param)
+ : C2ParamField(param->index(), 0u, param->size()) {}
+};
+
+/**
* A shared (union) representation of numeric values
*/
class C2Value {
diff --git a/media/libstagefright/codec2/include/C2Work.h b/media/libstagefright/codec2/include/C2Work.h
index 105cf81..58a9174 100644
--- a/media/libstagefright/codec2/include/C2Work.h
+++ b/media/libstagefright/codec2/include/C2Work.h
@@ -83,32 +83,64 @@
kParamIndexWorkOrdinal,
};
+/**
+ * Information for ordering work items on a component port.
+ */
struct C2WorkOrdinalStruct {
- uint64_t timestamp;
- uint64_t frame_index; // submission ordinal on the initial component
- uint64_t custom_ordinal; // can be given by the component, e.g. decode order
+//public:
+ c2_cntr64_t timestamp; /** frame timestamp in microseconds */
+ c2_cntr64_t frameIndex; /** submission ordinal on the initial component */
+ c2_cntr64_t customOrdinal; /** can be given by the component, e.g. decode order */
DEFINE_AND_DESCRIBE_C2STRUCT(WorkOrdinal)
C2FIELD(timestamp, "timestamp")
- C2FIELD(frame_index, "frame-index")
- C2FIELD(custom_ordinal, "custom-ordinal")
+ C2FIELD(frameIndex, "frame-index")
+ C2FIELD(customOrdinal, "custom-ordinal")
};
-struct C2BufferPack {
+/**
+ * This structure represents a Codec 2.0 frame with its metadata.
+ *
+ * A frame basically consists of an ordered sets of buffers, configuration changes and info buffers
+ * along with some non-configuration metadata.
+ */
+struct C2FrameData {
//public:
enum flags_t : uint32_t {
- FLAG_CODEC_CONFIG = (1 << 0),
- FLAG_DROP_FRAME = (1 << 1),
- FLAG_END_OF_STREAM = (1 << 2),
+ /**
+ * For input frames: no output frame shall be generated when processing this frame, but
+ * metadata shall still be processed.
+ * For output frames: this frame shall be discarded and but metadata is still valid.
+ */
+ FLAG_DROP_FRAME = (1 << 0),
+ /**
+ * This frame is the last frame of the current stream. Further frames are part of a new
+ * stream.
+ */
+ FLAG_END_OF_STREAM = (1 << 1),
+ /**
+ * This frame shall be discarded with its metadata.
+ * This flag is only set by components - e.g. as a response to the flush command.
+ */
+ FLAG_DISCARD_FRAME = (1 << 2),
+ /**
+ * This frame contains only codec-specific configuration data, and no actual access unit.
+ *
+ * \deprecated pass codec configuration with using the \todo codec-specific configuration
+ * info together with the access unit.
+ */
+ FLAG_CODEC_CONFIG = (1u << 31),
};
+ /**
+ * Frame flags */
flags_t flags;
C2WorkOrdinalStruct ordinal;
std::vector<std::shared_ptr<C2Buffer>> buffers;
//< for initial work item, these may also come from the parser - if provided
//< for output buffers, these are the responses to requestedInfos
- std::list<std::unique_ptr<C2Info>> infos;
- std::list<std::shared_ptr<C2InfoBuffer>> infoBuffers;
+ std::vector<std::unique_ptr<C2Param>> configUpdate;
+ std::vector<std::shared_ptr<C2InfoBuffer>> infoBuffers;
};
struct C2Worklet {
@@ -116,59 +148,61 @@
// IN
c2_node_id_t component;
- std::list<std::unique_ptr<C2Param>> tunings; //< tunings to be applied before processing this
- // worklet
- std::list<C2Param::Type> requestedInfos;
- std::vector<std::shared_ptr<C2BlockPool>> allocators; //< This vector shall be the same size as
- //< output.buffers. \deprecated
+ /** Configuration changes to be applied before processing this worklet. */
+ std::vector<std::unique_ptr<C2Tuning>> tunings;
+ std::vector<std::unique_ptr<C2SettingResult>> failures;
// OUT
- C2BufferPack output;
- std::list<std::unique_ptr<C2SettingResult>> failures;
+ C2FrameData output;
};
/**
+ * Information about partial work-chains not part of the current work items.
+ *
+ * To be defined later.
+ */
+struct C2WorkChainInfo;
+
+/**
* This structure holds information about all a single work item.
*
* This structure shall be passed by the client to the component for the first worklet. As such,
* worklets must not be empty. The ownership of this object is passed.
- *
- * input:
- * The input data to be processed. This is provided by the client with ownership. When the work
- * is returned, the input buffer-pack's buffer vector shall contain nullptrs.
- *
- * worklets:
- * The chain of components and associated allocators, tunings and info requests that the data
- * must pass through. If this has more than a single element, the tunnels between successive
- * components of the worklet chain must have been (successfully) pre-registered at the time
- * the work is submitted. Allocating the output buffers in the worklets is the responsibility
- * of each component. Upon work submission, each output buffer-pack shall be an appropriately
- * sized vector containing nullptrs. When the work is completed/returned to the client,
- *
- * worklets_processed:
- * It shall be initialized to 0 by the client when the work is submitted.
- * It shall contain the number of worklets that were successfully processed when the work is
- * returned. If this is less then the number of worklets, result must not be success.
- * It must be in the range of [0, worklets.size()].
- *
- * result:
- * The final outcome of the work. If 0 when work is returned, it is assumed that all worklets
- * have been processed.
*/
struct C2Work {
//public:
- // pre-chain infos (for portions of a tunneling chain that happend before this work-chain for
- // this work item - due to framework facilitated (non-tunneled) work-chaining)
- std::list<std::pair<std::unique_ptr<C2PortMimeConfig>, std::unique_ptr<C2Info>>> preChainInfos;
- std::list<std::pair<std::unique_ptr<C2PortMimeConfig>, std::unique_ptr<C2Buffer>>> preChainInfoBlobs;
+ /// additional work chain info not part of this work
+ std::shared_ptr<C2WorkChainInfo> chainInfo;
- C2BufferPack input;
+ /// The input data to be processed as part of this work/work-chain. This is provided by the
+ /// client with ownership. When the work is returned (via onWorkDone), the input buffer-pack's
+ /// buffer vector shall contain nullptrs.
+ C2FrameData input;
+
+ /// The chain of components, tunings (including output buffer pool IDs) and info requests that the
+ /// data must pass through. If this has more than a single element, the tunnels between successive
+ /// components of the worklet chain must have been (successfully) pre-registered at the time that
+ /// the work is submitted. Allocating the output buffers in the worklets is the responsibility of
+ /// each component. Upon work submission, each output buffer-pack shall be an appropriately sized
+ /// vector containing nullptrs. When the work is completed/returned to the client, output buffers
+ /// pointers from all but the final worklet shall be nullptrs.
std::list<std::unique_ptr<C2Worklet>> worklets;
- uint32_t worklets_processed;
+ /// Number of worklets successfully processed in this chain. This shall be initialized to 0 by the
+ /// client when the work is submitted. It shall contain the number of worklets that were
+ /// successfully processed when the work is returned to the client. If this is less then the number
+ /// of worklets, result must not be success. It must be in the range of [0, worklets.size()].
+ uint32_t workletsProcessed;
+
+ /// The final outcome of the work (corresponding to the current workletsProcessed). If 0 when
+ /// work is returned, it is assumed that all worklets have been processed.
c2_status_t result;
};
+/**
+ * Information about a future work to be submitted to the component. The information is used to
+ * reserve the work for work ordering purposes.
+ */
struct C2WorkOutline {
//public:
C2WorkOrdinalStruct ordinal;
diff --git a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
index f6e6478..a310717 100644
--- a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
+++ b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
@@ -359,14 +359,14 @@
class BufferData : public C2BufferData {
public:
- explicit BufferData(const std::list<C2ConstLinearBlock> &blocks) : C2BufferData(blocks) {}
- explicit BufferData(const std::list<C2ConstGraphicBlock> &blocks) : C2BufferData(blocks) {}
+ explicit BufferData(const std::vector<C2ConstLinearBlock> &blocks) : C2BufferData(blocks) {}
+ explicit BufferData(const std::vector<C2ConstGraphicBlock> &blocks) : C2BufferData(blocks) {}
};
class Buffer : public C2Buffer {
public:
- explicit Buffer(const std::list<C2ConstLinearBlock> &blocks) : C2Buffer(blocks) {}
- explicit Buffer(const std::list<C2ConstGraphicBlock> &blocks) : C2Buffer(blocks) {}
+ explicit Buffer(const std::vector<C2ConstLinearBlock> &blocks) : C2Buffer(blocks) {}
+ explicit Buffer(const std::vector<C2ConstGraphicBlock> &blocks) : C2Buffer(blocks) {}
};
TEST_F(C2BufferTest, BufferDataTest) {
@@ -487,45 +487,45 @@
std::shared_ptr<C2Info> info1(new C2Number1Info(1));
std::shared_ptr<C2Info> info2(new C2Number2Info(2));
buffer.reset(new Buffer( { block->share(0, kCapacity, C2Fence()) }));
- EXPECT_TRUE(buffer->infos().empty());
+ EXPECT_TRUE(buffer->info().empty());
EXPECT_FALSE(buffer->hasInfo(info1->type()));
EXPECT_FALSE(buffer->hasInfo(info2->type()));
ASSERT_EQ(C2_OK, buffer->setInfo(info1));
- EXPECT_EQ(1u, buffer->infos().size());
- EXPECT_EQ(*info1, *buffer->infos().front());
+ EXPECT_EQ(1u, buffer->info().size());
+ EXPECT_EQ(*info1, *buffer->info().front());
EXPECT_TRUE(buffer->hasInfo(info1->type()));
EXPECT_FALSE(buffer->hasInfo(info2->type()));
ASSERT_EQ(C2_OK, buffer->setInfo(info2));
- EXPECT_EQ(2u, buffer->infos().size());
+ EXPECT_EQ(2u, buffer->info().size());
EXPECT_TRUE(buffer->hasInfo(info1->type()));
EXPECT_TRUE(buffer->hasInfo(info2->type()));
std::shared_ptr<C2Info> removed = buffer->removeInfo(info1->type());
ASSERT_TRUE(removed);
EXPECT_EQ(*removed, *info1);
- EXPECT_EQ(1u, buffer->infos().size());
- EXPECT_EQ(*info2, *buffer->infos().front());
+ EXPECT_EQ(1u, buffer->info().size());
+ EXPECT_EQ(*info2, *buffer->info().front());
EXPECT_FALSE(buffer->hasInfo(info1->type()));
EXPECT_TRUE(buffer->hasInfo(info2->type()));
removed = buffer->removeInfo(info1->type());
ASSERT_FALSE(removed);
- EXPECT_EQ(1u, buffer->infos().size());
+ EXPECT_EQ(1u, buffer->info().size());
EXPECT_FALSE(buffer->hasInfo(info1->type()));
EXPECT_TRUE(buffer->hasInfo(info2->type()));
std::shared_ptr<C2Info> info3(new C2Number2Info(3));
ASSERT_EQ(C2_OK, buffer->setInfo(info3));
- EXPECT_EQ(1u, buffer->infos().size());
+ EXPECT_EQ(1u, buffer->info().size());
EXPECT_FALSE(buffer->hasInfo(info1->type()));
EXPECT_TRUE(buffer->hasInfo(info2->type()));
removed = buffer->removeInfo(info2->type());
ASSERT_TRUE(removed);
EXPECT_EQ(*info3, *removed);
- EXPECT_TRUE(buffer->infos().empty());
+ EXPECT_TRUE(buffer->info().empty());
EXPECT_FALSE(buffer->hasInfo(info1->type()));
EXPECT_FALSE(buffer->hasInfo(info2->type()));
}
diff --git a/media/libstagefright/codec2/vndk/C2Buffer.cpp b/media/libstagefright/codec2/vndk/C2Buffer.cpp
index 65a271e..4ab3e05 100644
--- a/media/libstagefright/codec2/vndk/C2Buffer.cpp
+++ b/media/libstagefright/codec2/vndk/C2Buffer.cpp
@@ -602,44 +602,44 @@
class C2BufferData::Impl {
public:
- explicit Impl(const std::list<C2ConstLinearBlock> &blocks)
+ explicit Impl(const std::vector<C2ConstLinearBlock> &blocks)
: mType(blocks.size() == 1 ? LINEAR : LINEAR_CHUNKS),
mLinearBlocks(blocks) {
}
- explicit Impl(const std::list<C2ConstGraphicBlock> &blocks)
+ explicit Impl(const std::vector<C2ConstGraphicBlock> &blocks)
: mType(blocks.size() == 1 ? GRAPHIC : GRAPHIC_CHUNKS),
mGraphicBlocks(blocks) {
}
Type type() const { return mType; }
- const std::list<C2ConstLinearBlock> &linearBlocks() const { return mLinearBlocks; }
- const std::list<C2ConstGraphicBlock> &graphicBlocks() const { return mGraphicBlocks; }
+ const std::vector<C2ConstLinearBlock> &linearBlocks() const { return mLinearBlocks; }
+ const std::vector<C2ConstGraphicBlock> &graphicBlocks() const { return mGraphicBlocks; }
private:
Type mType;
- std::list<C2ConstLinearBlock> mLinearBlocks;
- std::list<C2ConstGraphicBlock> mGraphicBlocks;
+ std::vector<C2ConstLinearBlock> mLinearBlocks;
+ std::vector<C2ConstGraphicBlock> mGraphicBlocks;
};
-C2BufferData::C2BufferData(const std::list<C2ConstLinearBlock> &blocks) : mImpl(new Impl(blocks)) {}
-C2BufferData::C2BufferData(const std::list<C2ConstGraphicBlock> &blocks) : mImpl(new Impl(blocks)) {}
+C2BufferData::C2BufferData(const std::vector<C2ConstLinearBlock> &blocks) : mImpl(new Impl(blocks)) {}
+C2BufferData::C2BufferData(const std::vector<C2ConstGraphicBlock> &blocks) : mImpl(new Impl(blocks)) {}
C2BufferData::Type C2BufferData::type() const { return mImpl->type(); }
-const std::list<C2ConstLinearBlock> C2BufferData::linearBlocks() const {
+const std::vector<C2ConstLinearBlock> C2BufferData::linearBlocks() const {
return mImpl->linearBlocks();
}
-const std::list<C2ConstGraphicBlock> C2BufferData::graphicBlocks() const {
+const std::vector<C2ConstGraphicBlock> C2BufferData::graphicBlocks() const {
return mImpl->graphicBlocks();
}
class C2Buffer::Impl {
public:
- Impl(C2Buffer *thiz, const std::list<C2ConstLinearBlock> &blocks)
+ Impl(C2Buffer *thiz, const std::vector<C2ConstLinearBlock> &blocks)
: mThis(thiz), mData(blocks) {}
- Impl(C2Buffer *thiz, const std::list<C2ConstGraphicBlock> &blocks)
+ Impl(C2Buffer *thiz, const std::vector<C2ConstGraphicBlock> &blocks)
: mThis(thiz), mData(blocks) {}
~Impl() {
@@ -676,8 +676,8 @@
return C2_OK;
}
- std::list<std::shared_ptr<const C2Info>> infos() const {
- std::list<std::shared_ptr<const C2Info>> result(mInfos.size());
+ std::vector<std::shared_ptr<const C2Info>> info() const {
+ std::vector<std::shared_ptr<const C2Info>> result(mInfos.size());
std::transform(
mInfos.begin(), mInfos.end(), result.begin(),
[] (const auto &elem) { return elem.second; });
@@ -712,10 +712,10 @@
std::list<std::pair<OnDestroyNotify, void *>> mNotify;
};
-C2Buffer::C2Buffer(const std::list<C2ConstLinearBlock> &blocks)
+C2Buffer::C2Buffer(const std::vector<C2ConstLinearBlock> &blocks)
: mImpl(new Impl(this, blocks)) {}
-C2Buffer::C2Buffer(const std::list<C2ConstGraphicBlock> &blocks)
+C2Buffer::C2Buffer(const std::vector<C2ConstGraphicBlock> &blocks)
: mImpl(new Impl(this, blocks)) {}
const C2BufferData C2Buffer::data() const { return mImpl->data(); }
@@ -728,8 +728,8 @@
return mImpl->unregisterOnDestroyNotify(onDestroyNotify, arg);
}
-const std::list<std::shared_ptr<const C2Info>> C2Buffer::infos() const {
- return mImpl->infos();
+const std::vector<std::shared_ptr<const C2Info>> C2Buffer::info() const {
+ return mImpl->info();
}
c2_status_t C2Buffer::setInfo(const std::shared_ptr<C2Info> &info) {
diff --git a/media/libstagefright/codecs/aacdec/C2SoftAac.cpp b/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
index 390f36c..5ddfc14 100644
--- a/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
+++ b/media/libstagefright/codecs/aacdec/C2SoftAac.cpp
@@ -316,9 +316,9 @@
work->worklets.front()->output.buffers.clear();
work->worklets.front()->output.buffers.push_back(buffer);
work->worklets.front()->output.ordinal = work->input.ordinal;
- work->worklets_processed = 1u;
+ work->workletsProcessed = 1u;
};
- if (work && work->input.ordinal.frame_index == outInfo.frameIndex) {
+ if (work && work->input.ordinal.frameIndex == c2_cntr64_t(outInfo.frameIndex)) {
fillWork(work);
} else {
finish(outInfo.frameIndex, fillWork);
@@ -332,7 +332,7 @@
void C2SoftAac::process(
const std::unique_ptr<C2Work> &work,
const std::shared_ptr<C2BlockPool> &pool) {
- work->worklets_processed = 0u;
+ work->workletsProcessed = 0u;
if (mSignalledError) {
return;
}
@@ -346,8 +346,8 @@
size_t offset = 0u;
size_t size = view.capacity();
- bool eos = (work->input.flags & C2BufferPack::FLAG_END_OF_STREAM) != 0;
- bool codecConfig = (work->input.flags & C2BufferPack::FLAG_CODEC_CONFIG) != 0;
+ bool eos = (work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0;
+ bool codecConfig = (work->input.flags & C2FrameData::FLAG_CODEC_CONFIG) != 0;
//TODO
#if 0
@@ -381,8 +381,8 @@
}
Info inInfo;
- inInfo.frameIndex = work->input.ordinal.frame_index;
- inInfo.timestamp = work->input.ordinal.timestamp;
+ inInfo.frameIndex = work->input.ordinal.frameIndex.peeku();
+ inInfo.timestamp = work->input.ordinal.timestamp.peeku();
inInfo.bufferSize = size;
inInfo.decodedSizes.clear();
while (size > 0u) {
@@ -604,13 +604,13 @@
work->worklets.front()->output.buffers.clear();
work->worklets.front()->output.buffers.emplace_back(nullptr);
work->worklets.front()->output.ordinal = work->input.ordinal;
- work->worklets_processed = 1u;
+ work->workletsProcessed = 1u;
};
while (mBuffersInfo.size() > 1u) {
finish(mBuffersInfo.front().frameIndex, fillEmptyWork);
mBuffersInfo.pop_front();
}
- if (work->worklets_processed == 0u) {
+ if (work->workletsProcessed == 0u) {
fillEmptyWork(work);
}
mBuffersInfo.clear();
diff --git a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
index 94308c4..7bce21d 100644
--- a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
+++ b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.cpp
@@ -176,12 +176,12 @@
void C2SoftAacEnc::process(
const std::unique_ptr<C2Work> &work,
const std::shared_ptr<C2BlockPool> &pool) {
- work->worklets_processed = 0u;
+ work->workletsProcessed = 0u;
if (mSignalledError) {
return;
}
- bool eos = (work->input.flags & C2BufferPack::FLAG_END_OF_STREAM) != 0;
+ bool eos = (work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0;
if (!mSentCodecSpecificData) {
// The very first thing we want to output is the codec specific
@@ -215,7 +215,7 @@
#if defined(LOG_NDEBUG) && !LOG_NDEBUG
hexdump(csd->m.value, csd->flexCount());
#endif
- work->worklets.front()->output.infos.push_back(std::move(csd));
+ work->worklets.front()->output.configUpdate.push_back(std::move(csd));
mOutBufferSize = encInfo.maxOutBufBytes;
mNumBytesPerInputFrame = encInfo.frameLength * mNumChannels * sizeof(int16_t);
@@ -225,7 +225,7 @@
}
C2ReadView view = work->input.buffers[0]->data().linearBlocks().front().map().get();
- uint64_t timestamp = mInputTimeUs;
+ uint64_t timestamp = mInputTimeUs.peeku();
size_t numFrames = (view.capacity() + mInputSize + (eos ? mNumBytesPerInputFrame - 1 : 0))
/ mNumBytesPerInputFrame;
@@ -336,11 +336,11 @@
}
work->worklets.front()->output.flags =
- (C2BufferPack::flags_t)(eos ? C2BufferPack::FLAG_END_OF_STREAM : 0);
+ (C2FrameData::flags_t)(eos ? C2FrameData::FLAG_END_OF_STREAM : 0);
work->worklets.front()->output.buffers.clear();
work->worklets.front()->output.ordinal = work->input.ordinal;
work->worklets.front()->output.ordinal.timestamp = timestamp;
- work->worklets_processed = 1u;
+ work->workletsProcessed = 1u;
if (nOutputBytes) {
work->worklets.front()->output.buffers.push_back(
createLinearBuffer(block, 0, nOutputBytes));
@@ -350,7 +350,7 @@
#if 0
ALOGI("sending %d bytes of data (time = %lld us, flags = 0x%08lx)",
- nOutputBytes, mInputTimeUs, outHeader->nFlags);
+ nOutputBytes, mInputTimeUs.peekll(), outHeader->nFlags);
hexdump(outHeader->pBuffer + outHeader->nOffset, outHeader->nFilledLen);
#endif
diff --git a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.h b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.h
index 947c960..c9f440f 100644
--- a/media/libstagefright/codecs/aacenc/C2SoftAacEnc.h
+++ b/media/libstagefright/codecs/aacenc/C2SoftAacEnc.h
@@ -57,7 +57,7 @@
bool mSentCodecSpecificData;
size_t mInputSize;
- int64_t mInputTimeUs;
+ c2_cntr64_t mInputTimeUs;
bool mSignalledError;
diff --git a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
index 0da9cc7..cc12d3c 100644
--- a/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
+++ b/media/libstagefright/codecs/avcdec/C2SoftAvcDec.cpp
@@ -206,14 +206,14 @@
void fillEmptyWork(const std::unique_ptr<C2Work> &work) {
uint32_t flags = 0;
- if ((work->input.flags & C2BufferPack::FLAG_END_OF_STREAM)) {
- flags |= C2BufferPack::FLAG_END_OF_STREAM;
+ if ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM)) {
+ flags |= C2FrameData::FLAG_END_OF_STREAM;
}
- work->worklets.front()->output.flags = (C2BufferPack::flags_t)flags;
+ work->worklets.front()->output.flags = (C2FrameData::flags_t)flags;
work->worklets.front()->output.buffers.clear();
work->worklets.front()->output.buffers.emplace_back(nullptr);
work->worklets.front()->output.ordinal = work->input.ordinal;
- work->worklets_processed = 1u;
+ work->workletsProcessed = 1u;
}
} // namespace
@@ -1061,17 +1061,17 @@
std::shared_ptr<C2Buffer> buffer = createGraphicBuffer(std::move(mAllocatedBlock));
auto fillWork = [buffer](const std::unique_ptr<C2Work> &work) {
uint32_t flags = 0;
- if (work->input.flags & C2BufferPack::FLAG_END_OF_STREAM) {
- flags |= C2BufferPack::FLAG_END_OF_STREAM;
+ if (work->input.flags & C2FrameData::FLAG_END_OF_STREAM) {
+ flags |= C2FrameData::FLAG_END_OF_STREAM;
ALOGV("EOS");
}
- work->worklets.front()->output.flags = (C2BufferPack::flags_t)flags;
+ work->worklets.front()->output.flags = (C2FrameData::flags_t)flags;
work->worklets.front()->output.buffers.clear();
work->worklets.front()->output.buffers.push_back(buffer);
work->worklets.front()->output.ordinal = work->input.ordinal;
- work->worklets_processed = 1u;
+ work->workletsProcessed = 1u;
};
- if (work && index == work->input.ordinal.frame_index) {
+ if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) {
fillWork(work);
} else {
finish(index, fillWork);
@@ -1084,25 +1084,25 @@
bool eos = false;
work->result = C2_OK;
- work->worklets_processed = 0u;
+ work->workletsProcessed = 0u;
const C2ConstLinearBlock &buffer =
work->input.buffers[0]->data().linearBlocks().front();
if (buffer.capacity() == 0) {
- ALOGV("empty input: %llu", (long long)work->input.ordinal.frame_index);
+ ALOGV("empty input: %llu", work->input.ordinal.frameIndex.peekull());
// TODO: result?
fillEmptyWork(work);
- if ((work->input.flags & C2BufferPack::FLAG_END_OF_STREAM)) {
+ if ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM)) {
eos = true;
}
return;
- } else if (work->input.flags & C2BufferPack::FLAG_END_OF_STREAM) {
- ALOGV("input EOS: %llu", (long long)work->input.ordinal.frame_index);
+ } else if (work->input.flags & C2FrameData::FLAG_END_OF_STREAM) {
+ ALOGV("input EOS: %llu", work->input.ordinal.frameIndex.peekull());
eos = true;
}
C2ReadView input = work->input.buffers[0]->data().linearBlocks().front().map().get();
- uint32_t workIndex = work->input.ordinal.frame_index & 0xFFFFFFFF;
+ uint32_t workIndex = work->input.ordinal.frameIndex.peeku() & 0xFFFFFFFF;
size_t inOffset = 0u;
while (inOffset < input.capacity()) {
@@ -1266,7 +1266,7 @@
}
if (drainMode == DRAIN_COMPONENT_WITH_EOS
- && work && work->worklets_processed == 0u) {
+ && work && work->workletsProcessed == 0u) {
fillEmptyWork(work);
}
diff --git a/media/libstagefright/codecs/cmds/codec2.cpp b/media/libstagefright/codecs/cmds/codec2.cpp
index 78fb527..ec05d7a 100644
--- a/media/libstagefright/codecs/cmds/codec2.cpp
+++ b/media/libstagefright/codecs/cmds/codec2.cpp
@@ -247,7 +247,7 @@
}
int slot;
sp<Fence> fence;
- ALOGV("Render: Frame #%" PRId64, work->worklets.front()->output.ordinal.frame_index);
+ ALOGV("Render: Frame #%lld", work->worklets.front()->output.ordinal.frameIndex.peekll());
const std::shared_ptr<C2Buffer> &output = work->worklets.front()->output.buffers[0];
if (output) {
const C2ConstGraphicBlock &block = output->data().graphicBlocks().front();
@@ -266,7 +266,7 @@
status_t err = igbp->attachBuffer(&slot, buffer);
IGraphicBufferProducer::QueueBufferInput qbi(
- work->worklets.front()->output.ordinal.timestamp * 1000ll,
+ (work->worklets.front()->output.ordinal.timestamp * 1000ll).peekll(),
false,
HAL_DATASPACE_UNKNOWN,
Rect(block.width(), block.height()),
@@ -338,9 +338,9 @@
mQueueCondition.wait_for(l, 100ms);
}
}
- work->input.flags = (C2BufferPack::flags_t)0;
+ work->input.flags = (C2FrameData::flags_t)0;
work->input.ordinal.timestamp = timestamp;
- work->input.ordinal.frame_index = numFrames;
+ work->input.ordinal.frameIndex = numFrames;
std::shared_ptr<C2LinearBlock> block;
mLinearPool->fetchLinearBlock(