32 #define BITSTREAM_READER_LE
37 #define EA_PREAMBLE_SIZE 8
38 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T')
66 unsigned char *dst_end = dst + width*
height;
67 int size, size1, size2, offset,
run;
68 unsigned char *dst_start = dst;
80 while(size>0 && src<src_end) {
84 if ( src[0] & 0x80 ) {
86 if ( src[0] & 0x20 ) {
88 size1 = (((src[0] & 31) + 1) << 2);
92 offset = ((src[0] & 0x10) << 12) +
AV_RB16(&src[1]) + 1;
93 size2 = ((src[0] & 0xC) << 6) + src[3] + 5;
97 size1 = ( ( src[1] & 0xC0) >> 6 );
98 offset = (
AV_RB16(&src[1]) & 0x3FFF) + 1;
99 size2 = (src[0] & 0x3F) + 4;
103 offset = ((src[0] & 0x60) << 3) + src[1] + 1;
104 size2 = ((src[0] & 0x1C) >> 2) + 3;
110 if (size1>src_end-src)
115 run =
FFMIN(size1, dst_end-dst);
116 memcpy(dst, src, run);
122 if (dst-dst_start<offset)
125 run =
FFMIN(size2, dst_end-dst);
141 int num_blocks_packed;
146 const unsigned char *blocks_raw;
152 num_blocks_raw =
AV_RL16(&buf[2]);
153 num_blocks_packed =
AV_RL16(&buf[4]);
154 vector_bits =
AV_RL16(&buf[6]);
159 "Invalid value for motion vector bits: %d\n", vector_bits);
175 mvbits = (num_mvs*2*10+31) & ~31;
177 if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end)
189 buf += num_blocks_raw*16;
193 for (i=0; i<num_blocks_packed; i++) {
208 unsigned int vector =
get_bits(&gb, vector_bits);
209 const unsigned char *src;
212 if (vector < num_mvs) {
224 if (offset<num_blocks_raw)
225 src = blocks_raw + 16*offset;
226 else if (offset-num_blocks_raw<num_blocks_packed)
236 src[j*src_stride + i];
252 void *
data,
int *got_frame,
256 int buf_size = avpkt->
size;
258 const uint8_t *buf_end = buf + buf_size;
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
unsigned char(* block_codebook)[16]
int buffer_hints
codec suggestion on buffer type if != 0
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
memory handling functions
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst, int width, int height)
Unpack buffer.
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
#define FFSWAP(type, a, b)
8 bit with PIX_FMT_RGB32 palette
bitstream reader API header.
static int init(AVCodecParserContext *s)
static int get_bits_left(GetBitContext *gb)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
static av_cold int tgv_decode_end(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int num_mvs
current length of mv_codebook
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
struct AVRational AVRational
rational number numerator/denominator
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...
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
unsigned int palette[AVPALETTE_COUNT]
int width
picture width / height.
int num_blocks_packed
current length of block_codebook
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
static int tgv_decode_inter(TgvContext *s, const uint8_t *buf, const uint8_t *buf_end)
Decode inter-frame.
main external API structure.
static void close(AVCodecParserContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static av_cold int tgv_decode_init(AVCodecContext *avctx)
struct TgvContext TgvContext
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define AVERROR_INVALIDDATA
static const int num_mvs[RV34_MB_TYPES]
number of motion vectors in each macroblock type
int key_frame
1 -> keyframe, 0-> not
#define FF_BUFFER_HINTS_VALID
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation
static int tgv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
This structure stores compressed data.
static void cond_release_buffer(AVFrame *pic)
release AVFrame buffers if allocated