Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : #include <stdint.h>
34 : #include "options.h"
35 : #include "cnst.h"
36 : #include "prot_fx.h"
37 : #include "stat_enc.h"
38 : #include "wmc_auto.h"
39 : #include "ivas_rom_com.h"
40 : #include "ivas_prot_fx.h"
41 :
42 : /*---------------------------------------------------------------------*
43 : * Local function prototypes
44 : *---------------------------------------------------------------------*/
45 :
46 : static Word16 adapt_GR_sg_fx( const Word16 *in, const Word16 len, const Word16 no_symb, Word16 *nbits, Word16 *in_enc, const Word16 *map0, const Word16 no_GR_ord );
47 :
48 :
49 : /*---------------------------------------------------------------------*
50 : * calculate_diff_fx()
51 : *
52 : * calculate difference wrt previous frame and maps it to positive integer
53 : *---------------------------------------------------------------------*/
54 :
55 50503 : static void calculate_diff_fx(
56 : const Word16 *in, /* i : current frame values */
57 : const Word16 *prev, /* i : previous frmae values */
58 : Word16 *in_diff, /* o : difference values */
59 : const Word16 len /* i : vector length */
60 : )
61 : {
62 : Word16 i, tmp;
63 :
64 421222 : FOR( i = 0; i < len; i++ )
65 : {
66 370719 : tmp = sub( in[i], prev[i] );
67 370719 : IF( tmp > 0 )
68 : {
69 82750 : in_diff[i] = sub( imult1616( 2, tmp ), 1 );
70 82750 : move16();
71 : }
72 : ELSE
73 : {
74 287969 : IF( tmp < 0 )
75 : {
76 59442 : in_diff[i] = imult1616( -2, tmp );
77 59442 : move16();
78 : }
79 : ELSE
80 : {
81 228527 : in_diff[i] = 0;
82 228527 : move16();
83 : }
84 : }
85 : }
86 :
87 50503 : return;
88 : }
89 :
90 :
91 : /*---------------------------------------------------------------------*
92 : * calculate_bit_diff_fx()
93 : *
94 : * estimates the GR number of bits for encoding differential values
95 : * selects between GR order 0 or 1
96 : *---------------------------------------------------------------------*/
97 :
98 : /*! r: number of bits */
99 50503 : static Word16 calculate_bit_diff_fx(
100 : Word16 *in_diff, /* i : values to be encoded */
101 : Word16 len, /* i : number of params */
102 : Word16 *flag_diff /* o : selected GR order */
103 : )
104 : {
105 : Word16 i, nb, nb1;
106 :
107 50503 : nb = 0;
108 50503 : move16();
109 50503 : nb1 = 0;
110 50503 : move16();
111 421222 : FOR( i = 0; i < len; i++ )
112 : {
113 370719 : nb = add( nb, in_diff[i] );
114 370719 : nb1 = add( nb1, shr( in_diff[i], 1 ) );
115 : }
116 50503 : nb = add( nb, len );
117 50503 : nb1 = add( nb1, imult1616( 2, len ) );
118 :
119 50503 : IF( LT_16( nb1, nb ) )
120 : {
121 5414 : nb = add( nb1, 1 );
122 5414 : *flag_diff = 1; /* GR order for differential coding */
123 5414 : move16();
124 : }
125 : ELSE
126 : {
127 45089 : nb = add( nb, 1 );
128 45089 : *flag_diff = 0;
129 45089 : move16();
130 : }
131 :
132 50503 : return nb;
133 : }
134 :
135 :
136 : /*---------------------------------------------------------------------*
137 : * adapt_GR_ief_fx()
138 : *
139 : * adaptive GR coding considering also the differential case
140 : *---------------------------------------------------------------------*/
141 :
142 : /*! r: used GR order */
143 45085 : Word16 adapt_GR_ief_fx(
144 : const Word16 *in, /* i : vector to encode */
145 : Word16 *in_diff, /* o : encoded symbols in case of differential encoding */
146 : const Word16 *prev, /* i : previous frame data */
147 : const Word16 len, /* i : input vector length */
148 : const Word16 no_symb, /* i : number of symbols */
149 : Word16 *nbits, /* o : number of used bits */
150 : Word16 *in_enc, /* o : symbold actually encoded after adapt_GR */
151 : const Word16 *map0, /* i : mapping array */
152 : const Word16 no_GR_ord, /* i : number of GR order to try 2: 0,1; 3:0,1,2 */
153 : Word16 *nbits_diff, /* o : number bits in diff encoding */
154 : const Word16 side_gain_counter, /* i : number of frames since last abs coding */
155 : Word16 *side_gain_bitdiff_lp, /* i/o: LP-filtered bit difference between abs/diff Q(q_side_gain_bitdiff_lp) */
156 : Word16 *q_side_gain_bitdiff_lp, /* i/o: Q of LP-filtered bit difference between abs/diff */
157 : const Word16 try_diff /* i : diff coding allowed 1/0 */
158 : )
159 : {
160 : Word16 nb_diff, flag, flag_diff;
161 : Word16 bitdiff;
162 : Word32 L_tmp, L_tmp1;
163 : Word16 exp_diff;
164 :
165 45085 : flag = adapt_GR_sg_fx( in, len, no_symb, nbits, in_enc, map0, no_GR_ord );
166 :
167 45085 : IF( try_diff ) /* inter-frame prediction allowed */
168 : {
169 10428 : calculate_diff_fx( in, prev, in_diff, len );
170 10428 : nb_diff = calculate_bit_diff_fx( in_diff, len, &flag_diff );
171 10428 : *nbits_diff = nb_diff;
172 10428 : move16();
173 :
174 10428 : bitdiff = sub( s_min( imult1616( 5, len ), *nbits ), add( nb_diff, 1 ) );
175 10428 : L_tmp = Mpy_32_16_1( STEREO_DFT_BITDIFF_LP_FAC_Q31, bitdiff ); // (Q31, Q0) -> Q16
176 10428 : L_tmp1 = Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_DFT_BITDIFF_LP_FAC_Q31 ), *side_gain_bitdiff_lp ); // (Q31, *q_side_gain_bitdiff_lp) -> *q_side_gain_bitdiff_lp + Q16
177 10428 : *side_gain_bitdiff_lp = extract_h( BASOP_Util_Add_Mant32Exp( L_tmp, Q31 - Q16, L_tmp1, sub( Q31, add( *q_side_gain_bitdiff_lp, Q16 ) ), &exp_diff ) );
178 10428 : *q_side_gain_bitdiff_lp = sub( Q15, exp_diff );
179 10428 : move16();
180 :
181 10428 : L_tmp = Mpy_32_16_1( STEREO_DFT_BITDIFF_ABS_SELECT_Q31, *side_gain_bitdiff_lp ); // (Q31, *q_side_gain_bitdiff_lp) -> *q_side_gain_bitdiff_lp + Q16
182 10428 : L_tmp1 = Mpy_32_16_1( STEREO_DFT_FEC_THRESHOLD_PLUS_1_INV_Q31, side_gain_counter ); // (Q31, Q0) -> Q16
183 10428 : L_tmp = Mpy_32_32( L_tmp, L_tmp1 ); // (*q_side_gain_bitdiff_lp + Q16, Q16) -> *q_side_gain_bitdiff_lp + Q1
184 10428 : IF( GT_64( W_shl( W_deposit32_l( L_deposit_l( bitdiff ) ), add( *q_side_gain_bitdiff_lp, Q1 ) ), W_deposit32_l( L_tmp ) ) )
185 : {
186 8836 : flag = add( no_GR_ord, flag_diff );
187 8836 : *nbits = add( nb_diff, 1 );
188 8836 : move16();
189 : }
190 : }
191 : ELSE
192 : {
193 34657 : *nbits_diff = 100;
194 34657 : move16();
195 34657 : flag_diff = -1;
196 34657 : move16();
197 : }
198 :
199 45085 : return flag;
200 : }
201 :
202 :
203 : /*---------------------------------------------------------------------*
204 : * adapt_GR_rpg1_ief_fx()
205 : *
206 : * use adaptive GR for RPG's considering also the differential case
207 : *---------------------------------------------------------------------*/
208 :
209 : /*! r: used GR order */
210 42026 : Word16 adapt_GR_rpg1_ief_fx(
211 : const Word16 *in, /* i : res pred gains input vector */
212 : Word16 *in_diff, /* o : encoded symbols in case of differential encoding */
213 : const Word16 *prev, /* i : previous frame data */
214 : const Word16 len, /* i : input vector length */
215 : const Word16 no_symb, /* i : number of symbols */
216 : Word16 *nbits, /* o : number of used bits */
217 : Word16 *in_enc, /* o : symbold actually encoded after adapt_GR */
218 : const Word16 *maps, /* i : mapping array */
219 : Word16 *nbits_diff, /* o : estimated no of bits for differential encoding */
220 : const Word16 no_GR_ord, /* i : number of GR order to try 2: 0,1; 3:0,1,2 */
221 : const Word16 try_diff /* i : diff coding allowed 1/0 */
222 : )
223 : {
224 : const Word16 *map0;
225 : Word16 s, i, GR_ord, flag_diff, nb_diff;
226 :
227 42026 : map0 = &maps[8 * NO_SYMB_GR_PRED_G];
228 :
229 42026 : IF( in[0] == 0 )
230 : {
231 2412 : s = 0;
232 2412 : move16();
233 18825 : FOR( i = 0; i < len; i++ )
234 : {
235 16413 : s = add( s, in[i] );
236 : }
237 :
238 2412 : IF( s == 0 )
239 : {
240 : /* encode only the first zero with GR1 */
241 1081 : *nbits = add( shr( map0[0], 1 ), 2 );
242 1081 : move16();
243 1081 : in_enc[0] = map0[0];
244 1081 : move16();
245 : }
246 : ELSE
247 : {
248 1331 : *nbits = 1000; /* large number such that the plain coding will be selected */
249 1331 : move16();
250 : }
251 2412 : GR_ord = 1;
252 2412 : move16();
253 : }
254 : ELSE
255 : {
256 39614 : GR_ord = adapt_GR_sg_fx( in, len, no_symb, nbits, in_enc, maps, no_GR_ord );
257 : }
258 :
259 42026 : IF( try_diff )
260 : {
261 40075 : calculate_diff_fx( in, prev, in_diff, len );
262 40075 : nb_diff = calculate_bit_diff_fx( in_diff, len, &flag_diff );
263 40075 : *nbits_diff = nb_diff;
264 40075 : move16();
265 :
266 40075 : IF( LT_16( add( nb_diff, 1 ), *nbits ) ) /* there is one more bit to signal differential coding */
267 : {
268 30976 : GR_ord = add( no_GR_ord, flag_diff );
269 :
270 30976 : *nbits = add( nb_diff, 1 );
271 30976 : move16();
272 : }
273 : }
274 : ELSE
275 : {
276 1951 : *nbits_diff = 100;
277 1951 : move16();
278 : }
279 :
280 42026 : return GR_ord;
281 : }
282 :
283 :
284 : /*---------------------------------------------------------------------*
285 : * adapt_GR_sg_fx()
286 : *
287 : * adaptive GR coding
288 : *---------------------------------------------------------------------*/
289 :
290 : /*! r: GR order */
291 84699 : static Word16 adapt_GR_sg_fx(
292 : const Word16 *in, /* i : data to be encoded */
293 : const Word16 len, /* i : number of params to be encoded */
294 : const Word16 no_symb, /* i : max number of symbols */
295 : Word16 *nbits, /* o : estimated number of bits */
296 : Word16 *in_enc, /* o : mapped symbols */
297 : const Word16 *map0, /* i : mapping */
298 : const Word16 no_GR_ord /* i : number of GR orders to be tested (2 or 3)*/
299 : )
300 : {
301 : const Word16 *map;
302 : Word16 nbits0, nbits1, nbits2, symb, map_symb, i, nb0, nb1, nb2;
303 :
304 84699 : IF( EQ_16( no_symb, NO_SYMB_GR_SIDE_G ) )
305 : {
306 45085 : map = &map0[imult1616( 15, no_symb )];
307 : }
308 : ELSE
309 : {
310 39614 : map = &( map0[imult1616( 8, no_symb )] );
311 : }
312 :
313 84699 : set_s( in_enc, 0, len );
314 :
315 84699 : nbits1 = 0;
316 84699 : move16();
317 84699 : nbits0 = 0;
318 84699 : move16();
319 84699 : nbits2 = 0;
320 84699 : move16();
321 :
322 784287 : FOR( i = 0; i < len; i++ )
323 : {
324 699588 : symb = in[i];
325 699588 : move16();
326 699588 : map_symb = map[symb];
327 699588 : move16();
328 :
329 699588 : IF( i == 0 )
330 : {
331 : /* GR order is 1 for first band*/
332 84699 : nb0 = add( shr( map_symb, 1 ), 1 );
333 84699 : nb2 = sub( nb0, 2 );
334 : }
335 : ELSE
336 : {
337 614889 : nb0 = map_symb;
338 614889 : move16();
339 614889 : nb2 = shr( map_symb, 2 );
340 : }
341 699588 : nb1 = shr( map_symb, 1 );
342 :
343 699588 : in_enc[i] = map_symb;
344 699588 : move16();
345 699588 : nbits0 = add( nbits0, nb0 );
346 699588 : nbits1 = add( nbits1, nb1 );
347 699588 : nbits2 = add( nbits2, nb2 );
348 :
349 : /* update counts */
350 699588 : map = &( map0[imult1616( symb, no_symb )] );
351 : }
352 :
353 84699 : IF( EQ_16( no_GR_ord, 2 ) )
354 : {
355 39614 : nbits0 = add( nbits0, add( len, 1 ) );
356 39614 : nbits1 = add( nbits1, add( imult1616( 2, len ), 1 ) );
357 39614 : IF( LE_16( nbits0, nbits1 ) )
358 : {
359 21256 : *nbits = nbits0;
360 21256 : move16();
361 21256 : return 0;
362 : }
363 : ELSE
364 : {
365 18358 : *nbits = nbits1;
366 18358 : move16();
367 18358 : return 1;
368 : }
369 : }
370 : ELSE
371 : {
372 45085 : IF( EQ_16( no_GR_ord, 3 ) )
373 : {
374 45085 : nbits0 = add( nbits0, add( len, 2 ) );
375 45085 : nbits1 = add( nbits1, add( imult1616( 2, len ), 1 ) );
376 45085 : nbits2 = add( nbits2, add( imult1616( 3, len ), 2 ) );
377 :
378 45085 : test();
379 45085 : IF( LE_16( nbits1, nbits2 ) && LE_16( nbits1, nbits0 ) )
380 : {
381 28110 : *nbits = nbits1;
382 28110 : move16();
383 28110 : return 1;
384 : }
385 :
386 16975 : test();
387 16975 : IF( LE_16( nbits0, nbits2 ) && LE_16( nbits0, nbits1 ) )
388 : {
389 11836 : *nbits = nbits0;
390 11836 : move16();
391 11836 : return 0;
392 : }
393 :
394 5139 : test();
395 5139 : IF( LE_16( nbits2, nbits0 ) && LE_16( nbits2, nbits1 ) )
396 : {
397 5139 : *nbits = nbits2;
398 5139 : move16();
399 5139 : return 2;
400 : }
401 : }
402 : ELSE
403 : {
404 0 : IVAS_ERROR( IVAS_ERR_INTERNAL, "Wrong number of GR orders!" );
405 : }
406 : }
407 :
408 0 : return -1;
409 : }
410 :
411 :
412 : /*---------------------------------------------------------------------*
413 : * write_GR0_fx()
414 : *
415 : * write data with GR order 0
416 : *---------------------------------------------------------------------*/
417 :
418 : /*! r: number of bits written */
419 62151 : Word16 write_GR0_fx(
420 : BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
421 : const Word16 ind, /* i : bitstream index */
422 : const Word16 *in, /* i : data to be encoded */
423 : const Word16 len /* i : input data length */
424 : )
425 : {
426 : Word16 nb, i, n, val;
427 62151 : nb = 0;
428 62151 : move16();
429 :
430 472287 : FOR( i = 0; i < len; i++ )
431 : {
432 410136 : n = add( in[i], 1 );
433 :
434 410136 : IF( LT_16( n, 16 ) )
435 : {
436 410135 : val = sub( shl( 1, in[i] ), 1 );
437 410135 : val = shl( val, 1 );
438 410135 : push_indice( hBstr, ind, val, n );
439 : }
440 : ELSE
441 : {
442 1 : push_indice( hBstr, ind, 16383, 14 );
443 1 : push_indice( hBstr, ind, sub( shl( 1, sub( n, 15 ) ), 1 ), sub( n, 15 ) );
444 1 : push_indice( hBstr, ind, 0, 1 );
445 : }
446 410136 : nb = add( nb, n );
447 : }
448 :
449 62151 : return nb;
450 : }
451 :
452 :
453 : /*---------------------------------------------------------------------*
454 : * write_GR1_fx()
455 : *
456 : * write data with GR order 1
457 : *---------------------------------------------------------------------*/
458 :
459 : /*! r: number of bits written */
460 68775 : Word16 write_GR1_fx(
461 : BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
462 : const Word16 ind, /* i : bitstream index */
463 : const Word16 *in, /* i : data to be encoded */
464 : const Word16 len /* i : input data length */
465 : )
466 : {
467 : Word16 nb, i, n, val;
468 68775 : nb = 0;
469 68775 : move16();
470 :
471 328985 : FOR( i = 0; i < len; i++ )
472 : {
473 260210 : n = shr( in[i], 1 );
474 260210 : IF( LT_16( n, 14 ) )
475 : {
476 260050 : val = sub( shl( 1, n ), 1 );
477 260050 : val = add( shl( val, 2 ), s_and( in[i], 1 ) );
478 260050 : push_indice( hBstr, ind, val, add( n, 2 ) );
479 : }
480 : ELSE
481 : {
482 160 : push_indice( hBstr, ind, 16383, 14 );
483 160 : IF( GT_16( n, 14 ) )
484 : {
485 1 : push_indice( hBstr, ind, sub( shl( 1, sub( n, 14 ) ), 1 ), sub( n, 14 ) ); /* 1 n times */
486 : }
487 160 : push_indice( hBstr, ind, 0, 1 );
488 160 : push_indice( hBstr, ind, s_and( in[i], 1 ), 1 );
489 : }
490 260210 : nb = add( nb, add( n, 2 ) );
491 : }
492 :
493 68775 : return nb;
494 : }
495 :
496 :
497 : /*---------------------------------------------------------------------*
498 : * write_GR2_fx()
499 : *
500 : * write data with GR order 2
501 : *---------------------------------------------------------------------*/
502 :
503 : /*! r: number of bits written */
504 2789 : static Word16 write_GR2_fx(
505 : BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */
506 : const Word16 ind, /* i : bitstream index */
507 : const Word16 *in, /* i : data to be encoded */
508 : const Word16 len /* i : input data length */
509 : )
510 : {
511 : Word16 nb, i, n;
512 2789 : nb = 0;
513 2789 : move16();
514 :
515 25748 : FOR( i = 0; i < len; i++ )
516 : {
517 22959 : n = shr( in[i], 2 );
518 22959 : IF( LT_16( n, 14 ) )
519 : {
520 22959 : IF( n > 0 )
521 : {
522 12935 : push_indice( hBstr, ind, sub( shl( 1, n ), 1 ), n ); /* 1 n times */
523 : }
524 22959 : push_indice( hBstr, ind, 0, 1 );
525 22959 : push_indice( hBstr, ind, s_and( in[i], 3 ), 2 );
526 : }
527 : ELSE
528 : {
529 0 : push_indice( hBstr, ind, 16383, 14 );
530 0 : IF( GT_16( n, 14 ) )
531 : {
532 0 : push_indice( hBstr, ind, sub( shl( 1, sub( n, 14 ) ), 1 ), sub( n, 14 ) ); /* 1 n times */
533 : }
534 0 : push_indice( hBstr, ind, 0, 1 );
535 0 : push_indice( hBstr, ind, s_and( in[i], 3 ), 2 );
536 : }
537 22959 : nb = add( nb, add( n, 3 ) );
538 : }
539 :
540 2789 : return nb;
541 : }
542 :
543 :
544 : /*---------------------------------------------------------------------*
545 : * write_bitstream_GR_fx()
546 : *
547 : * generic GR encoder for GR order 0 or 1
548 : *---------------------------------------------------------------------*/
549 :
550 : /*! r: number of bits written */
551 39094 : Word16 write_bitstream_GR_fx(
552 : BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
553 : const Word16 ind, /* i : bitstream index */
554 : const Word16 *in, /* i : input vector */
555 : const Word16 len, /* i : input vector length */
556 : const Word16 GR_ord /* i : GR order */
557 : )
558 : {
559 : Word16 nb;
560 39094 : nb = 0;
561 39094 : move16();
562 :
563 39094 : push_indice( hBstr, ind, GR_ord, 1 );
564 39094 : nb = add( nb, 1 );
565 :
566 39094 : IF( GR_ord == 0 )
567 : {
568 38413 : nb = add( nb, write_GR0_fx( hBstr, ind, in, len ) );
569 : }
570 : ELSE
571 : {
572 681 : nb = add( nb, write_GR1_fx( hBstr, ind, in, len ) );
573 : }
574 :
575 39094 : return nb;
576 : }
577 :
578 :
579 : /*---------------------------------------------------------------------*
580 : * write_bitstream_adapt_GR_fx()
581 : *
582 : * write encoded data using adaptive GR
583 : *---------------------------------------------------------------------*/
584 :
585 : /*! r: number of bits written */
586 42604 : Word16 write_bitstream_adapt_GR_fx(
587 : BSTR_ENC_HANDLE hBstr, /* i/o: Encoder bitstream handle */
588 : const Word16 ind, /* i : bitstream index */
589 : const Word16 *in, /* i : values to be written in bitstream */
590 : const Word16 len, /* i : values vector length */
591 : const Word16 GR_ord, /* i : GR order to be used */
592 : const Word16 no_GR_ord /* i : speech/music 0/1 */
593 : )
594 : {
595 : Word16 nb;
596 :
597 42604 : nb = 0;
598 42604 : move16();
599 : /* first component first */
600 42604 : nb = add( nb, write_GR1_fx( hBstr, ind, in, 1 ) );
601 :
602 : /* write the GR order */
603 42604 : IF( EQ_16( no_GR_ord, 2 ) )
604 : {
605 7426 : push_indice( hBstr, ind, GR_ord, 1 );
606 7426 : nb = add( nb, 1 );
607 : }
608 : ELSE
609 : {
610 35178 : IF( EQ_16( GR_ord, 1 ) )
611 : {
612 23314 : push_indice( hBstr, ind, 0, 1 ); /* GR order = 1*/
613 23314 : nb = add( nb, 1 );
614 : }
615 : ELSE
616 : {
617 11864 : push_indice( hBstr, ind, 1, 1 );
618 11864 : push_indice( hBstr, ind, shr( GR_ord, 1 ), 1 ); /* '10' for GR ord = 0; '11' for GR ord 2 */
619 11864 : nb = add( nb, 2 );
620 : }
621 : }
622 :
623 42604 : IF( GR_ord == 0 )
624 : {
625 15300 : nb = add( nb, write_GR0_fx( hBstr, ind, &in[1], sub( len, 1 ) ) );
626 : }
627 : ELSE
628 : {
629 27304 : IF( EQ_16( GR_ord, 1 ) )
630 : {
631 24515 : nb = add( nb, write_GR1_fx( hBstr, ind, &in[1], sub( len, 1 ) ) );
632 : }
633 : ELSE
634 : {
635 2789 : nb = add( nb, write_GR2_fx( hBstr, ind, &in[1], sub( len, 1 ) ) );
636 : }
637 : }
638 :
639 42604 : return nb;
640 : }
|