41 #define FPS_TAG MKTAG('F', 'P', 'S', 'x') 83 static int huff_cmp(
const void *va,
const void *vb)
85 const Node *
a = va, *
b = vb;
86 return (a->
count - b->count)*256 + a->
sym - b->sym;
101 for (i = 0; i < 256; i++)
102 nodes[i].count = bytestream_get_le32(&src);
112 (
const uint32_t *) src, size >> 2);
115 for (j = 0; j < h; j++) {
116 for (i = 0; i < w*
step; i +=
step) {
122 dst[i] += dst[i -
stride];
137 void *
data,
int *got_frame,
142 int buf_size = avpkt->
size;
146 unsigned int version,header_size;
148 const uint32_t *buf32;
149 uint32_t *luma1,*luma2,*cb,*cr;
151 int i, j, ret, is_chroma, planes;
153 int prev_pic_bit, expected_size;
161 version = header & 0xff;
162 header_size = (header & (1<<30))? 8 : 4;
163 prev_pic_bit = header & (1
U << 31);
167 "This file is encoded with Fraps version %d. " \
168 "This codec can only decode versions <= 5.\n", version);
173 if (header_size == 8)
184 expected_size = header_size;
191 expected_size += avctx->
width * avctx->
height * 3 / 2;
192 if (buf_size != expected_size) {
194 "Invalid frame length %d (should be %d)\n",
195 buf_size, expected_size);
199 if (((avctx->
width % 8) != 0) || ((avctx->
height % 2) != 0)) {
213 buf32 = (
const uint32_t*)buf;
214 for (y = 0; y < avctx->
height / 2; y++) {
215 luma1 = (uint32_t*)&f->
data[0][ y * 2 * f->
linesize[0]];
216 luma2 = (uint32_t*)&f->
data[0][(y * 2 + 1) * f->
linesize[0]];
219 for (x = 0; x < avctx->
width; x += 8) {
220 *(luma1++) = *(buf32++);
221 *(luma1++) = *(buf32++);
222 *(luma2++) = *(buf32++);
223 *(luma2++) = *(buf32++);
224 *(cr++) = *(buf32++);
225 *(cb++) = *(buf32++);
235 if (buf_size != expected_size) {
237 "Invalid frame length %d (should be %d)\n",
238 buf_size, expected_size);
250 for (y = 0; y<avctx->
height; y++)
252 &buf[y * avctx->
width * 3],
276 if ((
AV_RL32(buf) !=
FPS_TAG) || (buf_size < (planes * 1024 + 24))) {
280 for (i = 0; i < planes; i++) {
281 offs[i] =
AV_RL32(buf + 4 + i * 4);
282 if (offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
287 offs[planes] = buf_size;
288 for (i = 0; i < planes; i++) {
291 offs[i + 1] - offs[i] - 1024);
295 avctx->
width >> is_chroma,
296 avctx->
height >> is_chroma,
297 buf + offs[i], offs[i + 1] - offs[i],
298 is_chroma, 1)) < 0) {
324 for (i = 0; i < planes; i++) {
325 offs[i] =
AV_RL32(buf + 4 + i * 4);
326 if (offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
331 offs[planes] = buf_size;
332 for (i = 0; i < planes; i++) {
334 offs[i + 1] - offs[i] - 1024);
339 buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) {
345 for (j = 0; j < avctx->
height; j++) {
346 for (i = 0; i < avctx->
width; i++) {
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bits, Node *nodes, HuffCmp cmp, int flags)
nodes size must be 2*nb_codes first nb_codes nodes.count must be set
enum AVColorRange color_range
MPEG vs JPEG YUV range.
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)
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)
Allocate a buffer with padding, reusing the given one if large enough.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
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
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_HUFFMAN_FLAG_ZERO_COUNT
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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.
static int huff_cmp(const void *va, const void *vb)
Comparator - our nodes should ascend by count but with preserved symbol order.
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
enum AVPictureType pict_type
Picture type of the frame.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int width
picture width / height.
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
packed RGB 8:8:8, 24bpp, BGRBGR...
enum AVPixelFormat pix_fmt
the normal 2^n-1 "JPEG" YUV ranges
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static av_cold int decode_end(AVCodecContext *avctx)
closes decoder
main external API structure.
static av_cold int decode_init(AVCodecContext *avctx)
initializes decoder
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
huffman tree builder and VLC generator
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static av_cold int init(AVCodecParserContext *s)
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
AVPixelFormat
Pixel format.
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.