Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c2_buffers/include/mfx_c2_frame_in.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MfxC2FrameIn
private:
std::shared_ptr<C2Buffer> m_c2Buffer;
std::unique_ptr<const C2GraphicView> m_c2GraphicView;
mfxFrameSurface1 *m_pMfxFrameSurface = nullptr;
mfxFrameSurface1 *m_pMfxFrameSurface;
std::shared_ptr<uint8_t> m_yuvData; //only for sw frame
std::shared_ptr<MfxFrameConverter> m_frameConverter;
mfxFrameInfo m_mfxFrameInfo; //va surface info with width and height 16byte aligned
Expand Down
12 changes: 4 additions & 8 deletions c2_components/src/mfx_c2_decoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo

addParameter(
DefineParam(m_maxSize, C2_PARAMKEY_MAX_PICTURE_SIZE)
.withDefault(new C2StreamMaxPictureSizeTuning::output(SINGLE_STREAM_ID, MIN_W, MIN_H))
.withDefault(new C2StreamMaxPictureSizeTuning::output(SINGLE_STREAM_ID, WIDTH_8K, HEIGHT_8K))
.withFields({
C2F(m_size, width).inRange(2, WIDTH_8K, 2),
C2F(m_size, height).inRange(2, HEIGHT_8K, 2),
Expand Down Expand Up @@ -632,7 +632,6 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo
// By default prepare buffer to be displayed on any of the common surfaces
m_consumerUsage = kDefaultConsumerUsage;

MFX_ZERO_MEMORY(m_signalInfo);
//m_paramStorage.DumpParams();
}

Expand Down Expand Up @@ -800,16 +799,17 @@ c2_status_t MfxC2DecoderComponent::Release()
}
#else
sts = m_mfxSession.Close();
if (MFX_ERR_NONE != sts) res = MfxStatusToC2(sts);
#endif

if (MFX_ERR_NONE != sts) res = MfxStatusToC2(sts);

if (m_allocator) {
m_allocator = nullptr;
}

if (m_device) {
m_device->Close();
if (MFX_ERR_NONE != sts) res = MfxStatusToC2(sts);

m_device = nullptr;
}
Expand Down Expand Up @@ -1809,10 +1809,6 @@ c2_status_t MfxC2DecoderComponent::AllocateFrame(MfxC2FrameOut* frame_out)
std::unique_ptr<native_handle_t, decltype(hndl_deleter)> hndl(
android::UnwrapNativeCodec2GrallocHandle(out_block->handle()), hndl_deleter);

if(hndl == nullptr)
{
return C2_NO_MEMORY;
}
auto it = m_surfaces.end();
if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_VIDEO_MEMORY) {

Expand Down Expand Up @@ -1850,7 +1846,7 @@ c2_status_t MfxC2DecoderComponent::AllocateFrame(MfxC2FrameOut* frame_out)
m_surfacePool.push_back(frame_out->GetMfxFrameSurface());
} else {
auto it = m_surfacePool.begin();
for(auto& mfx_frame: m_surfacePool) {
for(auto mfx_frame: m_surfacePool) {
// Check if there is avaiable surface in the pool
if (!mfx_frame->Data.Locked) {
auto blk = m_blocks.begin();
Expand Down
15 changes: 9 additions & 6 deletions c2_components/src/mfx_c2_encoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,6 @@ MfxC2EncoderComponent::MfxC2EncoderComponent(const C2String name, const CreateCo
m_codedColorAspects->matrix = C2Color::MATRIX_UNSPECIFIED;
m_codedColorAspects->primaries = C2Color::PRIMARIES_UNSPECIFIED;

MFX_ZERO_MEMORY(m_signalInfo);
MFX_ZERO_MEMORY(m_mfxInputInfo);
//m_paramStorage.DumpParams();
}

Expand Down Expand Up @@ -1254,7 +1252,6 @@ void MfxC2EncoderComponent::DoWork(std::unique_ptr<C2Work>&& work)

if (MFX_ERR_NONE != mfx_sts) {
res = MfxStatusToC2(mfx_sts);
MFX_ZERO_MEMORY(mfx_frame_in);
break;
}

Expand Down Expand Up @@ -1308,8 +1305,6 @@ void MfxC2EncoderComponent::DoWork(std::unique_ptr<C2Work>&& work)
break;
}

// XXX: "Big parameter passed by value(PASS_BY_VALUE)" by Coverity scanning.
// mfx_frame of type size 136 bytes.
m_waitingQueue.Push( [ mfx_frame = std::move(mfx_frame_in), this ] () mutable {
RetainLockedFrame(std::move(mfx_frame));
} );
Expand Down Expand Up @@ -1878,6 +1873,10 @@ void MfxC2EncoderComponent::DoUpdateMfxParam(const std::vector<C2Param*> &params
}
case kParamIndexColorAspects: {
if (C2StreamColorAspectsInfo::input::PARAM_TYPE == param->index()) {
m_colorAspects->range = m_colorAspects->range;
m_colorAspects->transfer = m_colorAspects->transfer;
m_colorAspects->matrix = m_colorAspects->matrix;
m_colorAspects->primaries = m_colorAspects->primaries;

// set video signal info
setColorAspects_l();
Expand All @@ -1887,6 +1886,10 @@ void MfxC2EncoderComponent::DoUpdateMfxParam(const std::vector<C2Param*> &params
MFX_DEBUG_TRACE_U32(m_colorAspects->transfer);
MFX_DEBUG_TRACE_U32(m_colorAspects->matrix);
} else {
m_codedColorAspects->range = m_codedColorAspects->range;
m_codedColorAspects->transfer = m_codedColorAspects->transfer;
m_codedColorAspects->matrix = m_codedColorAspects->matrix;
m_codedColorAspects->primaries = m_codedColorAspects->primaries;

MFX_DEBUG_TRACE_U32(m_codedColorAspects->range);
MFX_DEBUG_TRACE_U32(m_codedColorAspects->primaries);
Expand Down Expand Up @@ -2095,7 +2098,7 @@ uint32_t MfxC2EncoderComponent::getSyncFramePeriod_l(int32_t sync_frame_period)
return 0;
}

double frame_rate = m_mfxVideoParamsConfig.mfx.FrameInfo.FrameRateExtN / m_mfxVideoParamsConfig.mfx.FrameInfo.FrameRateExtD * 1.0;
double frame_rate = m_mfxVideoParamsConfig.mfx.FrameInfo.FrameRateExtN / m_mfxVideoParamsConfig.mfx.FrameInfo.FrameRateExtD;
double period = sync_frame_period / 1e6 * frame_rate;

MFX_DEBUG_TRACE_F64(frame_rate);
Expand Down
1 change: 0 additions & 1 deletion c2_components/src/mfx_c2_vpp_wrapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ MfxC2VppWrapp::MfxC2VppWrapp(void):
MFX_ZERO_MEMORY(m_vppParam);
MFX_ZERO_MEMORY(m_allocator);
MFX_ZERO_MEMORY(m_responses);
MFX_ZERO_MEMORY(m_vppSrf);
}

MfxC2VppWrapp::~MfxC2VppWrapp(void)
Expand Down
17 changes: 5 additions & 12 deletions c2_store/src/mfx_c2_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,14 @@ void RegisterC2Service()


int main(int /* argc */, char** /* argv */) {
// ALOGD("hardware.intel.media.c2@1.0-service starting...");
ALOGD("hardware.intel.media.c2@1.0-service starting...");

signal(SIGPIPE, SIG_IGN);
try
{
android::SetUpMinijail(kBaseSeccompPolicyPath, kExtSeccompPolicyPath);
// vndbinder is needed by BufferQueue.
android::ProcessState::initWithDriver("/dev/vndbinder");
android::ProcessState::self()->startThreadPool();
}
catch(const std::exception& e)
{
// ALOGE("SetUpMinijail function execution error");
}
android::SetUpMinijail(kBaseSeccompPolicyPath, kExtSeccompPolicyPath);

// vndbinder is needed by BufferQueue.
android::ProcessState::initWithDriver("/dev/vndbinder");
android::ProcessState::self()->startThreadPool();

// Extra threads may be needed to handle a stacked IPC sequence that
// contains alternating binder and hwbinder calls. (See b/35283480.)
Expand Down
2 changes: 0 additions & 2 deletions c2_utils/include/mfx_c2_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class BinaryWriter

private:
std::ofstream stream_;
std::mutex m_mutex;
};

// Writes YUV format frame to file.It useful for debug.
Expand All @@ -194,7 +193,6 @@ class YUVWriter
void Write(const uint8_t* yuv_data, int stride, int height, int frameIndex/*, int fourCC*/);

private:
std::mutex m_mutex;
std::ofstream stream_;
};

Expand Down
1 change: 0 additions & 1 deletion c2_utils/include/mfx_cmd_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <C2Work.h>

#include <utils/Log.h>
#include <functional>
#include <queue>
#include <thread>
Expand Down
23 changes: 4 additions & 19 deletions c2_utils/include/mfx_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#pragma once

#include <utils/Log.h>
#include <mutex>
#include <future>
#include <memory>
Expand All @@ -47,16 +46,9 @@ class MfxPool
// Correct method to free pool instance.
// This waiting for destroyed is needed as module with pool could be unloaded from
// memory while some resource could try to add itself back to the pool.
try
{
std::future<void> destroyed = m_poolImpl->Destroyed();
m_poolImpl.reset();
destroyed.wait();
}
catch(const std::exception& e)
{
// ALOGE("Destroyed function execution error");
}
std::future<void> destroyed = m_poolImpl->Destroyed();
m_poolImpl.reset();
destroyed.wait();
}

MFX_CLASS_NO_COPY(MfxPool<T>)
Expand Down Expand Up @@ -88,14 +80,7 @@ class MfxPool
public:
~MfxPoolImpl()
{
try
{
m_destroyed.set_value();
}
catch(const std::exception& e)
{
// ALOGE("set_value function execution error");
}
m_destroyed.set_value();
}

void Append(std::unique_ptr<T>&& free_item)
Expand Down
14 changes: 2 additions & 12 deletions c2_utils/src/mfx_c2_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,6 @@ BinaryWriter::BinaryWriter(const std::string& dir,
std::stringstream full_name;
full_name << dir << "/";

std::lock_guard<std::mutex> lock(m_mutex);

for(const std::string& sub_dir : sub_dirs) {
full_name << sub_dir;

Expand All @@ -640,10 +638,7 @@ BinaryWriter::BinaryWriter(const std::string& dir,

if (!dir_exists) {
MFX_DEBUG_TRACE_STREAM(NAMED(full_name.str()));
if(mkdir(full_name.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) {
MFX_DEBUG_TRACE_MSG("cannot create the path");
return;
}
mkdir(full_name.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
}

full_name << "/";
Expand All @@ -661,8 +656,6 @@ YUVWriter::YUVWriter(const std::string& dir,
std::stringstream full_name;
full_name << dir << "/";

std::lock_guard<std::mutex> lock(m_mutex);

for(const std::string& sub_dir : sub_dirs) {
full_name << sub_dir;

Expand All @@ -676,10 +669,7 @@ YUVWriter::YUVWriter(const std::string& dir,

if (!dir_exists) {
MFX_DEBUG_TRACE_STREAM(NAMED(full_name.str()));
if(mkdir(full_name.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) {
MFX_DEBUG_TRACE_MSG("cannot create the path");
return;
}
mkdir(full_name.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
}

full_name << "/";
Expand Down
9 changes: 1 addition & 8 deletions c2_utils/src/mfx_cmd_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@
MfxCmdQueue::~MfxCmdQueue()
{
MFX_DEBUG_TRACE(MFX_PTR_NAME(this));
try
{
Abort();
}
catch(const std::exception& e)
{
// ALOGE("Abort function execution error");
}
Abort();
}

void MfxCmdQueue::Start()
Expand Down
35 changes: 7 additions & 28 deletions c2_utils/src/mfx_va_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,23 +350,11 @@ mfxStatus MfxVaFrameAllocator::UnlockFrame(mfxMemId mid, mfxFrameData *frame_dat
if (va_mid && va_mid->surface_) {

if (MFX_FOURCC_P8 == va_mid->fourcc_) { // bitstream processing
VAStatus va_res = vaUnmapBuffer(m_dpy, *(va_mid->surface_));
if (VA_STATUS_SUCCESS != va_res) {
mfx_res = va_to_mfx_status(va_res);
return mfx_res;
}
vaUnmapBuffer(m_dpy, *(va_mid->surface_));
}
else { // Image processing
VAStatus va_res = vaUnmapBuffer(m_dpy, va_mid->image_.buf);
if (VA_STATUS_SUCCESS != va_res) {
mfx_res = va_to_mfx_status(va_res);
return mfx_res;
}
va_res = vaDestroyImage(m_dpy, va_mid->image_.image_id);
if (VA_STATUS_SUCCESS != va_res) {
mfx_res = va_to_mfx_status(va_res);
return mfx_res;
}
vaUnmapBuffer(m_dpy, va_mid->image_.buf);
vaDestroyImage(m_dpy, va_mid->image_.image_id);

if (nullptr != frame_data) {
frame_data->Pitch = 0;
Expand Down Expand Up @@ -640,7 +628,6 @@ mfxStatus MfxVaFrameAllocator::TouchSurface(VASurfaceID surface)
VAImage image;
unsigned char* buffer;
VAStatus va_res;
mfxStatus mfx_res = MFX_ERR_NONE;

if (VA_INVALID_ID == surface) return MFX_ERR_UNKNOWN;

Expand All @@ -651,18 +638,10 @@ mfxStatus MfxVaFrameAllocator::TouchSurface(VASurfaceID surface)
if (VA_STATUS_SUCCESS == va_res)
{
*buffer = 0x0; // can have any value
va_res = vaUnmapBuffer(m_dpy, image.buf);
if (VA_STATUS_SUCCESS != va_res) {
mfx_res = va_to_mfx_status(va_res);
return mfx_res;
}
vaUnmapBuffer(m_dpy, image.buf);
}
va_res = vaDestroyImage(m_dpy, image.image_id);
if (VA_STATUS_SUCCESS != va_res) {
mfx_res = va_to_mfx_status(va_res);
return mfx_res;
}
}
return mfx_res;
vaDestroyImage(m_dpy, image.image_id);
}
return MFX_ERR_NONE;
}
#endif // #if defined(LIBVA_SUPPORT)
10 changes: 5 additions & 5 deletions c2_utils/src/mfx_va_frame_pool_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ mfxStatus MfxVaFramePoolAllocator::AllocFrames(mfxFrameAllocRequest *request,
native_handle_t *hndl = android::UnwrapNativeCodec2GrallocHandle(new_block->handle());
m_grallocAllocator->GetBackingStore(hndl, &id);
m_cachedBufferId.emplace(id, i);
// if (C2_OK != res) { //TODO dead code not need.
// native_handle_delete(hndl);
// mfx_res = MFX_ERR_MEMORY_ALLOC;
// break;
// }
if (C2_OK != res) {
native_handle_delete(hndl);
mfx_res = MFX_ERR_MEMORY_ALLOC;
break;
}

// deep copy to have unique_ptr as m_pool required unique_ptr
std::unique_ptr<C2GraphicBlock> unique_block = std::make_unique<C2GraphicBlock>(*new_block);
Expand Down