[FFmpeg-cvslog] avcodec/diracdec: Factor +2 out of the inner loop

Michael Niedermayer git at videolan.org
Wed Jan 13 19:28:29 CET 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Tue Jan 12 23:32:57 2016 +0100| [bbd977162590db4b29a5532e3e7102e054ff3ae0] | committer: Michael Niedermayer

avcodec/diracdec: Factor +2 out of the inner loop

Reviewed-by: Rostislav Pehlivanov <atomnuker at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bbd977162590db4b29a5532e3e7102e054ff3ae0
---

 libavcodec/diracdec.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index fe879bb..bbe6d87 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -517,7 +517,7 @@ static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffse
         coeff = ret - 1;
     }
     if (coeff) {
-        coeff = (coeff * qfactor + qoffset + 2) >> 2;
+        coeff = (coeff * qfactor + qoffset) >> 2;
         sign  = SHOW_SBITS(re, gb, 1);
         LAST_SKIP_BITS(re, gb, 1);
         coeff = (coeff ^ sign) - sign;
@@ -548,7 +548,7 @@ static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffse
         } \
         coeff = dirac_get_arith_uint(c, pred_ctx, CTX_COEFF_DATA); \
         if (coeff) { \
-            coeff = (coeff * qfactor + qoffset + 2) >> 2; \
+            coeff = (coeff * qfactor + qoffset) >> 2; \
             sign  = dirac_get_arith_bit(c, SIGN_CTX(sign_pred)); \
             coeff = (coeff ^ -sign) + sign; \
         } \
@@ -600,9 +600,9 @@ static inline void codeblock(DiracContext *s, SubBand *b,
     qfactor = qscale_tab[b->quant];
     /* TODO: context pointer? */
     if (!s->num_refs)
-        qoffset = qoffset_intra_tab[b->quant];
+        qoffset = qoffset_intra_tab[b->quant] + 2;
     else
-        qoffset = qoffset_inter_tab[b->quant];
+        qoffset = qoffset_inter_tab[b->quant] + 2;
 
     buf = b->ibuf + top * b->stride;
     if (is_arith) {
@@ -776,7 +776,7 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
     int bottom = b1->height *(slice_y+1) / s->num_y;
 
     int qfactor = qscale_tab[quant & 0x7f];
-    int qoffset = qoffset_intra_tab[quant & 0x7f];
+    int qoffset = qoffset_intra_tab[quant & 0x7f] + 2;
 
     uint8_t *buf1 =      b1->ibuf + top * b1->stride;
     uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;



More information about the ffmpeg-cvslog mailing list