Skip to content

Instantly share code, notes, and snippets.

@LebedevRI
Created August 10, 2017 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LebedevRI/429a410ea5f19e2abb0b77bd0710b9bd to your computer and use it in GitHub Desktop.
Save LebedevRI/429a410ea5f19e2abb0b77bd0710b9bd to your computer and use it in GitHub Desktop.
#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

$ 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