Skip to content

Commit

Permalink
🎨 Create Lut::GetFactor() to get lut
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiyamou committed Mar 21, 2020
1 parent c303377 commit 70100f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions include/EWAResizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void delete_coeff_table(EWAPixelCoeff* out)
}

/* Coefficient table generation */
void generate_coeff_table_c(double* lut, EWAPixelCoeff* out, int quantize_x, int quantize_y,
void generate_coeff_table_c(Lut* func, EWAPixelCoeff* out, int quantize_x, int quantize_y,
int src_width, int src_height, int dst_width, int dst_height, double radius,
double crop_left, double crop_top, double crop_width, double crop_height)
{
Expand Down Expand Up @@ -183,9 +183,10 @@ void generate_coeff_table_c(double* lut, EWAPixelCoeff* out, int quantize_x, int
const float dx = (current_x - window_x) * filter_step_x;
const float dy = (current_y - window_y) * filter_step_y;
const float dist = dx * dx + dy * dy;
double index = round((1024 - 1) * dist / radius2) + DOUBLE_ROUND_MAGIC_NUMBER;
double index_d = round((1024 - 1) * dist / radius2) + DOUBLE_ROUND_MAGIC_NUMBER;
int index = *reinterpret_cast<int*>(&index_d);

const float factor = (float)lut[*reinterpret_cast<int*>(&index)];
const float factor = func->GetFactor(index);

tmp_array[curr_factor_ptr + lx] = factor;
divider += factor;
Expand Down
7 changes: 7 additions & 0 deletions include/Lut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Lut
void InitLut(int lut_size, double radius, double blur);
void DestroyLutTable();

float GetFactor(int index);

double* lut;

private:
Expand Down Expand Up @@ -80,4 +82,9 @@ void Lut::DestroyLutTable()
#endif
}

float Lut::GetFactor(int index)
{
return (float)lut[index];
}

#endif
6 changes: 3 additions & 3 deletions src/JincResize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void VS_CC filterCreate(const VSMap* in, VSMap* out, void* userData, VSCo
d->init_lut->InitLut(d->samples, d->radius, d->blur);
d->out_y = new EWAPixelCoeff();

generate_coeff_table_c(d->init_lut->lut, d->out_y, quantize_x, quantize_y, d->vi->width, d->vi->height,
generate_coeff_table_c(d->init_lut, d->out_y, quantize_x, quantize_y, d->vi->width, d->vi->height,
d->w, d->h, d->radius, crop_left, crop_top, crop_width, crop_height);

if (d->vi->format->numPlanes > 1)
Expand All @@ -187,9 +187,9 @@ static void VS_CC filterCreate(const VSMap* in, VSMap* out, void* userData, VSCo
double div_w = 1 << width_uv;
double div_h = 1 << height_uv;

generate_coeff_table_c(d->init_lut->lut, d->out_u, quantize_x, quantize_y, d->vi->width >> width_uv, d->vi->height >> height_uv,
generate_coeff_table_c(d->init_lut, d->out_u, quantize_x, quantize_y, d->vi->width >> width_uv, d->vi->height >> height_uv,
d->w >> width_uv, d->h >> height_uv, d->radius, crop_left / div_w, crop_top / div_h, crop_width / div_w, crop_height / div_h);
generate_coeff_table_c(d->init_lut->lut, d->out_v, quantize_x, quantize_y, d->vi->width >> width_uv, d->vi->height >> height_uv,
generate_coeff_table_c(d->init_lut, d->out_v, quantize_x, quantize_y, d->vi->width >> width_uv, d->vi->height >> height_uv,
d->w >> width_uv, d->h >> height_uv, d->radius, crop_left / div_w, crop_top / div_h, crop_width / div_w, crop_height / div_h);
}
}
Expand Down

0 comments on commit 70100f2

Please sign in to comment.