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;
290 for (k = 1 + interlaced; k <
height; k++) {
291 top = dst[-fake_stride];
294 for (x = 1; x <
width; x++) {
295 top = dst[x - fake_stride];
296 lefttop = dst[x - (fake_stride + 1)];
297 left += top - lefttop + dst[x];
304 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
305 lefttop = left = dst[0];
309 lefttop = left = dst[0];
313 for (k = 1 + interlaced; k <
height; k++) {
315 lefttop = left = dst[0];
332 for (k = 0; k <
width; k++) {
333 b[k] = (b[k] +
g[k]) & max;
334 r[k] = (r[k] +
g[k]) & max;
355 for (i = 0; i < s->
planes; i++) {
356 int left, lefttop, top;
374 for (k = 0; k <
height; k++) {
375 for (x = 0; x <
width; x++)
381 for (k = 0; k <
height; k++) {
382 for (x = 0; x <
width; x++) {
406 for (k = 1 + interlaced; k <
height; k++) {
421 for (k = 1 + interlaced; k <
height; k++) {
422 top = dst[-fake_stride];
425 for (x = 1; x <
width; x++) {
426 top = dst[x - fake_stride];
427 lefttop = dst[x - (fake_stride + 1)];
428 left += top - lefttop + dst[x];
436 lefttop = left = dst[0];
440 lefttop = left = dst[0];
444 for (k = 1 + interlaced; k <
height; k++) {
446 dst, width, &left, &lefttop);
447 lefttop = left = dst[0];
463 for (i = 0; i <
height; i++) {
480 memset(s->
len, 0,
sizeof(s->
len));
486 for (k = 0; k < l; k++)
488 s->
len[i][j + k] = x;
501 }
else if (j > max) {
523 uint32_t first_offset,
offset, next_offset, header_size, slice_width;
528 if (bytestream2_get_le32(&gbyte) !=
MKTAG(
'M',
'A',
'G',
'Y'))
531 header_size = bytestream2_get_le32(&gbyte);
532 if (header_size < 32 || header_size >= avpkt->
size) {
534 "header or packet too small %"PRIu32
"\n", header_size);
538 version = bytestream2_get_byte(&gbyte);
554 format = bytestream2_get_byte(&gbyte);
641 s->
flags = bytestream2_get_byte(&gbyte);
645 width = bytestream2_get_le32(&gbyte);
646 height = bytestream2_get_le32(&gbyte);
651 slice_width = bytestream2_get_le32(&gbyte);
668 "invalid number of slices: %d\n", s->
nb_slices);
672 for (i = 0; i < s->
planes; i++) {
677 offset = bytestream2_get_le32(&gbyte);
678 if (offset >= avpkt->
size - header_size)
687 next_offset = bytestream2_get_le32(&gbyte);
688 if (next_offset <= offset || next_offset >= avpkt->
size - header_size)
692 offset = next_offset;
699 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.
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.
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)
static const char * format
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
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)