Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port commits from android 14 #206

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 0 additions & 6 deletions c2_buffers/src/mfx_c2_frame_in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ c2_status_t MfxC2FrameIn::MfxC2LoadSurfaceInSW(C2ConstGraphicBlock& c_graph_bloc
}
}

#if MFX_DEBUG_DUMP_FRAME == MFX_DEBUG_YES
static int frameIndex = 0;
static YUVWriter writer("/data/local/tmp",std::vector<std::string>({}),"encoder_frame.log");
writer.Write(m_yuvData.get(), stride, height, frameIndex++);
#endif

mfx_sts = InitMfxFrameSW(buf_pack.ordinal.timestamp.peeku(), buf_pack.ordinal.frameIndex.peeku(),
m_yuvData.get(), m_yuvData.get()+y_plane_size, width, height, stride, MFX_FOURCC_NV12, m_mfxFrameInfo,
m_pMfxFrameSurface);
Expand Down
1 change: 0 additions & 1 deletion c2_components/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ cc_library_shared {
include_dirs: [
"vendor/intel/mediasdk_c2/c2_utils/include",
"vendor/intel/mediasdk_c2/c2_buffers/include",
"vendor/intel/mediasdk_c2/plugin_store/include",
"frameworks/native/libs/ui/include",
"frameworks/av/media/codec2/sfplugin/utils",
],
Expand Down
1 change: 0 additions & 1 deletion c2_components/include/mfx_c2_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class MfxC2Component : public C2ComponentInterface,
struct CreateConfig
{
int flags{0};
bool dump_output{false};
uint32_t concurrent_instances{0};
bool low_power_mode{false};
};
Expand Down
37 changes: 26 additions & 11 deletions c2_components/include/mfx_c2_decoder_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "mfx_c2_bitstream_in.h"
#include "mfx_frame_pool_allocator.h"
#include "mfx_gralloc_instance.h"
#include "mfx_intel_device.h"
#include "mfx_c2_setters.h"
#include "mfx_c2_utils.h"
#include <cutils/properties.h>

class MfxC2DecoderComponent : public MfxC2Component
Expand Down Expand Up @@ -131,9 +133,10 @@ class MfxC2DecoderComponent : public MfxC2Component
mfxStatus DecodeFrame(mfxBitstream *bs, MfxC2FrameOut&& frame_out,
bool* flushing, bool* expect_output);

c2_status_t AllocateC2Block(uint32_t width, uint32_t height, uint32_t fourcc, std::shared_ptr<C2GraphicBlock>* out_block);
c2_status_t AllocateC2Block(uint32_t width, uint32_t height, uint32_t fourcc,
std::shared_ptr<C2GraphicBlock>* out_block, bool vpp_conversion = false);

c2_status_t AllocateFrame(MfxC2FrameOut* frame_out);
c2_status_t AllocateFrame(MfxC2FrameOut* frame_out, bool vpp_conversion = false);

mfxU16 GetAsyncDepth();

Expand Down Expand Up @@ -162,6 +165,8 @@ class MfxC2DecoderComponent : public MfxC2Component

void UpdateColorAspectsFromBitstream(const mfxExtVideoSignalInfo &signalInfo);

mfxStatus InitVPP();

private:
DecoderType m_decoderType;

Expand Down Expand Up @@ -219,7 +224,7 @@ class MfxC2DecoderComponent : public MfxC2Component
std::list<MfxC2FrameOut> m_lockedSurfaces; // allocated, but cannot be re-used as Locked by Decoder

std::mutex m_pendingWorksMutex;
std::map<decltype(C2WorkOrdinalStruct::timestamp), std::unique_ptr<C2Work>> m_pendingWorks;
std::map<decltype(C2WorkOrdinalStruct::frameIndex), std::unique_ptr<C2Work>> m_pendingWorks;

std::shared_ptr<MfxFramePoolAllocator> m_allocator; // used when Video memory output
// for pre-allocation when Video memory is chosen and always when System memory output
Expand All @@ -246,19 +251,28 @@ class MfxC2DecoderComponent : public MfxC2Component
unsigned int m_uOutputDelay = 8u;
unsigned int m_uInputDelay = 0u;

#if MFX_DEBUG_DUMP_FRAME == MFX_DEBUG_YES
int m_count = 0;
std::mutex m_count_lock;
bool NeedDumpBuffer();
#endif
MFXVideoVPP* m_vpp;
bool m_vppConversion = false;

std::unique_ptr<BinaryWriter> m_outputWriter;
std::unique_ptr<BinaryWriter> m_inputWriter;

std::mutex m_dump_output_lock;
std::mutex m_dump_input_lock;

uint32_t m_dump_count = 0;
// decoder output dump file number, during decoding one bitstream, if
// dump output multiple times, the first dumped file named xxx_0.yuv,
// second dumped file named xxx_1.yuv ...
uint32_t m_file_num = 0;
bool m_needCpuAccess = false;

/* -----------------------C2Parameters--------------------------- */
std::shared_ptr<C2ComponentNameSetting> m_name;
std::shared_ptr<C2ComponentKindSetting> m_kind;
std::shared_ptr<C2ComponentDomainSetting> m_domain;
std::shared_ptr<C2StreamPictureSizeInfo::output> m_size;
std::shared_ptr<C2PortSurfaceAllocatorTuning::output> m_surfaceAllocator;
std::shared_ptr<C2PortAllocatorsTuning::input> m_inputAllocators;
std::shared_ptr<C2PortAllocatorsTuning::output> m_outputAllocators;
std::shared_ptr<C2StreamMaxPictureSizeTuning::output> m_maxSize;
std::shared_ptr<C2StreamMaxBufferSizeInfo::input> m_maxInputSize;
Expand All @@ -268,15 +282,15 @@ class MfxC2DecoderComponent : public MfxC2Component
std::shared_ptr<C2PortMediaTypeSetting::input> m_inputMediaType;
std::shared_ptr<C2StreamBufferTypeSetting::input> m_inputFormat;
std::shared_ptr<C2StreamBufferTypeSetting::output> m_outputFormat;
std::shared_ptr<C2StreamUsageTuning::output> m_outputUsage;
std::shared_ptr<C2StreamProfileLevelInfo::input> m_profileLevel;
std::shared_ptr<C2PortActualDelayTuning::output> m_actualOutputDelay;
std::shared_ptr<C2PortRequestedDelayTuning::input> m_requestedInputDelay;
std::shared_ptr<C2PortActualDelayTuning::input> m_actualInputDelay;
std::shared_ptr<C2PortDelayTuning::input> m_inputDelay;
std::shared_ptr<C2StreamColorAspectsTuning::output> m_defaultColorAspects;
std::shared_ptr<C2StreamColorAspectsInfo::input> m_inColorAspects;
std::shared_ptr<C2StreamColorAspectsInfo::output> m_outColorAspects;
std::shared_ptr<C2StreamPixelFormatInfo::output> m_pixelFormat;

/* ----------------------------------------Setters------------------------------------------- */
static C2R OutputSurfaceAllocatorSetter(bool mayBlock, C2P<C2PortSurfaceAllocatorTuning::output> &me);
static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe,
Expand All @@ -292,4 +306,5 @@ class MfxC2DecoderComponent : public MfxC2Component
static C2R ColorAspectsSetter(bool mayBlock, C2P<C2StreamColorAspectsInfo::output> &me,
const C2P<C2StreamColorAspectsTuning::output> &def,
const C2P<C2StreamColorAspectsInfo::input> &coded);
static C2R OutputUsageSetter(bool mayBlock, C2P<C2StreamUsageTuning::output> &me);
};
12 changes: 10 additions & 2 deletions c2_components/include/mfx_c2_encoder_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "mfx_c2_utils.h"
#include "mfx_c2_vpp_wrapp.h"
#include "mfx_c2_setters.h"
#include <cutils/properties.h>

// Assumes all calls are done from one (working) thread, no sync is needed.
// m_ctrlOnce accumulates subsequent changes for one next frame.
Expand Down Expand Up @@ -202,8 +203,6 @@ class MfxC2EncoderComponent : public MfxC2Component

std::shared_ptr<C2BlockPool> m_c2Allocator;

std::unique_ptr<BinaryWriter> m_outputWriter;

bool m_bHeaderSent{false};

mfxFrameSurface1 *m_encSrfPool;
Expand All @@ -220,6 +219,15 @@ class MfxC2EncoderComponent : public MfxC2Component
// Input frame info with width or height not 16byte aligned
mfxFrameInfo m_mfxInputInfo;

std::unique_ptr<BinaryWriter> m_outputWriter;
std::unique_ptr<BinaryWriter> m_inputWriter;

std::mutex m_dump_output_lock;
std::mutex m_dump_input_lock;

uint32_t m_dump_count = 0;
uint32_t m_dump_frames_number = 0; //total frames to dump

/* -----------------------C2Parameters--------------------------- */
std::mutex m_c2ParameterMutex;
std::shared_ptr<C2ComponentNameSetting> m_name;
Expand Down
Loading
Loading