StreamError stream_read_int32(stream_dt *stream, int32_t *to, bool swap) { StreamError err; err = stream_read(stream, to, sizeof(*to)); if (swap) *to = _swap32(*to); return err; }
void Video::swapBuffers() { assert(win); switch (win->format->BitsPerPixel) { case 16: _swap16(); break; case 32: _swap32(); break; } }
void FLACDecoder::writeBuffer(FLAC__int32 x, int bps) { if (bps == 8) { unsigned char v = (unsigned char) x; data.push_back(v * this->getConv() - 1.0); } else if (bps == 16) { short v = (short) x; data.push_back(_swap16(v) * this->getConv()); } else if (bps == 24) { int v = (int) x; data.push_back(_swap32(v) * this->getConv()); } else { throw std::runtime_error(std::string("FLACDecoder error: Unsupported bit depth of ") + std::to_string(bps)); } }
StreamError stream_write_int32(stream_dt *stream, const int32_t from, bool swap) { int32_t from_endian = swap ? _swap32(from) : from; return stream_write(stream, &from_endian, sizeof(from)); }