Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <cassert>
#include <cstdlib>
#include <cstring>
using ushort16 = unsigned short;
class PentaxDecompressor {
enum class ThreadingModel {
// no threading whatsoever, need to do everything right here and now.
NoThreading = 0,
// threaded. only do the preparatory work that has to be done sequentially
MainThread = 1,
// threaded. runs strictly after MainThread. finishes decoding parallelized
SlaveThread = 2,
};
template <ThreadingModel TM>
void decompressInternal(ushort16* dest) const{
int pred[2];
dest[0] = pred[0] = dest[0] + dest[0];
dest[1] = pred[1] = dest[1] + dest[1];
assert(dest[0] == pred[0]);
assert(dest[1] == pred[1]);
};
public:
void decompress() const {
ushort16* dest = (ushort16*)malloc(128*sizeof(ushort16));
// memset(dest, 0, 128*sizeof(ushort16));
decompressInternal<ThreadingModel::SlaveThread>(dest);
};
};
int main () {
PentaxDecompressor p;
p.decompress();
return 0;
}
@LebedevRI
Copy link
Author

LebedevRI commented Aug 10, 2017

$ clang++ rawspeed.cpp -std=c++11
$ ./a.out 
a.out: rawspeed.cpp:26: void PentaxDecompressor::decompressInternal(ushort16 *) const [TM = PentaxDecompressor::ThreadingModel::SlaveThread]: Assertion `dest[0] == pred[0]' failed.
Aborted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment