技术领域technical field
本发明涉及电子技术领域,尤其涉及一种机顶盒内存分配方法及装置。The invention relates to the field of electronic technology, in particular to a set-top box memory allocation method and device.
背景技术Background technique
机顶盒是一个连接电视机与外部信号源的设备,可以将压缩的数字信号转成电视内容,并在电视机上显示出来。随着数字电视的发展,越来越多的用户使用机顶盒来接收数字信号进而收看数字电视。A set-top box is a device that connects a TV with an external signal source, converts compressed digital signals into TV content, and displays them on the TV. With the development of digital TV, more and more users use set-top boxes to receive digital signals and watch digital TV.
机顶盒内部不同软件模块在执行任务时,需要从系统可用内存中分配内存给对应的软件模块以执行各自的任务。目前大多分配内存的方法是估算一个软件模块需要的内存大小的估计值,固定分配估计值大小的内存给该软件模块。在机顶盒图文处理模块开发的过程中,根据不同的需求,图文处理模块,例如UI模块,处理的图片或者文字随时可能改变,则图文处理模块需要的内存大小也会随之变化,那么固定分配内存的方法,有可能会造成分配的内存不足导致运行失败,或分配的内存有剩余可能造成内存碎片或内存泄露的问题,如果每次开发人员每修改一次图像或文字就修改一次给图文处理模块的内存的大小,将极大地影响机顶盒图文处理模块的开发效率。When performing tasks, different software modules inside the set-top box need to allocate memory from the available memory of the system to the corresponding software modules to perform their respective tasks. At present, most methods of allocating memory are to estimate the estimated value of the memory size required by a software module, and fixedly allocate the memory of the estimated size to the software module. In the development process of the graphics and text processing module of the set-top box, according to different requirements, the graphics or text processed by the graphics and text processing module, such as the UI module, may change at any time, and the memory size required by the graphics and text processing module will also change accordingly. The method of fixedly allocating memory may cause insufficient allocated memory to cause running failure, or excess allocated memory may cause memory fragmentation or memory leaks. If the developer modifies the image or text every time The memory size of the text processing module will greatly affect the development efficiency of the text processing module of the set-top box.
发明内容Contents of the invention
本发明实施例提供一种机顶盒内存分配方法及装置,可以实现根据图文处理模块的图文处理对象的占用空间大小为所述图文处理模块分配内存,提高了机顶盒图文处理模块的开发效率。The embodiment of the present invention provides a set-top box memory allocation method and device, which can allocate memory for the image-text processing module according to the size of the image-text processing object occupied by the image-text processing module, and improve the development efficiency of the set-top box image-text processing module .
本发明实施例第一方面提供了一种机顶盒内存分配方法,所述方法可以包括:The first aspect of the embodiment of the present invention provides a set-top box memory allocation method, the method may include:
获取图文处理模块的图文处理对象;Obtain the image-text processing object of the image-text processing module;
确定所述图文处理对象的占用空间大小;Determine the size of the occupied space of the image-text processing object;
根据所述图文处理对象的占用空间大小从系统可用内存中为所述图文处理模块分配内存,以使所述图文处理模块对所述图文处理对象进行处理。Allocating memory for the image-text processing module from the available memory of the system according to the occupied space of the image-text processing object, so that the image-text processing module processes the image-text processing object.
在本发明实施例第一方面的第一种可能的实现方式中,所述图文处理对象包括至少一个图文处理子对象;In a first possible implementation manner of the first aspect of the embodiments of the present invention, the image-text processing object includes at least one image-text processing sub-object;
所述确定所述图文处理对象的占用空间大小包括:The determination of the size of the occupied space of the image-text processing object includes:
分别获取所述至少一个图文处理子对象中每一个图文处理子对象的占用空间大小;Respectively acquire the occupied space of each image-text processing sub-object in the at least one image-text processing sub-object;
将所述每一个图文处理子对象的占用空间大小累加得到所述图文处理对象的占用空间大小。The occupied space of each image-text processing sub-object is accumulated to obtain the occupied space of the image-text processing object.
结合本发明实施例第一方面的第一种可能的实现方式,在本发明实施例第一方面的第二种可能的实现方式中,所述根据所述图文处理对象的占用空间大小从系统可用内存中为所述图文处理模块分配内存包括:With reference to the first possible implementation of the first aspect of the embodiments of the present invention, in the second possible implementation of the first aspect of the embodiments of the present invention, the Allocating memory for the graphics and text processing module in the available memory includes:
从系统可用内存中分配所述图文处理对象的占用空间大小的内存给所述图文处理模块。Allocating a memory equal to the occupied space of the image-text processing object to the image-text processing module from the available memory of the system.
结合本发明实施例第一方面的第二种可能的实现方式,在本发明实施例第一方面的第三种可能的实现方式中,所述图文处理对象包括图片对象和/或字符对象。With reference to the second possible implementation manner of the first aspect of the embodiments of the present invention, in a third possible implementation manner of the first aspect of the embodiments of the present invention, the image-text processing object includes a picture object and/or a character object.
相应地,本发明实施例还提供了一种机顶盒内存分配装置,所述装置可以包括:Correspondingly, the embodiment of the present invention also provides a set-top box memory allocation device, the device may include:
获取单元,用于获取图文处理模块的图像处理对象;An acquisition unit, configured to acquire the image processing object of the graphic processing module;
确定单元,用于确定所述图文处理对象的占用空间大小;A determining unit, configured to determine the occupied space of the image-text processing object;
分配单元,用于根据所述图文处理对象的占用空间大小从系统可用内存中为所述图文处理模块分配内存,以使所述图文处理模块对所述图文处理对象进行处理。The allocating unit is configured to allocate memory for the image-text processing module from the available memory of the system according to the occupied space of the image-text processing object, so that the image-text processing module processes the image-text processing object.
在本发明实施例第二方面的第一种可能的实现方式中,所述图文处理对象包括至少一个图文处理子对象;In a first possible implementation manner of the second aspect of the embodiment of the present invention, the image-text processing object includes at least one image-text processing sub-object;
所述确定单元包括:The determination unit includes:
大小获取单元,用于分别获取所述至少一个图文处理子对象的占用空间大小;A size acquisition unit, configured to respectively acquire the occupied space size of the at least one graphics and text processing sub-object;
累加单元,用于将所述每一个图文处理子对象的占用空间大小累加得到所述图文处理对象的占用空间大小。An accumulating unit, configured to accumulate the occupied space of each graphic-text processing sub-object to obtain the occupied space of the graphic-text processing object.
结合本发明实施例第二方面的第一种可能的实现方式,在本发明实施例第二方面的第二种可能的实现方式中,所述分配单元具体用于从系统可用内存中分配所述图文处理对象的占用空间大小的内存给所述图文处理模块。With reference to the first possible implementation manner of the second aspect of the embodiment of the present invention, in the second possible implementation manner of the second aspect of the embodiment of the present invention, the allocation unit is specifically configured to allocate the The image-text processing module takes up memory of the size of the space occupied by the image-text processing object.
结合本发明实施例第二方面的第二种可能的实现方式,在本发明实施例第二方面的第三种可能的实现方式中,所述图文处理对象包括图片对象和/或字符对象。With reference to the second possible implementation manner of the second aspect of the embodiments of the present invention, in a third possible implementation manner of the second aspect of the embodiments of the present invention, the image-text processing object includes a picture object and/or a character object.
实施本发明实施例,具有如下有益效果:Implementing the embodiment of the present invention has the following beneficial effects:
通过获取图文处理模块的图文处理对象的占用空间大小,从系统可用内存中为所述图文处理模块分配占用空间大小的内存,可以实现在机顶盒图文处理模块开发过程中随着图文处理对象的改变,为图文处理模块灵活分配内存,提高了机顶盒图文处理模块的开发效率。By obtaining the size of the occupied space of the graphics and text processing object of the graphics and text processing module, and allocating the memory of the size of the occupied space for the graphics and text processing module from the available memory of the system, it can be realized that in the development process of the graphics and text processing module of the set-top box The change of the processing object is used to flexibly allocate memory for the graphics and text processing module, which improves the development efficiency of the graphics and text processing module of the set-top box.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1是本发明实施例提供的一种机顶盒内存分配方法的流程示意图;Fig. 1 is a schematic flow chart of a set-top box memory allocation method provided by an embodiment of the present invention;
图2是本发明另一实施例提供的一种机顶盒内存分配方法的流程示意图;Fig. 2 is a schematic flow chart of a set-top box memory allocation method provided by another embodiment of the present invention;
图3是本发明实施例提供的一种机顶盒内存分配装置的结构示意图;3 is a schematic structural diagram of a set-top box memory allocation device provided by an embodiment of the present invention;
图4是本发明实施例3中确定单元的实施例的结构示意图;Fig. 4 is a schematic structural diagram of an embodiment of a determination unit in Embodiment 3 of the present invention;
图5是本发明实施例提供的另一种机顶盒内存分配装置的结构示意图。Fig. 5 is a schematic structural diagram of another set-top box memory allocation device provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
本发明的应用场景可以包括但不仅限于接收开机指令后,启动图文展示模块将开机界面展示在机顶盒的显示屏幕上,或者将机顶盒在电视机上的应用导航界面通过机顶盒与电视机接口传送给电视机。The application scenarios of the present invention may include but are not limited to, after receiving the boot command, start the graphic display module to display the boot interface on the display screen of the set-top box, or transmit the application navigation interface of the set-top box on the TV to the TV through the interface between the set-top box and the TV machine.
图1是本发明实施例提供的一种机顶盒内存分配方法的流程示意图,如图所示,所述方法可以包括:Fig. 1 is a schematic flow chart of a set-top box memory allocation method provided by an embodiment of the present invention. As shown in the figure, the method may include:
S101,获取图文处理模块的图文处理对象。S101. Acquire an image-text processing object of an image-text processing module.
具体的,上述图文处理模块可以是UI模块,上述图文处理对象包括图片对象和/或字符对象。步骤S101可以是机顶盒开机后触发执行的。机顶盒内存分配装置可以从机顶盒内部的存储介质中图文处理模块对应的存储位置获取图文处理对象。上述机顶盒内部的存储介质和机顶盒系统内存是两种不同概念,上述机顶盒内部的存储介质用来存储机顶盒软件模块的运行程序或数据等,如图文处理模块的图文处理对象,机顶盒关机断电后,图文处理对象仍然存在,上述机顶盒内部的存储介质可以是存储卡,硬盘等。上述机顶盒系统内存是用来存储机顶盒运行时各个软件模块,如图文处理模块,产生的数据,机顶盒关机断电后,上述运行中产生的数据被清除,上述机顶盒系统内存可以是随机存储记忆体的空间等。Specifically, the image-text processing module may be a UI module, and the image-text processing objects include image objects and/or character objects. Step S101 may be triggered to be executed after the set-top box is turned on. The set-top box memory allocation device can acquire the graphic-text processing object from the storage location corresponding to the graphic-text processing module in the storage medium inside the set-top box. The storage medium inside the above-mentioned set-top box and the system memory of the set-top box are two different concepts. The storage medium inside the above-mentioned set-top box is used to store the running program or data of the software module of the set-top box, such as the image-text processing object of the image-text processing module. Afterwards, the image-text processing object still exists, and the storage medium inside the above-mentioned set-top box may be a memory card, a hard disk, and the like. The system memory of the set-top box is used to store the data generated by each software module when the set-top box is running, such as the image-text processing module. After the set-top box is powered off, the data generated during the operation is cleared. space etc.
S102,确定所述图文处理对象的占用空间大小。S102. Determine the occupied space of the image-text processing object.
具体的,上述图文处理对象包括至少一个图文处理子对象,分别获取所述至少一个图文处理子对象中每一个图文处理子对象的占用空间大小,将所述每一个图文处理子对象的占用空间大小累加得到所述图文处理对象的占用空间大小。例如图像展示模块需要展示的图片有五张,五张图片占用空间大小分别为50KB、45KB、20KB、25KB和10KB,则图像展示模块的图文处理对象的占用空间大小为150KB。Specifically, the above-mentioned image-text processing object includes at least one image-text processing sub-object, and the occupied space of each image-text processing sub-object in the at least one image-text processing sub-object is obtained respectively, and each image-text processing sub-object The occupied space of the object is accumulated to obtain the occupied space of the image-text processing object. For example, the image display module needs to display five pictures, and the space occupied by the five pictures is 50KB, 45KB, 20KB, 25KB, and 10KB respectively, so the space occupied by the image-text processing object of the image display module is 150KB.
若所述图文处理模块的图文处理对象为图片对象,获取每一个图文处理子对象,即每一幅图片的宽度、高度、格式等属性信息,进而根据所述属性信息得到所述图文处理子对象的占用空间大小。若所述图文处理模块的图文处理对象为字符对象,获取每一个图文处理子对象,即每个字符的占用空间大小和字符对象的总个数,以使步骤S103将二者相乘得到字符对象的占用空间大小。If the image-text processing object of the image-text processing module is a picture object, obtain each image-text processing sub-object, that is, attribute information such as width, height, and format of each image, and then obtain the image according to the attribute information. The space occupied by the text processing sub-object. If the image-text processing object of the image-text processing module is a character object, obtain each image-text processing sub-object, that is, the occupied space size of each character and the total number of character objects, so that step S103 multiplies the two Get the space occupied by the character object.
S103,根据所述图文处理对象的占用空间大小从系统可用内存中为所述图文处理模块分配内存。S103. Allocate memory for the image-text processing module from the available memory of the system according to the occupied space of the image-text processing object.
具体的,从系统内存中分配所述图文处理对象的占用空间大小的内存给所述图文处理模块,以使所述图文处理模块对所述图文处理对象进行处理。例如步骤S102中得到的所述图文处理对象的大小为150KB,则从系统可用内存中为所述图文处理模块分配150KB的内存。Specifically, memory of the size occupied by the image-text processing object is allocated from the system memory to the image-text processing module, so that the image-text processing module processes the image-text processing object. For example, if the size of the image-text processing object obtained in step S102 is 150 KB, then 150 KB of memory is allocated for the image-text processing module from the available memory of the system.
通过获取图文处理模块的图文处理对象的占用空间大小,从系统可用内存中为所述图文处理模块分配占用空间大小的内存,可以实现在机顶盒图文处理模块开发过程中随着图文处理对象的改变,为图文处理模块灵活分配内存,提高了机顶盒图文处理模块的开发效率。By obtaining the size of the occupied space of the graphics and text processing object of the graphics and text processing module, and allocating the memory of the size of the occupied space for the graphics and text processing module from the available memory of the system, it can be realized that in the development process of the graphics and text processing module of the set-top box The change of the processing object is used to flexibly allocate memory for the graphics and text processing module, which improves the development efficiency of the graphics and text processing module of the set-top box.
图2是本发明另一实施例提供的一种机顶盒内存分配方法的流程示意图,如图所示,所述方法可以包括:Fig. 2 is a schematic flow chart of a set-top box memory allocation method provided by another embodiment of the present invention. As shown in the figure, the method may include:
S201,获取图文处理模块的图文处理对象。S201. Acquire an image-text processing object of an image-text processing module.
上述图文处理模块可以是UI模块,上述图文处理对象包括图片对象和/或字符对象。所述图文处理对象包括至少一个图文处理子对象,所述图文处理子对象可以是一幅图片、一个文字或一个符号等。The image-text processing module may be a UI module, and the image-text processing objects include image objects and/or character objects. The image-text processing object includes at least one image-text processing sub-object, and the image-text processing sub-object may be a picture, a text, or a symbol.
S202,分别获取所述至少一个图文处理子对象中每一个图文处理子对象的占用空间大小。S202. Obtain the occupied space of each image-text processing sub-object in the at least one image-text processing sub-object respectively.
若所述图文处理模块的图文处理对象为图片对象,获取每一个图文处理子对象,即每一幅图片的宽度、高度、格式等属性信息,进而根据所述属性信息得到所述图文处理子对象的占用空间大小。例如,一张32位颜色、1024×768像素、格式为BMP的图片占用空间大小为1024×768×32÷8=4096KB。If the image-text processing object of the image-text processing module is a picture object, obtain each image-text processing sub-object, that is, attribute information such as width, height, and format of each image, and then obtain the image according to the attribute information. The space occupied by the text processing sub-object. For example, a picture with 32-bit color, 1024×768 pixels, and BMP format occupies a space of 1024×768×32÷8=4096KB.
若所述图文处理模块的图文处理对象为字符对象,所述字符对象可以包括文字、字母、符号或数字等,则所述图文处理子对象可以是一个文字、一个字母、一个符号或一个数字等,可以获取预先设置的一个文字、一个字母、一个符号或一个数字的占用空间大小分别为两个字节、一个字节、一个字节和一个字节,并获取所述文字的总个数、字母的总个数、符号的总个数和数字的总个数,以使步骤S203进一步获取所述图文处理对象的占用空间大小。If the image-text processing object of the image-text processing module is a character object, and the character object can include words, letters, symbols or numbers, etc., then the image-text processing sub-object can be a word, a letter, a symbol or A number, etc., you can obtain the preset space occupied by a text, a letter, a symbol or a number as two bytes, one byte, one byte and one byte respectively, and obtain the total number, the total number of letters, the total number of symbols, and the total number of numbers, so that step S203 can further obtain the occupied space of the image-text processing object.
S203,将所述每一个图文处理子对象的占用空间大小累加得到所述图文处理对象的占用空间大小。S203. Accumulate the occupied space of each graphic-text processing sub-object to obtain the occupied space of the graphic-text processing object.
具体实现中,若所述图文处理对象为图片对象,图文处理子对象可以是一幅图片,对所述图片处理子对象从零开始编号,可以是按图片生成时间先后编排,也可以随机编排,统计所述图像处理子对象的总个数,预先设置一个占用空间中间变量,上述占用空间中间变量初始值为零,获取步骤S202中得到的编号为零的图片的占用空间大小,与所述占用空间中间变量相加,得到相加后的占用空间中间变量,继续获取步骤S202中得到的编号为一的图片的占用空间大小,与所述相加后的占用空间中间变量相加,循环该过程直到编号等于所述图像处理子对象总个数的图片的占用空间大小被累加在上述占用空间中间变量后结束,将上述占用空间中间变量的值确定为所述图文处理对象的占用空间大小。In specific implementation, if the image-text processing object is a picture object, the image-text processing sub-object can be a picture, and the picture-text processing sub-objects are numbered from zero, which can be arranged according to the generation time of the pictures, or randomly Arranging, counting the total number of the image processing sub-objects, setting an intermediate variable of occupied space in advance, the initial value of the intermediate variable of occupied space is zero, and obtaining the occupied space of the picture numbered zero obtained in step S202, which is consistent with the Add the intermediate variable of the occupied space to obtain the intermediate variable of occupied space after the addition, continue to obtain the occupied space size of the picture numbered as one obtained in step S202, add the intermediate variable of occupied space after the addition, and loop This process ends after the occupied space size of the picture whose number is equal to the total number of the image processing sub-objects is accumulated in the intermediate variable of the occupied space, and the value of the intermediate variable of the occupied space is determined as the occupied space of the image-text processing object size.
若所述图文处理对象为字符对象,将步骤S202中获取的文字的总个数乘以一个文字的占用空间大小,字母的总个数乘以一个字母的占用空间大小,符号的总个数乘以一个符号的占用空间大小,数字的总个数乘以一个数字的占用空间大小,将上述乘积相加后得到所述图文处理对象的占用空间大小。If the image-text processing object is a character object, the total number of characters obtained in step S202 is multiplied by the size of the occupied space of a character, the total number of letters is multiplied by the size of the occupied space of a letter, and the total number of symbols Multiplying the space occupied by a symbol, multiplying the total number of numbers by the space occupied by a number, and adding the above products together to obtain the space occupied by the image-text processing object.
例如,步骤S201中获取的图文处理模块的图文处理对象为五张图片:Image1.png、Image2.png、Image3.png、Image4.png和Image5.png,七个字母“welcome”和一个符号“!”,步骤S202中得到五张图片占用空间大小分别为:50KB、45KB、20KB、25KB和10KB,每个字母占用空间大小为一个字节,每个符号占用空间大小为一个字节,则步骤S203可以得到上述图文处理对象的占用空间大小为50KB+45KB+20KB+25KB+10KB+7×1KB+1×1KB=158KB。For example, the image-text processing object of the image-text processing module obtained in step S201 is five pictures: Image1.png, Image2.png, Image3.png, Image4.png and Image5.png, seven letters "welcome" and a symbol "!", the space occupied by the five pictures obtained in step S202 is respectively: 50KB, 45KB, 20KB, 25KB and 10KB, the space occupied by each letter is one byte, and the space occupied by each symbol is one byte, then In step S203, it can be obtained that the occupied space of the image-text processing object is 50KB+45KB+20KB+25KB+10KB+7*1KB+1*1KB=158KB.
S204,从系统可用内存中分配所述图文处理对象的占用空间大小的内存给所述图文处理模块。S204. Allocate a memory equal to the occupied space of the image-text processing object to the image-text processing module from the available memory of the system.
从系统可用内存中分配步骤S203中得到的所述图文处理对象的占用空间大小相等的内存给所述图文处理模块,以使所述图文处理模块对所述图文处理对象进行处理。Allocating memory equal to the occupied space of the image-text processing object obtained in step S203 from the available memory of the system to the image-text processing module, so that the image-text processing module processes the image-text processing object.
通过上述过程,在机顶盒开发的过程中,若在所述图文处理模块的图文处理对象中添加一幅图片,则直接将步骤S203中的图像处理子对象的总个数加一,并给增加的图片编号,进而可以获取所述图文处理对象的大小,并分配相应的内存给所述图文处理模块。若删除所述图文处理对象中的一幅图片,则将步骤S203中的图像处理子对象的总个数减一,并将删除图片的编号编给比删除图片的编号大一的图片,以此类推,进而获取所述图文处理对象的大小,并分配相应的内存给所述图文处理模块。若在所述图文处理模块的图文处理对象中更换一幅图片,则将更换前图片的编号编给更换后的图片,进而获取所述图片处理对象的大小,并分配相应的内存给所述图文处理模块,提高了开发效率。Through the above process, in the process of set-top box development, if a picture is added in the image-text processing object of the image-text processing module, the total number of image processing sub-objects in step S203 is directly added by one, and given The increased picture number can further obtain the size of the image-text processing object, and allocate corresponding memory to the image-text processing module. If you delete a picture in the image-text processing object, then the total number of image processing sub-objects in step S203 will be reduced by one, and the numbering of the deleted picture will be assigned to a picture that is one larger than the numbering of the deleted picture, so as to By analogy, the size of the image-text processing object is further obtained, and corresponding memory is allocated to the image-text processing module. If a picture is replaced in the picture-text processing object of the picture-text processing module, the serial number of the picture before the change is assigned to the picture after the change, and then the size of the picture-text processing object is obtained, and corresponding memory is allocated to all Described graphics and text processing module improves development efficiency.
若在所述图文处理模块的图文处理对象中更改、添加或删除文字、字母、符号或数字,则重新统计文字、字母、符号或数字各自的总个数即可,进而获取所述图片处理对象的大小,并分配相应的内存给所述图文处理模块,提高了开发效率。If you change, add or delete words, letters, symbols or numbers in the image-text processing object of the image-text processing module, it is enough to re-count the total number of words, letters, symbols or numbers, and then obtain the picture The size of the object is processed, and the corresponding memory is allocated to the image-text processing module, which improves the development efficiency.
通过获取图文处理模块的图文处理对象的占用空间大小,从系统可用内存中为所述图文处理模块分配占用空间大小的内存,可以实现在机顶盒图文处理模块开发过程中随着图文处理对象的改变,为图文处理模块灵活分配内存,提高了机顶盒图文处理模块的开发效率。By obtaining the size of the occupied space of the graphics and text processing object of the graphics and text processing module, and allocating the memory of the size of the occupied space for the graphics and text processing module from the available memory of the system, it can be realized that in the development process of the graphics and text processing module of the set-top box The change of the processing object is used to flexibly allocate memory for the graphics and text processing module, which improves the development efficiency of the graphics and text processing module of the set-top box.
图3是本发明实施例提供的一种机顶盒内存分配装置的结构示意图,如图所示,所述内存分配装置可以包括:获取单元301、确定单元302和分配单元303,其中:FIG. 3 is a schematic structural diagram of a set-top box memory allocation device provided by an embodiment of the present invention. As shown in the figure, the memory allocation device may include: an acquisition unit 301, a determination unit 302, and an allocation unit 303, wherein:
获取单元301,用于获取图文处理模块的图像处理对象。The acquiring unit 301 is configured to acquire an image processing object of the image-text processing module.
具体的,上述图文处理模块可以是UI模块,上述图文处理对象包括图片对象和/或字符对象。获取单元301获取图文处理模块的图像处理对象可以是机顶盒开机后触发执行的。获取单元301可以从机顶盒内部的存储介质中图文处理模块对应的存储位置获取图文处理对象。上述机顶盒内部的存储介质和机顶盒系统内存是两种不同概念,上述机顶盒内部的存储介质用来存储机顶盒软件模块的运行程序或数据等,如图文处理模块的图文处理对象,机顶盒关机断电后,图文处理对象仍然存在,上述机顶盒内部的存储介质可以是存储卡,硬盘等。上述机顶盒系统内存是用来存储机顶盒运行时各个软件模块,如图文处理模块,产生的数据,机顶盒关机断电后,上述运行中产生的数据被清除,上述机顶盒系统内存可以是随机存储记忆体的空间等。Specifically, the image-text processing module may be a UI module, and the image-text processing objects include image objects and/or character objects. Acquisition by the acquisition unit 301 of the image processing object of the image-text processing module may be triggered to execute after the set-top box is turned on. The obtaining unit 301 may obtain the image-text processing object from the storage location corresponding to the image-text processing module in the storage medium inside the set-top box. The storage medium inside the above-mentioned set-top box and the system memory of the set-top box are two different concepts. The storage medium inside the above-mentioned set-top box is used to store the running program or data of the software module of the set-top box, such as the image-text processing object of the image-text processing module. Afterwards, the image-text processing object still exists, and the storage medium inside the above-mentioned set-top box may be a memory card, a hard disk, and the like. The system memory of the set-top box is used to store the data generated by each software module when the set-top box is running, such as the image-text processing module. After the set-top box is powered off, the data generated during the operation is cleared. space etc.
确定单元302,用于确定所述图文处理对象的占用空间大小。The determining unit 302 is configured to determine the occupied space of the image-text processing object.
具体的,上述图文处理对象包括至少一个图文处理子对象,,所述图文处理子对象可以是一幅图片、一个文字或一个符号等。确定单元302分别获取所述至少一个图文处理子对象中每一个图文处理子对象的占用空间大小,将所述每一个图文处理子对象的占用空间大小累加得到所述图文处理对象的占用空间大小。例如图像展示模块需要展示的图片有五张,占用空间大小分别为50KB、45KB、20KB、25KB和10KB,则图像展示模块的图文处理对象的占用空间大小为150KB。Specifically, the image-text processing object includes at least one image-text processing sub-object, and the image-text processing sub-object may be a picture, a text, or a symbol. The determination unit 302 respectively acquires the occupied space of each image-text processing sub-object in the at least one image-text processing sub-object, and accumulates the occupied space of each image-text processing sub-object to obtain the image-text processing object. The size of the occupied space. For example, the image display module needs to display five pictures, and the occupied space is 50KB, 45KB, 20KB, 25KB, and 10KB respectively, so the image-text processing object of the image display module occupies 150KB.
可选的,如图4所示,所述确定单元302可以包括大小获取单元3201和累加单元3202,其中:Optionally, as shown in FIG. 4, the determination unit 302 may include a size acquisition unit 3201 and an accumulation unit 3202, wherein:
大小获取单元3201,用于分别获取所述至少一个图文处理子对象的占用空间大小。The size obtaining unit 3201 is configured to respectively obtain the occupied space size of the at least one graphics and text processing sub-object.
若所述图文处理模块的图文处理对象为图片对象,大小获取单元3201获取每一个图文处理子对象,即每一幅图片的宽度、高度、格式等属性信息,进而根据所述属性信息得到所述图文处理子对象的占用空间大小。例如,获取单元301获取一张32位颜色、1024×768像素、格式为BMP的图片,大小获取单元3201可以通过1024×768×32÷8=4096KB计算该图片占用空间大小为4096KB。If the image-text processing object of the image-text processing module is a picture object, the size acquisition unit 3201 acquires each image-text processing sub-object, that is, attribute information such as width, height, and format of each image, and then according to the attribute information Obtain the occupied space of the image-text processing sub-object. For example, the acquisition unit 301 acquires a picture with 32-bit color, 1024×768 pixels, and BMP format, and the size acquisition unit 3201 can calculate the space occupied by the picture as 4096KB by 1024×768×32÷8=4096KB.
若所述图文处理模块的图文处理对象为字符对象,所述字符对象可以包括文字、字母、符号或数字等,则所述图文处理子对象可以是一个文字、一个字母、一个符号或一个数字等,大小获取单元3201可以获取预先设置的一个文字、一个字母、一个符号或一个数字的占用空间大小分别为两个字节、一个字节、一个字节和一个字节,并获取所述文字的总个数、字母的总个数、符号的总个数和数字的总个数,以使累加单元3202进一步获取所述图文处理对象的占用空间大小。If the image-text processing object of the image-text processing module is a character object, and the character object can include words, letters, symbols or numbers, etc., then the image-text processing sub-object can be a word, a letter, a symbol or A number, etc., the size acquisition unit 3201 can acquire the pre-set space size of a text, a letter, a symbol or a number as two bytes, one byte, one byte and one byte respectively, and obtain all The total number of characters, the total number of letters, the total number of symbols and the total number of numbers, so that the accumulating unit 3202 can further obtain the occupied space of the image-text processing object.
累加单元3202,用于将所述每一个图文处理子对象的占用空间大小累加得到所述图文处理对象的占用空间大小。The accumulating unit 3202 is configured to accumulate the occupied space of each graphic-text processing sub-object to obtain the occupied space of the graphic-text processing object.
具体实现中,若所述图文处理对象为图片对象,图文处理子对象可以是一幅图片,累加单元3202可以对所述图片处理子对象从零开始编号,可以是按图片生成时间先后编排,也可以随机编排,统计所述图像处理子对象的总个数,预先设置一个占用空间中间变量,上述占用空间中间变量初始值为零,获取大小获取单元3201得到的编号为零的图片的占用空间大小,与所述占用空间中间变量相加,得到相加后的占用空间中间变量,继续获取大小获取单元3201得到的编号为一的图片的占用空间大小,与所述相加后的占用空间中间变量相加,循环该过程直到编号等于所述图像处理子对象总个数的图片的占用空间大小被累加在上述占用空间中间变量后结束,将上述占用空间中间变量的值确定为所述图文处理对象的占用空间大小。In specific implementation, if the image-text processing object is a picture object, the image-text processing sub-object can be a picture, and the accumulating unit 3202 can number the picture-text processing sub-objects from zero, which can be arranged according to the generation time of the pictures , can also be arranged randomly, count the total number of the image processing sub-objects, and pre-set an occupied space intermediate variable. The space size is added to the occupied space intermediate variable to obtain the added occupied space intermediate variable, and the occupied space size of the picture numbered one obtained by the size acquisition unit 3201 is obtained, and the added occupied space is obtained. The intermediate variables are added, and the process is circulated until the size of the occupied space of the picture whose number is equal to the total number of the image processing sub-objects is accumulated after the above-mentioned occupied space intermediate variable, and the value of the above-mentioned occupied space intermediate variable is determined as the image The space occupied by the text processing object.
若所述图文处理对象为字符对象,累加单元3202将大小获取单元3201获取的文字的总个数乘以一个文字的占用空间大小,字母的总个数乘以一个字母的占用空间大小,符号的总个数乘以一个符号的占用空间大小,数字的总个数乘以一个数字的占用空间大小,并将上述乘积相加后得到所述图文处理对象的占用空间大小。If the image-text processing object is a character object, the accumulating unit 3202 multiplies the total number of characters obtained by the size acquisition unit 3201 by the size of the occupied space of a character, the total number of letters multiplied by the size of the occupied space of a letter, and the symbol The total number of numbers is multiplied by the space occupied by a symbol, the total number of numbers is multiplied by the space occupied by a number, and the above products are added to obtain the space occupied by the image-text processing object.
例如,获取单元301获取的图文处理模块的图文处理对象为五张图片:Image1.png、Image2.png、Image3.png、Image4.png和Image5.png,七个字母“welcome”和一个符号“!”,大小获取单元3201得到五张图片占用空间大小分别为:50KB、45KB、20KB、25KB和10KB,每个字母占用空间大小为一个字节,每个符号占用空间大小为一个字节,累加单元3202可以得到上述图文处理对象的占用空间大小为50KB+45KB+20KB+25KB+10KB+7×1KB+1×1KB=158KB。For example, the image-text processing object of the image-text processing module acquired by the acquisition unit 301 is five pictures: Image1.png, Image2.png, Image3.png, Image4.png and Image5.png, seven letters "welcome" and a symbol "!", the size acquisition unit 3201 obtains the space occupied by five pictures as follows: 50KB, 45KB, 20KB, 25KB and 10KB, the space occupied by each letter is one byte, and the space occupied by each symbol is one byte. The accumulating unit 3202 can obtain that the space occupied by the image-text processing object is 50KB+45KB+20KB+25KB+10KB+7*1KB+1*1KB=158KB.
分配单元303,用于根据所述图文处理对象的占用空间大小从系统可用内存中为所述图文处理模块分配内存,以使所述图文处理模块对所述图文处理对象进行处理。The allocating unit 303 is configured to allocate memory for the image-text processing module from the available memory of the system according to the occupied space of the image-text processing object, so that the image-text processing module processes the image-text processing object.
从系统可用内存中分配确定单元302得到的所述图文处理对象的占用空间大小相等的内存给所述图文处理模块,以使所述图文处理模块对所述图文处理对象进行处理。例如确定单元302得到的所述图文处理对象的大小为150KB,则分配单元303从系统可用内存中为所述图文处理模块分配150KB的内存。Allocating memory equal to the occupied space of the image-text processing object obtained by the determining unit 302 from the available memory of the system to the image-text processing module, so that the image-text processing module processes the image-text processing object. For example, the size of the image-text processing object obtained by the determining unit 302 is 150 KB, and then the allocating unit 303 allocates 150 KB of memory for the image-text processing module from the available memory of the system.
在机顶盒开发的过程中,若在所述图文处理模块的图文处理对象中添加一幅图片,则累加单元3202直接将图像处理子对象的总个数加一,并给增加的图片编号,进而可以获取所述图文处理对象的大小,分配单元303分配相应的内存给所述图文处理模块。若删除所述图文处理对象中的一幅图片,则累加单元3202将图像处理子对象的总个数减一,并将删除图片的编号编给比删除图片的编号大一的图片,以此类推,进而获取所述图文处理对象的大小,分配单元303分配相应的内存给所述图文处理模块。若在所述图文处理模块的图文处理对象中更换一幅图片,则累加单元3202将更换前图片的编号编给更换后的图片,进而获取所述图片处理对象的大小,分配单元303分配相应的内存给所述图文处理模块,提高了开发效率。During the development of the set-top box, if a picture is added to the picture-text processing object of the picture-text processing module, the accumulating unit 3202 directly adds one to the total number of the picture-processing sub-objects, and numbers the added picture, Furthermore, the size of the image-text processing object can be obtained, and the allocation unit 303 allocates corresponding memory to the image-text processing module. If a picture in the image-text processing object is deleted, the accumulating unit 3202 will subtract one from the total number of image processing sub-objects, and assign the number of the deleted picture to a picture that is one larger than the number of the deleted picture, so as to By analogy, the size of the image-text processing object is further obtained, and the allocation unit 303 allocates corresponding memory to the image-text processing module. If a picture is replaced in the picture-text processing object of the picture-text processing module, the accumulating unit 3202 will code the number of the picture before the change to the picture after the change, and then obtain the size of the picture-text processing object, and the allocation unit 303 will allocate Corresponding memory is provided to the image-text processing module, which improves the development efficiency.
若在所述图文处理模块的图文处理对象中更改、添加或删除文字、字母、符号或数字,则累加单元3202重新统计文字、字母、符号或数字各自的总个数即可,进而获取所述图片处理对象的大小,分配单元303分配相应的内存给所述图文处理模块,提高了开发效率。If the text, letter, symbol or number is changed, added or deleted in the text processing object of the text processing module, then the accumulating unit 3202 can re-count the total number of the text, letter, symbol or number respectively, and then obtain According to the size of the image processing object, the allocation unit 303 allocates corresponding memory to the image-text processing module, which improves the development efficiency.
通过获取图文处理模块的图文处理对象的占用空间大小,从系统可用内存中为所述图文处理模块分配占用空间大小的内存,可以实现在机顶盒图文处理模块开发过程中随着图文处理对象的改变,为图文处理模块灵活分配内存,提高了机顶盒图文处理模块的开发效率。By obtaining the size of the occupied space of the graphics and text processing object of the graphics and text processing module, and allocating the memory of the size of the occupied space for the graphics and text processing module from the available memory of the system, it can be realized that in the development process of the graphics and text processing module of the set-top box The change of the processing object is used to flexibly allocate memory for the graphics and text processing module, which improves the development efficiency of the graphics and text processing module of the set-top box.
图5是本发明实施例提供的另一种机顶盒内存分配装置的结构示意图,如图所示,所述内存分配装置可以包括:至少一个输入装置401,至少一个输出装置402,至少一个处理器403,例如CPU,存储器404和至少一个总线405。FIG. 5 is a schematic structural diagram of another set-top box memory allocation device provided by an embodiment of the present invention. As shown in the figure, the memory allocation device may include: at least one input device 401, at least one output device 402, and at least one processor 403 , such as a CPU, a memory 404 and at least one bus 405 .
其中,上述总线405用于连接上述输入装置401、输出装置402、处理器403和存储器404。Wherein, the above-mentioned bus 405 is used for connecting the above-mentioned input device 401 , output device 402 , processor 403 and memory 404 .
其中,上述输入装置401具体可为内存分配装置的用户接口,包括按键,用于接收用户的操作指令。Wherein, the above-mentioned input device 401 may specifically be a user interface of the memory allocation device, including buttons, for receiving user's operation instructions.
上述输出设装置402具体可为内存分配装置的显示屏,用于展示图文处理模块的处理图文对象。The above-mentioned output device 402 may specifically be a display screen of the memory allocation device, which is used to display the processed graphic objects of the graphic-text processing module.
上述存储器404可以是高速RAM存储器,也可为非不稳定的存储器(non-volatile memory),例如磁盘存储器。上述存储器404用于存储一组程序代码,上述处理器403,用于调用存储器404中存储的程序代码,执行如下操作:The above-mentioned memory 404 may be a high-speed RAM memory, or a non-volatile memory, such as a disk memory. The memory 404 is used to store a set of program codes, and the processor 403 is used to call the program codes stored in the memory 404 to perform the following operations:
获取图文处理模块的图文处理对象;Obtain the image-text processing object of the image-text processing module;
确定所述图文处理对象的占用空间大小;Determine the size of the occupied space of the image-text processing object;
根据所述图文处理对象的占用空间大小从系统可用内存中为所述图文处理模块分配内存,以使所述图文处理模块对所述图文处理对象进行处理。Allocating memory for the image-text processing module from the available memory of the system according to the occupied space of the image-text processing object, so that the image-text processing module processes the image-text processing object.
在一种可选的实施方式中,所述图文处理对象包括至少一个图文处理子对象;In an optional implementation manner, the image-text processing object includes at least one image-text processing sub-object;
上述处理器403,用于调用存储器404中存储的程序代码,执行:The above-mentioned processor 403 is used to call the program code stored in the memory 404 to execute:
分别获取所述至少一个图文处理子对象中每一个图文处理子对象的占用空间大小;Respectively acquire the occupied space of each image-text processing sub-object in the at least one image-text processing sub-object;
将所述每一个图文处理子对象的占用空间大小累加得到所述图文处理对象的占用空间大小。The occupied space of each image-text processing sub-object is accumulated to obtain the occupied space of the image-text processing object.
在另一种可选的实施例中,上述处理器403,用于调用存储器404中存储的程序代码,执行:In another optional embodiment, the processor 403 is configured to call the program code stored in the memory 404 to execute:
从系统可用内存中分配所述图文处理对象的占用空间大小的内存给所述图文处理模块。Allocating a memory equal to the occupied space of the image-text processing object to the image-text processing module from the available memory of the system.
可选的,所述图文处理对象包括图片对象和/或字符对象。Optionally, the graphics and text processing objects include picture objects and/or character objects.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the programs can be stored in a computer-readable storage medium. During execution, it may include the processes of the embodiments of the above-mentioned methods. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAM), etc.
以上所揭露的仅为本发明较佳实施例而已,当然不能以此来限定本发明之权利范围,因此依本发明权利要求所作的等同变化,仍属本发明所涵盖的范围。The above disclosures are only preferred embodiments of the present invention, and certainly cannot limit the scope of rights of the present invention. Therefore, equivalent changes made according to the claims of the present invention still fall within the scope of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410834623.9ACN104602103A (en) | 2014-12-29 | 2014-12-29 | Set top box memory distribution method and device |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410834623.9ACN104602103A (en) | 2014-12-29 | 2014-12-29 | Set top box memory distribution method and device |
| Publication Number | Publication Date |
|---|---|
| CN104602103Atrue CN104602103A (en) | 2015-05-06 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201410834623.9APendingCN104602103A (en) | 2014-12-29 | 2014-12-29 | Set top box memory distribution method and device |
| Country | Link |
|---|---|
| CN (1) | CN104602103A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118433472A (en)* | 2024-07-04 | 2024-08-02 | 深圳市海宇科电子科技有限公司 | Set top box real-time control method and system based on mobile internet |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101169759A (en)* | 2007-11-08 | 2008-04-30 | Ut斯达康通讯有限公司 | Memory management method for application program |
| CN101226549A (en)* | 2008-01-25 | 2008-07-23 | 中兴通讯股份有限公司 | Method and device for loading picture resource in embedded system |
| CN101373445A (en)* | 2008-09-09 | 2009-02-25 | 创新科存储技术(深圳)有限公司 | A memory scheduling method and device |
| US20090320069A1 (en)* | 2001-06-07 | 2009-12-24 | The Directv Group, Inc. | Method and system for electronic program guide temporal content organization |
| CN102446139A (en)* | 2011-11-14 | 2012-05-09 | 奇智软件(北京)有限公司 | Data storage method and device |
| CN103718543A (en)* | 2011-07-27 | 2014-04-09 | 汤姆逊许可公司 | Variable real time buffer and apparatus |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090320069A1 (en)* | 2001-06-07 | 2009-12-24 | The Directv Group, Inc. | Method and system for electronic program guide temporal content organization |
| CN101169759A (en)* | 2007-11-08 | 2008-04-30 | Ut斯达康通讯有限公司 | Memory management method for application program |
| CN101226549A (en)* | 2008-01-25 | 2008-07-23 | 中兴通讯股份有限公司 | Method and device for loading picture resource in embedded system |
| CN101373445A (en)* | 2008-09-09 | 2009-02-25 | 创新科存储技术(深圳)有限公司 | A memory scheduling method and device |
| CN103718543A (en)* | 2011-07-27 | 2014-04-09 | 汤姆逊许可公司 | Variable real time buffer and apparatus |
| CN102446139A (en)* | 2011-11-14 | 2012-05-09 | 奇智软件(北京)有限公司 | Data storage method and device |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118433472A (en)* | 2024-07-04 | 2024-08-02 | 深圳市海宇科电子科技有限公司 | Set top box real-time control method and system based on mobile internet |
| CN118433472B (en)* | 2024-07-04 | 2024-09-03 | 深圳市海宇科电子科技有限公司 | Set top box real-time control method and system based on mobile internet |
| Publication | Publication Date | Title |
|---|---|---|
| US11344806B2 (en) | Method for rendering game, and method, apparatus and device for generating game resource file | |
| CN106021421B (en) | method and device for accelerating webpage rendering | |
| CN105808219B (en) | A kind of memory headroom distribution method and device | |
| US20170235473A1 (en) | Method and Apparatus for Loading Application Program View, and Electronic Terminal | |
| CN106569805B (en) | Canvas storage method, picture drawing method and equipment | |
| KR20200035491A (en) | Reducing latency in map interfaces | |
| US10311060B2 (en) | Glyph management in texture atlases | |
| CN104111913A (en) | Processing method and device of streaming document | |
| CN111460342B (en) | Page rendering display method and device, electronic equipment and computer storage medium | |
| CN108989704B (en) | Image generation method and device and terminal equipment | |
| CN111275777A (en) | Automatic color matching method, device, medium and electronic equipment | |
| CN111931708A (en) | Form generation method and device | |
| CN106610828B (en) | Android system-based GIF animation playing method and device | |
| CN109615668B (en) | Component-based digital image synchronization | |
| CN104602103A (en) | Set top box memory distribution method and device | |
| CN116719496B (en) | Virtual screen implementation method, device, equipment and storage medium | |
| CN111240676A (en) | Method and device for generating code of skeleton screen | |
| CN111199511A (en) | Graph generation method and device and computer readable storage medium | |
| CN105094668A (en) | Message processing method and electronic device | |
| CN115512033A (en) | 3D scene rendering method and device, electronic equipment and storage medium | |
| CN111273913B (en) | Method and device for outputting application program interface data represented by specifications | |
| JP5842029B2 (en) | Information processing support apparatus, information processing apparatus, and information processing support program for caching image data | |
| CN104424661A (en) | Three-dimensional object display method and device | |
| CN113691835A (en) | Video implantation method, device, equipment and computer readable storage medium | |
| CN114281773A (en) | Animation display method and device, electronic equipment and computer readable storage medium |
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication | Application publication date:20150506 | |
| RJ01 | Rejection of invention patent application after publication |