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);
109 for (j = 0; j < h; j++) {
110 for (i = 0; i < w*step; i += step) {
116 dst[i] += dst[i - stride];
131 void *
data,
int *got_frame,
136 int buf_size = avpkt->
size;
140 unsigned int version,header_size;
142 const uint32_t *buf32;
143 uint32_t *luma1,*luma2,*
cb,*
cr;
145 int i, j,
ret, is_chroma;
146 const int planes = 3;
155 version = header & 0xff;
156 header_size = (header & (1<<30))? 8 : 4;
160 "This file is encoded with Fraps version %d. " \
161 "This codec can only decode versions <= 5.\n", version);
168 unsigned needed_size = avctx->
width * avctx->
height * 3;
169 if (version == 0) needed_size /= 2;
170 needed_size += header_size;
172 if (header & (1
U<<31)) {
176 if (buf_size != needed_size) {
178 "Invalid frame length %d (should be %d)\n",
179 buf_size, needed_size);
192 for (i = 0; i < planes; i++) {
193 offs[i] =
AV_RL32(buf + 4 + i * 4);
194 if (offs[i] >= buf_size - header_size || (i && offs[i] <= offs[i - 1] + 1024)) {
199 offs[planes] = buf_size - header_size;
200 for (i = 0; i < planes; i++) {
222 if (((avctx->
width % 8) != 0) || ((avctx->
height % 2) != 0)) {
228 buf32 = (
const uint32_t*)buf;
229 for (y = 0; y < avctx->
height / 2; y++) {
230 luma1 = (uint32_t*)&f->
data[0][ y * 2 * f->
linesize[0] ];
231 luma2 = (uint32_t*)&f->
data[0][ (y * 2 + 1) * f->
linesize[0] ];
234 for (x = 0; x < avctx->
width; x += 8) {
247 for (y = 0; y<avctx->
height; y++)
249 &buf[y * avctx->
width * 3],
259 for (i = 0; i < planes; i++) {
262 avctx->
width >> is_chroma,
263 avctx->
height >> is_chroma,
264 buf + offs[i], offs[i + 1] - offs[i],
265 is_chroma, 1)) < 0) {
274 for (i = 0; i < planes; i++) {
277 buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) {
284 for (j = 0; j < avctx->
height; j++) {
286 while (out < line_end) {