[go: up one dir, main page]

CN112150585B - Animation data encoding, decoding method, device, storage medium and computer equipment - Google Patents

Animation data encoding, decoding method, device, storage medium and computer equipment Download PDF

Info

Publication number
CN112150585B
CN112150585B CN201910502147.3A CN201910502147A CN112150585B CN 112150585 B CN112150585 B CN 112150585B CN 201910502147 A CN201910502147 A CN 201910502147A CN 112150585 B CN112150585 B CN 112150585B
Authority
CN
China
Prior art keywords
attribute
animation
data
value
content
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
CN201910502147.3A
Other languages
Chinese (zh)
Other versions
CN112150585A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910502147.3A priority Critical patent/CN112150585B/en
Publication of CN112150585A publication Critical patent/CN112150585A/en
Application granted granted Critical
Publication of CN112150585B publication Critical patent/CN112150585B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T13/00Animation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The present application relates to an animation data encoding and decoding method, apparatus, storage medium and computer device, the animation data encoding method comprising: obtaining animation data corresponding to each animation tag code from an animation engineering file; when the attribute type does not exist in the attribute structure table corresponding to the animation tag code, coding attribute values corresponding to the attributes in the animation data in sequence according to the data type and the attribute sequence corresponding to the attributes in the attribute structure table to obtain a basic attribute data block corresponding to the animation tag code. The proposal provided by the application can obviously reduce the file size of the animation file.

Description

动画数据编码、解码方法、装置、存储介质和计算机设备Animation data encoding, decoding method, device, storage medium and computer equipment

技术领域Technical Field

本申请涉及计算机技术领域,特别是涉及一种动画数据编码、动画数据解码方法、装置、计算机可读存储介质和计算机设备。The present application relates to the field of computer technology, and in particular to an animation data encoding and decoding method, device, computer-readable storage medium and computer equipment.

背景技术Background Art

为了让视频内容或图片内容更生动有趣,用户会在编辑视频内容或图片内容时添加动画效果,实质上动画效果是根据动画文件来呈现的,一个动画文件也可以称之为一个贴纸。动画效果越复杂,对应的动画文件所包括的动画属性数据也就越多,动画文件的文件大小也就越大。In order to make the video or picture content more vivid and interesting, users will add animation effects when editing the video or picture content. In fact, the animation effect is presented based on the animation file. An animation file can also be called a sticker. The more complex the animation effect, the more animation attribute data the corresponding animation file includes, and the larger the file size of the animation file.

传统方式中动画文件的制作流程是:先通过动画设计师设计出动画工程文件,动画工程文件包括动画特效数据,然后由开发工程师通过原生代码实现各类复杂动画特效。The traditional process of making animation files is: first, an animation designer designs an animation project file, which includes animation special effects data, and then a development engineer implements various complex animation special effects through native code.

然而,上述方式在编码的过程中需要大量额外的标识符字段来标识各个属性的属性状态,导致得到的动画文件体积太大,浪费存储空间。However, the above method requires a large number of additional identifier fields to identify the attribute status of each attribute during the encoding process, resulting in a large size of the obtained animation file and a waste of storage space.

发明内容Summary of the invention

基于此,有必要针对现有技术在编码动画数据的过程中需要大量额外的标识符字段来标识各个属性,导致得到的动画文件体积太大的技术问题,提供一种动画数据编码方法、装置、计算机可读存储介质和计算机设备。Based on this, it is necessary to provide an animation data encoding method, apparatus, computer-readable storage medium and computer device to address the technical problem that in the process of encoding animation data in the prior art, a large number of additional identifier fields are required to identify each attribute, resulting in the resulting animation file being too large.

一种动画数据编码方法,包括:An animation data encoding method, comprising:

从动画工程文件中获取与各动画标签码对应的动画数据;Obtain animation data corresponding to each animation tag code from the animation project file;

当与所述动画标签码对应的属性结构表中存在属性类型时,则When there is an attribute type in the attribute structure table corresponding to the animation tag code,

确定各所述属性对应的属性标识信息;Determine the attribute identification information corresponding to each of the attributes;

按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各所述属性对应的属性内容;According to the attribute identification information, the attribute value corresponding to each attribute in the animation data is encoded to obtain the attribute content corresponding to each attribute;

根据所述属性结构表中各所述属性对应的属性排序,将各所述属性对应的属性标识信息、所述属性内容依次存储,得到所述动画标签码对应的动态属性数据块。According to the attribute sorting corresponding to each of the attributes in the attribute structure table, the attribute identification information and the attribute content corresponding to each of the attributes are stored in sequence to obtain the dynamic attribute data block corresponding to the animation tag code.

一种动画数据编码装置,包括:An animation data encoding device, comprising:

动画数据获取模块,用于从动画工程文件中获取与各动画标签码对应的动画数据;Animation data acquisition module, used to acquire animation data corresponding to each animation tag code from the animation project file;

属性标识信息确定模块,用于当与所述动画标签码对应的属性结构表中存在属性类型时,则确定各所述属性对应的属性标识信息;An attribute identification information determination module, used for determining the attribute identification information corresponding to each attribute when an attribute type exists in the attribute structure table corresponding to the animation tag code;

属性内容编码模块,用于按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各所述属性对应的属性内容;An attribute content encoding module, used for encoding the attribute value corresponding to each attribute in the animation data according to the attribute identification information, to obtain the attribute content corresponding to each attribute;

数据块生成模块,用于根据所述属性结构表中各所述属性对应的属性排序,将各所述属性对应的属性标识信息、所述属性内容依次存储,得到所述动画标签码对应的动态属性数据块。The data block generation module is used to sort the attributes corresponding to each attribute in the attribute structure table, store the attribute identification information and the attribute content corresponding to each attribute in sequence, and obtain the dynamic attribute data block corresponding to the animation tag code.

一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时,使得所述处理器执行上述动画数据编码方法的步骤。A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above-mentioned animation data encoding method.

一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行上述动画数据编码方法的步骤。A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned animation data encoding method.

上述动画数据编码方法、装置、计算机可读存储介质和计算机设备中,动画标签码可用于标识一组属性,属性结构表用于描述动画标签码所标识的一组属性的数据结构,当这一组属性的属性值从种类或数量都不确定,或者当属性的属性值存在大量冗余时,为了避免额外引入大量的用于描述属性种类或数量的标识符字段导致动画文件体积太大的问题,引入了动态属性数据块的数据结构,可以最大化压缩这些标识符,大大减小目标动画文件占用的体积。具体地,在获取到动画工程文件后,按照动画标签码对应的属性结构表所包括的一组属性,从动画工程文件中获取这一组属性的属性值,动态属性数据块中的属性标识信息用于描述属性的属性状态,当属性结构表中存在属性类型时,可以根据动画数据确定各个属性对应的属性标识信息,再按照属性标识信息对各属性对应的属性值进行动态编码得到对应的属性内容,结合属性结构表中各属性的属性标识信息和属性内容得到动画标签码对应的动态属性数据块,可以显著减少动画文件占用的空间。In the above-mentioned animation data encoding method, device, computer-readable storage medium and computer equipment, the animation tag code can be used to identify a group of attributes, and the attribute structure table is used to describe the data structure of a group of attributes identified by the animation tag code. When the attribute values of this group of attributes are uncertain in terms of type or quantity, or when there is a large amount of redundancy in the attribute values of the attributes, in order to avoid the problem of introducing a large number of identifier fields for describing the type or quantity of the attributes, which leads to a large volume of the animation file, a data structure of a dynamic attribute data block is introduced, which can maximize the compression of these identifiers and greatly reduce the volume occupied by the target animation file. Specifically, after obtaining the animation project file, according to a group of attributes included in the attribute structure table corresponding to the animation tag code, the attribute values of this group of attributes are obtained from the animation project file, and the attribute identification information in the dynamic attribute data block is used to describe the attribute state of the attribute. When there is an attribute type in the attribute structure table, the attribute identification information corresponding to each attribute can be determined according to the animation data, and then the attribute values corresponding to each attribute can be dynamically encoded according to the attribute identification information to obtain the corresponding attribute content, and the dynamic attribute data block corresponding to the animation tag code is obtained by combining the attribute identification information and the attribute content of each attribute in the attribute structure table, which can significantly reduce the space occupied by the animation file.

一种动画数据解码方法,包括:An animation data decoding method, comprising:

获取动画标签码;Get the animation tag code;

当与所述动画标签码对应的属性结构表中存在属性类型时,则When there is an attribute type in the attribute structure table corresponding to the animation tag code,

根据所述属性结构表中各属性对应的属性类型,从所述动画标签码对应的动态属性数据块中解析各所述属性对应的属性标识信息;According to the attribute type corresponding to each attribute in the attribute structure table, parsing the attribute identification information corresponding to each attribute from the dynamic attribute data block corresponding to the animation tag code;

根据各所述属性对应的属性标识信息从所述动态属性数据块中解析各所述属性对应的属性内容。The attribute content corresponding to each of the attributes is parsed from the dynamic attribute data block according to the attribute identification information corresponding to each of the attributes.

一种动画数据解码装置,所述装置包括:An animation data decoding device, the device comprising:

获取模块,用于获取动画标签码;Acquisition module, used to obtain animation tag code;

属性标识信息解析模块,用于当与所述动画标签码对应的属性结构表中存在属性类型时,则根据所述属性结构表中各属性对应的属性类型,从所述动画标签码对应的动态属性数据块中解析各所述属性对应的属性标识信息;An attribute identification information parsing module, for parsing attribute identification information corresponding to each attribute from the dynamic attribute data block corresponding to the animation tag code according to the attribute type corresponding to each attribute in the attribute structure table when there is an attribute type in the attribute structure table corresponding to the animation tag code;

属性内容解析模块,用于根据各所述属性对应的属性标识信息从所述动态属性数据块中解析各所述属性对应的属性内容。The attribute content parsing module is used to parse the attribute content corresponding to each attribute from the dynamic attribute data block according to the attribute identification information corresponding to each attribute.

一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时,使得所述处理器执行上述动画数据解码方法的步骤。A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above-mentioned animation data decoding method.

一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行上述动画数据解码方法的步骤。A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above animation data decoding method.

上述动画数据解码方法、装置、计算机可读存储介质和计算机设备中,动画标签码可用于标识一组属性,属性结构表用于描述动画标签码所标识的一组属性的数据结构,当这一组属性的属性值从种类或数量都不确定,或者当属性的属性值存在大量冗余时,为了避免额外引入大量的用于描述属性种类或数量的标识符字段导致动画文件体积太大的问题,引入了动态属性数据块的数据结构,可以最大化压缩这些标识符,大大减小目标动画文件占用的体积。具体地,在解码时,读取到动画标签码后,当该动画标签码对应的属性结构表中存在属性类型时,说明该动画标签码所标识的一组属性的属性值是以动态属性数据块的形式编码的,可以结合各属性对应的属性类型从动画标签码对应的动态属性数据块中解析各属性对应的属性标识信息,再基于该属性标识信息可以从动态属性数据块中解析各所述属性对应的属性内容,实现动画文件的解码。In the above-mentioned animation data decoding method, device, computer-readable storage medium and computer equipment, the animation tag code can be used to identify a group of attributes, and the attribute structure table is used to describe the data structure of the group of attributes identified by the animation tag code. When the attribute values of this group of attributes are uncertain in terms of type or quantity, or when there is a large amount of redundancy in the attribute values of the attributes, in order to avoid the problem of too large animation file size caused by the additional introduction of a large number of identifier fields for describing the type or quantity of the attributes, a data structure of a dynamic attribute data block is introduced, which can maximize the compression of these identifiers and greatly reduce the volume occupied by the target animation file. Specifically, during decoding, after reading the animation tag code, when the attribute type exists in the attribute structure table corresponding to the animation tag code, it means that the attribute values of the group of attributes identified by the animation tag code are encoded in the form of a dynamic attribute data block, and the attribute identification information corresponding to each attribute can be parsed from the dynamic attribute data block corresponding to the animation tag code in combination with the attribute type corresponding to each attribute, and then based on the attribute identification information, the attribute content corresponding to each of the attributes can be parsed from the dynamic attribute data block to achieve decoding of the animation file.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为一个实施例中动画数据编码方法的应用环境图;FIG1 is a diagram showing an application environment of an animation data encoding method according to an embodiment;

图2为一个实施例中在采集视频时在视频内容中添加动画贴纸的示意图;FIG. 2 is a schematic diagram of adding animated stickers to video content when capturing a video in one embodiment;

图3为一个48比特位的数据流的示意图;FIG3 is a schematic diagram of a 48-bit data stream;

图4为一个实施例中连续无符号整数类型的数据的编码结构示意图;FIG4 is a schematic diagram of an encoding structure of data of a continuous unsigned integer type in one embodiment;

图5为一个实施例中路径信息的编码结构示意图;FIG5 is a schematic diagram of a coding structure of path information in one embodiment;

图6为一个实施例中PAG文件的文件组织结构示意图;FIG6 is a schematic diagram of the file organization structure of a PAG file in one embodiment;

图7为一个实施例中节点元素的节点元素组织结构示意图;FIG7 is a schematic diagram of a node element organization structure of a node element in one embodiment;

图8为一个实施例中动画数据编码方法的流程示意图;FIG8 is a schematic diagram of a flow chart of an animation data encoding method in one embodiment;

图9为一个实施例中遮罩信息对应的属性结构表和动态属性数据块的结构示意图;FIG9 is a schematic diagram of the structure of an attribute structure table and a dynamic attribute data block corresponding to mask information in one embodiment;

图10为一个实施例中时间缓动参数数组的编码结构示意图;FIG10 is a schematic diagram of the encoding structure of a time easing parameter array in one embodiment;

图11为一个实施例中空间缓动参数数组的编码结构示意图;FIG11 is a schematic diagram of the encoding structure of a spatial easing parameter array in one embodiment;

图12为一个实施例中位图序列帧编码方式对应的动画数据的编码结构图;FIG12 is a diagram showing the coding structure of animation data corresponding to a bitmap sequence frame coding method in one embodiment;

图13为一个实施例中视频序列帧编码方式对应的动画数据的编码结构图;FIG13 is a diagram showing the coding structure of animation data corresponding to a video sequence frame coding method in one embodiment;

图14为一个实施例中动画数据解码方法的流程示意图;FIG14 is a schematic flow chart of a method for decoding animation data in one embodiment;

图15为一个实施例中矢量导出方式所对应的文件数据结构;FIG15 is a file data structure corresponding to a vector export method in one embodiment;

图16为一个实施例中动画数据编码装置的结构框图;FIG16 is a block diagram of a structure of an animation data encoding device in one embodiment;

图17为一个实施例中动画数据解码装置的结构框图;FIG17 is a block diagram of a structure of an animation data decoding device in one embodiment;

图18为一个实施例中计算机设备的结构框图。FIG. 18 is a block diagram of a computer device in one embodiment.

具体实施方式DETAILED DESCRIPTION

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

以下对本申请涉及的部分名词进行介绍:The following is an introduction to some of the terms involved in this application:

AE:Adobe After Effects的简称,Adobe After Effects是一种图形视频处理软件,可用于设计复杂的视频特效。设计师通过该软件设计出复杂的动画效果,得到的动画文件为AE工程文件(文件后缀名为aep),后文中也称之为动画工程文件。AE工程文件用于存储合成(Composition)以及该合成中所使用的全部源文件、动画特性参数,合成是图层(Layer)的集合。AE: Short for Adobe After Effects, Adobe After Effects is a graphics and video processing software that can be used to design complex video effects. Designers use this software to design complex animation effects, and the resulting animation files are AE project files (file suffix aep), which are also referred to as animation project files in the following text. AE project files are used to store compositions and all source files and animation feature parameters used in the compositions. Compositions are a collection of layers.

PAG:Portable Animated Graphics的简称,是本申请提出的一种自研二进制动画文件格式。PAG文件可作为一种动画效果附着在视频中,称之为动画贴纸。PAG: Portable Animated Graphics, a self-developed binary animation file format proposed by this application. PAG files can be attached to videos as an animation effect, called animation stickers.

PAGExporter:一种为PAG文件自研的动画导出插件,可用于读取AE工程文件中的动画特效数据,将读取的动画特效数据以矢量导出方式、位图序列帧导出方式或视频序列帧导出方式中任意一种方式导出,得到PAG文件。PAGExpoter可作为AE软件的插件加载后实现将AE工程文件导出得到PAG文件。PAGExporter: A self-developed animation export plug-in for PAG files, which can be used to read the animation special effects data in the AE project file, and export the read animation special effects data in any of the vector export mode, bitmap sequence frame export mode or video sequence frame export mode to obtain a PAG file. PAGExpoter can be loaded as a plug-in of the AE software to export the AE project file to a PAG file.

PAGViewer:一种为预览PAG文件自研的动画预览软件,可用于预览PAG文件以及向PAG文件写入性能参数,以便该PAG文件上传到服务器时,可以根据性能参数对该PAG文件进行校验。PAGViewer: A self-developed animation preview software for previewing PAG files. It can be used to preview PAG files and write performance parameters to PAG files so that when the PAG file is uploaded to the server, the PAG file can be verified according to the performance parameters.

图1为一个实施例中动画数据编码方法的应用环境图。参照图1,该动画数据编码方法应用于终端110。FIG1 is a diagram showing an application environment of an animation data encoding method in an embodiment. Referring to FIG1 , the animation data encoding method is applied to a terminal 110 .

终端110上安装和运行有支持图形视频处理的软件,通过该软件生成动画工程文件,该软件比如可以是AE软件。终端110上还安装有动画导出插件,动画导出插件比如可以是PAGExporter。当终端110运行该软件打开动画工程文件时,终端可通过动画导出插件读取动画工程文件的动画数据,并加载动画导出插件对该动画数据进行编码,得到目标动画文件,目标动画文件比如可以是PAG文件。终端110具体可以是台式终端或移动终端,移动终端具体可以手机、平板电脑、笔记本电脑等中的至少一种。The terminal 110 is installed and running with software that supports graphics and video processing, and an animation project file is generated by the software. The software may be, for example, AE software. The terminal 110 is also installed with an animation export plug-in, and the animation export plug-in may be, for example, PAGExporter. When the terminal 110 runs the software to open an animation project file, the terminal may read the animation data of the animation project file through the animation export plug-in, and load the animation export plug-in to encode the animation data to obtain a target animation file, and the target animation file may be, for example, a PAG file. The terminal 110 may specifically be a desktop terminal or a mobile terminal, and the mobile terminal may specifically be at least one of a mobile phone, a tablet computer, a laptop computer, and the like.

在一个实施例中,终端110上运行的PAGExporter对动画工程文件中的动画数据进行处理,导出得到PAG文件,通过PAGViewer在播放PAG文件的过程中,统计该PAG文件的性能参数,并将计算得到的性能参数写入该PAG文件,最后还可以通过校验服务器对PAG文件所携带的性能参数进行校验,校验成功的PAG文件可发布至网络,经用户下载后播放。PAG文件可以所呈现的动画效果可以作为动画贴纸附着于视频上,如图2所示,为一个实施例中在采集视频时在视频内容中添加动画贴纸202的示意图。In one embodiment, the PAGExporter running on the terminal 110 processes the animation data in the animation project file and exports it to obtain a PAG file. In the process of playing the PAG file, the performance parameters of the PAG file are counted through PAGViewer, and the calculated performance parameters are written into the PAG file. Finally, the performance parameters carried by the PAG file can be verified by the verification server. The PAG file that has been successfully verified can be published to the network and played after being downloaded by the user. The animation effect presented by the PAG file can be attached to the video as an animation sticker, as shown in Figure 2, which is a schematic diagram of adding an animation sticker 202 to the video content when capturing the video in one embodiment.

下面介绍二进制动画文件格式即PAG文件用到的基础数据类型,数据类型描述了数据保存在文件中的编排格式。The following introduces the basic data types used in the binary animation file format, namely PAG files. The data types describe the format in which the data is saved in the file.

在编码动画数据得到PAG文件时,所采用的基础数据类型包括整数类型、布尔类型、浮点数类型、数组类型、比特类型、时间类型、字符串类型,这些数据类型的数据长度通常是不变的,也叫做定长数据类型。When encoding animation data to obtain a PAG file, the basic data types used include integer type, Boolean type, floating point type, array type, bit type, time type, and string type. The data length of these data types is usually constant, and they are also called fixed-length data types.

基础数据类型还包括根据这些数据类型进行排列组合自定义的新的数据结构,作为一种新的数据类型,可以称之为组合类型,这些组合类型可用于描述动画数据,包括可变长度编码整数类型、坐标类型、比率类型、颜色类型、字体类型、透明度变化信息类型、颜色变化信息类型、文本类型、路径类型、字节流类型、位图信息类型和视频帧信息类型。The basic data types also include new data structures that are customized based on the arrangement and combination of these data types. As a new data type, it can be called a combination type. These combination types can be used to describe animation data, including variable-length coded integer types, coordinate types, ratio types, color types, font types, transparency change information types, color change information types, text types, path types, byte stream types, bitmap information types, and video frame information types.

下面对上述基础数据类型进行详细介绍:The following is a detailed description of the above basic data types:

一、整数类型1. Integer Type

所有的整数数值都以二进制的形式存储在PAG文件中。从上表可以看出,整数类型的数据可以按照有符号和无符号的8位、16位、32位、64位进行存储。PAG格式中数据的存储方式可以采用“小端字节序”(little endian)进行存储,即低位字节数据存储在内存低地址处,高位字节数据存储在内存高位地址处。整数类型的数据是需要进行字节对齐的数据类型,也就说,一个整数值的第1位(bit)的值被存储在PAG文件中某个字节的第1位处。All integer values are stored in binary form in the PAG file. As can be seen from the table above, integer data can be stored in signed and unsigned 8-bit, 16-bit, 32-bit, and 64-bit formats. Data in the PAG format can be stored in "little endian" format, that is, low-order byte data is stored at the low address of the memory, and high-order byte data is stored at the high address of the memory. Integer data is a data type that requires byte alignment, that is, the value of the first bit of an integer value is stored at the first bit of a byte in the PAG file.

二、布尔类型2. Boolean Type

数据类型Data Types 备注Remark BoolBool 0代表false;1代表true0 represents false; 1 represents true

参照上表,在PAG文件中,布尔类型的数据用一个比特位来表示。相比于用一个字节来表示而言,能够节省存储空间。布尔类型是不需要进行字节对齐的数据类型。Referring to the table above, in the PAG file, Boolean data is represented by one bit. Compared with one byte, it can save storage space. Boolean data types do not require byte alignment.

三、浮点数类型3. Floating point types

数据类型Data Types 备注Remark FloatFloat 单精度32位Single precision 32 bits

在PAG文件中,小数的数据类型采用单精度浮点数类型表示。In the PAG file, the data type of decimals is represented by a single-precision floating-point type.

四、数组类型4. Array Types

对于连续存储的相同数据类型的数据,可以在数据类型后面加[n]符号来表示这一组数据,其中n表示数组长度。例如,Uint8[10]表示Uint8类型的一维数组,长度为10。又比如,Int8[n][m]是一个二维数组,其中m表示数组长度,代表有m个数据类型为Int8[n]的数据。For data of the same data type stored continuously, you can add the [n] symbol after the data type to represent this group of data, where n represents the length of the array. For example, Uint8[10] represents a one-dimensional array of type Uint8 with a length of 10. For another example, Int8[n][m] is a two-dimensional array, where m represents the length of the array, indicating that there are m data of the data type Int8[n].

五、比特类型5. Bit Type

与占用固定位数的数据类型不一样,比特类型是一种可变长的数据类型,可用于表示有符号整数和无符号整数这两种数据。比如SB[5]可用于表示占用5位的有符号整数的数据类型,UB[2]可用于表示占用2位的无符号整数的数据类型。SB是Signed Bits的缩写,UB是Unsigned Bits的缩写。Unlike data types that occupy a fixed number of bits, bit types are variable-length data types that can be used to represent both signed and unsigned integer data. For example, SB[5] can be used to represent a 5-bit signed integer data type, and UB[2] can be used to represent a 2-bit unsigned integer data type. SB is the abbreviation for Signed Bits, and UB is the abbreviation for Unsigned Bits.

与需要进行字节对齐的数据类型(比如Int8、Uint16)不同,比特类型的数据不需要进行字节对齐。具体地,当一个需要进行字节对齐的数据类型的数据被编码在比特类型的数据后面时,那么在比特类型的最后一个字节(Byte)需要进行字节对齐,也就是最后一个字节中除了比特类型的数据多出的位需要用零补位以进行字节对齐。Unlike data types that require byte alignment (such as Int8 and Uint16), bit type data does not require byte alignment. Specifically, when data of a data type that requires byte alignment is encoded after bit type data, the last byte of the bit type needs to be byte aligned, that is, the extra bits in the last byte except for the bit type data need to be padded with zeros for byte alignment.

参照图3,以一个48位(6个字节)的二进制数据流来举例说明,该二进制数据流包括6个不同位长的数值,前面5个数值是比特类型的,最后1个数值是Uint16类型的,每一格代表一个字节。比特流的第一个数值(010110)占用6位,第二个数值(10100)占用5位,该数值跨越了第1个字节和第2个字节。第三个数值(100100)占用6位,第三个数值也跨越了两个字节,第四个数值(1011)占用4位,这个数值的位全部属于第3个字节。第五个数值(1101001)占用7位,在第五个数值之后的第六个数值是一个字节对齐的数值(0100110010101101),所以第五个数值所占用的字节(第4个字节)内的其余4位用零补齐。Referring to Fig. 3, a 48-bit (6-byte) binary data stream is used as an example. The binary data stream includes 6 values of different bit lengths. The first 5 values are of bit type, and the last value is of Uint16 type, and each grid represents a byte. The first value (010110) of the bit stream occupies 6 bits, and the second value (10100) occupies 5 bits, which spans the first byte and the second byte. The third value (100100) occupies 6 bits, and the third value also spans two bytes. The fourth value (1011) occupies 4 bits, and all the bits of this value belong to the third byte. The fifth value (1101001) occupies 7 bits, and the sixth value after the fifth value is a byte-aligned value (0100110010101101), so the remaining 4 bits in the byte (the fourth byte) occupied by the fifth value are padded with zeros.

为了能够尽量的压缩PAG文件占用的空间,针对一组相同类型的连续数据,还可以采用连续数据编码方法来进行编码。具体地,在这一组相同类型的连续数据的前面添加头部区域,头部区域中的数值用于表示这一组相同类型的连续数据所占用的位数nBits,也就是说,在该头部区域后的这一组相同类型的连续数据均按照该位数存储。具体nBits的值是多少,是根据这一组数据中的最大值来确定的,对于这一组数据中其它的较小数据,采用高位补零的方式进行编码。In order to compress the space occupied by the PAG file as much as possible, a continuous data encoding method can be used to encode a group of continuous data of the same type. Specifically, a header area is added in front of this group of continuous data of the same type. The value in the header area is used to represent the number of bits nBits occupied by this group of continuous data of the same type. In other words, the group of continuous data of the same type after the header area is stored according to this number of bits. The specific value of nBits is determined based on the maximum value in this group of data. For other smaller data in this group of data, the high-bit zero padding method is used for encoding.

如图4所示,为对连续无符号整数类型的数据进行编码的编码结构示意图,参照图4,头部区域存储这一组整数类型的连续数据中每一个数据所占用的比特位数nBits,后面紧接着采用UB[nBits]类型对这一组整数类型的连续数据进行编码,以连续的32位无符号整数的存储为例,头部区域最多占用5个比特位,用于存储nBits。As shown in Figure 4, it is a schematic diagram of the encoding structure for encoding continuous unsigned integer type data. Referring to Figure 4, the header area stores the number of bits nBits occupied by each data in this group of continuous data of integer type, followed by the use of UB[nBits] type to encode this group of continuous data of integer type. Taking the storage of continuous 32-bit unsigned integers as an example, the header area occupies a maximum of 5 bits for storing nBits.

比如,一组16位无符号整数:50、100、200、300、350、400,若按照Uint16的数据类型来进行编码,则每个数值分别占用16位,这一组数值一共需要占用96位。若按照连续数据编码方法进行编码,则根据最大值400确定每个数据均占用10位,所以按照UB[10]进行编码,并且在这一组数据的前面添加一个UB[4]类型的头部区域,用于存储“10”这个值,也就是说头部区域占用4位,头部区域后紧接着的这一组连续数据占用60位,那么这一组数据仅占用64位,相比于传统方式,可以少占用32位(4个字节)。For example, a group of 16-bit unsigned integers: 50, 100, 200, 300, 350, 400, if encoded according to the Uint16 data type, each value occupies 16 bits, and this group of values occupies a total of 96 bits. If encoded according to the continuous data encoding method, each data occupies 10 bits according to the maximum value 400, so it is encoded according to UB[10], and a UB[4] type header area is added in front of this group of data to store the value "10", that is, the header area occupies 4 bits, and the group of continuous data following the header area occupies 60 bits, so this group of data only occupies 64 bits, which can occupy 32 bits (4 bytes) less than the traditional method.

需要说明的是,连续的有符号整数的编码与无符号整数的编码方式一致,区别是无符号整数读取出头部区域后的数据全部都表示数值内容,而有符号整型读取出的头部区域后的第1位表示符号位(0正数,1负数),接下来的连续的nBits-1位表示数值内容。对于连续的浮点数据,也可以采用上述连续数据编码方式进行编码。It should be noted that the encoding of continuous signed integers is the same as that of unsigned integers. The difference is that the data after the header area of the unsigned integer is all numerical content, while the first bit after the header area of the signed integer represents the sign bit (0 for positive numbers, 1 for negative numbers), and the next continuous nBits-1 bits represent the numerical content. For continuous floating-point data, the above continuous data encoding method can also be used for encoding.

进一步地,对于一些允许精度损失的连续浮点数据,还可以转换为整型数据后再按照上述连续整数类型的方式进行编码。具体地,对于表示空间上的点的坐标数据,比如空间缓动参数是浮点类型的,可以将该浮点数据除以空间精度系数(SPATIAL_PRECISION=0.05)后转换为整数;对于表示贝塞尔曲线缓动参数的坐标数据,可以将该浮点数据除以贝塞尔精度系数(BEZIER_PRECISION=0.005)后转换为整数再编码;对于表示渐变信息的坐标数据,可以将该浮点数据除以渐变精度系数(GRADIENT_PRECISION=0.00002)后转换为整数再编码。Furthermore, for some continuous floating-point data that allow loss of precision, they can be converted into integer data and then encoded in the above-mentioned continuous integer type. Specifically, for coordinate data representing points in space, such as spatial easing parameters that are of floating-point type, the floating-point data can be divided by the spatial precision coefficient (SPATIAL_PRECISION=0.05) and converted into an integer; for coordinate data representing Bezier curve easing parameters, the floating-point data can be divided by the Bezier precision coefficient (BEZIER_PRECISION=0.005) and converted into an integer and then encoded; for coordinate data representing gradient information, the floating-point data can be divided by the gradient precision coefficient (GRADIENT_PRECISION=0.00002) and converted into an integer and then encoded.

六、时间类型6. Time Type

PAG文件内属于时间类型(Time)的数据统一使用Int64来描述,时间类型可以用表示帧序号,每一帧的帧序号除以帧率可以转换为以秒为单位的外部时间。The data of time type (Time) in the PAG file is uniformly described using Int64. The time type can be used to represent the frame number. The frame number of each frame divided by the frame rate can be converted into the external time in seconds.

七、字符串类型7. String Type

在PAG文件中,属于字符串类型(String)的数据使用null字符来标识字符串的结束。In the PAG file, the data of the string type (String) uses the null character to mark the end of the string.

八、可变长度编码整数类型8. Variable-length encoded integer types

数据类型Data Types 备注Remark EncodedInt32EncodedInt32 可变长度编码的32位整数Variable-length encoded 32-bit integer EncodedUint32EncodedUint32 可变长度编码的32位无符号整数Variable-length encoded 32-bit unsigned integer EncodedInt64EncodedInt64 可变长度编码的64位整数Variable-length encoded 64-bit integer EncodedUint64EncodedUint64 可变长度编码的64位无符号整数Variable-length encoded 64-bit unsigned integer

可变长度编码整数类型是以字节作为最小储存单位来表示一个整数,整数值最小占用一个字节,最多占用4个字节或8个字节。在编码可变长度编码整数类型的数值时,以字节的前7位表示该数值,第8位用于标识后面是否还有数值,第8位为0,表示下个字节不属于该数值的内容,第8位为1,表示下个字节还属于该数值的内容。因此,在解码时,如果每个字节的第8位是0,表示数值已经读完,如果第8位是1,表示数值还未读取完,需要再向下读取一个字节,直到把长度都读完为止(32位或64位)。有符号位的可变长度编码整数类型,则是先读取无符号编码整数类型的值,再来判断符号位。The variable-length coded integer type uses bytes as the minimum storage unit to represent an integer. The integer value occupies a minimum of one byte and a maximum of 4 bytes or 8 bytes. When encoding the value of the variable-length coded integer type, the first 7 bits of the byte represent the value, and the 8th bit is used to indicate whether there is a value behind it. The 8th bit is 0, indicating that the next byte does not belong to the content of the value, and the 8th bit is 1, indicating that the next byte still belongs to the content of the value. Therefore, when decoding, if the 8th bit of each byte is 0, it means that the value has been read. If the 8th bit is 1, it means that the value has not been read. It is necessary to read one more byte until the length is read (32 bits or 64 bits). For the variable-length coded integer type with a signed bit, the value of the unsigned coded integer type is read first, and then the sign bit is determined.

比如,若数据值14的数据类型为EncodedInt32,则对应的二进制为:0011100,相比于数据类型为Int32少占用的24位。For example, if the data type of the data value 14 is EncodedInt32, the corresponding binary is: 0011100, which occupies 24 bits less than the data type Int32.

九、坐标类型9. Coordinate Type

字段Fields 字段类型Field Type 备注Remark xx FloatFloat X轴坐标X-axis coordinate yy FloatFloat Y轴坐标Y-axis coordinate

坐标类型(Point)用于表示一个位置的坐标,也就是x轴,y轴的值。当编码属于坐标类型的数值时,先用32位编码的x的值,再用32位编码y的值。The coordinate type (Point) is used to represent the coordinates of a location, that is, the values of the x-axis and y-axis. When encoding a value belonging to the coordinate type, first use 32 bits to encode the x value, and then use 32 bits to encode the y value.

十、比率类型10. Ratio Type

比率类型(Ratio)用于表示一个比率。当编码属于比率类型的数值时,先编码占用可变长度比特位的分子的值,再编码占用可变长度比特位的分母值。The ratio type (Ratio) is used to represent a ratio. When encoding a value belonging to the ratio type, the value of the numerator that occupies a variable length of bits is encoded first, and then the value of the denominator that occupies a variable length of bits is encoded.

十一、颜色类型11. Color Type

字段Fields 字段类型Field Type 备注Remark RedRed Uint8Uint8 红色值(0至255)Red value (0 to 255) GreenGreen Uint8Uint8 绿色值(0至255)Green value (0 to 255) BlueBlue Uint8Uint8 蓝色值(0至255)Blue value (0 to 255)

颜色类型(Color)用于表示一种颜色值,一种颜色值通常由红色、绿色和蓝色三种颜色组成。当编码属于颜色类型的数值时,先用一个字节编码红色值,接下来的第二个字节编码绿色值,第三个字节编码蓝色值,每种颜色值的数据类型为Uint8。The color type (Color) is used to represent a color value, which is usually composed of three colors: red, green, and blue. When encoding a value belonging to the color type, first use one byte to encode the red value, the second byte to encode the green value, and the third byte to encode the blue value. The data type of each color value is Uint8.

十二、字体类型12. Font Type

字段Fields 字段类型Field Type 备注Remark idid EncodedUint32EncodedUint32 唯一标识Unique ID fontFamilyfontFamily StringString 字体家族系列Font Family fontStylefontStyle StringString 字体样式Font Style

字体类型(FontData)用于标识字体。当编码属于字体类型的数值时,先编码可变长的字体标识,再分别采用String的数据类型编码字体所属的字体家族系列和字体样式,字体家族系列和字体样式分别占用的位数根据字符长度确定。fontFamily表示字体的名称,可以是一个字体的名称,也可以是一类字体的名称。fontStyle用于定义字体的倾斜程度,包括斜体、倾斜或正常字体。The font type (FontData) is used to identify the font. When encoding a numerical value belonging to the font type, first encode the variable-length font identifier, and then use the String data type to encode the font family series and font style to which the font belongs. The number of bits occupied by the font family series and font style is determined by the character length. fontFamily represents the name of the font, which can be the name of a font or the name of a type of font. fontStyle is used to define the degree of inclination of the font, including italic, tilted or normal font.

十三、透明度变化信息类型13. Transparency Change Information Type

透明度变化信息类型(AlphaStop)用于描述透明度的渐变信息。The transparency change information type (AlphaStop) is used to describe the gradual change information of transparency.

浮点数类型需要根据精度编码为Unit16的类型再存储,在解码时就需要将读取的Unit16的数值乘以精度得到浮点数。精度比如为0.00002f。The floating point type needs to be encoded as Unit16 type according to the precision and then stored. When decoding, the value of Unit16 read needs to be multiplied by the precision to get the floating point number. For example, the precision is 0.00002f.

十四、颜色变化信息类型14. Color change information type

字段Fields 字段类型Field Type 备注Remark positionposition Uint16Uint16 开始点位置Starting point location midpointmidpoint Uint16Uint16 中间点位置Midpoint colorcolor ColorColor 颜色值Color Value

颜色变化信息类型(ColorStop)用于描述颜色的渐变信息。The color change information type (ColorStop) is used to describe the color gradient information.

十五、颜色梯度变化信息类型15. Color gradient change information type

字段Fields 字段类型Field Type 备注Remark alphaCountalphaCount EncodedUint32EncodedUint32 透明度渐变信息数组长度Transparency gradient information array length colorCountcolorCount EncodedUint32EncodedUint32 颜色渐变信息数组长度Color gradient information array length alphaStopListalphaStopList AlphaStop[alphaCount]AlphaStop[alphaCount] 连续alphaCount个AlphaStopConsecutive alphaCount AlphaStops colorStopListcolorStopList ColorStop[colorCount]ColorStop[colorCount] 连续colorCount个ColorStopConsecutive colorCount ColorStops

颜色梯度变化信息类型(GradientColor),是将透明度变化信息类型和颜色变化信息类型进行组合,得到表示颜色梯度变化信息的数据类型。一个alphaStopList(透明度变化信息列表)包括多个透明度变化信息,一个透明度变化信息包括:开始点位置、中间点位置以及透明度值。一个colorStopList(颜色变化信息列表)包括多个颜色变化信息,一个颜色变化信息包括:开始点位置、中间点位置以及颜色值。The color gradient change information type (GradientColor) is a data type that combines the transparency change information type and the color change information type to obtain the color gradient change information. An alphaStopList (transparency change information list) includes multiple transparency change information, and one transparency change information includes: the starting point position, the middle point position and the transparency value. A colorStopList (color change information list) includes multiple color change information, and one color change information includes: the starting point position, the middle point position and the color value.

在编码属于颜色梯度变化信息类型的数据时,先用可变长度编码整数类型EncodedUint32依次对alphaCount、colorCount进行编码,然后依次按照透明度变化信息类型所占用的位数对透明度变化信息列表中的每个透明度变化信息进行编码,再依次按照颜色变化信息类型所占用的位数对颜色变化信息列表中每个颜色变化信息进行编码。When encoding data belonging to the color gradient change information type, first use the variable length coded integer type EncodedUint32 to encode alphaCount and colorCount in sequence, and then encode each transparency change information in the transparency change information list according to the number of bits occupied by the transparency change information type, and then encode each color change information in the color change information list according to the number of bits occupied by the color change information type.

十六、文本类型16. Text Type

文本类型(Text)用于描述文本信息,包括文本、字体、大小、颜色等文本信息。由于不同的图层中文本信息所包括的种类和数量都不确定,因此,在编码时用标识位来标识这些数据是否存在,并且每一个标识位都采用仅占用一位的比特类型来表示,能够节约存储空间。从上表可以看出,文本类型中一共包括19个标识位,占用3个字节,在编码时这3个字节的最后一个字节用零补齐。在编码文本类型的数据时,若某个标识位的值为0,则代表该标识位对应的文本信息不存在,则直接编码下一个值为1的标识位所对应的文本信息即可,那么在解码时,读取的下一个字节的数据也就是下一个值为1的标识位所对应的文本信息。The text type (Text) is used to describe text information, including text, font, size, color and other text information. Since the types and quantities of text information in different layers are uncertain, the identification bit is used to identify whether this data exists during encoding, and each identification bit is represented by a bit type that only occupies one bit, which can save storage space. As can be seen from the above table, the text type includes a total of 19 identification bits, occupying 3 bytes. The last byte of these 3 bytes is padded with zeros during encoding. When encoding text type data, if the value of a certain identification bit is 0, it means that the text information corresponding to the identification bit does not exist, then the text information corresponding to the next identification bit with a value of 1 can be directly encoded. Then, when decoding, the next byte of data read is the text information corresponding to the next identification bit with a value of 1.

十七、路径类型17. Path Type

路径类型(Path)用于表示描述一个形状的绘制路径信息,路径信息由一组动作确定。在PAG文件中,通常包括8个动作:The path type (Path) is used to represent the drawing path information that describes a shape. The path information is determined by a set of actions. In a PAG file, it usually includes 8 actions:

在编码路径信息时,首先需要根据路径绘制信息中所有动作的数量确定numVerbs以及根据每个动作确定相应的动作值,还需要根据每个动作的坐标数据确定需要编码floatNum个float类型的值,在编码之前还需要将这floatNum个float类型的值先乘以SPATIAL_PRECISION以将浮点数转换为整数类型,再计算这floatNum个float类型的值中的最大值,根据最大值所占用的位数得到numBits,由于floatlist里面每个值占用位最多不超过31位,即numBits≤31,因此需要按照UB[5]对numBits进行编码,再将每个float类型的值按照UB[numBits]进行编码。When encoding path information, first you need to determine numVerbs based on the number of all actions in the path drawing information and the corresponding action value for each action. You also need to determine the floatNum float type values that need to be encoded based on the coordinate data of each action. Before encoding, you need to multiply these floatNum float type values by SPATIAL_PRECISION to convert the floating point number to an integer type, and then calculate the maximum value of these floatNum float type values. Get numBits based on the number of bits occupied by the maximum value. Since each value in floatlist occupies no more than 31 bits, that is, numBits≤31, you need to encode numBits according to UB[5], and then encode each float type value according to UB[numBits].

例如,绘制一个(x:5,y:0,r:15,b:20)的矩形,用路径类型(Path)的数据结构描述如下:执行Move动作到(5,0)点,需要记录下动作“1”以及两个Float值(5,0),再执行HLine到(15,0)点,需要记录动作“3”以及一个Float值(15),再执行VLine到(15,20)点,需要记录动作“4”以及一个Float值(20),再执行HLine到(5,20)点,需要记录动作“3”以及一个Float值(5),再执行Close闭合矩形,回到起点(5,0),需要记录动作“0”。For example, to draw a rectangle of (x:5, y:0, r:15, b:20), the data structure of the path type (Path) is as follows: execute the Move action to the point (5,0), and record the action "1" and two Float values (5,0). Then execute HLine to the point (15,0), and record the action "3" and a Float value (15). Then execute VLine to the point (15,20), and record the action "4" and a Float value (20). Then execute HLine to the point (5,20), and record the action "3" and a Float value (5). Then execute Close to close the rectangle and return to the starting point (5,0). Record the action "0".

参照图5,为上述例子中路径信息的编码结构示意图。在编码上述路径信息时,首先对numVerbs即动作的数量“5”按照EncodedUint32进行编码,然后按照UB[3]类型依次对五个动作“1、3、4、3、0”依次编码。上述五个动作包括5个float值,分别为5、0、15、20、5,根据精度参数将这五个浮点数转换为整数类型后依次为100、0、300、400、100,其中最大值为400,400需要用10位来表示,因此numBits=10。在按照UB[5]对numBits进行编码后得到这一组连续的浮点类型数据的头部区域。最后依次按照SB[10]依次对100、0、300、400、100进行编码,从而得到整个路径信息的编码数据。Refer to Figure 5, which is a schematic diagram of the encoding structure of the path information in the above example. When encoding the above path information, first, numVerbs, that is, the number of actions "5", is encoded according to EncodedUint32, and then the five actions "1, 3, 4, 3, 0" are encoded in sequence according to the UB[3] type. The above five actions include 5 float values, namely 5, 0, 15, 20, and 5. After converting these five floating-point numbers into integer types according to the precision parameter, they are 100, 0, 300, 400, and 100 respectively. The maximum value is 400, and 400 needs to be represented by 10 bits, so numBits = 10. After encoding numBits according to UB[5], the header area of this group of continuous floating-point type data is obtained. Finally, 100, 0, 300, 400, and 100 are encoded in sequence according to SB[10] to obtain the encoded data of the entire path information.

十八、字节流类型18. Byte stream type

字段Fields 数据类型Data Types 备注Remark datadata 字节地址Byte Address 字节的起始地址Starting address of bytes lengthlength Uint64Uint64 字节长度Byte length

字节流类型(ByteData)用于表示字节流的起始地址和字节流的长度。在编码某一串字节流时,先编码这一串字节流中字节的起始地址,然后再编码整个字节流的长度,以便于在解码时从内存中的该起始地址开始按照该字节流长度读取数据,得到整个字节流。该字节地址还可以是偏移地址,在计算机为PAG文件分配相应的内存后,该字节流的起始地址可以根据分配的内存的起始地址与该偏移地址确定。The byte stream type (ByteData) is used to indicate the starting address and length of the byte stream. When encoding a string of byte streams, first encode the starting address of the bytes in the string of byte streams, and then encode the length of the entire byte stream, so that when decoding, data can be read from the starting address in the memory according to the length of the byte stream to obtain the entire byte stream. The byte address can also be an offset address. After the computer allocates the corresponding memory for the PAG file, the starting address of the byte stream can be determined based on the starting address of the allocated memory and the offset address.

十九、位图信息类型19. Bitmap Information Type

字段Fields 字段类型Field Type 备注Remark xx Int32Int32 差异像素区域起点位置的X坐标X coordinate of the starting point of the difference pixel area yy Int32Int32 差异像素区域起点位置的Y坐标The Y coordinate of the starting point of the difference pixel area fileBytesfileBytes ByteDataByteData 图片数据Image Data

位图信息类型(BitmapRect)用于表示位图图像序列中每一位图图像对应差异像素区域按照图片编码方式进行压缩编码后得到的二进制图片数据。其中x,y分别表示差异像素区域起点位置的X坐标和Y坐标。在编码位图信息时,需要找到差异像素区域中的起点位置,然后对该起点位置、差异像素区域对应的图片数据依次按照字节流类型编码,得到每一位图图像的编码数据。The bitmap information type (BitmapRect) is used to represent the binary image data obtained by compressing and encoding the difference pixel area corresponding to each bitmap image in the bitmap image sequence according to the image encoding method. Among them, x and y represent the X coordinate and Y coordinate of the starting position of the difference pixel area respectively. When encoding the bitmap information, it is necessary to find the starting position in the difference pixel area, and then encode the image data corresponding to the starting position and the difference pixel area in turn according to the byte stream type to obtain the encoded data of each bitmap image.

二十、视频帧信息类型20. Video frame information type

字段Fields 字段类型Field Type 备注Remark frameframe TimeTime 帧序号Frame number fileBytesfileBytes ByteDataByteData 视频帧数据Video frame data

视频帧信息类型(VideoFrame)用于表示位图图像序列中每一位图图像对应的合成位图按照视频编码方式进行压缩得到的二进制图片数据。其中,frame表示当前帧的帧序号,帧序号除以帧率可以转换为以秒为单位的时间。Time类型采用Int64进行编码。在编码视频帧信息时,先按照Int64对帧序号进行编码,然后再按照字节流类型对该视频帧对应的视频帧数据进行编码,得到每一视频帧的编码数据。The video frame information type (VideoFrame) is used to represent the binary image data obtained by compressing the synthetic bitmap corresponding to each bitmap image in the bitmap image sequence according to the video encoding method. Among them, frame represents the frame number of the current frame, and the frame number divided by the frame rate can be converted into time in seconds. The Time type is encoded using Int64. When encoding the video frame information, the frame number is first encoded according to Int64, and then the video frame data corresponding to the video frame is encoded according to the byte stream type to obtain the encoded data of each video frame.

下面介绍PAG文件的文件组织结构。The following describes the file organization structure of the PAG file.

如图6所示,PAG文件的文件组织结构由文件头(FileHeader)和节点元素(Tag)构成。文件头是PAG文件中位于开头部分用于描述文件头信息的数据结构。文件头信息至少包括文件版本号、文件长度和文件压缩方式。文件头信息可以按照下表的文件头组织结构进行组织:As shown in Figure 6, the file organization structure of the PAG file consists of a file header (FileHeader) and a node element (Tag). The file header is a data structure located at the beginning of the PAG file and used to describe the file header information. The file header information includes at least the file version number, file length, and file compression method. The file header information can be organized according to the file header organization structure in the following table:

字段Fields 数据类型Data Types 字段含义Field meaning 签名sign Unit8Unit8 签名字节,用于存储“P”Signature byte, used to store "P" 签名sign Unit8Unit8 签名字节,用于存储“A”Signature byte, used to store "A" 签名sign Unit8Unit8 签名字节,用于存储“G”Signature byte, used to store "G" 文件版本号File version number Unit32Unit32 文件版本号,例如0X04表示第“4”个版本File version number, for example 0X04 means the 4th version 文件长度File Length Unit32Unit32 整个文件的文件长度,包括文件头的长度The file length of the entire file, including the length of the file header 文件压缩方式File compression method Int8Int8 文件的压缩方式How to compress the file

节点元素都具有相同的数据结构,如图7所示,节点元素都包括节点元素头部(TagHeader)和节点元素内容(TagBody),便于在解码时遇到无法解析的节点元素能够直接跳过当前的节点元素。节点结束符(End)是一个特殊的节点元素,用于标识本层次的节点元素已经全部读取,没有更多的节点元素要读取。节点元素还可以是嵌套的节点元素,在一个节点元素中可以包括一个或多个子节点元素,同样也是在结尾使用End标识子节点元素已经全部读取,没有更多的子节点元素要读取。Node elements all have the same data structure, as shown in Figure 7, and node elements all include a node element header (TagHeader) and a node element content (TagBody), so that when encountering a node element that cannot be parsed during decoding, the current node element can be directly skipped. The node terminator (End) is a special node element that is used to indicate that all node elements at this level have been read and there are no more node elements to be read. Node elements can also be nested node elements, and one node element can include one or more child node elements. Similarly, End is used at the end to indicate that all child node elements have been read and there are no more child node elements to be read.

参照图7,节点元素头部(TagHeader)用于记录动画标签码(TagCode)和节点元素内容的字节流长度(Length)。动画标签码可用于表示节点元素具体记录了哪一类的动画信息,不同的动画标签码表示记录了不同的动画信息。字节流长度可用于表示节点元素中节点元素内容的长度。Referring to Figure 7, the node element header (TagHeader) is used to record the animation tag code (TagCode) and the byte stream length (Length) of the node element content. The animation tag code can be used to indicate which type of animation information is recorded in the node element. Different animation tag codes indicate that different animation information is recorded. The byte stream length can be used to indicate the length of the node element content in the node element.

由于TagBody记录的数据有可能非常少也可能非常多,有的只占用一个字节,则Length的值是1,有的占用了100个字节,则Length的值为100,因此,为了尽可能减少文件占用的存储空间,可以将TagHeader具体分为short类型和long类型的结构进行存储。Since the data recorded by TagBody may be very small or very large, some data only occupies one byte, then the value of Length is 1, and some data occupies 100 bytes, then the value of Length is 100. Therefore, in order to minimize the storage space occupied by the file, the TagHeader can be divided into short type and long type structures for storage.

TagHeader short类型TagHeader short type

TagHeader long类型TagHeader long type

short型结构的TagHeader采用16位来记录动画标签码和节点元素内容的长度。在short型结构的TagHeader中,节点元素内容的长度的值最大可以是62(TagCodeAndLength后6位为111110时),表示TagBody最多可以存储62字节的数据。而long型结构的TagHeader中,length的数据类型为Uint32,因此节点元素内容的长度的最大值可以是4G,表示TagBody最多可以存储4G的数据。The short-type TagHeader uses 16 bits to record the animation tag code and the length of the node element content. In the short-type TagHeader, the maximum value of the length of the node element content can be 62 (when the last 6 bits of TagCodeAndLength are 111110), which means that the TagBody can store up to 62 bytes of data. In the long-type TagHeader, the data type of length is Uint32, so the maximum value of the length of the node element content can be 4G, which means that the TagBody can store up to 4G of data.

也就说,当TagBody的长度是62字节或是小于62字节时,则TagHeader的数据类型为Uint16,前10位用于存储动画标签码,后6位用于存储Length。当TagBody的长度是63字节或是更长,则TagHeader包含了一个Uint16的TagCodeAndLength字段以及一个Uint32的Length字段,在Uint16的TagCodeAndLength中,前6位用于存储动画标签码,后6位固定为0x3f,也就是当后6位为“111111”时表示当前的TagHeader采用的是long类型结构存储,在这种情况下,TagCodeAndLength字段后紧接着采用32位的无符号整型表示TagBody的长度。在解码时,先读取TagCodeAndLength字段的前10位得到动画标签码,再读取后6位,若后6位的值不是“111111”,则读取的这6位的值即为TagBody的长度,若后6位的值是“111111”,则继续读取后面32位(4字节)的数据,读取出的这4字节的数据即为TagBody的长度。That is to say, when the length of TagBody is 62 bytes or less, the data type of TagHeader is Uint16, the first 10 bits are used to store the animation tag code, and the last 6 bits are used to store the Length. When the length of TagBody is 63 bytes or longer, TagHeader contains a Uint16 TagCodeAndLength field and a Uint32 Length field. In the Uint16 TagCodeAndLength, the first 6 bits are used to store the animation tag code, and the last 6 bits are fixed to 0x3f. That is, when the last 6 bits are "111111", it means that the current TagHeader is stored in a long type structure. In this case, the TagCodeAndLength field is followed by a 32-bit unsigned integer to represent the length of TagBody. During decoding, first read the first 10 bits of the TagCodeAndLength field to get the animation tag code, and then read the last 6 bits. If the value of the last 6 bits is not "111111", the value of the read 6 bits is the length of TagBody. If the value of the last 6 bits is "111111", continue to read the next 32 bits (4 bytes) of data, and the read 4 bytes of data are the length of TagBody.

在上述方式中,若TagBody的数据更多,需要占用更多的位,则在long型的TagHeader中,可以采用无符号64位整型记录Length的值。In the above method, if the TagBody contains more data and needs to occupy more bits, an unsigned 64-bit integer can be used to record the value of Length in the long-type TagHeader.

进一步地,从TagCodeAndLength字段中读取出的Length的值也可以是0代表TagBody的长度是0,这种情况下,TagBody不存在。例如,前文提到的节点结束符(End)是一个特殊的节点元素,该节点元素的TagHeader中记录的Length的值为0。Furthermore, the value of Length read from the TagCodeAndLength field can also be 0, indicating that the length of TagBody is 0. In this case, TagBody does not exist. For example, the node end (End) mentioned above is a special node element, and the value of Length recorded in the TagHeader of the node element is 0.

当然,在上述提供的节点元素头部的数据结构中,每一个字段的数据类型可以根据实际情况进行调整,可以根据实际情况使每个字段占用更多的位数,也可以使每个字段占用更少的位数。Of course, in the data structure of the node element header provided above, the data type of each field can be adjusted according to actual conditions, and each field can occupy more bits or fewer bits according to actual conditions.

PAG文件提供了大量的动画标签码,用于表示丰富的动画信息。每一个动画标签码对应的动画信息的数据结构用一个属性结构表来表示。在编码PAG文件时,先按照文件头组织结构编码文件头信息,再按照节点元素的数据结构根据动画数据依次编码动画标签码(TagCode)、节点元素内容的字节流长度(Length)以及节点元素内容(TagBody)。PAG files provide a large number of animation tag codes to represent rich animation information. The data structure of the animation information corresponding to each animation tag code is represented by an attribute structure table. When encoding a PAG file, first encode the file header information according to the file header organization structure, and then encode the animation tag code (TagCode), the byte stream length (Length) of the node element content, and the node element content (TagBody) in sequence according to the animation data according to the data structure of the node element.

其中,在编码节点元素内容(TagBody)时,需要根据动画标签码所对应的属性结构表来进行编码。属性结构表定义了动画标签码所对应的动画信息的数据结构。When encoding the node element content (TagBody), it is necessary to encode according to the attribute structure table corresponding to the animation tag code. The attribute structure table defines the data structure of the animation information corresponding to the animation tag code.

若动画标签码所表示的动画信息包括的属性从种类到数量都是固定的,则该动画标签码所对应的属性结构表中每个属性对应的数据类型都是基础类型,可以直接根据这些基础数据类型对该动画标签码相应的动画数据进行编码得到节点元素内容,此时编码节点元素所采用的数据结构可以称之为基础数据结构。If the attributes included in the animation information represented by the animation tag code are fixed in type and quantity, then the data type corresponding to each attribute in the attribute structure table corresponding to the animation tag code is a basic type, and the animation data corresponding to the animation tag code can be directly encoded according to these basic data types to obtain the node element content. At this time, the data structure used to encode the node element can be called the basic data structure.

若TagBody记录的动画信息所包括属性的种类、数量都是不确定的,比如,遮罩的绘制路径信息,不同遮罩的绘制路径信息所包括的动作类型、动作数量可能都存在差异,此时就会需要大量额外的标识符字段,这时候用上述的方式去定义数据结构将会浪费大量的文件空间。为了能够尽量压缩文件空间,针对这种动画标签码对应的动画信息,需要重新定义其对应的属性结构表,并提供相应的编码规则来编码节点元素内容。这种新定义的属性结构表所表示的数据结构可以称之为动态属性数据结构(AttributeBlock)。If the types and quantities of attributes included in the animation information recorded by TagBody are uncertain, for example, the drawing path information of the mask, the action types and number of actions included in the drawing path information of different masks may be different, then a large number of additional identifier fields will be required. At this time, defining the data structure in the above way will waste a lot of file space. In order to compress the file space as much as possible, for the animation information corresponding to this animation tag code, it is necessary to redefine its corresponding attribute structure table and provide corresponding encoding rules to encode the node element content. The data structure represented by this newly defined attribute structure table can be called a dynamic attribute data structure (AttributeBlock).

下面介绍按照上述的基础数据结构或动态属性数据结构对各动画标签码对应的动画数据进行编码得到节点元素内容(TagBody)的具体方法。The following describes a specific method for encoding the animation data corresponding to each animation tag code according to the above basic data structure or dynamic attribute data structure to obtain the node element content (TagBody).

如图8所示,在一个实施例中,提供了一种动画数据编码方法。本实施例主要以该方法应用于上述图1中的终端110来举例说明。参照图8,该动画数据编码方法具体包括如下步骤:As shown in FIG8 , in one embodiment, a method for encoding animation data is provided. This embodiment is mainly illustrated by applying the method to the terminal 110 in FIG1 . Referring to FIG8 , the method for encoding animation data specifically includes the following steps:

S802,从动画工程文件中获取与各动画标签码对应的动画数据。S802, acquiring animation data corresponding to each animation tag code from the animation project file.

其中,动画工程文件比如可以是上文提及的AE工程文件,拓展名为.aep。动画标签码用于表示该动画标签码所对应的节点元素头部后的节点元素内容具体表示的是哪一类动画信息。在编码之前,需要预先设定动画标签码与对应的动画信息之间的一一对应的关系,以便按照预先设定的一一对应关系将动画标签码与对应的动画信息对应编码。动画数据是与该动画标签码对应的描述动画信息的数据。比如,动画标签码为14,代表MaskBlock,表示动画工程文件中的某个遮罩信息,遮罩信息包括以下属性:遮罩标识、遮罩是否反转、遮罩的混合模式、遮罩的矢量路径、遮罩的透明度以及遮罩的边缘扩展参数,与该动画标签码对应的动画数据就是这些属性对应的属性值。又比如,动画标签码为13,代表Transform2D,表示动画工程文件中某个2D变换信息,2D变换信息包括以下属性:锚点坐标、位置信息、X轴偏移、Y轴偏移、缩放信息、旋转信息和透明度信息。Among them, the animation project file can be, for example, the AE project file mentioned above, with an extension of .aep. The animation tag code is used to indicate which type of animation information the node element content after the node element header corresponding to the animation tag code specifically represents. Before encoding, it is necessary to pre-set a one-to-one correspondence between the animation tag code and the corresponding animation information, so that the animation tag code and the corresponding animation information are encoded in accordance with the pre-set one-to-one correspondence. Animation data is data describing the animation information corresponding to the animation tag code. For example, the animation tag code is 14, which represents MaskBlock, indicating a mask information in the animation project file. The mask information includes the following attributes: mask identification, whether the mask is inverted, the blending mode of the mask, the vector path of the mask, the transparency of the mask, and the edge extension parameters of the mask. The animation data corresponding to the animation tag code is the attribute values corresponding to these attributes. For another example, the animation tag code is 13, which represents Transform2D, indicating a 2D transformation information in the animation project file. The 2D transformation information includes the following attributes: anchor point coordinates, position information, X-axis offset, Y-axis offset, scaling information, rotation information, and transparency information.

动画工程文件可以是设计师通过AE软件制作好的文件,动画工程文件存储了整个动画合成所使用的全部参数。动画合成(Composition)是图层的集合。终端可以在获取到该动画工程文件后,从动画工程文件中提取动画数据,并按照预先定义的动画标签码,将这些动画数据与各个动画标签码一一对应,得到各个动画标签码所对应的动画数据。例如,获取到一组2D变换信息,而预先定义的表示2D变换信息的动画标签码为“13”,则与该动画标签码“13”对应的动画数据即为这一组2D变换信息。当然,在动画工程文件中,可能存在多组不同的2D变换信息,则每一组2D变换信息都需要用动画标签码“13”来标识。An animation project file can be a file created by a designer using AE software. The animation project file stores all the parameters used for the entire animation synthesis. Animation synthesis (Composition) is a collection of layers. After obtaining the animation project file, the terminal can extract the animation data from the animation project file, and according to the predefined animation tag code, these animation data correspond to each animation tag code one by one to obtain the animation data corresponding to each animation tag code. For example, a set of 2D transformation information is obtained, and the predefined animation tag code representing the 2D transformation information is "13", then the animation data corresponding to the animation tag code "13" is this set of 2D transformation information. Of course, there may be multiple sets of different 2D transformation information in the animation project file, and each set of 2D transformation information needs to be identified by the animation tag code "13".

从前文描述节点元素头部的内容可以知道,PAG文件采用10比特位来存储动画标签码,最多可以存储1024种不同的动画标签码。由于动画数据是基于动画标签码与对应的数据块(包括基础数据块或动态属性数据块)进行编码的,因此,在PAG文件不断支持新的动画特性时,可以持续保证对在前的旧文件格式的向后兼容性。目前PAG文件仅用到了37种动画标签码,其中,0-29是矢量导出方式所支持的动画标签码,45-51是为位图序列帧导出方式以及视频序列帧导出方式扩展的7个动画标签码。若后续PAG文件还可以支持更多的动画特性,则还可以继续扩展新的动画标签码表示新增的动画特性所对应的动画信息。From the description of the node element header content in the previous text, we can know that the PAG file uses 10 bits to store the animation tag code, and can store up to 1024 different animation tag codes. Since the animation data is encoded based on the animation tag code and the corresponding data block (including the basic data block or the dynamic attribute data block), when the PAG file continues to support new animation features, it can continue to ensure backward compatibility with the previous old file format. Currently, PAG files only use 37 animation tag codes, of which 0-29 are animation tag codes supported by the vector export method, and 45-51 are 7 animation tag codes extended for the bitmap sequence frame export method and the video sequence frame export method. If subsequent PAG files can support more animation features, new animation tag codes can continue to be extended to represent the animation information corresponding to the newly added animation features.

下表介绍了各个动画标签码所分别代表的动画信息:The following table describes the animation information represented by each animation tag code:

上述每一类动画信息所对应的属性结构表将会在后面列出。The attribute structure table corresponding to each type of animation information mentioned above will be listed later.

S804,当与动画标签码对应的属性结构表中存在属性类型时,则确定各属性对应的属性标识信息。S804: When there is an attribute type in the attribute structure table corresponding to the animation tag code, attribute identification information corresponding to each attribute is determined.

其中,属性结构表定义了动画标签码所对应的动画信息的数据结构。在编码节点元素内容时,需要根据动画标签码所对应的属性结构表进行编码。各个动画标签码的属性结构表是预先定义好的,后文给出了各个动画标签码所对应的属性结构表。为了明确编码方式以及解码规则,当需要支持更多的动画特性时就需要扩展新的动画标签码,并且还需要定义与新增的动画标签码所对应的属性结构表。Among them, the attribute structure table defines the data structure of the animation information corresponding to the animation tag code. When encoding the node element content, it is necessary to encode according to the attribute structure table corresponding to the animation tag code. The attribute structure table of each animation tag code is pre-defined, and the attribute structure table corresponding to each animation tag code is given later. In order to clarify the encoding method and decoding rules, when more animation features need to be supported, new animation tag codes need to be expanded, and the attribute structure table corresponding to the newly added animation tag code also needs to be defined.

当动画标签码所表示的动画信息包括的属性从种类到数量都不确定时,则定义的该动画标签码所对应的属性结构表中存在各属性的属性类型,该属性结构表所呈现的数据结构可以称之为动态属性数据结构。比如,对于表示遮罩信息的动画标签码“14”,其对应的属性结构表中存在属性类型。进一步地,若该属性结构表中一些属性的属性值通常情况下等于默认值,为了减小文件的大小,也可以不用存储该属性的属性值,只需要用一个比特位来表示该属性的属性值等于默认值即可。因此,该属性结构表中还包括各个属性对应的默认值。各个属性的默认值以及对应的属性类型可以硬编码在动画文件的解码代码中,以便解析时根据标识位确定为默认值时直接获取默认值。When the attributes included in the animation information represented by the animation tag code are uncertain from the type to the quantity, the attribute structure table corresponding to the defined animation tag code contains the attribute type of each attribute, and the data structure presented by the attribute structure table can be called a dynamic attribute data structure. For example, for the animation tag code "14" representing mask information, the attribute type exists in its corresponding attribute structure table. Furthermore, if the attribute values of some attributes in the attribute structure table are usually equal to the default values, in order to reduce the file size, the attribute values of the attributes do not need to be stored, and only one bit is needed to indicate that the attribute value of the attribute is equal to the default value. Therefore, the attribute structure table also includes the default values corresponding to each attribute. The default values of each attribute and the corresponding attribute type can be hard-coded in the decoding code of the animation file, so that the default value can be directly obtained when it is determined as the default value according to the identification bit during parsing.

属性类型(AttributeType)是按照动态属性数据结构编码动画数据以及解析动态属性数据块(AttributeBlock)所必需的。当某个动画标签码所对应的属性结构表中存在属性类型时,则表明该动画标签码所对应的节点元素头部后的节点元素内容需要按照动态属性数据结构进行编码。在编码阶段,属性类型用于确定属性标识信息占用的比特位数,在解码阶段,属性类型用于确定属性标识信息占用的比特位数以及相应的读取规则。The attribute type (AttributeType) is required to encode animation data according to the dynamic attribute data structure and parse the dynamic attribute data block (AttributeBlock). When an attribute type exists in the attribute structure table corresponding to a certain animation tag code, it indicates that the node element content after the node element header corresponding to the animation tag code needs to be encoded according to the dynamic attribute data structure. In the encoding stage, the attribute type is used to determine the number of bits occupied by the attribute identification information. In the decoding stage, the attribute type is used to determine the number of bits occupied by the attribute identification information and the corresponding reading rules.

动态属性数据块主要由两部分组成:各个属性对应的属性标识信息(AttributeFlag)组成的属性标识区域以及由各个属性对应的属性内容(AttributeContent)组成的属性内容区域。以遮罩信息的属性结构表为例进行说明,参照图9,图9左边给出了遮罩信息所对应的属性结构表,其中包括6个属性,图9右边给出了该属性结构表对应的动态属性数据块的具体结构。参照图9可知,每个属性都有相应的属性标识信息(当该属性对应的属性类型为固定属性则属性标识信息不存在)和属性内容。每个属性标识信息的排列顺序是与属性内容的排列顺序一一对应的。每次给定一个属性结构表,就按照该属性结构表确定每个属性对应的属性标识信息与属性内容,然后按顺序排列存储。例如这里的AttributeFlag 0和AttributeContent 0即对应遮罩信息对应的属性结构表的第一项ID属性。从图9中可以看出,数据结构是先存储完所有的属性标识信息再开始存储所有的属性内容,这样做是因为属性标识信息区域中每项通常都是以比特位表示的,集中存储在一起可以避免频繁发生字节对齐,从而产生大量空间浪费。属性标识信息区域读取结束后会进行一次统一的字节对齐,由于字节对齐产生的额外比特位都会用0补齐,再从整字节数位置开始继续存储属性内容。The dynamic attribute data block mainly consists of two parts: an attribute identification area composed of attribute identification information (AttributeFlag) corresponding to each attribute and an attribute content area composed of attribute content (AttributeContent) corresponding to each attribute. Take the attribute structure table of mask information as an example for explanation, refer to Figure 9, the attribute structure table corresponding to the mask information is shown on the left side of Figure 9, which includes 6 attributes, and the specific structure of the dynamic attribute data block corresponding to the attribute structure table is shown on the right side of Figure 9. Referring to Figure 9, it can be seen that each attribute has corresponding attribute identification information (when the attribute type corresponding to the attribute is a fixed attribute, the attribute identification information does not exist) and attribute content. The arrangement order of each attribute identification information is one-to-one corresponding to the arrangement order of the attribute content. Each time an attribute structure table is given, the attribute identification information and attribute content corresponding to each attribute are determined according to the attribute structure table, and then stored in order. For example, AttributeFlag 0 and AttributeContent 0 here correspond to the first ID attribute of the attribute structure table corresponding to the mask information. As can be seen from Figure 9, the data structure stores all attribute identification information first and then starts to store all attribute contents. This is because each item in the attribute identification information area is usually represented by bits, and centralized storage can avoid frequent byte alignment, which will result in a lot of space waste. After the attribute identification information area is read, a unified byte alignment will be performed. The extra bits generated by byte alignment will be padded with 0, and then the attribute content will continue to be stored from the integer byte position.

由于每个动画标签码所对应的属性结构表中定义的属性的数量是固定不会变化的,为了压缩动画文件的大小,每个动画标签码所对应的属性结构表所包括的属性的数量并不会写入动画文件,而是硬编码在解析代码中,这样解析的时候就可以直接获取该动画标签码所标识的动画信息所包括的属性的数量。Since the number of attributes defined in the attribute structure table corresponding to each animation tag code is fixed and will not change, in order to compress the size of the animation file, the number of attributes included in the attribute structure table corresponding to each animation tag code will not be written into the animation file, but will be hard-coded in the parsing code. In this way, the number of attributes included in the animation information identified by the animation tag code can be directly obtained during parsing.

如前文所提及的,当动画标签码所表示的动画信息包括的属性从种类到数量都不确定时,则定义的该动画标签码所对应的属性结构表中存在各属性的属性类型。比如,属性的种类或数量不确定的情形包括以下几种特征:As mentioned above, when the attributes of the animation information represented by the animation tag code are uncertain in both type and quantity, the attribute structure table corresponding to the defined animation tag code contains the attribute types of each attribute. For example, the situation where the type or quantity of the attribute is uncertain includes the following characteristics:

1、有的属性对应的数据类型是一个布尔类型,需占用一个字节,但是实际上可以只用1个比特位来标识该属性的值,即0表示false,1表示true,为此,我们可以额外用属性类型来标识该属性的属性值为占用1个比特位的布尔值,在编码时只需要占用1个比特位,在解码时可以根据属性类型来解析该属性对应的属性值。1. The data type corresponding to some attributes is a Boolean type, which takes up one byte. However, in fact, only one bit is needed to identify the value of the attribute, that is, 0 represents false and 1 represents true. Therefore, we can use the attribute type to identify the attribute value of the attribute as a Boolean value that takes up one bit. It only takes up one bit during encoding, and the attribute value corresponding to the attribute can be parsed according to the attribute type during decoding.

2、有的属性对应的属性值通常是默认值,为了压缩文件大小,这种情况可以不存储实际的值,在编码时可以直接使用1个比特位来标识该属性对应的属性值等于默认值即可,然后将默认值植入解析代码即可。2. The attribute values corresponding to some attributes are usually default values. In order to compress the file size, the actual value may not be stored in this case. When encoding, one bit may be directly used to indicate that the attribute value corresponding to the attribute is equal to the default value, and then the default value may be implanted into the parsing code.

3、有的属性对应的属性值可能是一个动画区间特性数据,但是该动画区间特性数据不包括空间缓动参数,可以不存储空间缓动参数相关的数据。有的属性对应的属性值可能又不包括动画区间特性数据,是一个固定的值,这种情况下又只需要存储一个值即可。若该值还等于默认值,可以用1个比特位标识等于默认值即可。3. The attribute value corresponding to some attributes may be an animation interval characteristic data, but the animation interval characteristic data does not include spatial easing parameters, so the data related to spatial easing parameters may not be stored. The attribute value corresponding to some attributes may not include animation interval characteristic data and is a fixed value. In this case, only one value needs to be stored. If the value is still equal to the default value, 1 bit can be used to indicate that it is equal to the default value.

根据上述动态属性数据结构中各属性的特征,每个属性都有可能存在很多不同的状态,充分利用好这些状态可以在大部分情况下显著减少文件大小。因而根据上述属性的特征,定义出的属性标识信息的数据结构如下表所示:According to the characteristics of each attribute in the above dynamic attribute data structure, each attribute may have many different states. Making full use of these states can significantly reduce the file size in most cases. Therefore, according to the characteristics of the above attributes, the data structure of the defined attribute identification information is shown in the following table:

终端可以根据动画标签码对应的属性结构表中每个属性的属性类型和动画数据确定每个属性对应的属性标识信息。在解码时,就可以根据该属性标识信息从属性内容区域中读取该属性对应的属性内容。但每个属性对应的属性标识信息占用的比特位数是动态的,取值范围是0-3比特位。各个属性具体占用了几个比特位,需要根据属性类型确定,也就是说,属性类型可用于确定属性标识信息可能占用的比特位数(0-3位)。PAG文件将属性类型划分成以下8种,如下表所示:The terminal can determine the attribute identification information corresponding to each attribute based on the attribute type and animation data of each attribute in the attribute structure table corresponding to the animation tag code. During decoding, the attribute content corresponding to the attribute can be read from the attribute content area based on the attribute identification information. However, the number of bits occupied by the attribute identification information corresponding to each attribute is dynamic, and the value range is 0-3 bits. The specific number of bits occupied by each attribute needs to be determined based on the attribute type, that is, the attribute type can be used to determine the number of bits (0-3 bits) that the attribute identification information may occupy. The PAG file divides attribute types into the following 8 types, as shown in the following table:

从上表可以看出,普通属性的属性标识信息最多只可能占1个比特位,解码时只需要读取内容标识位。而空间缓动动画属性的属性标识信息最多会占用3个比特位来存储属性标识信息。例如,当一个空间缓动动画属性不含有动画区间特性数据且属性值等于默认值时,只需要1个比特位来表示属性标识信息,属性标识信息仅包括属性内容标志位,其值为0,表示对应的属性内容为默认值。解码时读取到内容标识位为0,代表该属性的属性标识信息已经读取完毕,不会接着读取下一比特位的值。在极限情况下,属性结构表中各个属性都不含有动画区间特性数据而且都等于默认值,那么只会占用属性数量个比特位存储各个属性对应的属性标识信息,且每个属性标识信息都只包括内容标识位,其值均为0,并且整个属性内容区域都为空,从而可以显著降低动画文件的大小。另外,固定属性的属性标识信息为空,布尔属性的属性标识信息仅占用1个比特位,简单动画属性、离散动画属性、多维时间缓动动画属性的属性标识信息占用1个或2个比特位。As can be seen from the above table, the attribute identification information of ordinary attributes may only occupy 1 bit at most, and only the content identification bit needs to be read during decoding. The attribute identification information of spatial slow-motion animation attributes will occupy up to 3 bits to store the attribute identification information. For example, when a spatial slow-motion animation attribute does not contain animation interval characteristic data and the attribute value is equal to the default value, only 1 bit is needed to represent the attribute identification information, and the attribute identification information only includes the attribute content flag bit, whose value is 0, indicating that the corresponding attribute content is the default value. When decoding, the content identification bit is read as 0, which means that the attribute identification information of the attribute has been read and the value of the next bit will not be read. In the extreme case, each attribute in the attribute structure table does not contain animation interval characteristic data and is equal to the default value, then only the number of attribute bits will be used to store the attribute identification information corresponding to each attribute, and each attribute identification information only includes the content identification bit, whose value is 0, and the entire attribute content area is empty, which can significantly reduce the size of the animation file. In addition, the attribute identification information of fixed attributes is empty, the attribute identification information of Boolean attributes only occupies 1 bit, and the attribute identification information of simple animation attributes, discrete animation attributes, and multi-dimensional time easing animation attributes occupies 1 or 2 bits.

从上述内容可以知道,属性标识信息可用于表示该动画标签码所对应的属性结构表中各属性的状态信息,属性类型可以用确定属性标识信息可能占用的比特位数。在编码时,可以根据各个属性对应的属性类型以及动画数据确定每个属性对应的属性标识信息。在解码时,可以根据每个属性的属性类型先确定每个属性对应的属性标识信息可能占用的比特位数,再进一步根据属性标识信息的解析规则解析得到每个属性对应的属性标识信息,从而确定如何读取每个属性对应的属性内容。From the above content, it can be known that the attribute identification information can be used to represent the status information of each attribute in the attribute structure table corresponding to the animation tag code, and the attribute type can be used to determine the number of bits that the attribute identification information may occupy. When encoding, the attribute identification information corresponding to each attribute can be determined according to the attribute type corresponding to each attribute and the animation data. When decoding, the number of bits that the attribute identification information corresponding to each attribute may occupy can be determined first according to the attribute type of each attribute, and then further parsed according to the parsing rules of the attribute identification information to obtain the attribute identification information corresponding to each attribute, thereby determining how to read the attribute content corresponding to each attribute.

需要说明的是,每种动画标签码所对应的属性结构表中属性的数量、各个属性的数据类型、属性类型、属性的排序、属性对应的默认值都是植入在解析代码中的,也就是硬编码在解析代码中,不需要在编码时写入到动画文件中,这样可以减小动画文件的大小,或者,也可以说,动画标签码对应的属性结构表是硬编码在解析代码中的。比如,终端可以通过PAG SDK解析动画文件后进行渲染播放,每种动画标签码对应的属性结构表对应的上述信息可以硬编码在PAG SDK中。It should be noted that the number of attributes in the attribute structure table corresponding to each animation tag code, the data type of each attribute, the attribute type, the order of the attributes, and the default value corresponding to the attributes are all embedded in the parsing code, that is, hard-coded in the parsing code, and do not need to be written into the animation file during encoding, which can reduce the size of the animation file. Or, it can be said that the attribute structure table corresponding to the animation tag code is hard-coded in the parsing code. For example, the terminal can parse the animation file through the PAG SDK and then render and play it. The above information corresponding to the attribute structure table corresponding to each animation tag code can be hard-coded in the PAG SDK.

具体地,在需要对某一个动画标签码所对应的动画数据进行编码时,终端可以先查询该动画标签码所对应的属性结构表,当该属性结构表中存在属性类型时,则先需要确定各属性对应的属性标识信息,然后再按照该属性标识信息以及根据该属性结构表所呈现的动态属性数据结构对各属性对应的动画数据进行编码,得到属性内容,将每一对属性标识信息与属性内容所构成的动态属性数据块作为动画标签码对应的节点元素内容。进一步地,该属性结构表所呈现的动态属性数据结构中的各个属性的属性标识信息可以根据对应的属性类型以及动画数据本身确定。Specifically, when it is necessary to encode the animation data corresponding to a certain animation tag code, the terminal can first query the attribute structure table corresponding to the animation tag code. When the attribute type exists in the attribute structure table, it is necessary to first determine the attribute identification information corresponding to each attribute, and then encode the animation data corresponding to each attribute according to the attribute identification information and the dynamic attribute data structure presented by the attribute structure table to obtain the attribute content, and use the dynamic attribute data block composed of each pair of attribute identification information and attribute content as the node element content corresponding to the animation tag code. Furthermore, the attribute identification information of each attribute in the dynamic attribute data structure presented by the attribute structure table can be determined according to the corresponding attribute type and the animation data itself.

在一个实施例中,上述动画数据编码方法还包括:In one embodiment, the animation data encoding method further includes:

当与动画标签码对应的属性结构表中不存在属性类型时,则根据属性结构表中各属性对应的数据类型、属性排序,依次对动画数据中与各属性对应的属性值进行编码,得到动画标签码对应的基础属性数据块。When the attribute type does not exist in the attribute structure table corresponding to the animation tag code, the attribute values corresponding to each attribute in the animation data are encoded in turn according to the data type and attribute order corresponding to each attribute in the attribute structure table to obtain the basic attribute data block corresponding to the animation tag code.

具体地,当动画标签码所表示的动画信息包括的属性从种类到数量都是确定的时,则定义的该动画标签码所对应的属性结构表不存在各属性的属性类型,并且各属性的数据类型都是基础数据类型,该属性结构表所呈现的数据结构也称之为基础数据结构。比如,对于表示边框的尺寸和颜色信息的动画标签码“7”,其对应的属性结构表中不存在属性类型,也不存在各属性对应的默认值。在编码时,该动画标签码所对应的节点元素头部后的节点元素内容只需要根据属性结构表所呈现的基础数据结构进行编码。这里的基础数据结构是根据属性结构表中各属性对应的数据类型、属性排序确定的。Specifically, when the attributes included in the animation information represented by the animation tag code are determined from type to quantity, the attribute structure table corresponding to the defined animation tag code does not contain the attribute type of each attribute, and the data type of each attribute is a basic data type. The data structure presented by the attribute structure table is also called the basic data structure. For example, for the animation tag code "7" representing the size and color information of the border, the corresponding attribute structure table does not contain the attribute type, nor does it contain the default value corresponding to each attribute. When encoding, the node element content after the node element header corresponding to the animation tag code only needs to be encoded according to the basic data structure presented by the attribute structure table. The basic data structure here is determined based on the data type and attribute order corresponding to each attribute in the attribute structure table.

S806,按照属性标识信息,对动画数据中与各属性对应的属性值进行编码,得到各属性对应的属性内容。S806, encoding the attribute value corresponding to each attribute in the animation data according to the attribute identification information to obtain the attribute content corresponding to each attribute.

前文提到,属性标识信息用于表示动画标签码所对应的属性结构表中各属性的状态信息,因此,在确定每个属性对应的属性标识信息后,我们就能确定每个属性对应的属性内容是否存在,即是否为默认值,若是默认值,则对应的属性内容为空,若不是,则需要按照该属性对应的属性类型和数据结构对动画数据中与该属性对应的属性值进行编码,得到该属性对应的属性内容。还可以根据属性标识信息确定该属性对应的属性值是否包括动画区间特性数据、是否包括空间缓动参数信息,若是,则可以按照动画区间特性数据对应的数据结构对该属性对应的属性值进行编码,得到对应的属性内容。As mentioned above, the attribute identification information is used to represent the status information of each attribute in the attribute structure table corresponding to the animation tag code. Therefore, after determining the attribute identification information corresponding to each attribute, we can determine whether the attribute content corresponding to each attribute exists, that is, whether it is the default value. If it is the default value, the corresponding attribute content is empty. If not, it is necessary to encode the attribute value corresponding to the attribute in the animation data according to the attribute type and data structure corresponding to the attribute to obtain the attribute content corresponding to the attribute. It is also possible to determine whether the attribute value corresponding to the attribute includes animation interval characteristic data and whether it includes spatial easing parameter information based on the attribute identification information. If so, the attribute value corresponding to the attribute can be encoded according to the data structure corresponding to the animation interval characteristic data to obtain the corresponding attribute content.

在一个实施例中,属性对应的属性类型为普通属性或布尔属性,属性对应的属性标识信息仅包括内容标识位;确定各属性对应的属性标识信息,包括:若动画数据中与属性对应的属性值不是默认值时,则将内容标识位编码成表示动态属性数据块中存在与属性对应的属性内容的值;若动画数据中与属性对应的属性值是默认值时,则将内容标识位编码成表示动态属性数据块中不存在与属性对应的属性内容的值。In one embodiment, the attribute type corresponding to the attribute is a common attribute or a Boolean attribute, and the attribute identification information corresponding to the attribute only includes a content identification bit; the attribute identification information corresponding to each attribute is determined, including: if the attribute value corresponding to the attribute in the animation data is not a default value, then the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block; if the attribute value corresponding to the attribute in the animation data is a default value, then the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block.

具体地,若属性对应的属性类型为普通属性(Value),则属性对应的属性标识信息仅包括内容标识位。内容标识位用于标识属性对应的属性内容是否存在,若存在也就是当属性对应的属性值不是默认值时,则将内容标识位编码成表示动态属性数据块中存在与属性对应的属性内容的值,该值可以是1;当属性对应的属性内容是默认值时时,则将内容标识位编码成表示动态属性数据块中不存在与属性对应的属性内容的值,该值可以是0。也就是说,若属性对应的属性类型为普通类型,则该属性对应的属性标识信息要么是1,要么是0。实际上,该内容标识位就是用来确定属性对应的属性值是否为默认值的,该标识位的值具体编码成1或0是按照设定的标识位编码规则确定的,若属性对应的属性值为默认值,则用一个标识位(比如当内容标识为0时)直接表示该属性对应的属性值为默认值即可,不需要在属性内容区域中存储实际的值,可以减小动画文件的大小,若该属性对应的属性值不是默认值,则需要在属性内容区域中与该属性对应的内容区域中将该属性对应的属性值进行编码,得到该属性对应的属性内容。Specifically, if the attribute type corresponding to the attribute is a common attribute (Value), the attribute identification information corresponding to the attribute only includes the content identification bit. The content identification bit is used to identify whether the attribute content corresponding to the attribute exists. If it exists, that is, when the attribute value corresponding to the attribute is not the default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block, and the value can be 1; when the attribute content corresponding to the attribute is the default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block, and the value can be 0. In other words, if the attribute type corresponding to the attribute is a common type, the attribute identification information corresponding to the attribute is either 1 or 0. In fact, the content identification bit is used to determine whether the attribute value corresponding to the attribute is the default value. The value of the identification bit is specifically encoded as 1 or 0 according to the set identification bit encoding rules. If the attribute value corresponding to the attribute is the default value, then a identification bit (for example, when the content identification is 0) is used to directly indicate that the attribute value corresponding to the attribute is the default value. There is no need to store the actual value in the attribute content area, which can reduce the size of the animation file. If the attribute value corresponding to the attribute is not the default value, then it is necessary to encode the attribute value corresponding to the attribute in the content area corresponding to the attribute in the attribute content area to obtain the attribute content corresponding to the attribute.

在解码阶段,解析该属性对应的属性值时,先根据属性结构表确定该属性对应的属性类型,为普通属性,说明动态属性数据块中该属性对应的属性标识信息只占用1个比特位,当从动态属性数据块中读取到的该属性对应的属性标识信息为0时,则说明该属性对应的属性值为默认值,当读取到1时,则继续从动态属性数据块中读取该属性对应的属性内容,得到该属性对应的属性值。In the decoding stage, when parsing the attribute value corresponding to the attribute, the attribute type corresponding to the attribute is first determined according to the attribute structure table. If it is a common attribute, it means that the attribute identification information corresponding to the attribute in the dynamic attribute data block only occupies 1 bit. When the attribute identification information corresponding to the attribute read from the dynamic attribute data block is 0, it means that the attribute value corresponding to the attribute is the default value. When 1 is read, the attribute content corresponding to the attribute is continued to be read from the dynamic attribute data block to obtain the attribute value corresponding to the attribute.

若属性对应的属性类型为布尔类型(BitFlag),则对应的属性值为true或false,如前文提到的,可以用一个比特位来表示该属性的值。在编码时,可以用内容标识位直接表示对应的属性值,当对应的属性值为true时,可以将属性对应的内容标识位编码成表示true的值,该值比如可以是1;当对应的属性值为false时,可以将属性对应的内容标识位编码成表示false的值,该值比如可以是0。相应地,在解码阶段解析该属性对应的属性值时,先根据属性结构表确定该属性对应的属性类型,为布尔属性,说明动态属性数据块中该属性对应的属性标识信息只占用1个比特位,并且该比特位的值即为该属性对应的属性值,也就是说,对于布尔属性而言,在解析该属性时直接将读取到的内容标识位的值作为对应的属性值,不需要解析动态属性数据块的属性内容区域。If the attribute type corresponding to the attribute is a Boolean type (BitFlag), the corresponding attribute value is true or false. As mentioned above, one bit can be used to represent the value of the attribute. When encoding, the corresponding attribute value can be directly represented by the content identifier. When the corresponding attribute value is true, the content identifier corresponding to the attribute can be encoded into a value representing true, which can be 1, for example; when the corresponding attribute value is false, the content identifier corresponding to the attribute can be encoded into a value representing false, which can be 0, for example. Accordingly, when parsing the attribute value corresponding to the attribute in the decoding stage, the attribute type corresponding to the attribute is first determined according to the attribute structure table, which is a Boolean attribute, indicating that the attribute identification information corresponding to the attribute in the dynamic attribute data block only occupies 1 bit, and the value of the bit is the attribute value corresponding to the attribute. That is to say, for a Boolean attribute, when parsing the attribute, the value of the content identifier read is directly used as the corresponding attribute value, and there is no need to parse the attribute content area of the dynamic attribute data block.

在一个实施例中,属性对应的属性类型为固定属性,属性标识信息为空;按照属性标识信息,对动画数据中与各属性对应的属性值进行编码,得到各属性对应的属性内容,包括:直接根据属性对应的数据类型对动画数据中与属性对应的属性值进行编码,得到属性对应的属性内容。In one embodiment, the attribute type corresponding to the attribute is a fixed attribute, and the attribute identification information is empty; according to the attribute identification information, the attribute value corresponding to each attribute in the animation data is encoded to obtain the attribute content corresponding to each attribute, including: directly encoding the attribute value corresponding to the attribute in the animation data according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute.

具体地,当属性的属性类型为固定属性(FixedValue)时,表示该属性对应的属性值是固定存在的,不需要用属性标识信息来标识这个属性的状态,在编码时,需要将该属性对应的属性值按照该属性对应的数据类型进行编码,得到该属性对应的属性内容。比如,在表示遮罩信息的属性结构表中,第一个属性表示遮罩的遮罩标识(id),该属性对应的属性类型为固定属性,表示需要将该遮罩标识按照对应的数据类型进行编码后得到对应的属性内容。Specifically, when the attribute type of an attribute is a fixed attribute (FixedValue), it means that the attribute value corresponding to the attribute is fixed and does not need to be identified by attribute identification information. When encoding, the attribute value corresponding to the attribute needs to be encoded according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute. For example, in the attribute structure table representing mask information, the first attribute represents the mask identifier (id) of the mask, and the attribute type corresponding to the attribute is a fixed attribute, which means that the mask identifier needs to be encoded according to the corresponding data type to obtain the corresponding attribute content.

在一个实施例中,属性对应的属性类型为简单动画属性、离散动画属性、多维时间缓动动画属性或空间缓动动画属性,属性标识信息至少包括内容标识位;确定各属性对应的属性标识信息,包括:若动画数据中与属性对应的属性值不是默认值时,则将内容标识位编码成表示动态属性数据块中存在与属性对应的属性内容的值;若动画数据中与属性对应的属性值是默认值时,则将内容标识位编码成表示动态属性数据块中不存在与属性对应的属性内容的值。In one embodiment, the attribute type corresponding to the attribute is a simple animation attribute, a discrete animation attribute, a multi-dimensional time-delayed animation attribute, or a space-delayed animation attribute, and the attribute identification information at least includes a content identification bit; the attribute identification information corresponding to each attribute is determined, including: if the attribute value corresponding to the attribute in the animation data is not a default value, then the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block; if the attribute value corresponding to the attribute in the animation data is a default value, then the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block.

具体地,当属性对应的属性类型为简单动画属性(SimpleProperty)、离散动画属性(DiscreteProperty)、多维时间缓动动画属性(MultiDimensionProperty)或空间缓动动画属性(SpatialProperty)时,则该属性对应的属性标识信息至少包括内容标识位。同样地,当动画数据中与该属性对应的属性值为默认值时,则动态属性数据块中不需要存储实际的属性值,只需要将内容标识位编码成表示该属性值为默认值的值即可,该值可以是0,在解码阶段解析到该值时说明动态属性数据块中不存在与属性对应的属性内容,只需要将该属性对应的默认值作为相应的属性内容即可。Specifically, when the property type corresponding to the property is a simple animation property (SimpleProperty), a discrete animation property (DiscreteProperty), a multi-dimensional time slow-motion animation property (MultiDimensionProperty) or a spatial slow-motion animation property (SpatialProperty), the property identification information corresponding to the property at least includes a content identification bit. Similarly, when the property value corresponding to the property in the animation data is a default value, the actual property value does not need to be stored in the dynamic property data block, and it is only necessary to encode the content identification bit into a value indicating that the property value is a default value, which can be 0. When this value is parsed in the decoding stage, it means that there is no property content corresponding to the property in the dynamic property data block, and it is only necessary to use the default value corresponding to the property as the corresponding property content.

当动画数据中与该属性对应的属性值不是默认值时,则动态属性数据块中需要存储实际的属性值,则将内容标识位编码成表示动态属性数据块中存在与该属性对应的属性内容的值,该值可以是1。当内容标识位为1时,则该属性标识信息至少还包括动画区间标识位,也就是属性标识信息至少占用2个比特位。动画区间标识位用于表示该属性对应的属性值是否包括动画区间特效数据。在解码阶段,在读取到内容标识位的值表示动态属性数据块中存在属性对应的属性内容时,则读取内容标识位下一比特位的值,作为动画区间标识位的值。When the attribute value corresponding to the attribute in the animation data is not the default value, the actual attribute value needs to be stored in the dynamic attribute data block, and the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block, and the value can be 1. When the content identification bit is 1, the attribute identification information also includes at least the animation interval identification bit, that is, the attribute identification information occupies at least 2 bits. The animation interval identification bit is used to indicate whether the attribute value corresponding to the attribute includes animation interval special effects data. In the decoding stage, when the value of the content identification bit is read to indicate that the attribute content corresponding to the attribute exists in the dynamic attribute data block, the value of the next bit of the content identification bit is read as the value of the animation interval identification bit.

在一个实施例中,属性标识信息还包括动画区间标识位;当内容标识位的值表示动态属性数据块中存在与属性对应的属性内容时,方法还包括:若属性值包括动画区间特性数据时,则将动画区间标识位编码成表示动态属性数据块中存储的与属性对应的属性内容包括动画区间特性数据的值;若属性值不包括动画区间特性数据时,则将动画区间标识位编码成表示动态属性数据块中存储的与属性对应的属性内容不包括动画区间特性数据的值。In one embodiment, the attribute identification information also includes an animation interval identification bit; when the value of the content identification bit indicates that there is attribute content corresponding to the attribute in the dynamic attribute data block, the method also includes: if the attribute value includes animation interval characteristic data, then the animation interval identification bit is encoded into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes the animation interval characteristic data; if the attribute value does not include the animation interval characteristic data, then the animation interval identification bit is encoded into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the animation interval characteristic data.

其中,动画区间特性数据是动画数据的基本单位,大部分动画数据的属性都包括动画区间特性数据。若该属性对应的属性值包括动画区间特性数据,动画区间特性数据描述了多个动画区间在该属性上对应的动画数据,每个动画区间对应了一段时间轴,每个动画区间的动画特性数据描述了属性在某一个时间轴上的变化关系,实际上也是描述了与该时间轴对应的各个动画帧对应该属性的变化关系。该关系可以是线性关系、呈贝塞尔曲线关系或是静止关系(即一个时间轴内在该属性上对应的属性值保持不变)。Among them, animation interval characteristic data is the basic unit of animation data, and most of the attributes of animation data include animation interval characteristic data. If the attribute value corresponding to the attribute includes animation interval characteristic data, the animation interval characteristic data describes the animation data corresponding to multiple animation intervals on the attribute, and each animation interval corresponds to a time axis. The animation characteristic data of each animation interval describes the change relationship of the attribute on a certain time axis, which actually describes the change relationship of each animation frame corresponding to the time axis corresponding to the attribute. The relationship can be a linear relationship, a Bezier curve relationship, or a static relationship (that is, the attribute value corresponding to the attribute in a time axis remains unchanged).

在一个实施例中,按照属性标识信息,对动画数据中与各属性对应的属性值进行编码,得到各属性对应的属性内容,包括:若动画区间标识位的值表示动态属性数据块中存储的与属性对应的属性内容不包括动画区间特性数据,则直接根据属性对应的数据类型,对动画数据中与属性对应的属性值进行编码,得到属性对应的属性内容。In one embodiment, the attribute value corresponding to each attribute in the animation data is encoded according to the attribute identification information to obtain the attribute content corresponding to each attribute, including: if the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the animation interval characteristic data, then the attribute value corresponding to the attribute in the animation data is encoded directly according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute.

具体地,属性对应的属性值中动画区间的数量可以是0到多个,当数量为0个时,表示该属性只包括一个有效值,说明该属性对应的属性值不包括动画区间特性数据,则需要将动画区间标识位编码成表示动态属性数据块中存储的与该属性对应的属性内容不包括动画区间特性数据的值,该值可以是0。在这种情况下,确定该属性对应的属性标识信息为“10”,在编码该属性对应属性值时,直接根据该属性对应的数据类型对属性值进行编码,得到该属性对应的属性内容。Specifically, the number of animation intervals in the attribute value corresponding to the attribute can be 0 or more. When the number is 0, it means that the attribute only includes one valid value, indicating that the attribute value corresponding to the attribute does not include animation interval characteristic data. Then, the animation interval identification bit needs to be encoded into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include animation interval characteristic data. The value can be 0. In this case, the attribute identification information corresponding to the attribute is determined to be "10". When encoding the attribute value corresponding to the attribute, the attribute value is directly encoded according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute.

在一个实施例中,按照属性标识信息,对动画数据中与各属性对应的属性值进行编码,得到各属性对应的属性内容,包括:若动画区间标识位的值表示动态属性数据块中存储的与属性对应的属性内容包括动画区间特性数据,则按照动画区间特性数据对应的数据存储结构,对属性对应的动画区间特性数据进行编码,得到与属性对应的属性内容。In one embodiment, the attribute values corresponding to each attribute in the animation data are encoded according to the attribute identification information to obtain the attribute content corresponding to each attribute, including: if the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data, then according to the data storage structure corresponding to the animation interval characteristic data, the animation interval characteristic data corresponding to the attribute is encoded to obtain the attribute content corresponding to the attribute.

具体地,属性对应的属性值中动画区间的数量为1个或多个时,则需要将动画区间标识位编码成表示动态属性数据块中存储的与该属性对应的属性内容包括动画区间特性数据的值,该值可以是1。在这种情况下,需要按照动画区间的数据结构记录下每个动画区间对应的特性数据,并且按照多个动画区间特性数据的数据存储结构(property存储结构)对各个动画区间的特性数据进行编码,得到该属性对应的属性内容。下表给出了一个动画区间所要记录的信息:Specifically, when the number of animation intervals in the attribute value corresponding to the attribute is 1 or more, the animation interval identification bit needs to be encoded into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes the animation interval characteristic data, and the value can be 1. In this case, it is necessary to record the characteristic data corresponding to each animation interval according to the data structure of the animation interval, and encode the characteristic data of each animation interval according to the data storage structure (property storage structure) of multiple animation interval characteristic data to obtain the attribute content corresponding to the attribute. The following table gives the information to be recorded for an animation interval:

一个动画区间包含了每个区间的起始和结束时间,还包括起始时间对应的属性值、结束时间对应的属性值,还包括标识属性值计算方法的插值器类型、时间缓动参数等。对于属性类型为多维时间缓动属性的属性而言,它的动画区间还有可能包含多维度的时间缓动参数;对于属性类型为空间缓动动画属性的属性而言,动画区间还可能包含空间缓动参数。startValue、endValue表示这个动画区间的起始值和结束值,对应的startTime和endTime表示这个动画区间的起始时刻和结束时刻,所以当时刻取值等于startTime时,对应的属性值为startValue,当时刻取值等于endTime时,对应的属性值为endValue,而在startTime和endTime之间的时刻,属性的取值是由插值器类型来决定的。根据动画文件中动画特性数据的特性,定义的插值器类型如下表所示:An animation interval includes the start and end time of each interval, as well as the attribute value corresponding to the start time, the attribute value corresponding to the end time, the interpolator type that identifies the attribute value calculation method, time easing parameters, etc. For attributes whose attribute type is a multi-dimensional time easing attribute, its animation interval may also contain multi-dimensional time easing parameters; for attributes whose attribute type is a spatial easing animation attribute, the animation interval may also contain spatial easing parameters. startValue and endValue represent the start and end values of this animation interval, and the corresponding startTime and endTime represent the start and end times of this animation interval. Therefore, when the time value is equal to startTime, the corresponding attribute value is startValue, and when the time value is equal to endTime, the corresponding attribute value is endValue. At the time between startTime and endTime, the value of the attribute is determined by the interpolator type. According to the characteristics of the animation feature data in the animation file, the defined interpolator types are shown in the following table:

结合动画区间的数据结构可以看出,当插值器类型的值不等于2(Bezier)时,可以不需要存储动画区间的时间缓动参数bezierOut和bezierIn。当属性类型是离散缓动动画属性时,表示插值器类型的值一定是3(Hold),或者默认是3,就不需要存储插值器类型的值,这种情况通常出现在属性的基础数据类型是布尔类型或者枚举类型时,它的数据是离散的,要么是true要么是false,true和false之间不可能出现中间插值。当属性类型是多维时间缓动动画属性时,表示时间缓动参数是多条贝塞尔曲线组成,每条贝塞尔曲线单独控制数据值的一个分量缓动。dimensionality表示每个动画区间的时间缓动参数数组是几维的,具体是多少条贝塞尔曲线,是根据startValue和endValue的数据类型来确认,例如当数据类型是Point,时间缓动参数就是2维数组,dimensionality为2,两条贝塞尔曲线分别控制x轴、y轴的独立缓动,也就是说Point数据类型中x轴坐标的值由两条贝塞尔曲线控制,y轴坐标的值也是由两条贝塞尔曲线控制。对于大部分不是多维时间缓动动画属性的情况,不需要根据基础数据类型判断维度,默认只存储一维时间缓动参数,即dimensionality始终为1。当属性类型是空间缓动动画属性时,表示动画区间可能存在空间缓动参数,这时候具体要根据空间缓动参数标识位来判断实际当前动画区间是否存在这部分参数。Combined with the data structure of the animation interval, it can be seen that when the value of the interpolator type is not equal to 2 (Bezier), it is not necessary to store the time easing parameters bezierOut and bezierIn of the animation interval. When the attribute type is a discrete easing animation attribute, it means that the value of the interpolator type must be 3 (Hold), or the default is 3, so there is no need to store the value of the interpolator type. This usually occurs when the basic data type of the attribute is a Boolean type or an enumeration type. Its data is discrete, either true or false, and there is no possibility of intermediate interpolation between true and false. When the attribute type is a multi-dimensional time easing animation attribute, it means that the time easing parameters are composed of multiple Bezier curves, and each Bezier curve controls the easing of a component of the data value separately. Dimensionality indicates the dimension of the time easing parameter array for each animation interval, and specifically how many Bezier curves there are. This is determined based on the data types of startValue and endValue. For example, when the data type is Point, the time easing parameter is a 2D array, and dimensionality is 2. The two Bezier curves control the independent easing of the x-axis and y-axis respectively, which means that the value of the x-axis coordinate in the Point data type is controlled by two Bezier curves, and the value of the y-axis coordinate is also controlled by two Bezier curves. For most cases that are not multi-dimensional time easing animation attributes, there is no need to determine the dimension based on the basic data type. By default, only one-dimensional time easing parameters are stored, that is, dimensionality is always 1. When the attribute type is a spatial easing animation attribute, it means that there may be spatial easing parameters in the animation interval. At this time, it is necessary to determine whether these parameters exist in the actual current animation interval based on the spatial easing parameter flag.

当属性对应的动画区间标识位为1时,则该属性标识信息至少还包括空间缓动参数标识位,也就是属性标识信息占用3个比特位。空间缓动参数标识位用于表示该属性对应的属性值是否包括空间缓动参数。在解码阶段,在读取到动画区间标识位的值表示动态属性数据块中存储的与属性对应的属性内容包括动画区间特性数据时,则继续读取动画区间标识位下一比特位的值,作为空间缓动参数标识位的值。When the animation interval identification bit corresponding to the attribute is 1, the attribute identification information also includes at least the spatial easing parameter identification bit, that is, the attribute identification information occupies 3 bits. The spatial easing parameter identification bit is used to indicate whether the attribute value corresponding to the attribute includes spatial easing parameters. In the decoding stage, when the value of the animation interval identification bit is read to indicate that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data, the value of the next bit of the animation interval identification bit is read as the value of the spatial easing parameter identification bit.

在一个实施例中,属性对应的属性类型为空间缓动动画属性,属性标识信息还包括空间缓动参数标识位;当动画区间标识位的值表示动态属性数据块中存储的与属性对应的属性内容包括动画区间特性数据时,方法还包括:若动画区间特性数据包括空间缓动参数,则将空间缓动参数标识位编码成动态属性数据块中存储的与属性对应的属性内容包括空间缓动参数的值;若动画区间特性数据不包括空间缓动参数时,则将空间缓动参数标识位编码成动态属性数据块中存储的与属性对应的属性内容不包括空间缓动参数的值。In one embodiment, the attribute type corresponding to the attribute is a spatial easing animation attribute, and the attribute identification information also includes a spatial easing parameter identification bit; when the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data, the method also includes: if the animation interval characteristic data includes the spatial easing parameter, then the spatial easing parameter identification bit is encoded into the attribute content corresponding to the attribute stored in the dynamic attribute data block including the value of the spatial easing parameter; if the animation interval characteristic data does not include the spatial easing parameter, then the spatial easing parameter identification bit is encoded into the attribute content corresponding to the attribute stored in the dynamic attribute data block not including the value of the spatial easing parameter.

其中,空间缓动参数是用于描述复杂动效的参数。只有当属性对应的属性类型为空间缓动动画属性时,该属性对应的属性标识信息才可能占用三个比特位,并且存在空间缓动参数标识位的前提是内容标识位、动画区间标识位均为1。而对于其它属性类型,都不需要判断是否存在第三个标识位,也不需要存储空间缓动参数。Among them, the spatial easing parameter is a parameter used to describe complex animation effects. Only when the attribute type corresponding to the attribute is a spatial easing animation attribute, the attribute identification information corresponding to the attribute may occupy three bits, and the premise for the existence of the spatial easing parameter identification bit is that the content identification bit and the animation interval identification bit are both 1. For other attribute types, there is no need to determine whether there is a third identification bit, nor is there a need to store the spatial easing parameter.

在一个实施例中,按照属性标识信息,对动画数据中与各属性对应的属性值进行编码,得到各属性对应的属性内容,包括:当空间缓动参数标识位的值表示动态属性数据块中存储的与属性对应的属性内容包括空间缓动参数时,则按照动画区间特性数据对应的数据存储结构,对属性对应的动画区间特性数据进行编码,得到与属性对应的包括空间缓动参数的属性内容。In one embodiment, the attribute values corresponding to each attribute in the animation data are encoded according to the attribute identification information to obtain the attribute content corresponding to each attribute, including: when the value of the spatial easing parameter identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes the spatial easing parameter, then according to the data storage structure corresponding to the animation interval characteristic data, the animation interval characteristic data corresponding to the attribute is encoded to obtain the attribute content corresponding to the attribute including the spatial easing parameter.

具体地,动画区间特性数据包括空间缓动参数,则将空间缓动参数标识位编码成动态属性数据块中存储的与属性对应的属性内容包括空间缓动参数的值,该值可以是1。在这种情况下,确定该属性对应的属性标识信息为“111”,在编码该属性对应的属性值时,需要按照动画区间特性数据对应的数据存储结构对该属性对应的动画区间特性数据进行编码,得到该属性对应的属性内容。Specifically, if the animation interval characteristic data includes a spatial easing parameter, the spatial easing parameter identification bit is encoded into the attribute content corresponding to the attribute stored in the dynamic attribute data block, including the value of the spatial easing parameter, which may be 1. In this case, the attribute identification information corresponding to the attribute is determined to be "111", and when encoding the attribute value corresponding to the attribute, the animation interval characteristic data corresponding to the attribute needs to be encoded according to the data storage structure corresponding to the animation interval characteristic data to obtain the attribute content corresponding to the attribute.

在一个实施例中,所述按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各属性对应的属性内容,包括:当空间缓动参数标识位的值表示动态属性数据块中存储的与属性对应的属性内容不包括空间缓动参数时,则按照动画区间特性数据对应的数据存储结构,对属性对应的动画区间特性数据进行编码,得到与属性对应的不包括空间缓动参数的属性内容。In one embodiment, the attribute values corresponding to each attribute in the animation data are encoded according to the attribute identification information to obtain the attribute content corresponding to each attribute, including: when the value of the spatial easing parameter identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the spatial easing parameters, then according to the data storage structure corresponding to the animation interval characteristic data, the animation interval characteristic data corresponding to the attribute is encoded to obtain the attribute content corresponding to the attribute that does not include the spatial easing parameters.

具体地,动画区间特性数据不包括空间缓动参数,则将空间缓动参数标识位编码成动态属性数据块中存储的与属性对应的属性内容不包括空间缓动参数的值,该值可以是0。在这种情况下,确定该属性对应的属性标识信息为“110”,在编码该属性对应的属性值时,需要按照动画区间特性数据对应的数据存储结构对该属性对应的动画区间特性数据进行编码,得到的属性内容不包括空间缓动参数。Specifically, if the animation interval characteristic data does not include the spatial easing parameter, the spatial easing parameter identification bit is encoded into a value in which the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the spatial easing parameter, and the value may be 0. In this case, the attribute identification information corresponding to the attribute is determined to be "110", and when encoding the attribute value corresponding to the attribute, the animation interval characteristic data corresponding to the attribute needs to be encoded according to the data storage structure corresponding to the animation interval characteristic data, and the obtained attribute content does not include the spatial easing parameter.

在一个实施例中,动画区间特性数据对应的数据存储结构所包括的字段包括动画区间数量、各动画区间的插值器类型、各动画区间的起始和结束时间,还包括各动画区间对应属性的起始值、结束值、时间缓动参数和空间缓动参数。In one embodiment, the fields included in the data storage structure corresponding to the animation interval characteristic data include the number of animation intervals, the interpolator type of each animation interval, the start and end time of each animation interval, and the start value, end value, time easing parameter and space easing parameter of the corresponding attribute of each animation interval.

动画区间特性数据对应的数据存储结构如下表所示:The data storage structure corresponding to the animation interval characteristic data is shown in the following table:

从上表给出的动画区间特性数据的数据存储结构(也称之为Property存储结构)可以看出,实际在存储多个动画区间的动画特性数据时,是依次存储每个动画区间的一类数据后再集中存储下一类数据,而不是先存储完一个动画区间的所有数据后再存储下一个动画区间的所有数据,这样做的好处是相似的数据可以集中存储并且可以集中压缩,减小存储空间。比如,插值器类型的值通常只会占用2个比特位,集中存储可以减少因字节对齐产生的额外空间浪费。又比如,下一个动画区间的startValue和startTime总等于上一个动画区间的endValue和endTime,集中存储也可以跳过不需要存储的动画区间之间重复的数据,可以进一步压缩存储空间。From the data storage structure (also called Property storage structure) of the animation interval characteristic data given in the table above, it can be seen that when storing the animation characteristic data of multiple animation intervals, one type of data for each animation interval is stored in turn and then the next type of data is stored in a centralized manner, rather than storing all the data of one animation interval first and then storing all the data of the next animation interval. The advantage of this is that similar data can be stored and compressed in a centralized manner, reducing storage space. For example, the value of the interpolator type usually only occupies 2 bits. Centralized storage can reduce the extra space waste caused by byte alignment. For another example, the startValue and startTime of the next animation interval are always equal to the endValue and endTime of the previous animation interval. Centralized storage can also skip the repeated data between animation intervals that do not need to be stored, which can further compress the storage space.

需要注意的是,在解码按照动画特性数据对应的数据存储结构存储的数据时,每个字段的数据值读取结束要进行一次字节对齐,跳过没读取完的剩余比特位,从下一个整数字节位置开始,再读取下一个字段对应的数据值。It should be noted that when decoding data stored in the data storage structure corresponding to the animation characteristic data, byte alignment must be performed after reading the data value of each field, skipping the remaining bits that have not been read, starting from the next integer byte position, and then reading the data value corresponding to the next field.

上表中提到,动画区间特性数据中动画区间的起始值和结束值(PropertyValue)可以有不同的数据类型,不同的数据类型对应了不同的存储方式。在PAG文件中,动画区间的起始值和结束值一共有15种类型,每种类型的编码方式如下表所示:As mentioned in the table above, the start value and end value (PropertyValue) of the animation interval in the animation interval property data can have different data types, and different data types correspond to different storage methods. In the PAG file, there are 15 types of start value and end value of the animation interval, and the encoding method of each type is shown in the following table:

从上表可以看出,动画区间的起始值和结束值的数据类型可以是上述15种中的任意一种。在前面给出的动画区间特性数据对应的存储结构中,valueList存储的是多个动画区间的起始值和结束值,其数据类型为PropertyValueList。对于PropertyValueList,实质上是转换成一个个的PropertyValue来存储。例如:Value<Float>[]的存储结构是一个连续的Value<Float>,而Value<Float>的数据类型又是Float类型,所以Value<Float>[]实质上是一组连续的Float类型的数值。也有转换成其他类型方式存储的,例如:Value<Uint8>[]的数据类型则是转成了连续无符号整数编码方式(UB[nBits][])存储。PropertyValueList的存储方式如下表所示:As can be seen from the above table, the data type of the start value and end value of the animation interval can be any of the 15 types mentioned above. In the storage structure corresponding to the animation interval characteristic data given above, valueList stores the start value and end value of multiple animation intervals, and its data type is PropertyValueList. For PropertyValueList, it is actually converted into one PropertyValue for storage. For example: the storage structure of Value<Float>[] is a continuous Value<Float>, and the data type of Value<Float> is Float type, so Value<Float>[] is actually a group of continuous Float type values. There are also conversions to other types of storage, for example: the data type of Value<Uint8>[] is converted to a continuous unsigned integer encoding method (UB[nBits][]) for storage. The storage method of PropertyValueList is shown in the following table:

在前面给出的动画区间特性数据对应的存储结构中,timeEaseList存储的是多个动画区间的时间缓动参数,其数据类型为TimeEaseValueList。TimeEaseValueList的数据结构如下表所示:In the storage structure corresponding to the animation interval characteristic data given above, timeEaseList stores the time easing parameters of multiple animation intervals, and its data type is TimeEaseValueList. The data structure of TimeEaseValueList is shown in the following table:

由于每个动画区间的时间缓动参数是一对控制点,每个控制点的数据类型为Point类型,因此,多个动画区间的时间缓动参数的编码方式可以如图10所示。参照图10,TimeEaseValueList的存储方式中,先存储时间缓动参数数组中的元素占用的比特位数timeEaseNumBits,然后依次编码各个动画区间的时间缓动参数,dimensionality表示每个动画区间的bezierIn和bezierOut数组是几维的。当dimensionality的值等于1时,每个动画区间的时间缓动参数是1对bezierOut(x,y)、bezierIn(x,y),是两个Point类型的值(4个Float类型),每个Float值按照SB[timeEaseNumBits]进行编码。当dimensionality的值等于2时,则包括2对bezierOut、bezierIn的值,共8个Float类型的值。除timeEasenumBits的值外,整个TimeEaseValueList需要存储numFrames*dimensionality*4个数据值。Since the time easing parameter of each animation interval is a pair of control points, and the data type of each control point is Point type, the encoding method of the time easing parameters of multiple animation intervals can be shown in Figure 10. Referring to Figure 10, in the storage method of TimeEaseValueList, the number of bits occupied by the elements in the time easing parameter array, timeEaseNumBits, is first stored, and then the time easing parameters of each animation interval are encoded in sequence. Dimensionality indicates the dimensions of the bezierIn and bezierOut arrays of each animation interval. When the value of dimensionality is equal to 1, the time easing parameter of each animation interval is a pair of bezierOut(x,y) and bezierIn(x,y), which are two Point type values (4 Float types), and each Float value is encoded according to SB[timeEaseNumBits]. When the value of dimensionality is equal to 2, it includes 2 pairs of bezierOut and bezierIn values, a total of 8 Float type values. In addition to the value of timeEasenumBits, the entire TimeEaseValueList needs to store numFrames*dimensionality*4 data values.

需要注意的是,在解码时,如果关键帧的插值器类型不是Bezier,那么直接跳过TimeEase相关数据的读取。bezierOut、bezierIn坐标成对连续存储,先编码bezierOut坐标,后编码bezierIn坐标。It should be noted that when decoding, if the interpolator type of the key frame is not Bezier, then the reading of TimeEase related data is skipped directly. The bezierOut and bezierIn coordinates are stored in pairs continuously, and the bezierOut coordinates are encoded first, and then the bezierIn coordinates are encoded.

在解码timeEaseList的值时,先读取5个比特位,得到timeEaseNumBits,然后再每隔timeEaseNumBits个比特位读取出的值分别为各个动画区间的bezierOut、bezierIn的坐标,读取numFrames*dimensionality*4次,得到该属性对应的时间缓动参数数组。When decoding the value of timeEaseList, first read 5 bits to get timeEaseNumBits, then read the values every timeEaseNumBits bits as the coordinates of bezierOut and bezierIn of each animation interval, read numFrames*dimensionality*4 times, and get the time easing parameter array corresponding to this attribute.

同样地,在前面给出的动画区间特性数据对应的存储结构中,spatialEaseList存储的是多个动画区间的空间缓动参数,其数据类型为SpatialEaseValueList。SpatialEaseValueList的数据结构如下表所示:Similarly, in the storage structure corresponding to the animation interval characteristic data given above, spatialEaseList stores the spatial easing parameters of multiple animation intervals, and its data type is SpatialEaseValueList. The data structure of SpatialEaseValueList is shown in the following table:

由于每个动画区间的空间缓动参数是一对控制点,每个控制点的数据类型为Point类型,因此,多个动画区间的空间缓动参数的编码方式可以如图11所示。参照图11,SpatialEaseValueList的存储方式中,先用连续个比特位来标识每个动画区间是否含有空间缓动参数,然后在编码空间缓动参数数组中的元素占用的比特位数spatialEaseNumBits,再依次编码各个动画区间的空间缓动参数。在解码阶段,空间缓动参数的读取需要依赖读取出的spatialFlagList列表以及spatialEaseNumBits。spatialFlagList的长度是动画区间数量的两倍,因为每个动画区间的空间缓动参数含有两个Point类型数据。spatialFlagList列表里的值依次表示每个动画区间的spatialIn和spatialOut是否存在。如果不存在,则spatialIn、spatialOut的坐标值均使用默认值(0,0)。另外,读取出来的数据为整型,需要乘以SPATIAL_PRECISION转换为Float后作为Point的x、y的值。Since the spatial easing parameters of each animation interval are a pair of control points, and the data type of each control point is Point type, the encoding method of the spatial easing parameters of multiple animation intervals can be shown in Figure 11. Referring to Figure 11, in the storage method of SpatialEaseValueList, consecutive bits are first used to identify whether each animation interval contains spatial easing parameters, and then the number of bits occupied by the elements in the encoding spatial easing parameter array is spatialEaseNumBits, and then the spatial easing parameters of each animation interval are encoded in turn. In the decoding stage, the reading of spatial easing parameters depends on the read spatialFlagList list and spatialEaseNumBits. The length of spatialFlagList is twice the number of animation intervals, because the spatial easing parameters of each animation interval contain two Point type data. The values in the spatialFlagList list indicate whether spatialIn and spatialOut of each animation interval exist in turn. If not, the coordinate values of spatialIn and spatialOut use the default value (0, 0). In addition, the data read out is an integer and needs to be multiplied by SPATIAL_PRECISION to convert it to Float and then used as the x and y values of Point.

需要说明的是,spatialInFlag与spatialOutFlag成对连续存储,先存储spatialInFlag,后存储spatialOutFlag。floatNum的值也就是空间缓动参数数组的长度取决于spatialInFlag与spatialOutFlag标识。如果spatialInFlag为1,那么继续读取spatialInPoint的x,y坐标,spatialInFlag为0则坐标Point的x,y坐标为默认值,无需读取。SpatialIn、spatialOut按顺序存储,先存储spatialIn坐标,后存储spatialOut坐标。It should be noted that spatialInFlag and spatialOutFlag are stored in pairs, first storing spatialInFlag and then storing spatialOutFlag. The value of floatNum, that is, the length of the spatial easing parameter array, depends on the spatialInFlag and spatialOutFlag flags. If spatialInFlag is 1, then continue to read the x, y coordinates of spatialInPoint. If spatialInFlag is 0, the x, y coordinates of the coordinate Point are the default values and do not need to be read. SpatialIn and spatialOut are stored in order, first storing the spatialIn coordinates and then storing the spatialOut coordinates.

在解码spatialEaseList的值时,先读取numFrames*2个比特位,得到spatialFlagList的值,然后再读取5个比特位,得到spatialEaseNumBits的值,接着按照spatialFlagList的值每隔spatialEaseNumBits个比特位读取数据,得到的就是存在空间缓动参数的动画区间的空间缓动参数。When decoding the value of spatialEaseList, first read numFrames*2 bits to get the value of spatialFlagList, then read 5 bits to get the value of spatialEaseNumBits, and then read data every spatialEaseNumBits bits according to the value of spatialFlagList to get the spatial easing parameters of the animation interval where the spatial easing parameters exist.

S808,根据属性结构表中各属性对应的属性排序,将各属性对应的属性标识信息、属性内容依次存储,得到动画标签码对应的动态属性数据块。S808, according to the attribute sorting corresponding to each attribute in the attribute structure table, the attribute identification information and attribute content corresponding to each attribute are stored in sequence to obtain a dynamic attribute data block corresponding to the animation tag code.

经过前面的分析可以得出以下结论:The following conclusions can be drawn from the previous analysis:

属性类型为普通属性,当属性对应的属性标识信息为“1”时,则直接按照该属性对应的数据类型对相应的属性值进行编码,得到属性内容;当属性对应的属性标识信息为“0”时,则相应的属性值为默认值,无需对相应的属性值进行编码,动态属性数据块中不存在相应的属性内容。The attribute type is a common attribute. When the attribute identification information corresponding to the attribute is "1", the corresponding attribute value is directly encoded according to the data type corresponding to the attribute to obtain the attribute content; when the attribute identification information corresponding to the attribute is "0", the corresponding attribute value is the default value, and there is no need to encode the corresponding attribute value. The corresponding attribute content does not exist in the dynamic attribute data block.

属性类型为布尔属性,当属性对应的属性标识信息为“1”时,则代表属性对应的属性值为“true”,无需对相应的属性值进行编码,动态属性数据块中不存在相应的属性内容;同理,当属性对应的属性标识信息为“0”时,则代表属性对应的属性值为“false”。The attribute type is a Boolean attribute. When the attribute identification information corresponding to the attribute is "1", it means that the attribute value corresponding to the attribute is "true". There is no need to encode the corresponding attribute value, and the corresponding attribute content does not exist in the dynamic attribute data block. Similarly, when the attribute identification information corresponding to the attribute is "0", it means that the attribute value corresponding to the attribute is "false".

属性类型为固定属性,不存在相应的属性标识信息,直接将对应的属性值按照相应的数据类型编码后得到属性内容。The attribute type is a fixed attribute, and there is no corresponding attribute identification information. The attribute content is obtained by directly encoding the corresponding attribute value according to the corresponding data type.

属性类型为简单动画属性、离散动画属性、多维时间缓动动画属性,当属性对应的属性标识信息为“0”时,则相应的属性值为默认值,无需对相应的属性值进行编码,动态属性数据块中不存在相应的属性内容;当属性对应的属性标识信息为“10”时,则相应的属性值不是默认值、且不包括动画区间特性数据,需要按照该属性对应数据类型正常编码后得到属性内容;当属性对应的属性标识信息为“11”时,则相应的属性值不是默认值、且包括动画区间特性数据,需要按照动画区间特性数据的数据存储结构进行编码后得到属性内容。The attribute type is simple animation attribute, discrete animation attribute, and multi-dimensional time easing animation attribute. When the attribute identification information corresponding to the attribute is "0", the corresponding attribute value is the default value, and there is no need to encode the corresponding attribute value. The corresponding attribute content does not exist in the dynamic attribute data block; when the attribute identification information corresponding to the attribute is "10", the corresponding attribute value is not the default value and does not include animation interval characteristic data. It is necessary to obtain the attribute content after normal encoding according to the data type corresponding to the attribute; when the attribute identification information corresponding to the attribute is "11", the corresponding attribute value is not the default value and includes animation interval characteristic data. It is necessary to obtain the attribute content after encoding according to the data storage structure of the animation interval characteristic data.

属性类型为空间缓动动画属性,当属性对应的属性标识信息为“0”时,则相应的属性值为默认值,无需对相应的属性值进行编码,动态属性数据块中不存在相应的属性内容;当属性对应的属性标识信息为“10”时,则相应的属性值不是默认值、且不包括动画区间特性数据,需要按照该属性对应数据类型正常编码后得到属性内容;当属性对应的属性标识信息为“110”时,则相应的属性值不是默认值、且包括动画区间特性数据、且不包括空间缓动参数,需要按照动画区间特性数据的数据存储结构进行编码后得到不包括空间缓动参数的属性内容;当属性对应的属性标识信息为“111”时,则相应的属性值不是默认值、且包括动画区间特性数据、且包括空间缓动参数,需要按照动画区间特性数据的数据存储结构进行编码后得到包括空间缓动参数的属性内容。The attribute type is a spatial easing animation attribute. When the attribute identification information corresponding to the attribute is "0", the corresponding attribute value is the default value, and there is no need to encode the corresponding attribute value. The corresponding attribute content does not exist in the dynamic attribute data block; when the attribute identification information corresponding to the attribute is "10", the corresponding attribute value is not the default value and does not include animation interval characteristic data. It is necessary to encode it normally according to the data type corresponding to the attribute to obtain the attribute content; when the attribute identification information corresponding to the attribute is "110", the corresponding attribute value is not the default value, and includes animation interval characteristic data, and does not include spatial easing parameters. It is necessary to encode it according to the data storage structure of animation interval characteristic data to obtain the attribute content that does not include spatial easing parameters; when the attribute identification information corresponding to the attribute is "111", the corresponding attribute value is not the default value, and includes animation interval characteristic data and spatial easing parameters. It is necessary to encode it according to the data storage structure of animation interval characteristic data to obtain the attribute content including spatial easing parameters.

动画标签码对应的属性结构表中包括多个属性,对于每个属性,都可以将动画数据中与各属性对应的属性值进行编码,也就是按照每个属性的属性标识信息、属性类型进行编码,得到相应的属性内容,最后将每个属性的属性标识信息按属性排序存储在一起得到属性标识区域、将每个属性的属性内容按属性排序存储在一起得到属性内容区域,动画标签码对应的属性标识区域、属性内容区域就构成了整个动画标签码对应的动态属性数据块。实质上,动态属性数据块就是该动画标签码(TagCode)所在的节点元素(Tag)的节点元素内容(TagBody)的值。The attribute structure table corresponding to the animation tag code includes multiple attributes. For each attribute, the attribute value corresponding to each attribute in the animation data can be encoded, that is, the attribute identification information and attribute type of each attribute are encoded to obtain the corresponding attribute content. Finally, the attribute identification information of each attribute is stored together in attribute order to obtain the attribute identification area, and the attribute content of each attribute is stored together in attribute order to obtain the attribute content area. The attribute identification area and attribute content area corresponding to the animation tag code constitute the dynamic attribute data block corresponding to the entire animation tag code. In essence, the dynamic attribute data block is the value of the node element content (TagBody) of the node element (Tag) where the animation tag code (TagCode) is located.

上述动画数据编码方法,动画标签码可用于标识一组属性,属性结构表用于描述动画标签码所标识的一组属性的数据结构,当这一组属性的属性值从种类或数量都不确定,或者当属性的属性值存在大量冗余时,为了避免额外引入大量的用于描述属性种类或数量的标识符字段导致动画文件体积太大的问题,引入了动态属性数据块的数据结构,可以最大化压缩这些标识符,大大减小目标动画文件占用的体积。具体地,在获取到动画工程文件后,按照动画标签码对应的属性结构表所包括的一组属性,从动画工程文件中获取这一组属性的属性值,动态属性数据块中的属性标识信息用于描述属性的属性状态,当属性结构表中存在属性类型时,可以根据动画数据确定各个属性对应的属性标识信息,再按照属性标识信息对各属性对应的属性值进行动态编码得到对应的属性内容,结合属性结构表中各属性的属性标识信息和属性内容得到动画标签码对应的动态属性数据块,可以显著减少动画文件占用的空间。In the above-mentioned animation data encoding method, the animation tag code can be used to identify a group of attributes, and the attribute structure table is used to describe the data structure of a group of attributes identified by the animation tag code. When the attribute values of this group of attributes are uncertain in terms of type or quantity, or when there is a large amount of redundancy in the attribute values of the attributes, in order to avoid the problem of introducing a large number of identifier fields for describing the type or quantity of the attributes, which leads to a large volume of the animation file, a data structure of a dynamic attribute data block is introduced, which can maximize the compression of these identifiers and greatly reduce the volume occupied by the target animation file. Specifically, after obtaining the animation project file, according to a group of attributes included in the attribute structure table corresponding to the animation tag code, the attribute values of this group of attributes are obtained from the animation project file, and the attribute identification information in the dynamic attribute data block is used to describe the attribute state of the attribute. When there is an attribute type in the attribute structure table, the attribute identification information corresponding to each attribute can be determined according to the animation data, and then the attribute values corresponding to each attribute can be dynamically encoded according to the attribute identification information to obtain the corresponding attribute content, and the dynamic attribute data block corresponding to the animation tag code is obtained by combining the attribute identification information and the attribute content of each attribute in the attribute structure table, which can significantly reduce the space occupied by the animation file.

在一个实施例中,动画标签码为位图合成标签码;从动画工程文件中获取与各动画标签码对应的动画数据,包括:播放动画工程文件;依次对动画工程文件对应的播放画面进行截图,得到动画工程文件对应的位图图像序列;按照位图序列帧导出方式对位图图像序列进行处理,得到位图合成标签码对应的图片二进制数据。In one embodiment, the animation tag code is a bitmap synthesis tag code; the animation data corresponding to each animation tag code is obtained from the animation project file, including: playing the animation project file; taking screenshots of the playback screens corresponding to the animation project file in sequence to obtain a bitmap image sequence corresponding to the animation project file; processing the bitmap image sequence according to the bitmap sequence frame export method to obtain image binary data corresponding to the bitmap synthesis tag code.

具体地,当采用位图序列帧方式对动画工程文件进行导出得到动画文件时,终端可以在播放动画工程文件的过程中,将动画工程文件对应的播放画面一帧帧截取成位图图像,得到对应的位图图像序列。在一个实施例中,可通过AE SDK的截图功能将动画工程文件的每一帧截取下来,得到每一帧对应的位图图像,从而得到整个动画工程文件对应的位图图像序列。其中,按照位图序列帧导出方式对位图图像序列进行处理,得到位图合成标签码对应的图片二进制数据包括:将位图图像序列中的位图图像与对应的关键位图图像进行像素对比,得到位图图像中的差异像素区域;当位图图像为非关键位图图像时,则按照图片编码方式对差异像素区域进行编码,得到位图图像对应的编码图片。编码图片即为每一位图图像对应的图片二进制数据。Specifically, when the animation project file is exported by the bitmap sequence frame method to obtain the animation file, the terminal can capture the playback screen corresponding to the animation project file frame by frame into a bitmap image during the process of playing the animation project file to obtain the corresponding bitmap image sequence. In one embodiment, each frame of the animation project file can be captured by the screenshot function of the AE SDK to obtain the bitmap image corresponding to each frame, thereby obtaining the bitmap image sequence corresponding to the entire animation project file. Among them, the bitmap image sequence is processed according to the bitmap sequence frame export method to obtain the image binary data corresponding to the bitmap synthesis label code, including: comparing the bitmap image in the bitmap image sequence with the corresponding key bitmap image pixel by pixel to obtain the difference pixel area in the bitmap image; when the bitmap image is a non-key bitmap image, the difference pixel area is encoded according to the image encoding method to obtain the encoded image corresponding to the bitmap image. The encoded image is the image binary data corresponding to each bitmap image.

实质上,当采用位图序列帧导出方式对动画工程文件进行导出得到动画文件时,需要获取位图合成标签码(BitmapCompositionBlock)对应的动画数据。该动画数据除了包括上述的图片二进制数据以外,还包括动画的一些基础属性数据,为此,定义的位图合成标签码的属性结构表如下表所示:In essence, when the animation project file is exported by bitmap sequence frame export method to obtain the animation file, it is necessary to obtain the animation data corresponding to the bitmap composition tag code (BitmapCompositionBlock). In addition to the above-mentioned image binary data, the animation data also includes some basic attribute data of the animation. For this purpose, the attribute structure table of the defined bitmap composition tag code is shown in the following table:

字段Fields 数据类型Data Types 备注Remark CompositionIDCompositionID EncodedUint32EncodedUint32 标识Logo CompositionAttributesCompositionAttributes CompositionAttributes TagCompositionAttributes Tag 合成基础属性Synthetic basic properties bitmapsequencesbitmapsequences BitmapSequence Tag[]BitmapSequence Tag[] 位图图像序列Bitmap image sequence

上表中,CompositionAttributes也是一个动画标签码,其对应的属性结构表如下表所示:In the above table, CompositionAttributes is also an animation tag code, and its corresponding attribute structure table is shown in the following table:

bitmapSequence也是一个动画标签码,其对应的属性结构表如下表所示:BitmapSequence is also an animation tag code, and its corresponding attribute structure table is shown in the following table:

从上面三个表可以看出,位图合成标签码所在的节点元素是一个嵌套的节点元素,其中嵌套了CompositionAttributes所在的节点元素以及bitmapsequence所在的节点元素。除了根据图片编码方式得到的图片二进制数据以外,位图合成标签码对应的动画数据还包括合成标识(CompositionID)、合成基础属性(CompositionAttributes)、位图图像序列(sequence),合成基础属性包括合成的播放时长、帧率和背景颜色,位图图像序列包括位图图像的宽、高、数目、关键帧标识以及图片二进制数据序列(bitmapRect[frameCount]),图片二进制序列包括每一位图图像对应的差异像素区域的宽、高、差异像素区域中起始像素点的坐标(x,y)、每一差异像素区域对应的图片二进制数据流(fileBytes)。As can be seen from the above three tables, the node element where the bitmap composition tag code is located is a nested node element, in which the node element where CompositionAttributes is located and the node element where bitmapsequence is located are nested. In addition to the image binary data obtained according to the image encoding method, the animation data corresponding to the bitmap composition tag code also includes the composition identifier (CompositionID), the basic composition attributes (CompositionAttributes), and the bitmap image sequence (sequence). The basic composition attributes include the playback duration, frame rate, and background color of the composition. The bitmap image sequence includes the width, height, number, key frame identifier, and image binary data sequence (bitmapRect[frameCount]) of the bitmap image. The image binary sequence includes the width and height of the difference pixel area corresponding to each bitmap image, the coordinates (x, y) of the starting pixel point in the difference pixel area, and the image binary data stream (fileBytes) corresponding to each difference pixel area.

如图12所示,为位图序列帧编码方式对应的动画数据的编码结构图。参考图12,在编码时,先按照位图合成标签码对应的属性结构表中合成标识的数据类型编码CompositionID的值,然后按照CompositionAttributes的属性结构表依次编码基础属性数据,然后编码整个动画播放时的宽width、高height、帧率framerate,再用nBits个比特位记录接下来的每一帧是否为关键帧,再编码位图图像的总数目bitmapCount,最后依次编码位图图像序列(bitmapsequences)中每个位图图像对应的图片二进制数据,即差异像素区域中起始像素点的坐标的值(x,y)以及对应的图片二进制数据fileBytes。As shown in Figure 12, it is the encoding structure diagram of the animation data corresponding to the bitmap sequence frame encoding method. Referring to Figure 12, when encoding, first encode the value of CompositionID according to the data type of the composition identifier in the attribute structure table corresponding to the bitmap composition tag code, and then encode the basic attribute data in sequence according to the attribute structure table of CompositionAttributes, and then encode the width, height, and frame rate framerate during the entire animation playback, and then use nBits bits to record whether each subsequent frame is a key frame, and then encode the total number of bitmap images bitmapCount, and finally encode the image binary data corresponding to each bitmap image in the bitmap image sequence (bitmapsequences), that is, the coordinate value (x, y) of the starting pixel point in the difference pixel area and the corresponding image binary data fileBytes.

在一个实施例中,动画标签码为视频合成标签码;从动画工程文件中获取与各动画标签码对应的动画数据,包括:播放动画工程文件;依次对动画工程文件对应的播放画面进行截图,得到动画工程文件对应的位图图像序列;按照视频序列帧导出方式对位图图像序列进行处理,得到视频合成标签码对应的图片二进制数据。In one embodiment, the animation tag code is a video synthesis tag code; the animation data corresponding to each animation tag code is obtained from the animation project file, including: playing the animation project file; taking screenshots of the playback screens corresponding to the animation project file in turn to obtain a bitmap image sequence corresponding to the animation project file; processing the bitmap image sequence according to the video sequence frame export method to obtain image binary data corresponding to the video synthesis tag code.

其中,按照视频序列帧导出方式对位图图像序列进行处理,得到视频合成标签码对应的图片二进制数据包括:将位图图像划分成颜色通道位图和透明度通道位图;合成颜色通道位图和透明度通道位图,得到合成位图;按照视频编码方式对合成位图进行编码,得到位图图像对应的编码图片。编码图片即为每一位图图像对应的图片二进制数据。The bitmap image sequence is processed according to the video sequence frame export method to obtain the image binary data corresponding to the video synthesis label code, including: dividing the bitmap image into a color channel bitmap and a transparency channel bitmap; synthesizing the color channel bitmap and the transparency channel bitmap to obtain a synthesized bitmap; encoding the synthesized bitmap according to the video encoding method to obtain an encoded image corresponding to the bitmap image. The encoded image is the image binary data corresponding to each bitmap image.

当采用视频序列帧导出方式对动画工程文件进行导出得到动画文件时,需要获取视频合成标签码(VideoCompositionBlock)对应的动画数据。When the animation project file is exported to obtain the animation file by using the video sequence frame export method, it is necessary to obtain the animation data corresponding to the video composition tag code (VideoCompositionBlock).

字段Fields 字段类型Field Type 备注Remark CompositionIDCompositionID EncodedUint32EncodedUint32 唯一标识Unique ID hasAlphahasAlpha BoolBool 是否有Alpha通道Is there an alpha channel? CompositionAttributesCompositionAttributes CompositionAttributes TagCompositionAttributes Tag videosequencesvideosequences VideoSequenceTag[]VideoSequenceTag[]

VideoSequence也是一个动画标签码,对应的属性结构表如下表所示:VideoSequence is also an animation tag code, and the corresponding attribute structure table is shown in the following table:

从上面给出的视频合成标签码的属性结构表可以看出,视频合成标签码所在的节点元素是一个嵌套的节点元素,嵌套了CompositionAttributes所在的节点元素和videoSequence所在的节点元素。除了根据视频编码方式得到的图片二进制数据以外,视频合成标签码对应的动画数据还包括合成标识(CompositionID)、是否包括透明通道(hasAlpha)、合成基础属性(CompositionAttributes)、视频帧序列(videoSequence),合成基础属性包括合成的播放时长、帧率和背景颜色,视频帧序列包括位图图像的宽、高、透明通道位置信息、视频编码方式的参数、关键帧标识以及图片二进制数据序列(videoFrames),图片二进制序列包括每一视频帧对应的时间戳和图片二进制数据流(fileBytes)。From the attribute structure table of the video composition tag code given above, it can be seen that the node element where the video composition tag code is located is a nested node element, which nests the node element where CompositionAttributes is located and the node element where videoSequence is located. In addition to the image binary data obtained according to the video encoding method, the animation data corresponding to the video composition tag code also includes the composition identifier (CompositionID), whether a transparent channel is included (hasAlpha), the basic composition attributes (CompositionAttributes), and the video frame sequence (videoSequence). The basic composition attributes include the playback duration, frame rate, and background color of the composition. The video frame sequence includes the width, height, and transparent channel position information of the bitmap image, the parameters of the video encoding method, the key frame identifier, and the image binary data sequence (videoFrames). The image binary sequence includes the timestamp and image binary data stream (fileBytes) corresponding to each video frame.

如图13所示,为视频序列帧编码方式对应的动画数据的编码结构图。参照图13,在编码时,先按照视频合成标签码对应的属性结构表中合成标识的数据类型编码CompositionID的值、按照布尔类型编码标识是否存在透明通道hasAlpha的值,然后按照CompositionAttributes的属性结构表依次编码基础属性数据,然后编码整个动画播放时的宽width、高height、帧率framerate,紧接着是透明通道起始位置信息alphaStartX和alphaStartY,然后再编码视频编码参数sps和pps,再编码位图图像的总数目Count,最后依次编码视频帧序列(videoSequence)中每个合成位图对应的帧序号frame和图片二进制数据fileBytes。As shown in Figure 13, it is a coding structure diagram of animation data corresponding to the video sequence frame coding method. Referring to Figure 13, when coding, first encode the value of CompositionID according to the data type of the composition identifier in the attribute structure table corresponding to the video composition tag code, encode the value of hasAlpha according to the Boolean type to identify whether there is a transparent channel, and then encode the basic attribute data in sequence according to the attribute structure table of CompositionAttributes, and then encode the width, height, and frame rate framerate of the entire animation playback, followed by the transparent channel starting position information alphaStartX and alphaStartY, and then encode the video encoding parameters sps and pps, and then encode the total number of bitmap images Count, and finally encode the frame number frame and image binary data fileBytes corresponding to each synthetic bitmap in the video frame sequence (videoSequence) in sequence.

在一个实施例中,上述动画数据编码方法还包括:按照文件头组织结构,将文件头信息依次编码,得到文件头编码信息;按照节点元素组织结构,将动画标签码、数据块长度和数据块依次编码,得到节点元素编码数据;数据块包括动态属性数据块和基础属性数据块;将文件头编码信息、各节点元素编码数据按照目标文件结构进行组织,得到目标动画文件。In one embodiment, the above-mentioned animation data encoding method also includes: encoding the file header information in sequence according to the file header organization structure to obtain file header encoding information; encoding the animation tag code, data block length and data block in sequence according to the node element organization structure to obtain node element encoding data; the data block includes a dynamic attribute data block and a basic attribute data block; organizing the file header encoding information and each node element encoding data according to the target file structure to obtain the target animation file.

这里的目标动画文件是PAG文件,PAG文件的文件组织结构包括文件头(FileHeader)和节点元素(Tag)。因此在编码整个动画文件的数据时,是按照文件头的组织结构将文件头信息进行编码,得到文件头编码信息。节点元素组织结构包括动画标签码、数据块长度以及数据块,因此,对于从动画工程文件中获取的与各动画标签码对应的动画数据,是按照节点元素组织结构依次编码后得到节点元素编码数据。这里的数据块包括动态属性数据块和基础属性数据块。在得到文件头编码信息以及节点元素编码数据后,按照目标动画文件的文件结构进行组织,得到目标动画文件。The target animation file here is a PAG file, and the file organization structure of the PAG file includes a file header (FileHeader) and a node element (Tag). Therefore, when encoding the data of the entire animation file, the file header information is encoded according to the organization structure of the file header to obtain the file header encoding information. The node element organization structure includes the animation tag code, the data block length, and the data block. Therefore, for the animation data corresponding to each animation tag code obtained from the animation project file, the node element encoding data is obtained after being encoded in sequence according to the node element organization structure. The data block here includes a dynamic attribute data block and a basic attribute data block. After obtaining the file header encoding information and the node element encoding data, they are organized according to the file structure of the target animation file to obtain the target animation file.

仅在按照矢量导出方式对动画工程文件进行导出时才会得到动态属性数据块。对于基础属性数据块,在按照矢量导出方式、位图序列帧导出方式以及视频序列帧导出方式进行导出时,都可能会用到。针对不同的动画标签码,对应的属性结构表不同,属性结构表中不同属性的属性类型不同,可能会按照基础属性数据块进行编码,也可能会按照动态属性数据块进行编码。Dynamic attribute data blocks are obtained only when the animation project file is exported in vector export mode. Basic attribute data blocks may be used when exporting in vector export mode, bitmap sequence frame export mode, and video sequence frame export mode. Different animation tag codes have different corresponding attribute structure tables. Different attributes in the attribute structure table have different attribute types. They may be encoded in basic attribute data blocks or dynamic attribute data blocks.

下面对前文列出的37个动画标签码的属性结构表进行介绍。The following is an introduction to the attribute structure table of the 37 animation tag codes listed above.

EndEnd

字段Fields 数据类型Data Types 备注Remark EndEnd Unit16Unit16 Tag结束标识Tag end mark

End作为一个特殊的动画标签码,标识着某个节点元素的结束,当解码过程中读取到这个标签时,标记与这个End对应的节点元素的内容都已经读取完了。如果节点元素包含嵌套,也就是包括子节点元素,那么在需要跳出当前节点元素的内容继续读取,从外层的字节元素读取内容。End is a special animation tag code that marks the end of a node element. When this tag is read during the decoding process, it indicates that the content of the node element corresponding to this End has been read. If the node element contains nested elements, that is, it includes child node elements, then if it is necessary to jump out of the current node element and continue reading, read the content from the outer byte element.

FontTablesFontTables

字段Fields 数据类型Data Types 备注Remark countcount EncodedUint32EncodedUint32 字体数目Number of fonts fontDatafontData FontData[]FontData[] 字体数组Font Array

FontTables是字体信息的合集。FontTables is a collection of font information.

VectorCompositionBlockVectorCompositionBlock

VectorCompositionBlock是按照矢量导出方式的动画数据的集合,里面可以包含简单的矢量图形数据,也可以再包含一个或多个VectorComposition。VectorCompositionBlock is a collection of animation data derived in vector format. It can contain simple vector graphics data or one or more VectorCompositions.

字段Fields 数据类型Data Types 备注Remark widthwidth EncodedInt32EncodedInt32 图层的宽The width of the layer heightheight EncodedInt32EncodedInt32 图层的高Layer height durationduration EncodedUint64EncodedUint64 持续时间Duration frameRateframeRate FloatFloat 帧率Frame rate backgroundColorbackgroundColor ColorColor 背景颜色Background Color

CompositionAttributes是合成的基本属性信息。CompositionAttributes is the basic attribute information of composition.

ImageTablesImageTables

字段Fields 数据类型Data Types 备注Remark countcount EncodedInt32EncodedInt32 图片数目Number of pictures imagesimages ImageBytesTag[]ImageBytesTag[] 图片数组Array of images

ImageTables是图片信息的合集。ImageTables is a collection of image information.

LayerBlockLayerBlock

LayerBlock是图层信息的合集。LayerBlock is a collection of layer information.

LayerAttributesLayerAttributes

LayerAttributes表示与图层属性相关的信息。LayerAttributes represents information related to layer attributes.

SolidColorSolidColor

字段Fields 数据类型Data Types 备注Remark solidColorsolidColor ColorColor 颜色值Color Value widthwidth EncodedInt32EncodedInt32 Width heightheight EncodedInt32EncodedInt32 high

LayerAttributes是图层的属性信息。LayerAttributes is the attribute information of the layer.

TextSourceTextSource

TextSource表示文本信息,包含:文本,字体,大小,颜色等基础信息。TextSource represents text information, including basic information such as text, font, size, color, etc.

TextPathOption标签TextPathOption Tag

字段Fields 字段类型Field Type 属性类型Property Type 默认值default value 备注Remark pathpath Mask TagMask Tag ValueValue nullnull 路径信息Path information reversedPathreversedPath BoolBool DiscretePropertyDiscrete Property falsefalse 是否反转路径Whether to reverse the path perpendicularToPathperpendicularToPath BoolBool DiscretePropertyDiscrete Property falsefalse 垂直路径Vertical Path forceAlignmentforceAlignment BoolBool DiscretePropertyDiscrete Property falsefalse 强制对齐Force alignment firstMarginfirstMargin FloatFloat SimplePropertySimpleProperty 0.0f0.0f 开始留白Start leaving blank space lastMarginlastMargin FloatFloat SimplePropertySimpleProperty 0.0f0.0f 最后留白Final blank

TextPathOption表示文本绘制信息,包含绘制路径、前后左右间距等。TextPathOption represents text drawing information, including the drawing path, front, back, left, and right spacing, etc.

TextMoreOption标签TextMoreOption Tag

TextMoreOption表示文本其他信息。TextMoreOption indicates additional information about the text.

ImageReference标签ImageReference Tag

字段Fields 数据类型Data Types 备注Remark idid EncodedUint32EncodedUint32 图片标识Image Logo

ImageReference表示图片索引,存储的是图片的ID,通过ID索引真正的图片信息。ImageReference represents an image index, which stores the image ID and indexes the actual image information through the ID.

CompositionReference标签CompositionReference Tag

字段Fields 数据类型Data Types 备注Remark idid EncodedUint32EncodedUint32 标识Logo compositionStartTimecompositionStartTime Int64Int64 开始时间Start time

CompositionReference表示图层组合索引,存储的是图层组合的ID,通过ID索引真正的图层组合。CompositionReference represents a layer combination index, which stores the ID of the layer combination and indexes the actual layer combination through the ID.

Transform2D标签Transform2D Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark anchorPointanchorPoint PointPoint ValueValue (0.0)(0.0) 锚点Anchor Point positionposition PointPoint ValueValue (0.0)(0.0) 位置信息Location Information xPositionxPosition FloatFloat ValueValue 0.00.0 x轴偏移x-axis offset yPositionyPosition FloatFloat ValueValue 0.00.0 y轴偏移Y-axis offset scalescale PointPoint ValueValue (0.0)(0.0) 缩放Zoom rotationrotation FloatFloat ValueValue 0.00.0 旋转Rotation opacityopacity unit8unit8 ValueValue 255255 透明度(0~255)Transparency (0-255)

Transform2D表示2D变换信息,包含:锚点,缩放,旋转,x轴偏移,y轴偏移等信息。Transform2D represents 2D transformation information, including: anchor point, scale, rotation, x-axis offset, y-axis offset and other information.

Mask标签Mask Tag

Mask表示遮罩信息。Mask represents mask information.

ShapeGroup标签ShapeGroup Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark blendModeblendMode 枚举(Unit8)Enumeration (Unit8) ValueValue BlendMode::NormalBlendMode::Normal 图像混合模式Image blending modes transformtransform ShapeTransformShapeTransform ValueValue none 变换Transform elementselements Shape[]Shape[] ValueValue none 元素element

ShapeGroup表示投影信息。ShapeGroup represents projection information.

Rectangle标签Rectangle Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark reversedreversed BoolBool BitFlagBitFlag falsefalse 是否翻转矩形的标识Whether to flip the rectangle's logo sizesize PointPoint MultiDimensionPropertyMultiDimensionProperty (100,100)(100,100) 矩形宽高Rectangle Width and Height positionposition PointPoint SpatialPropertySpatialProperty (0,0)(0,0) 矩形位置Rectangle Position roundnessroundness FloatFloat SimplePropertySimpleProperty 0.0f0.0f 圆角Rounded Corners

Rectangle表示矩形信息。Rectangle represents rectangle information.

Ellipse标签Ellipse Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark reversedreversed BoolBool BitFlagBitFlag falsefalse 是否翻转椭圆的标识Whether to flip the ellipse logo sizesize PointPoint MultiDimensionPropertyMultiDimensionProperty (100,100)(100,100) 宽高Width and Height positionposition PointPoint SpatialPropertySpatialProperty (0,0)(0,0) 位置Location

Ellipse表示椭圆信息。Ellipse represents ellipse information.

PolyStar标签PolyStar Tags

PolyStar表示多边星形的信息。PolyStar indicates information about a polygonal star.

ShapePath标签ShapePath Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark shapePathshapePath PathPath SimplePropertySimpleProperty none 路径形状Path shape

ShapePath表示形状的路径信息。ShapePath represents the path information of a shape.

Fill标签Fill Tag

Fill表示与填充相关的信息。Fill represents information related to filling.

Stroke标签Stroke Tags

Stroke表示与描边相关的信息。Stroke represents information related to the stroke.

GradientFill标签GradientFill Tags

GradientFill表示颜色渐变填充信息。GradientFill represents color gradient fill information.

GradientStroke标签GradientStroke Tags

GradientStroke表示描边的透明度渐变信息。GradientStroke represents the transparency gradient information of the stroke.

MergePaths标签MergePaths Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark modemode 枚举(Unit8)Enumeration (Unit8) ValueValue MergePathsMode::AddMergePathsMode::Add 合并模式Merge Mode

MergePaths表示合并路径相关的信息。MergePaths represents information related to merge paths.

TrimPaths标签TrimPaths Tags

TrimPaths表示路径生成效果相关的信息。TrimPaths represents information related to the path generation effect.

Repeater标签Repeater Tags

Repeater表示中转器相关的信息。Repeater represents information related to the repeater.

RoundCorners标签RoundCorners Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark radiusradius FloatFloat SimplePropertySimpleProperty 10.0f10.0f 半径radius

RoundCorners表示圆角相关的信息。RoundCorners represents information related to rounded corners.

Performance标签Performance Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark renderingTimerenderingTime Int64Int64 ValueValue 00 渲染耗时Rendering time imageDecodingTimeimageDecodingTime Int64Int64 ValueValue 00 图片解码耗时Image decoding time presentingTimepresentingTime Int64Int64 ValueValue 00 上屏耗时Time consumption for displaying the screen graphicsMemorygraphicsMemory Int64Int64 ValueValue 00 渲染内存Rendering Memory

Performance表示动画的性能参数。Performance represents the performance parameters of the animation.

DropShadowStyle标签DropShadowStyle Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark blendModeblendMode 枚举(Unit8)Enumeration (Unit8) DiscretePropertyDiscrete Property BlendMode::NormalBlendMode::Normal 图像混合模式Image blending modes colorcolor ColorColor SimplePropertySimpleProperty BlackBlack 颜色color opacityopacity unit8unit8 SimplePropertySimpleProperty 191191 透明度(0~255)Transparency (0-255) angleangle FloatFloat SimplePropertySimpleProperty 120.0f120.0f 角度angle distancedistance FloatFloat SimplePropertySimpleProperty 5.0f5.0f 距离distance sizesize FloatFloat DiscretePropertyDiscrete Property 5.0f5.0f 尺寸大小Size

DropShadowStyle表示添加阴影相关的信息。DropShadowStyle indicates adding shadow related information.

StrokeStyle标签StrokeStyle Tags

StrokeStyle是与描边样式相关的信息。StrokeStyle is information related to the stroke style.

TintEffect标签TintEffect Tags

TintEffect是与着色效果相关的信息。TintEffect is information related to the tinting effect.

FillEffect标签FillEffect Tags

字段Fields 数据类型Data Types 属性类型Property Type 默认值default value 备注Remark allMasksallMasks BoolBool BitFlagBitFlag falsefalse 所有遮罩All Masks fillMaskfillMask Mask TagMask Tag ValueValue nullnull 要填充的遮罩The mask to fill colorcolor ColorColor SimplePropertySimpleProperty RedRed 颜色color invertinvert BoolBool DiscretePropertyDiscrete Property falsefalse 是否翻转遮罩Whether to flip the mask horizontalFeatherhorizontalFeather FloatFloat SimplePropertySimpleProperty 0.0f0.0f 水平边缘羽化Horizontal edge feathering verticalFeatherverticalFeather FloatFloat SimplePropertySimpleProperty 0.0f0.0f 垂直边缘羽化Vertical edge feathering opacityopacity unit8unit8 SimplePropertySimpleProperty 255255 透明度(0~255)Transparency (0-255)

FillEffect是与填充效果相关的信息。FillEffect is information related to the fill effect.

StrokeEffect标签StrokeEffect Tags

StrokeEffect是与描边效果相关的信息。StrokeEffect is information related to the stroke effect.

TritoneEffect标签TritoneEffect Tags

TritoneEffect表示高光、中间色、阴影效果。TritoneEffect represents highlight, midtone, and shadow effects.

DropShadowEffect标签DropShadowEffect Tags

DropShadowEffect表示填充阴影效果信息。DropShadowEffect represents fill shadow effect information.

FillRadialWipeEffect标签FillRadialWipeEffect Tags

FillRadialWipeEffect表示填充径向擦除效果信息。FillRadialWipeEffect represents filling radial wipe effect information.

DisplacementMapEffect标签DisplacementMapEffect Tags

DisplacementMapEffect表示置换图层信息。DisplacementMapEffect represents the displacement layer information.

BitmapCompositionBlockBitmapCompositionBlock

BitmapCompositionBlock表示按照位图序列帧方式导出得到的合成。BitmapCompositionBlock represents the composition exported as a bitmap sequence frame.

CompositionAttributesCompositionAttributes

字段Fields 数据类型Data Types 备注Remark durationduration EncodedUint64EncodedUint64 播放时长Playing time frameRateframeRate FloatFloat 帧率Frame rate backgroundColorbackgroundColor ColorColor 背景颜色Background Color

CompositionAttributes表示按照位图序列帧方式导出的合成的基础属性信息。CompositionAttributes represents the basic attribute information of the composition exported in the bitmap sequence frame mode.

BitmapSequenceBitmapSequence

BitmapSequence表示位图图像序列。A BitmapSequence represents a sequence of bitmap images.

ImageBytesImageBytes

字段Fields 字段类型Field Type 备注Remark idid EncodedUint32EncodedUint32 标识Logo widthwidth EncodedInt32EncodedInt32 图片宽Image width widthwidth EncodedInt32EncodedInt32 图片宽Image width anchorXanchorX EncodedInt32EncodedInt32 x轴坐标x-axis coordinate anchorYanchorY EncodedInt32EncodedInt32 y轴坐标y-axis coordinate fileBytesfileBytes ByteDataByteData 图片字节流Image byte stream

ImageBytes表示编码后的图片属性信息。ImageBytes represents the encoded image attribute information.

ImageBytes2ImageBytes2

字段Fields 字段类型Field Type 备注Remark idid EncodedUint32EncodedUint32 标识Logo widthwidth EncodedInt32EncodedInt32 图片宽Image width widthwidth EncodedInt32EncodedInt32 图片宽Image width anchorXanchorX EncodedInt32EncodedInt32 x轴坐标x-axis coordinate anchorYanchorY EncodedInt32EncodedInt32 y轴坐标y-axis coordinate fileBytesfileBytes ByteDataByteData 图片字节流Image byte stream scaleFactorscaleFactor FloatFloat 缩放比例(0~1.0)Scaling ratio (0~1.0)

ImageBytes2存储图片相关属性信息,相对于ImageBytes多了一个scaleFactor属性。ImageBytes2 stores image-related attribute information, and has an additional scaleFactor attribute compared to ImageBytes.

ImageBytes3相对于ImageBytes2只是将透明边框剥离了,属性值没变。Compared with ImageBytes2, ImageBytes3 only removes the transparent border, and the attribute value remains unchanged.

VideoCompositionBlockVideoCompositionBlock

字段Fields 字段类型Field Type 备注Remark CompositionIDCompositionID EncodedUint32EncodedUint32 唯一标识Unique ID hasAlphahasAlpha BoolBool 是否有Alpha通道Is there an alpha channel? CompositionAttributesCompositionAttributes CompositionAttributes TagCompositionAttributes Tag 合成基础属性Synthetic basic properties videosequencesvideosequences VideoSequenceTag[]VideoSequenceTag[] 视频帧序列Video frame sequence

VideoCompositionBlock表示按照视频序列帧导出方式进行导出得到的合成。VideoCompositionBlock represents the composition exported in the same way as the video sequence frames are exported.

VideoSequenceVideoSequence

VideoSequence表示序列帧序列。VideoSequence represents a sequence of frames.

如图14所示,在一个实施例中,提供了一种动画数据解码方法。本实施例主要以该方法应用于上述图1中的终端110来举例说明。参照图14,该动画数据解码方法具体包括如下步骤:As shown in FIG14 , in one embodiment, a method for decoding animation data is provided. This embodiment is mainly illustrated by applying the method to the terminal 110 in FIG1 . Referring to FIG14 , the method for decoding animation data specifically includes the following steps:

S1402,获取动画标签码。S1402, obtaining an animation tag code.

在解析PAG文件时,除了文件头信息需要按照文件头组织结构进行解码以外,剩下的若干个节点元素需要按照节点元素组织结构进行解码。节点结束符(End)是一个特殊的节点元素,用于标识本层次的节点元素已经全部读取,没有更多的节点元素要读取,所以当读取到节点结束符(0)后表示当前节点元素的内容已经读取完毕,继续读取得到的数据是下一个节点元素的内容。当然,若节点元素是嵌套的节点元素,包括多个子节点元素,则在节点结束符后继续读取得到的数据是外层节点元素的内容,直至得到最外层节点元素对应的节点结束符或者按照最外层节点元素内容的字节流长度读取完毕后,表示最外层节点元素也没有更多的内容要读取。When parsing a PAG file, in addition to the file header information that needs to be decoded according to the file header organization structure, the remaining node elements need to be decoded according to the node element organization structure. The node end character (End) is a special node element that is used to indicate that all node elements at this level have been read and there are no more node elements to be read. Therefore, when the node end character (0) is read, it indicates that the content of the current node element has been read, and the data obtained by continuing to read is the content of the next node element. Of course, if the node element is a nested node element, including multiple child node elements, the data obtained by continuing to read after the node end character is the content of the outer node element, until the node end character corresponding to the outermost node element is obtained or the byte stream length of the outermost node element content is read, it indicates that there is no more content to be read in the outermost node element.

根据前文描述的节点元素组织结构,节点元素都包括节点元素头部(TagHeader)和节点元素内容(TagBody),节点元素头部包括动画标签码(TagCode)和节点元素内容的字节流长度(Length)。节点元素头部分为short类型和long类型,不管是short类型或是long类型,节点元素头部的前2个字节中的前10bits表示的是动画标签码,因此,当读取到END对应的动画标签码(0)之后,继续读取2个字节,这2个字节的前10bits表示的是下一个节点元素包括的动画标签码。若前2个字节的后6bits不是“0x3f”,则说明该节点元素的节点元素头部是short类型的,根据short类型的节点元素头部的组织结构,后6bits的值表示的是节点元素内容(TagBody)的字节流长度(Length)。若前2个字节的后6bits是“0x3f”,则说明该节点元素的节点元素头部是long类型的,根据long类型的节点元素头部的组织结构,继续读取这2个字节后的4个字节,得到的数据值表示的是节点元素内容(TagBody)的字节流长度(Length)。字节流长度的值表示的是节点元素内容占用的字节数,在解析得到字节流长度后,就可以确定在节点元素头部之后的多少个字节的数据是属于当前节点元素的节点元素内容。According to the node element organization structure described above, node elements include a node element header (TagHeader) and a node element content (TagBody). The node element header includes the animation tag code (TagCode) and the byte stream length (Length) of the node element content. The node element header is divided into short type and long type. Regardless of the short type or long type, the first 10 bits of the first 2 bytes of the node element header represent the animation tag code. Therefore, after reading the animation tag code (0) corresponding to END, continue to read 2 bytes. The first 10 bits of these 2 bytes represent the animation tag code included in the next node element. If the last 6 bits of the first 2 bytes are not "0x3f", it means that the node element header of the node element is of short type. According to the organization structure of the short type node element header, the value of the last 6 bits represents the byte stream length (Length) of the node element content (TagBody). If the last 6 bits of the first 2 bytes are "0x3f", it means that the node element header of the node element is of long type. According to the organizational structure of the node element header of long type, continue to read the 4 bytes after these 2 bytes, and the data value obtained represents the byte stream length (Length) of the node element content (TagBody). The value of the byte stream length represents the number of bytes occupied by the node element content. After parsing the byte stream length, it can be determined how many bytes of data after the node element header belong to the node element content of the current node element.

动画标签码用于表示节点元素具体记录了哪一类的动画信息,不同的动画标签码表示记录了不同的动画信息。当解析到某个动画标签码后,就可以确定当前节点元素的节点元素内容表示的是什么动画信息,不同的动画信息的节点元素内容有着不同的编码结构,因此,获取每个节点元素中的动画标签码是准确解析各个节点元素,尤其是节点元素内容的前提。The animation tag code is used to indicate which type of animation information is recorded in the node element. Different animation tag codes indicate different animation information. After parsing a certain animation tag code, it is possible to determine what animation information the node element content of the current node element represents. The node element content of different animation information has different encoding structures. Therefore, obtaining the animation tag code in each node element is a prerequisite for accurately parsing each node element, especially the node element content.

如前文提到的,PAG文件采用10比特位来存储动画标签码,最多可以存储1024种不同的动画标签码。目前PAG文件仅用到了37种动画标签码,其中,0-29是矢量导出方式所支持的动画标签码,45-51是为位图序列帧导出方式以及视频序列帧导出方式扩展的7个动画标签码。若后续PAG文件还可以支持更多的动画特性,则还可以继续扩展新的动画标签码表示新增的动画特性所对应的动画信息。As mentioned above, PAG files use 10 bits to store animation tag codes, and can store up to 1024 different animation tag codes. Currently, PAG files only use 37 animation tag codes, of which 0-29 are animation tag codes supported by the vector export method, and 45-51 are 7 animation tag codes extended for the bitmap sequence frame export method and the video sequence frame export method. If subsequent PAG files can support more animation features, new animation tag codes can be further extended to represent the animation information corresponding to the newly added animation features.

进一步地,当解析到一个动画标签码后,需要根据动画标签码所表示动画信息对应的属性结构表来解析当前节点元素的节点元素内容。主要分为两种情况,当解析得到的动画标签码所对应的属性结构表中不存在属性类型时,则节点元素内容中的数据是以基础属性数据块的形式存储的,当解析得到的动画标签码所对应的属性结构表中存在属性类型时,则节点元素内容中的数据是以动态属性数据块的形式存储的。Furthermore, after parsing an animation tag code, it is necessary to parse the node element content of the current node element according to the attribute structure table corresponding to the animation information represented by the animation tag code. There are mainly two situations. When the attribute type does not exist in the attribute structure table corresponding to the parsed animation tag code, the data in the node element content is stored in the form of a basic attribute data block. When the attribute type exists in the attribute structure table corresponding to the parsed animation tag code, the data in the node element content is stored in the form of a dynamic attribute data block.

S1404,当与动画标签码对应的属性结构表中存在属性类型时,则根据属性结构表中各属性对应的属性类型,从动画标签码对应的动态属性数据块中解析各属性对应的属性标识信息。S1404, when there is an attribute type in the attribute structure table corresponding to the animation tag code, the attribute identification information corresponding to each attribute is parsed from the dynamic attribute data block corresponding to the animation tag code according to the attribute type corresponding to each attribute in the attribute structure table.

其中,属性结构表定义了动画标签码所对应的动画信息的数据结构。当某个动画标签码所对应的属性结构表中存在属性类型时,则表明该动画标签码所对应的节点元素头部后的节点元素内容需要按照动态属性数据结构进行解码。动态属性数据块主要由两部分组成:各个属性对应的属性标识信息(AttributeFlag)组成的属性标识区域以及由各个属性对应的属性内容(AttributeContent)组成的属性内容区域。属性类型(AttributeType)用于确定属性标识信息占用的比特位数以及相应的属性内容的读取规则。属性类型包括普通属性、布尔属性、固定属性、简单动画属性、离散动画属性、多维时间缓动动画属性和空间缓动动画属性。Among them, the attribute structure table defines the data structure of the animation information corresponding to the animation tag code. When an attribute type exists in the attribute structure table corresponding to a certain animation tag code, it indicates that the node element content after the node element header corresponding to the animation tag code needs to be decoded according to the dynamic attribute data structure. The dynamic attribute data block mainly consists of two parts: an attribute identification area composed of attribute identification information (AttributeFlag) corresponding to each attribute and an attribute content area composed of attribute content (AttributeContent) corresponding to each attribute. The attribute type (AttributeType) is used to determine the number of bits occupied by the attribute identification information and the corresponding attribute content reading rules. Attribute types include common attributes, Boolean attributes, fixed attributes, simple animation attributes, discrete animation attributes, multi-dimensional time easing animation attributes, and space easing animation attributes.

以遮罩信息为例,当读取到表示遮罩信息的动画标签码“14”时,由于遮罩信息对应的属性结构表中存在属性类型,因此对于当前节点元素的节点元素内容,需要按照动态属性数据结构进行解析。总体上,是先解析出动态属性数据块中的属性标识区域,然后进行一次统一的字节对齐后再从整数字节数位置开始读取属性内容区域,依次得到遮罩信息所对应的属性结构表中各属性对应的属性内容。Taking mask information as an example, when the animation tag code "14" representing the mask information is read, since the attribute type exists in the attribute structure table corresponding to the mask information, the node element content of the current node element needs to be parsed according to the dynamic attribute data structure. In general, the attribute identification area in the dynamic attribute data block is parsed first, and then a unified byte alignment is performed and the attribute content area is read from the integer byte position, and the attribute content corresponding to each attribute in the attribute structure table corresponding to the mask information is obtained in turn.

属性标识信息可能为空,属性标识信息可能至少包括内容标识位,还可能包括动画区间标识位以及空间缓动参数标识位。内容标识位(exist)用于表示属性对应的属性内容是存在于动态属性数据块中还是等于默认值,动画区间标识位(animatable)用于表示该属性对应的属性值是否包括动画区间特效数据,空间缓动参数标识位(hasSpatial)用于表示该属性对应的属性值是否包括空间缓动参数。不同属性类型的属性所对应的属性标识信息占用的比特位数是动态的,取值范围是0-3比特位。各个属性具体占用了几个比特位,需要根据属性类型确定,也就是说,属性类型可用于确定属性标识信息可能占用的比特位数(0-3位)。普通属性最多只可能占1个比特位,解码时只需要读取内容标识位。而空间缓动动画属性最多会占用3个比特位来存储属性标识信息。例如,当一个空间缓动动画属性不含有动画区间特性数据且属性值等于默认值时,只需要1个比特位来表示属性标识信息,属性标识信息仅包括属性内容标志位,其值为0,表示对应的属性内容为默认值。解码时读取到内容标识位为0,代表该属性的属性标识信息已经读取完毕,不会接着读取下一比特位的值。在极限情况下,属性结构表中各个属性都不含有动画区间特性数据而且都等于默认值,那么只会占用属性数量个比特位存储各个属性对应的属性标识信息,且每个属性标识信息都只包括内容标识位,其值均为0。The attribute identification information may be empty. The attribute identification information may include at least a content identification bit, and may also include an animation interval identification bit and a spatial easing parameter identification bit. The content identification bit (exist) is used to indicate whether the attribute content corresponding to the attribute exists in the dynamic attribute data block or is equal to the default value. The animation interval identification bit (animatable) is used to indicate whether the attribute value corresponding to the attribute includes animation interval special effects data. The spatial easing parameter identification bit (hasSpatial) is used to indicate whether the attribute value corresponding to the attribute includes spatial easing parameters. The number of bits occupied by the attribute identification information corresponding to attributes of different attribute types is dynamic, and the value range is 0-3 bits. The specific number of bits occupied by each attribute needs to be determined according to the attribute type. In other words, the attribute type can be used to determine the number of bits (0-3 bits) that the attribute identification information may occupy. Ordinary attributes may only occupy 1 bit at most, and only the content identification bit needs to be read during decoding. The spatial easing animation attribute will occupy up to 3 bits to store the attribute identification information. For example, when a spatial easing animation attribute does not contain animation interval characteristic data and the attribute value is equal to the default value, only 1 bit is needed to represent the attribute identification information. The attribute identification information only includes the attribute content flag bit, whose value is 0, indicating that the corresponding attribute content is the default value. When decoding, the content identification bit read is 0, which means that the attribute identification information of the attribute has been read and the value of the next bit will not be read. In the extreme case, each attribute in the attribute structure table does not contain animation interval characteristic data and is equal to the default value. In this case, only attribute number bits will be used to store the attribute identification information corresponding to each attribute, and each attribute identification information only includes the content identification bit, whose value is 0.

下面给出不同属性类型对应的属性标识信息的解析规则:The following are the parsing rules for attribute identification information corresponding to different attribute types:

普通属性的属性标识信息仅占用一个比特位,在读取该属性对应的属性标识信息时,只需要读取一个比特位的值即可。The attribute identification information of a common attribute occupies only one bit. When reading the attribute identification information corresponding to the attribute, only the value of one bit needs to be read.

布尔属性的属性标识信息仅占用一个比特位,在读取该属性对应的属性标识信息时,也只需要读取一个比特位即可,并且,该比特位的值即为该属性对应的属性值。The attribute identification information of a Boolean attribute occupies only one bit. When reading the attribute identification information corresponding to the attribute, only one bit needs to be read, and the value of the bit is the attribute value corresponding to the attribute.

固定属性的属性标识信息不占用比特位,因此无需从动态属性数据块中读取该属性对应的属性标识信息。The attribute identification information of the fixed attribute does not occupy any bit, so there is no need to read the attribute identification information corresponding to the attribute from the dynamic attribute data block.

简单动画属性、离散动画属性以及多维时间缓动动画属性的属性标识信息占用1-2个比特位。当读取到第1个比特位的值为1时,代表该属性对应的属性值不是默认值,还需要继续读取第2个比特位,从而得到该属性对应的属性标识信息“11”或“10”,当读取到第1个比特位的值为0时,代表该属性对应的属性值为默认值且属性标识信息只占用1个比特位,即为“1”。The attribute identification information of simple animation attributes, discrete animation attributes, and multi-dimensional time slow animation attributes occupies 1-2 bits. When the value of the first bit is 1, it means that the attribute value corresponding to the attribute is not the default value, and the second bit needs to be read to obtain the attribute identification information "11" or "10" corresponding to the attribute. When the value of the first bit is 0, it means that the attribute value corresponding to the attribute is the default value and the attribute identification information only occupies 1 bit, that is, "1".

空间缓动动画属性的属性标识信息占用1-3个比特位。当读取到第1个比特位的值为1时,代表该属性对应的属性值不是默认值,还需要继续读取第2个比特位;若第2个比特位的值为0,则该属性对应的属性内容不包括动画区间特性数据,从而得到该属性对应的属性标识信息“10”,不能再去读取后面的数据作为该属性对应的属性标识信息;若第2个比特位的值为1,则该属性对应的属性内容包括动画区间特性数据,还需要继续读取第3个比特位;若第3个比特位的值为0,则该属性对应的属性内容不包括空间缓动参数,并且确定该属性对应的属性标识信息“110”;第3个比特位的值为1,则该属性对应的属性内容包括空间缓动参数,并且确定该属性对应的属性标识信息“111”;若读取到第1个比特位的值为0时,代表该属性对应的属性值为默认值且属性标识信息只占用1个比特位,即为“1”,不能再去读取后面的数据作为该属性对应的属性标识信息。The attribute identification information of the spatial easing animation attribute occupies 1-3 bits. When the value of the first bit is read as 1, it means that the attribute value corresponding to the attribute is not the default value, and the second bit needs to be read; if the value of the second bit is 0, the attribute content corresponding to the attribute does not include the animation interval characteristic data, thereby obtaining the attribute identification information "10" corresponding to the attribute, and the subsequent data cannot be read as the attribute identification information corresponding to the attribute; if the value of the second bit is 1, the attribute content corresponding to the attribute includes the animation interval characteristic data, and the third bit needs to be read; if the value of the third bit is 0, the attribute content corresponding to the attribute does not include the spatial easing parameters, and the attribute identification information "110" corresponding to the attribute is determined; the value of the third bit is 1, the attribute content corresponding to the attribute includes the spatial easing parameters, and the attribute identification information "111" corresponding to the attribute is determined; if the value of the first bit is read as 0, it means that the attribute value corresponding to the attribute is the default value and the attribute identification information only occupies 1 bit, that is, "1", and the subsequent data cannot be read as the attribute identification information corresponding to the attribute.

在一个实施例中,根据属性结构表中各属性对应的属性类型,从动画标签码对应的动态属性数据块中解析各属性对应的属性标识信息,包括:查询属性结构表,得到各属性对应的属性排序;根据各属性对应的属性类型,确定各属性对应的属性标识信息所占用的比特位数;从动画标签码对应的动态属性数据块中的首个比特位开始读取数据;基于各属性对应的属性标识信息所占用的比特位数,按照属性排序从依次读取的数据中确定各属性对应的属性标识信息。In one embodiment, according to the attribute type corresponding to each attribute in the attribute structure table, the attribute identification information corresponding to each attribute is parsed from the dynamic attribute data block corresponding to the animation tag code, including: querying the attribute structure table to obtain the attribute sorting corresponding to each attribute; determining the number of bits occupied by the attribute identification information corresponding to each attribute according to the attribute type corresponding to each attribute; reading data starting from the first bit in the dynamic attribute data block corresponding to the animation tag code; and determining the attribute identification information corresponding to each attribute from the data read sequentially according to the attribute sorting based on the number of bits occupied by the attribute identification information corresponding to each attribute.

实际上,属性结构表所包括属性的数量、属性排序、属性对应的属性类型以及属性对应的默认值都是硬编码在解析代码中的,当解析到某个动画标签码后,可以直接根据解析代码确定与之对应的属性结构表的信息,包括属性排序、属性对应的属性类型、数据类型、数量以及默认值等。In fact, the number of attributes included in the attribute structure table, attribute order, attribute types corresponding to the attributes, and default values corresponding to the attributes are all hard-coded in the parsing code. When a certain animation tag code is parsed, the corresponding attribute structure table information can be directly determined based on the parsing code, including attribute order, attribute types corresponding to the attributes, data types, quantity, and default values.

具体地,在从动态属性数据块中解析出各个属性对应的属性标识信息时,是根据各个属性对应的属性类型,先确定各个属性对应的属性标识信息可能占用的比特位数,除此之外,还要按照各个属性对应的属性排序从动态属性数据块的属性标识区域中依次读取数据,并且读取的数据还要按照不同属性类型的属性标识信息的编码规则进行解析,才能准确确定各个属性对应的属性标识信息。Specifically, when parsing the attribute identification information corresponding to each attribute from the dynamic attribute data block, the number of bits that may be occupied by the attribute identification information corresponding to each attribute is first determined based on the attribute type corresponding to each attribute. In addition, data is read from the attribute identification area of the dynamic attribute data block in sequence according to the attribute sorting corresponding to each attribute, and the read data is also parsed according to the encoding rules of the attribute identification information of different attribute types to accurately determine the attribute identification information corresponding to each attribute.

在一个实施例中,当与动画标签码对应的属性结构表中不存在属性类型时,则根据属性结构表中各属性对应的数据类型、属性排序,依次从动画标签码对应的基础属性数据块中读取各属性对应的属性值。In one embodiment, when the attribute type does not exist in the attribute structure table corresponding to the animation tag code, the attribute values corresponding to each attribute are read from the basic attribute data block corresponding to the animation tag code in sequence according to the data type and attribute sorting corresponding to each attribute in the attribute structure table.

具体地,当动画标签码对应的属性结构表中不存在属性类型时,则表明该动画标签码所对应的节点元素头部后的节点元素内容需要按照基础属性数据结构进行解码,实质上就是按照该动画标签码所对应的属性结构表中各属性对应的数据类型、属性排序对节点元素内容进行解析,依次得到各属性对应的属性值。Specifically, when the attribute type does not exist in the attribute structure table corresponding to the animation tag code, it indicates that the node element content after the node element header corresponding to the animation tag code needs to be decoded according to the basic attribute data structure. In essence, the node element content is parsed according to the data type and attribute order corresponding to each attribute in the attribute structure table corresponding to the animation tag code, and the attribute value corresponding to each attribute is obtained in turn.

比如,当解析到动画标签码的值为“7”时,代表当前节点元素表示的是边框的尺寸和颜色信息,而该信息对应的属性结构表中不存在属性类型,属性结构表中仅包括三个字段,分别为solidColor、width和height,其中solidColor的数据类型为Color,Color类型需要占用三个字节,依次表示红、绿、蓝的值,width、height的数据类型为EncodedInt32。在解码该动画标签码所在的节点元素的节点元素内容时,就需要先读取24bits,得到的是solidColor的值,然后按照EncodedInt32的编码规则依次读取width、height的值,就得到了当前节点元素所要表示的动画信息的各个属性值。For example, when the parsed animation tag code value is "7", it means that the current node element represents the size and color information of the border, but the attribute type does not exist in the attribute structure table corresponding to this information. The attribute structure table only includes three fields, namely solidColor, width and height. The data type of solidColor is Color, and the Color type needs to occupy three bytes, which represent the values of red, green and blue respectively. The data types of width and height are EncodedInt32. When decoding the node element content of the node element where the animation tag code is located, it is necessary to read 24 bits first to obtain the value of solidColor, and then read the values of width and height in turn according to the encoding rules of EncodedInt32 to obtain the various attribute values of the animation information to be represented by the current node element.

S1406,根据各属性对应的属性标识信息从动态属性数据块中解析各属性对应的属性内容。S1406: parse the attribute content corresponding to each attribute from the dynamic attribute data block according to the attribute identification information corresponding to each attribute.

由于属性标识信息标识了各个属性的状态,状态可分为以下几种,比如属性值是默认值还是存在于动态属性数据块的属性内容区域中,又比如,若属性值存在于动态属性数据块的属性内容区域,属性内容是否包括动画区间特性数据,又比如,属性内容是否包括空间缓动参数等。由于不同的状态下对应的属性值的编码方式存在差异,因此,根据各属性对应的属性标识信息确定各属性的状态,也就确定了应该按照什么数据结构从动态属性数据块中解析属性内容,或是如何解析对应的属性值。Since the attribute identification information identifies the state of each attribute, the states can be divided into the following types, such as whether the attribute value is the default value or exists in the attribute content area of the dynamic attribute data block, and if the attribute value exists in the attribute content area of the dynamic attribute data block, whether the attribute content includes animation interval characteristic data, and whether the attribute content includes spatial easing parameters. Since the encoding methods of the corresponding attribute values under different states are different, the state of each attribute is determined according to the attribute identification information corresponding to each attribute, which also determines what data structure should be used to parse the attribute content from the dynamic attribute data block, or how to parse the corresponding attribute value.

具体地,在得到各属性对应的属性标识信息后,就可以按照属性标识信息所标识的属性的状态,采用与各状态对应的解析方式从动态属性数据块中解析出各个属性对应的属性内容。每一种属性类型以及每一种属性类型的属性标识信息取不同值时所对应的解析方式不同,下面进行具体说明。Specifically, after obtaining the attribute identification information corresponding to each attribute, the attribute content corresponding to each attribute can be parsed from the dynamic attribute data block according to the state of the attribute identified by the attribute identification information, using the parsing method corresponding to each state. Each attribute type and the parsing method corresponding to different values of the attribute identification information of each attribute type are different, which are described in detail below.

在一个实施例中,属性类型为普通属性,属性标识信息仅包括内容标识位;根据各属性对应的属性标识信息从动态属性数据块中解析各属性对应的属性内容,包括:若内容标识位的值表示动态属性数据块中存在属性对应的属性内容,则根据属性对应的数据类型从动态属性数据块中读取属性对应的属性内容;若内容标识位的值表示动态属性数据块中不存在属性对应的属性内容,则从属性结构表中查询与属性对应的默认值。In one embodiment, the attribute type is a common attribute, and the attribute identification information only includes a content identification bit; the attribute content corresponding to each attribute is parsed from the dynamic attribute data block according to the attribute identification information corresponding to each attribute, including: if the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, then the attribute content corresponding to the attribute is read from the dynamic attribute data block according to the data type corresponding to the attribute; if the value of the content identification bit indicates that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block, then the default value corresponding to the attribute is queried from the attribute structure table.

当属性类型为普通属性时,属性标识信息仅包括内容标识位,也就是说,属性标识信息只占用一个比特位。若内容标识位的值表示动态属性数据块中存在属性对应的属性内容,内容标识位的值比如可以是1,也就是说该属性对应的属性内容不是默认值时,则需要按照该属性对应的数据类型从动态属性数据块中解析出该属性对应的属性内容。若内容标识位的值表示动态属性数据块中存在属性对应的属性内容,内容标识位的值比如可以是0,也就是说该属性对应的属性内容是默认值时,则直接获取该属性对应的默认值,不需要按照该属性对应的数据类型从动态属性数据块中解析出该属性对应的属性内容。When the attribute type is a common attribute, the attribute identification information only includes the content identification bit, that is, the attribute identification information only occupies one bit. If the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, the value of the content identification bit can be 1, for example, that is, when the attribute content corresponding to the attribute is not the default value, it is necessary to parse the attribute content corresponding to the attribute from the dynamic attribute data block according to the data type corresponding to the attribute. If the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, the value of the content identification bit can be 0, for example, that is, when the attribute content corresponding to the attribute is the default value, the default value corresponding to the attribute is directly obtained, and it is not necessary to parse the attribute content corresponding to the attribute from the dynamic attribute data block according to the data type corresponding to the attribute.

在一个实施例中,属性类型为固定属性,属性标识信息为空;根据各属性对应的属性标识信息从动态属性数据块中解析各属性对应的属性内容,包括:直接根据属性对应的数据类型从动态属性数据块中读取属性对应的属性内容。In one embodiment, the attribute type is a fixed attribute, and the attribute identification information is empty; the attribute content corresponding to each attribute is parsed from the dynamic attribute data block according to the attribute identification information corresponding to each attribute, including: directly reading the attribute content corresponding to the attribute from the dynamic attribute data block according to the data type corresponding to the attribute.

属性类型为固定属性,固定属性的属性标识信息为空,不占用比特位,实际上是因为固定属性对应的属性值肯定存在与动态属性数据块的属性内容区域中,因此可以直接根据该属性对应的数据类型从动态属性数据块中读取该属性对应的属性内容。The attribute type is a fixed attribute, and the attribute identification information of the fixed attribute is empty and does not occupy any bit. In fact, this is because the attribute value corresponding to the fixed attribute must exist in the attribute content area of the dynamic attribute data block. Therefore, the attribute content corresponding to the attribute can be directly read from the dynamic attribute data block according to the data type corresponding to the attribute.

在一个实施例中,属性类型为布尔属性,属性标识信息仅包括内容标识位;根据各属性对应的属性标识信息从动态属性数据块中解析各属性对应的属性内容,包括:直接将内容标识位的值作为属性对应的属性内容。In one embodiment, the attribute type is a Boolean attribute, and the attribute identification information only includes a content identification bit; the attribute content corresponding to each attribute is parsed from the dynamic attribute data block according to the attribute identification information corresponding to each attribute, including: directly using the value of the content identification bit as the attribute content corresponding to the attribute.

属性类型为布尔类型,布尔类型的属性只占用一个比特位,且该比特位的值即为该属性对应的值,因此可以直接将该内容标识位的值作为该属性对应的属性值。当该内容标识位的值为1时,该属性对应的属性值为true;当该内容标识位的值为0时,该属性对应的属性值为false。The attribute type is Boolean type. Boolean attributes only occupy one bit, and the value of this bit is the value corresponding to the attribute. Therefore, the value of the content identifier can be directly used as the attribute value corresponding to the attribute. When the value of the content identifier is 1, the attribute value corresponding to the attribute is true; when the value of the content identifier is 0, the attribute value corresponding to the attribute is false.

在一个实施例中,属性类型为简单动画属性、离散动画属性、多维时间缓动动画属性或空间缓动动画属性,属性标识信息至少包括内容标识位;根据各属性对应的属性标识信息从动态属性数据块中解析各属性对应的属性内容,包括:若内容标识位的值表示动态属性数据块中存在属性对应的属性内容,则从动态属性数据块中读取属性对应的属性内容;若内容标识位的值表示动态属性数据块中不存在属性对应的属性内容时,则根据属性结构表查询与属性对应的默认值。In one embodiment, the attribute type is a simple animation attribute, a discrete animation attribute, a multi-dimensional time-delayed animation attribute, or a space-delayed animation attribute, and the attribute identification information at least includes a content identification bit; the attribute content corresponding to each attribute is parsed from the dynamic attribute data block according to the attribute identification information corresponding to each attribute, including: if the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, then the attribute content corresponding to the attribute is read from the dynamic attribute data block; if the value of the content identification bit indicates that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block, then the default value corresponding to the attribute is queried according to the attribute structure table.

当属性对应的属性类型为简单动画属性(SimpleProperty)、离散动画属性(DiscreteProperty)、多维时间缓动动画属性(MultiDimensionProperty)或空间缓动动画属性(SpatialProperty)时,则该属性对应的属性标识信息至少包括内容标识位。同样地,当解析到内容标识位的值表示属性值不是默认值,也就是表示动态属性数据块中存在属性对应的属性内容时,比如内容标识位的值可以是1,则需要从动态属性数据块中读取属性对应的属性内容。当解析到内容标识位的值表示属性值是默认值,也就是表示动态属性数据块中不存在属性对应的属性内容时,比如内容标识位的值可以是0,则只需要将该属性对应的默认值作为相应的属性内容即可。When the property type corresponding to the attribute is a simple animation property (SimpleProperty), a discrete animation property (DiscreteProperty), a multi-dimensional time slow-motion animation property (MultiDimensionProperty) or a spatial slow-motion animation property (SpatialProperty), the property identification information corresponding to the attribute includes at least a content identification bit. Similarly, when the value of the content identification bit is parsed to indicate that the attribute value is not the default value, that is, it indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, for example, the value of the content identification bit may be 1, then it is necessary to read the attribute content corresponding to the attribute from the dynamic attribute data block. When the value of the content identification bit is parsed to indicate that the attribute value is the default value, that is, it indicates that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block, for example, the value of the content identification bit may be 0, then it is only necessary to use the default value corresponding to the attribute as the corresponding attribute content.

在一个实施例中,若内容标识位的值表示动态属性数据块中存在属性对应的属性内容,则从动态属性数据块中读取属性对应的属性内容,包括:当内容标识位的值表示动态属性数据块中存在属性对应的属性内容时,读取内容标识位下一比特位的值,作为动画区间标识位的值;若动画区间标识位的值表示属性内容包括动画区间特性数据时,则按照动画区间特性数据对应的数据存储结构,从动态属性数据块中解析属性对应的动画区间特性数据;若动画区间标识位的值表示属性内容不包括动画区间特性数据时,则直接根据属性的数据类型从动态属性数据块中解析属性对应的属性内容。In one embodiment, if the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, the attribute content corresponding to the attribute is read from the dynamic attribute data block, including: when the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, read the value of the next bit of the content identification bit as the value of the animation interval identification bit; if the value of the animation interval identification bit indicates that the attribute content includes animation interval characteristic data, then according to the data storage structure corresponding to the animation interval characteristic data, parse the animation interval characteristic data corresponding to the attribute from the dynamic attribute data block; if the value of the animation interval identification bit indicates that the attribute content does not include animation interval characteristic data, then directly parse the attribute content corresponding to the attribute from the dynamic attribute data block according to the data type of the attribute.

具体地,当内容标识位的值表示动态属性数据块中存在属性对应的属性内容时,比如内容标识位为1时,则该属性对应的属性标识信息至少还包括动画区间标识位,也就是属性标识信息至少占用2个比特位。当读取内容标识位的下一比特位的值(比如1)表示属性内容包括动画区间特性数据,也就是属性标识信息的第2位也为1时,则需要按照动画区间特性数据对应的数据存储结构解析动态属性数据块中与该属性对应的属性内容。当读取内容标识位的下一比特位的值(比如0)表示属性内容不包括动画区间特性数据,也就是属性标识信息的第2位也为0时,也就是属性标识信息为“10”时,则直接按照该属性对应的数据类型解析动态属性数据块中与该属性对应的属性内容。Specifically, when the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, for example, when the content identification bit is 1, the attribute identification information corresponding to the attribute also includes at least the animation interval identification bit, that is, the attribute identification information occupies at least 2 bits. When the value of the next bit of the content identification bit (for example, 1) is read, it indicates that the attribute content includes animation interval characteristic data, that is, the second bit of the attribute identification information is also 1, then it is necessary to parse the attribute content corresponding to the attribute in the dynamic attribute data block according to the data storage structure corresponding to the animation interval characteristic data. When the value of the next bit of the content identification bit (for example, 0) is read, it indicates that the attribute content does not include animation interval characteristic data, that is, the second bit of the attribute identification information is also 0, that is, when the attribute identification information is "10", the attribute content corresponding to the attribute in the dynamic attribute data block is directly parsed according to the data type corresponding to the attribute.

在一个实施例中,动画区间特性数据对应的数据存储结构所包括的字段包括动画区间数量、各动画区间的插值器类型、各动画区间的起始和结束时间,还包括各动画区间对应属性的起始值、结束值、时间缓动参数和空间缓动参数。In one embodiment, the fields included in the data storage structure corresponding to the animation interval characteristic data include the number of animation intervals, the interpolator type of each animation interval, the start and end time of each animation interval, and the start value, end value, time easing parameter and space easing parameter of the corresponding attribute of each animation interval.

动画区间特性数据对应的数据存储结构可以参考动画数据编码方法中给出的解释。这样的数据存储结构用于存储1个或多个动画区间的动画数据,并且在存储多个动画区间的动画特性数据时,是依次存储每个动画区间的一类数据后再集中存储下一类数据,而不是先存储完一个动画区间的所有数据后再存储下一个动画区间的所有数据,这样做的好处是相似的数据可以集中存储并且可以集中压缩,减小存储空间。The data storage structure corresponding to the animation interval characteristic data can refer to the explanation given in the animation data encoding method. Such a data storage structure is used to store the animation data of one or more animation intervals, and when storing the animation characteristic data of multiple animation intervals, it is to store one type of data of each animation interval in sequence and then store the next type of data in a centralized manner, rather than storing all the data of one animation interval first and then storing all the data of the next animation interval. The advantage of this is that similar data can be stored and compressed in a centralized manner, reducing storage space.

在一个实施例中,属性类型为空间缓动动画属性,若动画区间标识位的值表示属性内容包括动画区间特性数据时,则按照动画区间特性数据对应的数据存储结构,从动态属性数据块中解析属性对应的动画区间特性数据,包括:当动画区间标识位的值表示属性内容包括动画区间特性数据时,读取动画区间标识位下一比特位的值,作为空间缓动参数标识位的值;若空间缓动参数标识位的值表示动画区间特性数据包括空间缓动参数,则按照动画区间特性数据对应的数据存储结构,从动态属性数据块中解析属性对应的包括空间缓动参数的动画区间特性数据;若空间缓动参数标识位的值表示动画区间特性数据不包括空间缓动参数,则按照动画区间特性数据对应的数据存储结构,从动态属性数据块中解析属性对应的不包括空间缓动参数的动画区间特性数据。In one embodiment, the attribute type is a spatial easing animation attribute. If the value of the animation interval identification bit indicates that the attribute content includes animation interval characteristic data, the animation interval characteristic data corresponding to the attribute is parsed from the dynamic attribute data block according to the data storage structure corresponding to the animation interval characteristic data, including: when the value of the animation interval identification bit indicates that the attribute content includes animation interval characteristic data, read the value of the next bit of the animation interval identification bit as the value of the spatial easing parameter identification bit; if the value of the spatial easing parameter identification bit indicates that the animation interval characteristic data includes spatial easing parameters, then according to the data storage structure corresponding to the animation interval characteristic data, the animation interval characteristic data including the spatial easing parameters corresponding to the attribute is parsed from the dynamic attribute data block; if the value of the spatial easing parameter identification bit indicates that the animation interval characteristic data does not include spatial easing parameters, then according to the data storage structure corresponding to the animation interval characteristic data, the animation interval characteristic data not including the spatial easing parameters corresponding to the attribute is parsed from the dynamic attribute data block.

其中,空间缓动参数是用于描述复杂动效的参数。只有当属性对应的属性类型为空间缓动动画属性时,该属性对应的属性标识信息才可能占用3个比特位,并且存在空间缓动参数标识位的前提是内容标识位、动画区间标识位均为1。而对于其它属性类型,都不需要判断是否存在第三个标识位,也不需要存储空间缓动参数。Among them, the spatial easing parameter is a parameter used to describe complex animation effects. Only when the attribute type corresponding to the attribute is a spatial easing animation attribute, the attribute identification information corresponding to the attribute may occupy 3 bits, and the premise for the existence of the spatial easing parameter identification bit is that the content identification bit and the animation interval identification bit are both 1. For other attribute types, there is no need to determine whether there is a third identification bit, nor is there a need to store the spatial easing parameter.

具体地,当动画区间标识位的值表示属性内容包括动画区间特性数据时,比如动画区间标识位为1时,则该属性对应的属性标识信息至少还包括空间缓动参数标识位,也就是属性标识信息占用3个比特位。当读取的动画区间标识位下一比特位的值(比如1)表示属性内容包括空间缓动参数时,也就是属性标识信息的第3位也为1时,即属性标识信息为“111”时,则从动态属性数据块中解析属性对应的包括空间缓动参数的动画区间特性数据,并且空间缓动参数也有对应的编码结构,需要根据相应的编码结构进行解析。当读取的动画区间标识位下一比特位的值(比如0)表示属性内容不包括空间缓动参数时,属性标识信息的第3位为0时,即属性标识信息为“110”时,则从动态属性数据块中解析属性对应的动画区间特性数据不包括空间缓动参数。Specifically, when the value of the animation interval identification bit indicates that the attribute content includes animation interval characteristic data, for example, when the animation interval identification bit is 1, the attribute identification information corresponding to the attribute also includes at least the spatial easing parameter identification bit, that is, the attribute identification information occupies 3 bits. When the value of the next bit of the animation interval identification bit read (for example, 1) indicates that the attribute content includes the spatial easing parameter, that is, when the third bit of the attribute identification information is also 1, that is, when the attribute identification information is "111", the animation interval characteristic data including the spatial easing parameter corresponding to the attribute is parsed from the dynamic attribute data block, and the spatial easing parameter also has a corresponding encoding structure, which needs to be parsed according to the corresponding encoding structure. When the value of the next bit of the animation interval identification bit read (for example, 0) indicates that the attribute content does not include the spatial easing parameter, when the third bit of the attribute identification information is 0, that is, when the attribute identification information is "110", the animation interval characteristic data corresponding to the attribute parsed from the dynamic attribute data block does not include the spatial easing parameter.

需要注意的是,在按照动画区间特性数据的数据存储结构解析属性内容时,具体还需要根据属性类型确定每个动画区间是否存在插值器类型字段(离散动画属性不存在插值器类型字段,因为插值器类型默认为Hold),还要根据解析得到的插值器类型确定动画区间特性数据中是否包括时间缓动参数(因为插值器类型的值不等于Bezier时不存在时间缓动参数),根据属性标识信息确定是否存在空间缓动参数等等。也就是说,动画区间特性数据的数据存储结构中某些字段的值不一定存在,需要结合属性类型、属性标识信息、插值器类型以及动画区间对应的属性值的数据类型等一步步来判断,整个属性内容的存储结构才能逐步清晰化,从而才能从属性内容区域中解析出属性对应的属性内容。对于动画标签码对应的属性结构表中每一个属性对应的属性内容的解析过程,都是按照前面的解析思路执行的。It should be noted that when parsing the attribute content according to the data storage structure of the animation interval characteristic data, it is also necessary to determine whether there is an interpolator type field for each animation interval according to the attribute type (there is no interpolator type field for discrete animation attributes, because the interpolator type defaults to Hold), and whether the animation interval characteristic data includes time easing parameters according to the parsed interpolator type (because there is no time easing parameter when the value of the interpolator type is not equal to Bezier), and whether there is a spatial easing parameter according to the attribute identification information, etc. In other words, the values of some fields in the data storage structure of the animation interval characteristic data may not exist, and it is necessary to combine the attribute type, attribute identification information, interpolator type, and the data type of the attribute value corresponding to the animation interval to judge step by step, so that the storage structure of the entire attribute content can be gradually clarified, so that the attribute content corresponding to the attribute can be parsed from the attribute content area. The parsing process of the attribute content corresponding to each attribute in the attribute structure table corresponding to the animation tag code is executed according to the previous parsing ideas.

上述动画数据解码方法,动画标签码可用于标识一组属性,属性结构表用于描述动画标签码所标识的一组属性的数据结构,当这一组属性的属性值从种类或数量都不确定,或者当属性的属性值存在大量冗余时,为了避免额外引入大量的用于描述属性种类或数量的标识符字段导致动画文件体积太大的问题,引入了动态属性数据块的数据结构,可以最大化压缩这些标识符,大大减小目标动画文件占用的体积。具体地,在解码时,读取到动画标签码后,当该动画标签码对应的属性结构表中存在属性类型时,说明该动画标签码所标识的一组属性的属性值是以动态属性数据块的形式编码的,可以结合各属性对应的属性类型从动画标签码对应的动态属性数据块中解析各属性对应的属性标识信息,再基于该属性标识信息可以从动态属性数据块中解析各属性对应的属性内容,实现动画文件的解码。In the above-mentioned animation data decoding method, the animation tag code can be used to identify a group of attributes, and the attribute structure table is used to describe the data structure of a group of attributes identified by the animation tag code. When the attribute values of this group of attributes are uncertain in terms of type or quantity, or when there is a lot of redundancy in the attribute values of the attributes, in order to avoid the problem of too large animation file size caused by the additional introduction of a large number of identifier fields used to describe the type or quantity of the attributes, a data structure of a dynamic attribute data block is introduced, which can maximize the compression of these identifiers and greatly reduce the volume occupied by the target animation file. Specifically, during decoding, after reading the animation tag code, when the attribute type exists in the attribute structure table corresponding to the animation tag code, it means that the attribute values of a group of attributes identified by the animation tag code are encoded in the form of a dynamic attribute data block, and the attribute identification information corresponding to each attribute can be parsed from the dynamic attribute data block corresponding to the animation tag code in combination with the attribute type corresponding to each attribute, and then based on the attribute identification information, the attribute content corresponding to each attribute can be parsed from the dynamic attribute data block to achieve decoding of the animation file.

在一个实施例中,获取动画标签码,包括:解析目标动画文件,得到二进制序列;按照目标动画文件的目标文件结构,依次从二进制序列中读取目标动画文件的文件头编码信息和节点元素编码数据;按照目标动画文件的文件头组织结构所包括字段的排序、各字段的数据类型对文件头编码信息进行解码,得到文件头信息;按照目标动画文件的节点元素组织结构,对节点元素编码数据进行解码,依次得到动画标签码、数据块长度以及各动画标签码对应的数据块;数据块包括动态属性数据块和基础属性数据块。In one embodiment, obtaining an animation tag code includes: parsing a target animation file to obtain a binary sequence; reading file header encoding information and node element encoding data of the target animation file from the binary sequence in sequence according to a target file structure of the target animation file; decoding the file header encoding information in accordance with the order of fields included in the file header organizational structure of the target animation file and the data type of each field to obtain file header information; decoding the node element encoding data in accordance with the node element organizational structure of the target animation file to obtain the animation tag code, data block length, and data blocks corresponding to each animation tag code in sequence; the data blocks include dynamic attribute data blocks and basic attribute data blocks.

目标动画文件是PAG文件,PAG文件的文件组织结构包括文件头(FileHeader)和节点元素(Tag)。在编码整个动画文件的数据时,是按照文件头的组织结构将文件头信息进行编码,得到文件头编码信息。节点元素组织结构包括动画标签码、数据块长度以及数据块,对于从动画工程文件中获取的与各动画标签码对应的动画数据,是按照节点元素组织结构依次编码后得到节点元素编码数据。这里的数据块包括动态属性数据块和基础属性数据块。因此,在解析得到目标动画文件的二进制序列后,需要反过来按照文件头组织结构对二进制序列中的文件头编码信息进行解码,得到文件头信息,并按照节点元素组织结构对二进制序列中各节点元素编码数据进行解码,得到节点元素所包括的内容,即动画标签码、数据块长度以及各动画标签码对应的数据块。The target animation file is a PAG file, and the file organization structure of the PAG file includes a file header (FileHeader) and a node element (Tag). When encoding the data of the entire animation file, the file header information is encoded according to the organization structure of the file header to obtain the file header encoding information. The node element organization structure includes an animation tag code, a data block length, and a data block. For the animation data corresponding to each animation tag code obtained from the animation project file, the node element encoding data is obtained after being encoded in sequence according to the node element organization structure. The data block here includes a dynamic attribute data block and a basic attribute data block. Therefore, after parsing and obtaining the binary sequence of the target animation file, it is necessary to decode the file header encoding information in the binary sequence according to the file header organization structure in reverse to obtain the file header information, and decode the encoding data of each node element in the binary sequence according to the node element organization structure to obtain the content included in the node element, that is, the animation tag code, the data block length, and the data block corresponding to each animation tag code.

在一个实施例中,目标动画文件按照矢量导出方式对动画工程文件进行导出得到;解析目标动画文件,得到二进制序列,包括:获取矢量导出方式所对应的文件数据结构;根据文件数据结构解析目标动画文件,得到表示动画矢量数据的二进制序列。In one embodiment, a target animation file is obtained by exporting an animation project file in accordance with a vector export method; parsing the target animation file to obtain a binary sequence includes: obtaining a file data structure corresponding to the vector export method; parsing the target animation file according to the file data structure to obtain a binary sequence representing animation vector data.

如图15所示,为一个实施例中矢量导出方式所对应的文件数据结构。参照图15,整个目标动画文件是由所有图层的图层信息合成得到的,VectorComposition表示整个文件,它包括CompositionAttributes和Layer。CompositionAttributes表示动画基础属性数据,包括动画宽度width、高度height等,还包括整个动画的时长duration、帧率framerate、背景颜色backgroundcolor等。Layer表示动画图层数据,包括各个图层对应的数据,在原动画文件中,可能使用了不同类型的图层,可以包括但不限于虚拟对象(NullObjectLayer)、实色图层(SolidLayer)、文本图层(TextLayer)、形状图层(ShapeLayer)、图像图层(ImageLayer)、预合成图层(PreComposeLayer)等。因此,在解析目标动画文件得到的二进制序列,是按照上述图层结构描述图层信息的动画矢量数据。以实色图层为例,对应的描述信息包括图层的宽高、颜色以及图层属性(LayerAttributes),图层属性包括基础属性和动画属性组,基础属性包括图层时长duration,图层起始时间startTime(在播放哪一帧时需要获取使用该图层)和拉伸参数stretch等;动画属性组包括transform、mask、trackMatter、layerStyle、effect和content。一个图层是由这6类动画属性组中任意一种或多种组合得到的。As shown in Figure 15, it is the file data structure corresponding to the vector export method in one embodiment. Referring to Figure 15, the entire target animation file is synthesized by the layer information of all layers. VectorComposition represents the entire file, which includes CompositionAttributes and Layer. CompositionAttributes represents the basic attribute data of the animation, including the animation width width, height height, etc., as well as the duration duration, frame rate framerate, background color backgroundcolor, etc. of the entire animation. Layer represents the animation layer data, including the data corresponding to each layer. In the original animation file, different types of layers may be used, which may include but are not limited to virtual objects (NullObjectLayer), solid color layers (SolidLayer), text layers (TextLayer), shape layers (ShapeLayer), image layers (ImageLayer), pre-composite layers (PreComposeLayer), etc. Therefore, the binary sequence obtained by parsing the target animation file is the animation vector data that describes the layer information according to the above-mentioned layer structure. Taking a solid color layer as an example, the corresponding description information includes the width, height, color, and layer attributes (LayerAttributes) of the layer. The layer attributes include basic attributes and animation attribute groups. The basic attributes include the layer duration, the layer start time (which frame needs to be obtained when playing the layer), and the stretch parameter stretch, etc. The animation attribute group includes transform, mask, trackMatter, layerStyle, effect, and content. A layer is obtained by any one or more combinations of these six types of animation attribute groups.

在一个实施例中,目标动画文件按照位图序列帧导出方式对动画工程文件进行导出得到,解析目标动画文件,得到二进制序列,包括:按照图片解码方式解压目标动画文件,得到目标动画文件对应的图片二进制数据;图片二进制数据包括动画工程文件中关键位图图像的像素数据和非关键位图图像的差异像素区域的像素数据。In one embodiment, the target animation file is obtained by exporting the animation project file according to the bitmap sequence frame export method, and the target animation file is parsed to obtain a binary sequence, including: decompressing the target animation file according to the image decoding method to obtain the image binary data corresponding to the target animation file; the image binary data includes pixel data of key bitmap images in the animation project file and pixel data of difference pixel areas of non-key bitmap images.

具体地,按照位图序列帧导出方式对动画工程文件进行导出得到的目标动画文件,实际上是按照图片编码方式对非关键位图图像对应的差异像素区域以及关键位图图像进行压缩编码得到的一系列编码图片。具体步骤包括:获取动画工程文件对应的位图图像序列;将位图图像序列中的位图图像与对应的关键位图图像进行像素对比,得到位图图像中的差异像素区域;当位图图像为非关键位图图像时,则按照图片编码方式对差异像素区域进行编码,得到位图图像对应的编码图片;当位图图像为关键位图图像时,则直接采用图片编码方式对位图图像进行编码,得到位图图像对应的编码图片;根据位图图像序列中各位图图像对应的编码图片生成动画工程文件对应的目标动画文件。Specifically, the target animation file obtained by exporting the animation project file according to the bitmap sequence frame export method is actually a series of coded pictures obtained by compressing and coding the difference pixel area corresponding to the non-key bitmap image and the key bitmap image according to the picture coding method. The specific steps include: obtaining the bitmap image sequence corresponding to the animation project file; comparing the bitmap image in the bitmap image sequence with the corresponding key bitmap image to obtain the difference pixel area in the bitmap image; when the bitmap image is a non-key bitmap image, encoding the difference pixel area according to the picture coding method to obtain the coded picture corresponding to the bitmap image; when the bitmap image is a key bitmap image, directly encoding the bitmap image using the picture coding method to obtain the coded picture corresponding to the bitmap image; generating the target animation file corresponding to the animation project file according to the coded pictures corresponding to each bitmap image in the bitmap image sequence.

因此,在解析该目标动画文件时,需要按照相应的图片解码方式对目标动画文件进行解码,得到目标动画文件对应的图片二进制序列,该图片二进制数据包括动画工程文件中关键位图图像的像素数据和非关键位图图像的差异像素区域的像素数据。Therefore, when parsing the target animation file, it is necessary to decode the target animation file according to the corresponding image decoding method to obtain a binary sequence of images corresponding to the target animation file. The binary data of the image includes pixel data of the key bitmap image in the animation project file and pixel data of the difference pixel area of the non-key bitmap image.

在一个实施例中,目标动画文件按照视频序列帧导出方式对动画工程文件进行导出得到,解析目标动画文件,得到二进制序列,包括:按照视频解码方式解压目标动画文件,得到目标动画文件对应的图片二进制数据;图片二进制数据为合成位图的像素数据,合成位图是通过将动画工程文件所包括位图图像的颜色通道位图和透明度通道位图进行合成处理后得到的。In one embodiment, a target animation file is obtained by exporting an animation project file in a video sequence frame export manner, and the target animation file is parsed to obtain a binary sequence, including: decompressing the target animation file in a video decoding manner to obtain image binary data corresponding to the target animation file; the image binary data is pixel data of a synthetic bitmap, and the synthetic bitmap is obtained by synthesizing a color channel bitmap and a transparency channel bitmap of a bitmap image included in the animation project file.

具体地,按照视频序列帧导出方式对动画工程文件进行导出得到的目标动画文件的处理过程具体如下:获取动画工程文件对应的位图图像序列;将位图图像序列中各位图图像划分成颜色通道位图、透明度通道位图;合成颜色通道位图和透明度通道位图,得到合成位图;按照视频编码方式对合成位图进行编码,得到位图图像对应的编码图片;根据位图图像序列中各位图图像对应的编码图片生成动画工程文件对应的目标动画文件。Specifically, the processing procedure of the target animation file obtained by exporting the animation project file according to the video sequence frame export method is as follows: obtain a bitmap image sequence corresponding to the animation project file; divide each bitmap image in the bitmap image sequence into a color channel bitmap and a transparency channel bitmap; synthesize the color channel bitmap and the transparency channel bitmap to obtain a synthesized bitmap; encode the synthesized bitmap according to the video encoding method to obtain an encoded picture corresponding to the bitmap image; generate a target animation file corresponding to the animation project file according to the encoded picture corresponding to each bitmap image in the bitmap image sequence.

因此,在解析该目标动画文件时,需要按照相应的视频解码方式对目标动画文件进行解码,得到目标动画文件对应的合成位图对应的图片二进制数据。Therefore, when parsing the target animation file, it is necessary to decode the target animation file according to the corresponding video decoding method to obtain the image binary data corresponding to the synthetic bitmap corresponding to the target animation file.

在一个实施例中,如图16所示,提供了一种动画数据编码装置1600,该装置包括动画数据获取模块1602、属性标识信息确定模块1604、属性内容编码模块1606和数据块生成模块1608,其中:In one embodiment, as shown in FIG. 16 , an animation data encoding device 1600 is provided, the device comprising an animation data acquisition module 1602, an attribute identification information determination module 1604, an attribute content encoding module 1606 and a data block generation module 1608, wherein:

动画数据获取模块1602,用于从动画工程文件中获取与各动画标签码对应的动画数据;Animation data acquisition module 1602, used to acquire animation data corresponding to each animation tag code from the animation project file;

属性标识信息确定模块1604,用于当与动画标签码对应的属性结构表中存在属性类型时,则确定各属性对应的属性标识信息;The attribute identification information determination module 1604 is used to determine the attribute identification information corresponding to each attribute when there is an attribute type in the attribute structure table corresponding to the animation tag code;

属性内容编码模块1606,用于按照属性标识信息,对动画数据中与各属性对应的属性值进行编码,得到各属性对应的属性内容;The attribute content encoding module 1606 is used to encode the attribute value corresponding to each attribute in the animation data according to the attribute identification information to obtain the attribute content corresponding to each attribute;

数据块生成模块1608,用于根据属性结构表中各属性对应的属性排序,将各属性对应的属性标识信息、属性内容依次存储,得到动画标签码对应的动态属性数据块。The data block generation module 1608 is used to sort the attributes corresponding to the attributes in the attribute structure table, store the attribute identification information and attribute content corresponding to the attributes in sequence, and obtain the dynamic attribute data block corresponding to the animation tag code.

在一个实施例中,动画数据编码装置1600还包括基础属性数据块生成模块,用于当与动画标签码对应的属性结构表中不存在属性类型时,则根据属性结构表中各属性对应的数据类型、属性排序,依次对动画数据中与各属性对应的属性值进行编码,得到动画标签码对应的基础属性数据块。In one embodiment, the animation data encoding device 1600 also includes a basic attribute data block generation module, which is used to encode the attribute values corresponding to each attribute in the animation data in turn according to the data type and attribute sorting corresponding to each attribute in the attribute structure table when the attribute type does not exist in the attribute structure table corresponding to the animation tag code, so as to obtain the basic attribute data block corresponding to the animation tag code.

在一个实施例中,属性对应的属性类型为普通属性或布尔属性,属性对应的属性标识信息仅包括内容标识位;属性标识信息确定模块1604还用于若动画数据中与属性对应的属性值不是默认值时,则将内容标识位编码成表示动态属性数据块中存在与属性对应的属性内容的值;若动画数据中与属性对应的属性值是默认值时,则将内容标识位编码成表示动态属性数据块中不存在与属性对应的属性内容的值。In one embodiment, the attribute type corresponding to the attribute is a common attribute or a Boolean attribute, and the attribute identification information corresponding to the attribute only includes a content identification bit; the attribute identification information determination module 1604 is also used to encode the content identification bit into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block if the attribute value corresponding to the attribute in the animation data is not a default value; if the attribute value corresponding to the attribute in the animation data is a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block.

在一个实施例中,属性对应的属性类型为固定属性,属性标识信息为空;属性内容编码模块1606还用于直接根据属性对应的数据类型对动画数据中与属性对应的属性值进行编码,得到属性对应的属性内容。In one embodiment, the attribute type corresponding to the attribute is a fixed attribute, and the attribute identification information is empty; the attribute content encoding module 1606 is also used to directly encode the attribute value corresponding to the attribute in the animation data according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute.

在一个实施例中,属性对应的属性类型为简单动画属性、离散动画属性、多维时间缓动动画属性或空间缓动动画属性,属性标识信息至少包括内容标识位;属性标识信息确定模块1604还用于若动画数据中与属性对应的属性值不是默认值时,则将内容标识位编码成表示动态属性数据块中存在与属性对应的属性内容的值;若动画数据中与属性对应的属性值是默认值时,则将内容标识位编码成表示动态属性数据块中不存在与属性对应的属性内容的值。In one embodiment, the attribute type corresponding to the attribute is a simple animation attribute, a discrete animation attribute, a multi-dimensional time-easing animation attribute or a space-easing animation attribute, and the attribute identification information at least includes a content identification bit; the attribute identification information determination module 1604 is also used to encode the content identification bit into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block if the attribute value corresponding to the attribute in the animation data is not a default value; if the attribute value corresponding to the attribute in the animation data is a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block.

在一个实施例中,属性标识信息还包括动画区间标识位;当内容标识位的值表示动态属性数据块中存在与属性对应的属性内容时,属性标识信息确定模块1604还用于若属性值包括动画区间特性数据时,则将动画区间标识位编码成表示动态属性数据块中存储的与属性对应的属性内容包括动画区间特性数据的值;若属性值不包括动画区间特性数据时,则将动画区间标识位编码成表示动态属性数据块中存储的与属性对应的属性内容不包括动画区间特性数据的值。In one embodiment, the attribute identification information also includes an animation interval identification bit; when the value of the content identification bit indicates that there is attribute content corresponding to the attribute in the dynamic attribute data block, the attribute identification information determination module 1604 is also used to, if the attribute value includes animation interval characteristic data, encode the animation interval identification bit into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes the animation interval characteristic data; if the attribute value does not include the animation interval characteristic data, encode the animation interval identification bit into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the animation interval characteristic data.

在一个实施例中,属性内容编码模块1606还用于若动画区间标识位的值表示动态属性数据块中存储的与属性对应的属性内容包括动画区间特性数据,则按照动画区间特性数据对应的数据存储结构,对属性对应的动画区间特性数据进行编码,得到与属性对应的属性内容;若动画区间标识位的值表示动态属性数据块中存储的与属性对应的属性内容不包括动画区间特性数据,则直接根据属性对应的数据类型,对动画数据中与属性对应的属性值进行编码,得到属性对应的属性内容。In one embodiment, the attribute content encoding module 1606 is also used to encode the animation interval characteristic data corresponding to the attribute according to the data storage structure corresponding to the animation interval characteristic data to obtain the attribute content corresponding to the attribute if the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data; if the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include animation interval characteristic data, then directly encode the attribute value corresponding to the attribute in the animation data according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute.

在一个实施例中,属性对应的属性类型为空间缓动动画属性,属性标识信息还包括空间缓动参数标识位;当动画区间标识位的值表示动态属性数据块中存储的与属性对应的属性内容包括动画区间特性数据时,属性标识信息确定模块1604还用于若动画区间特性数据包括空间缓动参数,则将空间缓动参数标识位编码成动态属性数据块中存储的与属性对应的属性内容包括空间缓动参数的值;若动画区间特性数据不包括空间缓动参数时,则将空间缓动参数标识位编码成动态属性数据块中存储的与属性对应的属性内容不包括空间缓动参数的值。In one embodiment, the attribute type corresponding to the attribute is a spatial easing animation attribute, and the attribute identification information also includes a spatial easing parameter identification bit; when the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data, the attribute identification information determination module 1604 is also used to encode the spatial easing parameter identification bit into the value of the attribute content corresponding to the attribute stored in the dynamic attribute data block including the spatial easing parameters if the animation interval characteristic data includes the spatial easing parameters; if the animation interval characteristic data does not include the spatial easing parameters, the spatial easing parameter identification bit is encoded into the value of the attribute content corresponding to the attribute stored in the dynamic attribute data block not including the spatial easing parameters.

在一个实施例中,属性内容编码模块1606还用于当空间缓动参数标识位的值表示动态属性数据块中存储的与属性对应的属性内容包括空间缓动参数时,则按照动画区间特性数据对应的数据存储结构,对属性对应的动画区间特性数据进行编码,得到与属性对应的包括空间缓动参数的属性内容,否则,得到与属性对应的不包括空间缓动参数的属性内容。In one embodiment, the attribute content encoding module 1606 is also used to encode the animation interval characteristic data corresponding to the attribute according to the data storage structure corresponding to the animation interval characteristic data when the value of the spatial easing parameter identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes the spatial easing parameters, so as to obtain the attribute content corresponding to the attribute including the spatial easing parameters; otherwise, the attribute content corresponding to the attribute not including the spatial easing parameters is obtained.

在一个实施例中,动画区间特性数据对应的数据存储结构所包括的字段包括动画区间数量、各动画区间的插值器类型、各动画区间的起始和结束时间,还包括各动画区间对应属性的起始值、结束值、时间缓动参数和空间缓动参数。In one embodiment, the fields included in the data storage structure corresponding to the animation interval characteristic data include the number of animation intervals, the interpolator type of each animation interval, the start and end time of each animation interval, and the start value, end value, time easing parameter and space easing parameter of the corresponding attribute of each animation interval.

在一个实施例中,动画标签码为位图合成标签码;动画数据获取模块1602还用于播放动画工程文件;依次对动画工程文件对应的播放画面进行截图,得到动画工程文件对应的位图图像序列;按照位图序列帧导出方式对位图图像序列进行处理,得到位图合成标签码对应的图片二进制数据。In one embodiment, the animation tag code is a bitmap synthesis tag code; the animation data acquisition module 1602 is also used to play the animation project file; screenshots are taken of the playback screens corresponding to the animation project file in sequence to obtain a bitmap image sequence corresponding to the animation project file; the bitmap image sequence is processed according to the bitmap sequence frame export method to obtain image binary data corresponding to the bitmap synthesis tag code.

在一个实施例中,动画标签码为视频合成标签码;动画数据获取模块1602还用于播放动画工程文件;依次对动画工程文件对应的播放画面进行截图,得到动画工程文件对应的位图图像序列;按照视频序列帧导出方式对位图图像序列进行处理,得到视频合成标签码对应的图片二进制数据。In one embodiment, the animation tag code is a video synthesis tag code; the animation data acquisition module 1602 is also used to play the animation project file; screenshots are taken of the playback screens corresponding to the animation project file in sequence to obtain a bitmap image sequence corresponding to the animation project file; the bitmap image sequence is processed according to the video sequence frame export method to obtain image binary data corresponding to the video synthesis tag code.

在一个实施例中,动画数据编码装置1600还包括文件头信息编码模块、节点元素编码模块和目标动画文件生成模块,文件头信息编码模块用于按照文件头组织结构,将文件头信息依次编码,得到文件头编码信息;节点元素编码模块用于按照节点元素组织结构,将动画标签码、数据块长度和数据块依次编码,得到节点元素编码数据;数据块包括动态属性数据块和基础属性数据块;目标动画文件生成模块用于将文件头编码信息、各节点元素编码数据按照目标文件结构进行组织,得到目标动画文件。In one embodiment, the animation data encoding device 1600 also includes a file header information encoding module, a node element encoding module and a target animation file generation module. The file header information encoding module is used to encode the file header information in sequence according to the file header organization structure to obtain the file header encoding information; the node element encoding module is used to encode the animation tag code, the data block length and the data block in sequence according to the node element organization structure to obtain the node element encoding data; the data block includes a dynamic attribute data block and a basic attribute data block; the target animation file generation module is used to organize the file header encoding information and each node element encoding data according to the target file structure to obtain the target animation file.

上述动画数据编码装置中,动画标签码可用于标识一组属性,属性结构表用于描述动画标签码所标识的一组属性的数据结构,当这一组属性的属性值从种类或数量都不确定,或者当属性的属性值存在大量冗余时,为了避免额外引入大量的用于描述属性种类或数量的标识符字段导致动画文件体积太大的问题,引入了动态属性数据块的数据结构,可以最大化压缩这些标识符,大大减小目标动画文件占用的体积。具体地,在获取到动画工程文件后,按照动画标签码对应的属性结构表所包括的一组属性,从动画工程文件中获取这一组属性的属性值,动态属性数据块中的属性标识信息用于描述属性的属性状态,当属性结构表中存在属性类型时,可以根据动画数据确定各个属性对应的属性标识信息,再按照属性标识信息对各属性对应的属性值进行动态编码得到对应的属性内容,结合属性结构表中各属性的属性标识信息和属性内容得到动画标签码对应的动态属性数据块,可以显著减少动画文件占用的空间。In the above-mentioned animation data encoding device, the animation tag code can be used to identify a group of attributes, and the attribute structure table is used to describe the data structure of a group of attributes identified by the animation tag code. When the attribute values of this group of attributes are uncertain in terms of type or quantity, or when there is a lot of redundancy in the attribute values of the attributes, in order to avoid the problem of introducing a large number of identifier fields for describing the type or quantity of the attributes, which leads to a large volume of the animation file, a data structure of a dynamic attribute data block is introduced, which can maximize the compression of these identifiers and greatly reduce the volume occupied by the target animation file. Specifically, after obtaining the animation project file, according to a group of attributes included in the attribute structure table corresponding to the animation tag code, the attribute values of this group of attributes are obtained from the animation project file, and the attribute identification information in the dynamic attribute data block is used to describe the attribute state of the attribute. When there is an attribute type in the attribute structure table, the attribute identification information corresponding to each attribute can be determined according to the animation data, and then the attribute values corresponding to each attribute can be dynamically encoded according to the attribute identification information to obtain the corresponding attribute content, and the dynamic attribute data block corresponding to the animation tag code is obtained by combining the attribute identification information and the attribute content of each attribute in the attribute structure table, which can significantly reduce the space occupied by the animation file.

在一个实施例中,如图17所示,提供了一种动画数据解码装置1700,该装置包括获取模块1702、属性标识信息解析模块1704、属性内容解析模块1706,其中:In one embodiment, as shown in FIG. 17 , an animation data decoding device 1700 is provided, the device comprising an acquisition module 1702, an attribute identification information parsing module 1704, and an attribute content parsing module 1706, wherein:

获取模块1702,用于获取动画标签码;The acquisition module 1702 is used to acquire the animation tag code;

属性标识信息解析模块1704,用于当与动画标签码对应的属性结构表中存在属性类型时,则根据属性结构表中各属性对应的属性类型,从动画标签码对应的动态属性数据块中解析各属性对应的属性标识信息;The attribute identification information parsing module 1704 is used to parse the attribute identification information corresponding to each attribute from the dynamic attribute data block corresponding to the animation tag code according to the attribute type corresponding to each attribute in the attribute structure table when the attribute type exists in the attribute structure table corresponding to the animation tag code;

属性内容解析模块1706,用于根据各属性对应的属性标识信息从动态属性数据块中解析各属性对应的属性内容。The attribute content parsing module 1706 is used to parse the attribute content corresponding to each attribute from the dynamic attribute data block according to the attribute identification information corresponding to each attribute.

在一个实施例中,动画数据解码装置1700还包括基础属性数据块解析模块,用于当与动画标签码对应的属性结构表中不存在属性类型时,则根据属性结构表中各属性对应的数据类型、属性排序,依次从动画标签码对应的基础属性数据块中读取各属性对应的属性值。In one embodiment, the animation data decoding device 1700 also includes a basic attribute data block parsing module, which is used to read the attribute values corresponding to each attribute from the basic attribute data block corresponding to the animation tag code in sequence according to the data type and attribute sorting corresponding to each attribute in the attribute structure table when the attribute type does not exist in the attribute structure table corresponding to the animation tag code.

在一个实施例中,属性标识信息解析模块1704还用于查询属性结构表,得到各属性对应的属性排序;根据各属性对应的属性类型,确定各属性对应的属性标识信息所占用的比特位数;从动画标签码对应的动态属性数据块中的首个比特位开始读取数据;基于各属性对应的属性标识信息所占用的比特位数,按照属性排序从依次读取的数据中确定各属性对应的属性标识信息。In one embodiment, the attribute identification information parsing module 1704 is also used to query the attribute structure table to obtain the attribute ranking corresponding to each attribute; determine the number of bits occupied by the attribute identification information corresponding to each attribute according to the attribute type corresponding to each attribute; read data starting from the first bit in the dynamic attribute data block corresponding to the animation tag code; based on the number of bits occupied by the attribute identification information corresponding to each attribute, determine the attribute identification information corresponding to each attribute from the data read in sequence according to the attribute ranking.

在一个实施例中,属性类型为普通属性,属性标识信息仅包括内容标识位;属性内容解析模块1706还用于若内容标识位的值表示动态属性数据块中存在属性对应的属性内容,则根据属性对应的数据类型从动态属性数据块中读取属性对应的属性内容;若内容标识位的值表示动态属性数据块中不存在属性对应的属性内容,则从属性结构表中查询与属性对应的默认值。In one embodiment, the attribute type is a common attribute, and the attribute identification information only includes a content identification bit; the attribute content parsing module 1706 is also used to read the attribute content corresponding to the attribute from the dynamic attribute data block according to the data type corresponding to the attribute if the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block; if the value of the content identification bit indicates that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block, then query the default value corresponding to the attribute from the attribute structure table.

在一个实施例中,属性类型为固定属性,属性标识信息为空;属性内容解析模块1706还用于直接根据属性对应的数据类型从动态属性数据块中读取属性对应的属性内容。In one embodiment, the attribute type is a fixed attribute, and the attribute identification information is empty; the attribute content parsing module 1706 is further used to directly read the attribute content corresponding to the attribute from the dynamic attribute data block according to the data type corresponding to the attribute.

在一个实施例中,属性类型为布尔属性,属性标识信息仅包括内容标识位;属性内容解析模块1706还用于直接将内容标识位的值作为属性对应的属性内容。In one embodiment, the attribute type is a Boolean attribute, and the attribute identification information only includes a content identification bit; the attribute content parsing module 1706 is further configured to directly use the value of the content identification bit as the attribute content corresponding to the attribute.

在一个实施例中,属性类型为简单动画属性、离散动画属性、多维时间缓动动画属性或空间缓动动画属性,属性标识信息至少包括内容标识位;属性内容解析模块1706还用于若内容标识位的值表示动态属性数据块中存在属性对应的属性内容,则从动态属性数据块中读取属性对应的属性内容;若内容标识位的值表示动态属性数据块中不存在属性对应的属性内容时,则根据属性结构表查询与属性对应的默认值。In one embodiment, the attribute type is a simple animation attribute, a discrete animation attribute, a multi-dimensional time-delayed animation attribute or a space-delayed animation attribute, and the attribute identification information includes at least a content identification bit; the attribute content parsing module 1706 is also used to read the attribute content corresponding to the attribute from the dynamic attribute data block if the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block; if the value of the content identification bit indicates that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block, then query the default value corresponding to the attribute according to the attribute structure table.

在一个实施例中,属性内容解析模块1706还用于当内容标识位的值表示动态属性数据块中存在属性对应的属性内容时,读取内容标识位下一比特位的值,作为动画区间标识位的值;若动画区间标识位的值表示属性内容包括动画区间特性数据时,则按照动画区间特性数据对应的数据存储结构,从动态属性数据块中解析属性对应的动画区间特性数据;若动画区间标识位的值表示属性内容不包括动画区间特性数据时,则直接根据属性的数据类型从动态属性数据块中解析属性对应的属性内容。In one embodiment, the attribute content parsing module 1706 is also used to read the value of the next bit of the content identification bit as the value of the animation interval identification bit when the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block; if the value of the animation interval identification bit indicates that the attribute content includes animation interval characteristic data, then the animation interval characteristic data corresponding to the attribute is parsed from the dynamic attribute data block according to the data storage structure corresponding to the animation interval characteristic data; if the value of the animation interval identification bit indicates that the attribute content does not include animation interval characteristic data, then the attribute content corresponding to the attribute is directly parsed from the dynamic attribute data block according to the data type of the attribute.

在一个实施例中,属性类型为空间缓动动画属性,属性内容解析模块1706还用于当动画区间标识位的值表示属性内容包括动画区间特性数据时,读取动画区间标识位下一比特位的值,作为空间缓动参数标识位的值;若空间缓动参数标识位的值表示动画区间特性数据包括空间缓动参数,则按照动画区间特性数据对应的数据存储结构,从动态属性数据块中解析属性对应的包括空间缓动参数的动画区间特性数据;若空间缓动参数标识位的值表示动画区间特性数据不包括空间缓动参数,则按照动画区间特性数据对应的数据存储结构,从动态属性数据块中解析属性对应的不包括空间缓动参数的动画区间特性数据。In one embodiment, the attribute type is a spatial easing animation attribute, and the attribute content parsing module 1706 is also used to read the value of the next bit of the animation interval identification bit as the value of the spatial easing parameter identification bit when the value of the animation interval identification bit indicates that the attribute content includes animation interval characteristic data; if the value of the spatial easing parameter identification bit indicates that the animation interval characteristic data includes spatial easing parameters, then according to the data storage structure corresponding to the animation interval characteristic data, the animation interval characteristic data including the spatial easing parameters corresponding to the attribute is parsed from the dynamic attribute data block; if the value of the spatial easing parameter identification bit indicates that the animation interval characteristic data does not include spatial easing parameters, then according to the data storage structure corresponding to the animation interval characteristic data, the animation interval characteristic data not including the spatial easing parameters corresponding to the attribute is parsed from the dynamic attribute data block.

在一个实施例中,动画区间特性数据对应的数据存储结构所包括的字段包括动画区间数量、各动画区间的插值器类型、各动画区间的起始和结束时间,还包括各动画区间对应属性的起始值、结束值、时间缓动参数和空间缓动参数。In one embodiment, the fields included in the data storage structure corresponding to the animation interval characteristic data include the number of animation intervals, the interpolator type of each animation interval, the start and end time of each animation interval, and the start value, end value, time easing parameter and space easing parameter of the corresponding attribute of each animation interval.

在一个实施例中,获取模块1702还包括目标动画文件解析模块、文件头信息解析模块和节点元素解析模块,目标动画文件解析模块用于解析目标动画文件,得到二进制序列;按照目标动画文件的目标文件结构,依次从二进制序列中读取目标动画文件的文件头编码信息和节点元素编码数据;文件头信息解析模块用于按照目标动画文件的文件头组织结构所包括字段的排序、各字段的数据类型对文件头编码信息进行解码,得到文件头信息;节点元素解析模块用于按照目标动画文件的节点元素组织结构,对节点元素编码数据进行解码,依次得到动画标签码、数据块长度以及各动画标签码对应的数据块;数据块包括动态属性数据块和基础属性数据块。In one embodiment, the acquisition module 1702 also includes a target animation file parsing module, a file header information parsing module and a node element parsing module. The target animation file parsing module is used to parse the target animation file to obtain a binary sequence; according to the target file structure of the target animation file, the file header encoding information and the node element encoding data of the target animation file are read from the binary sequence in sequence; the file header information parsing module is used to decode the file header encoding information according to the order of the fields included in the file header organization structure of the target animation file and the data type of each field to obtain the file header information; the node element parsing module is used to decode the node element encoding data according to the node element organization structure of the target animation file, and obtain the animation tag code, the data block length and the data block corresponding to each animation tag code in sequence; the data block includes a dynamic attribute data block and a basic attribute data block.

在一个实施例中,目标动画文件按照矢量导出方式对动画工程文件进行导出得到;目标动画文件解析模块还用于获取矢量导出方式所对应的文件数据结构;根据文件数据结构解析目标动画文件,得到表示动画矢量数据的二进制序列。In one embodiment, the target animation file is obtained by exporting the animation project file in a vector export manner; the target animation file parsing module is also used to obtain the file data structure corresponding to the vector export manner; the target animation file is parsed according to the file data structure to obtain a binary sequence representing the animation vector data.

在一个实施例中,目标动画文件按照位图序列帧导出方式对动画工程文件进行导出得到,目标动画文件解析模块还用于按照图片解码方式解压目标动画文件,得到目标动画文件对应的图片二进制数据;图片二进制数据包括动画工程文件中关键位图图像的像素数据和非关键位图图像的差异像素区域的像素数据。In one embodiment, the target animation file is obtained by exporting the animation project file in a bitmap sequence frame export method, and the target animation file parsing module is also used to decompress the target animation file in an image decoding method to obtain image binary data corresponding to the target animation file; the image binary data includes pixel data of key bitmap images in the animation project file and pixel data of difference pixel areas of non-key bitmap images.

在一个实施例中,目标动画文件按照视频序列帧导出方式对动画工程文件进行导出得到,目标动画文件解析模块还用于按照视频解码方式解压目标动画文件,得到目标动画文件对应的图片二进制数据;图片二进制数据为合成位图的像素数据,合成位图是通过将动画工程文件所包括位图图像的颜色通道位图和透明度通道位图进行合成处理后得到的。In one embodiment, the target animation file is obtained by exporting the animation project file in a video sequence frame export manner, and the target animation file parsing module is also used to decompress the target animation file in a video decoding manner to obtain image binary data corresponding to the target animation file; the image binary data is pixel data of a synthetic bitmap, and the synthetic bitmap is obtained by synthesizing the color channel bitmap and transparency channel bitmap of the bitmap image included in the animation project file.

上述动画数据解码装置1700中,动画标签码可用于标识一组属性,属性结构表用于描述动画标签码所标识的一组属性的数据结构,当这一组属性的属性值从种类或数量都不确定,或者当属性的属性值存在大量冗余时,为了避免额外引入大量的用于描述属性种类或数量的标识符字段导致动画文件体积太大的问题,引入了动态属性数据块的数据结构,可以最大化压缩这些标识符,大大减小目标动画文件占用的体积。具体地,在解码时,读取到动画标签码后,当该动画标签码对应的属性结构表中存在属性类型时,说明该动画标签码所标识的一组属性的属性值是以动态属性数据块的形式编码的,可以结合各属性对应的属性类型从动画标签码对应的动态属性数据块中解析各属性对应的属性标识信息,再基于该属性标识信息可以从动态属性数据块中解析各所述属性对应的属性内容,实现动画文件的解码。In the above-mentioned animation data decoding device 1700, the animation tag code can be used to identify a group of attributes, and the attribute structure table is used to describe the data structure of the group of attributes identified by the animation tag code. When the attribute values of this group of attributes are uncertain in terms of type or quantity, or when there is a lot of redundancy in the attribute values of the attributes, in order to avoid the problem of too large animation file size caused by the additional introduction of a large number of identifier fields for describing the type or quantity of the attributes, a data structure of a dynamic attribute data block is introduced, which can maximize the compression of these identifiers and greatly reduce the volume occupied by the target animation file. Specifically, during decoding, after reading the animation tag code, when the attribute type exists in the attribute structure table corresponding to the animation tag code, it means that the attribute values of the group of attributes identified by the animation tag code are encoded in the form of a dynamic attribute data block, and the attribute identification information corresponding to each attribute can be parsed from the dynamic attribute data block corresponding to the animation tag code in combination with the attribute type corresponding to each attribute, and then based on the attribute identification information, the attribute content corresponding to each of the attributes can be parsed from the dynamic attribute data block to achieve decoding of the animation file.

图18示出了一个实施例中计算机设备的内部结构图。该计算机设备具体可以是图1中的终端110。如图18所示,该计算机设备包括该计算机设备包括通过系统总线连接的处理器和存储器。其中,存储器包括非易失性存储介质和内存储器。该计算机设备的非易失性存储介质存储有操作系统,还可存储有计算机程序,该计算机程序被处理器执行时,可使得处理器实现动画数据编码方法或动画数据解码方法。该内存储器中也可储存有计算机程序,该计算机程序被处理器执行时,可使得处理器执行动画数据编码方法或动画数据解码方法。FIG18 shows an internal structure diagram of a computer device in one embodiment. The computer device may specifically be the terminal 110 in FIG1 . As shown in FIG18 , the computer device includes a processor and a memory connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program, which, when executed by the processor, enables the processor to implement an animation data encoding method or an animation data decoding method. The internal memory may also store a computer program, which, when executed by the processor, enables the processor to execute an animation data encoding method or an animation data decoding method.

本领域技术人员可以理解,图18中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art will understand that the structure shown in FIG. 18 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

在一个实施例中,本申请提供的动画数据编码装置1600可以实现为一种计算机程序的形式,计算机程序可在如图18所示的计算机设备上运行。计算机设备的存储器中可存储组成该动画数据编码装置1600的各个程序模块,比如,图16所示的动画数据获取模块1602、属性标识信息确定模块1604、属性内容编码模块1606和数据块生成模块1608。各个程序模块构成的计算机程序使得处理器执行本说明书中描述的本申请各个实施例的动画数据编码方法中的步骤。In one embodiment, the animation data encoding device 1600 provided by the present application can be implemented in the form of a computer program, and the computer program can be run on a computer device as shown in FIG18. The memory of the computer device can store various program modules constituting the animation data encoding device 1600, such as the animation data acquisition module 1602, the attribute identification information determination module 1604, the attribute content encoding module 1606, and the data block generation module 1608 shown in FIG16. The computer program composed of various program modules enables the processor to execute the steps of the animation data encoding method of each embodiment of the present application described in this specification.

例如,图18所示的计算机设备可以通过如图16所示的动画数据编码装置1600中的动画数据获取模块1602执行步骤S802。计算机设备可通过属性标识信息确定模块1604执行步骤S804。计算机设备可通过属性内容编码模块1606执行步骤S1606。计算机设备可通过数据块生成模块1608执行步骤S1608。For example, the computer device shown in FIG18 may perform step S802 through the animation data acquisition module 1602 in the animation data encoding device 1600 shown in FIG16. The computer device may perform step S804 through the attribute identification information determination module 1604. The computer device may perform step S1606 through the attribute content encoding module 1606. The computer device may perform step S1608 through the data block generation module 1608.

在一个实施例中,本申请提供的动画数据解码装置1700可以实现为一种计算机程序的形式,计算机程序可在如图18所示的计算机设备上运行。计算机设备的存储器中可存储组成该动画数据解码装置1700的各个程序模块,比如,图17所示的包括获取模块1702、属性标识信息解析模块1704、属性内容解析模块1706。各个程序模块构成的计算机程序使得处理器执行本说明书中描述的本申请各个实施例的动画数据编码方法中的步骤。In one embodiment, the animation data decoding device 1700 provided by the present application can be implemented in the form of a computer program, and the computer program can be run on a computer device as shown in FIG18. The memory of the computer device can store various program modules constituting the animation data decoding device 1700, for example, the acquisition module 1702, the attribute identification information parsing module 1704, and the attribute content parsing module 1706 shown in FIG17. The computer program composed of various program modules enables the processor to execute the steps of the animation data encoding method of each embodiment of the present application described in this specification.

例如,图18所示的计算机设备可以通过如图17所示的动画数据解码装置1700中的获取模块1702执行步骤S1402。计算机设备可通过属性标识信息解析模块1704执行步骤S1404。计算机设备可通过属性内容解析模块1706执行步骤S1406。For example, the computer device shown in FIG18 may perform step S1402 through the acquisition module 1702 in the animation data decoding device 1700 shown in FIG17 . The computer device may perform step S1404 through the attribute identification information parsing module 1704 . The computer device may perform step S1406 through the attribute content parsing module 1706 .

在一个实施例中,提供了一种计算机设备,包括存储器和处理器,存储器存储有计算机程序,计算机程序被处理器执行时,使得处理器执行上述动画数据编码方法的步骤。此处动画数据编码方法的步骤可以是上述各个实施例的动画数据编码方法中的步骤。In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned animation data encoding method. The steps of the animation data encoding method here may be the steps of the animation data encoding method in the above-mentioned embodiments.

在一个实施例中,提供了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时,使得处理器执行上述动画数据编码方法的步骤。此处动画数据编码方法的步骤可以是上述各个实施例的动画数据解码方法中的步骤。In one embodiment, a computer readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above animation data encoding method. The steps of the animation data encoding method here can be the steps in the animation data decoding method of each of the above embodiments.

在一个实施例中,提供了一种计算机设备,包括存储器和处理器,存储器存储有计算机程序,计算机程序被处理器执行时,使得处理器执行上述动画数据解码方法的步骤。此处动画数据解码方法的步骤可以是上述各个实施例的动画数据解码方法中的步骤。In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above animation data decoding method. The steps of the animation data decoding method here may be the steps of the animation data decoding method in each of the above embodiments.

在一个实施例中,提供了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时,使得处理器执行上述动画数据解码方法的步骤。此处动画数据解码方法的步骤可以是上述各个实施例的动画数据解码方法中的步骤。In one embodiment, a computer readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the above animation data decoding method. The steps of the animation data decoding method here can be the steps of the animation data decoding method in each of the above embodiments.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and/or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims (20)

1.一种动画数据编码方法,包括:1. A method for encoding animation data, comprising: 从动画工程文件中获取与各动画标签码对应的动画数据;Obtain animation data corresponding to each animation tag code from the animation project file; 当与所述动画标签码对应的属性结构表中不存在属性类型时,则根据所述属性结构表中各属性对应的数据类型、属性排序,依次对所述动画数据中与各所述属性对应的属性值进行编码,得到所述动画标签码对应的基础属性数据块;When the attribute type does not exist in the attribute structure table corresponding to the animation tag code, the attribute values corresponding to each attribute in the animation data are encoded in sequence according to the data type and attribute order corresponding to each attribute in the attribute structure table to obtain the basic attribute data block corresponding to the animation tag code; 当与所述动画标签码对应的属性结构表中存在属性类型时,则确定各所述属性对应的属性标识信息,按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各所述属性对应的属性内容,根据所述属性结构表中各所述属性对应的属性排序,将各所述属性对应的属性标识信息、所述属性内容依次存储,得到所述动画标签码对应的动态属性数据块。When there is an attribute type in the attribute structure table corresponding to the animation tag code, the attribute identification information corresponding to each attribute is determined, and the attribute value corresponding to each attribute in the animation data is encoded according to the attribute identification information to obtain the attribute content corresponding to each attribute. According to the attribute sorting corresponding to each attribute in the attribute structure table, the attribute identification information and the attribute content corresponding to each attribute are stored in sequence to obtain the dynamic attribute data block corresponding to the animation tag code. 2.根据权利要求1所述的方法,其特征在于,当与所述动画标签码对应的属性结构表中存在属性类型时,且所述属性类型为普通属性或布尔属性,则所述属性结构表中各属性对应的属性标识信息仅包括内容标识位;2. The method according to claim 1, characterized in that when there is an attribute type in the attribute structure table corresponding to the animation tag code, and the attribute type is a common attribute or a Boolean attribute, the attribute identification information corresponding to each attribute in the attribute structure table only includes a content identification bit; 所述方法还包括:The method further comprises: 在所述动画数据中与所述属性对应的属性值不是默认值时,将所述内容标识位编码成表示所述动态属性数据块中存在与所述属性对应的属性内容的值;When the attribute value corresponding to the attribute in the animation data is not a default value, encoding the content identification bit into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block; 在所述动画数据中与所述属性对应的属性值是默认值时,则将所述内容标识位编码成表示所述动态属性数据块中不存在与所述属性对应的属性内容的值。When the attribute value corresponding to the attribute in the animation data is a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block. 3.根据权利要求1所述的方法,其特征在于,当与所述动画标签码对应的属性结构表中存在属性类型时,且所述属性对应的属性类型为固定属性,则所述属性结构表中各属性对应的属性标识信息为空;3. The method according to claim 1, characterized in that when there is an attribute type in the attribute structure table corresponding to the animation tag code, and the attribute type corresponding to the attribute is a fixed attribute, the attribute identification information corresponding to each attribute in the attribute structure table is empty; 所述按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各所述属性对应的属性内容,根据所述属性结构表中各所述属性对应的属性排序,将各所述属性对应的属性标识信息、所述属性内容依次存储,得到所述动画标签码对应的动态属性数据块,包括:According to the attribute identification information, the attribute value corresponding to each attribute in the animation data is encoded to obtain the attribute content corresponding to each attribute, and the attribute identification information and the attribute content corresponding to each attribute are sequentially stored according to the attribute sorting corresponding to each attribute in the attribute structure table to obtain the dynamic attribute data block corresponding to the animation tag code, including: 在属性结构表中各属性对应的属性标识信息为空的情况下,直接根据所述属性对应的数据类型对所述动画数据中与所述属性对应的属性值进行编码,得到所述属性对应的属性内容;When the attribute identification information corresponding to each attribute in the attribute structure table is empty, the attribute value corresponding to the attribute in the animation data is directly encoded according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute; 根据所述属性结构表中各所述属性对应的属性排序,将各所述属性对应的属性内容依次存储,得到所述动画标签码对应的动态属性数据块。According to the attribute sorting corresponding to each of the attributes in the attribute structure table, the attribute contents corresponding to each of the attributes are stored in sequence to obtain the dynamic attribute data block corresponding to the animation tag code. 4.根据权利要求1所述的方法,其特征在于,当与所述动画标签码对应的属性结构表中存在属性类型时,且所述属性对应的属性类型为简单动画属性、离散动画属性、多维时间缓动动画属性或空间缓动动画属性时,则所述属性结构表中各属性对应的属性标识信息至少包括内容标识位;4. The method according to claim 1 is characterized in that, when there is an attribute type in the attribute structure table corresponding to the animation tag code, and the attribute type corresponding to the attribute is a simple animation attribute, a discrete animation attribute, a multi-dimensional time slow-motion animation attribute or a space slow-motion animation attribute, the attribute identification information corresponding to each attribute in the attribute structure table at least includes a content identification bit; 所述方法还包括:The method further comprises: 在所述动画数据中与所述属性对应的属性值不是默认值时,则将所述内容标识位编码成表示所述动态属性数据块中存在与所述属性对应的属性内容的值;When the attribute value corresponding to the attribute in the animation data is not a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block; 在所述动画数据中与所述属性对应的属性值是默认值时,则将所述内容标识位编码成表示所述动态属性数据块中不存在与所述属性对应的属性内容的值。When the attribute value corresponding to the attribute in the animation data is a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block. 5.根据权利要求4所述的方法,其特征在于,所述属性标识信息还包括动画区间标识位;当所述内容标识位的值表示所述动态属性数据块中存在与所述属性对应的属性内容时,所述方法还包括:5. The method according to claim 4, characterized in that the attribute identification information further includes an animation interval identification bit; when the value of the content identification bit indicates that the attribute content corresponding to the attribute exists in the dynamic attribute data block, the method further includes: 若所述属性值包括动画区间特性数据时,则将所述动画区间标识位编码成表示所述动态属性数据块中存储的与所述属性对应的属性内容包括动画区间特性数据的值;If the attribute value includes animation interval characteristic data, the animation interval identification bit is encoded into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes the animation interval characteristic data; 若所述属性值不包括动画区间特性数据时,则将所述动画区间标识位编码成表示所述动态属性数据块中存储的与所述属性对应的属性内容不包括动画区间特性数据的值。If the attribute value does not include the animation interval characteristic data, the animation interval identification bit is encoded into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the animation interval characteristic data. 6.根据权利要求5所述的方法,其特征在于,所述按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各所述属性对应的属性内容,包括:6. The method according to claim 5, characterized in that encoding the attribute values corresponding to each attribute in the animation data according to the attribute identification information to obtain the attribute content corresponding to each attribute comprises: 若所述动画区间标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容包括动画区间特性数据,则按照所述动画区间特性数据对应的数据存储结构,对所述属性对应的动画区间特性数据进行编码,得到与所述属性对应的属性内容;If the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data, encoding the animation interval characteristic data corresponding to the attribute according to the data storage structure corresponding to the animation interval characteristic data to obtain the attribute content corresponding to the attribute; 若所述动画区间标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容不包括动画区间特性数据,则直接根据所述属性对应的数据类型,对所述动画数据中与所述属性对应的属性值进行编码,得到所述属性对应的属性内容。If the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include animation interval characteristic data, the attribute value corresponding to the attribute in the animation data is encoded directly according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute. 7.根据权利要求5所述的方法,所述属性对应的属性类型为空间缓动动画属性,所述属性标识信息还包括空间缓动参数标识位;当所述动画区间标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容包括动画区间特性数据时,所述方法还包括:7. The method according to claim 5, wherein the attribute type corresponding to the attribute is a spatial easing animation attribute, and the attribute identification information further includes a spatial easing parameter identification bit; when the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data, the method further includes: 若所述动画区间特性数据包括空间缓动参数,则将所述空间缓动参数标识位编码成所述动态属性数据块中存储的与所述属性对应的属性内容包括空间缓动参数的值;If the animation interval characteristic data includes a spatial easing parameter, the spatial easing parameter identification bit is encoded into the attribute content corresponding to the attribute stored in the dynamic attribute data block including the value of the spatial easing parameter; 若所述动画区间特性数据不包括空间缓动参数时,则将所述空间缓动参数标识位编码成所述动态属性数据块中存储的与所述属性对应的属性内容不包括空间缓动参数的值。If the animation interval characteristic data does not include a spatial easing parameter, the spatial easing parameter identification bit is encoded into a value in which the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the spatial easing parameter. 8.根据权利要求7所述的方法,其特征在于,所述按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各所述属性对应的属性内容,包括:8. The method according to claim 7, characterized in that encoding the attribute values corresponding to each attribute in the animation data according to the attribute identification information to obtain the attribute content corresponding to each attribute comprises: 当所述空间缓动参数标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容包括空间缓动参数时,则按照所述动画区间特性数据对应的数据存储结构,对所述属性对应的动画区间特性数据进行编码,得到与所述属性对应的包括空间缓动参数的属性内容,否则,得到与所述属性对应的不包括空间缓动参数的属性内容。When the value of the spatial easing parameter identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes spatial easing parameters, the animation interval characteristic data corresponding to the attribute is encoded according to the data storage structure corresponding to the animation interval characteristic data to obtain the attribute content including the spatial easing parameters corresponding to the attribute; otherwise, the attribute content corresponding to the attribute not including the spatial easing parameters is obtained. 9.根据权利要求8所述的方法,所述动画区间特性数据对应的数据存储结构所包括的字段包括动画区间数量、各动画区间的插值器类型、各所述动画区间的起始和结束时间,还包括各所述动画区间对应所述属性的起始值、结束值、时间缓动参数和空间缓动参数。9. According to the method of claim 8, the fields included in the data storage structure corresponding to the animation interval characteristic data include the number of animation intervals, the interpolator type of each animation interval, the start and end time of each animation interval, and also include the start value, end value, time easing parameter and space easing parameter of the attribute corresponding to each animation interval. 10.一种动画数据编码装置,所述装置包括:10. An animation data encoding device, the device comprising: 动画数据获取模块,用于从动画工程文件中获取与各动画标签码对应的动画数据;Animation data acquisition module, used to acquire animation data corresponding to each animation tag code from the animation project file; 数据块生成模块,用于当与所述动画标签码对应的属性结构表中不存在属性类型时,则根据所述属性结构表中各属性对应的数据类型、属性排序,依次对所述动画数据中与各所述属性对应的属性值进行编码,得到所述动画标签码对应的基础属性数据块;A data block generation module, for, when the attribute type does not exist in the attribute structure table corresponding to the animation tag code, encoding the attribute values corresponding to each attribute in the animation data in sequence according to the data type and attribute order corresponding to each attribute in the attribute structure table, to obtain a basic attribute data block corresponding to the animation tag code; 属性内容编码模块,用于当与所述动画标签码对应的属性结构表中存在属性类型时,则确定各所述属性对应的属性标识信息,按照所述属性标识信息,对所述动画数据中与各所述属性对应的属性值进行编码,得到各所述属性对应的属性内容;An attribute content encoding module, for determining attribute identification information corresponding to each attribute when an attribute type exists in the attribute structure table corresponding to the animation tag code, and encoding attribute values corresponding to each attribute in the animation data according to the attribute identification information to obtain attribute content corresponding to each attribute; 所述数据块生成模块,还用于根据所述属性结构表中各所述属性对应的属性排序,将各所述属性对应的属性标识信息、所述属性内容依次存储,得到所述动画标签码对应的动态属性数据块。The data block generation module is also used to sort the attributes corresponding to each attribute in the attribute structure table, store the attribute identification information and the attribute content corresponding to each attribute in sequence, and obtain the dynamic attribute data block corresponding to the animation tag code. 11.根据权利要求10所述的装置,其特征在于,所述装置还包括:11. The device according to claim 10, characterized in that the device further comprises: 属性标识信息确定模块,用于当与所述动画标签码对应的属性结构表中存在属性类型时,且所述属性类型为普通属性或布尔属性,则所述属性结构表中各属性对应的属性标识信息仅包括内容标识位;在所述动画数据中与所述属性对应的属性值不是默认值时,将所述内容标识位编码成表示所述动态属性数据块中存在与所述属性对应的属性内容的值;在所述动画数据中与所述属性对应的属性值是默认值时,则将所述内容标识位编码成表示所述动态属性数据块中不存在与所述属性对应的属性内容的值。An attribute identification information determination module is used for, when there is an attribute type in the attribute structure table corresponding to the animation tag code, and the attribute type is a common attribute or a Boolean attribute, the attribute identification information corresponding to each attribute in the attribute structure table only includes a content identification bit; when the attribute value corresponding to the attribute in the animation data is not a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block; when the attribute value corresponding to the attribute in the animation data is a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block. 12.根据权利要求10所述的装置,其特征在于,所述装置还包括:12. The device according to claim 10, characterized in that the device further comprises: 属性标识信息确定模块,用于当与所述动画标签码对应的属性结构表中存在属性类型时,且所述属性对应的属性类型为固定属性,则所述属性结构表中各属性对应的属性标识信息为空;An attribute identification information determination module, configured to, when there is an attribute type in the attribute structure table corresponding to the animation tag code, and the attribute type corresponding to the attribute is a fixed attribute, determine that the attribute identification information corresponding to each attribute in the attribute structure table is empty; 属性内容编码模块,用于在属性结构表中各属性对应的属性标识信息为空的情况下,直接根据所述属性对应的数据类型对所述动画数据中与所述属性对应的属性值进行编码,得到所述属性对应的属性内容;An attribute content encoding module, used for directly encoding the attribute value corresponding to the attribute in the animation data according to the data type corresponding to the attribute when the attribute identification information corresponding to each attribute in the attribute structure table is empty, so as to obtain the attribute content corresponding to the attribute; 所述数据块生成模块,还用于根据所述属性结构表中各所述属性对应的属性排序,将所述属性内容依次存储,得到所述动画标签码对应的动态属性数据块。The data block generation module is further used to store the attribute contents in sequence according to the attribute sorting corresponding to each attribute in the attribute structure table, so as to obtain the dynamic attribute data block corresponding to the animation tag code. 13.根据权利要求10所述的装置,其特征在于,所述装置还包括:13. The device according to claim 10, characterized in that the device further comprises: 属性标识信息确定模块,用于当与所述动画标签码对应的属性结构表中存在属性类型时,且所述属性对应的属性类型为简单动画属性、离散动画属性、多维时间缓动动画属性或空间缓动动画属性时,则所述属性结构表中各属性对应的属性标识信息至少包括内容标识位;在所述动画数据中与所述属性对应的属性值不是默认值时,则将所述内容标识位编码成表示所述动态属性数据块中存在与所述属性对应的属性内容的值;在所述动画数据中与所述属性对应的属性值是默认值时,则将所述内容标识位编码成表示所述动态属性数据块中不存在与所述属性对应的属性内容的值。An attribute identification information determination module is used for, when there is an attribute type in the attribute structure table corresponding to the animation tag code, and the attribute type corresponding to the attribute is a simple animation attribute, a discrete animation attribute, a multi-dimensional time slow-motion animation attribute or a space slow-motion animation attribute, then the attribute identification information corresponding to each attribute in the attribute structure table includes at least a content identification bit; when the attribute value corresponding to the attribute in the animation data is not a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute exists in the dynamic attribute data block; when the attribute value corresponding to the attribute in the animation data is a default value, the content identification bit is encoded into a value indicating that the attribute content corresponding to the attribute does not exist in the dynamic attribute data block. 14.根据权利要求13所述的装置,其特征在于,所述属性标识信息还包括动画区间标识位;当所述内容标识位的值表示所述动态属性数据块中存在与所述属性对应的属性内容时,所述属性标识信息确定模块,还用于若所述属性值包括动画区间特性数据时,则将所述动画区间标识位编码成表示所述动态属性数据块中存储的与所述属性对应的属性内容包括动画区间特性数据的值;若所述属性值不包括动画区间特性数据时,则将所述动画区间标识位编码成表示所述动态属性数据块中存储的与所述属性对应的属性内容不包括动画区间特性数据的值。14. The device according to claim 13 is characterized in that the attribute identification information also includes an animation interval identification bit; when the value of the content identification bit indicates that there is an attribute content corresponding to the attribute in the dynamic attribute data block, the attribute identification information determination module is also used to, if the attribute value includes animation interval characteristic data, encode the animation interval identification bit into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes the animation interval characteristic data; if the attribute value does not include the animation interval characteristic data, encode the animation interval identification bit into a value indicating that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include the animation interval characteristic data. 15.根据权利要求14所述的装置,其特征在于,所述属性内容编码模块,还用于若所述动画区间标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容包括动画区间特性数据,则按照所述动画区间特性数据对应的数据存储结构,对所述属性对应的动画区间特性数据进行编码,得到与所述属性对应的属性内容;若所述动画区间标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容不包括动画区间特性数据,则直接根据所述属性对应的数据类型,对所述动画数据中与所述属性对应的属性值进行编码,得到所述属性对应的属性内容。15. The device according to claim 14 is characterized in that the attribute content encoding module is also used to encode the animation interval characteristic data corresponding to the attribute according to the data storage structure corresponding to the animation interval characteristic data to obtain the attribute content corresponding to the attribute if the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data; if the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block does not include animation interval characteristic data, then directly encode the attribute value corresponding to the attribute in the animation data according to the data type corresponding to the attribute to obtain the attribute content corresponding to the attribute. 16.根据权利要求14所述的装置,其特征在于,所述属性对应的属性类型为空间缓动动画属性,所述属性标识信息还包括空间缓动参数标识位;当所述动画区间标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容包括动画区间特性数据时,16. The device according to claim 14, characterized in that the attribute type corresponding to the attribute is a spatial easing animation attribute, and the attribute identification information further includes a spatial easing parameter identification bit; when the value of the animation interval identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes animation interval characteristic data, 所述属性标识信息确定模块,还用于若所述动画区间特性数据包括空间缓动参数,则将所述空间缓动参数标识位编码成所述动态属性数据块中存储的与所述属性对应的属性内容包括空间缓动参数的值;若所述动画区间特性数据不包括空间缓动参数时,则将所述空间缓动参数标识位编码成所述动态属性数据块中存储的与所述属性对应的属性内容不包括空间缓动参数的值。The attribute identification information determination module is also used to, if the animation interval characteristic data includes spatial easing parameters, encode the spatial easing parameter identification bit into the attribute content corresponding to the attribute stored in the dynamic attribute data block including the value of the spatial easing parameters; if the animation interval characteristic data does not include spatial easing parameters, encode the spatial easing parameter identification bit into the attribute content corresponding to the attribute stored in the dynamic attribute data block not including the value of the spatial easing parameters. 17.根据权利要求16所述的装置,其特征在于,所述属性内容编码模块,还用于当所述空间缓动参数标识位的值表示所述动态属性数据块中存储的与所述属性对应的属性内容包括空间缓动参数时,则按照所述动画区间特性数据对应的数据存储结构,对所述属性对应的动画区间特性数据进行编码,得到与所述属性对应的包括空间缓动参数的属性内容,否则,得到与所述属性对应的不包括空间缓动参数的属性内容。17. The device according to claim 16 is characterized in that the attribute content encoding module is also used to encode the animation interval characteristic data corresponding to the attribute according to the data storage structure corresponding to the animation interval characteristic data when the value of the spatial easing parameter identification bit indicates that the attribute content corresponding to the attribute stored in the dynamic attribute data block includes spatial easing parameters, so as to obtain the attribute content including the spatial easing parameters corresponding to the attribute; otherwise, to obtain the attribute content not including the spatial easing parameters corresponding to the attribute. 18.根据权利要求17所述的装置,其特征在于,所述动画区间特性数据对应的数据存储结构所包括的字段包括动画区间数量、各动画区间的插值器类型、各所述动画区间的起始和结束时间,还包括各所述动画区间对应所述属性的起始值、结束值、时间缓动参数和空间缓动参数。18. The device according to claim 17 is characterized in that the fields included in the data storage structure corresponding to the animation interval characteristic data include the number of animation intervals, the interpolator type of each animation interval, the start and end time of each animation interval, and also include the start value, end value, time easing parameter and space easing parameter of the attribute corresponding to each animation interval. 19.一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时,使得所述处理器执行如权利要求1至9中任一项所述方法的步骤。19. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 9. 20.一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求1至9中任一项所述方法的步骤。20. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 9.
CN201910502147.3A 2019-06-11 2019-06-11 Animation data encoding, decoding method, device, storage medium and computer equipment Active CN112150585B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910502147.3A CN112150585B (en) 2019-06-11 2019-06-11 Animation data encoding, decoding method, device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910502147.3A CN112150585B (en) 2019-06-11 2019-06-11 Animation data encoding, decoding method, device, storage medium and computer equipment

Publications (2)

Publication Number Publication Date
CN112150585A CN112150585A (en) 2020-12-29
CN112150585B true CN112150585B (en) 2024-10-15

Family

ID=73868304

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910502147.3A Active CN112150585B (en) 2019-06-11 2019-06-11 Animation data encoding, decoding method, device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN112150585B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112822265A (en) * 2021-01-05 2021-05-18 树根互联技术有限公司 Data encoding method, device, equipment end and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102289834A (en) * 2011-08-30 2011-12-21 北京瑞信在线系统技术有限公司 Micro-animation editer and edition method thereof
CN102289835A (en) * 2011-08-30 2011-12-21 北京瑞信在线系统技术有限公司 Micro-animation effect checking method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1331461A (en) * 2000-07-05 2002-01-16 欢乐盒多媒体股份有限公司 Input property device methods for animation control
US9019300B2 (en) * 2006-08-04 2015-04-28 Apple Inc. Framework for graphics animation and compositing operations
CN107707925B (en) * 2012-06-08 2020-08-18 太阳专利托管公司 Image encoding method and image encoding device
CN106952508A (en) * 2017-05-11 2017-07-14 厦门优芽网络科技有限公司 Scene animation courseware in kind
CN107808307A (en) * 2017-09-28 2018-03-16 平安科技(深圳)有限公司 Business personnel's picture forming method, electronic installation and computer-readable recording medium
CN108021366B (en) * 2017-12-04 2020-10-16 携程旅游信息技术(上海)有限公司 Interface animation realization method and device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102289834A (en) * 2011-08-30 2011-12-21 北京瑞信在线系统技术有限公司 Micro-animation editer and edition method thereof
CN102289835A (en) * 2011-08-30 2011-12-21 北京瑞信在线系统技术有限公司 Micro-animation effect checking method and device

Also Published As

Publication number Publication date
CN112150585A (en) 2020-12-29

Similar Documents

Publication Publication Date Title
CN112150587B (en) Animation data encoding, decoding method, device, storage medium and computer equipment
CN111899322B (en) Video processing method, animation rendering SDK, equipment and computer storage medium
CN101625848B (en) Realization method of vector font library oriented to embedded platform
WO2020125567A1 (en) Automatic animation generation method, and automatic animation generation system
CN103209326B (en) PNG (Portable Network Graphic) image compression method
CN105427353B (en) Compression, method for drafting and the device of scalable vector graphics
CN111899155A (en) Video processing method, video processing device, computer equipment and storage medium
CN101340587A (en) Method for encoding input image and method and device for playing encoded image
CN105933708B (en) A kind of method and apparatus of data compression and decompression
CN110113617A (en) A kind of method and device of compression of images and decompression
CN103702133B (en) A kind of compression of images methods of exhibiting and its device
AU2018233015A1 (en) System and method for image processing
CN111061722A (en) Data compression method, data decompression method, device and equipment
CN112070866B (en) Animation data encoding and decoding method and device, storage medium and computer equipment
CN112150585B (en) Animation data encoding, decoding method, device, storage medium and computer equipment
CN105513115A (en) Method and device for converting SWF into Canvas cartoon
CN116894457A (en) Network weight access method of deep learning model
CN112150589B (en) Animation data encoding and decoding method and device, storage medium and computer equipment
CN112070850B (en) Animation data encoding and decoding method and device, storage medium and computer equipment
CN107343203B (en) JPEG Lossless Compression Method Based on OPEN-EXR Image
WO2019018030A1 (en) Structured record compression and retrieval
HK40035309A (en) Method and device for encoding and decoding animation data, storage medium and computer equipment
KR100882250B1 (en) Method for compositing dynamic virtual images
CN102833547B (en) A kind of method of the quick embedded dominant information for being applied to jpeg image
Zhang The studies and implementation for conversion of image file format

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TG01 Patent term adjustment
TG01 Patent term adjustment