VLC: decodage d'un Truncated Exp-Golomb code [Résolu]

VLC: decodage d'un Truncated Exp-Golomb code [Résolu] - Algo - Programmation

Marsh Posté le 15-06-2005 à 16:15:27    

Salut,
 
j'ai un petit problème avec un décodage de données de type H.264/AVC:
 
je dispose d'un flot de bits dont certaines parties sont truncated
Exp-Golomb-coded
marquées par la suite te(v):
 
selon la Recommendation H.264 de l'ITU-T, tous les codages de golomb commencent de la manière suivante:
 

Citation :

Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded. Syntax elements coded as te(v) are truncated
Exp-Golomb-coded. The parsing process for these syntax elements begins with reading the bits starting at the current
location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are equal
to 0. This process shall be equivalent to the following:

Code :
  1. leadingZeroBits = -1;
  2. for( b = 0; !b; leadingZeroBits++ )
  3. b = read_bits( 1 )


The variable codeNum is then assigned as follows:

Code :
  1. codeNum = 2^leadingZeroBits – 1 + read_bits( leadingZeroBits )


where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
integer with most significant bit written first.


 
jusque la pas de problème. Ensuite, suivant la variante du codage (unsigned|truncated|signed|mapped exp-golomb-coded), le traitement suivant diffère. Tous sont exprimés clairement sauf le truncated (te(v)):

Citation :

Otherwise (the syntax element is coded as te(v)), the range of the syntax element shall be determined first. The range
of this syntax element may be between 0 and x, with x being greater than or equal to 1 and is used in the derivation
of the value of a syntax element as follows
- If x is greater than 1, codeNum and the value of the syntax element shall be derived in the same way as for
syntax elements coded as ue(v)
- Otherwise (x is equal to 1), the parsing process for codeNum which is equal to the value of the syntax element
is given by a process equivalent to:

Code :
  1. b = read_bits( 1 )
  2. codeNum = !b



 
Connaissant la valeur de x on peut trouver facilement le résultat.
 
Mon problème est comment trouve t'on x, la Recommendation H.264 n'y fait nullement référence dans la section concernée exceptée peut être ceci mais je n'arive pas a comprendre la relation entre x et les xi:
 

Citation :

Table 9-1 illustrates the structure of the Exp-Golomb code by separating the bit string into “prefix” and “suffix” bits. The
“prefix” bits are those bits that are parsed in the above pseudo-code for the computation of leadingZeroBits, and are
shown as either 0 or 1 in the bit string column of Table 9-1. The “suffix” bits are those bits that are parsed in the
computation of codeNum and are shown as xi in Table 9-1, with i being in the range 0 to leadingZeroBits - 1, inclusive.
Each xi can take on values 0 or 1.
 
Table 9-1 – Bit strings with “prefix” and “suffix” bits and assignment to codeNum ranges (informative)
Bit string form         Range of codeNum
          1                    0
        0 1 x0                1-2
      0 0 1 x1 x0             3-6
    0 0 0 1 x2 x1 x0          7-14
  0 0 0 0 1 x3 x2 x1 x0      15-30
0 0 0 0 0 1 x4 x3 x2 x1 x0   31-62
          …                    …


 
Quelqu'un arrive t'il a comprendre le relation entre x et xi (s'il y en a une) ou alors quelqu'un connait et peut il m'expliquer comment decoder un codage Exp-Golomb trucated ?
 
Merci.
 
Remarque:
 

  • On peut trouver les infos en citation dans la section 9.1 de la Recommendation H.264, un exemplaire est disponible à http://www.dspr.com/www/technology/h264.pdf (page 164 (PDF) ou 148 (Document))
  • La fonction read_bits(n) permet de récupérer n bits (dans le flot de données) et fait avancer le pointeur de position du flot de n positions


Message édité par chicotruss le 16-06-2005 à 13:25:50
Reply

Marsh Posté le 15-06-2005 à 16:15:27   

Reply

Marsh Posté le 16-06-2005 à 13:25:04    

J'ai trouvé ma réponse en regardant les sources du projet x264 (http://www.videolan.org/x264.html):
 
A priori (surtout en regardant les sources), la Recommendation H.264 s'exprimerait mal et le cas des truncated Exp-Golomb code se gèrerait indépendamment des cas signed, unsigned et mapped:
 

Code :
  1. // fichier bs.h, ligne 205:
  2. static inline int bs_read_te( bs_t *s, int x )
  3. {
  4.     if( x == 1 )
  5.     {
  6.         return 1 - bs_read1( s );
  7.     }
  8.     else if( x > 1 )
  9.     {
  10.         return bs_read_ue( s );
  11.     }
  12.     return 0;
  13. }


 
donc x était un paramètre passé à l'appel et il ne faut pas, dans le cas du truncated Exp-Golomb code, prendre en compte l'info suivante:
 

Citation :

The parsing process for these syntax elements begins with reading the bits starting at the current
location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are equal
to 0. This process shall be equivalent to the following [...] where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
integer with most significant bit written first.


 
mais uniquement:
 

Citation :

Otherwise (the syntax element is coded as te(v)), the range of the syntax element shall be determined first. The range
of this syntax element may be between 0 and x, with x being greater than or equal to 1 and is used in the derivation
of the value of a syntax element as follows
- If x is greater than 1, codeNum and the value of the syntax element shall be derived in the same way as for
syntax elements coded as ue(v)
- Otherwise (x is equal to 1), the parsing process for codeNum which is equal to the value of the syntax element
is given by a process equivalent to:

Code :
  1. b = read_bits( 1 )
  2. codeNum = !b



Message édité par chicotruss le 16-06-2005 à 13:25:18
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed