40 #define FPS_TAG MKTAG('F', 'P', 'S', 'x')
77 static int huff_cmp(
const void *va,
const void *vb){
78 const Node *
a = va, *
b = vb;
79 return (a->
count - b->count)*256 + a->
sym - b->sym;
86 int h,
const uint8_t *src,
int size,
int Uoff,
94 for(i = 0; i < 256; i++)
95 nodes[i].count = bytestream_get_le32(&src);
106 for(j = 0; j < h; j++){
112 if(j) dst[i] += dst[i -
stride];
113 else if(Uoff) dst[i] += 0x80;
126 void *
data,
int *data_size,
129 const uint8_t *buf = avpkt->
data;
130 int buf_size = avpkt->
size;
135 unsigned int version,header_size;
137 const uint32_t *buf32;
138 uint32_t *luma1,*luma2,*cb,*cr;
140 int i, j, is_chroma, planes;
142 int prev_pic_bit, expected_size;
150 version = header & 0xff;
151 header_size = (header & (1<<30))? 8 : 4;
152 prev_pic_bit = header & (1
U << 31);
156 "This file is encoded with Fraps version %d. " \
157 "This codec can only decode versions <= 5.\n", version);
162 if (header_size == 8)
171 expected_size = header_size;
178 expected_size += avctx->
width * avctx->
height * 3 / 2;
179 if (buf_size != expected_size) {
181 "Invalid frame length %d (should be %d)\n",
182 buf_size, expected_size);
186 if (( (avctx->
width % 8) != 0) || ( (avctx->
height % 2) != 0 )) {
204 buf32=(
const uint32_t*)buf;
205 for(y=0; y<avctx->
height/2; y++){
210 for(x=0; x<avctx->
width; x+=8){
211 *(luma1++) = *(buf32++);
212 *(luma1++) = *(buf32++);
213 *(luma2++) = *(buf32++);
214 *(luma2++) = *(buf32++);
215 *(cr++) = *(buf32++);
216 *(cb++) = *(buf32++);
226 if (buf_size != expected_size) {
228 "Invalid frame length %d (should be %d)\n",
229 buf_size, expected_size);
245 for(y=0; y<avctx->
height; y++)
247 &buf[y*avctx->
width*3],
279 for(i = 0; i < planes; i++) {
280 offs[i] =
AV_RL32(buf + 4 + i * 4);
281 if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
286 offs[planes] = buf_size;
287 for(i = 0; i < planes; i++){
291 avctx->
height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) {
321 for(i = 0; i < planes; i++) {
322 offs[i] =
AV_RL32(buf + 4 + i * 4);
323 if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
328 offs[planes] = buf_size;
329 for(i = 0; i < planes; i++){
332 avctx->
width, avctx->
height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) {
338 for(j = 0; j < avctx->
height; j++){
339 for(i = 0; i < avctx->
width; i++){
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_BUFFER_HINTS_VALID
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
AVFrame * coded_frame
the picture in the bitstream
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, Node *nodes, HuffCmp cmp, int flags)
nodes size must be 2*nb_codes first nb_codes nodes.count must be set
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
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 decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
bitstream reader API header.
static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w, int h, const uint8_t *src, int size, int Uoff, const int step)
decode Fraps v2 packed plane
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_left(GetBitContext *gb)
#define FF_HUFFMAN_FLAG_ZERO_COUNT
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.
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int huff_cmp(const void *va, const void *vb)
Comparator - our nodes should ascend by count but with preserved symbol order.
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
#define FF_BUFFER_HINTS_REUSABLE
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
static av_cold int decode_end(AVCodecContext *avctx)
closes decoder
main external API structure.
static void close(AVCodecParserContext *s)
static av_cold int decode_init(AVCodecContext *avctx)
initializes decoder
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
#define FF_BUFFER_HINTS_PRESERVE
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
huffman tree builder and VLC generator
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
packed RGB 8:8:8, 24bpp, BGRBGR...
struct FrapsContext FrapsContext
local variable storage
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
void ff_free_vlc(VLC *vlc)