31 #define TOP  0x01000000 
   73     rc->
code  = bytestream2_get_be32(gb);
 
   80     for (comp = 0; comp < 3; comp++) {
 
   81         for (j = 0; j < 4096; j++) {
 
   83                 for (i = 0; i < 256; i++)
 
   85                 for (i = 0; i < 16; i++)
 
   92     for (j = 0; j < 6; j++) {
 
   94         for (i = 0; i < 256; i++)
 
   99     for (j = 0; j < 6; j++) {
 
  101         for (i = 0; i < 6; i++)
 
  106     for (i = 0; i < 256; i++) {
 
  113     for (i = 0; i < 5; i++) {
 
  118     for (j = 0; j < 4; j++) {
 
  119         for (i = 0; i < 16; i++) {
 
  125     for (i = 0; i < 512; i++) {
 
  139         unsigned byte = bytestream2_get_byte(gb);
 
  169     t = rc->
range * (uint64_t)cumFreq / total_freq;
 
  172     rc->
range = rc->
range * (uint64_t)(freq + cumFreq) / total_freq - (t + 1);
 
  175         unsigned byte = bytestream2_get_byte(gb);
 
  189     *freq = total_freq * (uint64_t)(rc->
code - rc->
code1) / rc->
range;
 
  198     unsigned totfr = cnt[maxc];
 
  200     unsigned c = 0, cumfr = 0, cnt_c = 0;
 
  203     if ((ret = s->
get_freq(rc, totfr, &value)) < 0)
 
  208         if (value >= cumfr + cnt_c)
 
  214     if ((ret = s->
decode(gb, rc, cumfr, cnt_c, totfr)) < 0)
 
  217     cnt[
c] = cnt_c + step;
 
  221         for (i = 0; i < maxc; i++) {
 
  222             unsigned nc = (cnt[i] >> 1) + 1;
 
  239     unsigned value, x = 0, cumfr = 0, cnt_x = 0;
 
  240     int i, j, ret, 
c, cnt_c;
 
  242     if ((ret = s->
get_freq(rc, totfr, &value)) < 0)
 
  247         if (value >= cumfr + cnt_x)
 
  257         cnt_c = pixel->
freq[
c];
 
  258         if (value >= cumfr + cnt_c)
 
  264     if (x >= 16 || c >= 256) {
 
  268     if ((ret = s->
decode(gb, rc, cumfr, cnt_c, totfr)) < 0)
 
  271     pixel->
freq[
c] = cnt_c + step;
 
  272     pixel->
lookup[x] = cnt_x + step;
 
  276         for (i = 0; i < 256; i++) {
 
  277             unsigned nc = (pixel->
freq[i] >> 1) + 1;
 
  281         for (i = 0; i < 16; i++) {
 
  283             unsigned i16_17 = i << 4;
 
  284             for (j = 0; j < 16; j++)
 
  285                 sum += pixel->
freq[i16_17 + j];
 
  291     *rval = c & s->
cbits;
 
  300     int cx = 0, cx1 = 0, k = 0, clr = 0;
 
  301     int run, 
r, 
g, 
b, off, y = 0, x = 0, z, ret;
 
  302     unsigned backstep = linesize - avctx->
width;
 
  303     const int cxshift = s->
cxshift;
 
  304     unsigned lx, ly, ptype;
 
  310     while (k < avctx->
width + 1) {
 
  315         cx1 = (cx << 6) & 0xFC0;
 
  321         cx1 = (cx << 6) & 0xFC0;
 
  327         cx1 = (cx << 6) & 0xFC0;
 
  334         clr = (b << 16) + (g << 8) + 
r;
 
  340             dst[y * linesize + x] = clr;
 
  344             if (x >= avctx->
width) {
 
  362             cx1 = (cx << 6) & 0xFC0;
 
  368             cx1 = (cx << 6) & 0xFC0;
 
  374             clr = (b << 16) + (g << 8) + 
r;
 
  388                 dst[y * linesize + x] = clr;
 
  392                 if (x >= avctx->
width) {
 
  403                 dst[y * linesize + x] = dst[ly * linesize + lx];
 
  407                 if (x >= avctx->
width) {
 
  412             clr = dst[ly * linesize + lx];
 
  416                 if (y < 1 || y >= avctx->
height)
 
  419                 clr = dst[y * linesize + x + off + 1];
 
  420                 dst[y * linesize + x] = clr;
 
  424                 if (x >= avctx->
width) {
 
  434                 if (y < 1 || y >= avctx->
height ||
 
  444                 r = odst[(ly * linesize + lx) * 4] +
 
  445                     odst[((y * linesize + x) + off - z) * 4 + 4] -
 
  446                     odst[((y * linesize + x) + off - z) * 4];
 
  447                 g = odst[(ly * linesize + lx) * 4 + 1] +
 
  448                     odst[((y * linesize + x) + off - z) * 4 + 5] -
 
  449                     odst[((y * linesize + x) + off - z) * 4 + 1];
 
  450                 b = odst[(ly * linesize + lx) * 4 + 2] +
 
  451                     odst[((y * linesize + x) + off - z) * 4 + 6] -
 
  452                     odst[((y * linesize + x) + off - z) * 4 + 2];
 
  453                 clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);
 
  454                 dst[y * linesize + x] = clr;
 
  458                 if (x >= avctx->
width) {
 
  466                 if (y < 1 || y >= avctx->
height ||
 
  476                 clr = dst[y * linesize + x + off - z];
 
  477                 dst[y * linesize + x] = clr;
 
  481                 if (x >= avctx->
width) {
 
  490             cx1 = (clr & 0x3F00) >> 2;
 
  491             cx = (clr & 0x3FFFFF) >> 16;
 
  493             cx1 = (clr & 0xFC00) >> 4;
 
  494             cx = (clr & 0xFFFFFF) >> 18;
 
  502                         uint32_t *dst, 
int linesize,
 
  503                         uint32_t *prev, 
int plinesize)
 
  507     int ret, 
temp, 
min, max, x, y, cx = 0, cx1 = 0;
 
  508     int backstep = linesize - avctx->
width;
 
  509     const int cxshift = s->
cxshift;
 
  511     if (bytestream2_get_byte(gb) == 0)
 
  535         while (min < s->nbcount && count-- > 0) {
 
  540     for (y = 0; y < s->
nby; y++) {
 
  541         for (x = 0; x < s->
nbx; x++) {
 
  542             int sy1 = 0, sy2 = 16, sx1 = 0, sx2 = 16;
 
  547             if (((s->
blocks[y * s->
nbx + x] - 1) & 1) > 0) {
 
  558             if (((s->
blocks[y * s->
nbx + x] - 1) & 2) > 0) {
 
  559                 int i, j, by = y * 16, bx = x * 16;
 
  570                 if (by + mvy + sy1 < 0 || bx + mvx + sx1 < 0 ||
 
  571                     by + mvy + sy1 >= avctx->
height || bx + mvx + sx1 >= avctx->
width)
 
  574                 for (i = 0; i < sy2 - sy1 && (by + sy1 + i) < avctx->
height && (by + mvy + sy1 + i) < avctx->
height; i++) {
 
  575                     for (j = 0; j < sx2 - sx1 && (bx + sx1 + j) < avctx->
width && (bx + mvx + sx1 + j) < avctx->
width; j++) {
 
  576                         dst[(by + i + sy1) * linesize + bx + sx1 + j] = prev[(by + mvy + sy1 + i) * plinesize + bx + sx1 + mvx + j];
 
  580                 int run, 
r, 
g, 
b, z, bx = x * 16 + sx1, by = y * 16 + sy1;
 
  581                 unsigned clr, ptype = 0;
 
  583                 for (; by < y * 16 + sy2 && by < avctx->
height;) {
 
  592                         cx1 = (cx << 6) & 0xFC0;
 
  598                         cx1 = (cx << 6) & 0xFC0;
 
  604                         clr = (b << 16) + (g << 8) + 
r;
 
  618                             dst[by * linesize + bx] = clr;
 
  620                             if (bx >= x * 16 + sx2 || bx >= avctx->
width) {
 
  639                             clr = dst[by * linesize + bx - 1 - z];
 
  640                             dst[by * linesize + bx] = clr;
 
  642                             if (bx >= x * 16 + sx2 || bx >= avctx->
width) {
 
  650                             if (by < 1 || by >= avctx->
height)
 
  653                             clr = dst[(by - 1) * linesize + bx];
 
  654                             dst[by * linesize + bx] = clr;
 
  656                             if (bx >= x * 16 + sx2 || bx >= avctx->
width) {
 
  667                             clr = prev[by * plinesize + bx];
 
  668                             dst[by * linesize + bx] = clr;
 
  670                             if (bx >= x * 16 + sx2 || bx >= avctx->
width) {
 
  680                             if (by < 1 || by >= avctx->
height)
 
  689                             r = odst[((by - 1) * linesize + bx) * 4] +
 
  690                                 odst[(by * linesize + bx - 1 - z) * 4] -
 
  691                                 odst[((by - 1) * linesize + bx - 1 - z) * 4];
 
  692                             g = odst[((by - 1) * linesize + bx) * 4 + 1] +
 
  693                                 odst[(by * linesize + bx - 1 - z) * 4 + 1] -
 
  694                                 odst[((by - 1) * linesize + bx - 1 - z) * 4 + 1];
 
  695                             b = odst[((by - 1) * linesize + bx) * 4 + 2] +
 
  696                                 odst[(by * linesize + bx - 1 - z) * 4 + 2] -
 
  697                                 odst[((by - 1) * linesize + bx - 1 - z) * 4 + 2];
 
  698                             clr = ((b & 0xFF) << 16) + ((g & 0xFF) << 8) + (r & 0xFF);
 
  699                             dst[by * linesize + bx] = clr;
 
  701                             if (bx >= x * 16 + sx2 || bx >= avctx->
width) {
 
  709                             if (by < 1 || by >= avctx->
height)
 
  718                             clr = dst[(by - 1) * linesize + bx - 1 - z];
 
  719                             dst[by * linesize + bx] = clr;
 
  721                             if (bx >= x * 16 + sx2 || bx >= avctx->
width) {
 
  730                         cx1 = (clr & 0x3F00) >> 2;
 
  731                         cx = (clr & 0x3FFFFF) >> 16;
 
  733                         cx1 = (clr & 0xFC00) >> 4;
 
  734                         cx = (clr & 0xFFFFFF) >> 18;
 
  762     type = bytestream2_peek_byte(gb);
 
  770     } 
else if (type == 18) {
 
  776     } 
else if (type == 17) {
 
  783             uint16_t 
value = bytestream2_get_le16(gb);
 
  787             g = (value >>  5) & 31;
 
  788             b = (value >> 10) & 31;
 
  789             clr = (r << 16) + (g << 8) + 
b;
 
  791             clr = bytestream2_get_le24(gb);
 
  793         for (y = 0; y < avctx->
height; y++) {
 
  794             for (x = 0; x < avctx->
width; x++) {
 
  799     } 
else if (type == 0 || type == 1) {
 
  830         for (y = 0; y < avctx->
height; y++) {
 
  832             if (!(((uintptr_t)dst) & 7)) {
 
  833                 uint64_t *dst64 = (uint64_t *)dst;
 
  834                 int w = avctx->
width>>1;
 
  835                 for (x = 0; x < w; x++) {
 
  836                     dst64[x] = (dst64[x] << 3) & 0xFCFCFCFCFCFCFCFCULL;
 
  841             for (; x < avctx->
width * 4; x++) {
 
  842                 dst[x] = dst[x] << 3;
 
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
unsigned mv_model[2][513]
static av_cold int decode_init(AVCodecContext *avctx)
int(* decode)(GetByteContext *gb, RangeCoder *rc, unsigned cumFreq, unsigned freq, unsigned total_freq)
#define AVERROR_INVALIDDATA
Invalid data found when processing input. 
This structure describes decoded (raw) audio or video data. 
ptrdiff_t const GLvoid * data
PixelModel pixel_model[3][4096]
static av_cold int init(AVCodecContext *avctx)
static int decode0(GetByteContext *gb, RangeCoder *rc, unsigned cumFreq, unsigned freq, unsigned total_freq)
static void reinit_tables(SCPRContext *s)
static int decode_value(SCPRContext *s, unsigned *cnt, unsigned maxc, unsigned step, unsigned *rval)
unsigned run_model[6][257]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx. 
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
unsigned count_model[257]
static int decompress_i(AVCodecContext *avctx, uint32_t *dst, int linesize)
static int decompress_p(AVCodecContext *avctx, uint32_t *dst, int linesize, uint32_t *prev, int plinesize)
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
unsigned sxy_model[4][17]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values. 
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined 
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame. 
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int(* get_freq)(RangeCoder *rc, unsigned total_freq, unsigned *freq)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv). 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
static av_cold int decode_close(AVCodecContext *avctx)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g. 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int decode(GetByteContext *gb, RangeCoder *rc, unsigned cumFreq, unsigned freq, unsigned total_freq)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation. 
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst. 
unsigned range_model[257]
enum AVPictureType pict_type
Picture type of the frame. 
int width
picture width / height. 
GLsizei GLboolean const GLfloat * value
static void init_rangecoder(RangeCoder *rc, GetByteContext *gb)
static int get_freq0(RangeCoder *rc, unsigned total_freq, unsigned *freq)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome. 
Libavcodec external API header. 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line. 
main external API structure. 
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame. 
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation. 
static int get_freq(RangeCoder *rc, unsigned total_freq, unsigned *freq)
common internal api header. 
static int decode_unit(SCPRContext *s, PixelModel *pixel, unsigned step, unsigned *rval)
int key_frame
1 -> keyframe, 0-> not 
#define av_malloc_array(a, b)
#define FFSWAP(type, a, b)
This structure stores compressed data. 
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.