Support auto-crop for YUV422P10LE.
[dcpomatic.git] / src / lib / guess_crop.cc
index 5deb0e480bc1f7520a8812658a6eca9fa1761168..3538f14dee4356ebec6bb52aa8e59b9862c7cb41 100644 (file)
@@ -61,8 +61,18 @@ guess_crop (shared_ptr<const Image> image, double threshold)
                        }
                        break;
                }
+               case AV_PIX_FMT_YUV422P10LE:
+               {
+                       uint16_t const* data = reinterpret_cast<uint16_t*>(image->data()[0] + (start_x * 2) + (start_y * image->stride()[0]));
+                       for (int p = 0; p < pixels; ++p) {
+                               /* Just using Y */
+                               brightest = std::max(brightest, static_cast<double>(*data) / 1024);
+                               data += rows ? 1 : (image->stride()[0] / 2);
+                       }
+                       break;
+               }
                default:
-                       DCPOMATIC_ASSERT (false);
+                       throw PixelFormatError("guess_crop()", image->pixel_format());
                }
 
                return brightest > threshold;