The invention is related to multimedia applications requiring buffering of data.
Multimedia applications typically perform various computing tasks on the multimedia data before the data could be displayed on a display device to the user. These applications use data buffers allocated on the system memory to store and process the media data and typically require sufficient amount of memory to store these buffers. Most of the current day computing systems have many applications that coexist on the same system and run at the same time sharing the common system resources such as memory, central processing unit (CPU), etc.
Because these known producer based memory allocation approaches may undesirably create excessive memory copies that could potentially slow down the performance of the desired applications, it would be beneficial to utilize improved memory allocation processes. As such, it would be beneficial to develop memory allocation processes in which the memory allocations to applications are just the sufficient or right amount and do not over allocate or waste the memory resources, thereby ensuring other applications that need memory can operate properly or more efficiently.
A consumer or consumption approach based model of memory buffer allocation is disclosed that optimizes the memory buffers allocated to multimedia applications resulting in better use of system resources as well as reducing the computationally expensive operation of memory buffer copy, thereby leading to improved performance of multimedia applications.
One embodiment involve a method of accessing and storing multiple media data segments from a producing device on to a consumer device that can involves allocating a portion of memory buffer on a consumer device for receiving the multiple media data segments, wherein the allocation of the portion is performed responsive to the nature of the multiple media data segments in which the multiple media segments can be read from a file reader and the multiple media segments can be MP4, AV1 or MP3 multimedia file formats. The method can further include the steps of accessing a first segment of the multiple media data segments for writing; verifying a status of the portion of memory buffer as being available to receive the first segment or not being available to receive the first segment; writing the first segment to the portion when the portion is available; storing the first segment on the consumer device; removing the first segment from the portion; and repeating the allocating, accessing, verifying, writing, and storing steps for other segments, one by one. Additional steps can include receiving the multiple media data segments by the consumer device employing a network protocol, creating the portion of the memory buffer from a memory pool of graphics card internal memory; and/or having the consumer device communicate the input data rate required by the consumer device to receive the multimedia data segments. The method can also include the step of limiting the portion of memory buffer such that the portion has a fixed size that is limited to a necessary and sufficient quantity, thereby other portions of the memory buffer are free for other applications.
An aspect of the invention can involve a system in which at least one producing device provides multiple media data segments to a consumer device that employs the steps of allocating specific memory buffers on the consumer device for receiving the multiple media data segments, wherein the allocation of the specific memory buffers is performed responsive to the nature of multiple media data segments; accessing a first segment of the multiple media data segments for writing; verifying a status of the specific memory buffers as being available to receive the first segment or not available to receive the first segment; writing the first segment to the specific memory buffers when the specific memory buffers are available; storing the first segment on the consumer device, wherein the first segment can be subsequently removed from the portion; and repeating the steps for other segments, one by one. The system can be adapted to include the steps of limiting the specific memory buffers to fixed sizes which are sufficient to permit other portions of memory on the consumer device to be free for other applications.
An additional aspect of the invention for cases that involve accessing and storing multiple stages of media data from at least one producing device on to a consumer device can comprise the steps of accessing a header for each of the stages; allocating specific memory buffers on the consumer device for receiving the multiple stages data, wherein the specific memory buffers have a fixed size that is large enough to store all the headers and a user provided payload buffer; separately accessing each stage for writing; verifying a status of the specific memory buffers as being available to receive the given stage or not available to receive the given stage; writing the given stage to the specific memory buffers when the specific memory buffers are available; storing the given segment on the consumer device; and removing the given segment from the specific memory buffers and freeing the specific memory buffers for a next stage to be processed in the verifying, writing and storing steps. The consumer and/or producer devices can be further adapted such that specific memory buffers can be limited to a necessary and sufficient quantity or quantities such that other portions of memory on the consuming device are free for other applications. Further steps can include creating the specific memory buffers from a memory pool of graphics card internal memory, wherein the specific memory buffers can be created according to stacked network protocols and can also be created such that each protocol is implemented as a stage that requires adding its own header to the memory block containing user provided payload. At least one stage can use an RTP protocol and an RTP protocol header can be added in front of at least one user provided payload. Additionally, multiple producers can be accessed and the consumer device can be adapted to permit the producers to just fill in their header portion.
The invention will now be described by way of example with reference to the accompanying figures which are as follows:
To address the issue of optimal allocation of memory, a consumption approach based model of memory buffer allocation is disclosed that optimizes the memory buffers allocated to multimedia applications resulting in better use of system resources as well as reducing the computationally expensive operation of memory buffer copy, thereby leading to improved performance of multimedia applications. The memory buffers are allocated at the consumer of a particular type of data. Thus, the uncompressed media buffers can be created out of the memory pool of the graphics. Using this approach, only the necessary and sufficient quantity of data buffers are allocated to the multimedia applications, thereby freeing up a greater quantity of system memory resources to be used by other applications that are in need of such resources.
In a typical multimedia application such as a media player that plays a compressed media files stored on a storage medium, the processing steps include reading portions of file into memory buffers, uncompressing the media data and then displaying it on a display device. During each of the steps above, memory buffers are used to hold the input data and the output data resulting from the processing such as compressed data and uncompressed data. As the data gets processed from input format to the data suitable for display, memory buffers are handed over from one computing task to next. Also, in case a computing task uses its own private memory such as the graphics display device, memory buffer from previous stage of computation has to be copied into the next stage's memory buffer region. In such a system as the file is being played continuously, many memory copies result since the buffers are allocated by the producer or the originator of the data. In addition, as the display memory is considerably less than the overall system memory the previous processing stages may allocate more buffers than needed and hold them in a manner that would in no way help the performance of the application at the same time depriving other applications running on the same system of memory.
However, by having a consumer model of memory buffer approach where instead of allocating memory at the source or the producer of data, memory buffers are provided by the consumer, memory buffer copies are minimized and producers do not over allocate idle buffers and work at the rate consumers operate.
For some applications, performance could be greatly increased by directly writing into the display memory rather than writing into the system memory and then copying into the graphics card's internal memory, because memory copies are computationally expensive.
In at least one multimedia application, a pipe-lined data flow model is used in which data flows from one computing/processing task to the next. For example, in a multimedia player application that could play media files containing compressed video or audio such as a MP4 file, the typical computational tasks include reading the media content from the file residing on a storage device in smaller chunks into memory, uncompressing or decoding the data that was read and finally rendering the uncompressed media data on a hardware device such as a display device for video media. If the same media player application is capable of playing media files obtained from a network, then it would include processing tasks of obtaining media data over the network using suitable networking protocols in place of reading the file from a storage device. As evident from the previously mentioned processing tasks, in these applications the data flows in a pipe-lined fashion from one stage to another. The data flow between the stages or computational tasks in such a system is accomplished by means of allocating data buffers that are shared among the stages within the application. To illustrate, one of the stages such as reading from a file creates or produces the data buffers that are subsequently consumed by another stage such as a decoder which is part of the data pipeline. Since the data entering a stage as input might leave the stage unaltered or might get transformed during the processing at a stage, the data buffers of various kinds are needed to accomplish the overall goal of the application. In addition, it may also be possible that some of the stages have their own physical memory to store working memory buffers in which case the data from previous stage has to be copied into these local memory buffers. This is true in case of a graphics display device which uses its own memory to store the data to be displayed. Since the multimedia content is large in size as well as has to be played for a longer duration, the memory buffer requirements for such applications are quite large and possibly involve lots of memory copies between buffers if some of the stages have local memory. This is undesirable since the memory copies could potentially slow down the performance of the application. Also in case of the buffer allocation based on producer model in which the stages that are data producers allocate memory buffers, it is difficult to allocate the exact amount of buffers needed ahead of time since buffer consumption rate may not be known. In these situations, if a producer is producing or filling up buffers at a rate greater than the rate consumed, it would hold up the memory without any use and also prevent any other applications running on the system that are short on the memory. To alleviate these problems a consumer centric memory buffer allocation model is proposed.
In this approach, the memory buffers are allocated at the consumer of a particular type of data. Thus, the uncompressed media buffers are created out of the memory pool of the graphics device. The prior stage when it needs to output a data buffer to its next stage queries the next stage for a memory buffer. In case a memory buffer is available the data will be directly written into the consumer buffer. Otherwise the prior stage will wait until a buffer becomes available. With such an approach the memory copies are minimized and the producer or the data originator matches its output to the rate required by the consumer, rather than non-deterministically producing more data than required, thereby resulting either in wasted memory or incurring memory copy penalty or both of these inefficiencies.
The minimization of memory copies using this approach over the producer based allocation scheme could be illustrated using applications that create data buffers using layered approach. An example for such an application is stacked network protocols. In this application each protocol implemented as a stage requires adding its own header to the memory block containing user provided payload. For example, a RTP packetizer stage that prepares packets to be sent using RTP protocol would need to add the RTP protocol header in front of the user payload. Therefore, this stage would need to allocate a bigger buffer that would hold the header and user payload and then store the header and copy the payload from the payload buffer. RTP protocol over IP normally uses UDP or TCP transport for transmitting packets on IP network. If the prepared RTP packet from RTP packetizer is then handed over to an UDP stage, then this protocol will need to add another header by the same means which requires yet another memory buffer allocation and buffer copy. Based on the number of protocol layers the application implements, the number of buffer allocations and memory copies will be significant if the each protocol stage allocates the data buffer and passes on to the next protocol stage. If the consumer based buffer allocation scheme is followed for the same application scenario, each receiving protocol or consumer stage will add the size of header header to the memory size requested by the producer or a previous stage and the final consumer or the stage that has no subsequent successors to it will allocate a single buffer that is large enough to store all the headers added by previous stages and the user provided payload buffer. Each of the producers will just fill in their header portion and the payload buffer will or need to be copied once into the single large buffer. Therefore, the consumer based memory allocation significantly reduces buffer allocation and memory copies in applications that involve layered data creation.
More particularly, in
The foregoing illustrates only some of the possibilities for practicing the invention. Many other embodiments are possible within the scope and spirit of the invention. It is, therefore, intended that the foregoing description be regarded as illustrative rather than limiting, and that the scope of the invention is given by the appended claims together with their full range of equivalents
This application claims priority from U.S. Provisional Application 61/458,691 filed Nov. 30, 2010 which is incorporated by reference herein in its entirety.
Number | Date | Country | |
---|---|---|---|
61458691 | Nov 2010 | US |