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
41
src/yuv_io.c
41
src/yuv_io.c
|
@ -53,20 +53,24 @@ 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;
|
||||
|
||||
unsigned i;
|
||||
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;
|
||||
|
||||
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];
|
||||
|
||||
|
@ -76,6 +80,23 @@ static int read_and_fill_frame_data(FILE *file,
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue