diff options
author | trav90 <travawine@palemoon.org> | 2018-10-18 19:47:53 -0500 |
---|---|---|
committer | trav90 <travawine@palemoon.org> | 2018-10-18 19:47:53 -0500 |
commit | 0c98b71659b728d80231af7c33214e03114f9a62 (patch) | |
tree | 627a0292646011b8208f40f92331a6271f77e7b8 /dom | |
parent | 4653be96093a65e8db08e29e10e13029fea861e7 (diff) | |
download | UXP-0c98b71659b728d80231af7c33214e03114f9a62.tar UXP-0c98b71659b728d80231af7c33214e03114f9a62.tar.gz UXP-0c98b71659b728d80231af7c33214e03114f9a62.tar.lz UXP-0c98b71659b728d80231af7c33214e03114f9a62.tar.xz UXP-0c98b71659b728d80231af7c33214e03114f9a62.zip |
[aom] Don't resample 8-bit images
The libaom av1 decoder will return 16 bit per channel aom_image_t structures with only 8 significant bits.
Detect this case and use the mSkip fields of PlanarYCbCrImage to handle the extra data instead of allocating and performing an extra copy to obtain the necessary 8 bit representation.
Diffstat (limited to 'dom')
-rw-r--r-- | dom/media/platforms/agnostic/AOMDecoder.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/dom/media/platforms/agnostic/AOMDecoder.cpp b/dom/media/platforms/agnostic/AOMDecoder.cpp index c2b62eaa4..1571fe352 100644 --- a/dom/media/platforms/agnostic/AOMDecoder.cpp +++ b/dom/media/platforms/agnostic/AOMDecoder.cpp @@ -161,8 +161,10 @@ AOMDecoder::DoDecode(MediaRawData* aSample) UniquePtr<aom_image_t, AomImageFree> img8; while ((img = aom_codec_get_frame(&mCodec, &iter))) { - if (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) { - // Downsample images with more than 8 bits per channel. + // Track whether the underlying buffer is 8 or 16 bits per channel. + bool highbd = bool(img->fmt & AOM_IMG_FMT_HIGHBITDEPTH); + if (img->bit_depth > 8) { + // Downsample images with more than 8 significant bits per channel. aom_img_fmt_t fmt8 = static_cast<aom_img_fmt_t>(img->fmt ^ AOM_IMG_FMT_HIGHBITDEPTH); img8.reset(aom_img_alloc(NULL, fmt8, img->d_w, img->d_h, 16)); if (img8 == nullptr) { @@ -183,10 +185,13 @@ AOMDecoder::DoDecode(MediaRawData* aSample) // Since img is assigned at the start of the while loop and img8 is held // outside that loop, the alias won't outlive the storage it points to. img = img8.get(); + highbd = false; } NS_ASSERTION(img->fmt == AOM_IMG_FMT_I420 || - img->fmt == AOM_IMG_FMT_I444, + img->fmt == AOM_IMG_FMT_I42016 || + img->fmt == AOM_IMG_FMT_I444 || + img->fmt == AOM_IMG_FMT_I44416, "AV1 image format not I420 or I444"); // Chroma shifts are rounded down as per the decoding examples in the SDK @@ -195,17 +200,21 @@ AOMDecoder::DoDecode(MediaRawData* aSample) b.mPlanes[0].mStride = img->stride[0]; b.mPlanes[0].mHeight = img->d_h; b.mPlanes[0].mWidth = img->d_w; - b.mPlanes[0].mOffset = b.mPlanes[0].mSkip = 0; + b.mPlanes[0].mOffset = 0; + b.mPlanes[0].mSkip = highbd ? 1 : 0; b.mPlanes[1].mData = img->planes[1]; b.mPlanes[1].mStride = img->stride[1]; - b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0; + b.mPlanes[1].mOffset = 0; + b.mPlanes[1].mSkip = highbd ? 1 : 0; b.mPlanes[2].mData = img->planes[2]; b.mPlanes[2].mStride = img->stride[2]; - b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0; + b.mPlanes[2].mOffset = 0; + b.mPlanes[2].mSkip = highbd ? 1 : 0; - if (img->fmt == AOM_IMG_FMT_I420) { + if (img->fmt == AOM_IMG_FMT_I420 || + img->fmt == AOM_IMG_FMT_I42016) { b.mPlanes[1].mHeight = (img->d_h + 1) >> img->y_chroma_shift; b.mPlanes[1].mWidth = (img->d_w + 1) >> img->x_chroma_shift; |