Patent Publication Number: US-2005141556-A1

Title: System and method for controlling bit stream in digital data

Description:
BACKGROUND OF THE INVENTION  
      1. Field of the Invention  
      The present invention relates to a bits stream control system for digital data, especially to a bits stream control system in compliance with digital video specification for digital data.  
      2. Description of the Prior Art  
      The image encoder of the prior art encodes digital data to a plurality of bits streams via the steps of transformation, quantization, and variable length coding (VLC) according to a predetermined encoding format; these formats include the moving pictures experts groups (MPEG), the joint photographic experts groups (JPEG), or the DV specification popularized by Sony, Matsushita, Philips, Thomson, and so on in 1993. After encoding, the image encoder of the prior art further processes the bits streams according to function and purpose.  
      When the encoder is applied in a DV apparatus, each of the bits streams generated by the DV specification is assigned to a corresponding sub-block by a bits assignment apparatus to constitute a segment. The DV specification also defines that the segment comprises five macroblocks; each of the macroblocks comprises four luma sub-blocks and two chroma sub-blocks, and each of the luma sub-blocks comprises 112 bits while each of the chroma sub-blocks comprises 80 bits.  
      The assignment steps of the bits assignment apparatus is described in the following:  
      (1) Judge whether the number of bits of an assigned bits stream of the bits streams exceeds the desired number of the corresponding sub-blocks.  
      (2) If yes, truncate the extra bits from the assigned bits stream, assign the truncated and assigned bits stream to the corresponding sub-block, and buffer the extra bits into an extra bits buffer; otherwise, assign the assigned bits stream to the corresponding sub-block directly.  
      (3) Repeat steps (1) and (2) until the bits streams are all assigned to the corresponding sub-blocks.  
      (4) Read the extra bits from the extra bits buffer, and assign the extra bits to the remaining capacity of the other sub-blocks.  
      For economical and practical use, the extra bits buffer of the prior art usually has the memory capacity of about 2K to 8 K bytes. Therefore, if the extra bits of one bits stream are too large, the extra bits will occupy most of the capacity, even all capacity, of the extra bits buffer, and the other extra bits will be lost. Accordingly, if the other extra bits contain important data, the important data will be lost, resulting in worse distortion when the digital data is restored subsequently.  
     SUMMARY OF THE INVENTION  
      The objective of the present invention is to provide a bits stream control system for digital data, so as to solve the problem of the prior art.  
      The bits stream control system of the present invention modifies the bits streams according to a predetermined bit budget policy after the encoder of the prior art encodes the digital data to a plurality of bits streams via the steps of transformation, quantization, and variable length coding (VLC) according to a predetermined encoding format, so as to reduce the number of bits of the extra bits for generating a plurality of corresponding modified bits streams. The present invention can avoid the situation where the extra bits are too large, the extra bits will occupy most of the capacity, even all capacity, of the extra bits buffer, and the other extra bits will be lost.  
      The present invention is a bits stream control system for digital data. The bits stream control system comprises an encoder, a bits stream truncator, and a buffer. The encoder is used for encoding the digital data to a plurality of bits streams. The bits stream truncator is used for truncating or not truncating each of the bits streams to generate a plurality of corresponding modified bits streams according to a predetermined bit budget policy. The buffer is used for storing the modified bits streams.  
      The advantage and spirit of the invention may be understood by the following recitations together with the appended drawings. 
    
    
     BRIEF DESCRIPTION OF THE APPENDED DRAWINGS  
       FIG. 1  is a schematic diagram of the bits stream control system of the first embodiment according to the present invention.  
       FIG. 2  is a calculation flowchart of the predetermined bit budget policy of the first embodiment.  
       FIG. 3  is a schematic diagram of the bits stream control system of the second embodiment according to the present invention.  
       FIG. 4  is a flowchart of the bits stream control system of the second embodiment. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION  
      Please refer to  FIG. 1 .  FIG. 1  is a schematic diagram of the bits stream control system  10  of the first embodiment according to the present invention. The bits stream control system  10  of the first embodiment comprises an encoder  16 , a bits stream truncator  18 , and a buffer  20 .  
      The encoder  16  first transforms a digital data  12  to a digital data of frequency domain (not shown), quantifies the digital data of frequency domain to a modified digital data (not shown), and then encodes the modified digital data to a plurality of bits streams  22  according to a predetermined encoding format; these formats include the moving pictures experts groups (MPEG), the joint photographic experts groups (JPEG), or the digital video (DV).  
      The bits stream truncator  18  is used for truncating or not truncating each of the bits streams  22  to generate a plurality of corresponding modified bits streams  14  according to a predetermined bit budget policy and for buffering the modified bits streams  14  into the buffer  20 . The bit budget policy calculates a bit length (not shown) of each modified bits stream  14  according to a budget capacity (not shown) provided by the buffer  20 .  
      The bits stream truncator  18  examines each of the bits streams  22  sequentially according to the bit budget policy. If a currently examined bits stream  22  doesn&#39;t conform to the bit budget policy, the bit budget policy truncates the currently examined bits stream  22  according to the budget capacity and adds an end mark to form a corresponding modified bits stream  14 ; otherwise, the bit budget policy doesn&#39;t truncate the currently examined bits stream  22  and output the currently examined bits stream  22  as the corresponding modified bits stream  14 .  
      Please refer to  FIG. 2 .  FIG. 2  is a calculation flowchart of the predetermined bit budget policy of the first embodiment. The number of bits streams is M, and the K th  bits stream  22  represents a corresponding bits stream  22 , wherein K=0˜M−1. The K th  bits stream  22  comprises N K  samples, and the L th  sample represents a corresponding sample, wherein L=0˜N K −1. The bits stream truncator  18  processes each of the bits streams  22  and the sample of each bits stream  22  sequentially. The steps are described in the following:  
      Step S 135 : Calculate a 0 th  remaining capacity of the buffer  20  corresponding to a oth bits stream  22 , and the equation is described in the following: 
 
 E   0 =Capacity− M *Quota, 
 
 wherein E 0  represents the 0 th  remaining capacity, and Capacity represents the total capacity of the buffer  20 ; Quota represents a guaranteed bit length, and the guaranteed bit length is a fixed capacity in the buffer  20  pre-reserved for each bits stream  22 . 
 
      Step S 140 : Calculate a K th  budget capacity, K=0˜M−1, and the equation is described in the following: 
 
 B   K =Quota+ E   K  
 
 wherein B K  represents the K th  budget capacity, and E K  represents a K th  remaining capacity. 
 
      Step S 142 : Judge whether K is smaller than M. If yes, go to step S 145 ; otherwise, go to step S 200 .  
      Step S 145 : Set the length (BK 0 ) of a oth temporarily modified bits stream to be 0.  
      Step S 150 : Input an L th  sample of the K th  bits stream  22 , wherein L=0˜N K −1.  
      Step S 152 : Judge whether L is smaller than N K . If yes go to step S 155 ; otherwise, go to step S 185 .  
      Step S 155 : Calculate an L th  temporary bit length, and the equation is described in the following: 
 
 TB   L   =BK   L   +TE   L   +EOB  
 
 wherein TB L  represents the L th  temporary bit length, and BKL represents the length of the L th  temporarily modified bits stream; TE L  represents the L th  sample, and EOB represents the end mark. 
 
      Step S 160 : Judge whether TB L  is larger than the corresponding B K . If yes, go to step S 165 ; otherwise, go to step S 170 .  
      Step S 165 : Calculate the bit length of a K th  modified bits stream, and the equation is described in the following: 
 
 FB   K   =BK   L   +EOB  
 
 wherein FB K  represents the bit length of the K th  modified bits stream; go to step S 185 . 
 
      Step S 170 : Calculate the length of an L+1 th  temporarily modified bits stream, and the equation is described in the following: 
 
 BK   L+1   =BK   L   +TE   L  
 
 wherein BK L+1  represents the length of the L+1 th  temporarily modified bits stream. 
 
      Step S 172 : Repeat step S 150  to calculate the L+1 th  sample.  
      Step S 185 : Input the K+1 th  bits stream.  
      Step S 190 : Calculate the K+1 th  remaining capacity, and the equation is described in the following: 
 
 E   K+1   =B   K   −FB   K  
 
      Step S 195 : Repeat step S 140  to calculate the K+1 th  budget capacity.  
      Step S 200 : Finish.  
      Please refer to  FIG. 3 .  FIG. 3  is a schematic diagram of the bits stream control system  24  of the second embodiment according to the present invention. In the second embodiment, the bits stream control system  24  is applied in the digital video (DV), and a plurality of bits streams  26  conform to a digital video specification. Beside the encoder  16 , the bits stream truncator  18 , and the buffer  20  shown in  FIG. 1 , the bits stream control system  24  further comprises an assignment module  28 . The assignment module  28  comprises an extra bits buffer  30 .  
      The assignment module  28  is used for assigning each modified bits stream  32  buffered in the buffer  20  to a corresponding sub-block (not shown) respectively. The corresponding sub-block comprises a block length. If the bit length of a currently assigned-modified bits stream  32  exceeds the block length of the corresponding sub-block, the assignment module  28  truncates an extra bit  34  from the bits stream  32 , buffers the extra bit  34  into the extra bits buffer  30 , adds a corresponding end mark to the truncated-modified bits stream  32 , and assigns the truncated-modified bits stream  32  to the corresponding sub-block; otherwise, the assignment module  28  assigns the currently assigned-modified bits stream  32  to the corresponding sub-block directly.  
      After each of the modified bits streams  32  is assigned to the corresponding sub-block, the assignment module  28  reads each extra bit  34  from the extra bits buffer  30 , assigns each extra bit  34  to a sub-block that has remaining capacity, and finally enables the corresponding sub-blocks of the modified bits streams  32  to form a segment  36 . The segment  36  comprises five macroblocks, and each of the macroblocks comprises four luma sub-blocks and two chroma sub-blocks; each of the luma sub-blocks comprises 112 bits, and each of the chroma sub-blocks comprises 80 bits.  
      As shown in  FIG. 2  with M number of bits streams  22 , M can be 6, which means a cycle can process  6  sub-blocks of a macroblock when performing the truncation procedure each time; M can also be  30 , which means a cycle can process  30  sub-blocks of a macroblock when performing the truncation procedure each time.  
      Please refer to  FIG. 4 .  FIG. 4  is a flowchart of the bits stream control system  24  of the second embodiment. According to the above, the second embodiment comprises the following steps:  
      Step S 210 : Encode a digital data  12  into a plurality of bits streams  26 .  
      Step S 215 : Truncate or not truncate each of the bits streams  26  to generate a plurality of corresponding modified bits streams  32  according to the predetermined bit budget policy.  
      Step S 220 : Store the modified bits streams  32 .  
      Step S 225 : Judge whether the currently assigned-modified bits stream  32  has an extra bit  34 . If yes, go to step S 230 ; otherwise, go to step S 240 .  
      Step S 230 : Truncate the extra bit  34  from the currently assigned-modified bits stream  32 , add a corresponding end mark to the truncated-modified bits stream  32 , and assign the truncated-modified bits stream  32  to the corresponding sub-block.  
      Step S 235 : Store the extra bit  34  and go to step S 245 .  
      Step  240 : Assign the currently assigned-modified bits stream  32  to the corresponding sub-block directly.  
      Step S 245 : Assign each extra bit  34  to the sub-block that has remaining capacity.  
      Step S 250 : Form the segment  36  by the corresponding sub-blocks of the modified bits streams  32 .  
      In the prior art, after the encoder encodes the digital data into bits streams, the bits assignment apparatus assigns each of the bits streams to the corresponding sub-blocks directly to form the segment. Therefore, if the extra bits of one of the bits streams are too large, the extra bits will occupy most of the capacity, even all capacity, of the extra bits buffer, and the other extra bits will be lost, resulting in worse distortion when the digital data is restored subsequently. The bits stream control systems  10  and  24  of the present invention modify the bits streams  22 ,  26  by the predetermined bits budget policy to generate the corresponding modified bits streams  14 ,  32  before the assignment module  28  performs assignment procedure. Accordingly, each bits stream  22 ,  26  can be examined in advance, and the extra bits of the prior art can be modified for further process.  
      With the example and explanations above, the features and spirits of the invention will be hopefully well described. Those skilled in the art will readily observe that numerous modifications and alterations of the device may be made while retaining the teaching of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.