Disadvantage is that it no longer allows modifying brightness through
adjustment of the RGB lookup table. Advantage is that now monowhite/black
no longer need to be identified as a RGB format.
---
 libswscale/output.c |   39 ++++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index 39d39c7..d94957e 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -311,7 +311,6 @@ yuv2mono_X_c_template(SwsContext *c, const int16_t 
*lumFilter,
                       int y, enum PixelFormat target)
 {
     const uint8_t * const d128=dither_8x8_220[y&7];
-    uint8_t *g = c->table_gU[128] + c->table_gV[128];
     int i;
     unsigned acc = 0;
 
@@ -330,8 +329,8 @@ yuv2mono_X_c_template(SwsContext *c, const int16_t 
*lumFilter,
             Y1 = av_clip_uint8(Y1);
             Y2 = av_clip_uint8(Y2);
         }
-        acc += acc + g[Y1 + d128[(i + 0) & 7]];
-        acc += acc + g[Y2 + d128[(i + 1) & 7]];
+        acc += acc + (Y1 + d128[(i + 0) & 7] >= 110 + 128);
+        acc += acc + (Y2 + d128[(i + 1) & 7] >= 110 + 128);
         if ((i & 7) == 6) {
             output_pixel(*dest++, acc);
         }
@@ -347,19 +346,18 @@ yuv2mono_2_c_template(SwsContext *c, const int16_t 
*buf[2],
 {
     const int16_t *buf0  = buf[0],  *buf1  = buf[1];
     const uint8_t * const d128 = dither_8x8_220[y & 7];
-    uint8_t *g = c->table_gU[128] + c->table_gV[128];
     int  yalpha1 = 4095 - yalpha;
     int i;
 
     for (i = 0; i < dstW - 7; i += 8) {
-        int acc =    g[((buf0[i    ] * yalpha1 + buf1[i    ] * yalpha) >> 19) 
+ d128[0]];
-        acc += acc + g[((buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19) 
+ d128[1]];
-        acc += acc + g[((buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19) 
+ d128[2]];
-        acc += acc + g[((buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19) 
+ d128[3]];
-        acc += acc + g[((buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19) 
+ d128[4]];
-        acc += acc + g[((buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19) 
+ d128[5]];
-        acc += acc + g[((buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19) 
+ d128[6]];
-        acc += acc + g[((buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19) 
+ d128[7]];
+        int acc =    (((buf0[i    ] * yalpha1 + buf1[i    ] * yalpha) >> 19) + 
d128[0] >= 110 + 128);
+        acc += acc + (((buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19) + 
d128[1] >= 110 + 128);
+        acc += acc + (((buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19) + 
d128[2] >= 110 + 128);
+        acc += acc + (((buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19) + 
d128[3] >= 110 + 128);
+        acc += acc + (((buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19) + 
d128[4] >= 110 + 128);
+        acc += acc + (((buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19) + 
d128[5] >= 110 + 128);
+        acc += acc + (((buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19) + 
d128[6] >= 110 + 128);
+        acc += acc + (((buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19) + 
d128[7] >= 110 + 128);
         output_pixel(*dest++, acc);
     }
 }
@@ -371,18 +369,17 @@ yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
                       int uvalpha, int y, enum PixelFormat target)
 {
     const uint8_t * const d128 = dither_8x8_220[y & 7];
-    uint8_t *g = c->table_gU[128] + c->table_gV[128];
     int i;
 
     for (i = 0; i < dstW - 7; i += 8) {
-        int acc =    g[(buf0[i    ] >> 7) + d128[0]];
-        acc += acc + g[(buf0[i + 1] >> 7) + d128[1]];
-        acc += acc + g[(buf0[i + 2] >> 7) + d128[2]];
-        acc += acc + g[(buf0[i + 3] >> 7) + d128[3]];
-        acc += acc + g[(buf0[i + 4] >> 7) + d128[4]];
-        acc += acc + g[(buf0[i + 5] >> 7) + d128[5]];
-        acc += acc + g[(buf0[i + 6] >> 7) + d128[6]];
-        acc += acc + g[(buf0[i + 7] >> 7) + d128[7]];
+        int acc =    ((buf0[i    ] >> 7) + d128[0] >= 110 + 128);
+        acc += acc + ((buf0[i + 1] >> 7) + d128[1] >= 110 + 128);
+        acc += acc + ((buf0[i + 2] >> 7) + d128[2] >= 110 + 128);
+        acc += acc + ((buf0[i + 3] >> 7) + d128[3] >= 110 + 128);
+        acc += acc + ((buf0[i + 4] >> 7) + d128[4] >= 110 + 128);
+        acc += acc + ((buf0[i + 5] >> 7) + d128[5] >= 110 + 128);
+        acc += acc + ((buf0[i + 6] >> 7) + d128[6] >= 110 + 128);
+        acc += acc + ((buf0[i + 7] >> 7) + d128[7] >= 110 + 128);
         output_pixel(*dest++, acc);
     }
 }
-- 
1.7.2.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to