Encoding method, apparatus, device and storage medium

文档序号:410495 发布日期:2021-12-17 浏览:5次 中文

阅读说明:本技术 编码方法、装置、设备及存储介质 (Encoding method, apparatus, device and storage medium ) 是由 郭鲲 于 2021-08-09 设计创作,主要内容包括:本公开提供一种编码方法、装置、设备及存储介质,涉及编码技术领域,所述方法包括将当前宏块的像素值和参考宏块中相同位置的像素值进行比较;在确定所述当前宏块中变化的像素值的数量小于第一预设阈值时,将每个变化的像素值插入多叉树中,并将每个未变化的像素值设置为零;对所述多叉树中的每个像素值进行编号;根据预设编码规则对当前宏块进行编码;所述预设编码规则为根据未变化的像素值的个数和所述多叉树中的每个像素值的编号确定的规则。本公开编码得到的码流传输的是图像像素,而不是频域变化再进行量化后的频域信号,从而能够保证微小的变化都能够在解码端显示,提高了图像的显示质量。(The present disclosure provides an encoding method, apparatus, device and storage medium, relating to the technical field of encoding, wherein the method comprises comparing a pixel value of a current macro block with a pixel value of the same position in a reference macro block; when the number of changed pixel values in the current macro block is determined to be smaller than a first preset threshold value, inserting each changed pixel value into a multi-way tree, and setting each unchanged pixel value to be zero; numbering each pixel value in the multi-way tree; coding the current macro block according to a preset coding rule; the preset encoding rule is a rule determined according to the number of unchanged pixel values and the number of each pixel value in the multi-branch tree. The code stream obtained by the coding of the method transmits image pixels instead of frequency domain signals after quantization after frequency domain change, so that the tiny change can be displayed at a decoding end, and the display quality of the image is improved.)

1. A method of encoding, the method comprising:

comparing the pixel value of the current macro block with the pixel value of the same position in the reference macro block;

when the number of changed pixel values in the current macro block is determined to be smaller than a first preset threshold value, inserting each changed pixel value into a multi-way tree, and setting each unchanged pixel value to be zero;

numbering each pixel value in the multi-way tree;

coding the current macro block according to a preset coding rule; the preset encoding rule is a rule determined according to the number of unchanged pixel values and the number of each pixel value in the multi-branch tree.

2. The method of claim 1, wherein comparing the pixel value of the current macroblock with the co-located pixel value of the reference macroblock comprises:

scanning each pixel in a current macro block according to a preset sequence, and calculating a pixel value of each pixel in the current macro block;

comparing the pixel value of each pixel in the current macroblock with the pixel value of the same position in a reference macroblock;

determining that the target pixel is unchanged when the pixel value of the target pixel in the current macro block is determined to be the same as the pixel value of the pixel at the same position in the reference macro block;

and determining that the target pixel is changed when the pixel value of the target pixel in the current macro block is determined not to be the same as the pixel value of the pixel at the same position in the reference macro block.

3. The method of claim 1, further comprising:

when scanning of all macro blocks in the current frame is finished, determining whether the number of pixel values in the multi-branch tree is larger than a second preset threshold value or not;

and when the number of the pixel values in the multi-branch tree is determined to be larger than the second preset threshold, pruning the multi-branch tree until the number of the pixel values stored in the multi-branch tree is smaller than the second preset threshold.

4. The method according to claim 1, wherein said encoding the current macroblock according to the preset encoding rule comprises:

determining the number of unchanged pixel values before the first changed pixel value in the current macro block, and recording the number as a first numerical value;

inquiring a number corresponding to each changed pixel value in the current macro block in the multi-branch tree;

determining the number of unchanged pixel values between any two changed pixel values in the current macro block to obtain a second value;

determining the number of unchanged pixel values after the last changed pixel value in the current macro block, and recording as a third numerical value;

sorting the first numerical value, the number corresponding to each changed pixel value, each second numerical value and the third numerical value according to the position of each pixel in the current macro block;

and coding each numerical value in the sequencing result to obtain a coded code stream.

5. The method of claim 4, wherein said ordering said first value, said number corresponding to each changed pixel value, each said second value, and said third value comprises:

when the second value is determined to be larger than the preset step length, recording the number of unchanged pixel values between two changed pixel values corresponding to the second value as the preset step length and a fourth value; the preset step length indicates that the preset step length is reduced by one unchanged pixel value, and the sum of the fourth value and the preset step length reduced by one is equal to the second value;

when the second numerical value is determined to be smaller than the preset step length, recording the number of unchanged pixel values between two changed pixel values corresponding to the second numerical value as the second numerical value;

and when each second numerical value is larger than the preset step length, sequencing the first numerical value, the number corresponding to each changed pixel value, each preset step length, each fourth numerical value and the third numerical value according to the position of each pixel in the current macro block.

6. The method of claim 5, further comprising:

and when each second numerical value is smaller than the preset step length, sequencing the first numerical value, the serial number corresponding to each changed pixel value, each second numerical value and the third numerical value according to the position of each pixel in the current macro block.

7. The method of claim 5, further comprising:

and when a second value which is larger than the preset step length exists in all the second values and is smaller than the preset step length exists, sequencing the first value, the serial number corresponding to each changed pixel value, each second value, each preset step length, each fourth value and the third value.

8. An encoding apparatus, comprising:

the comparison module is used for comparing the pixel value of the current macro block with the pixel value of the same position in the reference macro block;

a processing module, configured to insert each changed pixel value into a multi-way tree and set each unchanged pixel value to zero when it is determined that the number of changed pixel values in the current macroblock is less than a first preset threshold;

a numbering module for numbering each pixel value in the multi-way tree;

the encoding module is used for encoding the current macro block according to a preset encoding rule; the preset encoding rule is a rule determined according to the number of unchanged pixel values and the number of each pixel value in the multi-branch tree.

9. An encoding device, characterized by comprising: a processor and a memory, the memory having stored therein at least one computer instruction, the instruction being loaded and executed by the processor to implement the steps performed in the encoding method of any one of claims 1 to 7.

10. A computer-readable storage medium having stored thereon at least one computer instruction, which is loaded and executed by a processor to perform the steps performed in the encoding method of any one of claims 1 to 7.

Technical Field

The present disclosure relates to the field of encoding technologies, and in particular, to an encoding method, an encoding apparatus, a device, and a storage medium.

Background

The computer synthetic image is an artificial image obtained by computer graphics technology and calculation through a display card on a computer. When transmitting an image, it is usually necessary to encode and decode the image.

In the related art, a computer desktop is usually acquired, and then an acquired image is divided into a plurality of macro blocks with the same size and without overlapping. When a certain macro block in the current frame is partially changed relative to a macro block at the same position in the reference frame, the macro block is coded by adopting video coding technologies such as H264, H265 and the like.

However, in the above-mentioned techniques, the video coding techniques such as H264 and H265 adopt a quantization method, so that some slight changes of the current frame from the reference frame cannot be shown in the decoded image, thereby reducing the display quality of the image.

Disclosure of Invention

The embodiment of the disclosure provides an encoding method, an encoding device, encoding equipment and a storage medium, which can solve the problem that the display quality of an image is reduced in the prior art. The technical scheme is as follows:

according to a first aspect of embodiments of the present disclosure, there is provided an encoding method, the method including:

comparing the pixel value of the current macro block with the pixel value of the same position in the reference macro block;

when the number of changed pixel values in the current macro block is determined to be smaller than a first preset threshold value, inserting each changed pixel value into a multi-way tree, and setting each unchanged pixel value to be zero;

numbering each pixel value in the multi-way tree;

coding the current macro block according to a preset coding rule; the preset encoding rule is a rule determined according to the number of unchanged pixel values and the number of each pixel value in the multi-branch tree.

The embodiment of the disclosure provides an encoding method, wherein when it is determined that the number of changed pixel values in the current macroblock is smaller than a first preset threshold, each changed pixel value is inserted into a multi-way tree, each unchanged pixel value is set to be zero, each pixel value in the multi-way tree is numbered, and finally, the current macroblock is encoded by adopting a preset encoding rule determined according to the number of the unchanged pixel values and the number of each pixel value in the multi-way tree. Therefore, the code stream obtained by coding transmits image pixels instead of frequency domain signals obtained by quantizing frequency domain changes, so that the tiny changes can be displayed at a decoding end, and the display quality of the image is improved.

In one embodiment, the comparing the pixel value of the current macroblock with the pixel value of the same position in the reference macroblock comprises:

scanning each pixel in a current macro block according to a preset sequence, and calculating a pixel value of each pixel in the current macro block;

comparing the pixel value of each pixel in the current macroblock with the pixel value of the same position in a reference macroblock;

determining that the target pixel is unchanged when the pixel value of the target pixel in the current macro block is determined to be the same as the pixel value of the pixel at the same position in the reference macro block;

and determining that the target pixel is changed when the pixel value of the target pixel in the current macro block is determined not to be the same as the pixel value of the pixel at the same position in the reference macro block.

In one embodiment, further comprising:

when scanning of all macro blocks in the current frame is finished, determining whether the number of pixel values in the multi-branch tree is larger than a second preset threshold value or not;

and when the number of the pixel values in the multi-branch tree is determined to be larger than the second preset threshold, pruning the multi-branch tree until the number of the pixel values stored in the multi-branch tree is smaller than the second preset threshold.

In one embodiment, the encoding the current macroblock according to the preset encoding rule includes:

determining the number of unchanged pixel values before the first changed pixel value in the current macro block, and recording the number as a first numerical value;

inquiring a number corresponding to each changed pixel value in the current macro block in the multi-branch tree;

determining the number of unchanged pixel values between any two changed pixel values in the current macro block to obtain a second value;

determining the number of unchanged pixel values after the last changed pixel value in the current macro block, and recording as a third numerical value;

sorting the first numerical value, the number corresponding to each changed pixel value, each second numerical value and the third numerical value according to the position of each pixel in the current macro block;

and coding each numerical value in the sequencing result to obtain a coded code stream.

In one embodiment, said sorting said first value, said number corresponding to each changed pixel value, each said second value, and said third value comprises:

when the second value is determined to be larger than the preset step length, recording the number of unchanged pixel values between two changed pixel values corresponding to the second value as the preset step length and a fourth value; the preset step length indicates that the preset step length is reduced by one unchanged pixel value, and the sum of the fourth value and the preset step length reduced by one is equal to the second value;

when the second numerical value is determined to be smaller than the preset step length, recording the number of unchanged pixel values between two changed pixel values corresponding to the second numerical value as the second numerical value;

and when each second numerical value is larger than the preset step length, sequencing the first numerical value, the number corresponding to each changed pixel value, each preset step length, each fourth numerical value and the third numerical value according to the position of each pixel in the current macro block.

In one embodiment, further comprising:

and when each second numerical value is smaller than the preset step length, sequencing the first numerical value, the serial number corresponding to each changed pixel value, each second numerical value and the third numerical value according to the position of each pixel in the current macro block.

In one embodiment, when there is a second value greater than the preset step length among all the second values and there is a second value less than the preset step length, the first value, the number corresponding to each changed pixel value, each second value, each preset step length, each fourth value, and the third value are sorted.

According to a second aspect of the embodiments of the present disclosure, there is provided an encoding apparatus including:

the comparison module is used for comparing the pixel value of the current macro block with the pixel value of the same position in the reference macro block;

a processing module, configured to insert each changed pixel value into a multi-way tree and set each unchanged pixel value to zero when it is determined that the number of changed pixel values in the current macroblock is less than a first preset threshold;

a numbering module for numbering each pixel value in the multi-way tree;

the encoding module is used for encoding the current macro block according to a preset encoding rule; the preset encoding rule is a rule determined according to the number of unchanged pixel values and the number of each pixel value in the multi-branch tree.

In one embodiment, the comparison module includes a scan sub-module, a comparison sub-module, a first determination sub-module, and a second determination sub-module;

the scanning sub-module is used for scanning each pixel in the current macro block according to a preset sequence and calculating the pixel value of each pixel in the current macro block;

the comparison sub-module is used for comparing the pixel value of each pixel in the current macro block with the pixel value at the same position in the reference macro block;

the first determining sub-module is used for determining that the target pixel is unchanged when the pixel value of the target pixel in the current macro block is determined to be the same as the pixel value of the pixel at the same position in the reference macro block;

and the second determining sub-module is used for determining that the target pixel is changed when the pixel value of the target pixel in the current macro block is determined to be not the same as the pixel value of the pixel at the same position in the reference macro block.

In one embodiment, the apparatus further comprises a determining module and a pruning module;

the determining module is configured to determine whether the number of pixel values in the multi-way tree is greater than a second preset threshold when scanning of all macro blocks in the current frame is finished;

the pruning module is configured to prune the multi-branch tree until the number of the pixel values stored in the multi-branch tree is smaller than the second preset threshold when it is determined that the number of the pixel values in the multi-branch tree is larger than the second preset threshold.

In one embodiment, the encoding module includes a third determining sub-module, a numbering sub-module, a fourth determining sub-module, a fifth determining sub-module, a sorting sub-module, and an encoding sub-module;

the third determining submodule is configured to determine the number of unchanged pixel values before a first changed pixel value in the current macroblock, and record the number as a first numerical value;

the numbering sub-module is used for inquiring the number corresponding to each changed pixel value in the current macro block in the multi-branch tree;

the third determining submodule is configured to determine the number of unchanged pixel values between any two changed pixel values in the current macroblock, so as to obtain a second value;

the fourth determining submodule is configured to determine the number of unchanged pixel values after the last changed pixel value in the current macroblock, and record the number as a third numerical value;

the sorting submodule is configured to sort the first numerical value, the number corresponding to each changed pixel value, each second numerical value, and the third numerical value according to the position of each pixel in the current macroblock;

and the coding submodule is used for coding each numerical value in the sequencing result to obtain a coding code stream.

In one embodiment, the sorting submodule includes a first recording unit, a second recording unit, and a first sorting unit;

the first recording unit is configured to record, as a preset step length and a fourth value, the number of unchanged pixel values between two changed pixel values corresponding to the second value when it is determined that the second value is greater than the preset step length; the preset step length indicates that the preset step length is reduced by one unchanged pixel value, and the sum of the fourth value and the preset step length reduced by one is equal to the second value;

the second recording unit is configured to record, as the second numerical value, the number of unchanged pixel values between two changed pixel values corresponding to the second numerical value when it is determined that the second numerical value is smaller than the preset step length;

the first sorting unit is configured to, when each of the second values is greater than the preset step length, sort the first value, the number corresponding to each changed pixel value, each preset step length, each fourth value, and the third value according to the position of each pixel in the current macroblock.

In one embodiment, the sorting submodule further comprises a second sorting unit;

and the second sorting unit is configured to, when each of the second values is smaller than the preset step length, sort the first value, the number corresponding to each changed pixel value, each of the second values, and the third value according to the position of each pixel in the current macroblock.

In one embodiment, the sorting submodule further comprises a third sorting unit;

and the third sorting unit is used for sorting the first numerical value, the serial number corresponding to each changed pixel value, each second numerical value, each preset step length, each fourth numerical value and the third numerical value when all the second numerical values have the second numerical value which is larger than the preset step length and the second numerical value which is smaller than the preset step length.

According to a third aspect of embodiments of the present disclosure, there is provided an encoding device including: a processor and a memory, the memory having stored therein at least one computer instruction, the instruction being loaded and executed by the processor to implement the steps performed in the encoding method described in the first aspect and any embodiment of the first aspect.

According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, having at least one computer instruction stored therein, the instruction being loaded and executed by a processor to implement the steps performed in the encoding method described in the first aspect and any of the embodiments of the first aspect.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.

Fig. 1 is a flowchart of an encoding method provided by an embodiment of the present disclosure;

fig. 2a is a structural diagram of an encoding apparatus provided in an embodiment of the present disclosure;

fig. 2b is a structural diagram of an encoding apparatus provided in an embodiment of the present disclosure;

fig. 2c is a structural diagram of an encoding apparatus according to an embodiment of the disclosure;

fig. 2d is a structural diagram of an encoding apparatus provided in an embodiment of the present disclosure;

fig. 2e is a structural diagram of an encoding apparatus provided in an embodiment of the present disclosure;

fig. 2f is a structural diagram of an encoding apparatus according to an embodiment of the disclosure;

fig. 2g is a structural diagram of an encoding apparatus provided in an embodiment of the present disclosure;

fig. 3 is a block diagram of an encoding device according to an embodiment of the present disclosure.

Detailed Description

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

An embodiment of the present disclosure provides an encoding method, as shown in fig. 1, the method including the following steps:

step 101, comparing the pixel value of the current macro block with the pixel value of the same position in the reference macro block.

Optionally, scanning each pixel in the current macroblock according to a preset sequence, and calculating a pixel value of each pixel in the current macroblock; comparing the pixel value of each pixel in the current macroblock with the pixel value of the same position in a reference macroblock; determining that the target pixel is unchanged when the pixel value of the target pixel in the current macro block is determined to be the same as the pixel value of the pixel at the same position in the reference macro block; and determining that the target pixel is changed when the pixel value of the target pixel in the current macro block is determined not to be the same as the pixel value of the pixel at the same position in the reference macro block.

The preset sequence is from left to right and from top to bottom, that is, each pixel in the current macroblock and the pixel at the same position in the reference macroblock are scanned sequentially from left to right and from top to bottom according to the position respectively, a pixel value of each pixel in the current macroblock and a pixel value of each pixel in the reference macroblock are calculated, if a certain target pixel in the current macroblock is the same as the pixel value of the pixel at the same position in the reference macroblock, it indicates that the target pixel has not changed, the position of the target pixel is marked as 0, and if the pixel values are different, it indicates that the target pixel has changed, the position of the target pixel is marked as an (R, G, B) pixel value or as an (Y, U, V) pixel value.

And 102, when the number of the changed pixel values in the current macro block is determined to be smaller than a first preset threshold value, inserting each changed pixel value into the multi-way tree, and setting each unchanged pixel value to be zero.

Wherein the multi-way tree comprises an 8-way tree.

Further, when scanning of all macro blocks in the current frame is finished, determining whether the number of pixel values in the multi-branch tree is greater than a second preset threshold value; and when the number of the pixel values in the multi-branch tree is determined to be larger than the second preset threshold, pruning the multi-branch tree until the number of the pixel values stored in the multi-branch tree is smaller than the second preset threshold.

For example, when it is determined that the number of changed pixel values in the current macroblock is smaller than a first preset threshold, with the encoding method in the present disclosure, during the scanning process, when it is determined that a pixel (target pixel) in the current macroblock is not changed, the position of the pixel is recorded as 0, when it is determined that the pixel in the current macroblock is changed, the position of the pixel is recorded as (R, G, B) pixel value or as (Y, U, V) pixel value, and the pixel value of the pixel is inserted into one 8-way tree, and after all macroblocks of the current frame are completely scanned, if the number of different pixel values stored in the 8-way tree is larger than a second preset threshold (256), the 8-way tree needs to be pruned until the number of different pixel values stored in the 8-way tree is smaller than 256.

And 103, numbering each pixel value in the multi-branch tree.

Illustratively, the pruned pixel values in the 8-way tree are numbered for subsequent query.

And step 104, coding the current macro block according to a preset coding rule.

The preset coding rule is determined according to the number of unchanged pixel values and the number of each pixel value in the multi-branch tree.

Optionally, determining the number of unchanged pixel values before the first changed pixel value in the current macroblock, and recording as a first numerical value; inquiring a number corresponding to each changed pixel value in the current macro block in the multi-branch tree; determining the number of unchanged pixel values between any two changed pixel values in the current macro block to obtain a second value; determining the number of unchanged pixel values after the last changed pixel value in the current macro block, and recording as a third numerical value; sorting the first numerical value, the number corresponding to each changed pixel value, each second numerical value and the third numerical value according to the position of each pixel in the current macro block; and coding each numerical value in the sequencing result to obtain a coded code stream.

For example, before starting the encoding process, the number of unchanged pixel values (set to 0) between two changed pixel values in the current macroblock represented by RL is defined, or the number of unchanged pixel values before the first changed pixel value or the number of unchanged pixel values after the last changed pixel value; VAL represents the number of pixel values in the multi-way tree (0-255). The encoding rule is as follows: 1) the encoded code stream starts with RL (the number of unchanged pixel values before the first changed pixel value) and ends with RL (the number of unchanged pixel values after the last changed pixel value); 2) if RL equals the preset step length LmaxMeans having Lmax10 (number of unchanged pixel values) followed by at least one RL; 3) the VAL must occur after one or more RLs. Then, the calculation result (intermediate result) of the current macroblock is scanned and encoded. The number of unchanged pixel values before the first changed pixel value, that is, the number of 0 before the first changed pixel value, is calculated and recorded as a first value RL1, then the corresponding number is queried in an 8-way tree according to (R, G, B) or (Y, U, V), then recorded as VAL1, all RL and VAL after calculation is performed again until the last (R, G, B) or (Y, U, V) is queried and recorded as VAL, and then the number of 0 after the last VAL, that is, the last RL, is recorded.

Where R denotes red, G denotes green, B denotes blue, Y denotes luminance, and U and V denote chromaticity.

Specifically, when it is determined that the second value is greater than the preset step length, the number of unchanged pixel values between two changed pixel values corresponding to the second value is recorded as the preset step length and a fourth value.

Wherein the preset step size indicates that the preset step size is reduced by an unchanged pixel value, and the sum of the fourth value and the preset step size reduced by one is equal to the second value.

And when each second numerical value is larger than the preset step length, sequencing the first numerical value, the number corresponding to each changed pixel value, each preset step length, each fourth numerical value and the third numerical value according to the position of each pixel in the current macro block.

For example, the following steps are carried out: assume a threshold of 5, a maximum step size of 15, and a macroblock width and height of 8. After comparing a certain macro block in the current frame with a macro block at the same position in the reference frame, the following result is obtained.

For example, as shown in table 1, white squares represent the same pixel value as the reference frame, and black squares represent different pixel values. First write the intermediate result: (R1, G1, B1), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (R3, G3, B3), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0) (R4, G4, B4). The changed pixel values (R1, G1, B1), (R2, G2, B2), (R3, G3, B3), (R4, G4, B4) are inserted into the 8-pronged tree. And after all the macro blocks are scanned, pruning the 8-way tree to obtain 256 pixel values and numbers (0-255) corresponding to the pixel values. Suppose that the number of (R1, G1, B1) is 11, the number of (R2, G2, B2) is 61, the number of (R3, G3, B3) is 91, and the number of (R4, G4, B4) is 245. And then, scanning the intermediate result to obtain a first numerical value, a serial number corresponding to each changed pixel value, each preset step length, each fourth numerical value and a third numerical value sequencing result, wherein the sequencing results are as follows: 0(RL1), 11(VAL1), 15(RL2), 2(RL3), 61(VAL2), 15(RL4), 5(RL5), 91(VAL3), 15(RL6), 11(RL7), 245(VAL4), 0(RL8), wherein the first value is 0(RL1), the third value is 0(RL8), 15(RL2) between 11(VAL1) and 61(VAL2) is a preset step size, 2(RL3) is a fourth value, 15(RL4) between 61(VAL2) and 91(VAL3) is also a preset step size, 5(RL5) is a fourth value, and so on.

Because of the preset step length LmaxEqual to 15, 4 bits are needed to represent RL, so the final encoded codestream is 0000000010111111001000111101111101010101101111111011111101010000.

It should be noted that the preset steps 15(RL2), 15(RL4), and 15(RL6) in the above sorting result all indicate that there are 14 0, 15(RL2) and the next adjacent 2(RL3) which are added up to equal the total number of 0 between VAL1 and VAL2, which is 14+2, which is 16; 15(RL4) and the next adjacent 5(RL5) add up to a total of 0 between VAL2 and VAL3, 14+5 ═ 19; 15(RL6) and the next following 11(RL7) add up to the total number of 0's between VAL3 and VAL4, 14+11 equals 26.

TABLE 1

And recording the number of unchanged pixel values between two changed pixel values corresponding to the second numerical value as the second numerical value when the second numerical value is determined to be smaller than the preset step length.

And when each second numerical value is smaller than the preset step length, sequencing the first numerical value, the serial number corresponding to each changed pixel value, each second numerical value and the third numerical value according to the position of each pixel in the current macro block.

For example, as shown in table 2, white squares represent the same pixel value as the reference frame, and black squares represent different pixel values. First write the intermediate result: (R1, G1, B1), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (R2, G2, B2), (0), (0), (R3, G3, B3), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (R4, G4, B4), (0), (0), (0), (0), (0), (0), (0), (0), (R5, G5, B5), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0) (0), (R7, G7, B7), (0), (0). The changed pixel values (R1, G1, B1), (R2, G2, B2), (R3, G3, B3), (R4, G4, B4), (R5, G5, B5), (R6, G6, B6), (R7, G7, B7) are inserted into an 8-pronged tree. And after all the macro blocks are scanned, pruning the 8-way tree to obtain 256 pixel values and numbers (0-255) corresponding to the pixel values. Suppose that the numbers of (R1, G1, B1) are 11, the numbers of (R2, G2, B2) are 31, the numbers of (R3, G3, B3) are 41, the numbers of (R4, G4, B4) are 51, the numbers of (R5, G5, B5) are 91, the numbers of (R6, G6, B6) are 121, and the numbers of (R7, G7, B7) are 245. And then, scanning the intermediate result to obtain a first numerical value, a number corresponding to each changed pixel value, each second numerical value and a third numerical value sequencing result, wherein the sequencing results are as follows: 0(RL1), 11(VAL1), 14(RL2), 31(VAL2), 2(RL3), 41(VAL3), 12(RL4), 51(VAL4), 5(RL5), 91(VAL5), 14(RL6), 121(VAL7), 8(RL7), 245(VAL8), 2(RL 8).

Because of the preset step length LmaxEqual to 15, 4 bits are needed to represent RL, so the final encoded codestream is 000000001011111000011111001000101001000011000011001101010101101100001110011110011000111101010010.

TABLE 2

And when a second value which is larger than the preset step length exists in all the second values and is smaller than the preset step length exists, sequencing the first value, the serial number corresponding to each changed pixel value, each second value, each preset step length, each fourth value and the third value.

For example, as shown in table 3, white squares represent the same pixel value as the reference frame, and black squares represent different pixel values. First write the intermediate result: (R1, G1, B1), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (R4, G4, B4), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0), (0) (R5, G5, B5). The changed pixel values (R1, G1, B1), (R2, G2, B2), (R3, G3, B3), (R4, G4, B4), (R5, G5, B5) are inserted into the 8-pronged tree. And after all the macro blocks are scanned, pruning the 8-way tree to obtain 256 pixel values and numbers (0-255) corresponding to the pixel values. Suppose that the number of (R1, G1, B1) is 11, the number of (R2, G2, B2) is 61, the number of (R3, G3, B3) is 91, the number of (R4, G4, B4) is 121, and the number of (R5, G5, B5) is 245. And then, scanning the intermediate result to obtain a first numerical value, a number corresponding to each changed pixel value, each second numerical value, each preset step length, each fourth numerical value and a third numerical value sequencing result, wherein the sequencing results are as follows: 0(RL1), 11(VAL1), 15(RL2), 2(RL3), 61(VAL2), 9(RL4), 91(VAL3), 8(RL5), 121(VAL4), 15(RL6), 11(RL7), 245(VAL4), 0(RL 8).

Because of the preset step length LmaxEqual to 15, 4 bits are needed to represent RL, so the final encoded codestream is 000000001011000011110010001111011001010110111000011110010000111100001011111101010000.

TABLE 3

The embodiment of the disclosure provides an encoding method, wherein when it is determined that the number of changed pixel values in the current macroblock is smaller than a first preset threshold, each changed pixel value is inserted into a multi-way tree, each unchanged pixel value is set to be zero, each pixel value in the multi-way tree is numbered, and finally, the current macroblock is encoded by adopting a preset encoding rule determined according to the number of the unchanged pixel values and the number of each pixel value in the multi-way tree. Therefore, the code stream obtained by coding transmits image pixels instead of frequency domain signals after quantization after frequency domain change, so that the tiny changes can be ensured to be displayed at a decoding end, and the display quality of the image is improved; in addition, the compression rate can be calculated through a first preset threshold before encoding, and the first preset threshold can be dynamically adjusted according to the bandwidth, so that the compression rate of the macro block is ensured.

Based on the encoding methods described in the above embodiments, the following are embodiments of the apparatus of the present disclosure, which may be used to perform embodiments of the method of the present disclosure.

The embodiment of the present disclosure provides an encoding apparatus, as shown in fig. 2a, the encoding apparatus 20 includes: a comparison module 201, a processing module 202, a numbering module 203 and an encoding module 204.

The comparing module 201 is configured to compare a pixel value of the current macroblock with a pixel value of the same position in the reference macroblock.

A processing module 202, configured to insert each changed pixel value into the multi-way tree and set each unchanged pixel value to zero when it is determined that the number of changed pixel values in the current macroblock is smaller than a first preset threshold.

A numbering module 203, configured to number each pixel value in the multi-way tree.

The encoding module 204 is configured to encode the current macroblock according to a preset encoding rule; the preset encoding rule is a rule determined according to the number of unchanged pixel values and the number of each pixel value in the multi-branch tree.

In one embodiment, as shown in FIG. 2b, the comparison module 201 includes a scan sub-module 2011, a comparison sub-module 2012, a first determination sub-module 2013, and a second determination sub-module 2014.

The scanning sub-module 2011 is configured to scan each pixel in the current macroblock according to a preset order, and calculate a pixel value of each pixel in the current macroblock.

The comparing sub-module 2012 is configured to compare the pixel value of each pixel in the current macroblock with the pixel value of the same position in the reference macroblock.

The first determining submodule 2013 is configured to determine that the target pixel is unchanged when it is determined that the pixel value of the target pixel in the current macroblock is the same as the pixel value of the pixel at the same position in the reference macroblock.

The second determining sub-module 2014 is configured to determine that the target pixel is changed when it is determined that the pixel value of the target pixel in the current macroblock is not the same as the pixel value of the co-located pixel in the reference macroblock.

In one embodiment, as shown in fig. 2c, the apparatus further comprises a determination module 205 and a pruning module 206.

The determining module 205 is configured to determine whether the number of pixel values in the multi-way tree is greater than a second preset threshold when scanning all macroblocks in the current frame is finished.

The pruning module 206 is configured to prune the multi-branch tree until the number of the pixel values stored in the multi-branch tree is smaller than the second preset threshold when it is determined that the number of the pixel values in the multi-branch tree is greater than the second preset threshold.

In one embodiment, as shown in fig. 2d, the encoding module 204 includes a third determining submodule 2041, a numbering submodule 2042, a fourth determining submodule 2043, a fifth determining submodule 2044, an ordering submodule 2045 and an encoding submodule 2046.

The third determining submodule 2041 is configured to determine the number of unchanged pixel values before the first changed pixel value in the current macroblock, and record the number as a first numerical value.

The number sub-module 2042 is configured to query the multi-way tree for a number corresponding to each changed pixel value in the current macroblock.

The third determining submodule 2043 is configured to determine the number of unchanged pixel values between any two changed pixel values in the current macroblock, so as to obtain a second value.

The fourth determining submodule 2044 is configured to determine the number of unchanged pixel values after the last changed pixel value in the current macroblock, and record the number as a third value.

The sorting submodule 2045 is configured to sort the first value, the number corresponding to each changed pixel value, each second value, and the third value according to the position of each pixel in the current macroblock.

And the encoding submodule 2046 is configured to encode each numerical value in the sorting result to obtain an encoded code stream.

In one embodiment, as shown in fig. 2e, the sorting submodule 2045 includes a first recording unit 20451, a second recording unit 20452 and a first sorting unit 20453.

The first recording unit 20451 is configured to record, as a preset step length and a fourth value, the number of unchanged pixel values between two changed pixel values corresponding to the second value when it is determined that the second value is greater than the preset step length; the preset step size represents that the preset step size is reduced by one unchanged pixel value, and the sum of the fourth value and the preset step size reduced by one is equal to the second value.

The second recording unit 20452 is configured to record, as the second value, the number of unchanged pixel values between two changed pixel values corresponding to the second value when it is determined that the second value is smaller than the preset step length.

The first sorting unit 20453 is configured to, when each second value is greater than the preset step length, sort the first value, the number corresponding to each changed pixel value, each preset step length, each fourth value, and the third value according to the position of each pixel in the current macroblock.

In one embodiment, as shown in fig. 2f, the sorting submodule 2045 further comprises a second sorting unit 20454.

The second sorting unit 20454 is configured to, when each of the second values is smaller than the preset step length, sort the first value, the number corresponding to each changed pixel value, each of the second values, and the third value according to the position of each pixel in the current macroblock.

In one embodiment, as shown in fig. 2g, the sorting submodule 2045 further comprises a third sorting unit 20455.

The third sorting unit 20455 is configured to, when there is a second value that is greater than the preset step length and is less than the preset step length in all the second values, sort the first value, the number corresponding to each changed pixel value, each second value, each preset step length, each fourth value, and the third value.

The embodiment of the present disclosure provides an encoding apparatus, where when it is determined that the number of changed pixel values in the current macroblock is smaller than a first preset threshold, each changed pixel value is inserted into a multi-way tree, each unchanged pixel value is set to zero, each pixel value in the multi-way tree is also numbered, and finally, the current macroblock is encoded by using a preset encoding rule determined according to the number of unchanged pixel values and the number of each pixel value in the multi-way tree. Therefore, the code stream obtained by coding transmits image pixels instead of frequency domain signals obtained by quantizing frequency domain changes, so that the tiny changes can be displayed at a decoding end, and the display quality of the image is improved.

Referring to fig. 3, an embodiment of the present disclosure further provides a frame rate control device, which includes a receiver 301, a transmitter 302, a memory 303, and a processor 304, where the transmitter 302 and the memory 303 are respectively connected to the processor 304, the memory 303 stores at least one computer instruction, and the processor 304 is configured to load and execute the at least one computer instruction to implement the encoding method described in the embodiment corresponding to fig. 1.

Based on the encoding method described in the embodiment corresponding to fig. 1, an embodiment of the present disclosure further provides a computer-readable storage medium, for example, the non-transitory computer-readable storage medium may be a Read Only Memory (ROM), a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like. The storage medium stores computer instructions for executing the encoding method described in the embodiment corresponding to fig. 1, which is not described herein again.

It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.

Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

22页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:图像处理方法及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类