mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
[10bit] Fix reading 8bit data when using BIT_DEPTH 10+ and we need to fill the frame
This commit is contained in:
parent
e06d980a96
commit
67496d1874
53
src/yuv_io.c
53
src/yuv_io.c
|
@ -53,28 +53,49 @@ 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(
|
||||||
unsigned width, unsigned height, unsigned bytes_per_sample,
|
FILE* file,
|
||||||
unsigned array_width, uvg_pixel *data)
|
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) {
|
unsigned i;
|
||||||
// Read the beginning of the line from input.
|
if (bytes_per_sample != sizeof(uvg_pixel)) {
|
||||||
if (width != fread(p, bytes_per_sample, width, file))
|
uint8_t* p = (uint8_t*)data;
|
||||||
return 0;
|
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 the rest with the last pixel value.
|
||||||
|
fill_char = p[width - 1];
|
||||||
|
|
||||||
// Fill the rest with the last pixel value.
|
for (i = width; i < array_width; ++i) {
|
||||||
fill_char = p[width - 1];
|
p[i] = fill_char;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = width; i < array_width; ++i) {
|
p += array_width;
|
||||||
p[i] = fill_char;
|
|
||||||
}
|
}
|
||||||
|
} 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];
|
||||||
|
|
||||||
p += array_width;
|
for (i = width; i < array_width; ++i) {
|
||||||
|
p[i] = fill_char;
|
||||||
|
}
|
||||||
|
|
||||||
|
p += array_width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue