Esempio n. 1
0
StreamError stream_read_int16(stream_dt *stream, int16_t *to, bool swap)
{
    StreamError err;
    err = stream_read(stream, to, sizeof(*to));
    if (swap)
        *to = _swap16(*to);
    return err;
}
Esempio n. 2
0
void Video::swapBuffers()
{
    assert(win);
    switch (win->format->BitsPerPixel)
    {
    case 16:
        _swap16();
        break;
    case 32:
        _swap32();
        break;
    }
}
Esempio n. 3
0
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));
    }
}
Esempio n. 4
0
StreamError stream_write_int16(stream_dt *stream, const int16_t from, bool swap)
{
    int16_t from_endian = swap ? _swap16(from) : from;
    return stream_write(stream, &from_endian, sizeof(from));
}