42 #define FPS_TAG MKTAG('F', 'P', 'S', 'x')
77 static int huff_cmp(
const void *va,
const void *vb)
79 const Node *
a = va, *
b = vb;
80 return (a->
count - b->count)*256 + a->
sym - b->sym;
95 for (i = 0; i < 256; i++)
96 nodes[i].
count = bytestream_get_le32(&src);
106 (
const uint32_t *) src, size >> 2);
111 for (j = 0; j <
h; j++) {
112 for (i = 0; i < w*step; i += step) {
118 dst[i] += dst[i -
stride];
133 void *
data,
int *got_frame,
138 int buf_size = avpkt->
size;
142 unsigned int version,header_size;
144 const uint32_t *buf32;
145 uint32_t *luma1,*luma2,*
cb,*
cr;
147 int i, j, ret, is_chroma;
148 const int planes = 3;
157 version = header & 0xff;
158 header_size = (header & (1<<30))? 8 : 4;
162 "This file is encoded with Fraps version %d. " \
163 "This codec can only decode versions <= 5.\n", version);
170 unsigned needed_size = avctx->
width * avctx->
height * 3;
171 if (version == 0) needed_size /= 2;
172 needed_size += header_size;
174 if (header & (1
U<<31)) {
178 if (buf_size != needed_size) {
180 "Invalid frame length %d (should be %d)\n",
181 buf_size, needed_size);
194 for (i = 0; i < planes; i++) {
195 offs[i] =
AV_RL32(buf + 4 + i * 4);
196 if (offs[i] >= buf_size - header_size || (i && offs[i] <= offs[i - 1] + 1024)) {
201 offs[planes] = buf_size - header_size;
202 for (i = 0; i < planes; i++) {
224 if (((avctx->
width % 8) != 0) || ((avctx->
height % 2) != 0)) {
230 buf32 = (
const uint32_t*)buf;
231 for (y = 0; y < avctx->
height / 2; y++) {
232 luma1 = (uint32_t*)&f->
data[0][ y * 2 * f->
linesize[0] ];
233 luma2 = (uint32_t*)&f->
data[0][ (y * 2 + 1) * f->
linesize[0] ];
236 for (x = 0; x < avctx->
width; x += 8) {
249 for (y = 0; y<avctx->
height; y++)
251 &buf[y * avctx->
width * 3],
261 for (i = 0; i < planes; i++) {
264 avctx->
width >> is_chroma,
265 avctx->
height >> is_chroma,
266 buf + offs[i], offs[i + 1] - offs[i],
267 is_chroma, 1)) < 0) {
276 for (i = 0; i < planes; i++) {
279 buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) {
286 for (j = 0; j < avctx->
height; j++) {
288 while (out < line_end) {
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * 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
static av_cold int init(AVCodecContext *avctx)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
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 AV_INPUT_BUFFER_PADDING_SIZE at the end w...
static double cb(void *priv, double x, double y)
Multithreading support functions.
bitstream reader API header.
static const uint8_t header[24]
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
#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.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
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.
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 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...
the normal 2^n-1 "JPEG" YUV ranges
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, 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 int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static av_cold int decode_end(AVCodecContext *avctx)
closes decoder
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
static av_cold int decode_init(AVCodecContext *avctx)
initializes decoder
enum AVColorSpace colorspace
YUV colorspace type.
huffman tree builder and VLC generator
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
GLint GLenum GLboolean GLsizei stride
common internal api header.
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
static double cr(void *priv, double x, double y)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
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.