42 #define FPS_TAG MKTAG('F', 'P', 'S', 'x')
76 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;
94 for (i = 0; i < 256; i++)
95 nodes[i].
count = bytestream_get_le32(&src);
106 for (j = 0; j < h; j++) {
107 for (i = 0; i < w*step; i += step) {
113 dst[i] += dst[i -
stride];
128 void *
data,
int *got_frame,
133 int buf_size = avpkt->
size;
137 unsigned int version,header_size;
139 const uint32_t *buf32;
140 uint32_t *luma1,*luma2,*
cb,*
cr;
142 int i, j,
ret, is_chroma;
143 const int planes = 3;
147 version = header & 0xff;
148 header_size = (header & (1<<30))? 8 : 4;
152 "This file is encoded with Fraps version %d. " \
153 "This codec can only decode versions <= 5.\n", version);
160 unsigned needed_size = avctx->
width * avctx->
height * 3;
161 if (version == 0) needed_size /= 2;
162 needed_size += header_size;
164 if (header & (1
U<<31)) {
168 if (buf_size != needed_size) {
170 "Invalid frame length %d (should be %d)\n",
171 buf_size, needed_size);
184 for (i = 0; i < planes; i++) {
185 offs[i] =
AV_RL32(buf + 4 + i * 4);
186 if (offs[i] >= buf_size - header_size || (i && offs[i] <= offs[i - 1] + 1024)) {
191 offs[planes] = buf_size - header_size;
192 for (i = 0; i < planes; i++) {
212 if (((avctx->
width % 8) != 0) || ((avctx->
height % 2) != 0)) {
218 buf32 = (
const uint32_t*)buf;
219 for (y = 0; y < avctx->
height / 2; y++) {
220 luma1 = (uint32_t*)&f->
data[0][ y * 2 * f->
linesize[0] ];
221 luma2 = (uint32_t*)&f->
data[0][ (y * 2 + 1) * f->
linesize[0] ];
224 for (x = 0; x < avctx->
width; x += 8) {
237 for (y = 0; y<avctx->
height; y++)
239 &buf[y * avctx->
width * 3],
249 for (i = 0; i < planes; i++) {
252 avctx->
width >> is_chroma,
253 avctx->
height >> is_chroma,
254 buf + offs[i], offs[i + 1] - offs[i],
255 is_chroma, 1)) < 0) {
264 for (i = 0; i < planes; i++) {
267 buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) {
274 for (j = 0; j < avctx->
height; j++) {
276 while (out < line_end) {