79 return (aa->
len - bb->len) * 256 + aa->
sym - bb->sym;
85 return (aa->
len - bb->len) * 1024 + aa->
sym - bb->sym;
97 for (i = 0; i < 1024; i++) {
100 if (len[i] == 0 || len[i] > 32)
106 for (i = 1023; i >= 0; i--) {
107 codes[i] = code >> (32 - he[i].
len);
110 code += 0x80000000
u >> (he[i].
len - 1);
115 bits,
sizeof(*bits),
sizeof(*bits),
116 codes,
sizeof(*codes),
sizeof(*codes),
117 syms,
sizeof(*syms),
sizeof(*syms), 0);
129 for (i = 0; i < 256; i++) {
132 if (len[i] == 0 || len[i] > 32)
138 for (i = 255; i >= 0; i--) {
139 codes[i] = code >> (32 - he[i].
len);
142 code += 0x80000000
u >> (he[i].
len - 1);
147 bits,
sizeof(*bits),
sizeof(*bits),
148 codes,
sizeof(*codes),
sizeof(*codes),
149 syms,
sizeof(*syms),
sizeof(*syms), 0);
153 const uint16_t *
diff, intptr_t w,
154 int *left,
int *left_top)
162 for (i = 0; i < w; i++) {
163 l =
mid_pred(l, src1[i], (l + src1[i] - lt)) + diff[i];
183 for (i = 0; i < s->
planes; i++) {
184 int left, lefttop, top;
188 ptrdiff_t fake_stride = (p->
linesize[i] / 2) * (1 + interlaced);
200 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
202 for (k = 0; k <
height; k++) {
203 for (x = 0; x <
width; x++)
209 for (k = 0; k <
height; k++) {
210 for (x = 0; x <
width; x++) {
227 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
234 for (k = 1 + interlaced; k <
height; k++) {
240 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
249 for (k = 1 + interlaced; k <
height; k++) {
250 top = dst[-fake_stride];
252 dst[0] = left & 0x3FF;
253 for (x = 1; x <
width; x++) {
254 top = dst[x - fake_stride];
255 lefttop = dst[x - (fake_stride + 1)];
256 left += top - lefttop + dst[x];
257 dst[x] = left & 0x3FF;
263 dst = (uint16_t *)p->
data[i] + j * sheight * stride;
264 lefttop = left = dst[0];
268 lefttop = left = dst[0];
272 for (k = 1 + interlaced; k <
height; k++) {
274 lefttop = left = dst[0];
291 for (k = 0; k <
width; k++) {
292 b[k] = (b[k] +
g[k]) & 0x3FF;
293 r[k] = (r[k] +
g[k]) & 0x3FF;
314 for (i = 0; i < s->
planes; i++) {
315 int left, lefttop, top;
333 for (k = 0; k <
height; k++) {
334 for (x = 0; x <
width; x++)
340 for (k = 0; k <
height; k++) {
341 for (x = 0; x <
width; x++) {
365 for (k = 1 + interlaced; k <
height; k++) {
380 for (k = 1 + interlaced; k <
height; k++) {
381 top = dst[-fake_stride];
384 for (x = 1; x <
width; x++) {
385 top = dst[x - fake_stride];
386 lefttop = dst[x - (fake_stride + 1)];
387 left += top - lefttop + dst[x];
395 lefttop = left = dst[0];
399 lefttop = left = dst[0];
403 for (k = 1 + interlaced; k <
height; k++) {
405 dst, width, &left, &lefttop);
406 lefttop = left = dst[0];
422 for (i = 0; i <
height; i++) {
439 memset(s->
len, 0,
sizeof(s->
len));
445 for (k = 0; k < l; k++)
447 s->
len[i][j + k] = x;
460 }
else if (j > max) {
481 uint32_t first_offset,
offset, next_offset, header_size, slice_width;
486 if (bytestream2_get_le32(&gbyte) !=
MKTAG(
'M',
'A',
'G',
'Y'))
489 header_size = bytestream2_get_le32(&gbyte);
490 if (header_size < 32 || header_size >= avpkt->
size) {
492 "header or packet too small %"PRIu32
"\n", header_size);
496 version = bytestream2_get_byte(&gbyte);
511 format = bytestream2_get_byte(&gbyte);
578 s->
flags = bytestream2_get_byte(&gbyte);
582 width = bytestream2_get_le32(&gbyte);
583 height = bytestream2_get_le32(&gbyte);
588 slice_width = bytestream2_get_le32(&gbyte);
605 "invalid number of slices: %d\n", s->
nb_slices);
609 for (i = 0; i < s->
planes; i++) {
614 offset = bytestream2_get_le32(&gbyte);
615 if (offset >= avpkt->
size - header_size)
624 next_offset = bytestream2_get_le32(&gbyte);
625 if (next_offset <= offset || next_offset >= avpkt->
size - header_size)
629 offset = next_offset;
636 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]
static void magicyuv_median_pred10(uint16_t *dst, const uint16_t *src1, const uint16_t *diff, intptr_t w, int *left, int *left_top)
#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 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.
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.
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_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
#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)