11/*
2- * Copyrgght (c) 2006, Daisuke Okanohara
2+ * Copyright (c) 2006, Daisuke Okanohara
33 * Copyright (c) 2008-2010, Cybozu Labs, Inc.
44 * All rights reserved.
5- *
5+ *
66 * Redistribution and use in source and binary forms, with or without
77 * modification, are permitted provided that the following conditions are met:
8- *
8+ *
99 * * Redistributions of source code must retain the above copyright notice,
1010 * this list of conditions and the following disclaimer.
1111 * * Redistributions in binary form must reproduce the above copyright notice,
1414 * * Neither the name of the copyright holders nor the names of its
1515 * contributors may be used to endorse or promote products derived from this
1616 * software without specific prior written permission.
17- *
17+ *
1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1919 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -63,28 +63,28 @@ template <class Iter> class rc_encoder_t : public rc_type_t {
6363 }
6464 uint newL = L + r*low;
6565 if (newL < L) {
66- // overflow occured (newL >= 2^32)
67- // buffer FF FF .. FF -> buffer+1 00 00 .. 00
66+ // overflow occured (newL >= 2^32)
67+ // buffer FF FF .. FF -> buffer+1 00 00 .. 00
6868 buffer++;
6969 for (;carryN > 0 ; carryN--) {
70- *iter++ = buffer;
71- buffer = 0 ;
70+ *iter++ = buffer;
71+ buffer = 0 ;
7272 }
7373 }
7474 L = newL;
7575 while (R < TOP) {
7676 const byte newBuffer = (L >> 24 );
7777 if (start) {
78- buffer = newBuffer;
79- start = false ;
78+ buffer = newBuffer;
79+ start = false ;
8080 } else if (newBuffer == 0xFF ) {
81- carryN++;
81+ carryN++;
8282 } else {
83- *iter++ = buffer;
84- for (; carryN != 0 ; carryN--) {
85- *iter++ = 0xFF ;
86- }
87- buffer = newBuffer;
83+ *iter++ = buffer;
84+ for (; carryN != 0 ; carryN--) {
85+ *iter++ = 0xFF ;
86+ }
87+ buffer = newBuffer;
8888 }
8989 L <<= 8 ;
9090 R <<= 8 ;
@@ -101,7 +101,7 @@ template <class Iter> class rc_encoder_t : public rc_type_t {
101101 uint t8 = t >> 24 , l8 = L >> 24 ;
102102 *iter++ = l8;
103103 if (t8 != l8) {
104- break ;
104+ break ;
105105 }
106106 t <<= 8 ;
107107 L <<= 8 ;
@@ -151,7 +151,7 @@ template<int _BASE> struct rc_decoder_search_t<short, 256, _BASE> : public rc_de
151151 __m128i b = _mm_cmplt_epi16 (v, y);
152152 mask = (_mm_movemask_epi8 (b) << 16 ) | _mm_movemask_epi8 (a);
153153 if (mask) {
154- return i + (__builtin_ctz (mask) >> 1 ) - 1 ;
154+ return i + (__builtin_ctz (mask) >> 1 ) - 1 ;
155155 }
156156 }
157157 return 255 ;
@@ -175,25 +175,25 @@ template <class Iterator, class SearchType> class rc_decoder_t : public rc_type_
175175 uint decode (const uint total, const freq_type* cumFreq) {
176176 const uint r = R / total;
177177 const int targetPos = std::min (total-1 , D / r);
178-
179- // find target s.t. cumFreq[target] <= targetPos < cumFreq[target+1]
178+
179+ // find target s.t. cumFreq[target] <= targetPos < cumFreq[target+1]
180180 const uint target =
181181 search_type::get_index (cumFreq, targetPos + search_type::BASE);
182182 const uint low = cumFreq[target] - search_type::BASE;
183183 const uint high = cumFreq[target+1 ] - search_type::BASE;
184-
184+
185185 D -= r * low;
186186 if (high != total) {
187187 R = r * (high-low);
188188 } else {
189189 R -= r * low;
190190 }
191-
191+
192192 while (R < TOP) {
193193 R <<= 8 ;
194194 D = (D << 8 ) | next ();
195195 }
196-
196+
197197 return target;
198198 }
199199 byte next () {
0 commit comments