Skip to content

Commit

Permalink
Merge pull request google#24 from ittiam-systems/asan
Browse files Browse the repository at this point in the history
Allocate width aligned to MCU size for boundary rows
  • Loading branch information
DichenZhang1 authored Oct 22, 2023
2 parents e22dff9 + 48b2bcf commit d4a3e15
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions jpegencoderhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ bool JpegEncoderHelper::compressYuv(jpeg_compress_struct* cinfo, const uint8_t*
JSAMPROW cr[kCompressBatchSize / 2];
JSAMPARRAY planes[3]{y, cb, cr};

const int aligned_width = ALIGNM(cinfo->image_width, kCompressBatchSize);
const bool need_padding = (lumaStride < aligned_width);
size_t u_plane_size = chromaStride * cinfo->image_height / 2;
uint8_t* y_plane = const_cast<uint8_t*>(yBuffer);
uint8_t* u_plane = const_cast<uint8_t*>(uvBuffer);
uint8_t* v_plane = const_cast<uint8_t*>(u_plane + u_plane_size);
std::unique_ptr<uint8_t[]> empty = std::make_unique<uint8_t[]>(cinfo->image_width);
memset(empty.get(), 0, cinfo->image_width);
std::unique_ptr<uint8_t[]> empty = std::make_unique<uint8_t[]>(aligned_width);
memset(empty.get(), 0, aligned_width);

const int aligned_width = ALIGNM(cinfo->image_width, kCompressBatchSize);
const bool need_padding = (lumaStride < aligned_width);
std::unique_ptr<uint8_t[]> buffer_intrm = nullptr;
uint8_t* y_plane_intrm = nullptr;
uint8_t* u_plane_intrm = nullptr;
Expand Down Expand Up @@ -227,12 +227,12 @@ bool JpegEncoderHelper::compressY(jpeg_compress_struct* cinfo, const uint8_t* yB
JSAMPROW y[kCompressBatchSize];
JSAMPARRAY planes[1]{y};

uint8_t* y_plane = const_cast<uint8_t*>(yBuffer);
std::unique_ptr<uint8_t[]> empty = std::make_unique<uint8_t[]>(cinfo->image_width);
memset(empty.get(), 0, cinfo->image_width);

const int aligned_width = ALIGNM(cinfo->image_width, kCompressBatchSize);
const bool need_padding = (lumaStride < aligned_width);

uint8_t* y_plane = const_cast<uint8_t*>(yBuffer);
std::unique_ptr<uint8_t[]> empty = std::make_unique<uint8_t[]>(aligned_width);
memset(empty.get(), 0, aligned_width);
std::unique_ptr<uint8_t[]> buffer_intrm = nullptr;
uint8_t* y_plane_intrm = nullptr;
JSAMPROW y_intrm[kCompressBatchSize];
Expand Down

0 comments on commit d4a3e15

Please sign in to comment.