Disclosure of Invention
In order to overcome the above technical problems or at least partially solve the above technical problems, the following technical solutions are proposed:
one embodiment of the present invention provides a method for adjusting a multimedia decoding information buffer, comprising:
when the decoding of the multimedia information is monitored to be completed, judging whether a buffer area needs to be reallocated or not based on the multimedia parameters obtained according to the decoded data so as to cache the decoded data;
when the buffer area needs to be reallocated, determining the reallocated buffer area based on the multimedia parameters;
the decoded data is buffered in the reallocated buffer.
Preferably, before the step of decoding the multimedia information, the method further comprises:
initializing an initial capacity of an allocation buffer based on a buffer allocation parameter;
wherein, the step of determining whether the buffer needs to be reallocated based on the multimedia parameters comprises:
and judging whether the buffer area needs to be reallocated or not based on the comparison result of the multimedia parameters and the initial capacity of the initial allocation buffer area.
Preferably, the buffer is judged to need to be reallocated when the comparison result satisfies any one of the following conditions:
the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is smaller than the calculation result of the multimedia parameters which is obtained through calculation based on the preset operation mode; or
And the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is larger than the calculation result of the multimedia parameters which is obtained through calculation based on the preset operation mode, and the difference value of the two is larger than the first threshold value.
The multimedia parameters comprise the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and preset related parameters.
Preferably, the step of determining the reallocated buffer area based on the multimedia parameters comprises:
determining the number of the redistribution buffer areas based on the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and a preset related parameter;
based on the number of the re-allocated buffers, notifying and calling a release memory function of the open multimedia acceleration layer OpenMax, releasing the initially allocated buffers, calling an allocation memory function of the open multimedia acceleration layer OpenMax, and re-allocating the buffers.
Preferably, the method further comprises:
the buffer allocation parameter is updated based on the number of reallocated buffers.
Another embodiment of the present invention provides an apparatus for adjusting a multimedia decoding information buffer, including:
the monitoring module is used for judging whether a buffer area needs to be reallocated or not based on the multimedia parameters obtained according to the decoding data to cache the decoding data when the decoding of the multimedia information is monitored to be completed;
the allocation module is used for determining the reallocated buffer area based on the multimedia parameters when the buffer area needs to be reallocated;
and the buffer module is used for buffering the decoded data into the reallocated buffer area.
Preferably, the apparatus further comprises: the initialization module is used for initializing the initial capacity of the allocated buffer area based on the buffer area allocation parameter;
the monitoring module is used for judging whether the buffer area needs to be reallocated or not based on the comparison result of the multimedia parameters and the initial capacity of the initial allocation buffer area.
Preferably, the buffer is judged to need to be reallocated when the comparison result satisfies any one of the following conditions:
the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is smaller than the calculation result of the multimedia parameters which is obtained through calculation based on the preset operation mode; or
And the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is larger than the calculation result of the multimedia parameters which is obtained through calculation based on the preset operation mode, and the difference value of the two is larger than the first threshold value.
The multimedia parameters comprise the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and preset related parameters.
Preferably, the buffer module includes:
the determining unit is used for determining the number of the redistribution buffers based on the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and the preset related parameter;
and the reallocation unit is used for notifying and calling a release memory function of the open multimedia acceleration layer OpenMax based on the number of the reallocated buffer areas, releasing the initially allocated buffer areas, calling an allocation memory function of the open multimedia acceleration layer OpenMax and reallocating the buffer areas.
Preferably, the apparatus further comprises: and the updating module is used for updating the buffer allocation parameters based on the number of the re-allocated buffers.
In the technical scheme of the invention, when the decoding of the multimedia information is monitored to be completed, whether a buffer area needs to be reallocated is judged based on the multimedia parameters obtained according to the decoded data so as to cache the decoded data; when the buffer area needs to be reallocated, determining the reallocated buffer area based on the multimedia parameters; buffering the decoded data into a reallocated buffer; therefore, the purpose of dynamically adjusting the preset buffer area based on the multimedia parameters of the multimedia information to be played is achieved, the smooth playing of the multimedia information to be played is met, the situation of jamming or errors in the playing of the multimedia information to be played is avoided, meanwhile, the occupation of redundant system memory can be reduced, the system operation performance of the playing equipment and the operation of other applications are prevented from being influenced, and the use experience of a user is improved.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are illustrative only and should not be construed as limiting the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
FIG. 1 is a flowchart illustrating a method for adjusting a multimedia decoding information buffer according to an embodiment of the present invention.
It should be noted that the execution subject of the present embodiment is a hardware vendor decoding library. The hardware manufacturer decoding library is a set of packaged program interfaces provided by embedded equipment core chip manufacturers, and can complete the coding and decoding of multimedia information, such as the coding and decoding of audio, video and the like, and allocate and release a buffer area for caching the decoding data of the multimedia information; and the hardware vendor decoding library can also communicate with the gst-omx module.
Step S101: when the decoding of the multimedia information is monitored to be completed, judging whether a buffer area needs to be reallocated or not based on the multimedia parameters obtained according to the decoded data so as to cache the decoded data; step S102: when the buffer area needs to be reallocated, determining the reallocated buffer area based on the multimedia parameters; step S103: the decoded data is buffered in the reallocated buffer.
In the technical scheme of the invention, when the decoding of the multimedia information is monitored to be completed, whether a buffer area needs to be reallocated is judged based on the multimedia parameters obtained according to the decoded data so as to cache the decoded data; when the buffer area needs to be reallocated, determining the reallocated buffer area based on the multimedia parameters; buffering the decoded data into a reallocated buffer; therefore, the purpose of dynamically adjusting the preset buffer area based on the multimedia parameters of the multimedia information to be played is achieved, the smooth playing of the multimedia information to be played is met, the situation of jamming or errors in the playing of the multimedia information to be played is avoided, meanwhile, the occupation of redundant system memory can be reduced, the system operation performance of the playing equipment and the operation of other applications are prevented from being influenced, and the use experience of a user is improved.
The following further explains the specific implementation of each step:
step S101: when the decoding of the multimedia information is monitored to be completed, whether a buffer area needs to be reallocated or not is judged based on the multimedia parameters obtained according to the decoded data so as to cache the decoded data.
Among them, the multimedia information includes but is not limited to: video information, audio information.
The multimedia parameters comprise the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and preset related parameters; the preset related parameters comprise the number of the output-avoiding pause buffers, the number of the reconstruction frames and the number of the reserved buffers of the SurfaceFlinger component.
Specifically, before the step of decoding the multimedia information, the method further comprises: an initial capacity of the allocation buffer is initialized based on the buffer allocation parameter.
Wherein, the buffer allocation parameter is the buffer allocation number.
Specifically, the step of determining whether the buffer needs to be reallocated based on the multimedia parameters comprises: and judging whether the buffer area needs to be reallocated or not based on the comparison result of the multimedia parameters and the initial capacity of the initial allocation buffer area.
Wherein, when the comparison result satisfies any one of the following conditions, the buffer needs to be reallocated: the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is smaller than the calculation result of the multimedia parameters which is obtained through calculation based on the preset operation mode; or the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is larger than the calculation result obtained by calculating the multimedia parameters based on the preset operation mode, and the difference value of the two is larger than the first threshold value. The first threshold value may be set to 1 or 2.
For example, the hardware manufacturer decoding library initializes the initial capacity of the allocated buffer to be the buffer capacity of 15 buffers based on the buffer allocation number "15", and each buffer is preset with a capacity, such as 4M; decoding the video information by a hardware manufacturer decoding library; as shown in fig. 2, when the hardware manufacturer decoding library detects that the decoding of the video information is completed, the decoding data of the video information is buffered according to the number of reference frames of the video information obtained or extracted from the decoding data of the video information and the indication parameter value of whether the video information has a B frame, and the preset related parameters, for example, the number of reference frames of the video information is "2", the indication parameter value of whether the video information has a B frame is "1", and the value of the preset related parameter is "6", and the number of required allocated buffers is obtained according to the following formula 1):
equation 1) number of buffers to be allocated
=info->numRefFrames+info->has_b_frames+1+1+4
Wherein info- > numRefFrames is the number of reference frames of the video information, has _ B _ frames is an indication parameter of whether the video information has B frames, the first "1" is the number of output pause buffers to avoid outputting, the second "1" is the number of reconstructed frames, and "4" is the number of reserved buffers of the surface flag component.
The calculation of the above equation 1) can determine that 9 buffers are required to be allocated to buffer the decoded data of the video information; then, comparing the number 15 of the buffers corresponding to the initial capacity of the buffer to be initially allocated with the number 9 of the buffers corresponding to the capacity of the buffer to be allocated, and obtaining a comparison result that the number 15 of the buffers corresponding to the initial capacity of the buffer to be initially allocated is greater than a calculation result obtained by calculating the multimedia parameter based on a predetermined operation mode, namely a calculation result "9" obtained by the above formula 1), and a difference value "6" between the two is greater than a first threshold value "1" or "2". The buffer needs to be reallocated to buffer the decoded data of the video information.
It should be noted that, when the video information has a B frame, the indicated parameter value of whether the video information has a B frame is 1; when the video information has no B frame, the value of the indicating parameter for judging whether the video information has the B frame is 0. And the number of output pause buffer areas is preset to be 1, the number of reconstruction frames is preset to be 1, and the number of reserved buffer areas of the surface flag component is preset to be 4.
Step S102: when it is determined that the buffer needs to be reallocated, the reallocated buffer is determined based on the multimedia parameters.
Specifically, the step of determining the re-allocation buffer based on the multimedia parameters comprises: determining the number of the redistribution buffer areas based on the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and a preset related parameter; based on the number of the re-allocated buffers, notifying and calling a release memory function of the open multimedia acceleration layer OpenMax, releasing the initially allocated buffers, calling an allocation memory function of the open multimedia acceleration layer OpenMax, and re-allocating the buffers.
For example, as shown in fig. 2, when the hardware manufacturer decoding library determines that the buffer needs to be reallocated, the hardware manufacturer decoding library buffers the decoded data of the video information according to the number of reference frames of the video information obtained or extracted from the decoded data of the video information, the value of the indication parameter indicating whether the video information has B frames, and the preset related parameters, for example, the number of reference frames based on the video information is "2", the value of the indication parameter indicating whether the video information has B frames is "1", and the value of the preset related parameter is "6", and obtains the number of buffers that need to be allocated based on the following formula 2):
formula 2)
The number of reallocated buffers ═ info- > numRefFrames + info- > has _ b _ frames +1+1+4
Wherein info- > numRefFrames is the number of reference frames of the video information, has _ B _ frames is an indication parameter of whether the video information has B frames, the first "1" is the number of output pause buffers to avoid outputting, the second "1" is the number of reconstructed frames, and "4" is the number of reserved buffers of the surface flag component.
The calculation of the above equation 2) can determine that 9 buffers are allocated again to buffer the decoded data of the video information; the hardware manufacturer decoding library sends notification information to a plug-in gst-OMX module in a Gstreamer based on the number of the reallocated buffers being '9', the gst-OMX module is notified that the buffer is reallocated and the number of the reallocated buffers is 9, the gst-OMX module confirms the notification information after receiving the notification information sent by the hardware manufacturer decoding library, and calls a release memory function OMX _ FreeBuffer of an open multimedia acceleration layer OpenMax, releases 15 buffers initially allocated, and then calls an allocation memory function OMX _ AllocateBuffer of the open multimedia acceleration layer OpenMax to reallocate 9 buffers.
Step S103: the decoded data is buffered in the reallocated buffer.
Specifically, after the gst-omx module reallocates the buffer, the decoded data of the multimedia information, such as the decoded data of the video information, is buffered in the reallocated buffer.
Specifically, the method further comprises: the buffer allocation parameter is updated based on the number of reallocated buffers.
For example, as shown in fig. 2, after finishing buffering the decoded data of the video information into the reallocated buffer, the gst-omx module sends notification information to the hardware vendor decoding library to notify the hardware vendor decoding library that the allocated number of the buffer has been modified, and modifies the allocated number of the buffer to 9; after receiving the notification message sent by the gst-omx module, the hardware vendor decoding library confirms that the buffer has been reallocated and updates the allocated number of the buffer.
FIG. 3 is a block diagram of an apparatus for adjusting a multimedia decoding information buffer according to another embodiment of the present invention.
The monitoring module is used for judging whether a buffer area needs to be reallocated or not to cache the decoded data based on the multimedia parameters obtained according to the decoded data when the decoding of the multimedia information is completed; the allocation module determines the re-allocation buffer area based on the multimedia parameters when judging that the buffer area needs to be re-allocated; and the buffer module is used for buffering the decoded data into the redistributed buffer area.
The following further explains the specific implementation of each module:
and the monitoring module is used for judging whether a buffer area needs to be reallocated or not to cache the decoded data based on the multimedia parameters acquired according to the decoded data when the decoding of the multimedia information is completed.
Among them, the multimedia information includes but is not limited to: video information, audio information.
The multimedia parameters comprise the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and preset related parameters; the preset related parameters comprise the number of the output-avoiding pause buffers, the number of the reconstruction frames and the number of the reserved buffers of the SurfaceFlinger component.
Specifically, the apparatus further comprises: and the initialization module initializes the initial capacity of the allocated buffer area based on the buffer area allocation parameter.
Wherein, the buffer allocation parameter is the buffer allocation number.
Specifically, the monitoring module judges whether the buffer needs to be reallocated based on the comparison result of the multimedia parameter and the initial capacity of the initial allocation buffer.
Wherein, when the comparison result satisfies any one of the following conditions, the buffer needs to be reallocated: the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is smaller than the calculation result of the multimedia parameters which is obtained through calculation based on the preset operation mode; or the comparison result is that the number of the buffer areas corresponding to the initial capacity of the buffer areas which are initially allocated is larger than the calculation result obtained by calculating the multimedia parameters based on the preset operation mode, and the difference value of the two is larger than the first threshold value. The first threshold value may be set to 1 or 2.
For example, the initialization module initializes the initial capacity of the allocated buffer to be the buffer capacity of 15 buffers based on the buffer allocation number "15", and each buffer is preset with a capacity, such as 4M; decoding the video information by a hardware manufacturer decoding library; when the monitoring module monitors that the decoding of the video information is completed, buffering the decoded data of the video information according to the number of reference frames of the video information and the indicating parameter value of whether the video information has a B frame, which are obtained or extracted from the decoded data of the video information, and preset related parameters, for example, the number of reference frames of the video information is "2", the indicating parameter value of whether the video information has a B frame is "1", and the value of the preset related parameter is "6", and the number of required allocated buffers is obtained based on the following formula 1):
formula 1)
The number of buffers required to be allocated is info- > numRefFrames + info- > has _ b _ frames +1+1+4
Wherein info- > numRefFrames is the number of reference frames of the video information, has _ B _ frames is an indication parameter of whether the video information has B frames, the first "1" is the number of output pause buffers to avoid outputting, the second "1" is the number of reconstructed frames, and "4" is the number of reserved buffers of the surface flag component.
The calculation of the above equation 1) can determine that 9 buffers are required to be allocated to buffer the decoded data of the video information; then, the monitoring module compares the number of the buffer areas corresponding to the initial capacity of the buffer area to be initially allocated, namely 15, of the buffer areas corresponding to the initial capacity of the buffer area to be initially allocated, with the number of the buffer areas corresponding to the capacity of the buffer area to be allocated, and obtains a comparison result that the number of the buffer areas corresponding to the initial capacity of the buffer area to be initially allocated is greater than a calculation result obtained by calculating the multimedia parameter based on a predetermined operation mode, namely the calculation result obtained by the formula 1) is "9", and a difference value "6" between the two is greater than a first threshold value "1" or "2". The buffer needs to be reallocated to buffer the decoded data of the video information.
It should be noted that, when the video information has a B frame, the indicated parameter value of whether the video information has a B frame is 1; when the video information has no B frame, the value of the indicating parameter for judging whether the video information has the B frame is 0. And the number of output pause buffer areas is preset to be 1, the number of reconstruction frames is preset to be 1, and the number of reserved buffer areas of the surface flag component is preset to be 4. And the allocation module determines the re-allocation buffer area based on the multimedia parameters when judging that the buffer area needs to be re-allocated.
Specifically, the buffer module includes: the determining unit is used for determining the number of the redistribution buffers based on the number of reference frames of the multimedia information, the indication parameter value of whether the multimedia information has a B frame or not and the preset related parameters; and the reallocation unit is used for notifying and calling a release memory function of the open multimedia acceleration layer OpenMax based on the number of the reallocated buffer areas, releasing the initially allocated buffer areas, calling an allocation memory function of the open multimedia acceleration layer OpenMax and reallocating the buffer areas.
For example, when the monitoring module determines that buffer reallocation is required, the determining unit buffers the decoded data of the video information according to the number of reference frames of the video information obtained or extracted from the decoded data of the video information and the value of an indication parameter of whether the video information has a B frame, and preset related parameters, for example, based on the number of reference frames of the video information being "2", the value of an indication parameter of whether the video information has a B frame being "1", and the value of a preset related parameter being "6", and derives the number of buffer reallocation required based on the following formula 2):
formula 2)
The number of reallocated buffers ═ info- > numRefFrames + info- > has _ b _ frames +1+1+4
Wherein info- > numRefFrames is the number of reference frames of the video information, has _ B _ frames is an indication parameter of whether the video information has B frames, the first "1" is the number of output pause buffers to avoid outputting, the second "1" is the number of reconstructed frames, and "4" is the number of reserved buffers of the surface flag component.
The calculation of the above equation 2) can determine that 9 buffers are allocated again to buffer the decoded data of the video information; the reallocation unit sends notification information to a plug-in gst-OMX module in the Gstreamer based on the number of the reallocation buffers being "9", the gst-OMX module is notified that the number of the reallocation buffers is 9, after receiving the notification information sent by the reallocation unit, the gst-OMX module confirms the notification information, calls a release memory function OMX _ FreeBuffer of an open multimedia acceleration layer OpenMax, releases 15 buffers initially allocated, and calls an allocation memory function OMX _ AllocateBuffer of the open multimedia acceleration layer OpenMax to reallocate 9 buffers.
And the buffer module is used for buffering the decoded data into the redistributed buffer area.
Specifically, after the gst-omx module reallocates the buffer, the buffer module buffers the decoded data of the multimedia information, such as the decoded data of the video information, into the reallocated buffer.
Specifically, the apparatus further comprises: and the updating module updates the buffer allocation parameters based on the number of the re-allocated buffers.
For example, after finishing caching the decoded data of the video information into the reallocated buffer, the gst-omx module sends notification information to the hardware manufacturer decoding library, notifies the hardware manufacturer that the allocated number of the buffer in the decoding library has been modified, and modifies the allocated number of the buffer into 9; after receiving the notification message sent by the gst-omx module, the hardware vendor decoding library confirms that the buffer has been reallocated, and updates the allocated number of the buffer through the updating module.
Those skilled in the art will appreciate that the present invention includes apparatus directed to performing one or more of the operations described in the present application. These devices may be specially designed and manufactured for the required purposes, or they may comprise known devices in general-purpose computers. These devices have stored therein computer programs that are selectively activated or reconfigured. Such a computer program may be stored in a device (e.g., computer) readable medium, including, but not limited to, any type of disk including floppy disks, hard disks, optical disks, CD-ROMs, and magnetic-optical disks, ROMs (Read-Only memories), RAMs (Random Access memories), EPROMs (Erasable programmable Read-Only memories), EEPROMs (Electrically Erasable programmable Read-Only memories), flash memories, magnetic cards, or optical cards, or any type of media suitable for storing electronic instructions, and each coupled to a bus. That is, a readable medium includes any medium that stores or transmits information in a form readable by a device (e.g., a computer).
It will be understood by those within the art that each block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by computer program instructions. Those skilled in the art will appreciate that the computer program instructions may be implemented by a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, implement the features specified in the block or blocks of the block diagrams and/or flowchart illustrations of the present disclosure.
Those of skill in the art will appreciate that various operations, methods, steps in the processes, acts, or solutions discussed in the present application may be alternated, modified, combined, or deleted. Further, various operations, methods, steps in the flows, which have been discussed in the present application, may be interchanged, modified, rearranged, decomposed, combined, or eliminated. Further, steps, measures, schemes in the various operations, methods, procedures disclosed in the prior art and the present invention can also be alternated, changed, rearranged, decomposed, combined, or deleted.
The foregoing is only a partial embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.