CN112738516A - Encoding method, encoding device, storage medium and electronic equipment - Google Patents

Encoding method, encoding device, storage medium and electronic equipment Download PDF

Info

Publication number
CN112738516A
CN112738516A CN202110336854.7A CN202110336854A CN112738516A CN 112738516 A CN112738516 A CN 112738516A CN 202110336854 A CN202110336854 A CN 202110336854A CN 112738516 A CN112738516 A CN 112738516A
Authority
CN
China
Prior art keywords
quantization parameter
preset
value
coding unit
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110336854.7A
Other languages
Chinese (zh)
Other versions
CN112738516B (en
Inventor
王克彦
杨国全
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Huachuang Video Signal Technology Co Ltd
Original Assignee
Zhejiang Huachuang Video Signal Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Huachuang Video Signal Technology Co Ltd filed Critical Zhejiang Huachuang Video Signal Technology Co Ltd
Priority to CN202110336854.7A priority Critical patent/CN112738516B/en
Publication of CN112738516A publication Critical patent/CN112738516A/en
Application granted granted Critical
Publication of CN112738516B publication Critical patent/CN112738516B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods 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/17Methods 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/172Methods 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 picture, frame or field
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods 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/177Methods 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 a group of pictures [GOP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The present disclosure relates to an encoding method, apparatus, storage medium, and electronic device, the encoding method by obtaining data to be encoded from a video image to be encoded; determining the pixel bit number and the quantization parameter corresponding to the data to be encoded according to the code rate control parameter input by the user; under the condition that the coding mode corresponding to the data to be coded is determined to be a target coding mode according to the pixel bit number and the quantization parameter, obtaining the to-be-determined quantization parameter, the time domain texture value and the space domain texture value corresponding to each coding unit in the data to be coded; the undetermined quantization parameters of the coding units are adjusted according to the time domain texture value and the space domain texture value of each coding unit to obtain the target quantization parameters corresponding to each coding unit, so that more reasonable quantization parameters can be provided according to different video image contents, the code rate distributed to each coding unit can be reasonably controlled, and the quality of the video images displayed in the video conference can be effectively improved.

Description

Encoding method, encoding device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of video image coding, and in particular, to a coding method, an apparatus, a storage medium, and an electronic device.
Background
Video coding and decoding technology aims to compress collected video signals into data in different standard formats so as to facilitate transmission or storage. In the video compression process, the size and quality of a compressed video frame are related to parameters selected by an encoder in the encoding process, for example, a frame class (I/P/B frame), motion information, a Quantization Parameter (QP), and the like, wherein the Quantization Parameter controls the size of data loss in a lossy Quantization process, and can reflect the spatial detail compression condition, the smaller the Quantization Parameter setting, the more the image details are retained, the larger the code rate required by video transmission, the larger the Quantization Parameter setting, the more the details are lost, the lower the code rate required by video transmission, but the image distortion is enhanced, and the image quality is reduced.
In the related art, when the quantization parameter is set, the video image content is generally not considered, more reasonable quantization parameters cannot be given for different video contents, and the improvement of the video quality is not facilitated under the condition that the code rate required by video transmission is not changed.
Disclosure of Invention
The purpose of the present disclosure is to provide an encoding method, apparatus, storage medium, and electronic device.
To achieve the above object, a first aspect of the present disclosure provides an encoding method, the method including:
acquiring data to be coded from a video image to be coded;
determining the pixel bit number and the quantization parameter corresponding to the data to be encoded according to a code rate control parameter input by a user;
under the condition that the coding mode corresponding to the data to be coded is determined to be a target coding mode according to the pixel bit number and the quantization parameter, obtaining the to-be-determined quantization parameter, the time domain texture value and the space domain texture value corresponding to each coding unit in the data to be coded;
adjusting undetermined quantization parameters of each coding unit according to the time domain texture value and the space domain texture value of each coding unit to obtain target quantization parameters corresponding to each coding unit;
and coding the data to be coded according to the target quantization parameter corresponding to each coding unit.
Optionally, the obtaining of data to be encoded from a video image to be encoded includes:
under the condition that the preset coding level is GOP level coding, acquiring to-be-coded data taking GOP as a unit from a video image to be coded;
under the condition that the preset coding level is frame-level coding, acquiring the data to be coded with a frame as a unit from a video image to be coded;
in the case where the preset encoding level is line-level encoding, the data to be encoded in units of lines is acquired from the video image to be encoded.
Optionally, the code rate control parameter includes a resolution, the data to be encoded is a GOP image when a preset encoding level is GOP level encoding, and the determining the number of pixel bits corresponding to the data to be encoded according to the code rate control parameter input by the user includes:
acquiring a target bit number corresponding to a first frame image in the GOP image;
and acquiring the ratio of the target bit number to the resolution ratio to obtain the pixel bit number corresponding to the data to be encoded.
Optionally, the determining, according to a code rate control parameter input by a user, a quantization parameter corresponding to the data to be encoded includes:
and obtaining a quantization parameter corresponding to the data to be coded according to the code rate control parameter by a preset frame-level code rate control algorithm.
Optionally, the determining, according to the pixel bit number and the quantization parameter, that the coding mode corresponding to the data to be coded is a target coding mode includes:
and determining the coding mode as the target coding mode under the condition that the pixel bit number is less than or equal to a preset pixel bit number threshold and the quantization parameter is greater than a preset quantization parameter threshold.
Optionally, the obtaining a time domain texture value corresponding to each coding unit in the data to be coded includes:
acquiring the brightness average absolute error value of each coding unit in the data to be coded and a co-located coding unit of a time domain frame, wherein the time domain frame is a frame before a frame where the coding unit is located or a preset reference frame;
and taking the brightness average absolute error value as the time domain texture value.
Optionally, the obtaining the spatial texture value corresponding to each coding unit in the data to be coded includes:
acquiring a gradient value corresponding to each coding unit;
and determining the gradient value corresponding to each coding unit as the spatial texture value.
Optionally, the adjusting the to-be-determined quantization parameter of the coding unit according to the time domain texture value and the space domain texture value to obtain a target quantization parameter corresponding to the coding unit includes:
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the space domain texture value is larger than a space domain texture threshold value, adjusting the parameter to be quantized in a first preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the spatial domain texture value is smaller than or equal to the spatial domain texture threshold value, adjusting the to-be-determined quantization parameter in a second preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is larger than the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a third preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is smaller than or equal to the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a fourth preset adjusting mode to obtain the target quantization parameter;
the first preset adjustment mode, the second preset adjustment mode, the third preset adjustment mode and the fourth preset adjustment mode are the same or different.
Optionally, the method further comprises:
and determining the to-be-determined quantization parameter corresponding to the current coding unit through a preset coding unit level code rate control algorithm according to the code rate control parameter.
Optionally, the first preset adjustment manner and the fourth preset adjustment manner are:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, adding a first preset offset value on the basis of the to-be-determined quantization parameter; if the undetermined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, adding a second preset offset value on the basis of the undetermined quantization parameter to obtain the target quantization parameter, wherein the first preset offset value is larger than the second preset offset value;
the second preset adjustment mode and the third preset adjustment mode are as follows:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, reducing a second preset offset value on the basis of the to-be-determined quantization parameter; and if the to-be-determined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, reducing a first preset offset value on the basis of the to-be-determined quantization parameter.
Optionally, before the encoding the data to be encoded according to the target quantization parameter corresponding to each encoding unit, the method further includes:
acquiring a first quantization parameter value and a second quantization parameter value corresponding to each coding unit, wherein the first quantization parameter value is a quantization parameter value actually coded by a time domain co-located coding unit corresponding to each coding unit, and the second quantization parameter value is an actual coding quantization parameter value of a last coded coding unit in a frame where the coding unit is located;
generating a first limit interval according to the first quantization parameter value, a first preset upper limit offset and a first preset lower limit offset;
generating a second limit interval according to the second quantization parameter value, a second preset upper limit offset and a second preset lower limit offset;
generating a third limiting interval according to the frame level quantization parameter of the frame where the coding unit is located, a third preset upper limit offset and a third preset lower limit offset;
limiting the target quantization parameter according to the first limiting interval, the second limiting interval and the third limiting interval to obtain a limited target quantization parameter;
correspondingly, the encoding the data to be encoded according to the target quantization parameter corresponding to each encoding unit includes:
and coding the data to be coded according to the target quantization parameter which is subjected to the limitation processing and corresponds to each coding unit.
Optionally, the limiting the target quantization parameter according to the first limiting interval, the second limiting interval, and the third limiting interval to obtain a limited target quantization parameter includes:
and limiting the target quantization parameter according to the preset priorities corresponding to the first limiting interval, the second limiting interval and the third limiting interval.
Optionally, when the priority of the first restriction interval is higher than the priority of the second restriction interval, and the priority of the second restriction interval is higher than the priority of the third restriction interval, the restricting the target quantization parameter according to the preset priority corresponding to the first restriction interval, the second restriction interval, and the third restriction interval includes:
performing data processing on the target quantization parameter according to the first limit interval and a preset limit rule to obtain an updated target quantization parameter;
performing data processing on the current target quantization parameter according to the second limiting interval and the preset limiting rule to obtain an updated target quantization parameter;
and performing data processing on the current updated target quantization parameter according to the third limiting interval and the preset limiting rule to obtain the target quantization parameter subjected to limiting processing.
Optionally, the preset restriction rule is:
under the condition that the target quantization parameter is determined to be located in the current limit interval, taking the target quantization parameter as an updated target quantization parameter, and under the condition that the target quantization parameter is determined to be smaller than the lower limit value of the current limit interval, taking the lower limit value of the current limit interval as the updated target quantization parameter; under the condition that the target quantization parameter is determined to be larger than the upper limit value of the current limiting interval, taking the upper limit value of the current limiting interval as the updated target quantization parameter;
the current limiting interval is any one of a first limiting interval, a second limiting interval and a third limiting interval.
In a second aspect of the present disclosure, there is provided an encoding apparatus, the apparatus comprising:
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is configured to acquire data to be encoded from a video image to be encoded;
the first determining module is configured to determine the pixel bit number and the quantization parameter corresponding to the data to be encoded according to a code rate control parameter input by a user;
the second determining module is configured to acquire the to-be-determined quantization parameter, the time domain texture value and the spatial domain texture value corresponding to each coding unit in the to-be-coded data under the condition that the coding mode corresponding to the to-be-coded data is determined to be a target coding mode according to the pixel bit number and the quantization parameter;
the adjusting module is configured to adjust the undetermined quantization parameter of each coding unit according to the time domain texture value and the space domain texture value of the coding unit to obtain a target quantization parameter corresponding to each coding unit;
and the coding module is configured to code the data to be coded according to the target quantization parameter corresponding to each coding unit.
Optionally, the first obtaining module is configured to:
under the condition that the preset coding level is GOP (Group of picture) level coding, acquiring data to be coded with GOP as a unit from a video image to be coded;
under the condition that the preset coding level is frame-level coding, acquiring the data to be coded with a frame as a unit from a video image to be coded;
in the case where the preset encoding level is line-level encoding, the data to be encoded in units of lines is acquired from the video image to be encoded.
Optionally, the rate control parameter includes a resolution, and in a case that a preset encoding level is GOP level encoding, the data to be encoded is a GOP picture, and the first determining module is configured to:
acquiring a target bit number corresponding to a first frame image in the GOP image;
and acquiring the ratio of the target bit number to the resolution ratio to obtain the pixel bit number corresponding to the data to be encoded.
Optionally, the first determining module is configured to:
and obtaining a quantization parameter corresponding to the data to be coded according to the code rate control parameter by a preset frame-level code rate control algorithm.
Optionally, the second determining module is configured to:
and determining the coding mode as the target coding mode under the condition that the pixel bit number is less than or equal to a preset pixel bit number threshold and the quantization parameter is greater than a preset quantization parameter threshold.
Optionally, the obtaining a time domain texture value corresponding to each coding unit in the data to be coded includes:
acquiring the brightness average absolute error value of each coding unit in the data to be coded and a co-located coding unit of a time domain frame, wherein the time domain frame is a frame before a frame where the coding unit is located or a preset reference frame;
and taking the brightness average absolute error value as the time domain texture value.
Optionally, the second determining module is configured to:
acquiring a gradient value corresponding to each coding unit;
and determining the gradient value corresponding to each coding unit as the spatial texture value.
Optionally, the adjusting module is configured to:
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the space domain texture value is larger than a space domain texture threshold value, adjusting the parameter to be quantized in a first preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the spatial domain texture value is smaller than or equal to the spatial domain texture threshold value, adjusting the to-be-determined quantization parameter in a second preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is larger than the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a third preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is smaller than or equal to the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a fourth preset adjusting mode to obtain the target quantization parameter;
the first preset adjustment mode, the second preset adjustment mode, the third preset adjustment mode and the fourth preset adjustment mode are the same or different.
Optionally, the apparatus further comprises:
and the third determining module is configured to determine the to-be-determined quantization parameter corresponding to the current coding unit through a preset coding unit level code rate control algorithm according to the code rate control parameter.
Optionally, the first preset adjustment manner and the fourth preset adjustment manner are:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, adding a first preset offset value on the basis of the to-be-determined quantization parameter; if the undetermined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, adding a second preset offset value on the basis of the undetermined quantization parameter to obtain the target quantization parameter, wherein the first preset offset value is larger than the second preset offset value;
the second preset adjustment mode and the third preset adjustment mode are as follows:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, reducing a second preset offset value on the basis of the to-be-determined quantization parameter; and if the to-be-determined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, reducing a first preset offset value on the basis of the to-be-determined quantization parameter.
Optionally, the apparatus further comprises:
a second obtaining module, configured to obtain a first quantization parameter value and a second quantization parameter value corresponding to each coding unit, where the first quantization parameter value is a quantization parameter value actually encoded by a time-domain co-located coding unit corresponding to each coding unit, and the second quantization parameter value is an actual encoding quantization parameter value of a last encoded coding unit in a frame where the coding unit is located;
a first generating module configured to generate a first limit interval according to the first quantization parameter value and a first preset upper limit offset and a first preset lower limit offset;
a second generating module configured to generate a second limit interval according to the second quantization parameter value and a second preset upper limit offset and a second preset lower limit offset;
a third generating module configured to generate a third limiting interval according to the frame-level quantization parameter of the frame where the coding unit is located, and a third preset upper limit offset and a third preset lower limit offset;
a limiting module configured to limit the target quantization parameter according to the first limiting interval, the second limiting interval and the third limiting interval to obtain a limited target quantization parameter;
accordingly, the encoding module is configured to:
and coding the data to be coded according to the target quantization parameter which is subjected to the limitation processing and corresponds to each coding unit.
Optionally, the restriction module is configured to:
and limiting the target quantization parameter according to the preset priorities corresponding to the first limiting interval, the second limiting interval and the third limiting interval.
Optionally, in a case where the priority of the first restriction interval is higher than the priority of the second restriction interval, and the priority of the second restriction interval is higher than the priority of the third restriction interval, the restriction module is configured to:
performing data processing on the target quantization parameter according to the first limit interval and a preset limit rule to obtain an updated target quantization parameter;
performing data processing on the current target quantization parameter according to the second limiting interval and the preset limiting rule to obtain an updated target quantization parameter;
and performing data processing on the current updated target quantization parameter according to the third limiting interval and the preset limiting rule to obtain the target quantization parameter subjected to limiting processing.
Optionally, the preset restriction rule is:
under the condition that the target quantization parameter is determined to be located in the current limit interval, taking the target quantization parameter as an updated target quantization parameter, and under the condition that the target quantization parameter is determined to be smaller than the lower limit value of the current limit interval, taking the lower limit value of the current limit interval as the updated target quantization parameter; under the condition that the target quantization parameter is determined to be larger than the upper limit value of the current limiting interval, taking the upper limit value of the current limiting interval as the updated target quantization parameter;
the current limiting interval is any one of a first limiting interval, a second limiting interval and a third limiting interval.
In a third aspect of the present disclosure there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the method as set forth in the first aspect above.
In a fourth aspect of the present disclosure, there is provided an electronic device comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of the first aspect above.
According to the technical scheme, code rate control parameters input by a user are obtained; acquiring data to be coded from a video image to be coded; determining the pixel bit number and the quantization parameter corresponding to the data to be encoded according to the code rate control parameter; under the condition that the coding mode corresponding to the data to be coded is determined to be a target coding mode according to the pixel bit number and the quantization parameter, obtaining the to-be-determined quantization parameter, the time domain texture value and the space domain texture value corresponding to each coding unit in the data to be coded; adjusting undetermined quantization parameters of each coding unit according to the time domain texture value and the space domain texture value of each coding unit to obtain target quantization parameters corresponding to each coding unit; and coding the data to be coded according to the target quantization parameter corresponding to each coding unit. Therefore, the undetermined quantization parameter of each coding unit can be adjusted according to the time domain texture value and the space domain texture value of each coding unit to obtain the target quantization parameter corresponding to each coding unit, more reasonable quantization parameters can be given, the code rate distributed to each coding unit can be reasonably controlled, and the quality of the video image displayed in the video conference can be effectively improved under the condition that the video transmission code rate is not changed.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
fig. 1 is a flow chart illustrating an encoding method according to an exemplary embodiment of the present disclosure;
FIG. 2 is a flow chart of an encoding method shown in the embodiment of FIG. 1 according to the present disclosure;
fig. 3 is a block diagram of an encoding apparatus shown in an exemplary embodiment of the present disclosure;
FIG. 4 is a block diagram of an encoding device shown in the embodiment of FIG. 3 according to the present disclosure;
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
Before describing the specific embodiments of the present disclosure, the following description is first made on an application scenario of the present disclosure, and the present disclosure may be applied to an encoding process of a video image, and the video image can be compressed into data of different standard formats through video encoding, so as to be convenient for transmission or storage. In the process of video compression, the size of the selected quantization parameter is in negative correlation with the code rate required by video transmission and in positive correlation with the distortion degree of the image, that is, the size of the selected quantization parameter directly affects the code rate required by video transmission and the quality of later-stage video playing.
The inventor finds that, in the related art, when the quantization parameter is set, the quantization parameter of each coding unit cannot be adjusted according to different video contents, and the quantization parameter of each coding unit cannot be controlled more finely, so that the code rate cannot be allocated more reasonably, which is not beneficial to improving the video quality under the condition of ensuring the code rate required by video transmission.
In order to solve the above technical problems, the present disclosure provides an encoding method, an encoding device, a storage medium, and an electronic device, where the encoding method classifies an encoding mode of to-be-encoded data by a pixel bit number and a quantization parameter of the to-be-encoded data, adjusts a to-be-encoded parameter of each encoding unit according to a time domain texture value and a space domain texture value of each encoding unit in the to-be-encoded data when the encoding mode is determined to be a target encoding mode, so as to obtain a target quantization parameter corresponding to each encoding unit, and then encodes the to-be-encoded data according to the target quantization parameter corresponding to each encoding unit, so that a more reasonable quantization parameter can be given according to a content of each frame of image, which is beneficial to reasonably controlling a code rate allocated to each encoding unit, thereby ensuring that a video transmission code rate is not changed, the quality of the video image displayed in the video conference is effectively improved.
The present disclosure is illustrated below with reference to specific examples.
Fig. 1 is a flow chart illustrating an encoding method according to an exemplary embodiment of the present disclosure; referring to fig. 1, the method may include the steps of:
step 101, acquiring data to be encoded from a video image to be encoded.
One possible implementation manner in this step is: under the condition that the preset coding level is GOP level coding, acquiring to-be-coded data taking GOP as a unit from a video image to be coded; under the condition that the preset coding level is frame-level coding, acquiring the data to be coded with a frame as a unit from a video image to be coded; in the case where the preset encoding level is line-level encoding, the data to be encoded in units of lines is acquired from the video image to be encoded.
And step 102, determining the pixel bit number and the quantization parameter corresponding to the data to be encoded according to the code rate control parameter input by the user.
The rate control parameter may include a target rate, a frame rate, and a resolution. It should be noted that, before the obtaining of the data to be encoded from the video image to be encoded in step 101, the rate control parameter input by the user may be obtained through a preset interface (e.g., a preset text input box), so that the entire encoding process is encoded according to the rate control parameter.
In this step, the implementation manner of obtaining the quantization parameter corresponding to the data to be encoded is as follows: and obtaining a quantization parameter corresponding to the data to be coded according to the code rate control parameter through a preset frame-level code rate control algorithm. The preset frame-level rate control algorithm may be: any one of The frame-level rate control algorithms in h.264/AVC (Advanced Video Coding), h.265/HEVC (High Efficiency Video Coding), VP8 (Open and royalty-free Video compression format), VP9 (The WebM Project's next-generation Video codec, Open media Alliance Video Coding standard), AV1 (architecture for Open media Video codec 1.0; Open media Alliance Video Coding standard), and may also be other frame-level rate control algorithms in The prior art, which are not described herein again.
In addition, in the case where the data to be encoded is encoded data in units of GOPs, the data to be encoded is a GOP image, and the number of pixel bits corresponding to the data to be encoded can be obtained by: acquiring a target bit number corresponding to a first frame image in the GOP image; and acquiring the ratio of the target bit number to the resolution ratio to obtain the pixel bit number corresponding to the data to be encoded.
Illustratively, the first frame of pictures of the GOP picture is an I-frame, and the corresponding bit number of the I-frame, i.e. the target bit number, is
Figure 369802DEST_PATH_IMAGE001
The GOP picture corresponds to a resolution of
Figure 492610DEST_PATH_IMAGE002
Then, the number of pixel bits corresponding to the data to be encoded is:
Figure 891230DEST_PATH_IMAGE003
when the data to be encoded is encoded data in units of frames, a method for calculating the number of pixel bits corresponding to the data to be encoded is as follows: acquiring the bit number of a current frame image in the data to be encoded, acquiring a first ratio of the bit number of the current frame image to the resolution of the current frame image, and determining the first ratio as the pixel bit number corresponding to the data to be encoded.
When the data to be encoded is the encoded data in a row unit, the method for calculating the number of pixel bits corresponding to the data to be encoded is as follows: acquiring the bit number of the current line image in the data to be encoded, acquiring a second ratio of the bit number of the current line image to the width of the current line image, and determining the second ratio as the pixel bit number corresponding to the data to be encoded.
103, under the condition that the coding mode corresponding to the data to be coded is determined to be the target coding mode according to the pixel bit number and the quantization parameter, obtaining the to-be-determined quantization parameter, the time domain texture value and the space domain texture value corresponding to each coding unit in the data to be coded.
And determining the coding mode as the target coding mode under the condition that the pixel bit number is less than or equal to a preset pixel bit number threshold and the quantization parameter is greater than a preset quantization parameter threshold, wherein the target code rate mode can be a low code rate coding mode.
Illustratively, the number of pixel bits of the data to be encoded is used
Figure 960949DEST_PATH_IMAGE004
For representing, quantizing parameters
Figure 128625DEST_PATH_IMAGE005
Is shown in determining
Figure 140443DEST_PATH_IMAGE006
And is and
Figure 449196DEST_PATH_IMAGE007
under the condition that the code mode of the data to be coded is determined to be a high code rate coding mode, and the code mode is determined
Figure 837452DEST_PATH_IMAGE008
And is and
Figure 594055DEST_PATH_IMAGE009
in case of (2), determining the encoding mode of the data to be encoded to be a low rate encoding mode (i.e. the target encoding mode), wherein,
Figure 58666DEST_PATH_IMAGE010
to preset pixel bit number threshold value, the
Figure 431878DEST_PATH_IMAGE011
Is a preset quantization parameter threshold.
In this step, the to-be-determined quantization parameter corresponding to the coding unit may be obtained in the following manner: and determining the undetermined quantization parameter corresponding to the current coding unit through a preset coding unit level code rate control algorithm according to the code rate control parameter, wherein the preset coding unit level code rate control algorithm can be a preset coding unit level code rate control algorithm in any one of H.264/AVC, H.265/HEVC, VP8, VP9 and AV1, and can also be other preset coding unit level code rate control algorithms in the prior art, and details of the disclosure are omitted here.
The obtaining mode of the time domain texture value corresponding to the coding unit may be: acquiring the average absolute error value of the brightness of each coding unit in the data to be coded and a co-located coding unit of a time domain frame, wherein the time domain frame is a frame before a frame where the coding unit is located or a preset reference frame; and taking the brightness average absolute error value as the time domain texture value. Wherein the mean absolute error value of brightness (
Figure 843399DEST_PATH_IMAGE012
) The calculation formula of (2) is as follows:
Figure 923351DEST_PATH_IMAGE013
wherein,
Figure 339289DEST_PATH_IMAGE014
respectively a current coding unit and a time domain co-located coding unit corresponding to the current coding unit
Figure 622634DEST_PATH_IMAGE015
The luminance component pixel value at the coordinate position, M is the number of pixel blocks in the width of the coding unit, and N is the number of pixel blocks in the length of the coding unit.
The spatial texture value corresponding to the coding unit may be obtained by: acquiring a gradient value corresponding to each coding unit; and determining the gradient value corresponding to each coding unit as the spatial texture value. Wherein, the gradient value (G) corresponding to the coding unit is calculated according to the following formula:
Figure 883851DEST_PATH_IMAGE016
wherein, the
Figure 365779DEST_PATH_IMAGE017
For the current coding unit in
Figure 890301DEST_PATH_IMAGE018
The luminance component pixel value at the coordinate position, where M is the number of pixel blocks in the width of the coding unit and N is the number of pixel blocks in the length of the coding unit.
And 104, adjusting undetermined quantization parameters of each coding unit according to the time domain texture value and the space domain texture value of each coding unit to obtain a target quantization parameter corresponding to each coding unit.
One possible implementation of this step includes:
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the space domain texture value is larger than a space domain texture threshold value, adjusting the parameter to be quantized in a first preset adjusting mode to obtain the target quantization parameter;
when the time domain texture value is larger than a preset time domain texture threshold value and the space domain texture value is smaller than or equal to the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a second preset adjusting mode to obtain the target quantization parameter;
when the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is larger than the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a third preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is smaller than or equal to the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a fourth preset adjusting mode to obtain the target quantization parameter;
the first preset adjustment mode, the second preset adjustment mode, the third preset adjustment mode and the fourth preset adjustment mode are the same or different.
By way of example, will
Figure 972526DEST_PATH_IMAGE019
Is defined as class 1, will
Figure 725850DEST_PATH_IMAGE020
The coding unit of (2) is defined as class 2,
Figure 780394DEST_PATH_IMAGE021
is defined as class 3, will
Figure 538134DEST_PATH_IMAGE022
Is defined as category 4, and the corresponding undetermined quantization parameter of the coding unit is determined according to the adjustment mode shown in the following table 1
Figure 518773DEST_PATH_IMAGE023
On the basis of the target quantization parameter, to obtain the target quantization parameter:
Figure 387372DEST_PATH_IMAGE024
TABLE 1
Wherein,
Figure 296422DEST_PATH_IMAGE005
is the current compilationThe quantization parameter corresponding to the frame in which the code unit is located,offset1is a first predetermined offset value for the first predetermined offset value,offset2for the second preset offset value, the offset value is set,offset3is the third preset offset value and is,offset4for the fourth preset offset value, the offset value is set,offset1 > offset2offset3 > offset4the first preset deviation value, the second preset deviation value, the third preset deviation value and the fourth preset deviation value can be preset according to actual situation requirements.
Optionally, the first preset adjustment manner and the fourth preset adjustment manner are:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, adding a first preset offset value on the basis of the to-be-determined quantization parameter; if the undetermined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, adding a second preset deviation value on the basis of the undetermined quantization parameter to obtain the target quantization parameter, wherein the first preset deviation value is larger than the second preset deviation value;
the second preset adjustment mode and the third preset adjustment mode are as follows:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, reducing a second preset offset value on the basis of the to-be-determined quantization parameter; and if the to-be-determined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, reducing a first preset offset value on the basis of the to-be-determined quantization parameter.
Illustratively, still taking the above table 1 as an example, in this table 1, thisoffset1Can be equal tooffset3The product isoffset2Can be equal tooffset4
And 105, encoding the data to be encoded according to the target quantization parameter corresponding to each encoding unit.
In this step, when each coding unit in the data to be coded is coded, the to-be-determined quantization parameter of the coding unit is adjusted according to the method shown in the above steps 101 to 104 to obtain a more reasonable target quantization parameter, and the coding unit is coded according to the target quantization parameter until all coding units in the whole data to be coded are completed.
According to the technical scheme, the undetermined quantization parameter of each coding unit can be adjusted according to the time domain texture value and the space domain texture value of each coding unit so as to obtain the target quantization parameter corresponding to each coding unit, more reasonable quantization parameters can be given, the code rate distributed to each coding unit can be reasonably controlled, and the video quality can be effectively improved.
FIG. 2 is a flow chart of an encoding method shown in the embodiment of FIG. 1 according to the present disclosure; referring to fig. 2, before encoding the data to be encoded according to the target quantization parameter corresponding to each coding unit in step 105 shown in fig. 1, the method may further include the following steps:
and 106, acquiring a first quantization parameter value and a second quantization parameter value corresponding to each coding unit.
The first quantization parameter value is a quantization parameter value actually encoded by a time-domain co-located encoding unit corresponding to each encoding unit, and the second quantization parameter value is an actual encoding quantization parameter value of a last encoded encoding unit in a frame where the encoding unit is located.
Step 107, generating a first limiting interval according to the first quantization parameter value, the first preset upper limit offset and the first preset lower limit offset.
Illustratively, the first quantization parameter value is used
Figure 506955DEST_PATH_IMAGE025
It means that, when the first preset upper limit offset is 4 and the first preset lower limit offset is-6, the first limitation interval is:
Figure 48926DEST_PATH_IMAGE026
it should be noted that the specific data in the above example are only used to illustrate how to obtain the first limitation interval, and are not used to limit the specific protection scope.
And 108, generating a second limit interval according to the second quantization parameter value, the second preset upper limit offset and the second preset lower limit offset.
Exemplarily, the second quantization parameter value is used
Figure 190057DEST_PATH_IMAGE027
It means that, when the second preset upper limit offset is 4 and the second preset lower limit offset is-4, the second limitation interval is:
Figure 845292DEST_PATH_IMAGE028
it should be noted that, when the current coding unit is the first coding unit of the current frame, the second quantization parameter value does not exist, and the second limitation interval is empty at this time. In addition, it should be noted that the specific data in the above example are only used for illustrating how to obtain the first limitation interval, and are not used for limiting the specific protection scope.
Step 109, a third constraint interval is generated according to the frame level quantization parameter of the frame where the coding unit is located, the third preset upper limit offset and the third preset lower limit offset.
Illustratively, the values of the quantization parameters are used at the frame level
Figure 679255DEST_PATH_IMAGE029
It means that, when the third preset upper limit offset is 4 and the second preset lower limit offset is-6, the third limitation interval is:
Figure 161052DEST_PATH_IMAGE030
it should be noted that the specific data in the above example are only used to illustrate how to obtain the first limitation interval, and are not used to limit the specific protection scope.
Step 110, limiting the target quantization parameter according to the first limiting interval, the second limiting interval and the third limiting interval to obtain a limited target quantization parameter.
The target quantization parameter may be limited according to a preset priority corresponding to the first limitation interval, the second limitation interval, and the third limitation interval.
In a possible implementation manner, if the priority of the first limitation interval is higher than the priority of the second limitation interval, and the priority of the second limitation interval is higher than the priority of the third limitation interval, the target quantization parameter may be subjected to data processing according to a preset limitation rule in the first limitation interval to obtain an updated target quantization parameter; then, according to the second limit interval and the preset limit rule, carrying out data processing on the current target quantization parameter to obtain an updated target quantization parameter; and performing data processing on the current updated target quantization parameter according to the preset limiting rule in the third limiting interval to obtain the target quantization parameter subjected to limiting processing.
In the above embodiment, the preset restriction rule may be:
taking the target quantization parameter as an updated target quantization parameter under the condition that the target quantization parameter is determined to be positioned in the current limit interval, and taking the lower limit value of the current limit interval as the updated target quantization parameter under the condition that the target quantization parameter is determined to be smaller than the lower limit value of the current limit interval; under the condition that the target quantization parameter is determined to be larger than the upper limit value of the current limiting interval, taking the upper limit value of the current limiting interval as the updated target quantization parameter; wherein the current limitation interval is any one of a first limitation interval, a second limitation interval and a third limitation interval.
It should be noted that, after the target quantization parameter after the limiting processing is obtained, the data to be encoded may be encoded according to the target quantization parameter after the limiting processing corresponding to each encoding unit.
Illustratively, when a 1080P video is coded, a target code rate of 4096kbps is controlled by an average code rate, the coding is performed under the setting that a Frame Per Second (FPS) is 25, other coding settings are set as default settings, Frame-level coding control is performed, that is, a preset coding level is set as Frame-level coding, coded data of one Frame is obtained from an image to be coded each time to be used as the coded data, and the code rate control is performed through the preset Frame levelThe method calculates quantization parameters corresponding to the data to be encoded, wherein the preset frame-level code rate control method may be a code rate control method default to an encoder, such as a corresponding frame-level code rate control method in a software encoder x264 and the like. When the current data to be coded is the second frame P frame in the image to be coded, the frame-level quantization parameter of the second frame P frame, namely the quantization parameter corresponding to the data to be coded can be calculated through the process
Figure 122186DEST_PATH_IMAGE031
= 32; the pixel bit number Bpp corresponding to the P frame is obtained by the following formula:
Figure 740249DEST_PATH_IMAGE032
obtaining the quantization parameter of the data to be encoded
Figure 761426DEST_PATH_IMAGE033
And the number of pixel bits Bpp, according to the quantization parameter
Figure 730519DEST_PATH_IMAGE034
And the pixel bit number Bpp determines the coding mode for coding the data to be coded, if the pixel bit number threshold is preset
Figure 416715DEST_PATH_IMAGE035
Presetting a quantization parameter threshold
Figure 702334DEST_PATH_IMAGE036
Due to that
Figure 878101DEST_PATH_IMAGE037
I.e. by
Figure 334490DEST_PATH_IMAGE038
The product is
Figure 575109DEST_PATH_IMAGE039
That is to say that
Figure 230082DEST_PATH_IMAGE040
Therefore, the coding mode corresponding to the current data to be coded is a low-code-rate coding mode, i.e. a target coding mode; after the coding mode is determined, code rate control needs to be performed at the level of the coding units, that is, each to-be-coded data is subjected to finer division coding, that is, the to-be-coded data is divided into one coding unit, and to-be-determined quantization parameters corresponding to each coding unit are obtained
Figure 45591DEST_PATH_IMAGE041
If the current coding unit corresponds to
Figure 474429DEST_PATH_IMAGE042
Calculating to obtain the time domain texture value corresponding to the current coding unit
Figure 564745DEST_PATH_IMAGE043
Spatial texture value
Figure 277486DEST_PATH_IMAGE044
According to a preset empirical threshold
Figure 749050DEST_PATH_IMAGE045
I.e., the preset temporal texture threshold is 0.5,
Figure 180031DEST_PATH_IMAGE046
if the preset spatial texture value is 10, it is determined that the temporal texture value corresponding to the current coding unit is greater than the preset temporal texture threshold value, and the spatial texture value is greater than the spatial texture threshold value, the corresponding quantization parameter adjustment mode is the first preset adjustment mode, and still taking table 1 as an example, the to-be-determined quantization parameter is adjusted
Figure 74038DEST_PATH_IMAGE041
Is adjusted in a manner that
Figure 392018DEST_PATH_IMAGE047
According to the preset first preset offset value offset1=4,the second predetermined offset value offset2=2, and the target quantization parameter is obtained as
Figure 283751DEST_PATH_IMAGE048
And finally, acquiring a first limit interval as follows:
Figure 202028DEST_PATH_IMAGE049
the second limitation interval is:
Figure 384879DEST_PATH_IMAGE050
the third limitation interval is:
Figure 72212DEST_PATH_IMAGE051
if, if
Figure 134846DEST_PATH_IMAGE052
And the current coding unit is the first coding unit of the P frame of the second frame, therefore
Figure 274840DEST_PATH_IMAGE053
The second limitation section is empty, and thus the second limitation section does not exist, the first limitation section and the third limitation section
Figure 526961DEST_PATH_IMAGE054
If the priority of the first limitation interval is higher than that of the third limitation interval, the target quantization parameter is limited through the first limitation interval, and then limited through the third limitation interval, and since 37 does not belong to the first limitation interval, the target quantization parameter updated through the first limitation interval is 36, and since 36 belongs to the third limitation interval, the target quantization parameter after being limited is 36. In this way, the quantization parameter of each coding unit is adjusted to obtain the target quantization parameter, and the current P frame image is coded according to the quantization parameter until the coding of the image to be coded is completed.
According to the technical scheme, the target quantization parameter after adjustment is limited, so that the quantization parameter is adjusted on the whole of the data to be encoded, the image quality is guaranteed on the whole, and the image quality displayed in the video conference process can be improved.
Fig. 3 is a block diagram of an encoding apparatus shown in an exemplary embodiment of the present disclosure; referring to fig. 3, the apparatus may include:
a first obtaining module 301 configured to obtain data to be encoded from a video image to be encoded;
a first determining module 302, configured to determine, according to a code rate control parameter input by a user, a pixel bit number and a quantization parameter corresponding to the data to be encoded;
a second determining module 303, configured to, when it is determined that the coding mode corresponding to the to-be-coded data is the target coding mode according to the number of bits of the pixel and the quantization parameter, obtain a to-be-determined quantization parameter, a time domain texture value, and a space domain texture value corresponding to each coding unit in the to-be-coded data;
an adjusting module 304, configured to adjust the to-be-determined quantization parameter of each coding unit according to the time domain texture value and the space domain texture value of the coding unit, so as to obtain a target quantization parameter corresponding to each coding unit;
and an encoding module 305 configured to encode the data to be encoded according to the target quantization parameter corresponding to each encoding unit.
According to the technical scheme, the undetermined quantization parameter of each coding unit can be adjusted according to the time domain texture value and the space domain texture value of each coding unit so as to obtain the target quantization parameter corresponding to each coding unit, more reasonable quantization parameters can be given, the code rate distributed to each coding unit can be reasonably controlled, and the video quality can be effectively improved.
Optionally, the first obtaining module 301 is configured to:
under the condition that the preset coding level is GOP level coding, acquiring to-be-coded data taking GOP as a unit from a video image to be coded;
under the condition that the preset coding level is frame-level coding, acquiring the data to be coded with a frame as a unit from a video image to be coded;
in the case where the preset encoding level is line-level encoding, the data to be encoded in units of lines is acquired from the video image to be encoded.
Optionally, the rate control parameter includes a resolution, and in a case that the preset encoding level is GOP level encoding, the data to be encoded is a GOP picture, and the first determining module is configured to:
acquiring a target bit number corresponding to a first frame image in the GOP image;
and acquiring the ratio of the target bit number to the resolution ratio to obtain the pixel bit number corresponding to the data to be encoded.
Optionally, the first determining module 302 is configured to:
and obtaining a quantization parameter corresponding to the data to be coded according to the code rate control parameter through a preset frame-level code rate control algorithm.
Optionally, the second determining module 303 is configured to:
and determining the coding mode as the target coding mode under the condition that the pixel bit number is less than or equal to a preset pixel bit number threshold and the quantization parameter is greater than a preset quantization parameter threshold.
Optionally, the obtaining the time domain texture value corresponding to each coding unit in the data to be coded includes:
acquiring the average absolute error value of the brightness of each coding unit in the data to be coded and a co-located coding unit of a time domain frame, wherein the time domain frame is a frame before a frame where the coding unit is located or a preset reference frame;
and taking the brightness average absolute error value as the time domain texture value.
Optionally, the second determining module 303 is configured to:
acquiring a gradient value corresponding to each coding unit;
and determining the gradient value corresponding to each coding unit as the spatial texture value.
Optionally, the adjusting module 304 is configured to:
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the space domain texture value is larger than a space domain texture threshold value, adjusting the parameter to be quantized in a first preset adjusting mode to obtain the target quantization parameter;
when the time domain texture value is larger than a preset time domain texture threshold value and the space domain texture value is smaller than or equal to the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a second preset adjusting mode to obtain the target quantization parameter;
when the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is larger than the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a third preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is smaller than or equal to the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a fourth preset adjusting mode to obtain the target quantization parameter;
the first preset adjustment mode, the second preset adjustment mode, the third preset adjustment mode and the fourth preset adjustment mode are the same or different.
FIG. 4 is a block diagram of an encoding device shown in the embodiment of FIG. 3 according to the present disclosure; referring to fig. 4, the apparatus may include:
a third determining module 306, configured to determine, according to the code rate control parameter, a to-be-determined quantization parameter corresponding to the current coding unit through a preset coding unit-level code rate control algorithm.
Optionally, the first preset adjustment manner and the fourth preset adjustment manner are:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, adding a first preset offset value on the basis of the to-be-determined quantization parameter; if the undetermined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, adding a second preset deviation value on the basis of the undetermined quantization parameter to obtain the target quantization parameter, wherein the first preset deviation value is larger than the second preset deviation value;
the second preset adjustment mode and the third preset adjustment mode are as follows:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, reducing a second preset offset value on the basis of the to-be-determined quantization parameter; and if the to-be-determined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, reducing a first preset offset value on the basis of the to-be-determined quantization parameter.
Optionally, the apparatus further comprises:
a second obtaining module 307, configured to obtain a first quantization parameter value and a second quantization parameter value corresponding to each coding unit, where the first quantization parameter value is a quantization parameter value actually encoded by a time-domain co-located coding unit corresponding to each coding unit, and the second quantization parameter value is an actual encoding quantization parameter value of a last encoded coding unit in a frame where the coding unit is located;
a first generating module 308 configured to generate a first limiting interval according to the first quantization parameter value and a first preset upper limit offset and a first preset lower limit offset;
a second generating module 309 configured to generate a second limiting interval according to the second quantization parameter value and a second preset upper limit offset and a second preset lower limit offset;
a third generating module 310, configured to generate a third restriction interval according to the frame-level quantization parameter of the frame where the coding unit is located, and a third preset upper limit offset and a third preset lower limit offset;
a limiting module 311 configured to limit the target quantization parameter according to the first limiting interval, the second limiting interval and the third limiting interval to obtain a limited target quantization parameter;
accordingly, the encoding module 305 is configured to:
and coding the data to be coded according to the target quantization parameter after the limiting processing corresponding to each coding unit.
Optionally, the limiting module 311 is configured to:
and limiting the target quantization parameter according to the preset priorities corresponding to the first limiting interval, the second limiting interval and the third limiting interval.
Optionally, in a case that the priority of the first restriction interval is higher than the priority of the second restriction interval, and the priority of the second restriction interval is higher than the priority of the third restriction interval, the restriction module 311 is configured to:
performing data processing on the target quantization parameter according to the first limit interval and a preset limit rule to obtain an updated target quantization parameter;
performing data processing on the current target quantization parameter according to the second limit interval and the preset limit rule to obtain an updated target quantization parameter;
and performing data processing on the currently updated target quantization parameter according to the third limiting interval and the preset limiting rule to obtain the limited target quantization parameter.
Optionally, the preset restriction rule is:
taking the target quantization parameter as an updated target quantization parameter under the condition that the target quantization parameter is determined to be positioned in the current limit interval, and taking the lower limit value of the current limit interval as the updated target quantization parameter under the condition that the target quantization parameter is determined to be smaller than the lower limit value of the current limit interval; under the condition that the target quantization parameter is determined to be larger than the upper limit value of the current limiting interval, taking the upper limit value of the current limiting interval as the updated target quantization parameter;
wherein the current limitation interval is any one of a first limitation interval, a second limitation interval and a third limitation interval.
According to the technical scheme, the target quantization parameter after adjustment is limited, so that the quantization parameter is adjusted on the whole of the data to be encoded, the image quality is guaranteed on the whole, and the image quality displayed in the video conference process can be improved.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment. As shown in fig. 5, the electronic device 500 may include: a processor 501 and a memory 502. The electronic device 500 may also include one or more of a multimedia component 503, an input/output (I/O) interface 504, and a communication component 505.
The processor 501 is configured to control the overall operation of the electronic device 500, so as to complete all or part of the steps in the encoding method. The memory 502 is used to store various types of data to support operation at the electronic device 500, such as instructions for any application or method operating on the electronic device 500 and application-related data, such as contact data, messaging, pictures, audio, video, and so forth. The Memory 502 may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic disk or optical disk. The multimedia component 503 may include a screen and an audio component. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 502 or transmitted through the communication component 505. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 504 provides an interface between the processor 501 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 505 is used for wired or wireless communication between the electronic device 500 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so that the corresponding Communication component 505 may include: Wi-Fi module, bluetooth module, NFC module.
In an exemplary embodiment, the electronic Device 500 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described encoding method.
In another exemplary embodiment, a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the encoding method described above is also provided. For example, the computer readable storage medium may be the memory 502 described above comprising program instructions that are executable by the processor 501 of the electronic device 500 to perform the encoding method described above.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea section of the present disclosure, and these simple modifications all belong to the protection section of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (17)

1. A method of encoding, the method comprising:
acquiring data to be coded from a video image to be coded;
determining the pixel bit number and the quantization parameter corresponding to the data to be encoded according to a code rate control parameter input by a user;
under the condition that the coding mode corresponding to the data to be coded is determined to be a target coding mode according to the pixel bit number and the quantization parameter, obtaining the to-be-determined quantization parameter, the time domain texture value and the space domain texture value corresponding to each coding unit in the data to be coded;
adjusting undetermined quantization parameters of each coding unit according to the time domain texture value and the space domain texture value of each coding unit to obtain target quantization parameters corresponding to each coding unit;
and coding the data to be coded according to the target quantization parameter corresponding to each coding unit.
2. The method according to claim 1, wherein the obtaining of data to be encoded from a video image to be encoded comprises:
under the condition that the preset coding level is GOP level coding, acquiring to-be-coded data taking GOP as a unit from a video image to be coded;
under the condition that the preset coding level is frame-level coding, acquiring the data to be coded with a frame as a unit from a video image to be coded;
in the case where the preset encoding level is line-level encoding, the data to be encoded in units of lines is acquired from the video image to be encoded.
3. The method of claim 2, wherein the rate control parameter includes a resolution, and when the preset encoding level is GOP level encoding, the data to be encoded is a GOP picture, and the determining the number of pixel bits corresponding to the data to be encoded according to the rate control parameter input by the user includes:
acquiring a target bit number corresponding to a first frame image in the GOP image;
and acquiring the ratio of the target bit number to the resolution ratio to obtain the pixel bit number corresponding to the data to be encoded.
4. The method according to claim 1, wherein the determining the quantization parameter corresponding to the data to be encoded according to the code rate control parameter input by the user comprises:
and obtaining a quantization parameter corresponding to the data to be coded according to the code rate control parameter by a preset frame-level code rate control algorithm.
5. The method according to claim 1, wherein the determining, according to the number of pixel bits and the quantization parameter, that the coding mode corresponding to the data to be encoded is the target coding mode includes:
and determining the coding mode as the target coding mode under the condition that the pixel bit number is less than or equal to a preset pixel bit number threshold and the quantization parameter is greater than a preset quantization parameter threshold.
6. The method according to claim 1, wherein the obtaining the temporal texture value corresponding to each coding unit in the data to be encoded comprises:
acquiring the brightness average absolute error value of each coding unit in the data to be coded and a co-located coding unit of a time domain frame, wherein the time domain frame is a frame before a frame where the coding unit is located or a preset reference frame;
and taking the brightness average absolute error value as the time domain texture value.
7. The method according to claim 1, wherein the obtaining the spatial texture value corresponding to each coding unit in the data to be encoded comprises:
acquiring a gradient value corresponding to each coding unit;
and determining the gradient value corresponding to each coding unit as the spatial texture value.
8. The method according to claim 1, wherein the adjusting the to-be-determined quantization parameter of the coding unit according to the temporal texture value and the spatial texture value to obtain a target quantization parameter corresponding to the coding unit comprises:
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the space domain texture value is larger than a space domain texture threshold value, adjusting the parameter to be quantized in a first preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is larger than a preset time domain texture threshold value and the spatial domain texture value is smaller than or equal to the spatial domain texture threshold value, adjusting the to-be-determined quantization parameter in a second preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is larger than the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a third preset adjusting mode to obtain the target quantization parameter;
under the condition that the time domain texture value is smaller than or equal to a preset time domain texture threshold value and the space domain texture value is smaller than or equal to the space domain texture threshold value, adjusting the to-be-determined quantization parameter in a fourth preset adjusting mode to obtain the target quantization parameter;
the first preset adjustment mode, the second preset adjustment mode, the third preset adjustment mode and the fourth preset adjustment mode are the same or different.
9. The method of claim 8, further comprising:
and determining the to-be-determined quantization parameter corresponding to the current coding unit through a preset coding unit level code rate control algorithm according to the code rate control parameter.
10. The method of claim 9, wherein the first preset adjustment manner and the fourth preset adjustment manner are:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, adding a first preset offset value on the basis of the to-be-determined quantization parameter; if the undetermined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, adding a second preset offset value on the basis of the undetermined quantization parameter to obtain the target quantization parameter, wherein the first preset offset value is larger than the second preset offset value;
the second preset adjustment mode and the third preset adjustment mode are as follows:
if the to-be-determined quantization parameter is smaller than the frame-level quantization parameter of the frame where the current coding unit is located, reducing a second preset offset value on the basis of the to-be-determined quantization parameter; and if the to-be-determined quantization parameter is larger than or equal to the frame-level quantization parameter of the frame where the current coding unit is located, reducing a first preset offset value on the basis of the to-be-determined quantization parameter.
11. The method according to claim 1, wherein before the encoding the data to be encoded according to the target quantization parameter corresponding to each coding unit, the method further comprises:
acquiring a first quantization parameter value and a second quantization parameter value corresponding to each coding unit, wherein the first quantization parameter value is a quantization parameter value actually coded by a time domain co-located coding unit corresponding to each coding unit, and the second quantization parameter value is an actual coding quantization parameter value of a last coded coding unit in a frame where the coding unit is located;
generating a first limit interval according to the first quantization parameter value, a first preset upper limit offset and a first preset lower limit offset;
generating a second limit interval according to the second quantization parameter value, a second preset upper limit offset and a second preset lower limit offset;
generating a third limiting interval according to the frame level quantization parameter of the frame where the coding unit is located, a third preset upper limit offset and a third preset lower limit offset;
limiting the target quantization parameter according to the first limiting interval, the second limiting interval and the third limiting interval to obtain a limited target quantization parameter;
correspondingly, the encoding the data to be encoded according to the target quantization parameter corresponding to each encoding unit includes:
and coding the data to be coded according to the target quantization parameter which is subjected to the limitation processing and corresponds to each coding unit.
12. The method according to claim 11, wherein the limiting the target quantization parameter according to the first limiting interval, the second limiting interval and the third limiting interval to obtain a limited target quantization parameter comprises:
and limiting the target quantization parameter according to the preset priorities corresponding to the first limiting interval, the second limiting interval and the third limiting interval.
13. The method of claim 12, wherein when the priority of the first restriction interval is higher than the priority of the second restriction interval, and the priority of the second restriction interval is higher than the priority of the third restriction interval, the restricting the target quantization parameter according to the preset priorities corresponding to the first restriction interval, the second restriction interval, and the third restriction interval comprises:
performing data processing on the target quantization parameter according to the first limit interval and a preset limit rule to obtain an updated target quantization parameter;
performing data processing on the current target quantization parameter according to the second limiting interval and the preset limiting rule to obtain an updated target quantization parameter;
and performing data processing on the current updated target quantization parameter according to the third limiting interval and the preset limiting rule to obtain the target quantization parameter subjected to limiting processing.
14. The method of claim 13, wherein the preset restriction rule is:
under the condition that the target quantization parameter is determined to be located in the current limit interval, taking the target quantization parameter as an updated target quantization parameter, and under the condition that the target quantization parameter is determined to be smaller than the lower limit value of the current limit interval, taking the lower limit value of the current limit interval as the updated target quantization parameter; under the condition that the target quantization parameter is determined to be larger than the upper limit value of the current limiting interval, taking the upper limit value of the current limiting interval as the updated target quantization parameter;
the current limiting interval is any one of a first limiting interval, a second limiting interval and a third limiting interval.
15. An encoding apparatus, characterized in that the apparatus comprises:
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is configured to acquire data to be encoded from a video image to be encoded;
the first determining module is configured to determine the pixel bit number and the quantization parameter corresponding to the data to be encoded according to a code rate control parameter input by a user;
the second determining module is configured to acquire the to-be-determined quantization parameter, the time domain texture value and the spatial domain texture value corresponding to each coding unit in the to-be-coded data under the condition that the coding mode corresponding to the to-be-coded data is determined to be a target coding mode according to the pixel bit number and the quantization parameter;
the adjusting module is configured to adjust the undetermined quantization parameter of each coding unit according to the time domain texture value and the space domain texture value of the coding unit to obtain a target quantization parameter corresponding to each coding unit;
and the coding module is configured to code the data to be coded according to the target quantization parameter corresponding to each coding unit.
16. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 14.
17. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 14.
CN202110336854.7A 2021-03-30 2021-03-30 Encoding method, encoding device, storage medium and electronic equipment Active CN112738516B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110336854.7A CN112738516B (en) 2021-03-30 2021-03-30 Encoding method, encoding device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110336854.7A CN112738516B (en) 2021-03-30 2021-03-30 Encoding method, encoding device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN112738516A true CN112738516A (en) 2021-04-30
CN112738516B CN112738516B (en) 2021-07-09

Family

ID=75595954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110336854.7A Active CN112738516B (en) 2021-03-30 2021-03-30 Encoding method, encoding device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN112738516B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114554204A (en) * 2022-01-20 2022-05-27 珠海全志科技股份有限公司 Method and device for adjusting image quality of coded image
CN115396672A (en) * 2022-08-25 2022-11-25 广东中星电子有限公司 Bit stream storage method, device, electronic equipment and computer readable medium
WO2024051331A1 (en) * 2022-09-08 2024-03-14 华为技术有限公司 Image encoding and decoding methods, apparatus, encoder, decoder and system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090016451A1 (en) * 2004-08-30 2009-01-15 General Instrument Corporation Method and Apparatus for Performing Motion Compensated Temporal Filtering in Video Encoding
CN104410861A (en) * 2014-11-24 2015-03-11 华为技术有限公司 Video encoding method and device
CN107040788A (en) * 2016-02-03 2017-08-11 南京云岩信息科技有限公司 A kind of video-frequency compression method and device
CN107087163A (en) * 2017-06-26 2017-08-22 杭州当虹科技有限公司 A kind of coding method of lifting HDR Subjective video qualities
CN110740324A (en) * 2019-09-11 2020-01-31 浙江大华技术股份有限公司 Coding control method and related device
CN111050169A (en) * 2018-10-15 2020-04-21 华为技术有限公司 Method and device for generating quantization parameter in image coding and terminal
CN111901597A (en) * 2020-08-05 2020-11-06 杭州当虹科技股份有限公司 CU (CU) level QP (quantization parameter) allocation algorithm based on video complexity

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090016451A1 (en) * 2004-08-30 2009-01-15 General Instrument Corporation Method and Apparatus for Performing Motion Compensated Temporal Filtering in Video Encoding
CN104410861A (en) * 2014-11-24 2015-03-11 华为技术有限公司 Video encoding method and device
CN107040788A (en) * 2016-02-03 2017-08-11 南京云岩信息科技有限公司 A kind of video-frequency compression method and device
CN107087163A (en) * 2017-06-26 2017-08-22 杭州当虹科技有限公司 A kind of coding method of lifting HDR Subjective video qualities
CN111050169A (en) * 2018-10-15 2020-04-21 华为技术有限公司 Method and device for generating quantization parameter in image coding and terminal
CN110740324A (en) * 2019-09-11 2020-01-31 浙江大华技术股份有限公司 Coding control method and related device
CN111901597A (en) * 2020-08-05 2020-11-06 杭州当虹科技股份有限公司 CU (CU) level QP (quantization parameter) allocation algorithm based on video complexity

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114554204A (en) * 2022-01-20 2022-05-27 珠海全志科技股份有限公司 Method and device for adjusting image quality of coded image
CN115396672A (en) * 2022-08-25 2022-11-25 广东中星电子有限公司 Bit stream storage method, device, electronic equipment and computer readable medium
CN115396672B (en) * 2022-08-25 2024-04-26 广东中星电子有限公司 Bit stream storage method, device, electronic equipment and computer readable medium
WO2024051331A1 (en) * 2022-09-08 2024-03-14 华为技术有限公司 Image encoding and decoding methods, apparatus, encoder, decoder and system

Also Published As

Publication number Publication date
CN112738516B (en) 2021-07-09

Similar Documents

Publication Publication Date Title
CN112738516B (en) Encoding method, encoding device, storage medium and electronic equipment
CN114598875B (en) Apparatus and method for quantization/inverse quantization and encoding/decoding apparatus
CN114071165B (en) Video encoder, video decoder and corresponding methods
KR102549670B1 (en) Chroma block prediction method and device
US20150288965A1 (en) Adaptive quantization for video rate control
CN112673626B (en) Relationships between partition constraint elements
EP3840378A1 (en) Video decoding method and video decoder
CN108702513B (en) Apparatus and method for adaptive computation of quantization parameters in display stream compression
JPH08256335A (en) Apparatus and method for determining quantization parameter
WO2020108033A1 (en) Transcoding method, transcoding device, and computer readable storage medium
US11343501B2 (en) Video transcoding method and device, and storage medium
US20210274193A1 (en) Image encoding method and decoding method, encoder, decoder, and storage medium
KR20210047947A (en) Video encoder, video decoder and corresponding method
CN116962613A (en) Data transmission method and device, computer equipment and storage medium
WO2020255940A1 (en) Image processing device and image processing method

Legal Events

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