Abstract:
An electronic device is provided comprising a multimedia play unit and a processor. The processor receives a multimedia sequence, acquires a first bitrate of a first frame header from the received multimedia sequence, predicts a first length of a first frame comprising the first frame header by a formula employing at least parameters comprising the first bitrate and a proportion of a second length to a second bitrate of a second frame header prior to the first frame header, and directs the multimedia play unit to play frame data of the first frame according to the predicted first length of the first frame.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The invention relates to a system and method for multimedia decoding, and more particularly to a system and method for finding out a start position of a frame header of a multimedia sequence. 
     2. Description of the Related Art 
     MPEG-1 defines a group of Audio and Video (AV) coding and compression standards agreed upon by MPEG (Moving Picture Experts Group). MPEG-1, Audio Layer 3 is the popular audio format known as MP3. As cheaper and more powerful consumer decoding hardware became available, more advanced formats such as MPEG-2 and MPEG-4 were developed. These newer formats are more complex and require more powerful hardware, but the formats also achieve greater coding efficiency. 
     Typically, an MP3 file is made up of multiple MP3 frames, which consist of the MP3 header and the MP3 data. This sequence of frames is called an elementary stream. Frames are independent items: one can cut the frames from a file and an MP3 player would be able to play it. The MP3 header contains the information of encoding scheme (e.g. encoding version, sampling rate, and bitrate), and the MP3 data is the actual audio payload. However, lengths of each frame may not be fixed because of the variety of encoding bitrates, or others, lengths of each frame of the MP3 file for subsequent decoding is required to be determined. 
     BRIEF SUMMARY OF THE INVENTION 
     An electronic device for multimedia decoding is provided. The electronic device comprises a multimedia play unit and a processor. The processor receives a multimedia sequence, acquires a first bitrate of a first frame header from the received multimedia sequence, predicts a first length of a first frame comprising the first frame header by a formula employing at least parameters comprising the first bitrate and a proportion of a second length to a second bitrate of a second frame header prior to the first frame header and directs the multimedia play unit to play frame data of the first frame according to the predicted first length of the first frame. 
     A method for finding out frame sizes of a multimedia sequence is provided. First, a first bitrate of a first frame header is acquired from the multimedia sequence. Next, a first length of a first frame comprising the first frame header is predicted by a formula. The formula employs at least parameters comprising the first bitrate and a proportion of a second length to a second bitrate. The second bitrate is of a second frame header prior to the first frame header. Next, a synchronous pattern is searched within a first search region comprising a position of a start position of the first frame header plus the predicted first length to identify a start position of a third frame header next to the first frame. Next, the first length is updated as a length between the start positions of the first frame header and the third frame header. Finally, frame data of the first frame is played. 
     A machine-readable storage medium storing a computer program performing a method for multimedia decoding is provided. First, a multimedia sequence is received. Next, a first bitrate of a first frame header is acquired from the multimedia sequence. Next, a first length of a first frame comprising the first frame header is predicted by a formula employing at least parameters comprising the first bitrate and a proportion of a second length to a second bitrate of a second frame header prior to the first frame header. Next, a start position of a third frame header next to the first frame is determined according the predicted first length. Next, the first length is updated as a length between start positions of the first frame header and the third frame header. Finally, frame data of the first frame is played. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       The invention can be more fully understood by reading the subsequent detailed description and examples with references made to the accompanying drawings, wherein: 
         FIG. 1  shows an embodiment of a system for playing a multimedia file; 
         FIG. 2  shows an example of an audio header format, MPEG1, 11172-3; 
         FIG. 3(A)  is a flowchart of a method for finding out frame sizes of a multimedia sequence; 
         FIG. 3(B)  is a continuous flowchart of  FIG. 3(A) ; and 
         FIGS. 4(A)-4(B)  show a segment of a multimedia sequence corresponding to the method of  FIG. 3(A) . 
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       FIG. 1  shows an embodiment of a system for playing a multimedia file. The system  100  comprises a multimedia decoder  102 , a multimedia play unit  104 , a processor  106 , a volatile memory  108 , and a non-volatile memory  110 . Non-volatile memory  110  (e.g. hard disk or flash memory) can store a multimedia file such as an audio file or a video file, or combinations of the like. A multimedia file usually comprises multiple frames in sequence, and each frame is usually composed of two parts, the leading part is frame header and the later part is frame data. Each frame header has a common pattern with specific organization, and the common pattern is typically composed of a synchronous pattern and multimedia profile information (e.g file type, bitrate, encoding scheme, or others). Each frame data may store a segment of encoded multimedia data and can be decoded according to each corresponding frame header. In a multimedia file, the length (or size) of each frame header is fixed, however, the length of each frame may not be fixed because the bitrate of frame data may vary with the encoding scheme. Accordingly, processor  106  can execute a computer program performing a method for finding the frame headers of the multimedia file to identify start positions of the frames. The multimedia decoder  102  may decode the frame data according the multimedia profile information stored in the corresponding frame header. Subsequently, the processor  106  may direct the multimedia play unit  104 , such as a display unit or a speaker, to play the decoded frame data. Volatile memory  108  may store the computer program and be accessed by processor  106 , such as a dynamic random access memory (DRAM), static random access memory (SRAM), or others. 
       FIG. 2  shows an example of an audio header format, MPEG1, 11172-3, typically called MP3. The audio header format comprises multiple fields. In a multimedia file, each frame header has the same header length. A field SYNC_WORD can be used as a synchronous pattern (e.g. 0xFFF or 0xFFE) to verify the beginning of a valid frame. A field ID represents the MPEG audio version ID, and a field LAYER represents the encoding layer. A field SAMPLING_RATE represents the sampling rate of an MP3 file, such as 16 kHz or 24 kHz. In an MP3 file, fields SYNC_WORD, ID, LAYER, and SAMPLING_RATE are seen as constant in each frame header of the whole MP3 file. A field BITRATE represents the bitrate of the corresponding frame data, and there are several predetermined bitrates which can be chosen when a multimedia encoder encodes a MP3 file. It is noted that other multimedia frame headers, such as MPEG-2 or MPEG-4, may contain different header formats with different synchronous patterns. 
     Table 1 shows an example of bitrate table of MPEG1, 11172-3, where Fs denotes sampling rate and the length of field BITRATE is four bits. 
     
       
         
               
               
               
             
               
               
               
             
           
               
                   
                 TABLE 1 
               
             
             
               
                   
                   
               
               
                   
                 Bitrate specified (kbit/s) 
                   
               
               
                   
                 for Fs = 16, 22, 05, 24 kHz 
               
             
          
           
               
                 BITRATE 
                 Layer I 
                 Layer II, Layer III 
               
               
                   
               
               
                 ‘0000’ 
                 free 
                 Free 
               
               
                 ‘0001’ 
                 32 
                 8 
               
               
                 ‘0010’ 
                 48 
                 16 
               
               
                 ‘0011’ 
                 56 
                 24 
               
               
                 ‘0100’ 
                 64 
                 32 
               
               
                 ‘0101’ 
                 80 
                 40 
               
               
                 ‘0110’ 
                 96 
                 48 
               
               
                 ‘0111’ 
                 112 
                 56 
               
               
                 ‘1000’ 
                 128 
                 64 
               
               
                 ‘1001’ 
                 144 
                 80 
               
               
                 ‘1010’ 
                 160 
                 96 
               
               
                 ‘1011’ 
                 176 
                 112 
               
               
                 ‘1100’ 
                 192 
                 128 
               
               
                 ‘1101’ 
                 224 
                 144 
               
               
                 ‘1110’ 
                 256 
                 160 
               
               
                 ‘1111’ 
                 forbidden 
                 forbidden 
               
               
                   
               
             
          
         
       
     
       FIG. 3(A)  is a flowchart of a method for finding out frame sizes of a multimedia sequence, and the method can be stored in a computer program and executed by the processor described in  FIG. 1 .  FIGS. 4(A)-4(B)  show a segment of a multimedia sequence corresponding to the method of  FIG. 3(A) . Referring to  FIG. 3(A)  and  FIG. 4(A) , the code segments, H 0  and H 1 , are acquired from the multimedia sequence (step S 302 ), and a potential bitrate Br 0  is acquired from the code segment H 0  (step S 304 ). Both of the code segments HO and H 1  comprise the same patterns (i.e. common patterns) with a specific organization. A length of the frame L 0  between start positions of the code segments, P 0  and P 1 , is determined, and a mapping between Br 0  and L 0  is stored in a lookup table (step S 306 ). The lookup table may be stored in the volatile memory described in  FIG. 1 , and the processor described in  FIG. 1  may consult the lookup table and read out the corresponding length from the volatile memory. Table 2 shows an example of the lookup table assuming that the multimedia file is a file of MPEG1, 11172-3, Layer II or Layer III. For example, if the potential bitrate Br 0  is 40kbit/s, the length L 0  can be stored as Len(Br 40 ) in the lookup table. Therefore, a potential bitrate Br 1  is acquired from the code segment H 1  (step S 308 ), and checked whether a length corresponding to the acquired bitrate Br 1  has been determined in the lookup table (step S 310 ). 
     
       
         
               
               
               
             
               
               
               
             
           
               
                   
                 TABLE 2 
               
             
             
               
                   
                   
               
               
                   
                 Bitrate specified (kbit/s) 
                   
               
               
                   
                 for Fs = 16, 22, 05, 24 kHz 
               
             
          
           
               
                 BITRATE 
                 Layer II, Layer III 
                 Frame length 
               
               
                   
               
               
                 ‘0000’ 
                 free 
                 — 
               
               
                 ‘0001’ 
                 8 
                 N/A 
               
               
                 ‘0010’ 
                 16 
                 N/A 
               
               
                 ‘0011’ 
                 24 
                 N/A 
               
               
                 ‘0100’ 
                 32 
                 N/A 
               
               
                 ‘0101’ 
                 40 
                 Len(Br 40 ) 
               
               
                 ‘0110’ 
                 48 
                 N/A 
               
               
                 ‘0111’ 
                 56 
                 N/A 
               
               
                 ‘1000’ 
                 64 
                 N/A 
               
               
                 ‘1001’ 
                 80 
                 N/A 
               
               
                 ‘1010’ 
                 96 
                 N/A 
               
               
                 ‘1011’ 
                 112 
                 N/A 
               
               
                 ‘1100’ 
                 128 
                 N/A 
               
               
                 ‘1101’ 
                 144 
                 N/A 
               
               
                 ‘1110’ 
                 160 
                 N/A 
               
               
                 ‘1111’ 
                 forbidden 
                 — 
               
               
                   
               
             
          
         
       
     
     When the length corresponding to the acquired bitrate Br 1  is not determined (e.g bitrate Br 1  is 96kbit/s and no frame length stored in Table 2 corresponds to bitrate Br 1 ), a length of the frame L 1  is predicted by using a formula employing at least parameters of a proportion of the length L 0  to the bitrate Br 0  and Br 1  (step S 312 ). For example, the length L 1  is predicted as Br 1 ×(L 0 /Br 0 ). A position Pc is set as P 1  plus the predicted length L 1  (step S 314 ). A search region is defined between Pc minus a tolerance length Lb 1  and Pc plus the tolerance length Lb 1  plus a predetermined header length (step S 316 ). The tolerance length Lb 1  could be the smallest integer larger than Br max /Br min , where Br max  and Br min  are respectively the possible maximum and minimum bitrates of a frame. Referring to  FIG. 4(B) , a code segment H 2 , with a start position P 2 , comprising the common pattern with the specific organization is acquired from the search region (step S 318 ). Accordingly, the length L 1  is updated with an actual length between the start positions P 1  and P 2 , and a mapping between Br 1  and L 1  is stored in the lookup table (step S 320 ). 
     When the length corresponding to the acquired bitrate Br 1  is determined (e.g. bitrate Br 1  is 40kbit/s and the corresponding frame length Len(Br 40 ) has been found in Table 2), a predetermined (i.e. stored) length Ld corresponding to the bitrate Br 1  is acquired from the lookup table (step S 322 ), and a position Pc is set as P 1  plus the predetermined length Ld (step S 324 ). A search region between Pc minus a tolerance length Lb 2  (e.g. 1 byte) and Pc plus the tolerance length Lb 2  plus the predetermined header length is defined (step S 326 ). The code segment H 2 , with a start position P 2 , comprising the common pattern with the specific organization is acquired from the search region (step S 328 ). 
     Else, when the start position P 2  can be discovered from the search region, the length L 0  can be deemed reliable and the proportion of L 0  to Br 0  can also be deemed reliable. Moreover, the discovered same patterns with the specific organization of code segments H 0  and H 1  can be deemed reliable. When the start position P 2  cannot be discovered in the search region, however, another common pattern is needed to be found out to acquire a new length L 0 , and the new L 0  is needed to be validated again. For solving such exceptional result, steps S 302  to S 328  may be re-executed after the previously acquired code segment H 0  of the multimedia sequence. 
       FIG. 3(B)  is a continuous flowchart of  FIG. 3(A) . The code segment H 2  is set as a frame header H(i−1) with a start position P(i−1) (step S 330 ). The bitrate Br(i−1) is acquired from the frame header H(i−1) (step S 332 ), and then checked whether a length corresponding to the acquired bitrate Br(i−1) has been determined (step S 334 ). When the length corresponding to the acquired bitrate Br(i−1) is not determined, a length of the (i−1)th frame L(i−1) is predicted by using a formula employing at least parameters of Br(i−1) and a proportion of the length L 0  to the bitrate Br 0  (step S 336 ), and a position Pc is set as P(i−1) plus the predicted length L(i−1) (step S 338 ). A search region is defined between Pc minus a tolerance length Lb 1  and Pc plus the tolerance length Lb 1  plus the predetermined header length (step S 340 ). The tolerance length Lb 1 , for example, could be the smallest integer larger than Br max /Br min , where Br max  and Br min  are respectively the possible maximum and minimum bitrate of a frame. A frame header, with a start position P(i), comprising the common pattern with the specific organization is acquired from the search region (step S 342 ). Accordingly, the length L(i−1) is updated with an actual length between the start positions P(i−1) and P(i), and a mapping between Br(i−1) and L(i−1) is stored in the lookup table (step S 344 ). 
     Else, when the length corresponding to the acquired bitrate Br(i−1) is determined, a predetermined length Ld corresponding to the bitrate Br(i−1) is acquired from the lookup table (step S 346 ), and a position Pc is set as P(i−1) plus the predetermined length Ld (step S 348 ). A search region between Pc minus a tolerance length Lb 2  (e.g. 1 byte) and Pc plus the tolerance length Lb 2  plus the predetermined header length is defined (step S 350 ). It is to be understood that the tolerance length Lb 2  present in step S 350  may be smaller than the tolerance length Lb 1  present in step S 450 . A frame header, with a start position P(i), comprising the common pattern with the specific organization is acquired from the search region (step S 352 ). After the frame header comprising P(i) has been found, it is determined whether the multimedia file ends (step S 354 ). If so, the whole process also ends; if not, the acquired frame header is set as frame header H(i−1) (step S 356 ) and then back to step S 332  to discover subsequent multimedia frames. 
     An advantage of the embodiment is that the frame size can be determined only by one variable, i.e. frame bitrate, from a multimedia sequence which has synchronous pattern (or common pattern) and bitrate information in each frame header. Another advantage of the embodiment is that, because types of bitrate are limited, a record of a frame length corresponding to a bitrate type in a lookup table can be generated and stored upon acquisition of the mapping via the formula, and validation of the mapping by inspection of the next frame header. Therefore, the search time during decoding can be reduced. 
     While the invention has been described by way of examples and in terms of preferred embodiments, it is to be understood that the invention is not limited thereto. Any variation or modification can be made by those skilled in art without departing from the spirit or scope of the invention. Therefore, the scope of the appended claims should be accorded the broadest interpretation to encompass all such modifications and similar arrangements.