Skip to content

Commit

Permalink
Remove dumping code related to macro MFX_DEBUG_DUMP_FRAME
Browse files Browse the repository at this point in the history
Will add dumping code in another way, input & output buffer dump
for encoder & decoder will all be able to be configured by
set property.

Tracked-On: OAM-124732
Signed-off-by: Lina Sun <[email protected]>
  • Loading branch information
lsun30 committed Oct 12, 2024
1 parent 656fff2 commit a1a3f65
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 82 deletions.
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
6 changes: 0 additions & 6 deletions c2_components/include/mfx_c2_decoder_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ class MfxC2DecoderComponent : public MfxC2Component
MFXVideoVPP* m_vpp;
bool m_vppConversion = false;

#if MFX_DEBUG_DUMP_FRAME == MFX_DEBUG_YES
int m_count = 0;
std::mutex m_count_lock;
bool NeedDumpBuffer();
#endif

/* -----------------------C2Parameters--------------------------- */
std::shared_ptr<C2ComponentNameSetting> m_name;
std::shared_ptr<C2ComponentKindSetting> m_kind;
Expand Down
69 changes: 0 additions & 69 deletions c2_components/src/mfx_c2_decoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,42 +2266,6 @@ void MfxC2DecoderComponent::Drain(std::unique_ptr<C2Work>&& work)
}
}

#if MFX_DEBUG_DUMP_FRAME == MFX_DEBUG_YES
bool MfxC2DecoderComponent::NeedDumpBuffer() {
MFX_DEBUG_TRACE_FUNC;
const char* key = "mediacodec2.dump.buffer";
char* value = new char[20];
int len = property_get(key, value, "0");

#include <iostream>
#include <sstream>

std::stringstream strValue;
strValue << value;

unsigned int m_frame_number = 0;
strValue >> m_frame_number;

m_count_lock.lock();
if (m_count) {
delete[] value;
m_count_lock.unlock();
return true;
} else {
delete[] value;
if (len > 0 && m_frame_number > 0) {
m_count = m_frame_number;
MFX_DEBUG_TRACE_PRINTF("--------triggered to dump %d buffers---------", m_frame_number);
property_set(key, "0");
m_count_lock.unlock();
return true;
}
m_count_lock.unlock();
return false;
}
}
#endif

void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint sync_point)
{
MFX_DEBUG_TRACE_FUNC;
Expand Down Expand Up @@ -2460,39 +2424,6 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn
}
m_updatingC2Configures.clear();

#if MFX_DEBUG_DUMP_FRAME == MFX_DEBUG_YES
static FILE* m_f = 0;
if (NeedDumpBuffer()) {
const C2GraphicView& output_view = block->map().get();
m_count_lock.lock();
if (m_count) {
const uint8_t* srcY = output_view.data()[C2PlanarLayout::PLANE_Y];
const uint8_t* srcU = output_view.data()[C2PlanarLayout::PLANE_U];
const uint8_t* srcV = output_view.data()[C2PlanarLayout::PLANE_V];
if (!m_f) {
m_f = fopen("/data/local/traces/decoder_frame.yuv", "w+");
MFX_DEBUG_TRACE_STREAM("/data/local/traces/decoder_frame.yuv: create:" << m_f);
}
if (m_f) {
size_t copied_Y = 0, copied_U = 0;
copied_Y = fwrite(srcY, mfx_surface->Data.PitchLow * m_mfxVideoParams.mfx.FrameInfo.CropH, 1, m_f);
copied_U = fwrite(srcU, mfx_surface->Data.PitchLow * m_mfxVideoParams.mfx.FrameInfo.CropH / 2, 1, m_f);
MFX_DEBUG_TRACE_PRINTF("############# dumping #%d decoded buffer in size: %dx%d, Y:%zu, U:%zu #################",
m_count, mfx_surface->Data.PitchLow, m_mfxVideoParams.mfx.FrameInfo.CropH, copied_Y, copied_U);
if (copied_Y > 0 || copied_U > 0)
m_count--;
}
}
m_count_lock.unlock();
}
m_count_lock.lock();
if (m_count == 0 && m_f) {
fclose(m_f);
MFX_DEBUG_TRACE_MSG("dump file is closed");
m_f = NULL;
}
m_count_lock.unlock();
#endif
worklet->output.buffers.push_back(out_buffer);
block = nullptr;
}
Expand Down
1 change: 0 additions & 1 deletion c2_utils/include/mfx_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#define MFX_DEBUG MFX_DEBUG_NO // enables DEBUG output
#define MFX_PERF MFX_DEBUG_NO // enables PERF output, doesn't depends on MFX_DEBUG
#define MFX_ATRACE MFX_DEBUG_NO // enables systrace
#define MFX_DEBUG_DUMP_FRAME MFX_DEBUG_NO // enables write frame to file

#define MFX_DEBUG_FILE MFX_DEBUG_NO // sends DEBUG and PERF output to file, otherwise to logcat

Expand Down

0 comments on commit a1a3f65

Please sign in to comment.