Merge branch '10bit_coding'

This commit is contained in:
Marko Viitanen 2024-09-06 11:24:05 +03:00
commit 0c1a830dc1
4 changed files with 54 additions and 41 deletions

View file

@ -504,7 +504,7 @@ unsigned uvg_image_calc_satd(const uvg_picture *pic,
pic_data, pic_data,
pic->stride, pic->stride,
ref_data, ref_data,
ref->stride) >> (UVG_BIT_DEPTH - 8); ref->stride);
} else { } else {
// Extrapolate pixels from outside the frame. // Extrapolate pixels from outside the frame.
@ -550,7 +550,7 @@ unsigned uvg_image_calc_satd(const uvg_picture *pic,
pic_data, pic_data,
pic->stride, pic->stride,
ext_origin, ext_origin,
ext_s) >> (UVG_BIT_DEPTH - 8); ext_s);
return satd; return satd;
} }

View file

@ -54,7 +54,6 @@ extern const int16_t uvg_g_dct_32_t[32][32];
#if COMPILE_INTEL_AVX2 #if COMPILE_INTEL_AVX2
#include "uvg266.h" #include "uvg266.h"
#if UVG_BIT_DEPTH == 8
#include <immintrin.h> #include <immintrin.h>
#include "strategies/avx2/dct_avx2_tables.h" #include "strategies/avx2/dct_avx2_tables.h"
#define MAX_LOG2_TR_DYNAMIC_RANGE 15 #define MAX_LOG2_TR_DYNAMIC_RANGE 15
@ -8039,23 +8038,18 @@ static void mts_idct_avx2(
} }
} }
#endif // UVG_BIT_DEPTH == 8
#endif //COMPILE_INTEL_AVX2 #endif //COMPILE_INTEL_AVX2
int uvg_strategy_register_dct_avx2(void* opaque, uint8_t bitdepth) int uvg_strategy_register_dct_avx2(void* opaque, uint8_t bitdepth)
{ {
bool success = true; bool success = true;
#if COMPILE_INTEL_AVX2 #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_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_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_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_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_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_8x8", "avx2", 40, &matrix_idct_8x8_avx2);
@ -8065,8 +8059,7 @@ int uvg_strategy_register_dct_avx2(void* opaque, uint8_t bitdepth)
success &= uvg_strategyselector_register(opaque, "mts_dct", "avx2", 40, &mts_dct_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_idct", "avx2", 40, &mts_idct_avx2);
}
#endif // UVG_BIT_DEPTH == 8
#endif //COMPILE_INTEL_AVX2 #endif //COMPILE_INTEL_AVX2
return success; return success;
} }

View file

@ -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 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; uint32_t b_pos = (y + b_ofs.y) * block_width + x + b_ofs.x;
uint8_t a = rec_data[a_pos]; uvg_pixel a = rec_data[a_pos];
uint8_t b = rec_data[b_pos]; uvg_pixel b = rec_data[b_pos];
uint8_t c = rec_data[c_pos]; uvg_pixel c = rec_data[c_pos];
uint8_t orig = orig_data[c_pos]; uvg_pixel orig = orig_data[c_pos];
int32_t eo_cat = sao_calc_eo_cat(a, b, c); int32_t eo_cat = sao_calc_eo_cat(a, b, c);
int32_t offset = offsets[eo_cat]; int32_t offset = offsets[eo_cat];

View file

@ -53,20 +53,23 @@ static void fill_after_frame(unsigned height, unsigned array_width,
} }
static int read_and_fill_frame_data(FILE *file, static int read_and_fill_frame_data(FILE* file,
unsigned width, unsigned height, unsigned bytes_per_sample, unsigned width,
unsigned array_width, uvg_pixel *data) 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;
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) { while (p < end) {
// Read the beginning of the line from input. // Read the beginning of the line from input.
if (width != fread(p, bytes_per_sample, width, file)) if (width != fread(p, bytes_per_sample, width, file)) return 0;
return 0;
// Fill the rest with the last pixel value. // Fill the rest with the last pixel value.
fill_char = p[width - 1]; fill_char = p[width - 1];
@ -76,6 +79,23 @@ static int read_and_fill_frame_data(FILE *file,
p += array_width; 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;
}
}
return 1; return 1;
} }
@ -313,7 +333,7 @@ int yuv_io_seek(FILE* file, unsigned frames,
// Seek failed. Skip data by reading. // Seek failed. Skip data by reading.
error = 0; error = 0;
unsigned char* tmp[4096]; unsigned char tmp[4096];
size_t bytes_left = skip_bytes; size_t bytes_left = skip_bytes;
while (bytes_left > 0 && !error) { while (bytes_left > 0 && !error) {
const size_t skip = MIN(4096, bytes_left); const size_t skip = MIN(4096, bytes_left);