Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/src/gainmapmath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ Color getP010Pixel(uhdr_raw_image_t* image, size_t x, size_t y) {
size_t chroma_stride = image->stride[UHDR_PLANE_UV];

size_t pixel_y_idx = y * luma_stride + x;
size_t pixel_u_idx = (y >> 1) * chroma_stride + (x & ~0x1);
size_t chroma_x = x & ~(size_t)0x1;
if (chroma_x + 1 >= image->w) {
chroma_x = (image->w >= 2) ? ((image->w - 2) & ~(size_t)0x1) : 0;
}
size_t pixel_u_idx = (y >> 1) * chroma_stride + chroma_x;
size_t pixel_v_idx = pixel_u_idx + 1;

uint16_t y_uint = luma_data[pixel_y_idx] >> 6;
Expand Down Expand Up @@ -1317,8 +1321,8 @@ std::unique_ptr<uhdr_raw_image_ext_t> convert_raw_input_to_ycbcr(uhdr_raw_image_
uint16_t* uData = static_cast<uint16_t*>(dst->planes[UHDR_PLANE_UV]);
uint16_t* vData = uData + 1;

for (size_t i = 0; i < dst->h; i += 2) {
for (size_t j = 0; j < dst->w; j += 2) {
for (size_t i = 0; i + 1 < dst->h; i += 2) {
for (size_t j = 0; j + 1 < dst->w; j += 2) {
Color pixel[4];

pixel[0].r = float(rgbData[srcStride * i + j] & 0x3ff);
Expand Down Expand Up @@ -1410,8 +1414,8 @@ std::unique_ptr<uhdr_raw_image_ext_t> convert_raw_input_to_ycbcr(uhdr_raw_image_
uint8_t* yData = static_cast<uint8_t*>(dst->planes[UHDR_PLANE_Y]);
uint8_t* uData = static_cast<uint8_t*>(dst->planes[UHDR_PLANE_U]);
uint8_t* vData = static_cast<uint8_t*>(dst->planes[UHDR_PLANE_V]);
for (size_t i = 0; i < dst->h; i += 2) {
for (size_t j = 0; j < dst->w; j += 2) {
for (size_t i = 0; i + 1 < dst->h; i += 2) {
for (size_t j = 0; j + 1 < dst->w; j += 2) {
Color pixel[4];

pixel[0] = getPixel(src, j, i);
Expand Down
Loading