[FFmpeg-devel] [PATCH] Huffyuv speed tweaks
Jason Garrett-Glaser
darkshikari
Sat Aug 9 00:09:09 CEST 2008
$subj, faster decoding pixel prediction.
Dark Shikari
Index: libavcodec/huffyuv.c
===================================================================
--- libavcodec/huffyuv.c (revision 14661)
+++ libavcodec/huffyuv.c (working copy)
@@ -131,17 +131,23 @@
static inline int add_left_prediction(uint8_t *dst, uint8_t *src, int
w, int acc){
int i;
- for(i=0; i<w-1; i++){
- acc+= src[i];
- dst[i]= acc;
- i++;
- acc+= src[i];
- dst[i]= acc;
+ for(i=0; i<(w>>2); i++){
+ acc+= src[0];
+ dst[0]= acc;
+ acc+= src[1];
+ dst[1]= acc;
+ acc+= src[2];
+ dst[2]= acc;
+ acc+= src[3];
+ dst[3]= acc;
+ src+=4;
+ dst+=4;
}
-
- for(; i<w; i++){
- acc+= src[i];
- dst[i]= acc;
+ for(i<<=2; i<w; i++){
+ acc+= *src;
+ *dst= acc;
+ src++;
+ dst++;
}
return acc;
@@ -155,9 +161,12 @@
lt= *left_top;
for(i=0; i<w; i++){
- l= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF) + diff[i];
- lt= src1[i];
- dst[i]= l;
+ l= mid_pred(l, *src1, (l + *src1 - lt)&0xFF) + *diff;
+ lt= *src1;
+ *dst= l;
+ src1++;
+ dst++;
+ diff++;
}
*left= l;
@@ -172,13 +181,15 @@
b= *blue;
for(i=0; i<w; i++){
- b+= src[4*i+B];
- g+= src[4*i+G];
- r+= src[4*i+R];
+ b+= src[B];
+ g+= src[G];
+ r+= src[R];
- dst[4*i+B]= b;
- dst[4*i+G]= g;
- dst[4*i+R]= r;
+ dst[B]= b;
+ dst[G]= g;
+ dst[R]= r;
+ src+= 4;
+ dst+= 4;
}
*red= r;
More information about the ffmpeg-devel
mailing list