25 #include "../libavutil/pixdesc.h" 62 unsigned int slices_size[4];
71 return (aa->
len - bb->len) * 256 + aa->
sym - bb->sym;
83 for (i = 0; i < 256; i++) {
90 for (i = 255; i >= 0; i--) {
91 codes[i] = code >> (32 - he[i].
len);
94 code += 0x80000000
u >> (he[i].
len - 1);
99 bits,
sizeof(*bits),
sizeof(*bits),
100 codes,
sizeof(*codes),
sizeof(*codes),
101 syms,
sizeof(*syms),
sizeof(*syms), 0);
114 for (i = 0; i < s->
planes; i++) {
115 int left, lefttop, top;
119 ptrdiff_t fake_stride = p->
linesize[i] * (1 + interlaced);
133 for (k = 0; k <
height; k++) {
134 for (x = 0; x <
width; x++)
140 for (k = 0; k <
height; k++) {
141 for (x = 0; x <
width; x++) {
165 for (k = 1 + interlaced; k <
height; k++) {
180 for (k = 1 + interlaced; k <
height; k++) {
181 top = dst[-fake_stride];
184 for (x = 1; x <
width; x++) {
185 top = dst[x - fake_stride];
186 lefttop = dst[x - (fake_stride + 1)];
187 left += top - lefttop + dst[x];
195 lefttop = left = dst[0];
199 lefttop = left = dst[0];
203 for (k = 1 + interlaced; k <
height; k++) {
205 dst, width, &left, &lefttop);
206 lefttop = left = dst[0];
222 for (i = 0; i <
height; i++) {
242 uint32_t first_offset, offset, next_offset, header_size, slice_width;
247 if (bytestream2_get_le32(&gbyte) !=
MKTAG(
'M',
'A',
'G',
'Y'))
250 header_size = bytestream2_get_le32(&gbyte);
251 if (header_size < 32 || header_size >= avpkt->
size) {
253 "header or packet too small %"PRIu32
"\n", header_size);
257 version = bytestream2_get_byte(&gbyte);
269 format = bytestream2_get_byte(&gbyte);
307 s->
interlaced = !!(bytestream2_get_byte(&gbyte) & 2);
310 width = bytestream2_get_le32(&gbyte);
311 height = bytestream2_get_le32(&gbyte);
316 slice_width = bytestream2_get_le32(&gbyte);
317 if (slice_width != width) {
333 "invalid number of slices: %d\n", s->
nb_slices);
337 for (i = 0; i < s->
planes; i++) {
342 offset = bytestream2_get_le32(&gbyte);
343 if (offset >= avpkt->
size - header_size)
347 first_offset = offset;
352 next_offset = bytestream2_get_le32(&gbyte);
353 if (next_offset <= offset || next_offset >= avpkt->
size - header_size)
357 offset = next_offset;
364 if (bytestream2_get_byte(&gbyte) != s->
planes)
377 memset(s->
len, 0,
sizeof(s->
len));
384 for (k = 0; k < l; k++)
386 s->
len[i][j + k] = x;
399 }
else if (j > 256) {
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
void(* add_bytes)(uint8_t *dst, uint8_t *src, int w)
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.
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.
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c)
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)
#define FF_ARRAY_ELEMS(a)
unsigned int slices_size[4]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
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...
int ff_init_vlc_sparse(VLC *vlc, 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)
Multithreading support functions.
void(* add_hfyu_median_pred)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top)
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. ...
const char * name
Name of the codec implementation.
#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.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int(* add_hfyu_left_pred)(uint8_t *dst, const uint8_t *src, int w, int left)
if(ac->has_optimized_func)
static const float pred[4]
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, 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)
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.
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)
AVCodec ff_magicyuv_decoder
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int magy_decode_end(AVCodecContext *avctx)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
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 av_cold int init(AVCodecParserContext *s)
static int huff_build(VLC *vlc, uint8_t *len)
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.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AV_CEIL_RSHIFT(a, b)
Fast a / (1 << b) rounded toward +inf, assuming a >= 0 and b >= 0.