Coding method and device

CN112422973BActive Publication Date: 2024-09-13XIAN WANXIANG ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011177332.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-28
Publication Date
2024-09-13
Estimated Expiration
2040-10-28

AI Technical Summary

Technical Problem

[0003]本公开实施例提供一种编码方法及装置,能够解决相关技术中编码后码流较大且安全性较低的问题

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112422973B
    Figure CN112422973B
Patent Text Reader

Abstract

The present disclosure provides a coding method and device, which relates to the field of image processing and can solve the problem of large code stream and low security after coding in related technologies. The specific technical scheme is: divide the current frame into a×a macroblocks; determine the macroblock type of each macroblock; divide the macroblocks including non-copy macroblocks into b×b small macroblocks; determine the macroblock type of each small macroblock; encode the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock, wherein, for macroblocks and small macroblocks whose macroblock types are copy macroblocks, it is only necessary to mark the macroblock type, and for small macroblocks whose macroblock types are non-copy macroblocks, pixel-by-pixel coding is performed. Among them, the current frame can be divided into macroblocks first, and then each macroblock is subdivided. After the macroblock type of macroblocks of different sizes is identified, the corresponding type of coding can be performed. In this way, the coding code stream can be reduced, and the complexity of the program and code stream can be increased, thereby improving the security performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing, and in particular to a coding method and device. Background Art

[0002] The existing VGTP codec algorithm mainly uses a fixed-size 16x16 pixel macroblock as the encoding unit, identifies the type of macroblock, and then uses the corresponding encoding method for encoding. The main objects of VGTP are computer-generated images and the future video screen size will develop towards 4K resolution. The area of ​​the same and slowly changing content in the image will increase, and using a smaller macroblock size is not conducive to reducing the bit rate. Summary of the invention

[0003] The embodiments of the present disclosure provide a coding method and device, which can solve the problem of large bit stream and low security after coding in related technologies. The technical solution is as follows:

[0004] According to a first aspect of an embodiment of the present disclosure, there is provided a coding method, the method comprising:

[0005] Divide the current frame into a×a macroblocks;

[0006] Determine the macroblock type of each macroblock; the macroblock type includes: non-copy macroblock and copy macroblock; the non-copy macroblock includes the following macroblock types: image macroblock and text macroblock; the non-copy macroblock includes the following macroblock types: unchanged macroblock, motion vector macroblock, left copy macroblock and top copy macroblock;

[0007] If the macroblock includes the non-copy macroblock, dividing the macroblock including the non-copy macroblock into b×b small macroblocks; wherein b is smaller than a;

[0008] Determine the macroblock type of each small macroblock;

[0009] The current frame is encoded according to the macroblock types of the macroblocks and the macroblock types of the small macroblocks, wherein, for the macroblocks and the small macroblocks whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock types, and for the small macroblocks whose macroblock types are non-copy-type macroblocks, pixel-by-pixel encoding is performed.

[0010] The encoding method provided by the embodiment of the present disclosure includes: dividing the current frame into a×a macroblocks; determining the macroblock type of each macroblock; the macroblock type includes: non-copy macroblocks and copy macroblocks; the non-copy macroblocks include the following macroblock types: image macroblocks and text macroblocks; the non-copy macroblocks include the following macroblock types: unchanged macroblocks, motion vector macroblocks, left copy macroblocks and upper copy macroblocks; if the macroblocks include non-copy macroblocks, the macroblocks including the non-copy macroblocks are divided into b×b small macroblocks; wherein b is less than a; determining the macroblock type of each small macroblock; encoding the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock, wherein for macroblocks and small macroblocks whose macroblock type is copy macroblocks, only the macroblock type needs to be marked, and for small macroblocks whose macroblock type is non-copy macroblocks, pixel-by-pixel encoding is performed. The current frame can be divided into macroblocks first, and then each macroblock is subdivided. After the macroblock types of macroblocks of different sizes are identified, the corresponding types of encoding can be performed, which can not only reduce the encoding code stream, but also increase the complexity of the program and code stream, thereby improving security performance.

[0011] In one embodiment, encoding the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock includes:

[0012] If the small macroblock includes the non-copy macroblock, dividing the small macroblock including the non-copy macroblock into c×c small macroblocks; wherein c is smaller than b;

[0013] Determine the macroblock type of each small macroblock;

[0014] If the small macroblock includes the non-copy macroblock, dividing the small macroblock including the non-copy macroblock into d×d minimum macroblocks; wherein d is smaller than c;

[0015] Determine the macroblock type of each minimum macroblock;

[0016] The current frame is encoded according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock, wherein for the macroblocks, the small macroblocks, the small macroblocks and the minimum macroblock whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type, and for the minimum macroblock whose macroblock type is the non-copy-type macroblock, pixel-by-pixel encoding is performed.

[0017] In one embodiment, encoding the current frame according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock, and the macroblock type of each minimum macroblock includes:

[0018] The current frame is encoded according to a preset internal encoding order, as well as the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock.

[0019] In one embodiment, determining the macroblock type of each macroblock includes:

[0020] Determine whether the current macroblock is an unchanged macroblock type;

[0021] If the current macroblock is of the unchanged macroblock type, determining that the current macroblock is the copy type macroblock;

[0022] If the current macroblock is not the unchanged macroblock type, determining whether the current macroblock is a motion vector macroblock type;

[0023] If the current macroblock is of the motion vector macroblock type, determining that the current macroblock is a copy-type macroblock;

[0024] If the current macroblock is not of the motion vector macroblock type, determining whether the current macroblock is of the left copy macroblock type;

[0025] If the current macroblock is of the left copy macroblock type, determining that the current macroblock is the copy type macroblock;

[0026] If the current macroblock is not of the left copy macroblock type, determining whether the current macroblock is of the upper copy macroblock type;

[0027] If the current macroblock is of the upper copy macroblock type, determining that the current macroblock is the copy type macroblock;

[0028] If the current macroblock is not of the upper copy macroblock type, the current macroblock is determined to be the non-copy macroblock.

[0029] In one embodiment, determining that the current macroblock is the non-copy macroblock includes:

[0030] Determine whether the current macroblock is a text macroblock type;

[0031] If the current macroblock is not of the text macroblock type, the current macroblock is determined to be of the image macroblock type.

[0032] In one embodiment, the determining whether the current macroblock is a text macroblock type includes:

[0033] Obtaining a brightness difference between a brightness value of each pixel in the current macroblock and brightness values ​​of all surrounding pixels;

[0034] Obtaining the number of target pixels in the current macroblock whose brightness difference exceeds a preset threshold;

[0035] If the ratio of the number of the target pixels to the total number of pixels in the current macroblock is greater than a preset threshold, it is determined that the current macroblock is the text macroblock type.

[0036] According to a second aspect of an embodiment of the present disclosure, there is provided an encoding device, the device comprising:

[0037] A first division module, used for dividing the current frame into a×a macroblocks;

[0038] The first determination module is used to determine the macroblock type of each macroblock; the macroblock type includes: non-copy macroblock and copy macroblock; the non-copy macroblock includes the following macroblock types: image macroblock and text macroblock; the non-copy macroblock includes the following macroblock types: unchanged macroblock, motion vector macroblock, left copy macroblock and upper copy macroblock;

[0039] A second division module is configured to divide the macroblock including the non-copy macroblock into b×b small macroblocks if the macroblock includes the non-copy macroblock; wherein b is smaller than a;

[0040] A second determination module is used to determine the macroblock type of each small macroblock;

[0041] The encoding module is used to encode the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock, wherein, for the macroblocks and small macroblocks whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type, and for the small macroblocks whose macroblock types are non-copy-type macroblocks, pixel-by-pixel encoding is performed.

[0042] In one embodiment, the encoding module includes:

[0043] The first division submodule is used for dividing the small macroblock including the non-copy macroblock into c×c small macroblocks if the small macroblock includes the non-copy macroblock; wherein c is smaller than b;

[0044] A first determination submodule is used to determine the macroblock type of each small macroblock;

[0045] A second division submodule is used for dividing the small macroblock including the non-copy macroblock into d×d minimum macroblocks if the small macroblock includes the non-copy macroblock; wherein d is smaller than c;

[0046] A second determination submodule is used to determine the macroblock type of each minimum macroblock;

[0047] The encoding submodule is used to encode the current frame according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock, wherein for the macroblocks, small macroblocks, small macroblocks and minimum macroblocks whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type, and for the minimum macroblock whose macroblock type is the non-copy-type macroblock, pixel-by-pixel encoding is performed.

[0048] In one embodiment, the encoding submodule includes:

[0049] The encoding subunit is used to encode the current frame according to a preset internal encoding order, as well as the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock.

[0050] In one embodiment, the first determining module includes:

[0051] The first judgment submodule is used to judge whether the current macroblock is an unchanged macroblock type;

[0052] A third determination submodule is used to determine that the current macroblock is the copy type macroblock if the current macroblock is the unchanged macroblock type;

[0053] A second judgment submodule is used to judge whether the current macroblock is a motion vector macroblock type if the current macroblock is not the unchanged macroblock type;

[0054] A fourth determination submodule, configured to determine that the current macroblock is the copy type macroblock if the current macroblock is the motion vector macroblock type;

[0055] A third judgment submodule is used to judge whether the current macroblock is a left copy macroblock type if the current macroblock is not the motion vector macroblock type;

[0056] A fifth determination submodule, configured to determine that the current macroblock is the copy-type macroblock if the current macroblock is of the left copy macroblock type;

[0057] A fourth judgment submodule, used for judging whether the current macroblock is an upper copy macroblock type if the current macroblock is not a left copy macroblock type;

[0058] A sixth determination submodule, configured to determine that the current macroblock is the copy-type macroblock if the current macroblock is of the upper copy macroblock type;

[0059] The seventh determination submodule is used to determine that the current macroblock is the non-copy type macroblock if the current macroblock is not the upper copy macroblock type.

[0060] In one embodiment, the seventh determining submodule includes:

[0061] A fifth judgment submodule, used to judge whether the current macroblock is a text macroblock type;

[0062] The eighth determination submodule is used to determine that the current macroblock is the image macroblock type if the current macroblock is not the text macroblock type.

[0063] In one embodiment, the fifth judgment submodule includes:

[0064] A first acquisition submodule is used to acquire a brightness difference between a brightness value of each pixel in the current macroblock and brightness values ​​of all surrounding pixels;

[0065] A second acquisition submodule, used to acquire the number of target pixels in the current macroblock whose brightness difference exceeds a preset threshold;

[0066] The ninth determination submodule is used to determine that the current macroblock is the text macroblock type if the ratio of the number of the target pixels to the total number of pixels in the current macroblock is greater than a preset threshold.

[0067] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] 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 present disclosure.

[0069] Figure 1 is a flowchart of an encoding method provided by an embodiment of the present disclosure;

[0070] Figure 2 is a flowchart of an encoding method provided by an embodiment of the present disclosure;

[0071] Figure 3 is a basic flow chart for identifying the type of macroblock provided by an embodiment of the present disclosure;

[0072] Figure 4 is a macroblock division schematic diagram provided by an embodiment of the present disclosure;

[0073] Figure 5 is a macroblock division schematic diagram provided by an embodiment of the present disclosure;

[0074] Figure 6 is a macroblock division schematic diagram provided by an embodiment of the present disclosure;

[0075] Figure 7is a coding sequence diagram provided by an embodiment of the present disclosure;

[0076] Figure 8 is a structural diagram of a coding device provided by an embodiment of the present disclosure;

[0077] Fig. 9 is a structural diagram of an encoding module in an encoding device provided by an embodiment of the present disclosure;

[0078] Fig.10 It is a structural diagram of a coding submodule in a coding device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0079] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0080] The present disclosure provides a coding method. Figure 1 As shown, the encoding method includes the following steps:

[0081] 101. Divide the current frame into a×a macroblocks.

[0082] 102. Determine the macroblock type of each macroblock; the macroblock types include: non-copy macroblocks and copy macroblocks; the non-copy macroblocks include: image macroblocks and text macroblocks; the non-copy macroblocks include: unchanged macroblocks, motion vector macroblocks, left copy macroblocks and top copy macroblocks.

[0083] In the present disclosure, unchanged macroblocks (English: unchangemb), motion vector macroblocks (English: mvmb), left copy macroblocks (English: leftcopymb) and up copy macroblocks (English: upcopymb) are referred to as copy-type macroblocks.

[0084] The image macroblock (English: picturemb) and text macroblock (English: textmb) are called non-copy macros.

[0085] 103. If the macroblock includes a non-copy macroblock, divide the macroblock including the non-copy macroblock into b×b small macroblocks; wherein b is smaller than a.

[0086] In this step, the larger non-copy macroblocks are further subdivided into smaller macroblocks, and then the macroblock type in each small macroblock is further determined.

[0087] 104. Determine the macroblock type of each small macroblock.

[0088] 105. Encode the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock. For macroblocks and small macroblocks whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type. For small macroblocks whose macroblock types are non-copy-type macroblocks, pixel-by-pixel encoding is performed.

[0089] Through this division, it can be seen that the main source of the code stream is the non-copy macroblocks. Therefore, the non-copy macroblocks can be finely divided and further divided into smaller macroblocks. Only the non-copy small macroblocks in the non-copy macroblocks are encoded. Compared with encoding the entire non-copy macroblock, the encoded pixels can be reduced to reduce the code stream.

[0090] The encoding method provided by the embodiment of the present disclosure includes: dividing the current frame into a×a macroblocks; determining the macroblock type of each macroblock; the macroblock type includes: non-copy macroblocks and copy macroblocks; the non-copy macroblocks include the following macroblock types: image macroblocks and text macroblocks; the non-copy macroblocks include the following macroblock types: unchanged macroblocks, motion vector macroblocks, left copy macroblocks and upper copy macroblocks; if the macroblocks include non-copy macroblocks, the macroblocks including the non-copy macroblocks are divided into b×b small macroblocks; wherein b is less than a; determining the macroblock type of each small macroblock; encoding the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock, wherein for macroblocks and small macroblocks whose macroblock type is copy macroblocks, only the macroblock type needs to be marked, and for small macroblocks whose macroblock type is non-copy macroblocks, pixel-by-pixel encoding is performed. The current frame can be divided into macroblocks first, and then each macroblock is subdivided. After the macroblock types of macroblocks of different sizes are identified, the corresponding types of encoding can be performed, which can not only reduce the encoding code stream, but also increase the complexity of the program and code stream, thereby improving security performance.

[0091] In one embodiment, Figure 2 As shown, the above step 105 includes the following sub-steps:

[0092] 1051. If the small macroblock includes a non-copy macroblock, divide the small macroblock including the non-copy macroblock into c×c small macroblocks; wherein c is smaller than b;

[0093] 1052. Determine the macroblock type of each small macroblock;

[0094] 1053. If the small macroblock includes a non-copy macroblock, divide the small macroblock including the non-copy macroblock into d×d minimum macroblocks, where d is less than c.

[0095] 1054. Determine the macroblock type of each minimum macroblock;

[0096] 1055. Encode the current frame according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock, wherein, for macroblocks whose macroblock types are copy-type macroblocks, small macroblocks, small-small macroblocks and minimum macroblocks, it is only necessary to mark the macroblock type, and for the minimum macroblock whose macroblock type is a non-copy-type macroblock, pixel-by-pixel encoding is performed.

[0097] Since the above-mentioned small macroblocks are not the minimum granularity, in order to further reduce the bit rate, each small macroblock can be further subdivided, and the small macroblocks of the non-copy macroblocks in the small macroblocks can be further subdivided into small macroblocks, and then the small macroblocks of the non-copy macroblocks in the small macroblocks can be further subdivided into minimum macroblocks. Since the minimum macroblock is the minimum granularity, the bit rate can be reduced to the greatest extent.

[0098] In one embodiment, the above step 1055 includes the following sub-steps:

[0099] The current frame is encoded according to a preset internal encoding order, and the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small-small macroblock, and the macroblock type of each minimum macroblock.

[0100] According to the preset order of internally encoded wavefront encoding, encoding is performed from the upper left corner to the lower right corner. This encoding method is similar to that in the related art and will not be described in detail here.

[0101] In one embodiment, Figure 3 As shown, determining the macroblock type of each macroblock includes the following sub-steps:

[0102] A1. Determine whether the current macroblock is of unchanged macroblock type;

[0103] A2. If the current macroblock is of the unchanged macroblock type, determine that the current macroblock is a copy macroblock;

[0104] A3. If the current macroblock is not of the unchanged macroblock type, determine whether the current macroblock is of the motion vector macroblock type;

[0105] A4. If the current macroblock is a motion vector macroblock type, determine that the current macroblock is a copy macroblock;

[0106] A5. If the current macroblock is not a motion vector macroblock type, determine whether the current macroblock is a left copy macroblock type;

[0107] A6. If the current macroblock is of the left copy macroblock type, determine that the current macroblock is a copy type macroblock;

[0108] A7. If the current macroblock is not a left copy macroblock type, determine whether the current macroblock is an upper copy macroblock type;

[0109] A8. If the current macroblock is of the upper copy macroblock type, determine that the current macroblock is a copy type macroblock;

[0110] A9. If the current macroblock is not of the upper copy macroblock type, determine that the current macroblock is a non-copy macroblock.

[0111] In one embodiment, determining that the current macroblock is a non-copy macroblock includes the following sub-steps:

[0112] B1, determine whether the current macroblock is a text macroblock type;

[0113] B2. If the current macroblock is not a text macroblock type, determine that the current macroblock is an image macroblock type.

[0114] In one embodiment, determining whether the current macroblock is a text macroblock type includes the following sub-steps:

[0115] C1. Obtain the brightness difference between the brightness value of each pixel in the current macroblock and the brightness values ​​of all surrounding pixels;

[0116] C2, obtaining the number of target pixels in the current macroblock whose brightness difference exceeds a preset threshold;

[0117] C3. If the ratio of the number of target pixels to the total number of pixels in the current macroblock is greater than a preset ratio, determine that the current macroblock is a text macroblock type.

[0118] That is, in the present disclosure, a high gradient contrast method is used to determine whether the current macroblock is a text macroblock type.

[0119] Specifically, the high gradient contrast algorithm compares all pixels in a block with all pixels around it, and sets a preset threshold Nt. When the brightness value of this pixel is significantly different from the brightness value of the surrounding pixels, that is, exceeds the preset threshold Nt, the pixel is determined to be a high gradient pixel. If the proportion of high gradient pixels in a block reaches a preset ratio, the block is considered to be a text type macroblock (textmb).

[0120] For example, all pixels in a block are compared with the pixels of the 8 points around it. By setting a preset threshold Nt, when the brightness value of this pixel point is significantly different from the brightness value of the surrounding pixels, that is, exceeding the preset threshold Nt, the pixel point is determined to be a high-gradient pixel. If the proportion of high-gradient pixels in a block reaches 30%, the block is considered to be a text type block (textmb).

[0121] The technical solution of the present disclosure is described below by using specific examples. In the following embodiments, it is assumed that a is 64, b is 32, c is 16, and d is 8.

[0122] The encoding method comprises the following steps:

[0123] The first step is to divide the current frame into 64x64 macroblocks and identify the type of each macroblock.

[0124] refer to Figure 3 , Figure 3 This is a basic flow chart for identifying the type of macroblock. The specific process of identifying the type of macroblock is as follows:

[0125] Step 1, determine whether the macroblock is of the unchangemb type. If not, execute step 2. If yes, determine that the macroblock is a copy type macroblock.

[0126] Step 2, determine whether the macroblock is of the mvmb motion vector macroblock type. If not, execute step 3. If yes, determine that the macroblock is a copy type macroblock.

[0127] Step 3, determine whether the macroblock is of the leftcopymb type, if not, execute step 4, if yes, determine that the macroblock is a copy type macroblock.

[0128] Step 4, determine whether the macroblock is of upcopymb type, if not, execute step 5, if yes, determine that the macroblock is a copy type macroblock.

[0129] Step 5, through high gradient comparison, determine whether the macroblock is of textmb text macroblock type, if not, determine that the macroblock is of picturemb image macroblock type, if yes, determine that the macroblock is of textmb type.

[0130] That is to say, the input macroblocks are identified as unchangemb, mvmb, leftcopymb, upcopymb, picturemb, and textmb, and the macroblocks of the types unchangemb, mvmb, leftcopymb, and upcopymb are called copy-type macroblocks.

[0131] Specifically, if the macroblock is identified as a copy macroblock, false is returned, otherwise, true is returned.

[0132] It should be noted that the copy macroblock refers to a macroblock with the same pixels as the macroblock in the previous frame or reference frame. In order to reduce the bit rate, the copy macroblock does not need to be encoded pixel by pixel during encoding, and only the type of the macroblock needs to be recorded. During decoding, the pixels in the macroblock can be directly obtained from the previous frame or reference frame.

[0133] For non-copy macroblocks, that is, picturemb type and textmb type macroblocks, pixel-by-pixel encoding is required during encoding.

[0134] Therefore, the main source of the bitstream is the non-copy macroblocks. The non-copy macroblocks can be finely divided to separate the non-copy blocks in the non-copy macroblocks. Only the non-copy blocks in the non-copy macroblocks are encoded. Compared with encoding the entire non-copy macroblock, the encoded pixels can be reduced to reduce the bitstream.

[0135] It can be understood that the second step is mainly aimed at non-copy macroblocks, and accurately distinguishes non-copy blocks from copy blocks.

[0136] The second step is to further divide the macroblocks according to their types.

[0137] Specifically, the 64x64 macroblock is decomposed into four 32x32 small macroblocks, and the type of each small macroblock is identified, such as Figure 4 shown.

[0138] The specific steps include:

[0139] Step 01, decompose the 64x64 macroblock into four 32x32 small macroblocks; determine whether at least one of the four 32x32 small macroblocks after decomposition returns true; if not, execute step 02; if yes, execute step 03.

[0140] Specifically, first decompose the 64x64 macroblock into four 32x32 small macroblocks and put them into Figure 3 In the process, the type of each small macroblock is determined; whether at least one small macroblock returns true, that is, whether at least one small macroblock is a non-copy type. If so, it means that the macroblock includes non-copy small macroblocks, and the non-copy small macroblocks can continue to be divided; if not, it means that the macroblock does not include non-copy small macroblocks, and no further division is required.

[0141] Step 02, determine whether the types of the four 32x32-sized small macroblocks after decomposition are the same; if yes, mark the four small macroblocks as this type; if no, mark the type of each small macroblock separately; and execute the third step.

[0142] Step 03, mark the corresponding type of the small macroblock whose return result is false; decompose the 32x32 small macroblock whose return result is true into 4 small macroblocks of 16x16 size, and identify the block type of each small macroblock, such as Figure 5 shown.

[0143] exist Figure 3 In the example, the return result of the small 32x32 macroblock in the upper left corner is false, and the return results of the other three small 32x32 macroblocks are true.

[0144] Step 04, determine whether the return result of at least one of the four 16x16 small macroblocks after decomposition is true; if not, execute step 05; if yes, execute step 06.

[0145] Specifically, the decomposed 4 small 16x16 macroblocks are input Figure 1 The processing flow shown in the figure determines the type of each small macroblock. The result returned when judging whether there is at least one small macroblock is true, that is, whether there is at least one small macroblock of the non-copy type. If so, it means that the small macroblock includes a small macroblock of the non-copy type, and the small macroblock of the non-copy type can be further divided; if not, it means that the small macroblock does not include a small macroblock of the non-copy type, and no further division is required.

[0146] Step 05, determine whether the types of the four 16x16 small macroblocks after decomposition are the same; if yes, mark the four small macroblocks as this type; if no, mark the type of each small macroblock separately; and execute the third step.

[0147] Step 06, mark the corresponding type of the small macroblocks whose return result is false; decompose the 16x16 small macroblocks whose return result is true into four 8x8 minimum macroblocks, and identify the block type of each minimum macroblock, such as Figure 6 shown.

[0148] Step 07, determine whether the return result of at least one of the four 8x8 minimum macroblocks after decomposition is true; if not, execute step 08; if yes, execute step 09.

[0149] Specifically, the decomposed 4 8x8 minimum macroblocks are input Figure 3 The processing flow shown in the figure determines the type of each minimum macroblock. The return result of judging whether there is at least one minimum macroblock is true, that is, whether there is at least one minimum macroblock of the non-copy type. If so, it means that the small macroblock includes the non-copy type minimum macroblock, and the non-copy type minimum macroblock can be further divided; if not, it means that the small macroblock does not include the non-copy type small macroblock, and no further division is required.

[0150] Step 08, determine whether the types of the four 8x8 minimum macroblocks after decomposition are the same; if yes, mark the four minimum macroblocks as the same type; if no, mark the type of each minimum macroblock separately; and execute the third step.

[0151] Step 09, mark the corresponding type for the minimum macroblocks whose return result is false; among the 8x8 minimum macroblocks whose return result is true, the minimum macroblocks of type textmb are marked as text encoding, and the minimum macroblocks of type picturemb are marked as jpeg encoding.

[0152] It can be understood that the smallest macroblock of 8x8 that returns a true result is a finely divided non-copy block. It is only necessary to encode these blocks pixel by pixel, which can significantly reduce the bit rate.

[0153] The third step is to encode each 64x64 macroblock in the current frame according to the block type.

[0154] Specifically, in Figure 6 The basis of Figure 7 As shown, according to the preset internal coding wavefront coding order, the 64x64 macroblock is encoded from the upper left corner to the lower left corner. That is to say, according to the division result of the second step, each small macroblock / small macroblock / minimum macroblock in the macroblock is encoded in sequence from the upper left corner to the lower left corner.

[0155] It should be noted that for blocks / small macroblocks / small macroblocks / minimum macroblocks that return false results, there is no need to encode them pixel by pixel, and only the type needs to be marked; for blocks / small macroblocks / small macroblocks / minimum macroblocks marked as text encoding and jpeg encoding, pixel by pixel encoding is required.

[0156] In the present invention, the current frame can be first divided into macroblocks of 64x64 units, and then each 64x64 macroblock is subdivided. Specifically, through high gradient contrast, the 64x64 macroblock is subdivided into blocks of different sizes such as 64x64, 32x32, 16x16, and 8x8. After the types of blocks of different sizes are identified, the corresponding types of encoding can be performed.

[0157] In this way, the encoding code stream can be reduced and the complexity of the program and code stream can be increased, thereby improving security performance.

[0158] Based on the above Figure 1 The encoding method described in the corresponding embodiment is as follows: an embodiment of the device of the present disclosure, which can be used to execute the embodiment of the method of the present disclosure.

[0159] The present disclosure provides a coding device, such as Figure 8 As shown, the device comprises:

[0160] A first division module 11 is used to divide the current frame into a×a macroblocks;

[0161] The first determination module 12 is used to determine the macroblock type of each macroblock; the macroblock type includes: non-copy macroblock and copy macroblock; the non-copy macroblock includes the following macroblock types: image macroblock and text macroblock; the non-copy macroblock includes the following macroblock types: unchanged macroblock, motion vector macroblock, left copy macroblock and top copy macroblock;

[0162] The second division module 13 is configured to divide the macroblock including the non-copy macroblock into b×b small macroblocks if the macroblock includes the non-copy macroblock; wherein b is smaller than a;

[0163] A second determination module 14 is used to determine the macroblock type of each small macroblock;

[0164] The encoding module 15 is used to encode the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock, wherein, for the macroblocks and small macroblocks whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type, and for the small macroblocks whose macroblock types are non-copy-type macroblocks, pixel-by-pixel encoding is performed.

[0165] In one embodiment, Fig. 9 As shown, the encoding module 15 includes:

[0166] The first division submodule 151 is configured to divide the small macroblock including the non-copy macroblock into c×c small macroblocks if the small macroblock includes the non-copy macroblock; wherein c is smaller than b;

[0167] A first determination submodule 152 is used to determine the macroblock type of each small macroblock;

[0168] The second division submodule 153 is configured to divide the small macroblock including the non-copy macroblock into d×d minimum macroblocks if the small macroblock includes the non-copy macroblock; wherein d is smaller than c;

[0169] A second determination submodule 154, configured to determine the macroblock type of each minimum macroblock;

[0170] The encoding submodule 155 is used to encode the current frame according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock, wherein for the macroblocks, small macroblocks, small macroblocks and minimum macroblocks whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type, and for the minimum macroblock whose macroblock type is the non-copy-type macroblock, pixel-by-pixel encoding is performed.

[0171] In one embodiment, Fig.10As shown, the encoding submodule 155 includes:

[0172] The encoding subunit 1551 is used to encode the current frame according to a preset internal encoding order, as well as the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock.

[0173] In one embodiment, the first determining module 152 includes:

[0174] The first judgment submodule is used to judge whether the current macroblock is an unchanged macroblock type;

[0175] A third determination submodule is used to determine that the current macroblock is the copy type macroblock if the current macroblock is the unchanged macroblock type;

[0176] A second judgment submodule is used to judge whether the current macroblock is a motion vector macroblock type if the current macroblock is not the unchanged macroblock type;

[0177] A fourth determination submodule, configured to determine that the current macroblock is the copy type macroblock if the current macroblock is the motion vector macroblock type;

[0178] A third judgment submodule is used to judge whether the current macroblock is a left copy macroblock type if the current macroblock is not the motion vector macroblock type;

[0179] A fifth determination submodule, configured to determine that the current macroblock is the copy-type macroblock if the current macroblock is of the left copy macroblock type;

[0180] A fourth judgment submodule, used for judging whether the current macroblock is an upper copy macroblock type if the current macroblock is not a left copy macroblock type;

[0181] A sixth determination submodule, configured to determine that the current macroblock is the copy-type macroblock if the current macroblock is of the upper copy macroblock type;

[0182] The seventh determination submodule is used to determine that the current macroblock is the non-copy type macroblock if the current macroblock is not the upper copy macroblock type.

[0183] In one embodiment, the seventh determining submodule includes:

[0184] A fifth judgment submodule, used to judge whether the current macroblock is a text macroblock type;

[0185] The eighth determination submodule is used to determine that the current macroblock is the image macroblock type if the current macroblock is not the text macroblock type.

[0186] In one embodiment, the fifth judgment submodule includes:

[0187] A first acquisition submodule is used to acquire a brightness difference between a brightness value of each pixel in the current macroblock and brightness values ​​of all surrounding pixels;

[0188] A second acquisition submodule, used to acquire the number of target pixels in the current macroblock whose brightness difference exceeds a preset threshold;

[0189] The ninth determination submodule is used to determine that the current macroblock is the text macroblock type if the ratio of the number of the target pixels to the total number of pixels in the current macroblock is greater than a preset threshold.

[0190] Based on the above Figure 1 Corresponding to the encoding method described in the embodiment, the embodiment of the present disclosure also provides a computer-readable storage medium, for example, a non-temporary 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, and an optical data storage device. The storage medium stores computer instructions for executing the above Figure 1 The encoding method described in the corresponding embodiment will not be repeated here.

[0191] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0192] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A coding method, characterized in that: The method comprises: Divide the current frame into a×a macroblocks; Determine the macroblock type of each macroblock; the macroblock type includes: non-copy macroblock and copy macroblock; the non-copy macroblock includes the following macroblock types: image macroblock and text macroblock; the copy macroblock includes the following macroblock types: unchanged macroblock, motion vector macroblock, left copy macroblock and top copy macroblock; If the macroblock includes the non-copy macroblock, dividing the macroblock including the non-copy macroblock into b×b small macroblocks; wherein b is smaller than a; Determine the macroblock type of each small macroblock; Encoding the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock, wherein for the macroblock and the small macroblock whose macroblock type is a copy type macroblock, only the macroblock type needs to be marked, and for the small macroblock whose macroblock type is a non-copy type macroblock, pixel-by-pixel encoding is performed; The encoding of the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock includes: If the small macroblock includes the non-copy macroblock, dividing the small macroblock including the non-copy macroblock into c×c small macroblocks; wherein c is smaller than b; Determine the macroblock type of each small macroblock; If the small macroblock includes the non-copy macroblock, dividing the small macroblock including the non-copy macroblock into d×d minimum macroblocks; wherein d is smaller than c; Determine the macroblock type of each minimum macroblock; The current frame is encoded according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock, wherein for the macroblocks, the small macroblocks, the small macroblocks and the minimum macroblock whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type, and for the minimum macroblock whose macroblock type is the non-copy-type macroblock, pixel-by-pixel encoding is performed.

2. The method according to claim 1, characterized in that The encoding of the current frame according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock includes: The current frame is encoded according to a preset internal encoding order, as well as the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock.

3. The method according to claim 1, characterized in that: The determining of the macroblock type of each macroblock includes: Determine whether the current macroblock is an unchanged macroblock type; If the current macroblock is of the unchanged macroblock type, determining that the current macroblock is the copy type macroblock; If the current macroblock is not the unchanged macroblock type, determining whether the current macroblock is a motion vector macroblock type; If the current macroblock is of the motion vector macroblock type, determining that the current macroblock is a copy-type macroblock; If the current macroblock is not of the motion vector macroblock type, determining whether the current macroblock is of the left copy macroblock type; If the current macroblock is of the left copy macroblock type, determining that the current macroblock is the copy type macroblock; If the current macroblock is not of the left copy macroblock type, determining whether the current macroblock is of the upper copy macroblock type; If the current macroblock is of the upper copy macroblock type, determining that the current macroblock is the copy type macroblock; If the current macroblock is not of the upper copy macroblock type, the current macroblock is determined to be the non-copy macroblock.

4. The method according to claim 3, characterized in that The determining that the current macroblock is the non-copy macroblock includes: Determine whether the current macroblock is a text macroblock type; If the current macroblock is not of the text macroblock type, the current macroblock is determined to be of the image macroblock type.

5. The method according to claim 4, characterized in that The determining whether the current macroblock is a text macroblock type includes: Obtaining a brightness difference between a brightness value of each pixel in the current macroblock and brightness values ​​of all surrounding pixels; Obtaining the number of target pixels in the current macroblock whose brightness difference exceeds a preset threshold; If the ratio of the number of the target pixels to the total number of pixels in the current macroblock is greater than a preset threshold, it is determined that the current macroblock is the text macroblock type.

6. A coding device, characterized in that: The device comprises: A first division module, used for dividing the current frame into a×a macroblocks; The first determination module is used to determine the macroblock type of each macroblock; the macroblock type includes: non-copy macroblock and copy macroblock; the non-copy macroblock includes the following macroblock types: image macroblock and text macroblock; the copy macroblock includes the following macroblock types: unchanged macroblock, motion vector macroblock, left copy macroblock and upper copy macroblock; A second division module is configured to divide the macroblock including the non-copy macroblock into b×b small macroblocks if the macroblock includes the non-copy macroblock; wherein b is smaller than a; A second determination module is used to determine the macroblock type of each small macroblock; A coding module, configured to encode the current frame according to the macroblock type of each macroblock and the macroblock type of each small macroblock, wherein for the macroblock and the small macroblock whose macroblock type is a copy type macroblock, only the macroblock type needs to be marked, and for the small macroblock whose macroblock type is a non-copy type macroblock, pixel-by-pixel coding is performed; The encoding module comprises: The first division submodule is used for dividing the small macroblock including the non-copy macroblock into c×c small macroblocks if the small macroblock includes the non-copy macroblock; wherein c is smaller than b; A first determination submodule is used to determine the macroblock type of each small macroblock; A second division submodule is used for dividing the small macroblock including the non-copy macroblock into d×d minimum macroblocks if the small macroblock includes the non-copy macroblock; wherein d is smaller than c; A second determination submodule is used to determine the macroblock type of each minimum macroblock; The encoding submodule is used to encode the current frame according to the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock, wherein for the macroblocks, small macroblocks, small macroblocks and minimum macroblocks whose macroblock types are copy-type macroblocks, it is only necessary to mark the macroblock type, and for the minimum macroblock whose macroblock type is the non-copy-type macroblock, pixel-by-pixel encoding is performed.

7. The device according to claim 6, characterized in that The encoding submodule comprises: The encoding subunit is used to encode the current frame according to a preset internal encoding order, as well as the macroblock type of each macroblock, the macroblock type of each small macroblock, the macroblock type of each small macroblock and the macroblock type of each minimum macroblock.

8. The device according to claim 6, characterized in that The first determining module comprises: The first judgment submodule is used to judge whether the current macroblock is an unchanged macroblock type; A third determination submodule is used to determine that the current macroblock is the copy type macroblock if the current macroblock is the unchanged macroblock type; A second judgment submodule is used to judge whether the current macroblock is a motion vector macroblock type if the current macroblock is not the unchanged macroblock type; A fourth determination submodule, configured to determine that the current macroblock is the copy type macroblock if the current macroblock is the motion vector macroblock type; A third judgment submodule is used to judge whether the current macroblock is a left copy macroblock type if the current macroblock is not the motion vector macroblock type; A fifth determination submodule, configured to determine that the current macroblock is the copy-type macroblock if the current macroblock is of the left copy macroblock type; A fourth judgment submodule, used for judging whether the current macroblock is an upper copy macroblock type if the current macroblock is not a left copy macroblock type; A sixth determination submodule, configured to determine that the current macroblock is the copy-type macroblock if the current macroblock is of the upper copy macroblock type; The seventh determination submodule is used to determine that the current macroblock is the non-copy type macroblock if the current macroblock is not the upper copy macroblock type.