Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4917675c authored by Marco Nelissen's avatar Marco Nelissen Committed by Android (Google) Code Review
Browse files

Merge "Replace FOURCC macro with constexpr"

parents 566a7290 f9245881
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -22,8 +22,20 @@

namespace android {

#define FOURCC(c1, c2, c3, c4) \
    ((c1) << 24 | (c2) << 16 | (c3) << 8 | (c4))
constexpr int FOURCC(unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4) {
    return ((c1) << 24 | (c2) << 16 | (c3) << 8 | (c4));
}

template <size_t N>
constexpr int32_t FOURCC(const char (&s) [N]) {
    static_assert(N == 5, "fourcc: wrong length");
    return
            (unsigned char) s[0] << 24 |
            (unsigned char) s[1] << 16 |
            (unsigned char) s[2] << 8 |
            (unsigned char) s[3] << 0;
}


uint16_t U16_AT(const uint8_t *ptr);
uint32_t U32_AT(const uint8_t *ptr);