Mercurial > libavcodec.hg
comparison ffv1.c @ 1999:18d5eb75ae71 libavcodec
cleanup
author | michael |
---|---|
date | Sun, 02 May 2004 19:18:20 +0000 |
parents | 8d3540dddd1b |
children | 141a9539e270 |
comparison
equal
deleted
inserted
replaced
1998:5bc1a9ad6c33 | 1999:18d5eb75ae71 |
---|---|
373 int run_mode=0; | 373 int run_mode=0; |
374 | 374 |
375 for(x=0; x<w; x++){ | 375 for(x=0; x<w; x++){ |
376 int diff, context; | 376 int diff, context; |
377 | 377 |
378 context= get_context(s, sample[1]+x, sample[0]+x, sample[2]+x); | 378 context= get_context(s, sample[0]+x, sample[1]+x, sample[2]+x); |
379 diff= sample[1][x] - predict(sample[1]+x, sample[0]+x); | 379 diff= sample[0][x] - predict(sample[0]+x, sample[1]+x); |
380 | 380 |
381 if(context < 0){ | 381 if(context < 0){ |
382 context = -context; | 382 context = -context; |
383 diff= -diff; | 383 diff= -diff; |
384 } | 384 } |
427 } | 427 } |
428 s->run_index= run_index; | 428 s->run_index= run_index; |
429 } | 429 } |
430 | 430 |
431 static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){ | 431 static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){ |
432 int x,y; | 432 int x,y,i; |
433 int_fast16_t sample_buffer[3][w+6]; | 433 const int ring_size=2; |
434 int_fast16_t *sample[3]= {sample_buffer[0]+3, sample_buffer[1]+3, sample_buffer[2]+3}; | 434 int_fast16_t sample_buffer[ring_size][w+6], *sample[ring_size]; |
435 s->run_index=0; | 435 s->run_index=0; |
436 | 436 |
437 memset(sample_buffer, 0, sizeof(sample_buffer)); | 437 memset(sample_buffer, 0, sizeof(sample_buffer)); |
438 | 438 |
439 for(y=0; y<h; y++){ | 439 for(y=0; y<h; y++){ |
440 int_fast16_t *temp= sample[0]; //FIXME try a normal buffer | 440 for(i=0; i<ring_size; i++) |
441 | 441 sample[i]= sample_buffer[(h+i-y)%ring_size]+3; |
442 sample[0]= sample[1]; | 442 |
443 sample[1]= sample[2]; | 443 sample[0][-1]= sample[1][0 ]; |
444 sample[2]= temp; | 444 sample[1][ w]= sample[1][w-1]; |
445 | |
446 sample[1][-1]= sample[0][0 ]; | |
447 sample[0][ w]= sample[0][w-1]; | |
448 //{START_TIMER | 445 //{START_TIMER |
449 for(x=0; x<w; x++){ | 446 for(x=0; x<w; x++){ |
450 sample[1][x]= src[x + stride*y]; | 447 sample[0][x]= src[x + stride*y]; |
451 } | 448 } |
452 encode_line(s, w, sample, plane_index, 8); | 449 encode_line(s, w, sample, plane_index, 8); |
453 //STOP_TIMER("encode line")} | 450 //STOP_TIMER("encode line")} |
454 } | 451 } |
455 } | 452 } |
456 | 453 |
457 static void encode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride){ | 454 static void encode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride){ |
458 int x, y, p; | 455 int x, y, p, i; |
459 int_fast16_t sample_buffer[3][2][w+6]; | 456 const int ring_size=2; |
460 int_fast16_t *sample[3][2]= { | 457 int_fast16_t sample_buffer[3][ring_size][w+6], *sample[3][ring_size]; |
461 {sample_buffer[0][0]+3, sample_buffer[0][1]+3}, | |
462 {sample_buffer[1][0]+3, sample_buffer[1][1]+3}, | |
463 {sample_buffer[2][0]+3, sample_buffer[2][1]+3}}; | |
464 s->run_index=0; | 458 s->run_index=0; |
465 | 459 |
466 memset(sample_buffer, 0, sizeof(sample_buffer)); | 460 memset(sample_buffer, 0, sizeof(sample_buffer)); |
467 | 461 |
468 for(y=0; y<h; y++){ | 462 for(y=0; y<h; y++){ |
463 for(i=0; i<ring_size; i++) | |
464 for(p=0; p<3; p++) | |
465 sample[p][i]= sample_buffer[p][(h+i-y)%ring_size]+3; | |
466 | |
469 for(x=0; x<w; x++){ | 467 for(x=0; x<w; x++){ |
470 int v= src[x + stride*y]; | 468 int v= src[x + stride*y]; |
471 int b= v&0xFF; | 469 int b= v&0xFF; |
472 int g= (v>>8)&0xFF; | 470 int g= (v>>8)&0xFF; |
473 int r= (v>>16)&0xFF; | 471 int r= (v>>16)&0xFF; |
483 sample[0][0][x]= g; | 481 sample[0][0][x]= g; |
484 sample[1][0][x]= b; | 482 sample[1][0][x]= b; |
485 sample[2][0][x]= r; | 483 sample[2][0][x]= r; |
486 } | 484 } |
487 for(p=0; p<3; p++){ | 485 for(p=0; p<3; p++){ |
488 int_fast16_t *temp= sample[p][0]; //FIXME try a normal buffer | 486 sample[p][0][-1]= sample[p][1][0 ]; |
489 | 487 sample[p][1][ w]= sample[p][1][w-1]; |
490 sample[p][0]= sample[p][1]; | |
491 sample[p][1]= temp; | |
492 | |
493 sample[p][1][-1]= sample[p][0][0 ]; | |
494 sample[p][0][ w]= sample[p][0][w-1]; | |
495 encode_line(s, w, sample[p], FFMIN(p, 1), 9); | 488 encode_line(s, w, sample[p], FFMIN(p, 1), 9); |
496 } | 489 } |
497 } | 490 } |
498 } | 491 } |
499 | 492 |