aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoren Merritt <lorenm@u.washington.edu>2007-05-18 08:58:30 +0000
committerLoren Merritt <lorenm@u.washington.edu>2007-05-18 08:58:30 +0000
commitbf1a5a46d68d0dba66a5f43e9000ce937709ffd6 (patch)
tree2fd9412584b90a95b0284a268497313d8224294f
parent390f9f3127c1a0eee25f889d98d178759d3c643a (diff)
downloadffmpeg-bf1a5a46d68d0dba66a5f43e9000ce937709ffd6.tar.gz
cosmetics: macrofy duplicate code in huffyuv
Originally committed as revision 9055 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/huffyuv.c107
1 files changed, 62 insertions, 45 deletions
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 1154a7170f..3a252f6824 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -686,34 +686,43 @@ static int encode_422_bitstream(HYuvContext *s, int count){
return -1;
}
+#define LOAD4\
+ int y0 = s->temp[0][2*i];\
+ int y1 = s->temp[0][2*i+1];\
+ int u0 = s->temp[1][i];\
+ int v0 = s->temp[2][i];
+
count/=2;
if(s->flags&CODEC_FLAG_PASS1){
for(i=0; i<count; i++){
- s->stats[0][ s->temp[0][2*i ] ]++;
- s->stats[1][ s->temp[1][ i ] ]++;
- s->stats[0][ s->temp[0][2*i+1] ]++;
- s->stats[2][ s->temp[2][ i ] ]++;
+ LOAD4;
+ s->stats[0][y0]++;
+ s->stats[1][u0]++;
+ s->stats[0][y1]++;
+ s->stats[2][v0]++;
}
}
if(s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT)
return 0;
if(s->context){
for(i=0; i<count; i++){
- s->stats[0][ s->temp[0][2*i ] ]++;
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
- s->stats[1][ s->temp[1][ i ] ]++;
- put_bits(&s->pb, s->len[1][ s->temp[1][ i ] ], s->bits[1][ s->temp[1][ i ] ]);
- s->stats[0][ s->temp[0][2*i+1] ]++;
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
- s->stats[2][ s->temp[2][ i ] ]++;
- put_bits(&s->pb, s->len[2][ s->temp[2][ i ] ], s->bits[2][ s->temp[2][ i ] ]);
+ LOAD4;
+ s->stats[0][y0]++;
+ put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);
+ s->stats[1][u0]++;
+ put_bits(&s->pb, s->len[1][u0], s->bits[1][u0]);
+ s->stats[0][y1]++;
+ put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
+ s->stats[2][v0]++;
+ put_bits(&s->pb, s->len[2][v0], s->bits[2][v0]);
}
}else{
for(i=0; i<count; i++){
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
- put_bits(&s->pb, s->len[1][ s->temp[1][ i ] ], s->bits[1][ s->temp[1][ i ] ]);
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
- put_bits(&s->pb, s->len[2][ s->temp[2][ i ] ], s->bits[2][ s->temp[2][ i ] ]);
+ LOAD4;
+ put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);
+ put_bits(&s->pb, s->len[1][u0], s->bits[1][u0]);
+ put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
+ put_bits(&s->pb, s->len[2][v0], s->bits[2][v0]);
}
}
return 0;
@@ -727,11 +736,21 @@ static int encode_gray_bitstream(HYuvContext *s, int count){
return -1;
}
+#define LOAD2\
+ int y0 = s->temp[0][2*i];\
+ int y1 = s->temp[0][2*i+1];
+#define STAT2\
+ s->stats[0][y0]++;\
+ s->stats[0][y1]++;
+#define WRITE2\
+ put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);\
+ put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
+
count/=2;
if(s->flags&CODEC_FLAG_PASS1){
for(i=0; i<count; i++){
- s->stats[0][ s->temp[0][2*i ] ]++;
- s->stats[0][ s->temp[0][2*i+1] ]++;
+ LOAD2;
+ STAT2;
}
}
if(s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT)
@@ -739,15 +758,14 @@ static int encode_gray_bitstream(HYuvContext *s, int count){
if(s->context){
for(i=0; i<count; i++){
- s->stats[0][ s->temp[0][2*i ] ]++;
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
- s->stats[0][ s->temp[0][2*i+1] ]++;
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
+ LOAD2;
+ STAT2;
+ WRITE2;
}
}else{
for(i=0; i<count; i++){
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]);
- put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]);
+ LOAD2;
+ WRITE2;
}
}
return 0;
@@ -798,35 +816,34 @@ static int encode_bgr_bitstream(HYuvContext *s, int count){
return -1;
}
- if((s->flags&CODEC_FLAG_PASS1) && (s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT)){
- for(i=0; i<count; i++){
- int g= s->temp[0][4*i+G];
- int b= (s->temp[0][4*i+B] - g) & 0xff;
+#define LOAD3\
+ int g= s->temp[0][4*i+G];\
+ int b= (s->temp[0][4*i+B] - g) & 0xff;\
int r= (s->temp[0][4*i+R] - g) & 0xff;
- s->stats[0][b]++;
- s->stats[1][g]++;
+#define STAT3\
+ s->stats[0][b]++;\
+ s->stats[1][g]++;\
s->stats[2][r]++;
+#define WRITE3\
+ put_bits(&s->pb, s->len[1][g], s->bits[1][g]);\
+ put_bits(&s->pb, s->len[0][b], s->bits[0][b]);\
+ put_bits(&s->pb, s->len[2][r], s->bits[2][r]);
+
+ if((s->flags&CODEC_FLAG_PASS1) && (s->avctx->flags2&CODEC_FLAG2_NO_OUTPUT)){
+ for(i=0; i<count; i++){
+ LOAD3;
+ STAT3;
}
}else if(s->context || (s->flags&CODEC_FLAG_PASS1)){
for(i=0; i<count; i++){
- int g= s->temp[0][4*i+G];
- int b= (s->temp[0][4*i+B] - g) & 0xff;
- int r= (s->temp[0][4*i+R] - g) & 0xff;
- s->stats[0][b]++;
- s->stats[1][g]++;
- s->stats[2][r]++;
- put_bits(&s->pb, s->len[1][g], s->bits[1][g]);
- put_bits(&s->pb, s->len[0][b], s->bits[0][b]);
- put_bits(&s->pb, s->len[2][r], s->bits[2][r]);
+ LOAD3;
+ STAT3;
+ WRITE3;
}
}else{
for(i=0; i<count; i++){
- int g= s->temp[0][4*i+G];
- int b= (s->temp[0][4*i+B] - g) & 0xff;
- int r= (s->temp[0][4*i+R] - g) & 0xff;
- put_bits(&s->pb, s->len[1][g], s->bits[1][g]);
- put_bits(&s->pb, s->len[0][b], s->bits[0][b]);
- put_bits(&s->pb, s->len[2][r], s->bits[2][r]);
+ LOAD3;
+ WRITE3;
}
}
return 0;