32 #define BITSTREAM_READER_LE
37 #define EA_PREAMBLE_SIZE 8
38 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T')
65 static int unpack(
const uint8_t *src,
const uint8_t *src_end,
unsigned char *dst,
int width,
int height) {
66 unsigned char *dst_end = dst + width*
height;
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);
142 int num_blocks_packed;
147 const unsigned char *blocks_raw;
153 num_blocks_raw =
AV_RL16(&buf[2]);
154 num_blocks_packed =
AV_RL16(&buf[4]);
155 vector_bits =
AV_RL16(&buf[6]);
170 mvbits = (num_mvs*2*10+31) & ~31;
172 if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end)
184 buf += num_blocks_raw*16;
188 for (i=0; i<num_blocks_packed; i++) {
203 unsigned int vector =
get_bits(&gb, vector_bits);
204 const unsigned char *src;
207 if (vector < num_mvs) {
212 if (src+3*src_stride+3>=frame0_end)
216 if (offset<num_blocks_raw)
217 src = blocks_raw + 16*offset;
218 else if (offset-num_blocks_raw<num_blocks_packed)
228 src[j*src_stride + i];
244 void *
data,
int *data_size,
247 const uint8_t *buf = avpkt->
data;
248 int buf_size = avpkt->
size;
250 const uint8_t *buf_end = buf + buf_size;
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_RB16
#define FF_BUFFER_HINTS_VALID
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static int get_sbits(GetBitContext *s, int n)
static int tgv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
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)
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation
bitstream reader API header.
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
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.
struct AVFrame AVFrame
Audio Video Frame.
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)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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.
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_RB24
8 bit with PIX_FMT_RGB32 palette
static const int num_mvs[RV34_MB_TYPES]
number of motion vectors in each macroblock type
int key_frame
1 -> keyframe, 0-> not
#define FFSWAP(type, a, b)
static void cond_release_buffer(AVFrame *pic)
release AVFrame buffers if allocated