Merge "Codec2: tweak C2Work struct and rename C2BufferPack to C2FrameData"

gugelfrei
TreeHugger Robot 7 years ago committed by Android (Google) Code Review
commit c0f23e9450

@ -665,16 +665,16 @@ status_t CCodecBufferChannel::queueInputBuffer(const sp<MediaCodecBuffer> &buffe
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 @@ status_t CCodecBufferChannel::renderOutputBuffer(
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 @@ void CCodecBufferChannel::onWorkDone(std::vector<std::unique_ptr<C2Work>> workIt
}
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 @@ void CCodecBufferChannel::onWorkDone(std::vector<std::unique_ptr<C2Work>> workIt
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 @@ void CCodecBufferChannel::onWorkDone(std::vector<std::unique_ptr<C2Work>> workIt
}
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 @@ void CCodecBufferChannel::onWorkDone(std::vector<std::unique_ptr<C2Work>> workIt
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 @@ void CCodecBufferChannel::onWorkDone(std::vector<std::unique_ptr<C2Work>> workIt
}
}
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);

@ -342,7 +342,7 @@ void SimpleC2Component::processQueue() {
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 @@ void SimpleC2Component::processQueue() {
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);

@ -679,14 +679,14 @@ public:
*
* \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 @@ public:
* \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 @@ private:
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 @@ public:
*
* \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 @@ public:
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;

@ -682,7 +682,7 @@ public:
*/
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;
};

@ -721,6 +721,10 @@ struct C2ParamField {
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;
@ -728,6 +732,17 @@ private:
_C2FieldId _mFieldId; ///< field identifier
};
/**
* 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
*/

@ -83,32 +83,64 @@ enum {
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 @@ struct C2Worklet {
// 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;
C2BufferPack input;
/// additional work chain info not part of this work
std::shared_ptr<C2WorkChainInfo> chainInfo;
/// 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;

@ -359,14 +359,14 @@ TEST_F(C2BufferTest, GraphicBlockPoolTest) {
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 @@ TEST_F(C2BufferTest, BufferTest) {
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()));
}

@ -602,44 +602,44 @@ c2_status_t C2BasicGraphicBlockPool::fetchGraphicBlock(
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 @@ public:
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 @@ private:
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 @@ c2_status_t C2Buffer::unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify,
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) {

@ -316,9 +316,9 @@ void C2SoftAac::drainRingBuffer(
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::drainRingBuffer(
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 @@ void C2SoftAac::process(
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 @@ void C2SoftAac::process(
}
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 @@ c2_status_t C2SoftAac::drainInternal(
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();

@ -176,12 +176,12 @@ status_t C2SoftAacEnc::setAudioParams() {
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 @@ void C2SoftAacEnc::process(
#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 @@ void C2SoftAacEnc::process(
}
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 @@ void C2SoftAacEnc::process(
}
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 @@ void C2SoftAacEnc::process(
#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

@ -57,7 +57,7 @@ private:
bool mSentCodecSpecificData;
size_t mInputSize;
int64_t mInputTimeUs;
c2_cntr64_t mInputTimeUs;
bool mSignalledError;

@ -206,14 +206,14 @@ private:
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 @@ void C2SoftAvcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wor
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 @@ void C2SoftAvcDec::process(
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 @@ c2_status_t C2SoftAvcDec::drainInternal(
}
if (drainMode == DRAIN_COMPONENT_WITH_EOS
&& work && work->worklets_processed == 0u) {
&& work && work->workletsProcessed == 0u) {
fillEmptyWork(work);
}

@ -247,7 +247,7 @@ void SimplePlayer::play(const sp<IMediaSource> &source) {
}
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 @@ void SimplePlayer::play(const sp<IMediaSource> &source) {
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 @@ void SimplePlayer::play(const sp<IMediaSource> &source) {
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(

Loading…
Cancel
Save