Skip to content

Commit

Permalink
Merge pull request #26 from osamu620/improve_speed
Browse files Browse the repository at this point in the history
Improve speed
  • Loading branch information
osamu620 authored Oct 3, 2023
2 parents 99dbb55 + 29ab646 commit 6655260
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/block_coding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,19 +417,25 @@ HWY_ATTR void encode_single_block(int16_t *HWY_RESTRICT sp, huff_info &tab, int
const uint32_t EOB_cwd = tab.AC_cwd[0x00];
const int32_t EOB_len = tab.AC_len[0x00];

uint32_t diff;
int32_t nbits;
while (bitmap != 0) {
int run = JPEGENC_CLZ64(bitmap);
count += run;
bitmap <<= run;
diff = dp[count];
nbits = bits[count];
while (run > 15) {
// ZRL
enc.put_bits(ZRL_cwd, ZRL_len);
run -= 16;
}
// EncodeAC
size_t RS = (run << 4) + bits[count];
enc.put_bits(tab.AC_cwd[RS], tab.AC_len[RS]);
enc.put_bits(dp[count], bits[count]);
size_t RS = (run << 4) + nbits; // size_t RS = (run << 4) + bits[count];
diff |= tab.AC_cwd[RS] << nbits; // enc.put_bits(tab.AC_cwd[RS], tab.AC_len[RS]);
nbits += tab.AC_len[RS]; // enc.put_bits(dp[count], bits[count]);
enc.put_bits(diff, nbits);

count++;
bitmap <<= 1;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ HWY_ATTR void rgb2ycbcr(uint8_t *HWY_RESTRICT in, std::vector<uint8_t *> &out, i
Subsampling operation arranges component sample values in MCU order.
(In other words, component samples in an MCU are 1-d contiguous array.)
*/
HWY_ATTR void subsample_core(std::vector<uint8_t *> in, std::vector<int16_t *> &out, int width,
HWY_ATTR void subsample_core(std::vector<uint8_t *> &in, std::vector<int16_t *> &out, int width,
int YCCtype) {
// int nc = (YCCtype == YCC::GRAY) ? 1 : 3;
int scale_x = YCC_HV[YCCtype][0] >> 4;
Expand Down Expand Up @@ -710,7 +710,7 @@ HWY_ATTR void rgb2ycbcr(uint8_t *HWY_RESTRICT in, std::vector<uint8_t *> &out, c
}
}

HWY_ATTR void subsample_core(std::vector<uint8_t *> &in, std::vector<int16_t *> out, const int width,
HWY_ATTR void subsample_core(std::vector<uint8_t *> &in, std::vector<int16_t *> &out, const int width,
const int YCCtype) {
int nc = (YCCtype == YCC::GRAY) ? 1 : 3;
int scale_x = YCC_HV[YCCtype][0] >> 4;
Expand Down

0 comments on commit 6655260

Please sign in to comment.