/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef HAVE_NETINET_IN_H # include <netinet/in.h> #elifdefined XP_WIN # include <winsock2.h> #endif #include <string.h>
inline uint32_t YuvStamper::Capacity() { // Enforce at least a symbol width and height offset from outer edges. if (mCursor.y + mSymbolHeight > mHeight) { return 0;
}
// Normalize frame integral to mSymbolWidth x mSymbolHeight
uint32_t width = mWidth / mSymbolWidth;
uint32_t height = mHeight / mSymbolHeight;
uint32_t x = mCursor.x / mSymbolWidth;
uint32_t y = mCursor.y / mSymbolHeight;
return (width * height - width * y) - x;
}
bool YuvStamper::Write8(unsignedchar value) { // Encode MSB to LSB. unsignedchar mask = 0x80; while (mask) { if (!WriteBit(!!(value & mask))) { returnfalse;
}
mask >>= 1;
} returntrue;
}
bool YuvStamper::WriteBit(bool one) { // A bit is mapped to a mSymbolWidth x mSymbolHeight square of luma data // points. Don't use ternary op.: // https://bugzilla.mozilla.org/show_bug.cgi?id=1001708 unsignedchar value; if (one)
value = sYOn; else
value = sYOff;
for (uint32_t y = 0; y < mSymbolHeight; y++) { for (uint32_t x = 0; x < mSymbolWidth; x++) {
*(pYData + (mCursor.x + x) + ((mCursor.y + y) * mStride)) = value;
}
}
return AdvanceCursor();
}
bool YuvStamper::AdvanceCursor() {
mCursor.x += mSymbolWidth; if (mCursor.x + mSymbolWidth > mWidth) { // move to the start of the next row if possible.
mCursor.y += mSymbolHeight; if (mCursor.y + mSymbolHeight > mHeight) { // end of frame, do not advance
mCursor.y -= mSymbolHeight;
mCursor.x -= mSymbolWidth; returnfalse;
} else {
mCursor.x = 0;
}
}
¤ 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.0.13Bemerkung:
(vorverarbeitet)
¤
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.