Fix corruption of subsampled images that are being placed into black
authorCarl Hetherington <cth@carlh.net>
Fri, 2 Mar 2018 01:28:03 +0000 (01:28 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 2 Mar 2018 01:35:16 +0000 (01:35 +0000)
frames at odd offsets, using the same approach that is used when
cropping.  Should fix #1227.

ChangeLog
src/lib/image.cc
test/data

index cb7e83f9e1147c0fde879bbe0e606b101ba3d085..51354dc69256e606f05942b2b0e8ba8052127308 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-2018-02-28  Carl Hetherington  <cth@carlh.net>
+2018-03-02  Carl Hetherington  <cth@carlh.net>
+
+       * Fix bad Prores exports in some cases (#1227).
+
+2018-02-27  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.11.68 released.
 
index 158bce1d901aab1b7ff3de884ce8b090bb035805..792bf3ab469c2ffd363b81de850a0bedb8fe98c6 100644 (file)
@@ -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 (
index 22ba7b14571926f6c3fd860df57ad2146d9ba404..a6e0009c6e762d3bd27ebc6499b6e30fc4baea01 160000 (submodule)
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit 22ba7b14571926f6c3fd860df57ad2146d9ba404
+Subproject commit a6e0009c6e762d3bd27ebc6499b6e30fc4baea01