comparison rle.c @ 6546:18ab078a42ab libavcodec

change rle encoder to count up to 127, sgi does not support 128
author bcoudurier
date Sun, 30 Mar 2008 17:27:58 +0000
parents 2b72f9bc4f06
children 0e9e36d55e5e
comparison
equal deleted inserted replaced
6545:85acd5166cf8 6546:18ab078a42ab
33 static int count_pixels(const uint8_t *start, int len, int bpp, int same) 33 static int count_pixels(const uint8_t *start, int len, int bpp, int same)
34 { 34 {
35 const uint8_t *pos; 35 const uint8_t *pos;
36 int count = 1; 36 int count = 1;
37 37
38 for(pos = start + bpp; count < FFMIN(128, len); pos += bpp, count ++) { 38 for(pos = start + bpp; count < FFMIN(127, len); pos += bpp, count ++) {
39 if(same != !memcmp(pos-bpp, pos, bpp)) { 39 if(same != !memcmp(pos-bpp, pos, bpp)) {
40 if(!same) { 40 if(!same) {
41 /* if bpp == 1, then 0 1 1 0 is more efficiently encoded as a single 41 /* if bpp == 1, then 0 1 1 0 is more efficiently encoded as a single
42 * raw block of pixels. for larger bpp, RLE is as good or better */ 42 * raw block of pixels. for larger bpp, RLE is as good or better */
43 if(bpp == 1 && count + 1 < FFMIN(128, len) && *pos != *(pos+1)) 43 if(bpp == 1 && count + 1 < FFMIN(127, len) && *pos != *(pos+1))
44 continue; 44 continue;
45 45
46 /* if RLE can encode the next block better than as a raw block, 46 /* if RLE can encode the next block better than as a raw block,
47 * back up and leave _all_ the identical pixels for RLE */ 47 * back up and leave _all_ the identical pixels for RLE */
48 count --; 48 count --;