Skip to content

Commit

Permalink
Merge branch '10bit_coding'
Browse files Browse the repository at this point in the history
  • Loading branch information
fador committed Sep 6, 2024
2 parents 6d1ffd4 + f6ef70a commit 0c1a830
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ unsigned uvg_image_calc_satd(const uvg_picture *pic,
pic_data,
pic->stride,
ref_data,
ref->stride) >> (UVG_BIT_DEPTH - 8);
ref->stride);
} else {
// Extrapolate pixels from outside the frame.

Expand Down Expand Up @@ -550,7 +550,7 @@ unsigned uvg_image_calc_satd(const uvg_picture *pic,
pic_data,
pic->stride,
ext_origin,
ext_s) >> (UVG_BIT_DEPTH - 8);
ext_s);

return satd;
}
Expand Down
29 changes: 11 additions & 18 deletions src/strategies/avx2/dct-avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ extern const int16_t uvg_g_dct_32_t[32][32];

#if COMPILE_INTEL_AVX2
#include "uvg266.h"
#if UVG_BIT_DEPTH == 8
#include <immintrin.h>
#include "strategies/avx2/dct_avx2_tables.h"
#define MAX_LOG2_TR_DYNAMIC_RANGE 15
Expand Down Expand Up @@ -8039,34 +8038,28 @@ static void mts_idct_avx2(
}
}

#endif // UVG_BIT_DEPTH == 8
#endif //COMPILE_INTEL_AVX2

int uvg_strategy_register_dct_avx2(void* opaque, uint8_t bitdepth)
{
bool success = true;
#if COMPILE_INTEL_AVX2
#if UVG_BIT_DEPTH == 8
if (bitdepth == 8){
//success &= uvg_strategyselector_register(opaque, "fast_forward_dst_4x4", "avx2", 40, &matrix_dst_4x4_avx2);

success &= uvg_strategyselector_register(opaque, "dct_4x4", "avx2", 40, &matrix_dct_4x4_avx2);
success &= uvg_strategyselector_register(opaque, "dct_8x8", "avx2", 40, &matrix_dct_8x8_avx2);
success &= uvg_strategyselector_register(opaque, "dct_16x16", "avx2", 40, &matrix_dct_16x16_avx2);
success &= uvg_strategyselector_register(opaque, "dct_32x32", "avx2", 40, &matrix_dct_32x32_avx2);
success &= uvg_strategyselector_register(opaque, "dct_4x4", "avx2", 40, &matrix_dct_4x4_avx2);
success &= uvg_strategyselector_register(opaque, "dct_8x8", "avx2", 40, &matrix_dct_8x8_avx2);
success &= uvg_strategyselector_register(opaque, "dct_16x16", "avx2", 40, &matrix_dct_16x16_avx2);
success &= uvg_strategyselector_register(opaque, "dct_32x32", "avx2", 40, &matrix_dct_32x32_avx2);

// success &= uvg_strategyselector_register(opaque, "fast_inverse_dst_4x4", "avx2", 40, &matrix_idst_4x4_avx2);

success &= uvg_strategyselector_register(opaque, "idct_4x4", "avx2", 40, &matrix_idct_4x4_avx2);
success &= uvg_strategyselector_register(opaque, "idct_8x8", "avx2", 40, &matrix_idct_8x8_avx2);
success &= uvg_strategyselector_register(opaque, "idct_16x16", "avx2", 40, &matrix_idct_16x16_avx2);
success &= uvg_strategyselector_register(opaque, "idct_32x32", "avx2", 40, &matrix_idct_32x32_avx2);
success &= uvg_strategyselector_register(opaque, "idct_4x4", "avx2", 40, &matrix_idct_4x4_avx2);
success &= uvg_strategyselector_register(opaque, "idct_8x8", "avx2", 40, &matrix_idct_8x8_avx2);
success &= uvg_strategyselector_register(opaque, "idct_16x16", "avx2", 40, &matrix_idct_16x16_avx2);
success &= uvg_strategyselector_register(opaque, "idct_32x32", "avx2", 40, &matrix_idct_32x32_avx2);

success &= uvg_strategyselector_register(opaque, "mts_dct", "avx2", 40, &mts_dct_avx2);
success &= uvg_strategyselector_register(opaque, "mts_idct", "avx2", 40, &mts_idct_avx2);

success &= uvg_strategyselector_register(opaque, "mts_dct", "avx2", 40, &mts_dct_avx2);
success &= uvg_strategyselector_register(opaque, "mts_idct", "avx2", 40, &mts_idct_avx2);

}
#endif // UVG_BIT_DEPTH == 8
#endif //COMPILE_INTEL_AVX2
return success;
}
8 changes: 4 additions & 4 deletions src/strategies/generic/sao_shared_generics.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ static int sao_edge_ddistortion_generic(const uvg_pixel *orig_data,
uint32_t a_pos = (y + a_ofs.y) * block_width + x + a_ofs.x;
uint32_t b_pos = (y + b_ofs.y) * block_width + x + b_ofs.x;

uint8_t a = rec_data[a_pos];
uint8_t b = rec_data[b_pos];
uint8_t c = rec_data[c_pos];
uint8_t orig = orig_data[c_pos];
uvg_pixel a = rec_data[a_pos];
uvg_pixel b = rec_data[b_pos];
uvg_pixel c = rec_data[c_pos];
uvg_pixel orig = orig_data[c_pos];

int32_t eo_cat = sao_calc_eo_cat(a, b, c);
int32_t offset = offsets[eo_cat];
Expand Down
56 changes: 38 additions & 18 deletions src/yuv_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,48 @@ static void fill_after_frame(unsigned height, unsigned array_width,
}


static int read_and_fill_frame_data(FILE *file,
unsigned width, unsigned height, unsigned bytes_per_sample,
unsigned array_width, uvg_pixel *data)
static int read_and_fill_frame_data(FILE* file,
unsigned width,
unsigned height,
unsigned bytes_per_sample,
unsigned array_width,
uvg_pixel* data)
{
uvg_pixel* p = data;
uvg_pixel* end = data + array_width * height;
uvg_pixel fill_char;
unsigned i;

while (p < end) {
// Read the beginning of the line from input.
if (width != fread(p, bytes_per_sample, width, file))
return 0;

// Fill the rest with the last pixel value.
fill_char = p[width - 1];
unsigned i;
// Handle separately the case where we use UVG_BIT_DEPTH 10+ but the input is 8-bit.
if (bytes_per_sample != sizeof(uvg_pixel)) {
uint8_t* p = (uint8_t*)data;
uint8_t* end = (uint8_t*)data + array_width * height;
uint8_t fill_char;
while (p < end) {
// Read the beginning of the line from input.
if (width != fread(p, bytes_per_sample, width, file)) return 0;
// Fill the rest with the last pixel value.
fill_char = p[width - 1];

for (i = width; i < array_width; ++i) {
p[i] = fill_char;
}

for (i = width; i < array_width; ++i) {
p[i] = fill_char;
p += array_width;
}
} else {
uvg_pixel* p = data;
uvg_pixel* end = data + array_width * height;
uvg_pixel fill_char;
while (p < end) {
// Read the beginning of the line from input.
if (width != fread(p, bytes_per_sample, width, file)) return 0;
// Fill the rest with the last pixel value.
fill_char = p[width - 1];

for (i = width; i < array_width; ++i) {
p[i] = fill_char;
}

p += array_width;
p += array_width;
}
}
return 1;
}
Expand Down Expand Up @@ -313,7 +333,7 @@ int yuv_io_seek(FILE* file, unsigned frames,

// Seek failed. Skip data by reading.
error = 0;
unsigned char* tmp[4096];
unsigned char tmp[4096];
size_t bytes_left = skip_bytes;
while (bytes_left > 0 && !error) {
const size_t skip = MIN(4096, bytes_left);
Expand Down

0 comments on commit 0c1a830

Please sign in to comment.