aboutsummaryrefslogtreecommitdiff
path: root/research
diff options
context:
space:
mode:
authorIvan Nikulin <vanickulin@google.com>2016-09-15 16:59:52 +0200
committerIvan Nikulin <vanickulin@google.com>2016-09-15 16:59:52 +0200
commit0e52c59a07c62c537183a7848244037fe8172930 (patch)
tree778ee1feb191d1bd66432a99493509fc7eb4f32d /research
parent9589396e5dcca3fd16f568ff93d99124fd0eed2e (diff)
downloadbrotli-0e52c59a07c62c537183a7848244037fe8172930.zip
brotli-0e52c59a07c62c537183a7848244037fe8172930.tar.gz
brotli-0e52c59a07c62c537183a7848244037fe8172930.tar.bz2
Update variable naming.
Diffstat (limited to 'research')
-rw-r--r--research/draw_histogram.cc36
1 files changed, 16 insertions, 20 deletions
diff --git a/research/draw_histogram.cc b/research/draw_histogram.cc
index 6560f66..a7eddb6 100644
--- a/research/draw_histogram.cc
+++ b/research/draw_histogram.cc
@@ -61,7 +61,7 @@ void AdjustPosition(int* pos) {
*pos += offset;
}
-void CalculateStuff(FILE* fin, int** stuff) {
+void BuildHistogram(FILE* fin, int** histo) {
int height = FLAGS_height;
int width = FLAGS_width;
int skip = FLAGS_skip;
@@ -71,7 +71,7 @@ void CalculateStuff(FILE* fin, int** stuff) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
- stuff[i][j] = 0;
+ histo[i][j] = 0;
}
}
@@ -107,46 +107,46 @@ void CalculateStuff(FILE* fin, int** stuff) {
assert(right >= 0);
}
if (y == right) {
- stuff[x][y] += copy;
+ histo[x][y] += copy;
} else {
int pos2 = static_cast<int>(ceil(1.0 * (y + 1) * max_pos / width));
- stuff[x][y] += pos2 - pos;
+ histo[x][y] += pos2 - pos;
for (int i = y + 1; i < right && i < width; ++i) {
- stuff[x][i] += max_pos / width; // Sometimes 1 more, but who cares.
+ histo[x][i] += max_pos / width; // Sometimes 1 more, but who cares.
}
// Make sure the match doesn't go beyond the image.
if (right < width) {
pos2 = static_cast<int>(ceil(1.0 * right * max_pos / width));
- stuff[x][right] += pos + copy - 1 - pos2 + 1;
+ histo[x][right] += pos + copy - 1 - pos2 + 1;
}
}
} else {
- stuff[x][y]++;
+ histo[x][y]++;
}
}
}
}
-void ConvertToPixels(int** stuff, uint8_t** pixel) {
+void ConvertToPixels(int** histo, uint8_t** pixel) {
int height = FLAGS_height;
int width = FLAGS_width;
int maxs = 0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
- if (maxs < stuff[i][j]) maxs = stuff[i][j];
+ if (maxs < histo[i][j]) maxs = histo[i][j];
}
}
bool simple = FLAGS_simple;
- double max_stuff = static_cast<double>(maxs);
+ double max_histo = static_cast<double>(maxs);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if (simple) {
- pixel[i][j] = stuff[i][j] > 0 ? 0 : 255;
+ pixel[i][j] = histo[i][j] > 0 ? 0 : 255;
} else {
pixel[i][j] = static_cast<uint8_t>(
- 255 - DensityTransform(stuff[i][j] / max_stuff * 255));
+ 255 - DensityTransform(histo[i][j] / max_histo * 255));
}
}
}
@@ -178,21 +178,17 @@ int main(int argc, char* argv[]) {
if (FLAGS_max_distance == 0) FLAGS_max_distance = FLAGS_size;
- /* The bio of stuff:
- 1. Copy length of backward reference.
- 2. Number of backward references per pixel/bucket.
- */
uint8_t** pixel = new uint8_t*[height];
- int** stuff = new int*[height];
+ int** histo = new int*[height];
for (int i = 0; i < height; i++) {
pixel[i] = new uint8_t[width];
- stuff[i] = new int[width];
+ histo[i] = new int[width];
}
- CalculateStuff(fin, stuff);
+ BuildHistogram(fin, histo);
fclose(fin);
- ConvertToPixels(stuff, pixel);
+ ConvertToPixels(histo, pixel);
DrawPixels(pixel, fout);
fclose(fout);