Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
osamu620 committed Oct 5, 2023
1 parent 9ba3af6 commit 8102221
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions apps/main_enc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
FILE *fp;
int fpos = read_pnm(fp, infile, width, height, nc);
size_t fpos = read_pnm(fp, infile, width, height, nc);
jpegenc::im_info inimg(fp, fpos, width, height, nc);

size_t duration = 0;
Expand All @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) {
constexpr double warmuptime = 2000.0; // duration of warmup in milliseconds
constexpr double benchtime = 1000.0; // duration of benchmark in milliseconds
int iter = 0;
while (1) {
while (true) {
encoder.invoke();
iter++;
auto stop = std::chrono::high_resolution_clock::now() - start;
Expand Down
4 changes: 2 additions & 2 deletions include/jpegenc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace jpegenc {

struct im_info {
FILE *data;
const int32_t pos;
const size_t pos;
const int32_t width;
const int32_t height;
const int32_t nc;
im_info(FILE *buf, int32_t fpos, int32_t w, int32_t h, int32_t c)
im_info(FILE *buf, size_t fpos, int32_t w, int32_t h, int32_t c)
: data(buf), pos(fpos), width(w), height(h), nc(c) {}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/bitstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ HWY_ATTR void trial(uint8_t *HWY_RESTRICT in, uint8_t *HWY_RESTRICT out) {
#if HWY_ONCE
namespace jpegenc_hwy {
HWY_EXPORT(trial);
void send_8_bytes(uint8_t *in, uint8_t *out) {
[[maybe_unused]] void send_8_bytes(uint8_t *in, uint8_t *out) {
HWY_DYNAMIC_DISPATCH(trial)
(in, out);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/bitstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define USE_VECTOR 0

namespace jpegenc_hwy {
void send_8_bytes(uint8_t *in, uint8_t *out);
[[maybe_unused]] void send_8_bytes(uint8_t *in, uint8_t *out);
} // namespace jpegenc_hwy

class stream_buf {
Expand Down Expand Up @@ -216,7 +216,8 @@ class bitstream {
flush();
put_word(RST[n]);
}
auto get_stream() {

[[maybe_unused]] auto get_stream() {
flush();
return &stream;
}
Expand Down
1 change: 0 additions & 1 deletion lib/block_coding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "block_coding.hpp"
#include "constants.hpp"
#include "dct.hpp"
#include "huffman_tables.hpp"
#include "quantization.hpp"
#include "ycctype.hpp"

Expand Down
2 changes: 0 additions & 2 deletions lib/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include <hwy/highway.h>

#include <utility>

#include "color.hpp"
#include "ycctype.hpp"
#include "constants.hpp"
Expand Down
1 change: 0 additions & 1 deletion lib/jpegenc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "block_coding.hpp"
#include "color.hpp"
#include "constants.hpp"
#include "dct.hpp"
#include "image_chunk.hpp"
#include "huffman_tables.hpp"
#include "jpgheaders.hpp"
Expand Down
1 change: 0 additions & 1 deletion lib/jpgheaders.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <algorithm>
#include <vector>

#include "bitstream.hpp"
Expand Down
3 changes: 0 additions & 3 deletions lib/quantization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include <hwy/highway.h>

#include <cmath>
#include <utility>
#include "ycctype.hpp"
#include "constants.hpp"
#include "quantization.hpp"

namespace jpegenc_hwy {
Expand Down
2 changes: 1 addition & 1 deletion lib/quantization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ constexpr float qmatrix[2][64] = {
void create_scaled_qtable(int c, int QF, int16_t *qtable);
namespace jpegenc_hwy {
namespace HWY_NAMESPACE {
HWY_ATTR void quantize_core(int16_t *HWY_RESTRICT data, const int *HWY_RESTRICT qtable);
HWY_ATTR void quantize_core(int16_t *HWY_RESTRICT data, const int16_t *HWY_RESTRICT qtable);
} // namespace HWY_NAMESPACE
} // namespace jpegenc_hwy

0 comments on commit 8102221

Please sign in to comment.