Abstract:
A method and device for sharing MPEG frame buffers utilizes a shared bidirectional frame buffer, which is used for temporarily storing bidirectional predicted pictures, to reduce the quantity of bidirectional frame buffers. And, through monitoring and controlling the displaying units and the decoding units, the method and device avoids the decoded image data overwriting the image data, which has not yet been displayed, in the shared bidirectional frame buffer.

Description:
BACKGROUND OF THE INVENTION  
       [0001]     1. Field of the Invention  
         [0002]     The present invention generally relates to a method and device for sharing memory, and more particularly to a method and device for sharing frame buffers of frames in MPEG (Moving Picture Experts Group).  
         [0003]     2. Description of the Prior Art  
         [0004]      FIG. 1  is a schematic block diagram illustrating a conventional decoding system of MPEG. The decoding unit  110  decodes the bit stream data into image data. In accordance with the frame compression mode of the image data the buffer  120  stores the image data in the corresponding forward reference buffer  122 , the backward reference buffer  124 , the first Bi-directional (B 1 ) frame buffer  126  and the second Bi-directional (B 2 ) frame buffer  128 , respectively. The display unit  130  reads out and displays the image data in accordance with the assigned sequence of the image data stored in the buffer  120 . The forward reference buffer  122  is configured for storing, the backward reference buffer  124  is configured for storing, and the B 1  frame buffer  126  and the B 2  frame buffer  128  are configured for storing the first B frame and the second B frame of the Bi-directional predicted pictures, respectively. Herein, pictures in frame buffers are not restricted to Intra Coding Picture or Predictive Coding Pictures. In other words, picture in Forward reference buffer and Backward reference buffer may be Intra coding Picture or Predictive coding picture.  
         [0005]      FIG. 2  is a schematic diagram illustrating the decoding sequence and the playing sequence for I, P, and B frames in MPEG in accordance with the prior art. On one hand, the I 1 , P 1 , B 1 , B 2 , P 2 , . . . etc. frames in MPEG are decoded in order with reference to time axis “X”. On the other hand with reference to time axis “Y”, the frames in MPEG start to be played in sequence of I 1 , B 1 , B 2 , P 1 , . . . etc. after the complete decoding for the top field “T” of the frame P 1 . It is noted that “T” and “B” represent the top field and the bottom field respectively and as well as, F 0  and F 1  represent the first frame and the second frame respectively.  
         [0006]     In the prior art, the moment the decoding unit  110  completes decoding the top field T of B 1  frame and storing it in the B 1  frame buffer, the display unit  130  starts to play the B 1  frame. Furthermore, the display unit  130  plays the top field T of the B 1  frame (or the first frame F 0 ) at the moment that the decoding unit  110  decodes the bottom field B of the B 1  frame and stores it in the B 1  frame buffer. When the display unit  130  plays the bottom field B of the B 1  frame (or the second frame F 1 ), the decoding unit  110  decodes the top field T of the B 2  frame and stores it in the B 2  frame buffer. When the display unit  130  plays the top field T of the B 2  frame, the decoding unit  110  decodes the bottom field B of the B 2  frame and stores it in the B 2  frame buffer. And then the display unit  130  plays the bottom field B of the B 2  frame. As previously mentioned that the decoding and the playing sequence of the two sequent B frames, the data during reading and playing do not interference with each other by the two B frame buffers for each corresponding decoded frame. In other words, the data of the first B frame that is not displayed yet in the display unit  130  is not overwritten by the data of the second B frame even though the decoding speed is faster than the displaying speed.  
         [0007]     Nevertheless, refer to  FIG. 3 , the condition that the decoded data from the decoding unit  110  overwrites the data in the frame buffer  120  not read out by the display unit  130  may possibly happen while the B frame buffer is shared for some reasons, such as only single B frame buffer is used for saving the consumption and cost of memories. For example, referring to the period X 7  on the X time axis, the Top field B of the B 2  frame may possibly overwrite the Top field B of B 1  frame, which results in an data reading error, provided that the bottom field B of the B 1  frame is not readout completely yet, as well as the decoding speed is at least twice as fast as the display speed. Furthermore, the condition that the stored data is unable to be real time readout by the display unit  130  may be due to different display methods (for example: field display and frame display) accompanying with different structures (for example: frame structure, first top field and second bottom field, and first bottom field and second top field).  
         [0008]     As previously mentioned that the disadvantage of sharing MPEG frame buffer, it is needed a new and improved method to overcome the disadvantage of the prior art.  
       SUMMARY OF THE INVENTION  
       [0009]     In consideration of the prior art the process of MPEG decoding and playing, four buffers is provided for fear of overwriting data. Thus, a method and device of sharing MPEG frame buffer are provided herein for reducing the required numbers of buffers and the disadvantage generated by traditional sharing buffer.  
         [0010]     The invention provides a sharing B frame buffer for reducing the needed buffers for decoding and playing MPEG.  
         [0011]     The invention provides a method and device for sharing the dynamic image compression buffer. By monitoring the data reading speed of the displaying unit and by controlling the data writing speed of the decoding unit, the invention avoids overwriting in the sharing buffer.  
         [0012]     The invention provides a method and device for sharing dynamic image compression buffer. It reduces the data writing time by changing the location of the data is stored. It also effectively uses the sharing buffer space for real-time data reading.  
         [0013]     In short, the invention provides a method and device for sharing the MPEG frame buffer. It is by sharing a B frame buffer for reducing other B frame buffers used. By monitoring the reading B frame buffer data speed of the display unit and further by controlling the writing B frame buffer data speed of the decoding unit, it is to avoid the image data decoded by decoding unit in the sharing B frame buffer overwriting the display unit unread image data. By changing the position that the data is stored and by the space of the data that has been readout in the B frame buffer, the writing data of the decoding unit could be stored and then it is possible to reduce the waiting writing time of decoding unit. 
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0014]      FIG. 1  shows a prior schematic block diagram of MPEG decoding system;  
         [0015]      FIG. 2  shows a prior schematic diagram of the comparison of multi-picture decoding sequence and playing sequence in MPEG;  
         [0016]      FIG. 3  shows a schematic block diagram of the sharing MPEG buffer of the invention;  
         [0017]      FIG. 4A  shows a schematic block diagram of the sharing MPEG buffer of the invention applying in the method of the field display and the structure of the frame image data;  
         [0018]      FIG. 4B  shows the block diagram of the sharing MPEG buffer of the invention applying in the method of the field display and the structure of the first top field and the second bottom field image data (FTSB);  
         [0019]      FIG. 4C  shows the block diagram of the sharing MPEG buffer of the invention applying in the method of the field display and the structure of the first bottom field and the second top field image data (FBST);  
         [0020]      FIG. 4D  shows the block diagram of the sharing MPEG buffer of the invention applying in the method of the frame display and the structure of the frame image data;  
         [0021]      FIG. 4E  shows the block diagram of the sharing MPEG buffer of the invention applying in the method of the frame display and the structure of the first top field and the second bottom field image data (FTSB);  
         [0022]      FIG. 4F  shows the block diagram of the sharing MPEG buffer of the invention applying in the method of the frame display and the structure of the first top field and the second bottom field image data (FBST);  
         [0023]      FIG. 5A  shows a schematic diagram of the sharing buffer data for data reading and writing;  
         [0024]      FIG. 5B  shows another embodiment of the block diagram of the sharing MPEG buffer of the invention applying to the method of field display and the structure of the first bottom field and the second top field image data (FBST);  
         [0025]      FIG. 5C  shows another embodiment of the block diagram of the sharing MPEG buffer of the invention applying in the method of the frame display and the structure of the first top field and the second bottom field image data (FTSB); and  
         [0026]      FIG. 5D  shows another embodiment of the block diagram of the sharing MPEG buffer of the invention applying in the method of the frame display and the structure of the first top field and the second bottom field image data (FBST). 
     
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS  
       [0027]     Some of the embodiments of the invention will describe in detail and clearly as follows. However, except for the detailed description, the invention can widely apply in others. And the invention is not limited here but the claims.  
         [0028]     Otherwise, for easily understanding and clarifying the invention, the parts of the illustration does not depict in corresponding scale. Some scales and related ratio has been exaggerated, and the unrelated parts have not fully shown for the concise drawing.  
         [0029]      FIG. 3  shows the block diagram of sharing MPEG frame buffer in accordance with one embodiment of the invention. The decoding unit  310  decodes bitstream to the image data. The buffer  320  depending on the frame compression mode of the image data stores the image data in the forward reference buffer  322 , the backward reference buffer  324 , and the B frame buffer  326 , respectively. (Normally, memory forms storage device, hard disk or something likely also does). The display unit  330  following assigned sequence reads and displays the image data, which stores in the buffer  320 . The B frame buffer  326  provides the data with two B frames (the first B frame and the second B frame) in sequence for storing temporarily during decoding and reading-out for displaying. Under the condition of the uniform storage volume for the B frame buffer  326 , the speed of reading data in the display unit  330  as well as the speed of writing data in the decoding unit  310  are controlled for the sake of avoid overwriting and failing in reading in real time.  
         [0030]     Generally, there are two display types: field and frame and three picture structures: frame, FTSB (First Top field and Second Bottom field) and FBST (First Bottom field and Second Top field). A frame of 720*480 is an example for following illustrating processing methods in accompanying with different displaying methods and different picture structures, respectively. However, the application scopes of the invention are not limited to the size of a frame. It is noted that there are 720/16=45 macroblocks are in a row and 480/16=30 macroblocks are in a column for the frame of 720*480.  
         [0031]      FIG. 4A  shows the block diagram of the sharing MPEG buffer of the invention applying the method of the field display and the structure of the frame image data. In the step  411 , the display unit reads all of the top field rows of the first B frame while the bottom field row of the first B frame remain stored in every other position alternatively in the B frame buffer (such as: the second row, the fourth row, the sixth row etc.). The decoding unit checks whether the n-th row of the B frame buffer has been read out. If yes, the decoding unit sequentially writes the n-th frame macroblocks of the second B frame into the B frame buffer as follows: 0&lt;n&lt;31, where n is a positive integer (normally begins at n=1). In the step  412 , the decoding unit checks whether the n-th row of the B frame buffer has been readout. If no, the step  412  is repeated (i.e. waiting readout the n-th row). If yes, the n-th row of the second B frame is written in the B frame buffer as shown in step  413 . In the step  414 , the decoding unit checks whether all the frame macroblock in the second B frame have been written. If yes, the decode writing of the second B frame is completed. If no, n plus 1 as step  415  shown. Continuously repeating steps  412 ,  413  and  414  until all the frame macroblock of the second B frame decode are written completely.  
         [0032]     In the embodiment, because the top field row of the first B frame in the B frame buffer (i.e. the first row, the third row, the fifth row . . . odd rows etc..) has been readout before the action of the decoding unit, it is not necessary to wait for reading the top field row of the first B frame in the corresponding position when the decoding unit intends to write the odd frame row of the second B frame into B frame buffer. In other words, the odd frame row of the second B frame can be written into directly.  
         [0033]      FIG. 4B  shows the block diagram of the sharing MPEG buffer of the invention applying the method of the field display and the structure of the first top field and the second bottom field image data (FTSB). In step  421 , the display unit reads all the top field rows of the first B frame while the bottom field row of the first B frame is stored in every other position alternatively in the B frame buffer (such as: the second row, the fourth row, the sixth row etc.) at the moment. In step  422 , the decoding unit sequentially writes all the top field rows of the second B frame and display unit also sequentially reads the bottom field row of the first B frame. In the step  423 , the decoding unit checks whether the 2n-th row of the B frame buffer (the nth bottom field row of the first B frame) has been readout before writing, where 0&lt;n&lt;16 and n is a positive integer. If no, step  423  is repeated (wait until the 2n row readout). If yes, the n-th bottom field row of the second B frame is written into the B frame buffer as shown in step  424 . In step  425 , the decoding unit checks whether all the bottom field rows of the second B frame are written completely or not. If yes, the decode writing of the second B frame is terminated. If no, return to step  423  and repeat sequential steps,  424 ,  425  with n plus 1 in step  426  until the entire bottom field row of the second B frame are written completely by the decoding unit.  
         [0034]     Similarly, the decoding unit writes all the top field rows of the second B frame into the B frame buffer, followed sequentially by checking the reading progress of the bottom field row of the first B frame and scheduled writing the bottom field row of the second B frame, on the ground that the top field row of the first B frame stored in every other position alternatively in B frame buffer has been readout before the action of the decoding unit and the first top field and second bottom field data structure is applied on decoding the second B frame data.  
         [0035]      FIG. 4C  shows the block diagram of the sharing MPEG buffer of the invention applying the method of the field display and the structure of the first bottom field and the second top field image data (FBST). In step  431 , the display unit reads all the top field rows of the first B frame while the bottom field row of the first B frame is still stored in every other position alternatively in the B frame buffer at the moment (such as: the second row, the fourth row, the sixth row etc.). In step  432 , the decoding unit checks whether the  2 n row of the B frame buffer (the n-th bottom field row of the first B frame) is read or not, where 0&lt;n&lt;16 and n is a positive integer. If no, repeat the step  432  (wait until the 2n row readout). If yes, write the n-th bottom field row of the second B frame in the B frame buffer as shown in step  433 . In the step  434 , the decoding unit checks whether all the bottom field rows of the second B frame are written or not. If no, n plus 1 as shown in step  436  and continuously repeats steps  432 ,  433 ,  434  and  436  until all the bottom field row of the second B frame decode is successfully written. If yes, as step  435  the decoding unit sequentially writes all the top field rows of the second B frame.  
         [0036]     In the embodiment, because the second B frame data decoded by decoding unit is the first bottom field and the second top field data structure (FBST), it is necessary to wait for all the bottom field of the first B frame to be read and then write the bottom field of the second B frame row. The following step is sequentially decoding and writing in all the top field row of the second B frame.  
         [0037]      FIG. 4D  shows the block diagram of the sharing MPEG buffer of the invention applying the method of the frame display and the structure of the frame image data. Here, the frame display needs to be read twice (F 0  &amp; F 1 ). In the case and other cases that top field and bottom field is no different for the operation, the term indicated by “row” in the previous embodiment(s) could be called as “macroblock row”. The display unit fully reads F 0  of the first B frame and the decoding unit writes the second frame data in, depending on how many F 1  of the first B frame has been read. In the step  441 , the display unit reads F 0  of the first B frame. In the step  442 , the decoding unit firstly judges whether the n row of the first B frame in the buffer has been readout. As step  443  shows, while the data has been readout, writes the n frame row of the second B frame in B frame buffer. In step  444 , the decoding unit checks whether all the frames of the second B frame has written. If yes, the decoding ends the writing of the second B frame. If no, n adds 1 as shown in step  445  and then continuously repeats steps  442 ,  443  and  444  until all the frame macroblocks of the second B frame are decoded.  
         [0038]     In the embodiment, the display unit reads one row of the first B frame and immediately the decoding unit writes one row of the second B frame in the corresponding row.  
         [0039]      FIG. 4E  shows the block diagram of the sharing MPEG buffer of the invention applying the method of the frame display and the structure of the first top field and the second bottom field image data (FTSB). Similarly, after decoding the first B frame, in progress of displaying F 1  of the first B frame, the decoding unit checks whether the 2n-th row in the B frame buffer has been readout. If yes, fill in the n-th top field row of the second B frame and then fill in the bottom field as shown in figure. In the step  451 , the display unit reads the F 0  of the first B frame. In the step  452 , the decoding unit determines whether 2n row has been readout. If yes, write the n-th top field row of the second B frame in B frame buffer as shown in the step  453 . If no, follow the step  451  and  452 . In the step  454 , the decoding unit checks whether all the top field rows of the second B frame has been written. If no, n adds 1 as shown in the step  456 . And repeat the steps  452 ,  453  and  454  until all the top field macroblock of the second B frame has been decoded. If yes, as shown in the step  455 , the decoding unit sequentially writes all the bottom field row of the second B frame in.  
         [0040]     In the embodiment, the second B frame data decoded by the decoding unit is the structure of the first top field and the second bottom field (FTSB) and it needs to wait until all the top field macorblock row of the first B frame readout to write all the top field row of the second B frame. And then sequentially decodes and writes all the bottom field row of the second B frame.  
         [0041]      FIG. 4F  shows the block diagram of the sharing MPEG buffer of the invention applying the method of the frame display and the structure of the first top field and the second bottom field image data (FBST). Similarly, after decoding of the first B frame, in progress of displaying F 1  of the first B frame, the decoding unit check whether the 2n-th row in the B frame buffer has readout. If yes, initially fill the nth bottom field row of the second B frame and then fill ill in the top field as shown in figure. In step  461 , the display unit reads the F 0  of the first B frame. In step  462 , the decoding unit determines whether 2n row has readout. If yes, write the nth bottom field row of the second B frame in the B frame buffer as shown in step  463  and further follow step  464 . If no, repeat step  462 . In step  464 , the decoding unit checks whether all the bottom field row of the second B frame has been written. If no, n adds 1 as shown in step  466 . And repeat the steps  462 ,  463  and  464  until all the bottom field macroblocks of the second B frame have been decoded. If yes, as shown in step  465 , the decoding unit sequentially writes in all the top field rows of the second B frame.  
         [0042]     In the embodiment, the second B frame data decoded by decoding unit is the structure of the first bottom field and the second top field (FBST) and it needs to wait until all the top field macorblock rows of the first B frame readout to write all the bottom field rows of the second B frame. And then sequentially decode and write in all the top field rows of the second B frame.  
         [0043]     As the previous embodiments mentioned, the decoding unit writes the decoded row data in the corresponding row of the B frame buffer. The decoding unit needs to wait until the corresponding row is readout in the corresponding macroblock. In other words, the decoding unit does not write data in even though the B frame buffer has space. As the result, the writing speed of the decoding unit is limited to the reading speed of the display unit. As shown in  FIG. 5A , the invention provides other embodiments that data is written in the memory space has been readout. In the sharing B frame buffer  510 , the data of the decoded macroblock is written in the macroblock row that the data has been readout (not limited to the corresponding row). Of course, in this kind embodiments, the display unit provides three other reading methods of the buffer for different located data and for reducing the data waiting time of the decoding unit. Clearly, these kind embodiments fully use the space of the B frame buffer  510 .  
         [0044]      FIG. 5B  shows the block diagram of another embodiment of the sharing MPEG buffer of the invention applying the method of the field display and the structure of the first bottom field and the second top field image data (FBST). In step  531 , the display unit reads all the top field rows of the first B frame and the bottom field rows of the first B frame stills are stored in every other position alternatively in the B frame buffer (such as: the second row, the fourth row, the sixth row etc.). In step  532 , the decoding unit sequentially writes the bottom field row of the second B frame in place, which originally stores the top field row of the first B frame. At the same time, the display unit sequentially reads the bottom field row of the first B frame. In step  533 , the decoding unit sequentially writes the top field row of the second B frame in place, which originally stores the bottom field row of the first B frame. Of course, the display unit must be notified that the top field and the bottom field location of the second B frame in B frame must exchange.  
         [0045]     In the embodiment, the decoding unit does not need to wait for the bottom field row of the first B frame readout when writing the bottom row of the second B frame. As the result, the executing speed of the decoding unit in not limited to the executing speed of the display unit in the period (for normal hardware technology, the speed of the decoding unit is twice faster than the speed of the display unit). When the display unit reads the bottom field row of the first B frame, the decoding unit possibly could finish writing all the bottom field row of the second B frame and then the decoding unit could continuously and sequentially writes the top field row of the second B frame in place, which has been readout in the bottom field row of the first B frame. By this, the data writing time is reduced for real-time reading.  
         [0046]      FIG. 5C  shows another embodiment of the block diagram of the sharing MPEG buffer of the invention applying the method of the frame display and the structure of the first top field and the second bottom field image data (FTSB). In step  551 , the display unit reads the n-th frame row of the first B frame where 0&lt;n&lt;31 and n is a positive integer. In step  552 , the decoding unit writes the m-th top field row of the second B frame in the place, which originally stored the n-th frame row of the first B frame where m=n, 0&lt;m&lt;16 and m is the positive integer. In step  553 , the decoding unit checks whether all the top field rows of the second B frame have been written. If no, n adds 1 as shown in step  555 . And repeats the steps  551 ,  552 ,  553  and  555  until all the top field macroblocks of the second B frame have been decoded. If yes, as shown in step  554 , the decoding unit sequentially writes in all the bottom field rows of the second B frame. In step  554 , the decoding unit immediately writes a row of the bottom field row of the second B frame in place, which originally stored the frame macroblock of the first B frame, after the display unit reads a row of the frame row of the first B frame. Of course, the display unit must be notified that the top field of the second B frame is located at upper part of B frame buffer, and bottom field is located at lower part of the frame buffer.  
         [0047]     In the embodiment, the decoding unit immediately writes a row of the bottom field row of the second B frame in place, which originally stored the macroblock frame of the first B frame after the display unit reads a row of the macroblock frame row of the first B frame, wherein the row of the second B frame includes a top field row and bottom field row. In other words, the decoding unit immediately writes all the top field rows of the second B frame into the B frame buffer when the display unit reads half the frame rows of the first B frame. And the decoding unit also immediately writes all the bottom field rows of the second B frame in the B frame buffer when the display unit continuously reads the other half frame row of the first B frame. By this, the data writing time has been reduced for real-time reading.  
         [0048]      FIG. 5D  shows another embodiment of the block diagram of the sharing MPEG buffer of the invention applying the method of the frame display and the structure of the first top field and the second bottom field image data (FBST). In step  561 , the display unit reads the n-th frame row of the first B frame where 0&lt;n&lt;31 and n is positive integer. In step  562 , the decoding unit writes the m-th bottom field row of the second B frame in place, which originally stored the n-th frame row of the first B frame where m=n, 0&lt;m&lt;16 and m is a positive integer. In step  563 , the decoding unit checks whether all the bottom field rows of the second B frame have been written. If no, n adds 1 as shown in step  565 . And repeats the steps  561 ,  562 ,  563  and  565  until all the bottom field macroblocks of the second B frame have decoded. If yes, as shown in step  564 , the decoding unit sequentially writes in all the top field rows of the second B frame. Herein, the decoding unit immediately writes a row of the top field row of the second B frame in place, which originally stored the frame macroblock of the first B frame after the display unit reads a row of the frame row of the first B frame.  
         [0049]     In the embodiment, the decoding unit immediately writes a row of the row of the second B frame in place, which originally stored the frame macroblock of the first B frame after the display unit reads a row of the frame row of the first B frame. Wherein the row of the second B frame includes a bottom field row and top field row. In other words, the decoding unit immediately writes all the bottom field rows of the second B frame in B frame buffer when the display unit reads the half frame row of the first B frame. And the decoding unit immediately writes all the top field rows of the second B frame in the B frame buffer when the display unit continuously reads the other half frame row of the first B frame. By this, the data writing time has been reduced for real-time reading.  
         [0050]     Other embodiments of the invention will appear to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. It is intended that the specification and examples to be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.