38 #include "libavutil/imgutils.h"
40 #define EA_PREAMBLE_SIZE 8
41 #define MADk_TAG MKTAG('M', 'A', 'D', 'k')
42 #define MADm_TAG MKTAG('M', 'A', 'D', 'm')
43 #define MADe_TAG MKTAG('M', 'A', 'D', 'e')
71 static inline void comp(
unsigned char *dst,
int dst_stride,
72 unsigned char *
src,
int src_stride,
int add)
77 dst[j*dst_stride + i] = av_clip_uint8(src[j*src_stride + i] + add);
82 int j,
int mv_x,
int mv_y,
int add)
88 comp(frame->
data[0] + (mb_y*16 + ((j&2)<<2))*frame->
linesize[0] + mb_x*16 + ((j&1)<<3),
105 int mb_x,
int mb_y,
int j)
109 frame->
data[0] + (mb_y*16 + ((j&2)<<2))*frame->
linesize[0] + mb_x*16 + ((j&1)<<3),
114 frame->
data[index] + (mb_y*8)*frame->
linesize[index] + mb_x*8,
126 block[0] = (128 +
get_sbits(&s->
gb, 8)) * quant_matrix[0];
140 }
else if (level != 0) {
143 level = (level*quant_matrix[j]) >> 4;
159 level = (level*quant_matrix[j]) >> 4;
163 level = (level*quant_matrix[j]) >> 4;
205 for (j=0; j<6; j++) {
206 if (mv_map & (1<<j)) {
230 void *
data,
int *got_frame,
234 int buf_size = avpkt->
size;
235 const uint8_t *buf_end = buf+buf_size;
253 AV_RL16(&buf[6]), 1000, 1<<30);
260 if (width < 16 || height < 16) {
265 if (avctx->
width != width || avctx->
height != height) {
266 if((width * height)/2048*7 > buf_end-buf)
av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, int idct_permutation_type)
This structure describes decoded (raw) audio or video data.
uint16_t quant_matrix[64]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
av_cold void ff_mpeg12_init_vlcs(void)
static void comp_block(MadContext *t, AVFrame *frame, int mb_x, int mb_y, int j, int mv_x, int mv_y, int add)
static av_cold int init(AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
#define DECLARE_ALIGNED(n, t, v)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional FF_INPUT_BUFFER_PADDING_SIZE at the end w...
static int get_sbits(GetBitContext *s, int n)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static const uint8_t offset[511][2]
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
bitstream reader API header.
uint8_t idct_permutation[64]
idct input permutation.
static void calc_quant_matrix(MadContext *s, int qscale)
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int decode_end(AVCodecContext *avctx)
static int decode_block_intra(MadContext *s, int16_t *block)
#define CLOSE_READER(name, gb)
Libavcodec external API header.
#define GET_RL_VLC(level, run, name, gb, table, bits,max_depth, need_update)
#define SKIP_BITS(name, gb, num)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int width
picture width / height.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define LAST_SKIP_BITS(name, gb, num)
RL_VLC_ELEM * rl_vlc[32]
decoding only
#define SHOW_UBITS(name, gb, num)
static int decode210(GetBitContext *gb)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void idct_put(MadContext *t, AVFrame *frame, int16_t *block, int mb_x, int mb_y, int j)
const uint16_t ff_inv_aanscales[64]
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define OPEN_READER(name, gb)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
static int decode_motion(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
BYTE int const BYTE int int int height
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
const uint16_t ff_mpeg1_default_intra_matrix[256]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AAN (Arai Agui Nakajima) (I)DCT tables.
void ff_ea_idct_put_c(uint8_t *dest, int linesize, int16_t *block)
#define SHOW_SBITS(name, gb, num)
common internal api header.
const uint8_t ff_zigzag_direct[64]
#define CODEC_FLAG_GRAY
Only decode/encode grayscale.
void(* clear_block)(int16_t *block)
#define AVERROR_INVALIDDATA
static int decode_mb(MadContext *s, AVFrame *frame, int inter)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
unsigned int bitstream_buf_size
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int decode_init(AVCodecContext *avctx)