summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-03-02 01:28:03 +0000
committerCarl Hetherington <cth@carlh.net>2018-03-02 01:28:03 +0000
commitb6be1b4e51c81070ec3b00e850f010ecb78eef4d (patch)
treefe5a20890dec645c900fee537f97e5ccc23a9f26
parent2e60a7b24823b6b543f2920e0b5646fbce1ff6e7 (diff)
Fix corruption of subsampled images that are being placed into black
frames at odd offsets, using the same approach that is used when cropping. Should fix #1227.
-rw-r--r--ChangeLog4
-rw-r--r--src/lib/image.cc15
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 21492e29c..3e9e5a24b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-03-02 Carl Hetherington <cth@carlh.net>
+
+ * Fix bad Prores exports in some cases (#1227).
+
2018-02-27 Carl Hetherington <cth@carlh.net>
* Add a hint about the stereo-to-5.1 upmixers being
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 158bce1d9..792bf3ab4 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -183,8 +183,8 @@ Image::crop_scale_window (
0, 1 << 16, 1 << 16
);
- AVPixFmtDescriptor const * desc = av_pix_fmt_desc_get (_pixel_format);
- if (!desc) {
+ AVPixFmtDescriptor const * in_desc = av_pix_fmt_desc_get (_pixel_format);
+ if (!in_desc) {
throw PixelFormatError ("crop_scale_window()", _pixel_format);
}
@@ -196,16 +196,23 @@ Image::crop_scale_window (
round down so that we don't crop a subsampled pixel until
we've cropped all of its Y-channel pixels.
*/
- int const x = lrintf (bytes_per_pixel(c) * crop.left) & ~ ((int) desc->log2_chroma_w);
+ int const x = lrintf (bytes_per_pixel(c) * crop.left) & ~ ((int) in_desc->log2_chroma_w);
scale_in_data[c] = data()[c] + x + stride()[c] * (crop.top / vertical_factor(c));
}
/* Corner of the image within out_size */
Position<int> const corner ((out_size.width - inter_size.width) / 2, (out_size.height - inter_size.height) / 2);
+ AVPixFmtDescriptor const * out_desc = av_pix_fmt_desc_get (out_format);
+ if (!out_desc) {
+ throw PixelFormatError ("crop_scale_window()", out_format);
+ }
+
uint8_t* scale_out_data[out->planes()];
for (int c = 0; c < out->planes(); ++c) {
- scale_out_data[c] = out->data()[c] + lrintf (out->bytes_per_pixel(c) * corner.x) + out->stride()[c] * (corner.y / out->vertical_factor(c));
+ /* See the note in the crop loop above */
+ int const x = lrintf (out->bytes_per_pixel(c) * corner.x) & ~ ((int) out_desc->log2_chroma_w);
+ scale_out_data[c] = out->data()[c] + x + out->stride()[c] * (corner.y / out->vertical_factor(c));
}
sws_scale (