40 #define FPS_TAG MKTAG('F', 'P', 'S', 'x')
77 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;
86 int h,
const uint8_t *src,
int size,
int Uoff,
94 for(i = 0; i < 256; i++)
95 nodes[i].count = bytestream_get_le32(&src);
106 for(j = 0; j < h; j++){
112 if(j) dst[i] += dst[i -
stride];
113 else if(Uoff) dst[i] += 0x80;
126 void *
data,
int *data_size,
129 const uint8_t *buf = avpkt->
data;
130 int buf_size = avpkt->
size;
135 unsigned int version,header_size;
137 const uint32_t *buf32;
138 uint32_t *luma1,*luma2,*cb,*cr;
140 int i, j, is_chroma, planes;
144 version = header & 0xff;
145 header_size = (header & (1<<30))? 8 : 4;
149 "This file is encoded with Fraps version %d. " \
150 "This codec can only decode versions <= 5.\n", version);
155 if (header_size == 8)
168 if ( (buf_size != avctx->
width*avctx->
height*3/2+header_size) &&
169 (buf_size != header_size) ) {
171 "Invalid frame length %d (should be %d)\n",
172 buf_size, avctx->
width*avctx->
height*3/2+header_size);
176 if (( (avctx->
width % 8) != 0) || ( (avctx->
height % 2) != 0 )) {
195 buf32=(
const uint32_t*)buf;
196 for(y=0; y<avctx->
height/2; y++){
201 for(x=0; x<avctx->
width; x+=8){
202 *(luma1++) = *(buf32++);
203 *(luma1++) = *(buf32++);
204 *(luma2++) = *(buf32++);
205 *(luma2++) = *(buf32++);
206 *(cr++) = *(buf32++);
207 *(cb++) = *(buf32++);
215 if ( (buf_size != avctx->
width*avctx->
height*3+header_size) &&
216 (buf_size != header_size) ) {
218 "Invalid frame length %d (should be %d)\n",
219 buf_size, avctx->
width*avctx->
height*3+header_size);
236 for(y=0; y<avctx->
height; y++)
238 &buf[y*avctx->
width*3],
270 for(i = 0; i < planes; i++) {
271 offs[i] =
AV_RL32(buf + 4 + i * 4);
272 if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
277 offs[planes] = buf_size;
278 for(i = 0; i < planes; i++){
282 avctx->
height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) {
312 for(i = 0; i < planes; i++) {
313 offs[i] =
AV_RL32(buf + 4 + i * 4);
314 if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
319 offs[planes] = buf_size;
320 for(i = 0; i < planes; i++){
323 avctx->
width, avctx->
height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) {
329 for(j = 0; j < avctx->
height; j++){
330 for(i = 0; i < avctx->
width; i++){