80 return (aa->
len - bb->len) * 256 + aa->
sym - bb->sym;
86 return (aa->
len - bb->len) * 1024 + aa->
sym - bb->sym;
92 return (aa->
len - bb->len) * 4096 + aa->
sym - bb->sym;
104 for (i = 0; i < 1024; i++) {
105 he[i].
sym = 1023 - i;
107 if (len[i] == 0 || len[i] > 32)
113 for (i = 1023; i >= 0; i--) {
114 codes[i] = code >> (32 - he[i].
len);
117 code += 0x80000000
u >> (he[i].
len - 1);
122 bits,
sizeof(*bits),
sizeof(*bits),
123 codes,
sizeof(*codes),
sizeof(*codes),
124 syms,
sizeof(*syms),
sizeof(*syms), 0);
130 uint32_t codes[4096];
136 for (i = 0; i < 4096; i++) {
137 he[i].
sym = 4095 - i;
139 if (len[i] == 0 || len[i] > 32)
145 for (i = 4095; i >= 0; i--) {
146 codes[i] = code >> (32 - he[i].
len);
149 code += 0x80000000
u >> (he[i].
len - 1);
154 bits,
sizeof(*bits),
sizeof(*bits),
155 codes,
sizeof(*codes),
sizeof(*codes),
156 syms,
sizeof(*syms),
sizeof(*syms), 0);
168 for (i = 0; i < 256; i++) {
171 if (len[i] == 0 || len[i] > 32)
177 for (i = 255; i >= 0; i--) {
178 codes[i] = code >> (32 - he[i].
len);
181 code += 0x80000000
u >> (he[i].
len - 1);
186 bits,
sizeof(*bits),
sizeof(*bits),
187 codes,
sizeof(*codes),
sizeof(*codes),
188 syms,
sizeof(*syms),
sizeof(*syms), 0);
192 const uint16_t *
diff, intptr_t
w,
193 int *left,
int *left_top,
int max)
201 for (i = 0; i <
w; i++) {
202 l =
mid_pred(l, src1[i], (l + src1[i] - lt)) + diff[i];
218 const int max = s->
max - 1;
224 for (i = 0; i < s->
planes; i++) {
225 int left, lefttop, top;
229 ptrdiff_t fake_stride = (p->
linesize[i] / 2) * (1 + interlaced);
241 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
243 for (k = 0; k <
height; k++) {
244 for (x = 0; x <
width; x++)
250 for (k = 0; k <
height; k++) {
251 for (x = 0; x <
width; x++) {
268 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
275 for (k = 1 + interlaced; k <
height; k++) {
281 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
288 for (k = 1 + interlaced; k <
height; k++) {
289 top = dst[-fake_stride];
292 for (x = 1; x <
width; x++) {
293 top = dst[x - fake_stride];
294 lefttop = dst[x - (fake_stride + 1)];
295 left += top - lefttop + dst[x];
302 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
309 lefttop = left = dst[0];
310 for (k = 1 + interlaced; k <
height; k++) {
312 lefttop = left = dst[0];
329 for (k = 0; k <
width; k++) {
330 b[k] = (b[k] +
g[k]) & max;
331 r[k] = (r[k] +
g[k]) & max;
348 int i, k, x, min_width;
352 for (i = 0; i < s->
planes; i++) {
353 int left, lefttop, top;
371 for (k = 0; k <
height; k++) {
372 for (x = 0; x <
width; x++)
378 for (k = 0; k <
height; k++) {
379 for (x = 0; x <
width; x++) {
403 for (k = 1 + interlaced; k <
height; k++) {
416 min_width =
FFMIN(width, 32);
417 for (k = 1 + interlaced; k <
height; k++) {
418 top = dst[-fake_stride];
421 for (x = 1; x < min_width; x++) {
422 top = dst[x - fake_stride];
423 lefttop = dst[x - (fake_stride + 1)];
424 left += top - lefttop + dst[x];
440 lefttop = left = dst[0];
441 for (k = 1 + interlaced; k <
height; k++) {
443 dst, width, &left, &lefttop);
444 lefttop = left = dst[0];
460 for (i = 0; i <
height; i++) {
477 memset(s->
len, 0,
sizeof(s->
len));
483 for (k = 0; k < l; k++)
485 s->
len[i][j + k] = x;
498 }
else if (j > max) {
520 uint32_t first_offset,
offset, next_offset, header_size, slice_width;
525 if (bytestream2_get_le32(&gbyte) !=
MKTAG(
'M',
'A',
'G',
'Y'))
528 header_size = bytestream2_get_le32(&gbyte);
529 if (header_size < 32 || header_size >= avpkt->
size) {
531 "header or packet too small %"PRIu32
"\n", header_size);
535 version = bytestream2_get_byte(&gbyte);
551 format = bytestream2_get_byte(&gbyte);
638 s->
flags = bytestream2_get_byte(&gbyte);
642 width = bytestream2_get_le32(&gbyte);
643 height = bytestream2_get_le32(&gbyte);
648 slice_width = bytestream2_get_le32(&gbyte);
665 "invalid number of slices: %d\n", s->
nb_slices);
669 for (i = 0; i < s->
planes; i++) {
674 offset = bytestream2_get_le32(&gbyte);
675 if (offset >= avpkt->
size - header_size)
684 next_offset = bytestream2_get_le32(&gbyte);
685 if (next_offset <= offset || next_offset >= avpkt->
size - header_size)
689 offset = next_offset;
696 if (bytestream2_get_byte(&gbyte) != s->
planes)
int(* add_left_pred_int16)(uint16_t *dst, const uint16_t *src, unsigned mask, ptrdiff_t w, unsigned left)
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const char * format[]
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
#define AV_PIX_FMT_GBRAP10
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_thread_copy(AVCodecContext *avctx)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static av_cold int init(AVCodecContext *avctx)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
#define AV_PIX_FMT_GBRP10
static int huff_build10(VLC *vlc, uint8_t *len)
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 int slices_size[4]
#define AV_PIX_FMT_GRAY10
void(* add_bytes)(uint8_t *dst, uint8_t *src, ptrdiff_t w)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Multithreading support functions.
#define u(width, name, range_min, range_max)
int(* magy_decode_slice)(AVCodecContext *avctx, void *tdata, int j, int threadnr)
bitstream reader API header.
static int huff_cmp_len12(const void *a, const void *b)
static int magy_decode_slice(AVCodecContext *avctx, void *tdata, int j, int threadnr)
static int huff_cmp_len(const void *a, const void *b)
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
enum AVColorSpace colorspace
YUV colorspace type.
#define AV_PIX_FMT_GBRAP12
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static int huff_build12(VLC *vlc, uint8_t *len)
enum AVPictureType pict_type
Picture type of the frame.
static int huff_cmp_len10(const void *a, const void *b)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
#define FF_ARRAY_ELEMS(a)
the normal 2^n-1 "JPEG" YUV ranges
static const float pred[4]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static av_cold int magy_decode_init(AVCodecContext *avctx)
static av_always_inline int bytestream2_tell(GetByteContext *g)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
static int magy_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void ff_llviddsp_init(LLVidDSPContext *c)
AVCodec ff_magicyuv_decoder
static int magy_decode_slice10(AVCodecContext *avctx, void *tdata, int j, int threadnr)
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
the normal 219*2^(n-8) "MPEG" YUV ranges
void(* add_gradient_pred)(uint8_t *src, const ptrdiff_t stride, const ptrdiff_t width)
static av_cold int magy_decode_end(AVCodecContext *avctx)
GLint GLenum GLboolean GLsizei stride
int(* huff_build)(VLC *vlc, uint8_t *len)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
planar GBRA 4:4:4:4 32bpp
static int huff_build(VLC *vlc, uint8_t *len)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
int(* add_left_pred)(uint8_t *dst, const uint8_t *src, ptrdiff_t w, int left)
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
static void magicyuv_median_pred16(uint16_t *dst, const uint16_t *src1, const uint16_t *diff, intptr_t w, int *left, int *left_top, int max)
#define FFSWAP(type, a, b)
#define MKTAG(a, b, c, d)
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define AV_QSORT(p, num, type, cmp)
Quicksort This sort is fast, and fully inplace but not stable and it is possible to construct input t...
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
void(* add_median_pred)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, ptrdiff_t w, int *left, int *left_top)
#define AV_CEIL_RSHIFT(a, b)