WO2022011916A1 - 视频编码方法及装置 - Google Patents
视频编码方法及装置 Download PDFInfo
- Publication number
- WO2022011916A1 WO2022011916A1 PCT/CN2020/130430 CN2020130430W WO2022011916A1 WO 2022011916 A1 WO2022011916 A1 WO 2022011916A1 CN 2020130430 W CN2020130430 W CN 2020130430W WO 2022011916 A1 WO2022011916 A1 WO 2022011916A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- macroblock
- encoding
- current
- text
- current frame
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 152
- 230000000750 progressive effect Effects 0.000 claims abstract description 71
- 238000011217 control strategy Methods 0.000 claims description 71
- 238000013139 quantization Methods 0.000 claims description 46
- 230000005540 biological transmission Effects 0.000 abstract description 8
- 230000003044 adaptive effect Effects 0.000 abstract 1
- 230000006978 adaptation Effects 0.000 description 2
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
- H04N19/17—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
- H04N19/176—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/30—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using hierarchical techniques, e.g. scalability
Definitions
- the present disclosure relates to the field of video processing, and in particular, to a video encoding method and apparatus.
- vGTP is a real-time image compression transmission protocol, which is completely independent and controllable. It has core technologies such as multi-encoder, progressive encoding, visual lossless image transmission, network bandwidth adaptation, QoS, and supports audio transmission and reverse control channels.
- Embodiments of the present disclosure provide a video encoding method and device, which can solve the problem of poor adaptability of the vGTP video encoding algorithm in a scenario with poor network conditions.
- the technical solution is as follows:
- a video encoding method comprising:
- the encoding method of the text macroblock or the image macroblock is determined, and the encoding method of the text macroblock includes: progressive encoding or text encoding;
- the encoding method of the image macroblock includes: layered encoding or progressive encoding;
- the encoded data of the current frame is acquired according to the plurality of encoded data.
- the present disclosure provides a video encoding method, including: obtaining a current frame; when the current frame is different from a reference frame, obtaining the macroblock type of each macroblock in the current frame; if the type of the macroblock is a text macroblock or an image macroblock , then determine the encoding method of text macroblock or image macroblock, the encoding method of text macroblock includes: progressive encoding or text encoding; the encoding method of image macroblock includes: layered encoding or progressive encoding; The encoding method encodes each macroblock to obtain multiple encoded data; and obtains encoded data of the current frame according to the multiple encoded data.
- the video coding method in the present disclosure can use different processing procedures under different network conditions and different requirements, and has high adaptability.
- the determining the encoding method for the image macroblock includes:
- the encoding method of the image macroblock is progressive encoding.
- the determining an encoding method for the literal macroblock includes:
- the encoding method of the text macroblock is the text encoding method.
- the method before acquiring the macroblock type of each macroblock in the current frame, the method further includes:
- the acquiring the macroblock type of each macroblock in the current frame includes:
- the macroblock type of each macroblock in the current frame is determined according to the prediction result.
- the determining the macroblock type of each macroblock in the current frame according to the prediction result includes:
- the encoding of each macroblock according to the encoding method corresponding to each macroblock type to obtain a plurality of encoded data including:
- the current macroblock is encoded according to the encoding method corresponding to the macroblock type of the current macroblock.
- determining the macroblock type of each macroblock in the current frame one by one according to the prediction result, and encoding the current macroblock according to an encoding method corresponding to the macroblock type of the current macroblock including:
- the current macroblock is a video macroblock
- the current macroblock is encoded to obtain video encoded data, and the next macroblock is used as the current macroblock to cyclically perform the step of judging the macroblock type
- the current macroblock is not a video macroblock, determine whether the current macroblock is an unchanged macroblock according to the prediction result,
- the current macroblock is an unchanged macroblock, then according to the encoding mode corresponding to the unchanged macroblock, the current macroblock is encoded to obtain unchanged encoded data, and the next macroblock is repeatedly performed.
- the step of judging the macroblock type
- the current macroblock is not an unchanged macroblock, it is determined whether the current macroblock is a motion vector macroblock according to the prediction result,
- the current macroblock is a motion vector macroblock
- the current macroblock is encoded to obtain motion vector encoded data, and the next macroblock is repeatedly performed.
- the current macroblock is not a motion vector macroblock, then according to the prediction result, determine whether the current macroblock is a text macroblock,
- the current macroblock is a text macroblock
- the current macroblock is encoded to obtain textual encoded data, and the next macroblock is repeatedly performed.
- the current macroblock is not a text macroblock, it is determined whether the current macroblock is an image macroblock according to the prediction result,
- the current macroblock is an image macroblock
- the current macroblock is encoded according to the encoding mode corresponding to the image macroblock to obtain image encoded data, and the step of judging the macroblock type is repeated for the next macroblock.
- the encoding performed on the current macroblock according to the encoding mode corresponding to the text macroblock to obtain text encoding data includes:
- the first preset quantization parameter is smaller than the second preset quantization parameter.
- the obtaining the encoded data of the current frame according to the plurality of encoded data includes:
- the encoded data of the current frame is acquired according to the video encoded data, the unchanged encoded data, the motion vector encoded data, the character encoding and the image encoded data.
- a video encoding apparatus comprising:
- the first acquisition module is used to acquire the current frame
- a second acquisition module configured to acquire the macroblock type of each macroblock in the current frame when the current frame is different from the reference frame
- a first determining module configured to determine an encoding device for the text macroblock or the image macroblock if the type of the macroblock is a text macroblock or an image macroblock, and the encoding device for the text macroblock includes: Progressive encoding or text encoding; the encoding device for image macroblocks includes: layered encoding or progressive encoding;
- a first encoding module configured to encode each macroblock according to an encoding device corresponding to each macroblock type to obtain a plurality of encoded data
- a third obtaining module configured to obtain the encoded data of the current frame according to the plurality of encoded data.
- the first determining module when the macroblock type is an image macroblock, includes:
- a first processing submodule configured to perform cosine transform on the image macroblock, and perform quantization with a first preset quantization parameter to obtain first data
- a first judgment submodule configured to judge whether the current rate control strategy is the first rate control strategy
- a first determination submodule configured to determine that the encoding device of the image macroblock is layered encoding when the current rate control strategy is the first rate control strategy
- the second determination submodule is configured to determine that the encoding apparatus of the image macroblock is progressive encoding when the current rate control strategy is not the first rate control strategy.
- the first determining module when the type of the macroblock is a literal macroblock, includes:
- the second judgment submodule is used for judging whether the current rate control strategy is the second rate control strategy
- a third determination submodule configured to determine that the encoding device of the text macroblock is the progressive encoding when the current rate control strategy is the second rate control strategy;
- the fourth determination sub-module is configured to determine that the encoding device of the text macroblock is the text encoding mode when the current rate control strategy is not the second rate control strategy.
- the apparatus further comprises:
- the first judgment module is used to judge whether the current frame is the same as the reference frame before the second obtaining module obtains the macroblock type of each macroblock in the current frame, when the current frame is not the same as the reference frame.
- Full frame h.264 encoding
- a second encoding module configured to use an h.264 encoding device to encode the current frame when the current frame is a full-frame h.264 encoding
- the second judgment module is used to judge whether the current frame is full-frame vGTP coding when the current frame is not full-frame h.264 coding;
- the 3rd acquisition module is used for when current frame is full frame vGTP coding, then carries out global motion vector prediction, obtains prediction result;
- the fourth acquisition module is used to perform video window recognition when the current frame is not a full-frame vGTP encoding, and perform global motion vector prediction on the video window recognition result to obtain a prediction result;
- the second acquisition module includes:
- the fifth determination sub-module is configured to determine the macroblock type of each macroblock in the current frame according to the prediction result.
- the fifth determination sub-module includes: a first judgment sub-unit; the first encoding module includes: a first encoding sub-module,
- the first judgment subunit for judging the macroblock type of each macroblock in the current frame one by one according to the predicted result
- the first encoding sub-module is configured to encode the current macroblock according to the encoding device corresponding to the macroblock type of the current macroblock.
- the apparatus further comprises:
- a video macroblock judgment module configured to judge whether the current macroblock is a video macroblock according to the prediction result
- the video coding module is configured to, if the current macroblock is a video macroblock, perform coding on the current macroblock according to the coding mode corresponding to the video macroblock to obtain video coding data, and use the next macroblock as the current macroblock to cyclically execute the macroblock The steps of block type judgment;
- an unchanged macroblock judging module used for determining whether the current macroblock is an unchanged macroblock according to the prediction result if the current macroblock is not a video macroblock
- the unchanged macroblock encoding module is used to perform encoding on the current macroblock according to the encoding mode corresponding to the unchanged macroblock to obtain unchanged encoded data if the current macroblock is an unchanged macroblock, and repeat for the next macroblock Perform the steps of macroblock type judgment;
- a motion vector macroblock judgment module configured to judge whether the current macroblock is a motion vector macroblock according to the prediction result if the current macroblock is not an unchanged macroblock
- the motion vector macroblock coding module is used to perform coding on the current macroblock according to the coding mode corresponding to the motion vector macroblock if the current macroblock is a motion vector macroblock to obtain motion vector coded data, and repeat for the next macroblock Perform the steps of macroblock type judgment;
- a text macroblock judgment module configured to judge whether the current macroblock is a text macroblock according to the prediction result if the current macroblock is not a motion vector macroblock
- the text macroblock encoding module is used to, if the current macroblock is a text macroblock, perform encoding on the current macroblock according to the encoding method corresponding to the text macroblock to obtain text encoded data, and repeat the macroblock type for the next macroblock the steps of judgment;
- an image macroblock judgment module configured to judge whether the current macroblock is an image macroblock according to the prediction result if the current macroblock is not a text macroblock
- An image macroblock encoding module configured to perform encoding on the current macroblock according to the encoding mode corresponding to the image macroblock to obtain image encoded data if the current macroblock is an image macroblock, and repeat the macroblock type for the next macroblock judgment steps.
- the literal macroblock encoding module includes:
- the second data acquisition sub-module is configured to perform cosine transform on the text macroblock when it is determined that the encoding device of the text macroblock is the progressive encoding, and perform quantization using the second preset quantization parameter to obtain a second data acquisition sub-module. data;
- a progressive encoding submodule configured to perform progressive encoding on the second data to obtain the character encoded data
- a text encoding submodule configured to perform text encoding on the current macroblock to obtain the text encoding data when it is determined that the encoding device for the text macroblock is the text encoding
- the first preset quantization parameter is smaller than the second preset quantization parameter.
- the third obtaining module includes:
- An obtaining submodule configured to obtain the encoded data of the current frame according to the video encoded data, the unchanged encoded data, the motion vector encoded data, the text encoding and the image encoded data.
- FIG. 1 is a flowchart of a video encoding method provided by an embodiment of the present disclosure
- FIG. 2 is a flowchart of a video encoding method provided by an embodiment of the present disclosure
- FIG. 3 is a flowchart of a video encoding method provided by an embodiment of the present disclosure
- FIG. 4 is a flowchart of a video encoding method provided by an embodiment of the present disclosure.
- FIG. 5 is a schematic structural diagram of a video encoding apparatus provided by an embodiment of the present disclosure.
- Layered coding The principles of layered coding and progressive coding are the same, except that the transmission definition of each frame is the same during the coding process, and the number of layers to be coded is determined before transmission. It is generally applicable to scenarios with limited transmission bandwidth. For example, the current frame is divided into 5 layers, but the current bandwidth resources are limited, so only 3 layers can be sent.
- Quantization (parameter): The larger the parameter, the better the clarity, where T1 ⁇ T2, T1 is used to encode the picture macroblock, and T2 is used to encode the Text macroblock;
- Macroblock 16x16 pixels in size, vgtp divides a frame of image into macroblocks of the same size, and classifies each macroblock before encoding;
- NORC vgtp algorithm is not responsible for rate control, picture adopts layered encoding, and text macroblock adopts text encoding;
- PrimaryRC The picture macroblock adopts progressive encoding, and the text adopts text encoding;
- HighRC picture adopts progressive encoding
- text adopts progressive encoding, but the quantization parameter of text is larger than that of picture.
- An embodiment of the present disclosure provides a video encoding method. As shown in FIG. 1 , the video encoding method includes the following steps:
- the type of the macroblock is a text macroblock or an image macroblock
- the encoding method of the image macroblock includes: : Layered encoding or progressive encoding.
- two different encoding methods are set for the text macroblocks, namely progressive encoding and text encoding.
- the progressive encoding will make the encoded code stream lower than that after text encoding, so that in the network In poorer situations, it is more adaptable.
- layered encoding or progressive encoding two different encoding methods are set for image macroblocks, namely layered encoding or progressive encoding, and layered encoding or progressive encoding will make the encoded code stream lower than that after video encoding, Thus, the adaptability of the encoded data is improved.
- each macroblock Encodes each macroblock according to an encoding method corresponding to each macroblock type to obtain a plurality of encoded data.
- the existing vGTP video coding algorithm has poor adaptability in the scene with poor network conditions.
- the existing vGTP basically uses the same processing flow in different scenarios, different network conditions, and different requirements, and the configurability is also relatively poor.
- the present disclosure proposes a new video encoding method.
- the existing vgtp algorithm and the layered and progressive encoding method are fused. Since the layered and progressive encoding method can effectively Compared with the code stream encoded by the vgtp algorithm in the prior art, the code stream encoded by the video coding method in the present disclosure can significantly reduce the data amount of the code stream, so that the network condition is poor. In the scene, the adaptability is strong,
- the macroblocks of the current frame are classified, and different coding methods are used for different types of macroblocks, so that the video coding method in the present disclosure is more adaptable and flexible, and can meet the individual needs of users.
- the video encoding method in the present disclosure can use different processing procedures under different network conditions and requirements, and has high adaptability.
- the present disclosure provides a video encoding method, including: obtaining a current frame; when the current frame is different from a reference frame, obtaining the macroblock type of each macroblock in the current frame; if the type of the macroblock is a text macroblock or an image macroblock , then determine the encoding method of text macroblock or image macroblock, the encoding method of text macroblock includes: progressive encoding or text encoding; the encoding method of image macroblock includes: layered encoding or progressive encoding; The encoding method encodes each macroblock to obtain multiple encoded data; and obtains encoded data of the current frame according to the multiple encoded data.
- the video coding method in the present disclosure can use different processing procedures under different network conditions and different requirements, and has high adaptability.
- determining an encoding method for the image macroblock includes the following sub-steps:
- the current rate control strategy is the first rate control strategy. If the current rate control strategy is the first rate control strategy, it is determined that the encoding method of the image macroblock is layered encoding. If the current rate control strategy is not the first rate control strategy, then The coding method for determining the image macroblocks is progressive coding.
- the first stream control strategy includes: NORC. Specifically, DCT transform is performed on the picture macroblock, and the first data is obtained by quantizing with a smaller first preset quantization parameter T1. It is judged whether the current rate control strategy is NORC. When the rate control strategy is NORC, the coding mode of the picture macroblock is hierarchical coding, and the coding mode of the picture macroblock is progressive coding.
- the rate control strategy needs to be determined first, and then the encoding method for the picture macroblock can be determined.
- the encoding method for the text macroblock is determined according to a rate control strategy, including the following sub-blocks step:
- the second rate control strategy includes: HighRC. Specifically, it is determined whether the current rate control strategy is HighRC. When the rate control strategy is HighRC, the encoding method of the picture macroblock is progressive encoding, and the encoding method of the text macroblock is progressive encoding, but the encoding method of the text macroblock is progressive encoding.
- the quantization parameter is larger than the quantization parameter of picture.
- the rate control strategy needs to be determined first, and then the encoding method for the text macroblock can be determined.
- the above method before acquiring the macroblock type of each macroblock in the current frame, the above method also includes the following substeps:
- full-frame h.264 encoding is set in advance. Since h.264 has high coding efficiency and good quality for video images, for some scenarios, such as playing full-screen animations, you can set the image frames in a period of time to be full-frame h.264 encoding. For scenes with many images, such as office desktops, you do not need to set full-frame h.264 encoding.
- full-frame vGTP encoding is set in advance.
- Image frames containing video windows can be set to full-frame vGTP encoding.
- this step it is determined whether the current frame is full-frame vGTP encoding; after determining that the current frame is not full-frame vGTP encoding, the identification of the video window can be performed, and after determining that the current frame is full-frame vGTP encoding, the The macroblocks of the current frame are classified.
- A5 if not, then perform video window recognition, and perform global motion vector prediction on the video window recognition result to obtain the prediction result;
- the video window in the current frame can be identified; and the macroblocks within the video window range are further classified according to the range of the video window.
- the range of the video window includes: position and size.
- the video window may contain still images or dynamic video.
- processing object after this step is based on a macroblock, while before this step, the processing object is based on a frame.
- the above-mentioned acquisition of the macroblock type of each macroblock in the current frame includes the following sub-steps:
- A6 Determine the macroblock type of each macroblock in the current frame according to the prediction result.
- the macroblock type of each macroblock in the current frame can be determined one by one according to the prediction result, that is, one by one in a serial manner; all macroblocks in the current frame can also be determined uniformly, or That is, judgments are made in a parallel manner.
- the current macroblock is fully encoded, that is, the current macroblock is encoded according to the encoding method corresponding to the macroblock type of the current macroblock.
- the current frame is obtained, and it is determined whether the current frame is the same as the reference frame; if they are the same, the encoding is not performed, and the next frame is processed. If they are not the same, it is determined whether the current frame is a full frame h.
- For full-frame h.264 encoding input the current frame to the h.264 encoder for encoding, complete the encoding processing of this frame, and start processing the next frame after the encoding is completed; if the current frame is not a full-frame h.264 encoding, just It is necessary to determine whether the current frame is full-frame vGTP encoding.
- the current frame is full-frame vGTP encoding, perform global motion vector prediction to obtain the prediction result, and determine the macroblock type of each macroblock in the current frame according to the prediction result; if the current frame If it is not a full-frame vGTP encoding, video window recognition is performed, and global motion vector prediction is performed on the video window recognition result to obtain the prediction result, and the macroblock type of each macroblock in the current frame is determined according to the prediction result.
- the reference frame may be a reference image
- the macroblock type of each macroblock in the current frame is determined one by one according to the prediction result, and the current macroblock is encoded according to the encoding method corresponding to the macroblock type of the current macroblock, including the following sub-steps:
- the current macroblock is a video macroblock, then according to the coding mode corresponding to the video macroblock, the current macroblock is encoded to obtain the video encoded data, and the next macroblock is used as the current macroblock.
- the video macroblock can be encoded to generate video encoding data of the video macroblock, which can be specifically h .264 encoding, if no, the macroblock is further classified by subsequent steps.
- the current macroblock is an unchanged macroblock (also known as: unchange macroblock)
- the current macroblock is encoded according to the encoding method corresponding to the unchanged macroblock to obtain unchanged encoded data, and the next macroblock is encoded.
- the block repeats the step of performing the macroblock type judgment;
- the current macroblock is a motion vector macroblock (also referred to as an mv macroblock)
- the block repeats the step of performing the macroblock type judgment;
- the current macroblock is a text macroblock (also referred to as: text macroblock)
- the current macroblock is an image macroblock (also called a picture macroblock)
- encoding the current macroblock according to the encoding mode corresponding to the text macroblock to obtain text encoding data including the following sub-steps:
- DCT transform is performed on the text macroblock; quantization is performed using a larger second preset quantization parameter T2; and progressive encoding is performed to generate text encoded data of the text macroblock.
- the parameter T2 is greater than the parameter T1.
- character encoding is performed on the text macroblock to generate character encoding data of the text macroblock.
- the above step 105 includes the following sub-steps:
- the encoded data of the current frame is generated according to the encoded data corresponding to each macroblock obtained in the above steps.
- the encoded data of the current frame is acquired according to the video encoded data, unchanged encoded data, motion vector encoded data, text encoded and image encoded data.
- the current code rate can also be referred to Control strategy to modify the encoding method of macroblocks of the specified type. It is highly adaptable and flexible to use, and can meet the individual needs of users.
- the method includes the following sub-steps:
- Input a frame that is, obtain the current frame.
- step 203 Determine whether the current frame and the reference frame are the same; if they are the same, do not perform encoding, and start processing the next frame; if they are not the same, perform step 203.
- the reference frame may be a reference image. If the current frame is the same as the reference image, no coding is required, and the next frame can be processed. If not, proceed to the subsequent steps.
- full-frame h.264 encoding is set in advance. Since h.264 has high coding efficiency and good quality for video images, for some scenarios, such as playing full-screen animations, you can set the image frames in a period of time to be full-frame h.264 encoding. For scenes with many images, such as office desktops, you do not need to set full-frame h.264 encoding.
- step 204 it can be judged whether the current frame is a full frame h.264 encoding, if so, by executing step 204, h.264 encoding is performed on this frame, if not, further classification and processing are required.
- Step 204 the current frame is input to the h.264 encoder for encoding, and the encoding process of the current frame is completed.
- the h.264 encoder is used to encode the current frame. After the encoding is completed, start processing the next frame.
- Step 205 determine whether the current frame is full-frame vGTP encoding, if yes, go to step 206 , if not, go to step 207 .
- full-frame vGTP encoding is set in advance.
- Image frames containing video windows can be set to full-frame vGTP encoding.
- step 8 it is determined whether the current frame is full-frame vGTP encoding; after determining that the current frame is not full-frame vGTP encoding, step 8 can be performed to identify the video window, and after determining that the current frame is full-frame vGTP encoding, the The macroblocks of the current frame are classified.
- Step 206 perform global MV prediction on the current frame to obtain a prediction result, and perform step 7 .
- step 208 after it is determined that the current frame is not a full-frame h.264 encoded, global MV prediction is performed on the current frame to obtain a prediction result, and after the prediction result is obtained, step 208 is performed.
- Step 207 identify the video window of the current frame, determine the range of the video window, and execute step 206 .
- the video window in the current frame can be identified; and the macroblocks within the video window range are further classified according to the range of the video window.
- the range of the video window includes: position and size.
- the video window may contain still images or dynamic video.
- Step 208 determine whether the macroblock of the current frame is a video macroblock; if yes, go to step 2024 , if not, go to step 209 .
- the video macroblock can be encoded to generate the encoded data of the video macroblock, which can be specifically h.264 encoding, if no, the macroblock is further classified through subsequent steps.
- the processing object is in units of macroblocks, and before step 208, the processing objects are in units of frames.
- Step 209 determine whether other macroblocks in the current frame except the macroblocks of the determined type are unchange macroblocks, if yes, go to step 2024 , if not, go to step 2010 .
- step 208 after determining that the current frame is a full-frame vGTP encoding, classify other macroblocks in the current frame except the video macroblock determined in step 208; determine whether the macroblock is an unchange macroblock in turn; if If yes, the unchange macroblock can be encoded to generate encoded data of the unchange macroblock; if no, the classification is continued through subsequent steps.
- Step 2011, determine whether other macroblocks in the current frame except the macroblocks of the determined type are mv macroblocks; if yes, go to step 2024, if not, go to step 2012.
- step 206 classify the macroblocks other than the video macroblock determined in step 208 and the unchange macroblock determined in step 209 in the current frame; determine the macroblocks in sequence; Whether it is an mv macroblock; if yes, the macroblock is encoded through step 2024 to generate encoded data of the mv macroblock, if no, the classification is continued through subsequent steps.
- Step 2012 determine whether other macroblocks in the current frame except the macroblocks of the determined type are text macroblocks; if yes, go to step 2013, if not, go to step 2018.
- this step can classify all macroblocks in the current frame except the video macroblock determined in step 208, the unchange macroblock determined in step 209, and the mv macroblock determined in step 2010.
- step 2010 classify the macroblocks other than the video macroblock determined in step 208, the unchange macroblock determined in step 209, and the mv macroblock determined in step 2010 in the current frame; Whether the macroblock is a text macroblock; if so, the rate control strategy is further judged through step 2013 to determine the encoding method for the text macroblock; if not, the classification is continued through subsequent steps.
- Step 2013, determine whether the current rate control strategy (RC) is HIGH; if yes, go to step 2014; if not, go to step 2017.
- the rate control strategy needs to be determined first, and then the encoding method for the text macroblock can be determined.
- the encoding method of the picture macroblock is progressive encoding
- the encoding method of the text macroblock is progressive encoding, but the quantization parameter of text is larger than the quantization parameter of picture.
- step 2014 it is judged whether the current rate control strategy is HighRC, and if so, progressive coding is performed on the text macroblock through step 2014 .
- Step 2014 DCT transform is performed on the text macroblock.
- Step 2015 using a larger parameter T2 for quantization.
- Step 2016, perform progressive coding to generate coded data of text macroblocks.
- the parameter T2 is greater than the parameter T1.
- Step 2017 perform character encoding on the text macroblock to generate encoded data of the text macroblock, and execute step 2024 .
- Step 2018 Determine whether other macroblocks in the current frame except the macroblocks of the determined type are picture macroblocks; if yes, perform step 2019.
- step 208 the video macroblock determined in step 208, the unchange macroblock determined in step 209, the mv macroblock determined in step 2010, and the text macroblock determined in step 2012 are removed from the current frame Other macroblocks are classified; it is judged in turn whether the macroblocks are picture macroblocks; if so, step 2019 is executed.
- Step 2019, DCT transform is performed on the picture macroblock.
- Step 2020 use a smaller parameter T1 for quantization; go to step 2021.
- the parameter T1 is smaller than the parameter T2.
- Step 2021 determine whether the current rate control strategy is NORC; if so, execute step 2022, if not, execute step 2023.
- the rate control strategy needs to be determined first, and then the encoding method for the picture macroblock can be determined.
- the encoding mode of the picture macroblock is hierarchical encoding
- the encoding mode of the text macroblock is text encoding
- step 2022 it is judged whether the current rate control strategy is NORC, if yes, perform hierarchical coding on the picture macroblock through step 2022, and if not, perform progressive coding on the picture macroblock.
- Step 2022 perform hierarchical coding on the picture macroblock to generate coded data of the picture macroblock, and perform step 2024 .
- Step 2023 progressively encode the picture macroblock to generate encoded data of the picture macroblock, and perform step 2024 .
- Step 2024 based on the encoded data of all macroblocks, determine the encoded data of the current frame.
- the encoded data of the current frame may be generated based on the encoded data of macroblocks of various types obtained in steps 208 , 209 , 2010 , 2014 , 2017 , 2022 , and 2023 .
- the above-mentioned embodiment corresponding to FIG. 4 can perform parallel processing on all macroblocks in the current frame, and can also perform serial processing on each macroblock in the current frame.
- the loop goes to 208, and the judgment process is performed again for the next macroblock.
- the current code rate can also be referred to Control strategy to modify the encoding method of macroblocks of the specified type. It is highly adaptable and flexible to use, and can meet the individual needs of users.
- An embodiment of the present disclosure provides a video encoding apparatus. As shown in FIG. 5 , the video encoding apparatus includes:
- the first acquisition module 11 is used to acquire the current frame
- a second obtaining module 12 configured to obtain the macroblock type of each macroblock in the current frame when the current frame is different from the reference frame;
- the first determination module 13 is configured to determine an encoding device for the text macroblock or the image macroblock if the type of the macroblock is a text macroblock or an image macroblock, and the encoding device for the text macroblock includes: : progressive encoding or text encoding; the encoding device for the image macroblock includes: layered encoding or progressive encoding;
- a first encoding module 14 configured to encode each macroblock according to the encoding device corresponding to each macroblock type to obtain a plurality of encoded data
- the third obtaining module 15 is configured to obtain the encoded data of the current frame according to the plurality of encoded data.
- the first determining module when the macroblock type is an image macroblock, includes:
- a first processing submodule configured to perform cosine transform on the image macroblock, and perform quantization with a first preset quantization parameter to obtain first data
- a first judging submodule configured to judge whether the current rate control strategy is the first rate control strategy
- a first determination submodule configured to determine that the encoding device of the image macroblock is layered encoding when the current rate control strategy is the first rate control strategy
- the second determination submodule is configured to determine that the encoding apparatus for the image macroblock is progressive encoding when the current rate control strategy is not the first rate control strategy.
- the first determining module when the type of the macroblock is a literal macroblock, includes:
- a second judging submodule configured to judge whether the current rate control strategy is the second rate control strategy
- a third determination submodule configured to determine that the encoding device of the text macroblock is the progressive encoding when the current rate control strategy is the second rate control strategy;
- the fourth determination sub-module is configured to determine that the encoding device of the text macroblock is the text encoding mode when the current rate control strategy is not the second rate control strategy.
- the apparatus further includes:
- the first judgment module is used to judge whether the current frame is the same as the reference frame before the second obtaining module obtains the macroblock type of each macroblock in the current frame, when the current frame is different from the reference frame.
- Full frame h.264 encoding
- a second encoding module configured to use an h.264 encoding device to encode the current frame when the current frame is a full-frame h.264 encoding
- the second judgment module is used to judge whether the current frame is full-frame vGTP coding when the current frame is not full-frame h.264 coding;
- the third acquisition module is used to perform global motion vector prediction when the current frame is a full-frame vGTP encoding to obtain a prediction result;
- the fourth acquisition module is used to perform video window recognition when the current frame is not a full-frame vGTP encoding, and perform global motion vector prediction on the video window recognition result to obtain a prediction result;
- the second acquisition module includes:
- the fifth determination sub-module is configured to determine the macroblock type of each macroblock in the current frame according to the prediction result.
- the fifth determination sub-module includes: a first judgment sub-unit; the first encoding module includes: a first encoding sub-module,
- the first judgment subunit for judging the macroblock type of each macroblock in the current frame one by one according to the predicted result
- the first encoding sub-module is configured to encode the current macroblock according to the encoding device corresponding to the macroblock type of the current macroblock.
- the apparatus further includes:
- a video macroblock judgment module configured to judge whether the current macroblock is a video macroblock according to the prediction result
- the video coding module is configured to, if the current macroblock is a video macroblock, perform coding on the current macroblock according to the coding mode corresponding to the video macroblock to obtain video coding data, and use the next macroblock as the current macroblock to cyclically execute the macroblock The steps of block type judgment;
- an unchanged macroblock judging module used for determining whether the current macroblock is an unchanged macroblock according to the prediction result if the current macroblock is not a video macroblock
- the unchanged macroblock encoding module is used to perform encoding on the current macroblock according to the encoding mode corresponding to the unchanged macroblock to obtain unchanged encoded data if the current macroblock is an unchanged macroblock, and repeat for the next macroblock Perform the steps of macroblock type judgment;
- a motion vector macroblock judgment module configured to judge whether the current macroblock is a motion vector macroblock according to the prediction result if the current macroblock is not an unchanged macroblock
- the motion vector macroblock coding module is used to perform coding on the current macroblock according to the coding mode corresponding to the motion vector macroblock if the current macroblock is a motion vector macroblock to obtain motion vector coded data, and repeat for the next macroblock Perform the steps of macroblock type judgment;
- a text macroblock judgment module configured to judge whether the current macroblock is a text macroblock according to the prediction result if the current macroblock is not a motion vector macroblock
- the text macroblock encoding module is used for, if the current macroblock is a text macroblock, perform encoding on the current macroblock according to the encoding method corresponding to the text macroblock to obtain text encoded data, and repeat the macroblock type for the next macroblock the steps of judgment;
- an image macroblock judgment module configured to judge whether the current macroblock is an image macroblock according to the prediction result if the current macroblock is not a text macroblock
- the image macroblock encoding module is configured to, if the current macroblock is an image macroblock, perform encoding on the current macroblock according to the encoding mode corresponding to the image macroblock to obtain image encoded data, and repeat the macroblock type for the next macroblock judgment steps.
- the literal macroblock encoding module includes:
- the second data acquisition sub-module is configured to perform cosine transform on the text macroblock when it is determined that the encoding device of the text macroblock is the progressive encoding, and perform quantization using the second preset quantization parameter to obtain a second data acquisition sub-module. data;
- a progressive encoding submodule configured to perform progressive encoding on the second data to obtain the character encoded data
- a text encoding submodule configured to perform text encoding on the current macroblock to obtain the text encoding data when it is determined that the encoding device for the text macroblock is the text encoding;
- the first preset quantization parameter is smaller than the second preset quantization parameter.
- the third obtaining module includes:
- An obtaining submodule configured to obtain the encoded data of the current frame according to the video encoded data, the unchanged encoded data, the motion vector encoded data, the text encoding and the image encoded data.
- an embodiment of the present disclosure further provides a computer-readable storage medium, for example, a non-transitory computer-readable storage medium may be a read-only memory (English: Read Only Memory). Memory, ROM), random access memory (English: Random Access Memory, RAM), CD-ROM, magnetic tape, floppy disk and optical data storage devices, etc.
- the storage medium stores computer instructions for executing the video encoding method described in the embodiment corresponding to FIG. 1 , which will not be repeated here.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
本申请的实施例提供一种视频编码方法及装置,涉及视频处理技术领域,能够解决vGTP视频编码算法在网络情况较差的场景下,适应性比较差的问题。具体技术方案为:获取当前帧;在当前帧与参考帧不相同时,获取当前帧中各个宏块的宏块类型;若宏块的类型为文字宏块或图像宏块,则确定文字宏块为渐进编码或文字编码;确定图像宏块的编码方法为分层编码或渐进编码;根据各个宏块类型对应的编码方法对各个宏块进行编码得到多个编码数据;根据多个编码数据获取当前帧的编码数据。由于在编码时,会根据当前网络情况选择分层编码方式或渐进式的编码方式,以让编码后的码流可以更加适应当前网络传输。
Description
本公开涉及视频处理领域,尤其涉及视频编码方法及装置。
vGTP是实时图像压缩传输协议,完全独立,自主可控,具备多编码器,渐进式编码,视觉无损图像传递,网络带宽自适应,QoS等核心技术,并且支持音频传输和反向控制通道。
但现有vGTP视频编码在网络情况较差的场景下,适应性比较差。
发明内容
本公开实施例提供一种视频编码方法及装置,能够解决vGTP视频编码算法在网络情况较差的场景下,适应性比较差的问题。所述技术方案如下:
根据本公开实施例的第一方面,提供一种视频编码方法,该方法包括:
获取当前帧;
在所述当前帧与参考帧不相同时,获取所述当前帧中各个宏块的宏块类型;
若所述宏块的类型为文字宏块或图像宏块,则确定所述文字宏块或所述图像宏块的编码方法,所述文字宏块的编码方法包括:渐进编码或文字编码;所述图像宏块的编码方法包括:分层编码或渐进编码;
根据所述各个宏块类型对应的编码方法对所述各个宏块进行编码得到多个编码数据;
根据所述多个编码数据获取所述当前帧的编码数据。
本公开提供一种视频编码方法,包括:获取当前帧;在当前帧与参考帧 不相同时,获取当前帧中各个宏块的宏块类型;若宏块的类型为文字宏块或图像宏块,则确定文字宏块或图像宏块的编码方法,文字宏块的编码方法包括:渐进编码或文字编码;图像宏块的编码方法包括:分层编码或渐进编码;根据各个宏块类型对应的编码方法对各个宏块进行编码得到多个编码数据;根据多个编码数据获取当前帧的编码数据。其中,由于在编码时,并未一成不变的使用分层式的编码方式或渐进式的编码方式,而是会根据当前网络情况选择不同的编码方式,以让编码后的码流可以更加适应当前网络传输,因此,本公开中的视频编码方法可以不同网络条件,不同需求下使用的不相同的处理流程,可配性较高。
在一个实施例中,当所述宏块类型为图像宏块时,所述确定所述图像宏块的编码方法,包括:
对所述图像宏块执行余弦变换,并采用第一预设量化参数进行量化得到第一数据;
判断当前码率控制策略是否为第一码率控制策略;
若是,确定所述图像宏块的编码方法为分层编码;
若否,确定所述图像宏块的编码方法为渐进式编码。
在一个实施例中,当所述宏块的类型为文字宏块时,所述确定所述文字宏块的编码方法,包括:
判断当前码率控制策略是否为第二码率控制策略;
若是,确定所述文字宏块的编码方法为所述渐进式编码;
若否,确定所述文字宏块的编码方法为所述文字编码方式。
在一个实施例中,所述获取所述当前帧中各个宏块的宏块类型之前,所述方法还包括:
在所述当前帧与所述参考帧不相同时,判断所述当前帧是否为全帧h.264编码;
若是,采用h.264编码方法对所述当前帧进行编码;
若否,判断当前帧是否为全帧vGTP编码;
若是,则进行全局运动矢量预测,得到预测结果;
若否,则进行视频窗口识别,对视频窗口识别结果进行全局运动矢量预测,得到预测结果;
所述获取所述当前帧中各个宏块的宏块类型,包括:
根据所述预测结果确定当前帧中各个宏块的宏块类型。
在一个实施例中,所述根据所述预测结果确定当前帧中各个宏块的宏块类型,包括:
根据所述预测结果逐一判断当前帧中各个宏块的宏块类型;
所述根据所述各个宏块类型对应的编码方法对所述各个宏块进行编码得到多个编码数据,包括:
根据当前宏块的宏块类型对应的编码方法对所述当前宏块进行编码。
在一个实施例中,所述根据所述预测结果逐一判断当前帧中各个宏块的宏块类型,根据当前宏块的宏块类型对应的编码方法对所述当前宏块进行编码,包括:
根据所述预测结果判断当前宏块是否为视频宏块;
若当前宏块是视频宏块,则根据视频宏块对应的编码方式对所述当前宏块执行编码得到视频编码数据,并使用下一个宏块作为当前宏块循环执行宏块类型判断的步骤;
若当前宏块不是视频宏块,则根据所述预测结果判断当前宏块是否为未变化宏块,
若当前宏块是未变化宏块,则根据未变化宏块对应的编码方式对所述当前宏块执行编码得到未变化编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
若当前宏块不是未变化宏块,则根据所述预测结果判断当前宏块是否为运动矢量宏块,
若当前宏块是运动矢量宏块,则根据运动矢量宏块对应的编码方式对所述当前宏块执行编码得到运动矢量编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
若当前宏块不是运动矢量宏块,则根据所述预测结果判断当前宏块是否 为文字宏块,
若当前宏块是文字宏块,则根据文字宏块对应的编码方式对所述当前宏块执行编码得到文字编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
若当前宏块不是文字宏块,则根据所述预测结果判断当前宏块是否为图像宏块,
若当前宏块是图像宏块,则根据图像宏块对应的编码方式对所述当前宏块执行编码得到图像编码数据,并对下一个宏块重复执行宏块类型判断的步骤。
在一个实施例中,所述根据文字宏块对应的编码方式对所述当前宏块执行编码得到文字编码数据,包括:
在确定所述文字宏块的编码方法为所述渐进式编码时,对所述文字宏块执行余弦变换,并采用第二预设量化参数进行量化得到第二数据;
对所述第二数据执行渐进式编码,得到所述文字编码数据;
在确定所述文字宏块的编码方法为所述文字编码时,对所述当前宏块执行文字编码,得到所述文字编码数据;
其中,所述第一预设量化参数小于所述第二预设量化参数。
在一个实施例中,所述根据所述多个编码数据获取所述当前帧的编码数据,包括:
根据所述视频编码数据、所述未变化编码数据、所述运动矢量编码数据、所述文字编码和所述图像编码数据获取所述当前帧的编码数据。
根据本公开实施例的第二方面,提供一种视频编码装置,所述装置包括:
第一获取模块,用于获取当前帧;
第二获取模块,用于在所述当前帧与参考帧不相同时,获取所述当前帧中各个宏块的宏块类型;
第一确定模块,用于若所述宏块的类型为文字宏块或图像宏块,则确定所述文字宏块或所述图像宏块的编码装置,所述文字宏块的编码装置包括:渐进编码或文字编码;所述图像宏块的编码装置包括:分层编码或渐进编码;
第一编码模块,用于根据所述各个宏块类型对应的编码装置对所述各个宏块进行编码得到多个编码数据;
第三获取模块,用于根据所述多个编码数据获取所述当前帧的编码数据。
在一个实施例中,当所述宏块类型为图像宏块时,所述第一确定模块包括:
第一处理子模块,用于对所述图像宏块执行余弦变换,并采用第一预设量化参数进行量化得到第一数据;
第一判断子模块,用于判断当前码率控制策略是否为第一码率控制策略;
第一确定子模块,用于在当前码率控制策略为第一码率控制策略时,确定所述图像宏块的编码装置为分层编码;
第二确定子模块,用于在当前码率控制策略不为第一码率控制策略时,确定所述图像宏块的编码装置为渐进式编码。
在一个实施例中,当所述宏块的类型为文字宏块时,所述第一确定模块包括:
第二判断子模块,用于判断当前码率控制策略是否为第二码率控制策略;
第三确定子模块,用于在当前码率控制策略为第二码率控制策略时,确定所述文字宏块的编码装置为所述渐进式编码;
第四确定子模块,用于在当前码率控制策略不为第二码率控制策略时,确定所述文字宏块的编码装置为所述文字编码方式。
在一个实施例中,所述装置还包括:
第一判断模块,用于在所述第二获取模块获取所述当前帧中各个宏块的宏块类型之前,在所述当前帧与所述参考帧不相同时,判断所述当前帧是否为全帧h.264编码;
第二编码模块,用于在当前帧为全帧h.264编码时,采用h.264编码装置对所述当前帧进行编码;
第二判断模块,用于在当前帧不为全帧h.264编码时,判断当前帧是否为全帧vGTP编码;
第三获取模块,用于在当前帧为全帧vGTP编码时,则进行全局运动矢 量预测,得到预测结果;
第四获取模块,用于在当前帧不为全帧vGTP编码时,则进行视频窗口识别,对视频窗口识别结果进行全局运动矢量预测,得到预测结果;
所述第二获取模块,包括:
第五确定子模块,用于根据所述预测结果确定当前帧中各个宏块的宏块类型。
在一个实施例中,所述第五确定子模块包括:第一判断子单元;所述第一编码模块包括:第一编码子模块,
第一判断子单元,用于根据所述预测结果逐一判断当前帧中各个宏块的宏块类型;
第一编码子模块,用于根据当前宏块的宏块类型对应的编码装置对所述当前宏块进行编码。
在一个实施例中,所述装置还包括:
视频宏块判断模块,用于根据所述预测结果判断当前宏块是否为视频宏块;
视频编码模块,用于若当前宏块是视频宏块,则根据视频宏块对应的编码方式对所述当前宏块执行编码得到视频编码数据,并使用下一个宏块作为当前宏块循环执行宏块类型判断的步骤;
未变化宏块判断模块,用于若当前宏块不是视频宏块,则根据所述预测结果判断当前宏块是否为未变化宏块,
未变化宏块编码模块,用于若当前宏块是未变化宏块,则根据未变化宏块对应的编码方式对所述当前宏块执行编码得到未变化编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
运动矢量宏块判断模块,用于若当前宏块不是未变化宏块,则根据所述预测结果判断当前宏块是否为运动矢量宏块,
运动矢量宏块编码模块,用于若当前宏块是运动矢量宏块,则根据运动矢量宏块对应的编码方式对所述当前宏块执行编码得到运动矢量编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
文字宏块判断模块,用于若当前宏块不是运动矢量宏块,则根据所述预测结果判断当前宏块是否为文字宏块,
文字宏块编码模块,用于若当前宏块是文字宏块,则根据文字宏块对应的编码方式对所述当前宏块执行编码得到文字编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
图像宏块判断模块,用于若当前宏块不是文字宏块,则根据所述预测结果判断当前宏块是否为图像宏块,
图像宏块编码模块,用于若当前宏块是图像宏块,则根据图像宏块对应的编码方式对所述当前宏块执行编码得到图像编码数据,并对下一个宏块重复执行宏块类型判断的步骤。
在一个实施例中,所述文字宏块编码模块包括:
第二数据获取子模块,用于在确定所述文字宏块的编码装置为所述渐进式编码时,对所述文字宏块执行余弦变换,并采用第二预设量化参数进行量化得到第二数据;
渐进式编码子模块,用于对所述第二数据执行渐进式编码,得到所述文字编码数据;
文字编码子模块,用于在确定所述文字宏块的编码装置为所述文字编码时,对所述当前宏块执行文字编码,得到所述文字编码数据;
其中,所述第一预设量化参数小于所述第二预设量化参数。
在一个实施例中,所述第三获取模块包括:
获取子模块,用于根据所述视频编码数据、所述未变化编码数据、所述运动矢量编码数据、所述文字编码和所述图像编码数据获取所述当前帧的编码数据。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公 开的实施例,并与说明书一起用于解释本公开的原理。
图1是本公开实施例提供的一种视频编码方法的流程图;
图2是本公开实施例提供的一种视频编码方法的流程图;
图3是本公开实施例提供的一种视频编码方法的流程图;
图4是本公开实施例提供的一种视频编码方法的流程图;
图5是本公开实施例提供的一种视频编码装置的结构示意图。
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。
首先介绍本公开中的技术名词:
渐进式编码:对JPEG编码的picture宏块,通过将分层的方法,在网络带宽允许的条件下,将视频画面逐渐传输到清晰为止;
分层编码:分层编码和渐进式编码的原理相同,只是在编码过程中每一帧传输的清晰度相同,在传输之前确定待编码的层数。一般适用于传输带宽受限的场景,比如当前帧一共分为5层,但是当前带宽资源较少,可以只发送3层。
DCT:余弦变换;
RC:码率控制策略;
量化(参数):参数越大清晰度越好,其中T1<T2,T1是用来编码picture宏块,T2是用来编码Text宏块的;
宏块:大小为16x16的像素,vgtp将一帧图像划分为大小相同的宏块,并对每个宏块进行分类后再进行编码;
码率控制的方法有如下3种,3种方法均可控制视频帧编码的最低和最 高层数:
NORC:vgtp算法不负责码率控制,picture采用分层编码,text宏块采用文字编码;
PrimaryRC:picture宏块采用渐进式编码,text采用文字编码;
HighRC:picture采用渐进式编码,text采用渐进式编码,但text的量化参数要比picture的量化参数大。
本公开实施例提供一种视频编码方法,如图1所示,该视频编码方法包括以下步骤:
101、获取当前帧。
102、在当前帧与参考帧不相同时,获取当前帧中各个宏块的宏块类型。
103、若宏块的类型为文字宏块或图像宏块,则确定文字宏块或图像宏块的编码方法,文字宏块的编码方法包括:渐进编码或文字编码;图像宏块的编码方法包括:分层编码或渐进编码。
现有的vgtp算法中,对文字宏块会直接使用文字编码的方式进行编码,对图像宏块会直接使用图像编码的方式进行编码,这样的编码方式会使得文字宏块和图像宏块编码后的码流高。
而本公开中,为文字宏块设置了两种不同的编码方法,分别为渐进编码或文字编码,其中渐进编码会使得编码后的码流相较于文字编码后的码流低,从而在网络情况较差的场景下,适应性较强。
进一步的,为图像宏块设置了两种不同的编码方法,分别为分层编码或渐进编码,而分层编码或渐进编码会使得编码后的码流相较于视频编码后的码流低,从而提升了编码数据的适应性。
104、根据各个宏块类型对应的编码方法对各个宏块进行编码得到多个编码数据。
105、根据多个编码数据获取当前帧的编码数据。
由于现有vGTP视频编码算法在网络情况较差的场景下,适应性比较差。此外,现有的vGTP在不同场景,不同网络条件,不同需求下使用的基本上都是相同的处理流程,可配性也比较差。
为了解决上述技术问题,本公开提出一种新的视频编码方法,在本公开中,会将现有的vgtp算法和分层渐进式的编码方式进行融合,由于分层渐进式的编码方式可以有效的降低码流,从而采用本公开中的视频编码方法编码后的码流相较于现有技术中的vgtp算法编码后的码流,可以明显降低码流的数据量,使得在网络情况较差的场景下,适应性较强,
会对当前帧的宏块进行分类,对不同类型的宏块采用不同的编码方法,从而使得本公开中的视频编码方法的适应性更强,且非常灵活,能够满足用户的个性化需求。
进一步的,由于在编码时,并未一成不变的使用分层式的编码方式或渐进式的编码方式,而是会根据当前网络情况选择不同的编码方式,以让编码后的码流可以更加适应当前网络传输,因此,本公开中的视频编码方法可以不同网络条件,不同需求下使用的不相同的处理流程,可配性较高。
本公开提供一种视频编码方法,包括:获取当前帧;在当前帧与参考帧不相同时,获取当前帧中各个宏块的宏块类型;若宏块的类型为文字宏块或图像宏块,则确定文字宏块或图像宏块的编码方法,文字宏块的编码方法包括:渐进编码或文字编码;图像宏块的编码方法包括:分层编码或渐进编码;根据各个宏块类型对应的编码方法对各个宏块进行编码得到多个编码数据;根据多个编码数据获取当前帧的编码数据。其中,由于在编码时,并未一成不变的使用分层式的编码方式或渐进式的编码方式,而是会根据当前网络情况选择不同的编码方式,以让编码后的码流可以更加适应当前网络传输,因此,本公开中的视频编码方法可以不同网络条件,不同需求下使用的不相同的处理流程,可配性较高。
在一个实施例中,如图2所示,当宏块类型为图像宏块时,确定图像宏块的编码方法,包括以下子步骤:
1031、对图像宏块执行余弦变换,并采用第一预设量化参数进行量化得到第一数据。
1032、判断当前码率控制策略是否为第一码率控制策略。
1033、若是,确定图像宏块的编码方法为分层编码。
1034、若否,确定图像宏块的编码方法为渐进式编码。
相关技术中,在对图像宏块执行编码时,会直接对图像宏块执行余弦变换,并采用一个预设量化参数进行量化,然后对量化后的数据采用视频编码的方式执行视频编码。
而本公开中,在对图像宏块(也称之为:picture宏块)执行余弦变换,并采用第一预设量化参数进行量化得到第一数据后,还会去判断当前码率控制策略是否为第一码率控制策略,如果当前码率控制策略为第一码率控制策略,则确定图像宏块的编码方法为分层编码,如果当前码率控制策略不是第一码率控制策略,则确定图像宏块的编码方法为渐进式编码。
示例的,第一码流控制策略包括:NORC。具体的,对picture宏块进行DCT变换,并采用较小的第一预设量化参数T1进行量化得到第一数据。判断当前的码率控制策略是否为NORC,当码率控制策略为NORC时,picture宏块的编码方式为分层编码,picture宏块的编码方式为渐进式编码。
需要说明的是,若码率控制策略不同,则对picture宏块的编码方式也不同,因此,在本步骤中需要先确定码率控制策略,才能确定对picture宏块的编码方式。
在一个实施例中,如图3所示,当宏块的类型为文字宏块(也可以称之为:text宏块)时,根据码率控制策略确定文字宏块的编码方法,包括以下子步骤:
1035、判断当前码率控制策略是否为第二码率控制策略;
1036、若是,确定文字宏块的编码方法为渐进式编码;
1037、若否,确定文字宏块的编码方法为文字编码方式。
示例的,第二码率控制策略包括:HighRC。具体的,判断当前的码率控制策略是否为HighRC,其中,当码率控制策略为HighRC时,picture宏块的编码方式为渐进式编码,text宏块的编码方式为渐进式编码,但text的量化参数要比picture的量化参数大。
需要说明的是,若码率控制策略不同,则对text宏块的编码方式也不同,因此,在本步骤中需要先确定码率控制策略,才能确定对text宏块的编码方式。
在一个实施例中,在获取当前帧中各个宏块的宏块类型之前,上述方法 还包括以下子步骤:
A1、在当前帧与参考帧不相同时,判断当前帧是否为全帧h.264编码;
需要说明的是,全帧h.264编码是事先设置的。由于h.264对于视频图像的编码效率高且质量好,因此,对于某些场景,比如播放全屏动画的场景,则可以设置一个时间段内的图像帧均为全帧h.264编码,对于静止图像较多的场景,比如办公桌面,则无需设置全帧h.264编码。
A2、若是,采用h.264编码方法对当前帧进行编码;
A3、若否,判断当前帧是否为全帧vGTP编码;
需要说明的是,全帧vGTP编码是事先设置的。可以将包含有视频窗口的图像帧设置为全帧vGTP编码。
具体的,在本步骤中,判断当前帧是否为全帧vGTP编码;在确定当前帧不是全帧vGTP编码之后,可以通过执行视频窗口的识别,在确定当前帧是全帧vGTP编码之后,可以对当前帧的宏块进行分类。
A4、若是,则进行全局运动矢量预测,得到预测结果;
A5、若否,则进行视频窗口识别,对视频窗口识别结果进行全局运动矢量预测,得到预测结果;
在本步骤中,在确定当前帧不是全帧vGTP编码之后,可以识别当前帧中的视频窗口;进而根据视频窗口的范围,对视频窗口范围内的宏块进行进一步分类。
需要说明的是,该视频窗口的范围包括:位置和尺寸。视频窗口中可能为静态图像,也可能为动态视频。
值得注意的是,需要说明的是,本步骤之后的处理对象是以宏块为单位的,而在本步骤之前,处理对象是以帧为单位的。
此时,上述获取当前帧中各个宏块的宏块类型,包括以下子步骤:
A6、根据预测结果确定当前帧中各个宏块的宏块类型。
在一种可实现方式中,可以根据预测结果逐一判断当前帧中各个宏块的宏块类型,也即以串行的方式逐一判断;也可以将当前帧中的所有宏块统一进行判断,也即以并行的方式进行判断。
在判断完一个宏块后,对当前宏块尽心编码,也即根据当前宏块的宏块类型对应的编码方法对当前宏块进行编码。
具体的,获取当前帧,判断当前帧与参考帧是否相同;若相同,则不进行编码,开始处理下一帧,若不相同,则判断当前帧是否为全帧h.264编码,若当前帧为全帧h.264编码,将当前帧输入到h.264编码器进行编码,对本帧的编码处理完成,待编码完成后开始处理下一帧;如果当前帧不是全帧h.264编码,就需要判断当前帧是否为全帧vGTP编码,如果当前帧是全帧vGTP编码,则进行全局运动矢量预测,得到预测结果,并根据预测结果确定当前帧中各个宏块的宏块类型;如果当前帧不是全帧vGTP编码,则进行视频窗口识别,对视频窗口识别结果再进行全局运动矢量预测,得到预测结果,并根据预测结果确定当前帧中各个宏块的宏块类型。
在本步骤中,参考帧可以是参考图像,
在一个实施例中,根据预测结果逐一判断当前帧中各个宏块的宏块类型,根据当前宏块的宏块类型对应的编码方法对当前宏块进行编码,包括以下子步骤:
B1、根据预测结果判断当前宏块是否为视频宏块(也可以称之为:video宏块);
B2、若当前宏块是视频宏块,则根据视频宏块对应的编码方式对当前宏块执行编码得到视频编码数据,并使用下一个宏块作为当前宏块循环执行宏块类型判断的步骤;
在本步骤中,在确定视频窗口的范围之后,判断当前宏块是否为video宏块,若为是,则可以对该video宏块进行编码,生成video宏块的视频编码数据,具体可以是h.264编码,若为否,则通过后续步骤对宏块进行进一步分类。
需要说明的是,在本步骤中需要对当前帧的所有宏块依次进行判断,以便排查出video宏块。
B3、若当前宏块不是视频宏块,则根据预测结果判断当前宏块是否为未变化宏块,
B4、若当前宏块是未变化宏块(也可以称之为:unchange宏块),则根 据未变化宏块对应的编码方式对当前宏块执行编码得到未变化编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
B5、若当前宏块不是未变化宏块,则根据预测结果判断当前宏块是否为运动矢量宏块,
B6、若当前宏块是运动矢量宏块(也可以称之为:mv宏块),则根据运动矢量宏块对应的编码方式对当前宏块执行编码得到运动矢量编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
B7、若当前宏块不是运动矢量宏块,则根据预测结果判断当前宏块是否为文字宏块,
B8、若当前宏块是文字宏块(也可以称之为:text宏块),则根据文字宏块对应的编码方式对当前宏块执行编码得到文字编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
B9、若当前宏块不是文字宏块,则根据预测结果判断当前宏块是否为图像宏块;
B10、若当前宏块是图像宏块(也可以称之为:picture宏块),则根据图像宏块对应的编码方式对当前宏块执行编码得到图像编码数据,并对下一个宏块重复执行宏块类型判断的步骤。
在一个实施例中,根据文字宏块对应的编码方式对当前宏块执行编码得到文字编码数据,包括以下子步骤:
C1、在确定文字宏块的编码方法为渐进式编码时,对文字宏块执行余弦变换,并采用第二预设量化参数进行量化得到第二数据;其中,第一预设量化参数小于第二预设量化参数;
C2、对第二数据执行渐进式编码,得到文字编码数据;
具体的,对text宏块进行DCT变换;采用较大第二预设量化参数T2进行量化;进行渐进式编码,生成text宏块的文字编码数据。
其中,参数T2大于参数T1。
在本步骤中,若当前的码率控制策略为HighRC,则先对text宏块进行DCT变换,再采用较大参数T2进行量化,最后进行渐进式编码,生成text 宏块的编码数据。
C3、在确定文字宏块的编码方法为文字编码时,对当前宏块执行文字编码,得到文字编码数据。
具体的,若当前的码率控制策略不为HighRC,则对text宏块进行文字编码,生成text宏块的文字编码数据。
在一个实施例中,上述步骤105包括以下子步骤:
在对当前帧中的所有宏块均执行了编码后,根据上述步骤中得到的各个宏块对应的编码数据,生成当前帧的编码数据。
具体的,根据视频编码数据、未变化编码数据、运动矢量编码数据、文字编码和图像编码数据获取当前帧的编码数据。
可见,在本发明中,不仅能够结合渐进和分层的编码方式,而且能够对当前帧的宏块进行分类,对不同类型的宏块采用不同的编码方式,同时,还可以参考当前的码率控制策略,修改指定类型的宏块的编码方式。适应性强,且使用非常灵活,能够满足用户的个性化需求。
下面通过具体实施例方式介绍本公开中的技术方案,如图4所示,该方法包括以下子步骤:
201、输入一帧,也即获取当前帧。
202、判断当前帧与参考帧是否相同;若相同,则不进行编码,开始处理下一帧,若不相同,则执行步骤203。
在本步骤中,参考帧可以是参考图像,如果当前帧与参考图像相同,则无需编码,可以处理下一帧,若不相同,则进行后续步骤。
203,判断当前帧是否是全帧h.264编码;若是,则执行步骤204,若不相同,则执行步骤205。
需要说明的是,全帧h.264编码是事先设置的。由于h.264对于视频图像的编码效率高且质量好,因此,对于某些场景,比如播放全屏动画的场景,则可以设置一个时间段内的图像帧均为全帧h.264编码,对于静止图像较多的场景,比如办公桌面,则无需设置全帧h.264编码。
在本步骤中,可以判断当前帧是否为全帧h.264编码,若为是,则通过 执行步骤204,对该帧进行h.264编码,若否,则需要进行进一步分类和处理。
步骤204,将当前帧输入到h.264编码器进行编码,对本帧的编码处理完成。
在本步骤中,在确定当前帧是全帧h.264编码之后,使用h.264编码器对当前帧进行编码。待编码完成后开始处理下一帧。
步骤205,判断当前帧是否为全帧vGTP编码,若为是,则执行步骤206,若为否,则执行步骤207。
需要说明的是,全帧vGTP编码是事先设置的。可以将包含有视频窗口的图像帧设置为全帧vGTP编码。
在本步骤中,判断当前帧是否为全帧vGTP编码;在确定当前帧不是全帧vGTP编码之后,可以通过执行步骤8进行视频窗口的识别,在确定当前帧是全帧vGTP编码之后,可以对当前帧的宏块进行分类。
步骤206,对当前帧进行全局MV预测,得到预测结果,执行步骤7。
在本步骤中,在确定当前帧不是全帧h.264编码之后,对当前帧进行全局MV预测,得到预测结果,得到预测结果后,执行步骤208。
步骤207,对当前帧进行视频窗口的识别,确定视频窗口的范围,执行步骤206。
在本步骤中,在确定当前帧不是全帧vGTP编码之后,可以识别当前帧中的视频窗口;进而根据视频窗口的范围,对视频窗口范围内的宏块进行进一步分类。
需要说明的是,该视频窗口的范围包括:位置和尺寸。视频窗口中可能为静态图像,也可能为动态视频。
步骤208,判断当前帧的宏块是否为video宏块;若为是,则执行步骤2024,若为否,则执行步骤209。
在本步骤中,在确定视频窗口的范围之后,判断当前帧的宏块是否为video宏块,若为是,则可以对该video宏块进行编码,生成video宏块的编码数据,具体可以是h.264编码,若为否,则通过后续步骤对宏块进行进一步分类。
需要说明的是,在本步骤中需要对当前帧的所有宏块依次进行判断,以便排查出video宏块。
需要说明的是,从步骤208开始,处理对象是以宏块为单位的,而在步骤208之前,处理对象是以帧为单位的。
步骤209,判断当前帧中除已确定类型的宏块以外的其他宏块是否为unchange宏块,若为是,则执行步骤2024,若为否,则执行步骤2010。
需要说明的是,本步骤可以对当前帧中,除了步骤208已经确定的video宏块以外的所有宏块进行分类。
在本步骤中,在确定当前帧是全帧vGTP编码之后,对当前帧中除在步骤208中已确定的video宏块以外的其他宏块进行分类;依次判断宏块是否为unchange宏块;若为是,则可以对该unchange宏块进行编码,生成unchange宏块的编码数据,若为否,则通过后续步骤继续进行分类。
步骤2011,判断当前帧中除已确定类型的宏块以外的其他宏块是否为mv宏块;若为是,则执行步骤2024,若为否,则执行步骤2012。
需要说明的是,本步骤可以对当前帧中,除了步骤208已经确定的video宏块,以及步骤209已确定的unchange宏块以外的所有宏块进行分类。
在本步骤中,根据步骤206得到的预测结果,对当前帧中除在步骤208中已确定的video宏块,以及步骤209已确定的unchange宏块以外的其他宏块进行分类;依次判断宏块是否为mv宏块;若为是,则通过步骤2024对该宏块进行编码,生成mv宏块的编码数据,若为否,则通过后续步骤继续进行分类。
步骤2012,判断当前帧中除已确定类型的宏块以外的其他宏块是否为text宏块;若为是,则执行步骤2013,若为否,则执行步骤2018。
需要说明的是,本步骤可以对当前帧中,除了步骤208已经确定的video宏块,以及步骤209已确定的unchange宏块,以及步骤2010已确定的mv宏块以外的所有宏块进行分类。
在本步骤中,对当前帧中除在步骤208中已确定的video宏块,以及步骤209已确定的unchange宏块,以及步骤2010已确定的mv宏块以外的其他宏块进行分类;依次判断宏块是否为text宏块;若为是,则通过步骤2013 进一步判断码率控制策略,以便确定对text宏块的编码方式,若为否,则通过后续步骤继续进行分类。
步骤2013,判断当前码率控制策略(RC)是否为HIGH;若为是,则执行步骤2014;若为否,则执行步骤2017。
需要说明的是,若码率控制策略不同,则对text宏块的编码方式也不同,因此,在本步骤中需要先确定码率控制策略,才能确定对text宏块的编码方式。
其中,当码率控制策略为HighRC时,picture宏块的编码方式为渐进式编码,text宏块的编码方式为渐进式编码,但text的量化参数要比picture的量化参数大。
在本步骤中,判断当前的码率控制策略是否为HighRC,若为是,则通过步骤2014对该text宏块进行渐进式编码。
步骤2014,对text宏块进行DCT变换。
步骤2015,采用较大参数T2进行量化。
步骤2016,进行渐进式编码,生成text宏块的编码数据。
其中,参数T2大于参数T1。
在本步骤中,若当前的码率控制策略为HighRC,则先对text宏块进行DCT变换,再采用较大参数T2进行量化,最后进行渐进式编码,生成text宏块的编码数据。
步骤2017,对text宏块进行文字编码,生成text宏块的编码数据,执行步骤2024。
在本步骤中,若当前的码率控制策略不为HighRC,则对text宏块进行文字编码,生成text宏块的编码数据。
步骤2018,判断当前帧中除已确定类型的宏块以外的其他宏块是否为picture宏块;若为是,则执行步骤2019。
需要说明的是,本步骤可以对当前帧中,除了步骤208已经确定的video宏块,以及步骤209已确定的unchange宏块,以及步骤2010已确定的mv宏块,以及步骤2012已确定的text宏块以外的所有宏块进行分类。
在本步骤中,对当前帧中除在步骤208中已确定的video宏块,以及步骤209已确定的unchange宏块,以及步骤2010已确定的mv宏块,以及步骤2012已确定的text宏块以外的其他宏块进行分类;依次判断宏块是否为picture宏块;若为是,则执行步骤2019。
步骤2019,对picture宏块进行DCT变换.
步骤2020,采用较小的参数T1进行量化;执行步骤2021。
其中,参数T1小于参数T2。
步骤2021,判断当前的码率控制策略是否为NORC;若为是,则执行步骤2022,若为否,则执行步骤2023.
需要说明的是,若码率控制策略不同,则对picture宏块的编码方式也不同,因此,在本步骤中需要先确定码率控制策略,才能确定对picture宏块的编码方式。
其中,当码率控制策略为NORC时,picture宏块的编码方式为分层编码,text宏块的编码方式为文字编码。
在本步骤中,判断当前的码率控制策略是否为NORC,若为是,则通过步骤2022对该picture宏块进行分层编码,若为否,则对该picture宏块进行渐进式编码。
步骤2022,对picture宏块进行分层编码,生成picture宏块的编码数据,执行步骤2024。
步骤2023,对picture宏块进行渐进式编码,生成picture宏块的编码数据,执行步骤2024。
步骤2024,基于所有宏块的编码数据,确定当前帧的编码数据。
在本步骤中,可以基于步骤208、步骤209、步骤2010、步骤2014、步骤2017、步骤2022、步骤2023得到的各类型的宏块的编码数据,生成当前帧的编码数据。
值得注意的是,上述图4对应的实施例可以使对当前帧中的所有宏块执行并行处理,也可以对当前帧中的各个宏块执行串行处理,在执行串行处理时,在当前步骤执行到步骤2024后,便循环到208,重新对下一个宏块执行 判断过程。
可见,在本发明中,不仅能够结合渐进和分层的编码方式,而且能够对当前帧的宏块进行分类,对不同类型的宏块采用不同的编码方式,同时,还可以参考当前的码率控制策略,修改指定类型的宏块的编码方式。适应性强,且使用非常灵活,能够满足用户的个性化需求。
基于上述图1对应的实施例中所描述的视频编码方法,下述为本公开装置实施例,可以用于执行本公开方法实施例。
本公开实施例提供一种视频编码装置,如图5所示,该视频编码装置包括:
第一获取模块11,用于获取当前帧;
第二获取模块12,用于在所述当前帧与参考帧不相同时,获取所述当前帧中各个宏块的宏块类型;
第一确定模块13,用于若所述宏块的类型为文字宏块或图像宏块,则确定所述文字宏块或所述图像宏块的编码装置,所述文字宏块的编码装置包括:渐进编码或文字编码;所述图像宏块的编码装置包括:分层编码或渐进编码;
第一编码模块14,用于根据所述各个宏块类型对应的编码装置对所述各个宏块进行编码得到多个编码数据;
第三获取模块15,用于根据所述多个编码数据获取所述当前帧的编码数据。
在一个实施例中,当所述宏块类型为图像宏块时,所述第一确定模块包括:
第一处理子模块,用于对所述图像宏块执行余弦变换,并采用第一预设量化参数进行量化得到第一数据;
第一判断子模块,用于判断所述当前码率控制策略是否为第一码率控制策略;
第一确定子模块,用于在当前码率控制策略为第一码率控制策略时,确定所述图像宏块的编码装置为分层编码;
第二确定子模块,用于在当前码率控制策略不为第一码率控制策略时, 确定所述图像宏块的编码装置为渐进式编码。
在一个实施例中,当所述宏块的类型为文字宏块时,所述第一确定模块包括:
第二判断子模块,用于判断所述当前码率控制策略是否为第二码率控制策略;
第三确定子模块,用于在当前码率控制策略为第二码率控制策略时,确定所述文字宏块的编码装置为所述渐进式编码;
第四确定子模块,用于在当前码率控制策略不为第二码率控制策略时,确定所述文字宏块的编码装置为所述文字编码方式。
在一个实施例中,所述装置还包括:
第一判断模块,用于在所述第二获取模块获取所述当前帧中各个宏块的宏块类型之前,在所述当前帧与所述参考帧不相同时,判断所述当前帧是否为全帧h.264编码;
第二编码模块,用于在当前帧为全帧h.264编码时,采用h.264编码装置对所述当前帧进行编码;
第二判断模块,用于在当前帧不为全帧h.264编码时,判断当前帧是否为全帧vGTP编码;
第三获取模块,用于在当前帧为全帧vGTP编码时,则进行全局运动矢量预测,得到预测结果;
第四获取模块,用于在当前帧不为全帧vGTP编码时,则进行视频窗口识别,对视频窗口识别结果进行全局运动矢量预测,得到预测结果;
所述第二获取模块,包括:
第五确定子模块,用于根据所述预测结果确定当前帧中各个宏块的宏块类型。
在一个实施例中,所述第五确定子模块包括:第一判断子单元;所述第一编码模块包括:第一编码子模块,
第一判断子单元,用于根据所述预测结果逐一判断当前帧中各个宏块的宏块类型;
第一编码子模块,用于根据当前宏块的宏块类型对应的编码装置对所述当前宏块进行编码。
在一个实施例中,所述装置还包括:
视频宏块判断模块,用于根据所述预测结果判断当前宏块是否为视频宏块;
视频编码模块,用于若当前宏块是视频宏块,则根据视频宏块对应的编码方式对所述当前宏块执行编码得到视频编码数据,并使用下一个宏块作为当前宏块循环执行宏块类型判断的步骤;
未变化宏块判断模块,用于若当前宏块不是视频宏块,则根据所述预测结果判断当前宏块是否为未变化宏块,
未变化宏块编码模块,用于若当前宏块是未变化宏块,则根据未变化宏块对应的编码方式对所述当前宏块执行编码得到未变化编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
运动矢量宏块判断模块,用于若当前宏块不是未变化宏块,则根据所述预测结果判断当前宏块是否为运动矢量宏块,
运动矢量宏块编码模块,用于若当前宏块是运动矢量宏块,则根据运动矢量宏块对应的编码方式对所述当前宏块执行编码得到运动矢量编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
文字宏块判断模块,用于若当前宏块不是运动矢量宏块,则根据所述预测结果判断当前宏块是否为文字宏块,
文字宏块编码模块,用于若当前宏块是文字宏块,则根据文字宏块对应的编码方式对所述当前宏块执行编码得到文字编码数据,并对下一个宏块重复执行宏块类型判断的步骤;
图像宏块判断模块,用于若当前宏块不是文字宏块,则根据所述预测结果判断当前宏块是否为图像宏块,
图像宏块编码模块,用于若当前宏块是图像宏块,则根据图像宏块对应的编码方式对所述当前宏块执行编码得到图像编码数据,并对下一个宏块重复执行宏块类型判断的步骤。
在一个实施例中,所述文字宏块编码模块包括:
第二数据获取子模块,用于在确定所述文字宏块的编码装置为所述渐进式编码时,对所述文字宏块执行余弦变换,并采用第二预设量化参数进行量化得到第二数据;
渐进式编码子模块,用于对所述第二数据执行渐进式编码,得到所述文字编码数据;
文字编码子模块,用于在确定所述文字宏块的编码装置为所述文字编码时,对所述当前宏块执行文字编码,得到所述文字编码数据;
其中,所述第一预设量化参数小于所述第二预设量化参数。
在一个实施例中,所述第三获取模块包括:
获取子模块,用于根据所述视频编码数据、所述未变化编码数据、所述运动矢量编码数据、所述文字编码和所述图像编码数据获取所述当前帧的编码数据。
基于上述图1对应的实施例中所描述的视频编码方法,本公开实施例还提供一种计算机可读存储介质,例如,非临时性计算机可读存储介质可以是只读存储器(英文:Read Only Memory,ROM)、随机存取存储器(英文:Random Access Memory,RAM)、CD-ROM、磁带、软盘和光数据存储装置等。该存储介质上存储有计算机指令,用于执行上述图1对应的实施例中所描述的视频编码方法,此处不再赘述。
本领域技术人员在考虑说明书及实践这里公开的公开后,将容易想到本公开的其它实施方案。本申请旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。
Claims (9)
- 一种视频编码方法,其特征在于,所述方法包括:获取当前帧;在所述当前帧与参考帧不相同时,获取所述当前帧中各个宏块的宏块类型;若所述宏块的类型为文字宏块或图像宏块,则确定所述文字宏块或所述图像宏块的编码方法,所述文字宏块的编码方法包括:渐进编码或文字编码;所述图像宏块的编码方法包括:分层编码或渐进编码;根据所述各个宏块类型对应的编码方法对所述各个宏块进行编码得到多个编码数据;根据所述多个编码数据获取所述当前帧的编码数据。
- 根据权利要求1所述的方法,其特征在于,当所述宏块类型为图像宏块时,所述确定所述图像宏块的编码方法,包括:对所述图像宏块执行余弦变换,并采用第一预设量化参数进行量化得到第一数据;判断当前码率控制策略是否为第一码率控制策略;若是,确定所述图像宏块的编码方法为分层编码;若否,确定所述图像宏块的编码方法为渐进式编码。
- 根据权利要求2所述的方法,其特征在于,当所述宏块的类型为文字宏块时,所述确定所述文字宏块的编码方法,包括:判断当前码率控制策略是否为第二码率控制策略;若是,确定所述文字宏块的编码方法为所述渐进式编码;若否,确定所述文字宏块的编码方法为所述文字编码方式。
- 根据权利要求3所述的方法,其特征在于,所述获取所述当前帧中各个宏块的宏块类型之前,所述方法还包括:在所述当前帧与所述参考帧不相同时,判断所述当前帧是否为全帧h.264编码;若是,采用h.264编码方法对所述当前帧进行编码;若否,判断当前帧是否为全帧vGTP编码;若是,则进行全局运动矢量预测,得到预测结果;若否,则进行视频窗口识别,对视频窗口识别结果进行全局运动矢量预测,得到预测结果;所述获取所述当前帧中各个宏块的宏块类型,包括:根据所述预测结果确定当前帧中各个宏块的宏块类型。
- 根据权利要求4所述的方法,其特征在于,所述根据所述预测结果确定当前帧中各个宏块的宏块类型,包括:根据所述预测结果逐一判断当前帧中各个宏块的宏块类型;所述根据所述各个宏块类型对应的编码方法对所述各个宏块进行编码得到多个编码数据,包括:根据当前宏块的宏块类型对应的编码方法对所述当前宏块进行编码。
- 根据权利要求5所述的方法,其特征在于,所述根据所述预测结果逐一判断当前帧中各个宏块的宏块类型,根据当前宏块的宏块类型对应的编码方法对所述当前宏块进行编码,包括:根据所述预测结果判断当前宏块是否为视频宏块;若当前宏块是视频宏块,则根据视频宏块对应的编码方式对所述当前宏块执行编码得到视频编码数据,并使用下一个宏块作为当前宏块循环执行宏块类型判断的步骤;若当前宏块不是视频宏块,则根据所述预测结果判断当前宏块是否为未变化宏块,若当前宏块是未变化宏块,则根据未变化宏块对应的编码方式对所述当前宏块执行编码得到未变化编码数据,并对下一个宏块重复执行宏块类型判断的步骤;若当前宏块不是未变化宏块,则根据所述预测结果判断当前宏块是否为运动矢量宏块,若当前宏块是运动矢量宏块,则根据运动矢量宏块对应的编码方式对所述当前宏块执行编码得到运动矢量编码数据,并对下一个宏块重复执行宏块类型判断的步骤;若当前宏块不是运动矢量宏块,则根据所述预测结果判断当前宏块是否为文字宏块,若当前宏块是文字宏块,则根据文字宏块对应的编码方式对所述当前宏块执行编码得到文字编码数据,并对下一个宏块重复执行宏块类型判断的步骤;若当前宏块不是文字宏块,则根据所述预测结果判断当前宏块是否为图像宏块,若当前宏块是图像宏块,则根据图像宏块对应的编码方式对所述当前宏块执行编码得到图像编码数据,并对下一个宏块重复执行宏块类型判断的步骤。
- 根据权利要求6所述的方法,其特征在于,所述根据文字宏块对应的编码方式对所述当前宏块执行编码得到文字编码数据,包括:在确定所述文字宏块的编码方法为所述渐进式编码时,对所述文字宏块执行余弦变换,并采用第二预设量化参数进行量化得到第二数据;对所述第二数据执行渐进式编码,得到所述文字编码数据;在确定所述文字宏块的编码方法为所述文字编码时,对所述当前宏块执行文字编码,得到所述文字编码数据;其中,所述第一预设量化参数小于所述第二预设量化参数。
- 根据权利要求6或7所述的方法,其特征在于,所述根据所述多个编码数据获取所述当前帧的编码数据,包括:根据所述视频编码数据、所述未变化编码数据、所述运动矢量编码数据、所述文字编码和所述图像编码数据获取所述当前帧的编码数据。
- 一种视频编码装置,其特征在于,所述装置包括:第一获取模块,用于获取当前帧;第二获取模块,用于在所述当前帧与参考帧不相同时,获取所述当前帧中各个宏块的宏块类型;第一确定模块,用于若所述宏块的类型为文字宏块或图像宏块,则确定所述文字宏块或所述图像宏块的编码装置,所述文字宏块的编码装置包括:渐进编码或文字编码;所述图像宏块的编码装置包括:分层编码或渐进编码;第一编码模块,用于根据所述各个宏块类型对应的编码装置对所述各个宏块进行编码得到多个编码数据;第三获取模块,用于根据所述多个编码数据获取所述当前帧的编码数据。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010695454.0 | 2020-07-17 | ||
CN202010695454.0A CN111953983B (zh) | 2020-07-17 | 2020-07-17 | 视频编码方法及装置 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022011916A1 true WO2022011916A1 (zh) | 2022-01-20 |
Family
ID=73340534
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/130430 WO2022011916A1 (zh) | 2020-07-17 | 2020-11-20 | 视频编码方法及装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN111953983B (zh) |
WO (1) | WO2022011916A1 (zh) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111953983B (zh) * | 2020-07-17 | 2024-07-23 | 西安万像电子科技有限公司 | 视频编码方法及装置 |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100158400A1 (en) * | 2008-12-19 | 2010-06-24 | Microsoft Corporation | Accelerated Screen Codec |
CN105379279A (zh) * | 2013-06-12 | 2016-03-02 | 微软技术许可有限责任公司 | 屏幕映射以及用于屏幕内容编码的基于标准的渐进式编解码器 |
CN105472392A (zh) * | 2015-12-11 | 2016-04-06 | 钟炎培 | 基于渐进式文字块压缩的屏幕视频编解码方法及编解码器 |
CN107566842A (zh) * | 2017-08-31 | 2018-01-09 | 西安万像电子科技有限公司 | 图像编解码压缩的方法、装置和*** |
CN110446041A (zh) * | 2018-05-02 | 2019-11-12 | 中兴通讯股份有限公司 | 一种视频编解码方法、装置、***及存储介质 |
CN111953983A (zh) * | 2020-07-17 | 2020-11-17 | 西安万像电子科技有限公司 | 视频编码方法及装置 |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
FI120125B (fi) * | 2000-08-21 | 2009-06-30 | Nokia Corp | Kuvankoodaus |
EP1388815A3 (en) * | 2002-04-25 | 2005-11-16 | Microsoft Corporation | Segmented layered image system |
US8648858B1 (en) * | 2009-03-25 | 2014-02-11 | Skyfire Labs, Inc. | Hybrid text and image based encoding |
US20110255594A1 (en) * | 2010-04-15 | 2011-10-20 | Soyeb Nagori | Rate Control in Video Coding |
US9380312B2 (en) * | 2014-07-14 | 2016-06-28 | Apple Inc. | Encoding blocks in video frames containing text using histograms of gradients |
CN106385592B (zh) * | 2016-08-31 | 2019-06-28 | 西安万像电子科技有限公司 | 图像压缩方法和装置 |
-
2020
- 2020-07-17 CN CN202010695454.0A patent/CN111953983B/zh active Active
- 2020-11-20 WO PCT/CN2020/130430 patent/WO2022011916A1/zh active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100158400A1 (en) * | 2008-12-19 | 2010-06-24 | Microsoft Corporation | Accelerated Screen Codec |
CN105379279A (zh) * | 2013-06-12 | 2016-03-02 | 微软技术许可有限责任公司 | 屏幕映射以及用于屏幕内容编码的基于标准的渐进式编解码器 |
CN105472392A (zh) * | 2015-12-11 | 2016-04-06 | 钟炎培 | 基于渐进式文字块压缩的屏幕视频编解码方法及编解码器 |
CN107566842A (zh) * | 2017-08-31 | 2018-01-09 | 西安万像电子科技有限公司 | 图像编解码压缩的方法、装置和*** |
CN110446041A (zh) * | 2018-05-02 | 2019-11-12 | 中兴通讯股份有限公司 | 一种视频编解码方法、装置、***及存储介质 |
CN111953983A (zh) * | 2020-07-17 | 2020-11-17 | 西安万像电子科技有限公司 | 视频编码方法及装置 |
Also Published As
Publication number | Publication date |
---|---|
CN111953983B (zh) | 2024-07-23 |
CN111953983A (zh) | 2020-11-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6717385B2 (ja) | 量子化パラメータに基づくビデオ処理のためのシステム及び方法 | |
TWI436287B (zh) | 畫像編碼方法及裝置 | |
AU2016250476A1 (en) | Adaptive bit rate control based on scenes | |
JP2008507915A (ja) | 映像圧縮のための符号器補助式フレーム速度アップコンバージョンのための方法及び装置 | |
WO2021164216A1 (zh) | 一种视频编码方法、装置、设备及介质 | |
CN110149515B (zh) | 数据传输方法及装置 | |
WO2020244324A1 (zh) | 图像传输方法及装置 | |
CN114071189A (zh) | 视频处理装置及视频串流的处理方法 | |
CN111901596B (zh) | 基于深度学习的视频混合编码与解码方法及装置、介质 | |
CN108353175B (zh) | 使用系数引起的预测处理视频信号的方法和装置 | |
CN109688407B (zh) | 编码单元的参考块选择方法、装置、电子设备及存储介质 | |
US11330263B1 (en) | Machine learning based coded size estimation in rate control of video encoding | |
CN111556318B (zh) | 数据传输方法及装置 | |
WO2023005740A1 (zh) | 图像编码、解码、重建、分析方法、***及电子设备 | |
WO2020244328A1 (zh) | 图像处理方法及装置 | |
WO2022011916A1 (zh) | 视频编码方法及装置 | |
CN114422792A (zh) | 视频图像压缩方法、装置、设备及存储介质 | |
US20200351518A1 (en) | Prediction direction selection method and apparatus in image encoding, and storage medium | |
Li et al. | Bi-level video: Video communication at very low bit rates | |
JP2024511084A (ja) | ニューラルネットワークを用いた画像及びビデオコーディングにおける潜時特徴の多分布エントロピーモデリング | |
CN111212288B (zh) | 视频数据的编解码方法、装置、计算机设备和存储介质 | |
Jung | Comparison of video quality assessment methods | |
JP2017509188A (ja) | ブロッキングアーチファクトの可視性を減少させるためのビデオ信号処理方法および装置 | |
US10003826B2 (en) | Method of reducing noise of video signal | |
CN111093076A (zh) | 编码方式确定方法及装置 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20944882 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20944882 Country of ref document: EP Kind code of ref document: A1 |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 20944882 Country of ref document: EP Kind code of ref document: A1 |