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);
108 for (j = 0; j < h; j++) {
109 for (i = 0; i < w*step; i += step) {
115 dst[i] += dst[i - stride];
130 void *
data,
int *got_frame,
135 int buf_size = avpkt->
size;
139 unsigned int version,header_size;
141 const uint32_t *buf32;
142 uint32_t *luma1,*luma2,*
cb,*
cr;
144 int i, j,
ret, is_chroma;
145 const int planes = 3;
154 version = header & 0xff;
155 header_size = (header & (1<<30))? 8 : 4;
159 "This file is encoded with Fraps version %d. " \
160 "This codec can only decode versions <= 5.\n", version);
167 unsigned needed_size = avctx->
width * avctx->
height * 3;
168 if (version == 0) needed_size /= 2;
169 needed_size += header_size;
171 if (header & (1
U<<31)) {
175 if (buf_size != needed_size) {
177 "Invalid frame length %d (should be %d)\n",
178 buf_size, needed_size);
191 for (i = 0; i < planes; i++) {
192 offs[i] =
AV_RL32(buf + 4 + i * 4);
193 if (offs[i] >= buf_size - header_size || (i && offs[i] <= offs[i - 1] + 1024)) {
198 offs[planes] = buf_size - header_size;
199 for (i = 0; i < planes; i++) {
220 if (((avctx->
width % 8) != 0) || ((avctx->
height % 2) != 0)) {
226 buf32 = (
const uint32_t*)buf;
227 for (y = 0; y < avctx->
height / 2; y++) {
228 luma1 = (uint32_t*)&f->
data[0][ y * 2 * f->
linesize[0] ];
229 luma2 = (uint32_t*)&f->
data[0][ (y * 2 + 1) * f->
linesize[0] ];
232 for (x = 0; x < avctx->
width; x += 8) {
245 for (y = 0; y<avctx->
height; y++)
247 &buf[y * avctx->
width * 3],
257 for (i = 0; i < planes; i++) {
260 avctx->
width >> is_chroma,
261 avctx->
height >> is_chroma,
262 buf + offs[i], offs[i + 1] - offs[i],
263 is_chroma, 1)) < 0) {
272 for (i = 0; i < planes; i++) {
275 buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) {
282 for (j = 0; j < avctx->
height; j++) {
284 while (out < line_end) {