Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0f23e94 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 46313665 6fe098dc
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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);
+9 −9
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
};
+15 −0
Original line number Diff line number Diff line
@@ -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
 */
Loading