CN104182355A - Method and device for memory allocation - Google Patents

Method and device for memory allocation Download PDF

Info

Publication number
CN104182355A
CN104182355A CN201410438502.2A CN201410438502A CN104182355A CN 104182355 A CN104182355 A CN 104182355A CN 201410438502 A CN201410438502 A CN 201410438502A CN 104182355 A CN104182355 A CN 104182355A
Authority
CN
China
Prior art keywords
block
video data
size
memory block
default
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201410438502.2A
Other languages
Chinese (zh)
Other versions
CN104182355B (en
Inventor
李锦�
陈杰
施剑华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Cubesili Information Technology Co Ltd
Original Assignee
Guangzhou Huaduo Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Huaduo Network Technology Co Ltd filed Critical Guangzhou Huaduo Network Technology Co Ltd
Priority to CN201410438502.2A priority Critical patent/CN104182355B/en
Publication of CN104182355A publication Critical patent/CN104182355A/en
Application granted granted Critical
Publication of CN104182355B publication Critical patent/CN104182355B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses a method and a device for memory allocation. The method comprises the following steps: when the memory request of video data is detected, acquiring the sizes of video data blocks, wherein the video data comprises a plurality of video data blocks; acquiring the sizes of preset memory blocks allocated in a target memory pool in advance, wherein the target memory pool comprises a plurality of preset memory blocks; comparing the sizes of the video data blocks with the sizes of the preset memory blocks, and when the sizes of the video data blocks are the same as that of the preset memory blocks, allocating target memory blocks for the video data according to the sizes of the video data blocks. Through the embodiment, memory allocated can be carried out according to the sizes of the video data blocks in real-time video data, and the sizes of the allocated memory blocks are adaptive to the sizes of the video data blocks, so that the flexibility of memory allocation plane of the video data is promoted, and the memory usage rate is improved.

Description

A kind of memory allocation method and device
Technical field
The present invention relates to computer realm, relate in particular to a kind of memory allocation method and device.
Background technology
In the time that the video data of playing is carried out to buffer memory, video data is cached in memory pool, memory pool comprises multiple memory blocks, the size of each memory block is the same, and total size of multiple memory blocks is more than the size of video data, for each block of video data is distributed an idle memory block, wherein, video data comprises multiple block of video data, and block of video data can be one-frame video data, can be also a few frame video datas.Video data is under the broadcast interface of different resolution, the size of block of video data is not identical, for example resolution corresponding to the broadcast interface of different sizes, but the size that is the memory block of each block of video data distribution immobilizes, if the size of block of video data is more than the size of memory block, block of video data cannot full storage between internal memory, if the size of block of video data is less than the size of memory headroom, can cause the waste of memory headroom, this Memory Distribution Map lacks dirigibility, and greatly reduces memory usage.
Summary of the invention
The embodiment of the present invention provides a kind of memory allocation method and device, can improve the dirigibility of the Memory Distribution Map of video data, and can improve memory usage.
First aspect present invention provides a kind of memory allocation method, can comprise:
In the time the memory request of video data being detected, obtain the size of block of video data, described video data comprises multiple described block of video data;
Obtain the size of pre-assigned default memory block in target memory pool, described target memory pool comprises multiple described default memory blocks;
The size of more described block of video data and the size of described default memory block;
At described comparative result be: when not of uniform size the causing of the size of described block of video data and described default memory block, be that described video data distributes target memory block according to the size of described block of video data.
Second aspect present invention provides a kind of Memory Allocation device, can comprise:
Data block acquisition module, in the time the memory request of video data being detected, obtains the size of block of video data, and described video data comprises multiple described block of video data;
Memory block acquisition module, for obtaining the size of the pre-assigned default memory block of target memory pool, described target memory pool comprises multiple default memory blocks;
Comparison module, for the size of more described block of video data and the size of described default memory block;
Distribution module, for the comparative result at described comparison module is: when not of uniform size the causing of the size of described block of video data and described default memory block, be that described video data distributes target memory block according to the size of described block of video data.
Implement the embodiment of the present invention, there is following beneficial effect:
The embodiment of the present invention can be in the time detecting the memory request of video data, obtain the size of block of video data, also can obtain the size of pre-assigned default memory block in target memory pool, and then can compare the size of block of video data and the size of default memory block, at comparative result be: when not of uniform size the causing of the size of block of video data and default memory block, be that video data distributes target memory block according to the size of block of video data, the embodiment of the present invention can be carried out Memory Allocation according to the size of the block of video data in real-time video data, the memory block size of distributing and the size adaptation of block of video data, promote the dirigibility of video data Memory Distribution Map, improve memory usage.
Brief description of the drawings
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, to the accompanying drawing of required use in embodiment or description of the Prior Art be briefly described below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
The process flow diagram of a kind of memory allocation method that Fig. 1 provides for the embodiment of the present invention;
The process flow diagram of the another kind of memory allocation method that Fig. 2 provides for the embodiment of the present invention
A kind of Memory Allocation schematic diagram that Fig. 3 provides for the embodiment of the present invention;
The structural representation of a kind of Memory Allocation device that Fig. 4 provides for the embodiment of the present invention;
The structural representation of the comparison module that Fig. 5 provides for the embodiment of the present invention;
The structural representation of the distribution module that Fig. 6 provides for the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiment.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
The embodiment of the present invention provides a kind of memory allocation method and device, can be video data and distribute target memory block, wherein, video data comprises multiple block of video data, block of video data can be one-frame video data, also can be a few frame video datas, the size of the block of video data of video data changes, for example, for same video data, while broadcasting in mobile phone, mobile phones transverse screen and the corresponding different broadcast interface resolution of difference in the perpendicular situation of shielding of mobile phone, the block of video data under different broadcast interface resolution is in different size.In the embodiment of the present invention, can be according to the size of the current block of video data getting, size comparison with default memory block, in the time of the size of block of video data and not of uniform size the causing of default memory block, be that video data distributes target memory block according to the size of block of video data, thereby the size of having avoided block of video data more than the size of memory block cause block of video data cannot full storage to the situation between internal memory, the size of also having avoided the size of block of video data to be less than memory headroom causes the situation of the waste of memory headroom.
Further, the default memory block in the embodiment of the present invention is memory block idle in target memory pool, and the target memory block in the embodiment of the present invention is memory block idle in target memory pool.
Further alternative, the embodiment of the present invention was carried out before playing video data, after distributing target memory block for video data, the block of video data of video data is cached in target memory block, from target memory block, read again the video data of a frame, thereby carry out the broadcasting of video data, thus can the various video qualities of self-adaptation, the size adaptation that makes video data block size and the target memory block of video data, has promoted the dirigibility of video data Memory Distribution Map.
The embodiment of the present invention provide a kind of Memory Allocation device can for personal computer, panel computer, smart mobile phone, notebook computer etc. can playing video data terminal device, can be also in terminal device as client modules such as video player client, web browser clients.A kind of Memory Distribution Map that the embodiment of the present invention provides is for example: in webpage, when displaying video, when buffer memory video, need carry out to the video data of buffer memory scene of Memory Allocation etc.
Below in conjunction with accompanying drawing 1~accompanying drawing 3, the memory allocation method that the embodiment of the present invention is provided describes in detail.
Refer to Fig. 1, the process flow diagram of a kind of memory allocation method providing for the embodiment of the present invention; The method can comprise the following steps S101~S104.
S101, in the time the memory request of video data being detected, obtains the size of block of video data, and video data comprises multiple block of video data.
As the optional embodiment of one, in the time the memory request of video data being detected, concrete, can in the time receiving user to the play operation of video data, determine the memory request that video data detected, detecting after the memory request of video data, obtain the size of block of video data, wherein, video data comprises multiple block of video data, and block of video data can be one-frame video data, also can be a few frame video datas, specifically not be subject to the restriction of the embodiment of the present invention.
Further, the size that step S101 obtains block of video data specifically can comprise:
Obtain the size of the each block of video data receiving in Preset Time, when not of uniform size the causing of the size of the each block of video data receiving and default memory block, determine that comparative result is: the not of uniform size of the size of block of video data and default memory block causes in Preset Time; Or
Obtain the size of each block of video data in the top n block of video data receiving, wherein, N is predetermined number, in the top n block of video data receiving, when the size of each block of video data and not of uniform size the causing of default memory block, determine that comparative result is: the not of uniform size of the size of block of video data and default memory block causes.
In specific implementation, Preset Time can be the time numerical value arranging according to the integral multiple of the delivery time of every frame video data, such as 20ms, 15ms etc., Preset Time can arrange timer and control, in Preset Time, can receive M block of video data, M is greater than 1 positive integer, obtains the size of each block of video data in M block of video data.
Further, obtain the size of each block of video data in the top n block of video data receiving, wherein, N is predetermined number, concrete, also can count the quantity of block of video data, often receive a block of video data, increase progressively inner counting, in the time that the numerical value of inside counting reaches predetermined number N, obtain the size of each block of video data in this N block of video data, to first block of video data receiving, second block of video data ... N block of video data processed, obtain the size of each block of video data in top n block of video data.
S102, obtains the size of pre-assigned default memory block in target memory pool, and target memory pool comprises multiple default memory blocks.
As the optional embodiment of one, can obtain the size of pre-assigned default memory block in target memory pool, wherein, target memory pool comprises multiple default memory blocks, the size of default memory block is a predefined numerical value, target memory pool is the memory pool of enough memory headroom applying for from memory pool in the time receiving memory request, and the size of target memory pool is more than the size of video data.
Further alternative, the execution of step S101, S102 divides without priority, can first carry out one of them, then carry out another step, also can carry out simultaneously.
S103, the relatively size of block of video data and the size of default memory block.
As the optional embodiment of one, can compare the size of block of video data and the size of default memory block.In specific implementation, can calculate the size of block of video data and the big or small difference of default memory block.Further, whether the size that can relatively preset memory block is more than the first big or small ratio value of block of video data, or whether the size of relatively more default memory block is less than the second big or small ratio value of block of video data.Wherein, the first ratio value can be the ratio value that the size of predefined default memory block is more than the size of block of video data, and for example the first ratio value can be 120%, if the size of default memory block is 80KB, the size of block of video data is 30KB, 80>30*120%; The second ratio value can be the ratio value that the size of predefined default memory block is fewer than the size of block of video data, for example the second ratio value can be 110%, if the size of default memory block is 80KB, the size of block of video data is 80KB, 80<80*110%.
S104, at comparative result is: when not of uniform size the causing of the size of block of video data and default memory block, be that video data distributes target memory block according to the size of block of video data.
As the optional embodiment of one, when the size that is block of video data at the comparative result of S103 and not of uniform size the causing of default memory block, be that video data distributes target memory block according to the size of block of video data.Concrete, also can empty pre-assigned default memory block, then be video data storage allocation piece again, be specially video data and distribute target memory block.Further, can be directly also that video data distributes target memory block according to the size of block of video data, be not specifically subject to the restriction of the embodiment of the present invention.
Further, after obtaining the size of the each block of video data receiving in Preset Time, when not of uniform size the causing of the size of the each block of video data receiving and default memory block, can determine that comparative result is: the not of uniform size of the size of block of video data and default memory block causes in Preset Time.
Further, after obtaining the size of each block of video data in the top n block of video data receiving, in the top n block of video data receiving, when the size of each block of video data and not of uniform size the causing of default memory block, determine that comparative result is: the not of uniform size of the size of block of video data and default memory block causes.
Further, in the time calculating satisfied default the first difference threshold of difference obtaining in the size of block of video data and the big or small difference of default memory block, determine that comparative result is: the not of uniform size of the size of block of video data and default memory block causes.Wherein, minimum value and the maximal value of the size that default the first difference threshold is predefined block of video data and the big or small difference of default memory block, for example, default the first difference threshold can be: [15,-1] (unit is KB), the minimum value that is the size of block of video data and the big or small difference of default memory block can be-15KB that maximal value can be-1KB.
Further, presetting the size of memory block more than the first big or small ratio value of block of video data, or the size of default memory block is while being less than big or small second ratio value of block of video data, determines that comparative result is: the not of uniform size of the size of block of video data and default memory block causes.
As the optional embodiment of one, be that video data distributes target memory block specifically can comprise according to the size of block of video data:
The size of calculating block of video data and default the second difference threshold and, or calculate the size of block of video data and the product of default ratio threshold value, obtained the size of target memory block by result of calculation;
From target memory pool, apply for multiple target memory blocks according to the size of target memory block;
For block of video data is distributed target memory block.
In specific implementation, minimum value and the maximal value of the size that default the second difference threshold is predefined default memory block and the big or small difference of block of video data, for example, default the second difference threshold can be: [1, 20] (unit is KB), the minimum value that is the size of block of video data and the big or small difference of default memory block can be 1KB, maximal value can be 20KB, concrete, can from default the second difference threshold, select one as end value, for example, can select 1, if the size of block of video data is 30KB, the size of target memory block can be made as 30+1=31KB.
Wherein, default ratio threshold value can be minimum value and the maximal value of the size of predefined target memory block and the big or small ratio of block of video data, for example, default ratio threshold value can be [1.1,1.5], the minimum value that is the size of target memory block and the big or small ratio of block of video data can be 1.1, and the maximal value of ratio can be 1.5.For example, the size of block of video data is 30KB, and the size of target memory block can be made as 30*1.1=33KB.
In specific implementation, calculating after the size of target memory block, from target memory pool, applying for multiple target memory blocks according to the size of target memory block, for example, the size that calculates target memory block is 31KB, can from target memory pool, apply for the target memory block of multiple 31KB.Further, for each block of video data is distributed a target memory block, thereby the block of video data receiving can be cached in target memory block.
Further alternative, at comparative result be: when the size of block of video data and default memory block in the same size, the block of video data receiving is cached in default memory block.
Further alternative, at comparative result be: when not of uniform size the causing of the size of block of video data and default memory block, empty default memory block, can be video data and distribute target memory block, wherein, the size of target memory block is identical with the size of block of video data.
The embodiment of the present invention provides a kind of memory allocation method, can be in the time the memory request of video data being detected, obtain the size of block of video data, also can obtain the size of pre-assigned default memory block in target memory pool, and then can compare the size of block of video data and the size of default memory block, at comparative result be: when not of uniform size the causing of the size of block of video data and default memory block, empty default memory block, and be that video data distributes target memory block according to the size of block of video data, the embodiment of the present invention can be carried out Memory Allocation according to the size of the block of video data in real-time video data, the memory block size of distributing and the size adaptation of block of video data, promote the dirigibility of video data Memory Distribution Map, improve memory usage.
Refer to Fig. 2, the process flow diagram of the another kind of memory allocation method providing for the embodiment of the present invention, the method can comprise the following steps S201~S207.
S201, obtains the size of pre-assigned default memory block in target memory pool.
As the optional embodiment of one, target memory pool is the memory pool of enough memory headroom applying for from memory pool in the time receiving memory request, and wherein, target memory pool comprises multiple default memory blocks.
S202, in the time the memory request of video data being detected, obtains the size of each block of video data in the top n block of video data receiving.
Further, obtain the size of each block of video data in the top n block of video data receiving, wherein, N is predetermined number, concrete, also can count the quantity of block of video data, often receive a block of video data, increase progressively inner counting, in the time that the numerical value of inside counting reaches predetermined number N, obtain the size of each block of video data in this N block of video data, to first block of video data receiving, second block of video data ... N block of video data processed, obtain the size of each block of video data in top n block of video data.
S203, calculates the size of block of video data and the big or small difference of default memory block.
S204, whether the difference that judgement calculates meets default the first difference threshold.In judged result when being, execution step S205~S206, in judged result while being no, execution step S207.
As the optional embodiment of one, minimum value and the maximal value of the size that default the first difference threshold is predefined block of video data and the big or small difference of default memory block, for example, default the first difference threshold can be: [15,-1] (unit is KB), the minimum value that is the size of block of video data and the big or small difference of default memory block can be-15KB that maximal value can be-1KB.
S205, by size and the size default the second difference threshold and that calculate target memory block of block of video data.
As the optional embodiment of one, in the time that the difference calculating meets default the first difference threshold, calculate the size and size default the second difference threshold and that obtain target memory block of block of video data, minimum value and the maximal value of the size that default the second difference threshold is predefined default memory block and the big or small difference of block of video data, for example, default the second difference threshold can be: [1, 20] (unit is KB), the minimum value that is the size of block of video data and the big or small difference of default memory block can be 1KB, maximal value can be 20KB, concrete, can from default the second difference threshold, select one as end value, for example, can select 1, if the size of block of video data is 30KB, the size of target memory block can be made as 30+1=31KB.
S206 is that video data distributes target memory block by the size of the target memory block calculating.
As the optional embodiment of one, calculating after the size of target memory block, can from target memory pool, apply for according to the size of target memory block multiple target memory blocks, for example, the size that calculates target memory block is 31KB, can from target memory pool, apply for the target memory block of multiple 31KB.
S207, for video data distributes target memory block, the size of target memory block and the equal and opposite in direction of block of video data.
Further alternative, as shown in Figure 3, a kind of Memory Allocation schematic diagram providing for the embodiment of the present invention, video data 31 comprises first block of video data 311, second block of video data 312, the 3rd database block 313 ... target memory pool 32 comprises the first default memory block 321, the second default memory block 322, the 3rd default memory block 323 ..., in target memory pool, also comprise: first object memory block 331, the second target memory block 332, the 3rd target memory block 333 ...In the embodiment of the present invention, can calculate the size of each block of video data in top n block of video data, N=3, calculates the size of the size of first block of video data 311, second block of video data 312 and the size of the 3rd database block 313.Concrete, can calculate the size of the first default memory block 321: b1=40KB, calculate the size of the second default memory block 322: b2=40KB, calculate the size of the 3rd default memory block 323: b3=40KB ...In the time receiving first block of video data 311, calculate the size of first block of video data 311: a1=30KB, can compare the size of a1, b1, in the time that the difference of a1 and b1 meets default the first difference threshold, by the size and size default the second difference threshold and that calculate target memory block of block of video data, can calculate thus the size of first object memory block 331: c1=31KB, in the time receiving second block of video data 312, calculate the size of second block of video data 312: a2=30KB, can compare the size of a2, b2, in like manner can calculate the size of the second target memory block 332: c2=31KB, in the time receiving the 3rd block of video data 313, calculate the size of the 3rd block of video data 313: a3=30KB, can compare a3, the size of b3, in like manner can calculate the size of the 3rd target memory block 333: c3=31KB ... further, after calculating the size of target memory block, can empty default memory block, and be that video data distributes target memory block by the size of the target memory block calculating, be first block of video data 311 and distribute the first object memory block 331 of c1=31KB, it is the second target memory block 332 that second block of video data 312 distributed c2=31KB, it is the 3rd target memory block 333 that the 3rd video database piece 313 distributes c3=31KB.
The embodiment of the present invention provides a kind of memory allocation method, can obtain the size of pre-assigned default memory block in target memory pool, can be in the time the memory request of video data being detected, obtain the size of each block of video data in the top n block of video data receiving, and then can calculate the size of block of video data and the big or small difference of default memory block, in the time that the difference calculating meets default the first difference threshold, by the size and size default the second difference threshold and that calculate target memory block of block of video data, can be that video data distributes target memory block by the size of the target memory block calculating, the embodiment of the present invention can be carried out Memory Allocation according to the size of the block of video data in real-time video data, the memory block size of distributing and the size adaptation of block of video data, promote the dirigibility of video data Memory Distribution Map, improve memory usage.
Below in conjunction with accompanying drawing 4~Fig. 6, the Memory Allocation device that the embodiment of the present invention is provided describes in detail.It should be noted that, Memory Allocation device shown in accompanying drawing 4~Fig. 6, for carrying out Fig. 1 of the present invention or method embodiment illustrated in fig. 2, for convenience of explanation, only show the part relevant to the embodiment of the present invention, concrete ins and outs do not disclose, and please refer to the embodiment shown in Fig. 1 of the present invention or Fig. 2.
Refer to Fig. 4, the structural representation of a kind of Memory Allocation device providing for the embodiment of the present invention; This device can comprise: data block acquisition module 401, memory block acquisition module 402, comparison module 403 and distribution module 404.
Data block acquisition module 401, in the time the memory request of video data being detected, obtains the size of block of video data, and video data comprises multiple block of video data.
As the optional embodiment of one, in the time the memory request of video data being detected, concrete, can in the time receiving user to the play operation of video data, determine the memory request that video data detected, detecting after the memory request of video data, data block acquisition module 401 can obtain the size of block of video data, wherein, video data comprises multiple block of video data, block of video data can be one-frame video data, also can be a few frame video datas, specifically not be subject to the restriction of the embodiment of the present invention.
Further alternative, data block acquisition module 401 can comprise: the first acquiring unit or second acquisition unit.
The first acquiring unit, for obtaining the size of the each block of video data receiving in Preset Time, when not of uniform size the causing of the size of the each block of video data receiving and default memory block, determine that the size of block of video data and the not of uniform size of default memory block cause in Preset Time.
Second acquisition unit, for obtaining the size of the each block of video data of top n block of video data receiving, wherein, N is predetermined number, in the top n block of video data receiving, when the size of each block of video data and not of uniform size the causing of default memory block, determine that the size of block of video data and the not of uniform size of default memory block cause.
In specific implementation, Preset Time can be the time numerical value arranging according to the integral multiple of the delivery time of every frame video data, such as 20ms, 15ms etc., Preset Time can arrange timer and control, in Preset Time, can receive M block of video data, M is greater than 1 positive integer, and then the first acquiring unit can obtain the size of each block of video data in M block of video data.
Further, second acquisition unit can obtain the size of each block of video data in the top n block of video data receiving, wherein, N is predetermined number, concrete, also can count the quantity of block of video data, often receive a block of video data, increase progressively inner counting, in the time that the numerical value of inside counting reaches predetermined number N, obtain the size of each block of video data in this N block of video data, to first block of video data receiving, second block of video data ... N block of video data processed, obtain the size of each block of video data in top n block of video data.
Memory block acquisition module 402, for obtaining the size of the pre-assigned default memory block of target memory pool, target memory pool comprises multiple default memory blocks.
As the optional embodiment of one, memory block acquisition module 402 can obtain the size of pre-assigned default memory block in target memory pool, wherein, target memory pool comprises multiple default memory blocks, the size of default memory block is a predefined numerical value, target memory pool is the memory pool of enough memory headroom applying for from memory pool in the time receiving memory request, and the size of target memory pool is more than the size of video data.
Comparison module 403, for comparing the size of block of video data and the size of default memory block.
As the optional embodiment of one, comparison module 403 can compare the size of block of video data and the size of default memory block.In specific implementation, can calculate the size of block of video data and the big or small difference of default memory block.Further, whether the size that can relatively preset memory block is more than the first big or small ratio value of block of video data, or whether the size of relatively more default memory block is less than the second big or small ratio value of block of video data.
Further alternative, as shown in Figure 5, the structural representation of the comparison module providing for the embodiment of the present invention, as shown in the figure, comparison module 403 can comprise: the first computing unit 51.
The first computing unit 51, for calculating the size of block of video data and the big or small difference of default memory block, in the time that difference meets default the first difference threshold, determine that the comparative result of comparison module is: the not of uniform size of the size of block of video data and default memory block causes.
Further alternative, comparison module 403 can also comprise: ratio value comparing unit 52.
Ratio value comparing unit 52, for the size of relatively default memory block, whether more than the first big or small ratio value of block of video data, or whether the size of relatively more default memory block is less than the second big or small ratio value of block of video data; Presetting the size of memory block more than the first big or small ratio value of block of video data, or the size of default memory block is while being less than big or small second ratio value of block of video data, determines that the comparative result of comparison module is: the not of uniform size of the size of block of video data and default memory block causes.
In specific implementation, the first ratio value can be the ratio value that the size of predefined default memory block is more than the size of block of video data, for example the first ratio value can be 120%, if the size of default memory block is 80KB, the size of block of video data is 30KB, 80>30*120%; The second ratio value can be the ratio value that the size of predefined default memory block is fewer than the size of block of video data, for example the second ratio value can be 110%, if the size of default memory block is 80KB, the size of block of video data is 80KB, 80<80*110%.
Distribution module 404, at the comparative result of comparison module 403 is: when not of uniform size the causing of the size of block of video data and default memory block, be that video data distributes target memory block according to the size of block of video data.
As the optional embodiment of one, when the size that is block of video data at the comparative result of comparison module 403 and not of uniform size the causing of default memory block, distribution module 404 can empty default memory block, and is that video data distributes target memory block according to the size of block of video data.Concrete, distribution module 404 can empty pre-assigned default memory block, then is video data storage allocation piece again, is specially video data and distributes target memory block.Further, can be directly also that video data distributes target memory block according to the size of block of video data, be not specifically subject to the restriction of the embodiment of the present invention.
Further, data block acquisition module 401 is after obtaining the size of the each block of video data receiving in Preset Time, when not of uniform size the causing of the size of the each block of video data receiving in Preset Time and default memory block, comparison module 403 can determine that comparative result is: the not of uniform size of the size of block of video data and default memory block causes.
Further, after obtaining the size of each block of video data in the top n block of video data receiving, in the top n block of video data receiving, when the size of each block of video data and not of uniform size the causing of default memory block, determine that the comparative result of comparison module 403 is: the not of uniform size of the size of block of video data and default memory block causes.
Further, in the time calculating satisfied default the first difference threshold of difference obtaining in the size of block of video data and the big or small difference of default memory block, can determine that the comparative result of comparison module 403 is: the not of uniform size of the size of block of video data and default memory block causes.Wherein, minimum value and the maximal value of the size that default the first difference threshold is predefined block of video data and the big or small difference of default memory block, for example, default the first difference threshold can be: [15,-1] (unit is KB), the minimum value that is the size of block of video data and the big or small difference of default memory block can be-15KB that maximal value can be-1KB.
Further, presetting the size of memory block more than the first big or small ratio value of block of video data, or the size of default memory block is while being less than big or small second ratio value of block of video data, class determines that the comparative result of comparison module 403 is: the not of uniform size of the size of block of video data and default memory block causes.
Further alternative, as shown in Figure 6, the structural representation of the distribution module providing for the embodiment of the present invention, as shown in the figure, distribution module 404 can comprise: the second computing unit 61 and allocation units 62.
The second computing unit 61, for the size of calculating block of video data and default the second difference threshold and, or calculate the size of block of video data and the product of default ratio threshold value, obtained the size of target memory block by result of calculation.
Allocation units 62 for applying for multiple target memory blocks according to the size of target memory block from target memory pool, and are block of video data distribution target memory block.
In specific implementation, minimum value and the maximal value of the size that default the second difference threshold is predefined default memory block and the big or small difference of block of video data, for example, default the second difference threshold can be: [1, 20] (unit is KB), the minimum value that is the size of block of video data and the big or small difference of default memory block can be 1KB, maximal value can be 20KB, concrete, can from default the second difference threshold, select one as end value, for example, can select 1, if the size of block of video data is 30KB, the size of target memory block can be made as 30+1=31KB.
Wherein, default ratio threshold value can be minimum value and the maximal value of the size of predefined target memory block and the big or small ratio of block of video data, for example, default ratio threshold value can be [1.1,1.5], the minimum value that is the size of target memory block and the big or small ratio of block of video data can be 1.1, and the maximal value of ratio can be 1.5.For example, the size of block of video data is 30KB, and the size of target memory block can be made as 30*1.1=33KB.
In specific implementation, calculate after the size of target memory block at the second computing unit 61, allocation units 62 can be applied for according to the size of target memory block multiple target memory blocks from target memory pool, for example, the size that calculates target memory block is 31KB, can from target memory pool, apply for the target memory block of multiple 31KB.Further, for each block of video data is distributed a target memory block, thereby the block of video data receiving can be cached in target memory block.
Further alternative, at the comparative result of comparison module 403 be: when the size of block of video data and default memory block in the same size, distribution module 404 also can be cached to the block of video data receiving in default memory block.
Further alternative, comparative result at comparison module 403 is: when not of uniform size the causing of the size of block of video data and default memory block, empty default memory block, distribution module 404 can be video data and distributes target memory block, wherein, the size of target memory block is identical with the size of block of video data.
The embodiment of the present invention provides a kind of Memory Allocation device, data block acquisition module can be in the time detecting the memory request of video data, obtain the size of block of video data, memory block acquisition module can obtain the size of pre-assigned default memory block in target memory pool, and then comparison module can compare the size of block of video data and the size of default memory block, comparative result at comparison module is: when not of uniform size the causing of the size of block of video data and default memory block, distribution module can be that video data distributes target memory block according to the size of block of video data, the embodiment of the present invention can be carried out Memory Allocation according to the size of the block of video data in real-time video data, the memory block size of distributing and the size adaptation of block of video data, promote the dirigibility of video data Memory Distribution Map, improve memory usage.
The embodiment of the invention also discloses a kind of terminal, comprise the device of Fig. 4~Fig. 6 shown in arbitrary; The 26S Proteasome Structure and Function of this device can, referring to the associated description of the arbitrary illustrated embodiment of Fig. 4~Fig. 6, be not repeated herein.It should be noted that, the server that the present embodiment provides is corresponding with the memory allocation method shown in Fig. 1, Fig. 2, is the executive agent of the memory allocation method based on shown in Fig. 1 or Fig. 2.
One of ordinary skill in the art will appreciate that all or part of flow process realizing in above-described embodiment method, can carry out the hardware that instruction is relevant by computer program to complete, described program can be stored in a computer read/write memory medium, this program, in the time carrying out, can comprise as the flow process of the embodiment of above-mentioned each side method.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
Above disclosed is only preferred embodiment of the present invention, certainly can not limit with this interest field of the present invention, and the equivalent variations of therefore doing according to the claims in the present invention, still belongs to the scope that the present invention is contained.

Claims (10)

1. a memory allocation method, is characterized in that, described method comprises:
In the time the memory request of video data being detected, obtain the size of block of video data, described video data comprises multiple described block of video data;
Obtain the size of pre-assigned default memory block in target memory pool, described target memory pool comprises multiple described default memory blocks;
The size of more described block of video data and the size of described default memory block;
At described comparative result be: when not of uniform size the causing of the size of described block of video data and described default memory block, be that described video data distributes target memory block according to the size of described block of video data.
2. the method for claim 1, is characterized in that, described in obtain block of video data size comprise:
Obtain the size of the each block of video data receiving in Preset Time, when not of uniform size the causing of the size of the each block of video data receiving and described default memory block, determine that described comparative result is: the not of uniform size of the size of described block of video data and described default memory block causes in described Preset Time; Or
Obtain the size of each block of video data in the top n block of video data receiving, wherein, N is predetermined number, in the described top n block of video data receiving, when the size of each block of video data and not of uniform size the causing of described default memory block, determine that described comparative result is: the not of uniform size of the size of described block of video data and described default memory block causes.
3. the method for claim 1, is characterized in that, the size of described block of video data and the size of described default memory block, comprising:
Calculate the size of described block of video data and the big or small difference of described default memory block, in the time that described difference meets default the first difference threshold, determine that described comparative result is: the not of uniform size of the size of described block of video data and described default memory block causes.
4. the method for claim 1, is characterized in that, the size of described block of video data and the size of described default memory block, comprising:
Whether the size of more described default memory block is more than the first big or small ratio value of described block of video data, or whether the size of more described default memory block is less than the second big or small ratio value of described block of video data; The first big or small ratio value in the size of described default memory block more than described block of video data, or the size of described default memory block is while being less than big or small second ratio value of described block of video data, determines that described comparative result is: the not of uniform size of the size of described block of video data and described default memory block causes.
5. the method as described in as arbitrary in claim 1~4, is characterized in that, described is that described video data distributes target memory block according to the size of described block of video data, comprising:
The size of calculating described block of video data and default the second difference threshold and, or calculate the product of size and the default ratio threshold value of described block of video data, obtained the size of described target memory block by described result of calculation;
From described target memory pool, apply for multiple described target memory blocks according to the size of described target memory block, and distribute described target memory block for described block of video data.
6. a Memory Allocation device, is characterized in that, described device comprises:
Data block acquisition module, in the time the memory request of video data being detected, obtains the size of block of video data, and described video data comprises multiple described block of video data;
Memory block acquisition module, for obtaining the size of the pre-assigned default memory block of target memory pool, described target memory pool comprises multiple described default memory blocks;
Comparison module, for the size of more described block of video data and the size of described default memory block;
Distribution module, at the comparative result of described comparison module is: when not of uniform size the causing of the size of described block of video data and described default memory block, be that described video data distributes target memory block according to the size of described block of video data.
7. device as claimed in claim 6, is characterized in that, described data block acquisition module comprises: the first acquiring unit or second acquisition unit;
Described the first acquiring unit, for obtaining the size of the each block of video data receiving in Preset Time, when not of uniform size the causing of the size of the each block of video data receiving and described default memory block, determine that the size of described block of video data and the not of uniform size of described default memory block cause in described Preset Time;
Described second acquisition unit, for obtaining the size of the each block of video data of top n block of video data receiving, wherein, N is predetermined number, in the described top n block of video data receiving, when the size of each block of video data and not of uniform size the causing of described default memory block, determine that the size of described block of video data and the not of uniform size of described default memory block cause.
8. device as claimed in claim 6, is characterized in that, described comparison module comprises:
The first computing unit, for calculating the size of described block of video data and the big or small difference of described default memory block, in the time that described difference meets default the first difference threshold, determine that the comparative result of described comparison module is: the not of uniform size of the size of block of video data and described default memory block causes.
9. device as claimed in claim 6, is characterized in that, described comparison module also comprises:
Ratio value comparing unit, for the size of more described default memory block, whether more than the first big or small ratio value of described block of video data, or whether the size of more described default memory block is less than the second big or small ratio value of described block of video data; The first big or small ratio value in the size of described default memory block more than described block of video data, or the size of described default memory block is while being less than big or small second ratio value of described block of video data, determines that the comparative result of described comparison module is: the not of uniform size of the size of described block of video data and described default memory block causes.
10. the device as described in as arbitrary in claim 6~9, is characterized in that, described distribution module comprises:
The second computing unit, for the size of calculating described block of video data and default the second difference threshold and, or calculate the product of size and the default ratio threshold value of described block of video data, obtained the size of described target memory block by described result of calculation;
Allocation units, for applying for multiple described target memory blocks according to the size of described target memory block from described target memory pool, and distribute described target memory block for described block of video data.
CN201410438502.2A 2014-08-29 2014-08-29 A kind of memory allocation method and device Active CN104182355B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410438502.2A CN104182355B (en) 2014-08-29 2014-08-29 A kind of memory allocation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410438502.2A CN104182355B (en) 2014-08-29 2014-08-29 A kind of memory allocation method and device

Publications (2)

Publication Number Publication Date
CN104182355A true CN104182355A (en) 2014-12-03
CN104182355B CN104182355B (en) 2017-06-23

Family

ID=51963418

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410438502.2A Active CN104182355B (en) 2014-08-29 2014-08-29 A kind of memory allocation method and device

Country Status (1)

Country Link
CN (1) CN104182355B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105657540A (en) * 2016-01-05 2016-06-08 珠海全志科技股份有限公司 Video decoding method adapted to Android system and device thereof
WO2017113593A1 (en) * 2015-12-30 2017-07-06 深圳Tcl数字技术有限公司 Method and apparatus for processing animation menu based on smart television
CN107273061A (en) * 2017-07-12 2017-10-20 郑州云海信息技术有限公司 A kind of solid state hard disc creates many namespace method and system
CN110475122A (en) * 2018-05-10 2019-11-19 腾讯科技(深圳)有限公司 Method and device for live video stream broadcasting
CN111131185A (en) * 2019-12-06 2020-05-08 中国电子科技网络信息安全有限公司 CAN bus network anomaly detection method and device based on machine learning
CN111464860A (en) * 2019-01-18 2020-07-28 中国科学院声学研究所 Cache allocation method for video data
CN112752152A (en) * 2020-12-28 2021-05-04 海信视像科技股份有限公司 Delivery video playing method and display equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8122450B2 (en) * 2006-03-30 2012-02-21 International Business Machines Corporation Method and apparatus for distributing memory in a data processing system
CN102868908A (en) * 2011-07-04 2013-01-09 哈尔滨融智达网络科技有限公司 High-efficiency streaming media playing method and device
CN103150257A (en) * 2013-02-28 2013-06-12 天脉聚源(北京)传媒科技有限公司 Memory management method and memory management device
CN103186469A (en) * 2011-12-27 2013-07-03 上海博泰悦臻电子设备制造有限公司 Memory allocation method and device, and memory recovery method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8122450B2 (en) * 2006-03-30 2012-02-21 International Business Machines Corporation Method and apparatus for distributing memory in a data processing system
CN102868908A (en) * 2011-07-04 2013-01-09 哈尔滨融智达网络科技有限公司 High-efficiency streaming media playing method and device
CN103186469A (en) * 2011-12-27 2013-07-03 上海博泰悦臻电子设备制造有限公司 Memory allocation method and device, and memory recovery method
CN103150257A (en) * 2013-02-28 2013-06-12 天脉聚源(北京)传媒科技有限公司 Memory management method and memory management device

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017113593A1 (en) * 2015-12-30 2017-07-06 深圳Tcl数字技术有限公司 Method and apparatus for processing animation menu based on smart television
CN105657540A (en) * 2016-01-05 2016-06-08 珠海全志科技股份有限公司 Video decoding method adapted to Android system and device thereof
CN105657540B (en) * 2016-01-05 2019-02-22 珠海全志科技股份有限公司 A kind of video encoding/decoding method and its device being adapted to Android system
CN107273061A (en) * 2017-07-12 2017-10-20 郑州云海信息技术有限公司 A kind of solid state hard disc creates many namespace method and system
CN110475122A (en) * 2018-05-10 2019-11-19 腾讯科技(深圳)有限公司 Method and device for live video stream broadcasting
CN110475122B (en) * 2018-05-10 2021-10-08 腾讯科技(深圳)有限公司 Method and device for playing live video stream
CN111464860A (en) * 2019-01-18 2020-07-28 中国科学院声学研究所 Cache allocation method for video data
CN111464860B (en) * 2019-01-18 2021-06-08 中国科学院声学研究所 Cache allocation method for video data
CN111131185A (en) * 2019-12-06 2020-05-08 中国电子科技网络信息安全有限公司 CAN bus network anomaly detection method and device based on machine learning
CN111131185B (en) * 2019-12-06 2022-12-09 中国电子科技网络信息安全有限公司 CAN bus network anomaly detection method and device based on machine learning
CN112752152A (en) * 2020-12-28 2021-05-04 海信视像科技股份有限公司 Delivery video playing method and display equipment

Also Published As

Publication number Publication date
CN104182355B (en) 2017-06-23

Similar Documents

Publication Publication Date Title
CN104182355A (en) Method and device for memory allocation
CN104965659B (en) A kind of preloading method and device of page info
CN103778071A (en) Cache space distribution method and device
CN107801095B (en) audio and video decoding method and terminal equipment
CN105471950A (en) Distributed computing method and system
CN106790525A (en) File downloading method and device
CN103294718A (en) Method and device for web page cache management
CN103984781A (en) Webpage loading method and device
CN109766282B (en) Stuck detection method, stuck detection device and terminal equipment
CN108874688A (en) A kind of message data caching method and device
CN110442308A (en) A kind of data block storage method, device, equipment and storage medium
CN105404642A (en) Audio playing method and user terminal
WO2019076213A1 (en) Network control method and device
CN111028179A (en) Stripe correction method and device, electronic equipment and storage medium
CN107846514B (en) Alarm clock setting method and device
CN105005585A (en) Log data processing method and device
CN104202305A (en) Transcoding processing method and device, server
CN111858827A (en) Map point position rarefying display method and device and computer equipment
CN104881295A (en) Window display processing method and device
CN110543432B (en) Memory defragmentation method, device, terminal and storage medium
CN110489356B (en) Information processing method, information processing device, electronic equipment and storage medium
CN108986034B (en) Raster data coordinate conversion method, system, terminal equipment and storage medium
CN110096352A (en) Process management method, device and computer readable storage medium
CN113703678B (en) Method, device, equipment and medium for re-splitting storage bucket index
CN104679666A (en) Embedded system memory management method and management system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20210115

Address after: 511442 3108, 79 Wanbo 2nd Road, Nancun Town, Panyu District, Guangzhou City, Guangdong Province

Patentee after: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Address before: 510655 building 3-08, Yangcheng Creative Industry Park, 309 Huangpu Avenue central, Guangzhou, Guangdong

Patentee before: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20141203

Assignee: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

Assignor: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Contract record no.: X2021440000053

Denomination of invention: A memory allocation method and device

Granted publication date: 20170623

License type: Common License

Record date: 20210208

EE01 Entry into force of recordation of patent licensing contract