Skip to content

Commit 0c1a830

Browse files
committed
Merge branch '10bit_coding'
2 parents 6d1ffd4 + f6ef70a commit 0c1a830

File tree

4 files changed

+55
-42
lines changed

4 files changed

+55
-42
lines changed

src/image.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ unsigned uvg_image_calc_satd(const uvg_picture *pic,
504504
pic_data,
505505
pic->stride,
506506
ref_data,
507-
ref->stride) >> (UVG_BIT_DEPTH - 8);
507+
ref->stride);
508508
} else {
509509
// Extrapolate pixels from outside the frame.
510510

@@ -550,7 +550,7 @@ unsigned uvg_image_calc_satd(const uvg_picture *pic,
550550
pic_data,
551551
pic->stride,
552552
ext_origin,
553-
ext_s) >> (UVG_BIT_DEPTH - 8);
553+
ext_s);
554554

555555
return satd;
556556
}

src/strategies/avx2/dct-avx2.c

+11-18
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ extern const int16_t uvg_g_dct_32_t[32][32];
5454

5555
#if COMPILE_INTEL_AVX2
5656
#include "uvg266.h"
57-
#if UVG_BIT_DEPTH == 8
5857
#include <immintrin.h>
5958
#include "strategies/avx2/dct_avx2_tables.h"
6059
#define MAX_LOG2_TR_DYNAMIC_RANGE 15
@@ -8039,34 +8038,28 @@ static void mts_idct_avx2(
80398038
}
80408039
}
80418040

8042-
#endif // UVG_BIT_DEPTH == 8
80438041
#endif //COMPILE_INTEL_AVX2
80448042

80458043
int uvg_strategy_register_dct_avx2(void* opaque, uint8_t bitdepth)
80468044
{
80478045
bool success = true;
80488046
#if COMPILE_INTEL_AVX2
8049-
#if UVG_BIT_DEPTH == 8
8050-
if (bitdepth == 8){
8051-
//success &= uvg_strategyselector_register(opaque, "fast_forward_dst_4x4", "avx2", 40, &matrix_dst_4x4_avx2);
80528047

8053-
success &= uvg_strategyselector_register(opaque, "dct_4x4", "avx2", 40, &matrix_dct_4x4_avx2);
8054-
success &= uvg_strategyselector_register(opaque, "dct_8x8", "avx2", 40, &matrix_dct_8x8_avx2);
8055-
success &= uvg_strategyselector_register(opaque, "dct_16x16", "avx2", 40, &matrix_dct_16x16_avx2);
8056-
success &= uvg_strategyselector_register(opaque, "dct_32x32", "avx2", 40, &matrix_dct_32x32_avx2);
8048+
success &= uvg_strategyselector_register(opaque, "dct_4x4", "avx2", 40, &matrix_dct_4x4_avx2);
8049+
success &= uvg_strategyselector_register(opaque, "dct_8x8", "avx2", 40, &matrix_dct_8x8_avx2);
8050+
success &= uvg_strategyselector_register(opaque, "dct_16x16", "avx2", 40, &matrix_dct_16x16_avx2);
8051+
success &= uvg_strategyselector_register(opaque, "dct_32x32", "avx2", 40, &matrix_dct_32x32_avx2);
80578052

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

8060-
success &= uvg_strategyselector_register(opaque, "idct_4x4", "avx2", 40, &matrix_idct_4x4_avx2);
8061-
success &= uvg_strategyselector_register(opaque, "idct_8x8", "avx2", 40, &matrix_idct_8x8_avx2);
8062-
success &= uvg_strategyselector_register(opaque, "idct_16x16", "avx2", 40, &matrix_idct_16x16_avx2);
8063-
success &= uvg_strategyselector_register(opaque, "idct_32x32", "avx2", 40, &matrix_idct_32x32_avx2);
8054+
success &= uvg_strategyselector_register(opaque, "idct_4x4", "avx2", 40, &matrix_idct_4x4_avx2);
8055+
success &= uvg_strategyselector_register(opaque, "idct_8x8", "avx2", 40, &matrix_idct_8x8_avx2);
8056+
success &= uvg_strategyselector_register(opaque, "idct_16x16", "avx2", 40, &matrix_idct_16x16_avx2);
8057+
success &= uvg_strategyselector_register(opaque, "idct_32x32", "avx2", 40, &matrix_idct_32x32_avx2);
8058+
8059+
success &= uvg_strategyselector_register(opaque, "mts_dct", "avx2", 40, &mts_dct_avx2);
8060+
success &= uvg_strategyselector_register(opaque, "mts_idct", "avx2", 40, &mts_idct_avx2);
80648061

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

8068-
}
8069-
#endif // UVG_BIT_DEPTH == 8
80708063
#endif //COMPILE_INTEL_AVX2
80718064
return success;
80728065
}

src/strategies/generic/sao_shared_generics.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ static int sao_edge_ddistortion_generic(const uvg_pixel *orig_data,
6767
uint32_t a_pos = (y + a_ofs.y) * block_width + x + a_ofs.x;
6868
uint32_t b_pos = (y + b_ofs.y) * block_width + x + b_ofs.x;
6969

70-
uint8_t a = rec_data[a_pos];
71-
uint8_t b = rec_data[b_pos];
72-
uint8_t c = rec_data[c_pos];
73-
uint8_t orig = orig_data[c_pos];
70+
uvg_pixel a = rec_data[a_pos];
71+
uvg_pixel b = rec_data[b_pos];
72+
uvg_pixel c = rec_data[c_pos];
73+
uvg_pixel orig = orig_data[c_pos];
7474

7575
int32_t eo_cat = sao_calc_eo_cat(a, b, c);
7676
int32_t offset = offsets[eo_cat];

src/yuv_io.c

+38-18
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,48 @@ static void fill_after_frame(unsigned height, unsigned array_width,
5353
}
5454

5555

56-
static int read_and_fill_frame_data(FILE *file,
57-
unsigned width, unsigned height, unsigned bytes_per_sample,
58-
unsigned array_width, uvg_pixel *data)
56+
static int read_and_fill_frame_data(FILE* file,
57+
unsigned width,
58+
unsigned height,
59+
unsigned bytes_per_sample,
60+
unsigned array_width,
61+
uvg_pixel* data)
5962
{
60-
uvg_pixel* p = data;
61-
uvg_pixel* end = data + array_width * height;
62-
uvg_pixel fill_char;
63-
unsigned i;
6463

65-
while (p < end) {
66-
// Read the beginning of the line from input.
67-
if (width != fread(p, bytes_per_sample, width, file))
68-
return 0;
69-
70-
// Fill the rest with the last pixel value.
71-
fill_char = p[width - 1];
64+
unsigned i;
65+
// Handle separately the case where we use UVG_BIT_DEPTH 10+ but the input is 8-bit.
66+
if (bytes_per_sample != sizeof(uvg_pixel)) {
67+
uint8_t* p = (uint8_t*)data;
68+
uint8_t* end = (uint8_t*)data + array_width * height;
69+
uint8_t fill_char;
70+
while (p < end) {
71+
// Read the beginning of the line from input.
72+
if (width != fread(p, bytes_per_sample, width, file)) return 0;
73+
// Fill the rest with the last pixel value.
74+
fill_char = p[width - 1];
75+
76+
for (i = width; i < array_width; ++i) {
77+
p[i] = fill_char;
78+
}
7279

73-
for (i = width; i < array_width; ++i) {
74-
p[i] = fill_char;
80+
p += array_width;
7581
}
82+
} else {
83+
uvg_pixel* p = data;
84+
uvg_pixel* end = data + array_width * height;
85+
uvg_pixel fill_char;
86+
while (p < end) {
87+
// Read the beginning of the line from input.
88+
if (width != fread(p, bytes_per_sample, width, file)) return 0;
89+
// Fill the rest with the last pixel value.
90+
fill_char = p[width - 1];
91+
92+
for (i = width; i < array_width; ++i) {
93+
p[i] = fill_char;
94+
}
7695

77-
p += array_width;
96+
p += array_width;
97+
}
7898
}
7999
return 1;
80100
}
@@ -313,7 +333,7 @@ int yuv_io_seek(FILE* file, unsigned frames,
313333

314334
// Seek failed. Skip data by reading.
315335
error = 0;
316-
unsigned char* tmp[4096];
336+
unsigned char tmp[4096];
317337
size_t bytes_left = skip_bytes;
318338
while (bytes_left > 0 && !error) {
319339
const size_t skip = MIN(4096, bytes_left);

0 commit comments

Comments
 (0)