/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
// Blending with alpha mask. Mask values come from the range [0, 64], // as described for AOM_BLEND_A64 in aom_dsp/blend.h. src0 or src1 can // be the same as dst, or dst can be different from both sources.
// NOTE(rachelbarker): The input and output of aom_blend_a64_d16_mask_c() are // in a higher intermediate precision, and will later be rounded down to pixel // precision. // Thus, in order to avoid double-rounding, we want to use normal right shifts // within this function, not ROUND_POWER_OF_TWO. // This works because of the identity: // ROUND_POWER_OF_TWO(x >> y, z) == ROUND_POWER_OF_TWO(x, y+z) // // In contrast, the output of the non-d16 functions will not be further rounded, // so we *should* use ROUND_POWER_OF_TWO there.
// excerpt from clip_pixel_highbd() // set saturation_value to (1 << bd) - 1 unsignedint saturation_value; switch (bd) { case 8: default: saturation_value = 255; break; case 10: saturation_value = 1023; break; case 12: saturation_value = 4095; break;
}
if (subw == 0 && subh == 0) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {
int32_t res; constint m = mask[j];
res = ((m * src0[j] + (AOM_BLEND_A64_MAX_ALPHA - m) * src1[j]) >>
AOM_BLEND_A64_ROUND_BITS);
res -= round_offset; unsignedint v = negative_to_zero(ROUND_POWER_OF_TWO(res, round_bits));
dst[j] = AOMMIN(v, saturation_value);
}
mask += mask_stride;
src0 += src0_stride;
src1 += src1_stride;
dst += dst_stride;
}
} elseif (subw == 1 && subh == 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {
int32_t res; constint m = ROUND_POWER_OF_TWO(
mask[2 * j] + mask[mask_stride + 2 * j] + mask[2 * j + 1] +
mask[mask_stride + 2 * j + 1],
2);
res = (m * src0[j] + (AOM_BLEND_A64_MAX_ALPHA - m) * src1[j]) >>
AOM_BLEND_A64_ROUND_BITS;
res -= round_offset; unsignedint v = negative_to_zero(ROUND_POWER_OF_TWO(res, round_bits));
dst[j] = AOMMIN(v, saturation_value);
}
mask += 2 * mask_stride;
src0 += src0_stride;
src1 += src1_stride;
dst += dst_stride;
}
} elseif (subw == 1 && subh == 0) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {
int32_t res; constint m = AOM_BLEND_AVG(mask[2 * j], mask[2 * j + 1]);
res = (m * src0[j] + (AOM_BLEND_A64_MAX_ALPHA - m) * src1[j]) >>
AOM_BLEND_A64_ROUND_BITS;
res -= round_offset; unsignedint v = negative_to_zero(ROUND_POWER_OF_TWO(res, round_bits));
dst[j] = AOMMIN(v, saturation_value);
}
mask += mask_stride;
src0 += src0_stride;
src1 += src1_stride;
dst += dst_stride;
}
} else { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {
int32_t res; constint m = AOM_BLEND_AVG(mask[j], mask[mask_stride + j]);
res = (m * src0[j] + (AOM_BLEND_A64_MAX_ALPHA - m) * src1[j]) >>
AOM_BLEND_A64_ROUND_BITS;
res -= round_offset; unsignedint v = negative_to_zero(ROUND_POWER_OF_TWO(res, round_bits));
dst[j] = AOMMIN(v, saturation_value);
}
mask += 2 * mask_stride;
src0 += src0_stride;
src1 += src1_stride;
dst += dst_stride;
}
}
} #endif// CONFIG_AV1_HIGHBITDEPTH
// Blending with alpha mask. Mask values come from the range [0, 64], // as described for AOM_BLEND_A64 in aom_dsp/blend.h. src0 or src1 can // be the same as dst, or dst can be different from both sources.
void aom_blend_a64_mask_c(uint8_t *dst, uint32_t dst_stride, const uint8_t *src0, uint32_t src0_stride, const uint8_t *src1, uint32_t src1_stride, const uint8_t *mask, uint32_t mask_stride, int w, int h, int subw, int subh) { int i, j;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.