/usr/include/CharLS/streams.h is in libcharls-dev 1.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | //
// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
//
#ifndef CHARLS_STREAMS
#define CHARLS_STREAMS
#include <memory>
#include <vector>
#include "util.h"
// This file defines JPEG-LS streams: The header and the actual pixel data. Header markers have fixed length, the pixeldata not.
class JpegSegment;
enum JPEGLS_ColorXForm
{
// default (RGB)
COLORXFORM_NONE = 0,
// Color transforms as defined by HP
COLORXFORM_HP1,
COLORXFORM_HP2,
COLORXFORM_HP3,
// Defined by HP but not supported by CharLS
COLORXFORM_RGB_AS_YUV_LOSSY,
COLORXFORM_MATRIX
};
//
// JLSOutputStream: minimal implementation to write JPEG header streams
//
class JLSOutputStream
{
friend class JpegMarkerSegment;
friend class JpegImageDataSegment;
public:
JLSOutputStream();
virtual ~JLSOutputStream();
void Init(Size size, LONG bitsPerSample, LONG ccomp);
void AddScan(const void* compareData, const JlsParameters* pparams);
void AddLSE(const JlsCustomParameters* pcustom);
void AddColorTransform(int i);
size_t GetBytesWritten()
{ return _cbyteOffset; }
size_t GetLength()
{ return _cbyteLength - _cbyteOffset; }
size_t Write(BYTE* pdata, size_t cbyteLength);
void EnableCompare(bool bCompare)
{ _bCompare = bCompare; }
private:
BYTE* GetPos() const
{ return _pdata + _cbyteOffset; }
void WriteByte(BYTE val)
{
ASSERT(!_bCompare || _pdata[_cbyteOffset] == val);
_pdata[_cbyteOffset++] = val;
}
void WriteBytes(const std::vector<BYTE>& rgbyte)
{
for (size_t i = 0; i < rgbyte.size(); ++i)
{
WriteByte(rgbyte[i]);
}
}
void WriteWord(USHORT val)
{
WriteByte(BYTE(val / 0x100));
WriteByte(BYTE(val % 0x100));
}
void Seek(size_t byteCount)
{ _cbyteOffset += byteCount; }
bool _bCompare;
private:
BYTE* _pdata;
size_t _cbyteOffset;
size_t _cbyteLength;
LONG _icompLast;
std::vector<JpegSegment*> _segments;
};
//
// JLSInputStream: minimal implementation to read JPEG header streams
//
class JLSInputStream
{
public:
JLSInputStream(const BYTE* pdata, size_t cbyteLength);
size_t GetBytesRead()
{ return _cbyteOffset; }
const JlsParameters& GetMetadata() const
{ return _info; }
const JlsCustomParameters& GetCustomPreset() const
{ return _info.custom; }
void Read(void* pvoid, size_t cbyteAvailable);
void ReadHeader();
void EnableCompare(bool bCompare)
{ _bCompare = bCompare; }
void SetInfo(JlsParameters* info) { _info = *info; }
void SetRect(JlsRect rect) { _rect = rect; }
private:
void ReadPixels(void* pvoid, size_t cbyteAvailable);
void ReadScan(void*);
void ReadStartOfScan();
void ReadPresetParameters();
void ReadComment();
void ReadStartOfFrame();
BYTE ReadByte();
int ReadWord();
void ReadNBytes(std::vector<char>& dst, int byteCount);
// JFIF
void ReadJfif();
// Color Transform Application Markers & Code Stream (HP extension)
void ReadColorSpace();
void ReadColorXForm();
private:
const BYTE* _pdata;
size_t _cbyteOffset;
size_t _cbyteLength;
bool _bCompare;
JlsParameters _info;
JlsRect _rect;
};
#endif
|