Commit 30f409db authored by Chun-Min Chang's avatar Chun-Min Chang Committed by Pier Angelo Vendrame
Browse files

[ESR 153] Bug 2050150 - Require an NV12 destination stride that can hold a...

[ESR 153] Bug 2050150 - Require an NV12 destination stride that can hold a chroma row.  a=dmeehan DONTBUILD

Differential Revision: https://phabricator.services.mozilla.com/D320550
parent ed15626e
Loading
Loading
Loading
Loading
+7 −0
Changes for dom/media/ImageConversion.cpp: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -486,6 +486,13 @@ nsresult ConvertToNV12(layers::Image* aImage, uint8_t* aDestY, int aDestStrideY,
    return NS_ERROR_INVALID_ARG;
  }

  // An interleaved chroma row is 2 * ceil(width / 2) bytes wide.
  if (aDestStrideY < aDestSize.width ||
      aDestStrideUV < 2 * CeilingOfHalf(aDestSize.width)) {
    NS_WARNING("ConvertToNV12: destination strides too small for NV12");
    return NS_ERROR_INVALID_ARG;
  }

  if (const PlanarYCbCrData* data = GetPlanarYCbCrData(aImage)) {
    const ImageUtils imageUtils(aImage);
    Maybe<dom::ImageBitmapFormat> format = imageUtils.GetFormat();
+3 −0
Changes for dom/media/ImageConversion.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@ nsresult ConvertToI420(layers::Image* aImage, uint8_t* aDestY, int aDestStrideY,

/**
 * Converts aImage to an NV12 image and writes it to the given buffers.
 *
 * aDestStrideUV must be at least 2 * ceil(aDestSize.width / 2), since U and V
 * are interleaved. Returns NS_ERROR_INVALID_ARG if either stride is too small.
 */
nsresult ConvertToNV12(layers::Image* aImage, uint8_t* aDestY, int aDestStrideY,
                       uint8_t* aDestUV, int aDestStrideUV,