Skip to content

Commit

Permalink
[Decode] Optimize Jpeg seek to avoid copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaohua-Work authored and gfxVPLsdm committed Sep 19, 2024
1 parent cf0cd53 commit bd8a957
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions _studio/shared/umc/codec/jpeg_common/src/bitstreamin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ JERRCODE CBitStreamInput::SeekAfterByte(uint8_t byte, int* skipped)
{
JERRCODE jerr;
int cnt, res = 0;
unsigned char bytes[] = { byte };
unsigned char* buf;
std::size_t p;
std::string pattern(bytes, bytes + 1);
uint8_t* p;

for (;;)
{
Expand All @@ -274,19 +271,18 @@ JERRCODE CBitStreamInput::SeekAfterByte(uint8_t byte, int* skipped)
if(JPEG_OK != jerr)
return jerr;
}
buf = (unsigned char*) &m_pData[m_currPos];

cnt = m_DataLen - m_currPos;

std::string search(buf, buf + cnt);
p = std::find(m_pData + m_currPos, m_pData + m_DataLen, byte);
if(p != m_pData + m_DataLen) break;

p = search.find(pattern);
if(p != std::string::npos) break;
res += cnt;
m_currPos += cnt;
m_nUsedBytes += cnt;
}

cnt = (int) p;
cnt = (int) (p - m_pData - m_currPos);
res += cnt;
++cnt;
m_currPos += cnt;
Expand Down

0 comments on commit bd8a957

Please sign in to comment.