CN104182355B - A kind of memory allocation method and device - Google Patents

A kind of memory allocation method and device Download PDF

Info

Publication number
CN104182355B
CN104182355B CN201410438502.2A CN201410438502A CN104182355B CN 104182355 B CN104182355 B CN 104182355B CN 201410438502 A CN201410438502 A CN 201410438502A CN 104182355 B CN104182355 B CN 104182355B
Authority
CN
China
Prior art keywords
block
size
video data
default
memory
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.)
Active
Application number
CN201410438502.2A
Other languages
Chinese (zh)
Other versions
CN104182355A (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 kind of memory allocation method and device, methods described includes:When the memory request of video data is detected, the size of block of video data is obtained, video data includes multiple block of video data;The size of pre-assigned default memory block in target memory pond is obtained, target memory pond includes multiple default memory blocks;Compare the size of block of video data and the size of default memory block, in the cause not of uniform size of size and the default memory block of block of video data, size according to block of video data distributes target memory block for video data.By the embodiment of the present invention, Memory Allocation can be carried out according to the size of the block of video data in real-time video data, the internal memory block size of distribution is adapted to the size of block of video data, improves the flexibility of video data Memory Distribution Map, improves memory usage.

Description

A kind of memory allocation method and device
Technical field
The present invention relates to computer realm, more particularly to a kind of memory allocation method and device.
Background technology
When the video data to playing is cached, video data is cached in memory pool, memory pool includes multiple Memory block, the size of each memory block is the same, and the size of the total size more than video data of multiple memory blocks, is each video Data block distributes the memory block of free time, wherein, video data includes multiple block of video data, and block of video data can be one Frame video data, or a few frame video datas.Video data under the broadcast interface of different resolution, block of video data Size is differed, such as the different resolution ratio of different size of broadcast interface correspondence, but for each block of video data is distributed The size of memory block immobilize, if the size of block of video data is more than the size of memory block, block of video data cannot be complete Whole deposit is stored up between internal memory, if the size of block of video data can cause the waste of memory headroom less than the size of memory headroom, The Memory Distribution Map lacks flexibility, and greatly reduces memory usage.
The content of the invention
The embodiment of the present invention provides a kind of memory allocation method and device, can improve the Memory Distribution Map of video data Flexibility, and memory usage can be improved.
First aspect present invention provides a kind of memory allocation method, it may include:
When the memory request of video data is detected, the size of block of video data is obtained, the video data includes many The individual block of video data;
The size of pre-assigned default memory block in target memory pond is obtained, the target memory pond includes multiple described Default memory block;
Compare the size of the block of video data and the size of the default memory block;
It is in the comparative result:During the cause not of uniform size of the size of the block of video data and the default memory block, Size according to the block of video data is video data distribution target memory block.
Second aspect present invention provides a kind of Memory Allocation device, it may include:
Data block acquisition module, for when the memory request of video data is detected, obtaining the size of block of video data, The video data includes multiple block of video data;
Memory block acquisition module, the size for obtaining pre-assigned default memory block in target memory pond, the mesh Mark memory pool includes multiple default memory blocks;
Comparison module, for comparing the size of the block of video data and the size of the default memory block;
Distribute module, for being in the comparative result of the comparison module:The size of the block of video data is pre- with described If during the cause not of uniform size of memory block, the size according to the block of video data is video data distribution target memory block.
Implement the embodiment of the present invention, have the advantages that:
The embodiment of the present invention when the memory request of video data is detected, can obtain the size of block of video data, may be used also The size of pre-assigned default memory block in target memory pond is obtained, and then the size of comparable block of video data is interior with default The size of counterfoil, be in comparative result:During the cause not of uniform size of the size of block of video data and default memory block, according to video counts According to the size of block for video data distributes target memory block, the embodiment of the present invention can be according to the video counts in real-time video data Memory Allocation is carried out according to the size of block, the internal memory block size of distribution is adapted to the size of block of video data, improves video data The flexibility of Memory Distribution Map, improves memory usage.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing The accompanying drawing to be used needed for having technology description is briefly described, it should be apparent that, drawings in the following description are only this Some embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, can be with Other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is a kind of flow chart of memory allocation method provided in an embodiment of the present invention;
Fig. 2 is the flow chart of another memory allocation method provided in an embodiment of the present invention
Fig. 3 is a kind of Memory Allocation schematic diagram provided in an embodiment of the present invention;
Fig. 4 is a kind of structural representation of Memory Allocation device provided in an embodiment of the present invention;
Fig. 5 is the structural representation of comparison module provided in an embodiment of the present invention;
Fig. 6 is the structural representation of distribute module provided in an embodiment of the present invention.
Specific 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 carried out clear, complete Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of protection of the invention.
The embodiment of the present invention provides a kind of memory allocation method and device, can distribute target memory block for video data, its In, video data includes multiple block of video data, and block of video data can be one-frame video data, or a few frame video counts According to the size of the block of video data of video data is change, for example, for same video data, when being played in mobile phone, hand Machine transverse screen from different broadcast interface resolution ratio are corresponded in the case of mobile phone portrait layout respectively, then under different broadcast interface resolution ratio Block of video data it is in different size.In the embodiment of the present invention, can according to the size of the block of video data for currently getting, with The size of default memory block compares, in the cause not of uniform size of size and the default memory block of block of video data, according to video counts According to the size of block for video data distributes target memory block, so as to avoid the size of the size more than memory block of block of video data Cause block of video data cannot situation of the full storage between internal memory, it also avoid the size of block of video data empty less than internal memory Between size cause memory headroom waste situation.
Further, the default memory block in the embodiment of the present invention is the memory block of free time in target memory pond, the present invention Target memory block in embodiment is memory block idle in target memory pond.
Further alternative, the embodiment of the present invention was carried out before playing video data, and target is being distributed for video data After memory block, the block of video data of video data is cached in target memory block, then a frame is read from target memory block Video data, so as to carry out the broadcasting of video data, so that can the various video qualities of self adaptation so that the video counts of video data It is adapted to the size of target memory block according to block size, improves the flexibility of video data Memory Distribution Map.
It can be personal computer, panel computer, smart mobile phone, pen that the embodiment of the present invention provides a kind of Memory Allocation device Remember the terminal device of the playable video data such as this computer, or in terminal device as:Video player client, net The client modules such as page browsing device client.A kind of Memory Distribution Map provided in an embodiment of the present invention is for example:Broadcast in webpage When putting video, scene of Memory Allocation etc. need to be carried out to the video data for caching during buffered video.
Below in conjunction with 1~accompanying drawing of accompanying drawing 3, memory allocation method provided in an embodiment of the present invention is described in detail.
Fig. 1 is referred to, is a kind of flow chart of memory allocation method provided in an embodiment of the present invention;The method may include with Lower step S101~S104.
S101, when the memory request of video data is detected, obtains the size of block of video data, and video data includes many Individual block of video data.
As a kind of optional implementation method, when the memory request of video data is detected, specifically, can receive To user to the play operation of video data when determine to detect the memory request of video data, detecting in video data After depositing request, the size of block of video data is obtained, wherein, video data includes multiple block of video data, and block of video data can be with It is one-frame video data, or a few frame video datas, is not limited by the embodiment of the present invention specifically.
Further, the size of step S101 acquisitions block of video data can specifically include:
The size of each block of video data received in Preset Time is obtained, each received in Preset Time is regarded During the cause not of uniform size of the size of frequency data block and default memory block, determine that comparative result is:The size of block of video data with it is pre- If the cause not of uniform size of memory block;Or
The size of each block of video data in the top n block of video data that acquisition is received, wherein, N is predetermined number, In the top n block of video data for receiving during the cause not of uniform size of the size of each block of video data and default memory block, it is determined that Comparative result is:The cause not of uniform size of the size of block of video data and default memory block.
In implementing, what Preset Time can be configured according to per the integral multiple of the delivery time of frame video data Time numerical value, such as 20ms, 15ms etc., the settable timer of Preset Time are controlled, then M can be received in Preset Time Block of video data, M is the positive integer more than 1, obtains the size of each block of video data in M block of video data.
Further, the size of each block of video data in the top n block of video data for receiving is obtained, wherein, N is pre- If quantity, specifically, can also be counted to the quantity of block of video data, a block of video data is often received, be incremented by internal meter Number, when the numerical value for internally counting reaches predetermined number N, obtains the size of each block of video data in N number of block of video data, First block of video data receiving, second block of video data ... n-th block of video data are processed, is obtained 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 pond, and target memory pond includes multiple pre- If memory block.
As a kind of optional implementation method, the size of pre-assigned default memory block in target memory pond can be obtained, Wherein, target memory pond includes multiple default memory blocks, and the size for presetting memory block is a numerical value set in advance, target memory Pond be when memory request is received from memory pool apply a memory pool for enough memory headrooms, target memory pond it is big The small size more than video data.
It is further alternative, the execution of step S101, S102 without priority point, one of them can be first carried out, then perform Another step, can also perform simultaneously.
S103, compares the size of block of video data and the size of default memory block.
As a kind of optional implementation method, the size of block of video data and the size of default memory block are may compare.Specifically In realization, the size of block of video data and the difference of the size of default memory block can be calculated.Further, may compare default internal memory The size of block whether more than block of video data size the first ratio value, or relatively default memory block size whether less than regarding Second ratio value of the size of frequency data block.Wherein, the first ratio value can be the size ratio of default memory block set in advance Ratio value more than the size of block of video data, such as 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, then 80>30*120%;Second ratio value can be default internal memory set in advance The size of the block ratio value fewer than the size of block of video data, such as the second ratio value can be 110%, if default memory block Size is 80KB, and the size of block of video data is 80KB, then 80<80*110%.
S104, be in comparative result:During the cause not of uniform size of the size of block of video data and default memory block, according to video The size of data block is that video data distributes target memory block.
It is the size and default memory block of block of video data in the comparative result of S103 as a kind of optional implementation method Cause not of uniform size when, size according to block of video data distributes target memory block for video data.Specifically, can also empty pre- The default memory block for first distributing, then be again video data storage allocation block, specially video data distributes target memory block.Enter One step, size that also can directly according to block of video data is video data distribution target memory block, specifically unreal by the present invention Apply the limitation of example.
Further, after the size for obtaining each block of video data received in Preset Time, in Preset Time During the cause not of uniform size of the size of each block of video data for inside receiving and default memory block, it may be determined that comparative result is:Depending on The cause not of uniform size of the size of frequency data block and default memory block.
Further, after the size of each block of video data in obtaining the top n block of video data for receiving, connecing In the top n block of video data for receiving during the cause not of uniform size of the size of each block of video data and default memory block, it is determined that than Relatively result is:The cause not of uniform size of the size of block of video data and default memory block.
Further, the size and difference resulting in the difference of the size of default memory block of block of video data are being calculated When meeting default first difference threshold, determine that comparative result is:The size of block of video data is not of uniform size with default memory block Cause.Wherein, difference of the size with the size of default memory block that the first difference threshold is block of video data set in advance is preset Minimum value and maximum, for example, default first difference threshold can be:[- 15, -1] (unit is KB), i.e. block of video data Size and the difference of the size of default memory block minimum value can be -15KB, maximum can be -1KB.
Further, it is in first ratio value of the size more than the size of block of video data of default memory block or default interior When the size of counterfoil is less than the second ratio value of the size of block of video data, determine that comparative result is:The size of block of video data With the cause not of uniform size of default memory block.
Used as a kind of optional implementation method, the size according to block of video data is video data distribution target memory block tool Body can include:
Calculate the size of block of video data and default second difference threshold and, or calculating block of video data size with it is pre- If the product of fractional threshold, the size of target memory block is obtained by result of calculation;
Size according to target memory block applies for multiple target memory blocks from target memory pond;
For block of video data distributes target memory block.
In implementing, default second difference threshold is the size and block of video data of default memory block set in advance The minimum value and maximum of the difference of size, for example, default second difference threshold can be:[1,20] (unit is KB), that is, regard The size of frequency data block can be 1KB with the minimum value of the difference of the size of default memory block, and maximum can be 20KB, specifically , one can be selected as end value from default second difference threshold, for example, 1 can be selected, if then the size of block of video data is 30KB, then the size of target memory block can be set to 30+1=31KB.
Wherein, default fractional threshold can be the size and the size of block of video data of target memory block set in advance The minimum value and maximum of ratio, for example, default fractional threshold can for [1.1,1.5], the i.e. size of target memory block with regard The minimum value of the ratio of the size of frequency data block can be 1.1, and the maximum of ratio can be 1.5.For example, block of video data Size is 30KB, then the size of target memory block can be set to 30*1.1=33KB.
In implementing, after the size of target memory block is calculated, the size according to target memory block is from target The multiple target memory blocks of application in pond are deposited, for example, the size for being calculated target memory block is 31KB, then can be from target memory pond The target memory block of middle application multiple 31KB.Further, it is that each block of video data distributes a target memory block, so that can The block of video data that will be received is cached in target memory block.
It is further alternative, be in comparative result:The size of block of video data and default memory block it is in the same size when, will The block of video data for receiving is cached in default memory block.
It is further alternative, be in comparative result:During the cause not of uniform size of the size of block of video data and default memory block, Default memory block is emptied, target memory block can be distributed for video data, wherein, size and the block of video data of target memory block Size is identical.
The embodiment of the present invention provides a kind of memory allocation method, can be obtained when the memory request of video data is detected The size of block of video data, can also obtain the size of pre-assigned default memory block in target memory pond, and then comparable regard The size of the size of frequency data block and default memory block, be in comparative result:The size of block of video data and default memory block During cause not of uniform size, default memory block is emptied, and be that video data distributes target memory block according to the size of block of video data, this Inventive embodiments can carry out Memory Allocation according to the size of the block of video data in real-time video data, and the memory block of distribution is big It is small to be adapted to the size of block of video data, the flexibility of video data Memory Distribution Map is improved, improve memory usage.
Fig. 2 is referred to, is the flow chart of another memory allocation method provided in an embodiment of the present invention, the method may include Following steps S201~S207.
S201, obtains the size of pre-assigned default memory block in target memory pond.
Used as a kind of optional implementation method, target memory pond is to apply from memory pool when memory request is received One memory pool of enough memory headrooms, wherein, target memory pond includes multiple default memory blocks.
S202, when the memory request of video data is detected, each is regarded in the top n block of video data that acquisition is received The size of frequency data block.
Further, the size of each block of video data in the top n block of video data for receiving is obtained, wherein, N is pre- If quantity, specifically, can also be counted to the quantity of block of video data, a block of video data is often received, be incremented by internal meter Number, when the numerical value for internally counting reaches predetermined number N, obtains the size of each block of video data in N number of block of video data, First block of video data receiving, second block of video data ... n-th block of video data are processed, is obtained 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 difference of the size of default memory block.
Whether S204, the difference that judgement is calculated meets default first difference threshold.When judged result is to be, perform Step S205~S206, when judged result is no, performs step S207.
As a kind of optional implementation method, default first difference threshold be block of video data set in advance size with The minimum value and maximum of the difference of the size of default memory block, for example, default first difference threshold can be:[- 15, -1] (unit is KB), the i.e. size of block of video data can be -15KB with the minimum value of the difference of the size of default memory block, maximum Value can be -1KB.
S205, the size by block of video data is big with default second difference threshold and being calculated target memory block It is small.
Used as a kind of optional implementation method, when the difference being calculated meets default first difference threshold, calculating is regarded The size of frequency data block and default second difference threshold and obtain the size of target memory block, default second difference threshold is pre- The minimum value and maximum of the difference of the size of the default memory block for first setting and the size of block of video data, for example, default the Two difference thresholds can be:The difference of [1,20] (unit is KB), the i.e. size of block of video data and the size of default memory block Minimum value can be 1KB, maximum can be 20KB, specifically, a conduct can be selected most from default second difference threshold Final value, for example, 1 can be selected, if then the size of block of video data is 30KB, the size of target memory block can be set to 30+1= 31KB。
S206, by the size of the target memory block being calculated for video data distributes target memory block.
As a kind of optional implementation method, after the size of target memory block is calculated, can be according to target memory block Size apply for multiple target memory blocks from target memory pond, for example, the size for being calculated target memory block is 31KB, then The target memory block of multiple 31KB can be applied for from target memory pond.
S207, is video data distribution target memory block, and the size of target memory block is equal in magnitude with block of video data.
It is further alternative, as shown in figure 3, being a kind of Memory Allocation schematic diagram provided in an embodiment of the present invention, video counts Include first block of video data, 311, second block of video data 312, the 3rd database block 313 ..., target according to 31 Memory pool 32 includes the first default memory block 323 ... of the default default memory block the 322, the 3rd of memory block 321, second, target Also include in memory pool:First object memory block 331, the second target memory block 332, the 3rd target memory block 333 ....This hair In bright embodiment, the size of each block of video data in top n block of video data can be calculated, N=3 calculates first video counts According to the size of block 311, the size and the 3rd size of database block 313 of second block of video data 312.Specifically, can count Calculate the size of the first default memory block 321:B1=40KB, calculates the size of the second default memory block 322:B2=40KB, calculating The size of the 3rd default memory block 323:B3=40KB ....When first block of video data 311 is received, first is calculated The size of block of video data 311:A1=30KB, may compare the size of a1, b1, and default first difference is met in the difference of a1 and b1 During threshold value, by the size and default second difference threshold of block of video data and the size of target memory block is calculated, thus The size of first object memory block 331 can be calculated:C1=31KB;When second block of video data 312 is received, second is calculated The size of individual block of video data 312:A2=30KB, may compare the size of a2, b2, can similarly calculate the second target memory block 332 Size:C2=31KB;When the 3rd block of video data 313 is received, the 3rd size of block of video data 313 is calculated: A3=30KB, may compare the size of a3, b3, can similarly calculate the size of the 3rd target memory block 333:C3=31KB ... enters one Step, after the size for calculating target memory block, default memory block can be emptied, and by the big of the target memory block that is calculated Small is video data distribution target memory block, and as first block of video data 311 distributes the first object internal memory of c1=31KB Block 331, is second second target memory block 332 of the distribution of block of video data 312 c2=31KB, is the 3rd video database Block 313 distributes the 3rd target memory block 333 of c3=31KB.
The embodiment of the present invention provides a kind of memory allocation method, can obtain pre-assigned default internal memory in target memory pond The size of block, can obtain each video in the top n block of video data for receiving when the memory request of video data is detected The size of data block, and then the size of block of video data and the difference of the size of default memory block can be calculated, what is be calculated When difference meets default first difference threshold, by the size and default second difference threshold of block of video data and mesh is calculated The size of memory block is marked, can be by the size of the target memory block being calculated for video data distributes target memory block, the present invention Embodiment can carry out Memory Allocation according to the size of the block of video data in real-time video data, the internal memory block size of distribution with The size adaptation of block of video data, improves the flexibility of video data Memory Distribution Map, improves memory usage.
Below in conjunction with 4~Fig. 6 of accompanying drawing, Memory Allocation device provided in an embodiment of the present invention is described in detail.Need It is noted that the Memory Allocation device shown in 4~Fig. 6 of accompanying drawing, the side for performing Fig. 1 of the present invention or embodiment illustrated in fig. 2 Method, for convenience of description, illustrate only the part related to the embodiment of the present invention, and particular technique details is not disclosed, refer to Embodiment shown in Fig. 1 of the present invention or Fig. 2.
Fig. 4 is referred to, is a kind of structural representation of Memory Allocation device provided in an embodiment of the present invention;The device can be wrapped Include:Data block acquisition module 401, memory block acquisition module 402, comparison module 403 and distribute module 404.
Data block acquisition module 401, for when the memory request of video data is detected, obtaining the big of block of video data Small, video data includes multiple block of video data.
As a kind of optional implementation method, when the memory request of video data is detected, specifically, can receive To user to the play operation of video data when determine to detect the memory request of video data, detecting in video data After depositing request, data block acquisition module 401 can obtain the size of block of video data, wherein, video data includes multiple video counts According to block, block of video data can be one-frame video data, or a few frame video datas, specifically not by the embodiment of the present invention Limitation.
Further alternative, data block acquisition module 401 can include:First acquisition unit or second acquisition unit.
First acquisition unit, the size for obtaining each block of video data received in Preset Time, when default During the cause not of uniform size of the size of interior each block of video data for receiving and default memory block, the big of block of video data is determined The small cause not of uniform size with default memory block.
Second acquisition unit, the size for obtaining each block of video data in the top n block of video data for receiving, its In, N is predetermined number, the size of each block of video data and default memory block in the top n block of video data for receiving During cause not of uniform size, the size of block of video data and the cause not of uniform size of default memory block are determined.
In implementing, what Preset Time can be configured according to per the integral multiple of the delivery time of frame video data Time numerical value, such as 20ms, 15ms etc., the settable timer of Preset Time are controlled, then M can be received in Preset Time Block of video data, M is the positive integer more than 1, and then first acquisition unit can obtain each video data in M block of video data The size of block.
Further, second acquisition unit can obtain each block of video data in the top n block of video data for receiving Size, wherein, N is predetermined number, specifically, can also be counted to the quantity of block of video data, often receives a video counts According to block, it is incremented by count internal, when the numerical value for internally counting reaches predetermined number N, each is regarded in obtaining N number of block of video data The size of frequency data block, i.e. first block of video data, second block of video data ... n-th video data to receiving Block is processed, and obtains the size of each block of video data in top n block of video data.
Memory block acquisition module 402, the size for obtaining pre-assigned default memory block in target memory pond, target Memory pool includes multiple default memory blocks.
Used as a kind of optional implementation method, memory block acquisition module 402 can obtain pre-assigned in target memory pond The size of default memory block, wherein, target memory pond includes multiple default memory blocks, presets the size of memory block to preset A numerical value, target memory pond be when memory request is received from memory pool apply an internal memory for enough memory headrooms Pond, the size of the size more than video data in target memory pond.
Comparison module 403, for comparing the size of block of video data and the size of default memory block.
Used as a kind of optional implementation method, comparison module 403 may compare the size and default memory block of block of video data Size.In implementing, the size of block of video data and the difference of the size of default memory block can be calculated.Further, may be used Compare default memory block size whether more than block of video data size the first ratio value, or relatively default memory block is big Second ratio value of the small size for whether being less than block of video data.
It is further alternative, as shown in figure 5, being the structural representation of comparison module provided in an embodiment of the present invention, such as scheme Shown, comparison module 403 can include:First computing unit 51.
First computing unit 51, for calculating the size of block of video data and the difference of the size of default memory block, in difference When value meets default first difference threshold, the comparative result for determining comparison module is:The size of block of video data and default internal memory The cause not of uniform size of block.
Further alternative, comparison module 403 can also include:Ratio value comparing unit 52.
Ratio value comparing unit 52, for relatively default memory block size whether more than block of video data size the One ratio value, or relatively default memory block size whether less than block of video data size the second ratio value;In default The size of counterfoil is more than the first ratio value of the size of block of video data, or the size of default memory block is less than block of video data During the second ratio value of size, the comparative result for determining comparison module is:The size of block of video data is big with default memory block It is small inconsistent.
In implementing, the first ratio value can be that the size of default memory block set in advance is bigger than block of video data Small many ratio values, such as the first ratio value can be 120%, if the size of default memory block is 80KB, block of video data Size is 30KB, then 80>30*120%;Second ratio value can be that the size of default memory block set in advance compares video data The few ratio value of the size of block, such as the second ratio value can be 110%, if the size of default memory block is 80KB, video counts It is 80KB, then 80 according to the size of block<80*110%.
Distribute module 404, be in the comparative result of comparison module 403:The size of block of video data and default memory block During cause not of uniform size, the size according to block of video data is video data distribution target memory block.
As a kind of optional implementation method, comparison module 403 comparative result for block of video data size with it is pre- If during the cause not of uniform size of memory block, distribute module 404 can empty default memory block, and according to the size of block of video data be regarding Frequency data distribution target memory block.Specifically, distribute module 404 can empty pre-assigned default memory block, then be again regarding Frequency is according to storage allocation block, specially video data distribution target memory block.Further, also can be directly according to block of video data Size for video data distribute target memory block, do not limited by the embodiment of the present invention specifically.
Further, data block acquisition module 401 obtain Preset Time in receive each block of video data it is big After small, during the cause not of uniform size of the size of each block of video data received in Preset Time and default memory block, than Can determine that comparative result is compared with module 403:The cause not of uniform size of the size of block of video data and default memory block.
Further, after the size of each block of video data in obtaining the top n block of video data for receiving, connecing In the top n block of video data for receiving during the cause not of uniform size of the size of each block of video data and default memory block, it is determined that than Comparative result compared with module 403 is:The cause not of uniform size of the size of block of video data and default memory block.
Further, the size and difference resulting in the difference of the size of default memory block of block of video data are being calculated When meeting default first difference threshold, it may be determined that the comparative result of comparison module 403 is:The size of block of video data is interior with default The cause not of uniform size of counterfoil.Wherein, size and default internal memory that the first difference threshold is block of video data set in advance are preset The minimum value and maximum of the difference of the size of block, for example, default first difference threshold can be:[- 15, -1] (unit is KB), i.e. the minimum value of the size of block of video data and the difference of the size of default memory block can be -15KB, and maximum can be with For -1KB.
Further, it is in first ratio value of the size more than the size of block of video data of default memory block or default interior When the size of counterfoil is less than the second ratio value of the size of block of video data, class determines that the comparative result of comparison module 403 is:Depending on The cause not of uniform size of the size of frequency data block and default memory block.
It is further alternative, as shown in fig. 6, being the structural representation of distribute module provided in an embodiment of the present invention, such as scheme Shown, distribute module 404 can include:Second computing unit 61 and allocation unit 62.
Second computing unit 61, for calculate the size of block of video data and default second difference threshold and, or calculating The size of block of video data and the product of default fractional threshold, the size of target memory block is obtained by result of calculation.
Allocation unit 62, multiple target memory blocks are applied for for the size according to target memory block from target memory pond, And for block of video data distributes target memory block.
In implementing, default second difference threshold is the size and block of video data of default memory block set in advance The minimum value and maximum of the difference of size, for example, default second difference threshold can be:[1,20] (unit is KB), that is, regard The size of frequency data block can be 1KB with the minimum value of the difference of the size of default memory block, and maximum can be 20KB, specifically , one can be selected as end value from default second difference threshold, for example, 1 can be selected, if then the size of block of video data is 30KB, then the size of target memory block can be set to 30+1=31KB.
Wherein, default fractional threshold can be the size and the size of block of video data of target memory block set in advance The minimum value and maximum of ratio, for example, default fractional threshold can for [1.1,1.5], the i.e. size of target memory block with regard The minimum value of the ratio of the size of frequency data block can be 1.1, and the maximum of ratio can be 1.5.For example, block of video data Size is 30KB, then the size of target memory block can be set to 30*1.1=33KB.
In implementing, after the second computing unit 61 is calculated the size of target memory block, allocation unit 62 can root Apply for multiple target memory blocks from target memory pond according to the size of target memory block, for example, being calculated target memory block Size is 31KB, then can apply for the target memory block of multiple 31KB from target memory pond.Further, it is each video data Block distributes a target memory block, so that the block of video data that will can be received is cached in target memory block.
It is further alternative, be in the comparative result of comparison module 403:The size of block of video data and default memory block When in the same size, the block of video data that distribute module 404 will can also be received is cached in default memory block.
It is further alternative, be in the comparative result of comparison module 403:The size of block of video data and default memory block During cause not of uniform size, default memory block is emptied, distribute module 404 can distribute target memory block for video data, wherein, in target The size of counterfoil is identical with the size of block of video data.
The embodiment of the present invention provides a kind of Memory Allocation device, and data block acquisition module can be being detected in video data When depositing request, the size of block of video data is obtained, memory block acquisition module can obtain pre-assigned default in target memory pond The size of memory block, and then comparison module may compare the size of block of video data and the size of default memory block, in comparison module Comparative result be:During the cause not of uniform size of the size of block of video data and default memory block, distribute module can be according to video counts According to the size of block for video data distributes target memory block, the embodiment of the present invention can be according to the video counts in real-time video data Memory Allocation is carried out according to the size of block, the internal memory block size of distribution is adapted to the size of block of video data, improves video data The flexibility of Memory Distribution Map, improves memory usage.
The embodiment of the invention also discloses a kind of terminal, including any shown devices of Fig. 4~Fig. 6;The structure of the device With function reference can be made to the associated description of any illustrated embodiments of Fig. 4~Fig. 6, will not be described here.It should be noted that the present embodiment The server of offer is corresponding with the memory allocation method shown in Fig. 1, Fig. 2, is based on the Memory Allocation side shown in Fig. 1 or Fig. 2 The executive agent of method.
One of ordinary skill in the art will appreciate that all or part of flow in realizing above-described embodiment method, can be The hardware of correlation is instructed to complete by computer program, described program can be stored in a computer read/write memory medium In, the program is upon execution, it may include such as the flow of the embodiment of above-mentioned each method.Wherein, described storage medium can be magnetic Dish, CD, read-only memory (Read-Only Memory, ROM) or random access memory (Random Access Memory, RAM) etc..
Above disclosed is only present pre-ferred embodiments, can not limit the right model of the present invention with this certainly Enclose, therefore the equivalent variations made according to the claims in the present invention, still belong to the scope that the present invention is covered.

Claims (8)

1. a kind of memory allocation method, it is characterised in that methods described includes:
When the memory request of video data is detected, the size of block of video data is obtained, the video data includes multiple institutes State block of video data;
The size of pre-assigned default memory block in target memory pond is obtained, the target memory pond includes multiple described default Memory block;
Compare the size of the block of video data and the size of the default memory block;
It is in the comparative result:During the cause not of uniform size of the size of the block of video data and the default memory block, according to The size of the block of video data is that the video data distributes target memory block;
The size according to the block of video data is that the video data distributes target memory block, including:
Calculate the size of the block of video data and default second difference threshold and, or the calculating block of video data size With the product of default fractional threshold, the size of the target memory block is obtained by the result of calculation;Wherein, described default second Difference threshold is the minimum value and maximum of the size with the difference of the size of the block of video data of the default memory block;
Size according to the target memory block applies for multiple target memory blocks from the target memory pond, and for described Block of video data distributes the target memory block.
2. the method for claim 1, it is characterised in that the size of the acquisition block of video data includes:
The size of each block of video data received in Preset Time is obtained, each received in the Preset Time is regarded During the cause not of uniform size of the size of frequency data block and the default memory block, determine that the comparative result is:The video data The cause not of uniform size of the size of block and the default memory block;Or
The size of each block of video data in the top n block of video data that acquisition is received, wherein, N is predetermined number, described In the top n block of video data for receiving during the cause not of uniform size of the size of each block of video data and the default memory block, Determine that the comparative result is:The cause not of uniform size of the size of the block of video data and the default memory block.
3. the method for claim 1, it is characterised in that the size of the comparing block of video data and described default The size of memory block, including:
The size of the block of video data and the difference of the size of the default memory block are calculated, default the is met in the difference During one difference threshold, determine that the comparative result is:The size of the size of the block of video data and the default memory block is not Unanimously.
4. the method for claim 1, it is characterised in that the size of the comparing block of video data and described default The size of memory block, including:
Compare the default memory block size whether more than the block of video data size the first ratio value, or compare institute State default memory block size whether less than the block of video data size the second ratio value;In the default memory block Size is more than the first ratio value of the size of the block of video data, or the size of the default memory block is less than the video counts According to the size of block the second ratio value when, determine that the comparative result is:The size of the block of video data is default interior with described The cause not of uniform size of counterfoil.
5. a kind of Memory Allocation device, it is characterised in that described device includes:
Data block acquisition module, it is described for when the memory request of video data is detected, obtaining the size of block of video data Video data includes multiple block of video data;
Memory block acquisition module, the size for obtaining pre-assigned default memory block in target memory pond, in the target Depositing pond includes multiple default memory blocks;
Comparison module, for comparing the size of the block of video data and the size of the default memory block;
Distribute module, be in the comparative result of the comparison module:The size of the block of video data and the default memory block Cause not of uniform size when, size according to the block of video data distributes target memory block for the video data;
The distribute module includes:
Second computing unit, for calculate the size of the block of video data and default second difference threshold and, or calculating institute The size of block of video data and the product of default fractional threshold are stated, the big of the target memory block is obtained by the result of calculation It is small;Wherein, default second difference threshold is the difference of the size with the size of the block of video data of the default memory block The minimum value and maximum of value;
Allocation unit, applies in multiple targets for the size according to the target memory block from the target memory pond Counterfoil, and for the block of video data distributes the target memory block.
6. device as claimed in claim 5, it is characterised in that the data block acquisition module includes:First acquisition unit or Second acquisition unit;
The first acquisition unit, the size for obtaining each block of video data received in Preset Time, described pre- If during the cause not of uniform size of the size of each block of video data received in the time and the default memory block, it is determined that described regard The cause not of uniform size of the size of frequency data block and the default memory block;
The second acquisition unit, the size for obtaining each block of video data in the top n block of video data for receiving, its In, N is predetermined number, and the size of each block of video data is default with described in the top n block of video data for receiving During the cause not of uniform size of memory block, the size of the block of video data and the cause not of uniform size of the default memory block are determined.
7. device as claimed in claim 5, it is characterised in that the comparison module includes:
First computing unit, for calculating the size of the block of video data and the difference of the size of the default memory block, When the difference meets default first difference threshold, the comparative result for determining the comparison module is:The size of block of video data With the cause not of uniform size of the default memory block.
8. device as claimed in claim 5, it is characterised in that the comparison module also includes:
Whether ratio value comparing unit, the size for comparing the default memory block is more than the size of the block of video data First ratio value, or relatively the size of the default memory block whether less than the block of video data size the second ratio Value;In first ratio value of the size more than the size of the block of video data of the default memory block, or the default internal memory When the size of block is less than the second ratio value of the size of the block of video data, the comparative result for determining the comparison module is: The cause not of uniform size of the size of the block of video data and the default memory block.
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 CN104182355A (en) 2014-12-03
CN104182355B true 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)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105578264B (en) * 2015-12-30 2019-03-01 深圳Tcl数字技术有限公司 The processing method and processing device of animated menu based on smart television
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
CN110475122B (en) * 2018-05-10 2021-10-08 腾讯科技(深圳)有限公司 Method and device for playing live video stream
CN111464860B (en) * 2019-01-18 2021-06-08 中国科学院声学研究所 Cache allocation method for video data
CN111131185B (en) * 2019-12-06 2022-12-09 中国电子科技网络信息安全有限公司 CAN bus network anomaly detection method and device based on machine learning
CN112752152B (en) * 2020-12-28 2022-11-25 海信视像科技股份有限公司 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

Also Published As

Publication number Publication date
CN104182355A (en) 2014-12-03

Similar Documents

Publication Publication Date Title
CN104182355B (en) A kind of memory allocation method and device
CN103593453B (en) Method and device for calculating user retention ratio
CN103324566A (en) Multi-version test method and device for web page product
CN107742313A (en) A kind of data compression method and equipment applied to vector space
CN111028179B (en) Stripe correction method and device, electronic equipment and storage medium
CN103970879B (en) Method and system for regulating storage positions of data blocks
CN109151905A (en) Random access resource distributing method and base station, readable storage medium storing program for executing and electronic equipment
CN103501468B (en) Method and device for detecting whether network video playing address is effective
CN104426953A (en) Method and apparatus for distributing calculation resources
CN105847442A (en) Download speed adjustment method, background server, terminal and system
CN107317864A (en) The data balancing method and device of a kind of storage device
CN107515788A (en) A kind of method and device of Memory Allocation
CN108055486B (en) Brightness correction method and device
AU2017203553A1 (en) Geospatial smoothing in web applications
CN106886752A (en) The method and terminal of a kind of image procossing
CN109818921B (en) Method and device for analyzing abnormal flow of website interface
CN106683108A (en) Method and apparatus for determining the flat areas of video frame and electronic device
CN105160003A (en) Geographic position-based APP retrieving and ordering method and system
CN107886469A (en) A kind of image beautification method, device, electronic equipment and storage medium
CN105045910A (en) Application candidate set generation method and device and service equipment
CN104679666A (en) Embedded system memory management method and management system
CN109492574B (en) Data processing method and device
CN107347065A (en) A kind of data push method and device, a kind of terminal and storage medium
CN106557430A (en) A kind of data cached brush method and device
CN104093163B (en) The business flow allocation method and device of terminal collaboration

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
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.

EE01 Entry into force of recordation of patent licensing contract
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