40 #define FPS_TAG MKTAG('F', 'P', 'S', 'x')
78 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);
107 for(j = 0; j < h; j++){
113 if(j) dst[i] += dst[i -
stride];
114 else if(Uoff) dst[i] += 0x80;
127 void *
data,
int *got_frame,
131 int buf_size = avpkt->
size;
136 unsigned int version,header_size;
138 const uint32_t *buf32;
139 uint32_t *luma1,*luma2,*cb,*cr;
141 int i, j, is_chroma, planes;
143 int prev_pic_bit, expected_size;
151 version = header & 0xff;
152 header_size = (header & (1<<30))? 8 : 4;
153 prev_pic_bit = header & (1
U << 31);
157 "This file is encoded with Fraps version %d. " \
158 "This codec can only decode versions <= 5.\n", version);
163 if (header_size == 8)
172 expected_size = header_size;
179 expected_size += avctx->
width * avctx->
height * 3 / 2;
180 if (buf_size != expected_size) {
182 "Invalid frame length %d (should be %d)\n",
183 buf_size, expected_size);
187 if (( (avctx->
width % 8) != 0) || ( (avctx->
height % 2) != 0 )) {
205 buf32=(
const uint32_t*)buf;
206 for(y=0; y<avctx->
height/2; y++){
211 for(x=0; x<avctx->
width; x+=8){
212 *(luma1++) = *(buf32++);
213 *(luma1++) = *(buf32++);
214 *(luma2++) = *(buf32++);
215 *(luma2++) = *(buf32++);
216 *(cr++) = *(buf32++);
217 *(cb++) = *(buf32++);
227 if (buf_size != expected_size) {
229 "Invalid frame length %d (should be %d)\n",
230 buf_size, expected_size);
246 for(y=0; y<avctx->
height; y++)
248 &buf[y*avctx->
width*3],
280 for(i = 0; i < planes; i++) {
281 offs[i] =
AV_RL32(buf + 4 + i * 4);
282 if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
287 offs[planes] = buf_size;
288 for(i = 0; i < planes; i++){
291 offs[i + 1] - offs[i] - 1024);
295 avctx->
height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) {
325 for(i = 0; i < planes; i++) {
326 offs[i] =
AV_RL32(buf + 4 + i * 4);
327 if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
332 offs[planes] = buf_size;
333 for(i = 0; i < planes; i++){
335 offs[i + 1] - offs[i] - 1024);
339 avctx->
width, avctx->
height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) {
345 for(j = 0; j < avctx->
height; j++){
346 for(i = 0; i < avctx->
width; i++){