41 #define FPS_TAG MKTAG('F', 'P', 'S', 'x')
82 static int huff_cmp(
const void *va,
const void *vb)
84 const Node *
a = va, *
b = vb;
85 return (a->
count - b->count)*256 + a->
sym - b->sym;
100 for (i = 0; i < 256; i++)
101 nodes[i].count = bytestream_get_le32(&src);
112 for (j = 0; j < h; j++) {
113 for (i = 0; i < w*
step; i +=
step) {
119 dst[i] += dst[i -
stride];
134 void *
data,
int *got_frame,
139 int buf_size = avpkt->
size;
143 unsigned int version,header_size;
145 const uint32_t *buf32;
146 uint32_t *luma1,*luma2,*cb,*cr;
148 int i, j, ret, is_chroma, planes;
150 int prev_pic_bit, expected_size;
158 version = header & 0xff;
159 header_size = (header & (1<<30))? 8 : 4;
160 prev_pic_bit = header & (1
U << 31);
164 "This file is encoded with Fraps version %d. " \
165 "This codec can only decode versions <= 5.\n", version);
170 if (header_size == 8)
179 expected_size = header_size;
186 expected_size += avctx->
width * avctx->
height * 3 / 2;
187 if (buf_size != expected_size) {
189 "Invalid frame length %d (should be %d)\n",
190 buf_size, expected_size);
194 if (((avctx->
width % 8) != 0) || ((avctx->
height % 2) != 0)) {
208 buf32 = (
const uint32_t*)buf;
209 for (y = 0; y < avctx->
height / 2; y++) {
210 luma1 = (uint32_t*)&f->
data[0][ y * 2 * f->
linesize[0]];
211 luma2 = (uint32_t*)&f->
data[0][(y * 2 + 1) * f->
linesize[0]];
214 for (x = 0; x < avctx->
width; x += 8) {
215 *(luma1++) = *(buf32++);
216 *(luma1++) = *(buf32++);
217 *(luma2++) = *(buf32++);
218 *(luma2++) = *(buf32++);
219 *(cr++) = *(buf32++);
220 *(cb++) = *(buf32++);
230 if (buf_size != expected_size) {
232 "Invalid frame length %d (should be %d)\n",
233 buf_size, expected_size);
245 for (y = 0; y<avctx->
height; y++)
247 &buf[y * avctx->
width * 3],
271 if ((
AV_RL32(buf) !=
FPS_TAG) || (buf_size < (planes * 1024 + 24))) {
275 for (i = 0; i < planes; i++) {
276 offs[i] =
AV_RL32(buf + 4 + i * 4);
277 if (offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
282 offs[planes] = buf_size;
283 for (i = 0; i < planes; i++) {
286 offs[i + 1] - offs[i] - 1024);
290 avctx->
width >> is_chroma,
291 avctx->
height >> is_chroma,
292 buf + offs[i], offs[i + 1] - offs[i],
293 is_chroma, 1)) < 0) {
319 for (i = 0; i < planes; i++) {
320 offs[i] =
AV_RL32(buf + 4 + i * 4);
321 if (offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
326 offs[planes] = buf_size;
327 for (i = 0; i < planes; i++) {
329 offs[i + 1] - offs[i] - 1024);
334 buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) {
340 for (j = 0; j < avctx->
height; j++) {
341 for (i = 0; i < avctx->
width; i++) {