OpenCores
URL https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [test/] [decoder/] [ldecod/] [src/] [vlc.c] - Blame information for rev 100

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jamey.hick
 
2
/*!
3
 ************************************************************************
4
 * \file vlc.c
5
 *
6
 * \brief
7
 *    VLC support functions
8
 *
9
 * \author
10
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
11
 *    - Inge Lille-Langøy               <inge.lille-langoy@telenor.com>
12
 *    - Detlev Marpe                    <marpe@hhi.de>
13
 *    - Gabi Blaettermann               <blaetter@hhi.de>
14
 ************************************************************************
15
 */
16
#include "contributors.h"
17
 
18
#include <stdlib.h>
19
#include <math.h>
20
#include <string.h>
21
#include <assert.h>
22
 
23
#include "global.h"
24
#include "vlc.h"
25
#include "elements.h"
26
 
27
 
28
// A little trick to avoid those horrible #if TRACE all over the source code
29
#if TRACE
30
#define SYMTRACESTRING(s) strncpy(symbol.tracestring,s,TRACESTRING_SIZE)
31
#else
32
#define SYMTRACESTRING(s) // do nothing
33
#endif
34
 
35
extern void tracebits(const char *trace_str,  int len,  int info,int value1);
36
 
37
 
38
int UsedBits;      // for internal statistics, is adjusted by se_v, ue_v, u_1
39
 
40
// Note that all NA values are filled with 0
41
 
42
//! for the linfo_levrun_inter routine
43
const byte NTAB1[4][8][2] =
44
{
45
  {{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
46
  {{1,1},{1,2},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
47
  {{2,0},{1,3},{1,4},{1,5},{0,0},{0,0},{0,0},{0,0}},
48
  {{3,0},{2,1},{2,2},{1,6},{1,7},{1,8},{1,9},{4,0}},
49
};
50
const byte LEVRUN1[16]=
51
{
52
  4,2,2,1,1,1,1,1,1,1,0,0,0,0,0,0,
53
};
54
 
55
 
56
const byte NTAB2[4][8][2] =
57
{
58
  {{1,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
59
  {{1,1},{2,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}},
60
  {{1,2},{3,0},{4,0},{5,0},{0,0},{0,0},{0,0},{0,0}},
61
  {{1,3},{1,4},{2,1},{3,1},{6,0},{7,0},{8,0},{9,0}},
62
};
63
 
64
//! for the linfo_levrun__c2x2 routine
65
const byte LEVRUN3[4] =
66
{
67
  2,1,0,0
68
};
69
const byte NTAB3[2][2][2] =
70
{
71
  {{1,0},{0,0}},
72
  {{2,0},{1,1}},
73
};
74
 
75
/*!
76
 *************************************************************************************
77
 * \brief
78
 *    ue_v, reads an ue(v) syntax element, the length in bits is stored in
79
 *    the global UsedBits variable
80
 *
81
 * \param tracestring
82
 *    the string for the trace file
83
 *
84
 * \param bitstream
85
 *    the stream to be read from
86
 *
87
 * \return
88
 *    the value of the coded syntax element
89
 *
90
 *************************************************************************************
91
 */
92
int ue_v (char *tracestring, Bitstream *bitstream)
93
{
94
  SyntaxElement symbol;
95
 
96
  assert (bitstream->streamBuffer != NULL);
97
  symbol.type = SE_HEADER;
98
  symbol.mapping = linfo_ue;   // Mapping rule
99
  SYMTRACESTRING(tracestring);
100
  readSyntaxElement_VLC (&symbol, bitstream);
101
  UsedBits+=symbol.len;
102
  return symbol.value1;
103
}
104
 
105
 
106
/*!
107
 *************************************************************************************
108
 * \brief
109
 *    ue_v, reads an se(v) syntax element, the length in bits is stored in
110
 *    the global UsedBits variable
111
 *
112
 * \param tracestring
113
 *    the string for the trace file
114
 *
115
 * \param bitstream
116
 *    the stream to be read from
117
 *
118
 * \return
119
 *    the value of the coded syntax element
120
 *
121
 *************************************************************************************
122
 */
123
int se_v (char *tracestring, Bitstream *bitstream)
124
{
125
  SyntaxElement symbol;
126
 
127
  assert (bitstream->streamBuffer != NULL);
128
  symbol.type = SE_HEADER;
129
  symbol.mapping = linfo_se;   // Mapping rule: signed integer
130
  SYMTRACESTRING(tracestring);
131
  readSyntaxElement_VLC (&symbol, bitstream);
132
  UsedBits+=symbol.len;
133
  return symbol.value1;
134
}
135
 
136
 
137
/*!
138
 *************************************************************************************
139
 * \brief
140
 *    ue_v, reads an u(v) syntax element, the length in bits is stored in
141
 *    the global UsedBits variable
142
 *
143
 * \param LenInBits
144
 *    length of the syntax element
145
 *
146
 * \param tracestring
147
 *    the string for the trace file
148
 *
149
 * \param bitstream
150
 *    the stream to be read from
151
 *
152
 * \return
153
 *    the value of the coded syntax element
154
 *
155
 *************************************************************************************
156
 */
157
int u_v (int LenInBits, char*tracestring, Bitstream *bitstream)
158
{
159
  SyntaxElement symbol;
160
  symbol.inf = 0;
161
 
162
  assert (bitstream->streamBuffer != NULL);
163
  symbol.type = SE_HEADER;
164
  symbol.mapping = linfo_ue;   // Mapping rule
165
  symbol.len = LenInBits;
166
  SYMTRACESTRING(tracestring);
167
  readSyntaxElement_FLC (&symbol, bitstream);
168
  UsedBits+=symbol.len;
169
  return symbol.inf;
170
}
171
 
172
 
173
/*!
174
 *************************************************************************************
175
 * \brief
176
 *    ue_v, reads an u(1) syntax element, the length in bits is stored in
177
 *    the global UsedBits variable
178
 *
179
 * \param tracestring
180
 *    the string for the trace file
181
 *
182
 * \param bitstream
183
 *    the stream to be read from
184
 *
185
 * \return
186
 *    the value of the coded syntax element
187
 *
188
 *************************************************************************************
189
 */
190
Boolean u_1 (char *tracestring, Bitstream *bitstream)
191
{
192
  return (Boolean) u_v (1, tracestring, bitstream);
193
}
194
 
195
 
196
 
197
/*!
198
 ************************************************************************
199
 * \brief
200
 *    mapping rule for ue(v) syntax elements
201
 * \par Input:
202
 *    lenght and info
203
 * \par Output:
204
 *    number in the code table
205
 ************************************************************************
206
 */
207
void linfo_ue(int len, int info, int *value1, int *dummy)
208
{
209
  assert ((len>>1)<32);
210
  *value1 = (1<<(len>>1))+info-1;
211
}
212
 
213
/*!
214
 ************************************************************************
215
 * \brief
216
 *    mapping rule for se(v) syntax elements
217
 * \par Input:
218
 *    lenght and info
219
 * \par Output:
220
 *    signed mvd
221
 ************************************************************************
222
 */
223
void linfo_se(int len,  int info, int *value1, int *dummy)
224
{
225
  int n;
226
  assert ((len>>1)<32);
227
  n = (1 << (len>>1))+info-1;
228
  *value1 = (n+1)>>1;
229
  if((n & 0x01)==0)                           // lsb is signed bit
230
    *value1 = -*value1;
231
}
232
 
233
 
234
/*!
235
 ************************************************************************
236
 * \par Input:
237
 *    length and info
238
 * \par Output:
239
 *    cbp (intra)
240
 ************************************************************************
241
 */
242
void linfo_cbp_intra(int len,int info,int *cbp, int *dummy)
243
{
244
  extern const byte NCBP[2][48][2];
245
  int cbp_idx;
246
 
247
  linfo_ue(len,info,&cbp_idx,dummy);
248
  *cbp=NCBP[active_sps->chroma_format_idc?1:0][cbp_idx][0];
249
}
250
 
251
/*!
252
 ************************************************************************
253
 * \par Input:
254
 *    length and info
255
 * \par Output:
256
 *    cbp (inter)
257
 ************************************************************************
258
 */
259
void linfo_cbp_inter(int len,int info,int *cbp, int *dummy)
260
{
261
  extern const byte NCBP[2][48][2];
262
  int cbp_idx;
263
 
264
  linfo_ue(len,info,&cbp_idx,dummy);
265
  *cbp=NCBP[active_sps->chroma_format_idc?1:0][cbp_idx][1];
266
}
267
 
268
/*!
269
 ************************************************************************
270
 * \par Input:
271
 *    length and info
272
 * \par Output:
273
 *    level, run
274
 ************************************************************************
275
 */
276
void linfo_levrun_inter(int len, int info, int *level, int *irun)
277
{
278
  int l2;
279
  int inf;
280
  assert (((len>>1)-5)<32);
281
  if (len<=9)
282
  {
283
    l2=imax(0,(len>>1)-1);
284
    inf=info>>1;
285
    *level=NTAB1[l2][inf][0];
286
    *irun=NTAB1[l2][inf][1];
287
    if ((info&0x01)==1)
288
      *level=-*level;                   // make sign
289
  }
290
  else                                  // if len > 9, skip using the array
291
  {
292
    *irun=(info&0x1e)>>1;
293
    *level = LEVRUN1[*irun] + (info>>5) + ( 1<< ((len>>1) - 5));
294
    if ((info&0x01)==1)
295
      *level=-*level;
296
  }
297
    if (len == 1) // EOB
298
        *level = 0;
299
}
300
 
301
 
302
/*!
303
 ************************************************************************
304
 * \par Input:
305
 *    length and info
306
 * \par Output:
307
 *    level, run
308
 ************************************************************************
309
 */
310
void linfo_levrun_c2x2(int len, int info, int *level, int *irun)
311
{
312
  int l2;
313
  int inf;
314
 
315
  if (len<=5)
316
  {
317
    l2=imax(0,(len>>1)-1);
318
    inf=info>>1;
319
    *level=NTAB3[l2][inf][0];
320
    *irun=NTAB3[l2][inf][1];
321
    if ((info&0x01)==1)
322
      *level=-*level;                 // make sign
323
  }
324
  else                                  // if len > 5, skip using the array
325
  {
326
    *irun=(info&0x06)>>1;
327
    *level = LEVRUN3[*irun] + (info>>3) + (1 << ((len>>1) - 3));
328
    if ((info&0x01)==1)
329
      *level=-*level;
330
  }
331
  if (len == 1) // EOB
332
    *level = 0;
333
}
334
 
335
/*!
336
 ************************************************************************
337
 * \brief
338
 *    read next UVLC codeword from UVLC-partition and
339
 *    map it to the corresponding syntax element
340
 ************************************************************************
341
 */
342
int readSyntaxElement_VLC(SyntaxElement *sym, Bitstream *currStream)
343
{
344
  int frame_bitoffset = currStream->frame_bitoffset;
345
  byte *buf = currStream->streamBuffer;
346
  int BitstreamLengthInBytes = currStream->bitstream_length;
347
 
348
  sym->len =  GetVLCSymbol (buf, frame_bitoffset, &(sym->inf), BitstreamLengthInBytes);
349
  if (sym->len == -1)
350
    return -1;
351
  currStream->frame_bitoffset += sym->len;
352
  sym->mapping(sym->len,sym->inf,&(sym->value1),&(sym->value2));
353
 
354
#if TRACE
355
  tracebits(sym->tracestring, sym->len, sym->inf, sym->value1);
356
#endif
357
 
358
  return 1;
359
}
360
 
361
 
362
/*!
363
 ************************************************************************
364
 * \brief
365
 *    read next UVLC codeword from UVLC-partition and
366
 *    map it to the corresponding syntax element
367
 ************************************************************************
368
 */
369
int readSyntaxElement_UVLC(SyntaxElement *sym, struct img_par *img, struct datapartition *dP)
370
{
371
  Bitstream   *currStream = dP->bitstream;
372
 
373
  return (readSyntaxElement_VLC(sym, currStream));
374
}
375
 
376
/*!
377
 ************************************************************************
378
 * \brief
379
 *    read next VLC codeword for 4x4 Intra Prediction Mode and
380
 *    map it to the corresponding Intra Prediction Direction
381
 ************************************************************************
382
 */
383
int readSyntaxElement_Intra4x4PredictionMode(SyntaxElement *sym, struct img_par *img,struct datapartition *dP)
384
{
385
  Bitstream   *currStream            = dP->bitstream;
386
  int         frame_bitoffset        = currStream->frame_bitoffset;
387
  byte        *buf                   = currStream->streamBuffer;
388
  int         BitstreamLengthInBytes = currStream->bitstream_length;
389
 
390
  sym->len = GetVLCSymbol_IntraMode (buf, frame_bitoffset, &(sym->inf), BitstreamLengthInBytes);
391
 
392
  if (sym->len == -1)
393
    return -1;
394
 
395
  currStream->frame_bitoffset += sym->len;
396
  sym->value1                  = sym->len == 1 ? -1 : sym->inf;
397
 
398
#if TRACE
399
  tracebits2(sym->tracestring, sym->len, sym->value1);
400
#endif
401
 
402
  return 1;
403
}
404
 
405
int GetVLCSymbol_IntraMode (byte buffer[],int totbitoffset,int *info, int bytecount)
406
{
407
 
408
  register int inf;
409
  long byteoffset;      // byte from start of buffer
410
  int bitoffset;      // bit from start of byte
411
  int ctr_bit=0;      // control bit for current bit posision
412
  int bitcounter=1;
413
  int len;
414
  int info_bit;
415
 
416
  byteoffset = totbitoffset>>3;
417
  bitoffset  = 7-(totbitoffset&0x07);
418
  ctr_bit    = (buffer[byteoffset] & (0x01<<bitoffset));   // set up control bit
419
  len        = 1;
420
 
421
  //First bit
422
  if (ctr_bit)
423
  {
424
    *info = 0;
425
    return bitcounter;
426
  }
427
  else
428
    len=4;
429
 
430
  // make infoword
431
  inf=0;                          // shortest possible code is 1, then info is always 0
432
  for(info_bit=0;(info_bit<(len-1)); info_bit++)
433
  {
434
    bitcounter++;
435
    bitoffset-=1;
436
    if (bitoffset<0)
437
    {                 // finished with current byte ?
438
      bitoffset=bitoffset+8;
439
      byteoffset++;
440
    }
441
    if (byteoffset > bytecount)
442
    {
443
      return -1;
444
    }
445
    inf=(inf<<1);
446
    if(buffer[byteoffset] & (0x01<<(bitoffset)))
447
      inf |=1;
448
  }
449
 
450
  *info = inf;
451
  return bitcounter;           // return absolute offset in bit from start of frame
452
}
453
 
454
 
455
/*!
456
 ************************************************************************
457
 * \brief
458
 *    test if bit buffer contains only stop bit
459
 *
460
 * \param buffer
461
 *    buffer containing VLC-coded data bits
462
 * \param totbitoffset
463
 *    bit offset from start of partition
464
 * \param bytecount
465
 *    buffer length
466
 * \return
467
 *    true if more bits available
468
 ************************************************************************
469
 */
470
int more_rbsp_data (byte buffer[],int totbitoffset,int bytecount)
471
{
472
 
473
  long byteoffset;      // byte from start of buffer
474
  int bitoffset;      // bit from start of byte
475
  int ctr_bit=0;      // control bit for current bit posision
476
 
477
  int cnt=0;
478
 
479
 
480
  byteoffset= totbitoffset>>3;
481
  bitoffset= 7-(totbitoffset&0x07);
482
 
483
  assert (byteoffset<bytecount);
484
 
485
  // there is more until we're in the last byte
486
  if (byteoffset<(bytecount-1)) return TRUE;
487
 
488
  // read one bit
489
  ctr_bit = (buffer[byteoffset] & (0x01<<bitoffset));
490
 
491
  // a stop bit has to be one
492
  if (ctr_bit==0) return TRUE;
493
 
494
  bitoffset--;
495
 
496
  while (bitoffset>=0)
497
  {
498
    ctr_bit = (buffer[byteoffset] & (0x01<<bitoffset));   // set up control bit
499
    if (ctr_bit>0) cnt++;
500
    bitoffset--;
501
  }
502
 
503
  return (0!=cnt);
504
 
505
}
506
 
507
 
508
/*!
509
 ************************************************************************
510
 * \brief
511
 *    Check if there are symbols for the next MB
512
 ************************************************************************
513
 */
514
int uvlc_startcode_follows(struct img_par *img, int dummy)
515
{
516
  int dp_Nr = assignSE2partition[img->currentSlice->dp_mode][SE_MBTYPE];
517
  DataPartition *dP = &(img->currentSlice->partArr[dp_Nr]);
518
  Bitstream   *currStream = dP->bitstream;
519
  byte *buf = currStream->streamBuffer;
520
 
521
  //KS: new function test for End of Buffer
522
  return (!(more_rbsp_data(buf, currStream->frame_bitoffset,currStream->bitstream_length)));
523
}
524
 
525
 
526
 
527
/*!
528
 ************************************************************************
529
 * \brief
530
 *  read one exp-golomb VLC symbol
531
 *
532
 * \param buffer
533
 *    containing VLC-coded data bits
534
 * \param totbitoffset
535
 *    bit offset from start of partition
536
 * \param  info
537
 *    returns the value of the symbol
538
 * \param bytecount
539
 *    buffer length
540
 * \return
541
 *    bits read
542
 ************************************************************************
543
 */
544
int GetVLCSymbol (byte buffer[],int totbitoffset,int *info, int bytecount)
545
{
546
 
547
  register int inf;
548
  long byteoffset;      // byte from start of buffer
549
  int bitoffset;      // bit from start of byte
550
  int ctr_bit=0;      // control bit for current bit posision
551
  int bitcounter=1;
552
  int len;
553
  int info_bit;
554
 
555
  byteoffset= totbitoffset>>3;
556
  bitoffset= 7-(totbitoffset&0x07);
557
  ctr_bit = (buffer[byteoffset] & (0x01<<bitoffset));   // set up control bit
558
 
559
  len=1;
560
  while (ctr_bit==0)
561
  {                 // find leading 1 bit
562
    len++;
563
    bitoffset-=1;
564
    bitcounter++;
565
    if (bitoffset<0)
566
    {                 // finish with current byte ?
567
      bitoffset=bitoffset+8;
568
      byteoffset++;
569
    }
570
    ctr_bit=buffer[byteoffset] & (0x01<<(bitoffset));
571
  }
572
    // make infoword
573
  inf=0;                          // shortest possible code is 1, then info is always 0
574
  for(info_bit=0;(info_bit<(len-1)); info_bit++)
575
  {
576
    bitcounter++;
577
    bitoffset-=1;
578
    if (bitoffset<0)
579
    {                 // finished with current byte ?
580
      bitoffset=bitoffset+8;
581
      byteoffset++;
582
    }
583
    if (byteoffset > bytecount)
584
    {
585
      return -1;
586
    }
587
    inf=(inf<<1);
588
    if(buffer[byteoffset] & (0x01<<(bitoffset)))
589
      inf |=1;
590
  }
591
 
592
  *info = inf;
593
  return bitcounter;           // return absolute offset in bit from start of frame
594
}
595
 
596
extern void tracebits2(const char *trace_str,  int len,  int info) ;
597
 
598
/*!
599
 ************************************************************************
600
 * \brief
601
 *    code from bitstream (2d tables)
602
 ************************************************************************
603
 */
604
 
605
int code_from_bitstream_2d(SyntaxElement *sym,
606
                           DataPartition *dP,
607
                           const int *lentab,
608
                           const int *codtab,
609
                           int tabwidth,
610
                           int tabheight,
611
                           int *code)
612
{
613
  Bitstream   *currStream = dP->bitstream;
614
  int frame_bitoffset = currStream->frame_bitoffset;
615
  byte *buf = currStream->streamBuffer;
616
  int BitstreamLengthInBytes = currStream->bitstream_length;
617
 
618
  int i,j;
619
  int len, cod;
620
 
621
  // this VLC decoding method is not optimized for speed
622
  for (j = 0; j < tabheight; j++) {
623
    for (i = 0; i < tabwidth; i++)
624
    {
625
      len = lentab[i];
626
      if (!len)
627
        continue;
628
      cod = codtab[i];
629
 
630
      if ((ShowBits(buf, frame_bitoffset, BitstreamLengthInBytes, len) == cod))
631
      {
632
        sym->value1 = i;
633
        sym->value2 = j;
634
        currStream->frame_bitoffset += len; // move bitstream pointer
635
        sym->len = len;
636
        goto found_code;
637
      }
638
    }
639
    lentab += tabwidth;
640
    codtab += tabwidth;
641
  }
642
 
643
  return -1;  // failed to find code
644
 
645
found_code:
646
 
647
  *code = cod;
648
 
649
  return 0;
650
}
651
 
652
 
653
/*!
654
 ************************************************************************
655
 * \brief
656
 *    read FLC codeword from UVLC-partition
657
 ************************************************************************
658
 */
659
int readSyntaxElement_FLC(SyntaxElement *sym, Bitstream *currStream)
660
{
661
  int frame_bitoffset = currStream->frame_bitoffset;
662
  byte *buf = currStream->streamBuffer;
663
  int BitstreamLengthInBytes = currStream->bitstream_length;
664
 
665
  if ((GetBits(buf, frame_bitoffset, &(sym->inf), BitstreamLengthInBytes, sym->len)) < 0)
666
    return -1;
667
 
668
  currStream->frame_bitoffset += sym->len; // move bitstream pointer
669
  sym->value1 = sym->inf;
670
 
671
#if TRACE
672
  tracebits2(sym->tracestring, sym->len, sym->inf);
673
#endif
674
 
675
  return 1;
676
}
677
 
678
 
679
 
680
/*!
681
 ************************************************************************
682
 * \brief
683
 *    read NumCoeff/TrailingOnes codeword from UVLC-partition
684
 ************************************************************************
685
 */
686
 
687
int readSyntaxElement_NumCoeffTrailingOnes(SyntaxElement *sym,  DataPartition *dP,
688
                                           char *type)
689
{
690
  Bitstream   *currStream = dP->bitstream;
691
  int frame_bitoffset = currStream->frame_bitoffset;
692
  byte *buf = currStream->streamBuffer;
693
  int BitstreamLengthInBytes = currStream->bitstream_length;
694
 
695
  int vlcnum, retval;
696
  int code;
697
 
698
  static const int lentab[3][4][17] =
699
  {
700
    {   // 0702
701
      { 1, 6, 8, 9,10,11,13,13,13,14,14,15,15,16,16,16,16},
702
      { 0, 2, 6, 8, 9,10,11,13,13,14,14,15,15,15,16,16,16},
703
      { 0, 0, 3, 7, 8, 9,10,11,13,13,14,14,15,15,16,16,16},
704
      { 0, 0, 0, 5, 6, 7, 8, 9,10,11,13,14,14,15,15,16,16},
705
    },
706
    {
707
      { 2, 6, 6, 7, 8, 8, 9,11,11,12,12,12,13,13,13,14,14},
708
      { 0, 2, 5, 6, 6, 7, 8, 9,11,11,12,12,13,13,14,14,14},
709
      { 0, 0, 3, 6, 6, 7, 8, 9,11,11,12,12,13,13,13,14,14},
710
      { 0, 0, 0, 4, 4, 5, 6, 6, 7, 9,11,11,12,13,13,13,14},
711
    },
712
    {
713
      { 4, 6, 6, 6, 7, 7, 7, 7, 8, 8, 9, 9, 9,10,10,10,10},
714
      { 0, 4, 5, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 9,10,10,10},
715
      { 0, 0, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,10},
716
      { 0, 0, 0, 4, 4, 4, 4, 4, 5, 6, 7, 8, 8, 9,10,10,10},
717
    },
718
 
719
  };
720
 
721
  static const int codtab[3][4][17] =
722
  {
723
    {
724
      { 1, 5, 7, 7, 7, 7,15,11, 8,15,11,15,11,15,11, 7,4},
725
      { 0, 1, 4, 6, 6, 6, 6,14,10,14,10,14,10, 1,14,10,6},
726
      { 0, 0, 1, 5, 5, 5, 5, 5,13, 9,13, 9,13, 9,13, 9,5},
727
      { 0, 0, 0, 3, 3, 4, 4, 4, 4, 4,12,12, 8,12, 8,12,8},
728
    },
729
    {
730
      { 3,11, 7, 7, 7, 4, 7,15,11,15,11, 8,15,11, 7, 9,7},
731
      { 0, 2, 7,10, 6, 6, 6, 6,14,10,14,10,14,10,11, 8,6},
732
      { 0, 0, 3, 9, 5, 5, 5, 5,13, 9,13, 9,13, 9, 6,10,5},
733
      { 0, 0, 0, 5, 4, 6, 8, 4, 4, 4,12, 8,12,12, 8, 1,4},
734
    },
735
    {
736
      {15,15,11, 8,15,11, 9, 8,15,11,15,11, 8,13, 9, 5,1},
737
      { 0,14,15,12,10, 8,14,10,14,14,10,14,10, 7,12, 8,4},
738
      { 0, 0,13,14,11, 9,13, 9,13,10,13, 9,13, 9,11, 7,3},
739
      { 0, 0, 0,12,11,10, 9, 8,13,12,12,12, 8,12,10, 6,2},
740
    },
741
  };
742
 
743
  vlcnum = sym->value1;
744
  // vlcnum is the index of Table used to code coeff_token
745
  // vlcnum==3 means (8<=nC) which uses 6bit FLC
746
 
747
  if (vlcnum == 3)
748
  {
749
    // read 6 bit FLC
750
    code = ShowBits(buf, frame_bitoffset, BitstreamLengthInBytes, 6);
751
    currStream->frame_bitoffset += 6;
752
    sym->value2 = code & 3;
753
    sym->value1 = (code >> 2);
754
 
755
    if (!sym->value1 && sym->value2 == 3)
756
    {
757
      // #c = 0, #t1 = 3 =>  #c = 0
758
      sym->value2 = 0;
759
    }
760
    else
761
      sym->value1++;
762
 
763
    sym->len = 6;
764
 
765
    retval = 0;
766
  }
767
  else
768
 
769
  {
770
    const int *lt = &lentab[vlcnum][0][0];
771
    const int *ct = &codtab[vlcnum][0][0];
772
    retval = code_from_bitstream_2d(sym, dP, lt, ct, 17, 4, &code);
773
  }
774
 
775
  if (retval)
776
  {
777
    printf("ERROR: failed to find NumCoeff/TrailingOnes\n");
778
    exit(-1);
779
  }
780
 
781
#if TRACE
782
  snprintf(sym->tracestring,
783
    TRACESTRING_SIZE, "%s # c & tr.1s vlc=%d #c=%d #t1=%d",
784
           type, vlcnum, sym->value1, sym->value2);
785
  tracebits2(sym->tracestring, sym->len, code);
786
 
787
#endif
788
 
789
  return retval;
790
}
791
 
792
 
793
/*!
794
 ************************************************************************
795
 * \brief
796
 *    read NumCoeff/TrailingOnes codeword from UVLC-partition ChromaDC
797
 ************************************************************************
798
 */
799
int readSyntaxElement_NumCoeffTrailingOnesChromaDC(SyntaxElement *sym,  DataPartition *dP)
800
{
801
  int retval;
802
  int code;
803
 
804
  static const int lentab[3][4][17] =
805
  {
806
    //YUV420
807
   {{ 2, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
808
    { 0, 1, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
809
    { 0, 0, 3, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
810
    { 0, 0, 0, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
811
    //YUV422
812
   {{ 1, 7, 7, 9, 9,10,11,12,13, 0, 0, 0, 0, 0, 0, 0, 0},
813
    { 0, 2, 7, 7, 9,10,11,12,12, 0, 0, 0, 0, 0, 0, 0, 0},
814
    { 0, 0, 3, 7, 7, 9,10,11,12, 0, 0, 0, 0, 0, 0, 0, 0},
815
    { 0, 0, 0, 5, 6, 7, 7,10,11, 0, 0, 0, 0, 0, 0, 0, 0}},
816
    //YUV444
817
   {{ 1, 6, 8, 9,10,11,13,13,13,14,14,15,15,16,16,16,16},
818
    { 0, 2, 6, 8, 9,10,11,13,13,14,14,15,15,15,16,16,16},
819
    { 0, 0, 3, 7, 8, 9,10,11,13,13,14,14,15,15,16,16,16},
820
    { 0, 0, 0, 5, 6, 7, 8, 9,10,11,13,14,14,15,15,16,16}}
821
  };
822
 
823
  static const int codtab[3][4][17] =
824
  {
825
    //YUV420
826
   {{ 1, 7, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
827
    { 0, 1, 6, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
828
    { 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
829
    { 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
830
    //YUV422
831
   {{ 1,15,14, 7, 6, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0},
832
    { 0, 1,13,12, 5, 6, 6, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0},
833
    { 0, 0, 1,11,10, 4, 5, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0},
834
    { 0, 0, 0, 1, 1, 9, 8, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0}},
835
    //YUV444
836
   {{ 1, 5, 7, 7, 7, 7,15,11, 8,15,11,15,11,15,11, 7, 4},
837
    { 0, 1, 4, 6, 6, 6, 6,14,10,14,10,14,10, 1,14,10, 6},
838
    { 0, 0, 1, 5, 5, 5, 5, 5,13, 9,13, 9,13, 9,13, 9, 5},
839
    { 0, 0, 0, 3, 3, 4, 4, 4, 4, 4,12,12, 8,12, 8,12, 8}}
840
 
841
  };
842
  int yuv = active_sps->chroma_format_idc - 1;
843
 
844
  const int *lt = &lentab[yuv][0][0];
845
  const int *ct = &codtab[yuv][0][0];
846
 
847
  retval = code_from_bitstream_2d(sym, dP, lt, ct, 17, 4, &code);
848
 
849
  if (retval)
850
  {
851
    printf("ERROR: failed to find NumCoeff/TrailingOnes ChromaDC\n");
852
    exit(-1);
853
  }
854
 
855
 
856
#if TRACE
857
    snprintf(sym->tracestring,
858
      TRACESTRING_SIZE, "ChrDC # c & tr.1s  #c=%d #t1=%d",
859
              sym->value1, sym->value2);
860
    tracebits2(sym->tracestring, sym->len, code);
861
 
862
#endif
863
 
864
  return retval;
865
}
866
 
867
 
868
 
869
 
870
/*!
871
 ************************************************************************
872
 * \brief
873
 *    read Level VLC0 codeword from UVLC-partition
874
 ************************************************************************
875
 */
876
int readSyntaxElement_Level_VLC0(SyntaxElement *sym, struct datapartition *dP)
877
{
878
  Bitstream   *currStream = dP->bitstream;
879
  int frame_bitoffset = currStream->frame_bitoffset;
880
  byte *buf = currStream->streamBuffer;
881
  int BitstreamLengthInBytes = currStream->bitstream_length;
882
  int len, sign=0, level=0, code;
883
  int offset, addbit;
884
 
885
  len = 0;
886
  while (!ShowBits(buf, frame_bitoffset+len, BitstreamLengthInBytes, 1))
887
    len++;
888
 
889
  len++;
890
  code = 1;
891
  frame_bitoffset += len;
892
 
893
  if (len < 15)
894
  {
895
    sign = (len - 1) & 1;
896
    level = (len-1) / 2 + 1;
897
  }
898
  else if (len == 15)
899
  {
900
    // escape code
901
    code = (code << 4) | ShowBits(buf, frame_bitoffset, BitstreamLengthInBytes, 4);
902
    len += 4;
903
    frame_bitoffset += 4;
904
    sign = (code & 1);
905
    level = ((code >> 1) & 0x7) + 8;
906
  }
907
  else if (len >= 16)
908
  {
909
    // escape code
910
    addbit=len-16;
911
    code = ShowBits(buf, frame_bitoffset, BitstreamLengthInBytes, (len-4));
912
    len  = (len-4);
913
    frame_bitoffset += len;
914
    sign =  (code & 1);
915
 
916
    offset=(2048<<addbit)+16-2048;
917
    level = (code >> 1) + offset;
918
    code |= (1 << (len)); // for display purpose only
919
    len += addbit + 16;
920
 }
921
 
922
  if (sign)
923
    level = -level;
924
 
925
  sym->inf = level;
926
  sym->len = len;
927
 
928
#if TRACE
929
  tracebits2(sym->tracestring, sym->len, code);
930
#endif
931
  currStream->frame_bitoffset = frame_bitoffset;
932
  return 0;
933
 
934
}
935
 
936
/*!
937
 ************************************************************************
938
 * \brief
939
 *    read Level VLC codeword from UVLC-partition
940
 ************************************************************************
941
 */
942
int readSyntaxElement_Level_VLCN(SyntaxElement *sym, int vlc, struct datapartition *dP)
943
{
944
 
945
  Bitstream   *currStream = dP->bitstream;
946
  int frame_bitoffset = currStream->frame_bitoffset;
947
  byte *buf = currStream->streamBuffer;
948
  int BitstreamLengthInBytes = currStream->bitstream_length;
949
 
950
  int levabs, sign;
951
  int len = 0;
952
  int code, sb;
953
 
954
  int numPrefix;
955
  int shift = vlc-1;
956
  int escape = (15<<shift)+1;
957
  int addbit, offset;
958
 
959
  // read pre zeros
960
  numPrefix = 0;
961
  while (!ShowBits(buf, frame_bitoffset+numPrefix, BitstreamLengthInBytes, 1))
962
    numPrefix++;
963
 
964
 
965
  len = numPrefix+1;
966
  code = 1;
967
 
968
  if (numPrefix < 15)
969
  {
970
    levabs = (numPrefix<<shift) + 1;
971
 
972
    // read (vlc-1) bits -> suffix
973
    if (vlc-1)
974
    {
975
      sb =  ShowBits(buf, frame_bitoffset+len, BitstreamLengthInBytes, vlc-1);
976
      code = (code << (vlc-1) )| sb;
977
      levabs += sb;
978
      len += (vlc-1);
979
    }
980
 
981
    // read 1 bit -> sign
982
    sign = ShowBits(buf, frame_bitoffset+len, BitstreamLengthInBytes, 1);
983
    code = (code << 1)| sign;
984
    len ++;
985
  }
986
  else // escape
987
  {
988
    addbit = numPrefix - 15;
989
 
990
    sb = ShowBits(buf, frame_bitoffset+len, BitstreamLengthInBytes, (11+addbit));
991
    code = (code << (11+addbit) )| sb;
992
 
993
    len   += (11+addbit);
994
    offset = (2048<<addbit)+escape-2048;
995
    levabs = sb + offset;
996
 
997
    // read 1 bit -> sign
998
    sign = ShowBits(buf, frame_bitoffset+len, BitstreamLengthInBytes, 1);
999
    code = (code << 1)| sign;
1000
    len++;
1001
  }
1002
 
1003
  sym->inf = (sign)?-levabs:levabs;
1004
  sym->len = len;
1005
 
1006
  currStream->frame_bitoffset = frame_bitoffset+len;
1007
 
1008
#if TRACE
1009
  tracebits2(sym->tracestring, sym->len, code);
1010
#endif
1011
 
1012
  return 0;
1013
}
1014
 
1015
/*!
1016
 ************************************************************************
1017
 * \brief
1018
 *    read Total Zeros codeword from UVLC-partition
1019
 ************************************************************************
1020
 */
1021
int readSyntaxElement_TotalZeros(SyntaxElement *sym,  DataPartition *dP)
1022
{
1023
  int retval;
1024
  int code;
1025
 
1026
  static const int lentab[TOTRUN_NUM][16] =
1027
  {
1028
 
1029
    { 1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9},
1030
    { 3,3,3,3,3,4,4,4,4,5,5,6,6,6,6},
1031
    { 4,3,3,3,4,4,3,3,4,5,5,6,5,6},
1032
    { 5,3,4,4,3,3,3,4,3,4,5,5,5},
1033
    { 4,4,4,3,3,3,3,3,4,5,4,5},
1034
    { 6,5,3,3,3,3,3,3,4,3,6},
1035
    { 6,5,3,3,3,2,3,4,3,6},
1036
    { 6,4,5,3,2,2,3,3,6},
1037
    { 6,6,4,2,2,3,2,5},
1038
    { 5,5,3,2,2,2,4},
1039
    { 4,4,3,3,1,3},
1040
    { 4,4,2,1,3},
1041
    { 3,3,1,2},
1042
    { 2,2,1},
1043
    { 1,1},
1044
  };
1045
 
1046
  static const int codtab[TOTRUN_NUM][16] =
1047
  {
1048
    {1,3,2,3,2,3,2,3,2,3,2,3,2,3,2,1},
1049
    {7,6,5,4,3,5,4,3,2,3,2,3,2,1,0},
1050
    {5,7,6,5,4,3,4,3,2,3,2,1,1,0},
1051
    {3,7,5,4,6,5,4,3,3,2,2,1,0},
1052
    {5,4,3,7,6,5,4,3,2,1,1,0},
1053
    {1,1,7,6,5,4,3,2,1,1,0},
1054
    {1,1,5,4,3,3,2,1,1,0},
1055
    {1,1,1,3,3,2,2,1,0},
1056
    {1,0,1,3,2,1,1,1,},
1057
    {1,0,1,3,2,1,1,},
1058
    {0,1,1,2,1,3},
1059
    {0,1,1,1,1},
1060
    {0,1,1,1},
1061
    {0,1,1},
1062
    {0,1},
1063
  };
1064
 
1065
  int vlcnum = sym->value1;
1066
 
1067
  const int *lt = &lentab[vlcnum][0];
1068
  const int *ct = &codtab[vlcnum][0];
1069
 
1070
  retval = code_from_bitstream_2d(sym, dP, lt, ct, 16, 1, &code);
1071
 
1072
  if (retval)
1073
  {
1074
    printf("ERROR: failed to find Total Zeros\n");
1075
    exit(-1);
1076
  }
1077
 
1078
 
1079
#if TRACE
1080
    tracebits2(sym->tracestring, sym->len, code);
1081
 
1082
#endif
1083
 
1084
  return retval;
1085
}
1086
 
1087
/*!
1088
 ************************************************************************
1089
 * \brief
1090
 *    read Total Zeros Chroma DC codeword from UVLC-partition
1091
 ************************************************************************
1092
 */
1093
int readSyntaxElement_TotalZerosChromaDC(SyntaxElement *sym,  DataPartition *dP)
1094
{
1095
  int retval;
1096
  int code;
1097
 
1098
  static const int lentab[3][TOTRUN_NUM][16] =
1099
  {
1100
    //YUV420
1101
   {{ 1,2,3,3},
1102
    { 1,2,2},
1103
    { 1,1}},
1104
    //YUV422
1105
   {{ 1,3,3,4,4,4,5,5},
1106
    { 3,2,3,3,3,3,3},
1107
    { 3,3,2,2,3,3},
1108
    { 3,2,2,2,3},
1109
    { 2,2,2,2},
1110
    { 2,2,1},
1111
    { 1,1}},
1112
    //YUV444
1113
   {{ 1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9},
1114
    { 3,3,3,3,3,4,4,4,4,5,5,6,6,6,6},
1115
    { 4,3,3,3,4,4,3,3,4,5,5,6,5,6},
1116
    { 5,3,4,4,3,3,3,4,3,4,5,5,5},
1117
    { 4,4,4,3,3,3,3,3,4,5,4,5},
1118
    { 6,5,3,3,3,3,3,3,4,3,6},
1119
    { 6,5,3,3,3,2,3,4,3,6},
1120
    { 6,4,5,3,2,2,3,3,6},
1121
    { 6,6,4,2,2,3,2,5},
1122
    { 5,5,3,2,2,2,4},
1123
    { 4,4,3,3,1,3},
1124
    { 4,4,2,1,3},
1125
    { 3,3,1,2},
1126
    { 2,2,1},
1127
    { 1,1}}
1128
  };
1129
 
1130
  static const int codtab[3][TOTRUN_NUM][16] =
1131
  {
1132
    //YUV420
1133
   {{ 1,1,1,0},
1134
    { 1,1,0},
1135
    { 1,0}},
1136
    //YUV422
1137
   {{ 1,2,3,2,3,1,1,0},
1138
    { 0,1,1,4,5,6,7},
1139
    { 0,1,1,2,6,7},
1140
    { 6,0,1,2,7},
1141
    { 0,1,2,3},
1142
    { 0,1,1},
1143
    { 0,1}},
1144
    //YUV444
1145
   {{1,3,2,3,2,3,2,3,2,3,2,3,2,3,2,1},
1146
    {7,6,5,4,3,5,4,3,2,3,2,3,2,1,0},
1147
    {5,7,6,5,4,3,4,3,2,3,2,1,1,0},
1148
    {3,7,5,4,6,5,4,3,3,2,2,1,0},
1149
    {5,4,3,7,6,5,4,3,2,1,1,0},
1150
    {1,1,7,6,5,4,3,2,1,1,0},
1151
    {1,1,5,4,3,3,2,1,1,0},
1152
    {1,1,1,3,3,2,2,1,0},
1153
    {1,0,1,3,2,1,1,1,},
1154
    {1,0,1,3,2,1,1,},
1155
    {0,1,1,2,1,3},
1156
    {0,1,1,1,1},
1157
    {0,1,1,1},
1158
    {0,1,1},
1159
    {0,1}}
1160
  };
1161
  int yuv = active_sps->chroma_format_idc - 1;
1162
 
1163
  int vlcnum = sym->value1;
1164
 
1165
  const int *lt = &lentab[yuv][vlcnum][0];
1166
  const int *ct = &codtab[yuv][vlcnum][0];
1167
 
1168
  retval = code_from_bitstream_2d(sym, dP, lt, ct, 16, 1, &code);
1169
 
1170
  if (retval)
1171
  {
1172
    printf("ERROR: failed to find Total Zeros\n");
1173
    exit(-1);
1174
  }
1175
 
1176
 
1177
#if TRACE
1178
    tracebits2(sym->tracestring, sym->len, code);
1179
 
1180
#endif
1181
 
1182
  return retval;
1183
}
1184
 
1185
 
1186
/*!
1187
 ************************************************************************
1188
 * \brief
1189
 *    read  Run codeword from UVLC-partition
1190
 ************************************************************************
1191
 */
1192
int readSyntaxElement_Run(SyntaxElement *sym,  DataPartition *dP)
1193
{
1194
  int retval;
1195
  int code;
1196
 
1197
  static const int lentab[TOTRUN_NUM][16] =
1198
  {
1199
    {1,1},
1200
    {1,2,2},
1201
    {2,2,2,2},
1202
    {2,2,2,3,3},
1203
    {2,2,3,3,3,3},
1204
    {2,3,3,3,3,3,3},
1205
    {3,3,3,3,3,3,3,4,5,6,7,8,9,10,11},
1206
  };
1207
 
1208
  static const int codtab[TOTRUN_NUM][16] =
1209
  {
1210
    {1,0},
1211
    {1,1,0},
1212
    {3,2,1,0},
1213
    {3,2,1,1,0},
1214
    {3,2,3,2,1,0},
1215
    {3,0,1,3,2,5,4},
1216
    {7,6,5,4,3,2,1,1,1,1,1,1,1,1,1},
1217
  };
1218
 
1219
  int vlcnum = sym->value1;
1220
 
1221
  const int *lt = &lentab[vlcnum][0];
1222
  const int *ct = &codtab[vlcnum][0];
1223
 
1224
  retval = code_from_bitstream_2d(sym, dP, lt, ct, 16, 1, &code);
1225
 
1226
  if (retval)
1227
  {
1228
    printf("ERROR: failed to find Run\n");
1229
    exit(-1);
1230
  }
1231
 
1232
 
1233
#if TRACE
1234
    tracebits2(sym->tracestring, sym->len, code);
1235
#endif
1236
 
1237
  return retval;
1238
}
1239
 
1240
 
1241
/*!
1242
 ************************************************************************
1243
 * \brief
1244
 *  Reads bits from the bitstream buffer
1245
 *
1246
 * \param buffer
1247
 *    containing VLC-coded data bits
1248
 * \param totbitoffset
1249
 *    bit offset from start of partition
1250
 * \param info
1251
 *    returns value of the read bits
1252
 * \param bytecount
1253
 *    total bytes in bitstream
1254
 * \param numbits
1255
 *    number of bits to read
1256
 *
1257
 ************************************************************************
1258
 */
1259
int GetBits (byte buffer[],int totbitoffset,int *info, int bytecount,
1260
             int numbits)
1261
{
1262
 
1263
  register int inf;
1264
  long byteoffset;      // byte from start of buffer
1265
  int bitoffset;      // bit from start of byte
1266
 
1267
  int bitcounter=numbits;
1268
 
1269
  byteoffset= totbitoffset>>3;
1270
  bitoffset= 7-(totbitoffset&0x07);
1271
 
1272
  inf=0;
1273
  while (numbits)
1274
  {
1275
    inf <<=1;
1276
    inf |= (buffer[byteoffset] & (0x01<<bitoffset))>>bitoffset;
1277
    numbits--;
1278
    bitoffset--;
1279
    if (bitoffset < 0)
1280
    {
1281
      byteoffset++;
1282
      bitoffset += 8;
1283
      if (byteoffset > bytecount)
1284
      {
1285
        return -1;
1286
      }
1287
    }
1288
  }
1289
 
1290
  *info = inf;
1291
  return bitcounter;           // return absolute offset in bit from start of frame
1292
}
1293
 
1294
/*!
1295
 ************************************************************************
1296
 * \brief
1297
 *  Reads bits from the bitstream buffer
1298
 *
1299
 * \param buffer
1300
 *    buffer containing VLC-coded data bits
1301
 * \param totbitoffset
1302
 *    bit offset from start of partition
1303
 * \param bytecount
1304
 *    total bytes in bitstream
1305
 * \param numbits
1306
 *    number of bits to read
1307
 *
1308
 ************************************************************************
1309
 */
1310
 
1311
int ShowBits (byte buffer[],int totbitoffset,int bytecount, int numbits)
1312
{
1313
 
1314
  register int inf;
1315
  long byteoffset = totbitoffset>>3;      // byte from start of buffer
1316
  int bitoffset   = 7-(totbitoffset&0x07);      // bit from start of byte
1317
 
1318
  inf=0;
1319
  while (numbits)
1320
  {
1321
    inf <<=1;
1322
    inf |= (buffer[byteoffset] & (0x01<<bitoffset))>>bitoffset;
1323
    numbits--;
1324
    bitoffset--;
1325
    if (bitoffset < 0)
1326
    {
1327
      byteoffset++;
1328
      bitoffset += 8;
1329
      if (byteoffset > bytecount)
1330
      {
1331
        return -1;
1332
      }
1333
    }
1334
  }
1335
 
1336
  return inf;           // return absolute offset in bit from start of frame
1337
}
1338
 
1339
 
1340
/*!
1341
 ************************************************************************
1342
 * \brief
1343
 *    peek at the next 2 UVLC codeword from UVLC-partition to determine
1344
 *    if a skipped MB is field/frame
1345
 ************************************************************************
1346
 */
1347
int peekSyntaxElement_UVLC(SyntaxElement *sym, struct img_par *img, struct datapartition *dP)
1348
{
1349
  Bitstream   *currStream = dP->bitstream;
1350
  int frame_bitoffset = currStream->frame_bitoffset;
1351
  byte *buf = currStream->streamBuffer;
1352
  int BitstreamLengthInBytes = currStream->bitstream_length;
1353
 
1354
 
1355
  sym->len =  GetVLCSymbol (buf, frame_bitoffset, &(sym->inf), BitstreamLengthInBytes);
1356
  if (sym->len == -1)
1357
    return -1;
1358
  frame_bitoffset += sym->len;
1359
  sym->mapping(sym->len,sym->inf,&(sym->value1),&(sym->value2));
1360
 
1361
 
1362
#if TRACE
1363
  tracebits(sym->tracestring, sym->len, sym->inf, sym->value1);
1364
#endif
1365
 
1366
  return 1;
1367
}
1368
 
1369
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.