X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage.cc;h=9aecac8347a40bbbd0e7e4ff5a7fd2f85e608908;hb=ff639b3cf30afcc097bfd21d39c8d15f466cadd6;hp=7b95e67669ae8ca73ba46bab0aaf8bd7a55a1525;hpb=58d89ba0632d94504b15dc10cb4e4153808f8efe;p=dcpomatic.git diff --git a/src/lib/image.cc b/src/lib/image.cc index 7b95e6766..9aecac834 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -292,13 +292,17 @@ Image::crop_scale_window ( sws_freeContext (scale_context); - if (corrected_crop != Crop() && cropped_size == inter_size) { - /* We are cropping without any scaling or pixel format conversion, so FFmpeg may have left some - data behind in our image. Clear it out. It may get to the point where we should just stop - trying to be clever with cropping. - */ - out->make_part_black (corner.x + cropped_size.width, out_size.width - cropped_size.width); - } + /* There are some cases where there will be unwanted image data left in the image at this point: + * + * 1. When we are cropping without any scaling or pixel format conversion. + * 2. When we are scaling to certain sizes and placing the result into a larger + * black frame. + * + * Clear out the sides of the image to take care of those cases. + */ + auto const pad = (out_size.width - inter_size.width) / 2; + out->make_part_black(0, pad); + out->make_part_black(corner.x + inter_size.width, pad); if ( video_range == VideoRange::VIDEO && @@ -474,6 +478,21 @@ Image::make_part_black (int const start, int const width) } break; } + case AV_PIX_FMT_YUV444P10LE: + { + y_part(); + for (int i = 1; i < 3; ++i) { + auto p = reinterpret_cast(data()[i]); + int const h = sample_size(i).height; + for (int y = 0; y < h; ++y) { + for (int x = start; x < (start + width); ++x) { + p[x] = ten_bit_uv; + } + p += stride()[i] / 2; + } + } + break; + } default: throw PixelFormatError ("make_part_black()", _pixel_format); } @@ -730,14 +749,14 @@ Image::alpha_blend (shared_ptr other, Position position) double const b = lut_in[op[blue]]; /* RGB to XYZ, including Bradford transform and DCI companding */ - double const x = max (0.0, min (65535.0, r * fast_matrix[0] + g * fast_matrix[1] + b * fast_matrix[2])); - double const y = max (0.0, min (65535.0, r * fast_matrix[3] + g * fast_matrix[4] + b * fast_matrix[5])); - double const z = max (0.0, min (65535.0, r * fast_matrix[6] + g * fast_matrix[7] + b * fast_matrix[8])); + double const x = max(0.0, min(1.0, r * fast_matrix[0] + g * fast_matrix[1] + b * fast_matrix[2])); + double const y = max(0.0, min(1.0, r * fast_matrix[3] + g * fast_matrix[4] + b * fast_matrix[5])); + double const z = max(0.0, min(1.0, r * fast_matrix[6] + g * fast_matrix[7] + b * fast_matrix[8])); /* Out gamma LUT and blend */ - tp[0] = lrint(lut_out[lrint(x)] * 65535) * alpha + tp[0] * (1 - alpha); - tp[1] = lrint(lut_out[lrint(y)] * 65535) * alpha + tp[1] * (1 - alpha); - tp[2] = lrint(lut_out[lrint(z)] * 65535) * alpha + tp[2] * (1 - alpha); + tp[0] = lrint(lut_out[lrint(x * 65535)] * 65535) * alpha + tp[0] * (1 - alpha); + tp[1] = lrint(lut_out[lrint(y * 65535)] * 65535) * alpha + tp[1] * (1 - alpha); + tp[2] = lrint(lut_out[lrint(z * 65535)] * 65535) * alpha + tp[2] * (1 - alpha); tp += this_bpp / 2; op += other_bpp;