WO2019205831A1 - 视频编码方法、装置、存储介质及设备 - Google Patents

视频编码方法、装置、存储介质及设备 Download PDF

Info

Publication number
WO2019205831A1
WO2019205831A1 PCT/CN2019/078432 CN2019078432W WO2019205831A1 WO 2019205831 A1 WO2019205831 A1 WO 2019205831A1 CN 2019078432 W CN2019078432 W CN 2019078432W WO 2019205831 A1 WO2019205831 A1 WO 2019205831A1
Authority
WO
WIPO (PCT)
Prior art keywords
video frame
quantization parameter
encoding
coding
resolution
Prior art date
Application number
PCT/CN2019/078432
Other languages
English (en)
French (fr)
Inventor
毛煦楠
郭利财
时永方
高安林
高欣玮
张涛
邓海波
谷沉沉
吕静
Original Assignee
腾讯科技 (深圳) 有限公司
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 腾讯科技 (深圳) 有限公司 filed Critical 腾讯科技 (深圳) 有限公司
Priority to EP19792389.9A priority Critical patent/EP3787291B1/en
Priority to JP2020551298A priority patent/JP7085014B2/ja
Publication of WO2019205831A1 publication Critical patent/WO2019205831A1/zh
Priority to US16/996,443 priority patent/US11388403B2/en

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/189Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding
    • H04N19/192Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding the adaptation method, adaptation tool or adaptation type being iterative or recursive
    • H04N19/194Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding the adaptation method, adaptation tool or adaptation type being iterative or recursive involving only two passes
    • 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/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/115Selection of the code volume for a coding unit prior to coding
    • 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/117Filters, e.g. for pre-processing or post-processing
    • 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/132Sampling, masking or truncation of coding units, e.g. adaptive resampling, frame skipping, frame interpolation or high-frequency transform coefficient masking
    • 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/136Incoming video signal characteristics or properties
    • 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/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
    • H04N19/147Data rate or code amount at the encoder output according to rate distortion criteria
    • 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/154Measured or subjectively estimated visual quality after decoding, e.g. measurement of distortion
    • 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/187Methods 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 scalable video layer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/30Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using hierarchical techniques, e.g. scalability
    • H04N19/33Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using hierarchical techniques, e.g. scalability in the spatial domain
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/59Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving spatial sub-sampling or interpolation, e.g. alteration of picture size or resolution
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/478Supplemental services, e.g. displaying phone caller identification, shopping application
    • H04N21/4788Supplemental services, e.g. displaying phone caller identification, shopping application communicating with other users, e.g. chatting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N7/00Television systems
    • H04N7/14Systems for two-way working

Definitions

  • the embodiments of the present invention relate to the field of coding technologies, and in particular, to a video coding method, apparatus, storage medium, and device.
  • a video is a sequence of video frames that are sequentially composed of multiple video frames. Since the amount of data of the video is large, the video can be compressed by means of encoding, and the encoding resolution of each video frame in the video needs to be determined during encoding.
  • the encoding resolution and the type of video frame are described below.
  • the related art provides two encoding resolutions, the first encoding resolution is the resolution when the video frame is sampled, and the second encoding resolution is the resolution when the video frame is downsampled.
  • the downsampling here refers to sampling the sample sequence once every few samples, and it can be seen that the second encoding resolution is lower than the first encoding resolution.
  • the related art provides two types of video frames, one is an I frame and the other is a P frame.
  • An I frame is an intra prediction frame, which carries all the information and can be encoded without reference to other frames.
  • a P frame is an inter prediction frame, which needs to be referenced by other frames for encoding.
  • the terminal when the terminal encodes each video frame, it is necessary to determine whether the video frame is an I frame or a P frame.
  • the video frame When the video frame is an I frame, the video is encoded at the first encoding resolution.
  • the frame is encoded; when the video frame is a P frame, the video frame is encoded at a second encoding resolution.
  • video frames of the same type correspond to the same encoding resolution, resulting in an inflexible coding method.
  • the embodiment of the present invention provides a video encoding method, apparatus, storage medium, and device, which are used to solve the problem that the same type of video frame corresponds to the same encoding resolution, resulting in an inflexible encoding method.
  • the technical solution is as follows:
  • a video encoding method comprising:
  • an encoding resolution of the i-th video frame the encoding resolution being a first encoding resolution or a second encoding resolution, the first encoding resolution being a resolution at the time of sampling the i-th video frame, where the second encoding resolution is a resolution when down-sampling the ith video frame;
  • the ith video frame is encoded at the encoding resolution.
  • a video encoding apparatus comprising:
  • An acquiring module configured to acquire a video to be encoded, where the video includes at least two video frames arranged in order;
  • a calculation module configured to calculate, for an i-th video frame of the at least two video frames, a quantization parameter and a quantization parameter threshold of the i-th video frame, where i is a positive integer greater than or equal to 2;
  • a determining module configured to determine, according to the quantization parameter and the quantization parameter threshold obtained by the calculating module, an encoding resolution of the ith video frame, where the encoding resolution is a first encoding resolution or a second encoding a resolution, the first encoding resolution is a resolution when the ith video frame is sampled, and the second encoding resolution is a resolution when down-sampling the ith video frame;
  • an encoding module configured to encode the ith video frame by the encoding resolution determined by the determining module.
  • a computer readable storage medium having stored therein at least one instruction, at least one program, a code set, or a set of instructions, the at least one instruction, the at least one program, the code set Or the set of instructions is loaded and executed by the processor to implement the video encoding method as described above.
  • a video encoding apparatus including a processor and a memory, the memory storing at least one instruction loaded by the processor and executed to implement the video as described above Coding method.
  • the encoding resolution solves the problem that the encoding method is not flexible enough when the same type of video frame corresponds to the same encoding resolution, thereby improving the flexibility of the encoding method.
  • the quantization parameter threshold is related to the required picture quality. Therefore, determining the coding resolution of the video frame according to the quantization parameter and the quantization parameter threshold is equivalent to selecting the coding of the video frame according to the picture quality and the required picture quality. Resolution can improve the accuracy of the determined encoding resolution.
  • FIG. 1 is a flow chart showing determining a coding resolution, which is shown in some embodiments of the present application.
  • FIG. 2 is a schematic structural diagram of a video encoding system according to some exemplary embodiments
  • FIG. 3 is a flowchart of a method for video encoding according to an embodiment of the present application.
  • FIG. 4 is a flowchart of a method for a video encoding method according to another embodiment of the present application.
  • FIG. 5 is a flowchart of calculating a coding cost ratio value according to another embodiment of the present application.
  • FIG. 6 is a structural block diagram of a video encoding apparatus according to an embodiment of the present application.
  • FIG. 7 is a structural block diagram of a video encoding apparatus according to still another embodiment of the present application.
  • the embodiment of the present application is applied to an application scenario of video compression. After the video is compressed, the video can be transmitted to save the bandwidth occupied by the video during transmission and reduce the transmission time; the video can also be stored to save the storage space occupied by the video; The video performs other operations and is not limited here.
  • the video transmission includes real-time transmission and non-real-time transmission.
  • the real-time transmission may be real-time video communication using an instant messaging client, real-time live broadcast using a live client, etc.; non-real-time transmission may be video uploading, downloading, and the like.
  • the embodiment of the present application can be generally divided into five steps.
  • the first step 101 is an intra/inter precoding cost analysis to determine a coding cost ratio.
  • the second step 102 is to estimate a quantization parameter according to a coding cost ratio.
  • Step 103 is to calculate a quantization parameter threshold;
  • fourth step 104 is to select an encoding resolution according to the quantization parameter and the quantization parameter threshold;
  • the fifth step 105 encodes the video frame with the selected encoding resolution, please refer to FIG.
  • a detailed explanation of each step is described in the following examples.
  • each I frame in the video may correspond to the same encoding resolution, and may also correspond to different encoding resolutions; each P frame in the video may correspond to the same encoding resolution, and may also correspond to Different encoding resolutions. That is, video frames of the same type may correspond to the same encoding resolution, and may also correspond to different encoding resolutions, thereby improving the flexibility of the encoding method.
  • the quantization parameter threshold is related to the required picture quality. Therefore, determining the encoding resolution of the video frame according to the quantization parameter and the quantization parameter threshold is equivalent to selecting the video frame according to the picture quality and the required picture quality.
  • the encoding resolution can improve the accuracy of the determined encoding resolution.
  • FIG. 2 is a schematic structural diagram of a video coding system according to an embodiment of the present disclosure.
  • the video coding system is applied to a scenario in which a real-time video call is performed by using an instant messaging client, and the video coding is performed.
  • the system includes at least a first terminal 210, a second terminal 220, and a server 230.
  • the first terminal 210 and the server 230 establish a connection through a wired network or a wireless network
  • the second terminal 220 establishes a connection with the server 230 through a wired network or a wireless network.
  • the first terminal 210 is a device having a video data stream transceiving function, such as a smart phone.
  • the first terminal 210 is installed with an instant messaging client, such as a WeChat client, a QQ client, and the like.
  • the second terminal 220 is a device having a function of transmitting and receiving video data streams, such as a smart phone.
  • the second terminal 220 and the first terminal 210 are installed with at least one same instant messaging client, and the instant messaging client in the second terminal 220 can communicate with the instant messaging client in the first terminal 210.
  • the server 230 is a background server of the instant messaging client, and may be a server cluster or a cloud computing center composed of one server or multiple servers.
  • the first terminal 210 may initiate a real-time video call to the second terminal 220 through the server 230.
  • the second terminal 220 may also initiate a real-time video call to the first terminal 210 through the server 230.
  • the first terminal 210 captures the first user's call process through the camera, and obtains the first video.
  • the first video is encoded by using the video coding method provided by the embodiment of the present application, and the first video data stream obtained after the encoding is sent.
  • the server 230 forwards the first video data stream to the second terminal 220, and the second terminal 220 decodes the first video data stream according to the decoding mode corresponding to the encoding mode, and obtains the first obtained after decoding.
  • the video is played.
  • the second terminal 220 captures the call process of the second user by using the camera to obtain a second video, and encodes the second video by using the coding mode provided in the embodiment of the present application, and the second video data stream obtained after the coding is obtained.
  • the server 230 forwards the second video data stream to the first terminal 210, and the first terminal 210 decodes the second video data stream according to the decoding mode corresponding to the encoding mode, and obtains the decoded video data stream.
  • the second video is played.
  • the first terminal 210 can also play the first video captured by itself, that is, play the second video in the first area of the display interface of the first terminal 210, and play in the second area.
  • the first video in addition to playing the first video, the second terminal 220 can also play the second video captured by itself, that is, play the first video in the first area of the display interface of the second terminal 220, and play the first video in the second area.
  • the display interface of the first terminal 210 and the second terminal 220 is as shown in FIG. 2 .
  • FIG. 3 is a flowchart of a method for encoding a video provided by an embodiment of the present application.
  • the video encoding method may be applied to the first terminal or the second terminal shown in FIG. 2.
  • the video encoding method includes:
  • Step 301 Acquire a video to be encoded, where the video includes at least two video frames arranged in order.
  • the video may be obtained by the terminal, or may be downloaded from the network by the terminal, or may be obtained by the terminal from other devices. This embodiment does not limit the source of the video.
  • a video is a sequence of video frames comprising at least two video frames arranged in sequence.
  • the sequential arrangement is arranged in the order of shooting of the respective video frames, that is, in order of the shooting time of each video frame from the morning to the night.
  • the terminal For the first video frame in the video frame sequence, the terminal encodes the video frame by the first encoding resolution by default; for the remaining video frames in the video frame sequence, the terminal sequentially reads a video frame from the video frame sequence.
  • the video frame is used as the i-th video frame, and then steps 302-303 are performed to select the encoding resolution of the i-th video frame, and finally 304 is performed to select the i-th video frame with the selected encoding resolution.
  • Encoding is performed, i is a positive integer greater than or equal to 2.
  • the encoding resolution is the first encoding resolution or the second encoding resolution. For details, refer to the explanation in step 303.
  • Step 302 Calculate a quantization parameter and a quantization parameter threshold of the i-th video frame for the i-th video frame of the at least two video frames.
  • Quantization refers to the processing of sampling a continuous signal into a discrete signal to reduce the amount of data that needs to be encoded and achieve the purpose of compressing the data.
  • the quantization parameter is a parameter involved in the process of quantizing a video frame.
  • the quantization parameter is a parameter for indicating the quantization precision.
  • the quantization parameter has a negative correlation with the quantization accuracy. That is, the smaller the quantization parameter, the finer the quantization, the better the picture quality at this time, and the lower the compression ratio of the data; the larger the quantization parameter, the coarser the quantization, the worse the picture quality and the higher the compression of the data. .
  • the quantization parameter is the sequence number corresponding to the quantization step size. For example, in H.264 (Moving Picture Expert Group-4 Advanced Video Codec), there are 52 quantization step sizes, and the value of the quantization parameter is 0 to 51, and each quantization parameter is used for identification. One of the 52 quantization step sizes.
  • the quantization parameter threshold is a threshold for indicating the quality of the required picture, and the required picture quality here is the subjectively acceptable picture quality of the user. Among them, the quantization parameter threshold is positively correlated with the demand picture quality. That is, the lower the required picture quality, the smaller the quantization parameter threshold; the higher the required picture quality, the larger the quantization parameter threshold.
  • the human eye is sensitive to the picture quality loss of the still scene and is not sensitive to the picture quality loss of the motion scene. Therefore, the human eye has higher requirements on the picture quality of the video frame in the still scene, and the terminal can be on the still scene.
  • the lower video frame sets a larger quantization parameter threshold, so as to tend to use the first encoding resolution for encoding, thereby improving the picture quality; the human eye has lower requirements on the picture quality of the video frame in the motion scene, and the terminal can Video frames in a motion scene set a smaller quantization parameter threshold to favor encoding with a second encoding resolution, thereby increasing the compression ratio of the data.
  • the terminal separately calculates a quantization parameter of the i-th video frame and a quantization parameter threshold, where the quantization parameter is estimated by the terminal, possibly and actual The quantization parameters are different.
  • the quantization parameter is estimated by the terminal, possibly and actual The quantization parameters are different.
  • Step 303 Determine an encoding resolution of the i-th video frame according to the quantization parameter and the quantization parameter threshold.
  • the encoding resolution is the first encoding resolution or the second encoding resolution
  • the first encoding resolution is the resolution of the i-th video frame sampling, which may also be referred to as full resolution
  • the second encoding resolution is the The resolution at which a video frame is downsampled may also be referred to as a downsampling resolution.
  • the second encoding resolution is smaller than the first encoding resolution.
  • Step 304 encoding the ith video frame with the encoding resolution.
  • the picture quality is better, and the data compression is relatively low; when the ith video frame is encoded with the second encoding resolution, the picture quality is poor.
  • the compression of the data is relatively high.
  • the video coding method determines the coding resolution of a video frame according to the quantization parameter and the quantization parameter threshold by respectively calculating a quantization parameter and a quantization parameter threshold of a video frame, so that the same type of video
  • the frames may correspond to the same coding resolution, or may correspond to different coding resolutions, and solve the problem that the coding mode is not flexible when the same type of video frame corresponds to the same coding resolution, thereby improving the flexibility of the coding mode. Sex.
  • the quantization parameter threshold is related to the required picture quality. Therefore, determining the coding resolution of the video frame according to the quantization parameter and the quantization parameter threshold is equivalent to selecting the coding of the video frame according to the picture quality and the required picture quality. Resolution can improve the accuracy of the determined encoding resolution.
  • FIG. 4 is a flowchart of a method for encoding a video according to another embodiment of the present application.
  • the video encoding method may be applied to the first terminal or the second terminal shown in FIG. 2.
  • the video encoding method includes:
  • Step 401 Acquire a video to be encoded, where the video includes at least two video frames arranged in order.
  • the video may be obtained by the terminal, or may be downloaded from the network by the terminal, or may be obtained by the terminal from other devices. This embodiment does not limit the source of the video.
  • a video is a sequence of video frames comprising at least two video frames arranged in sequence.
  • the sequential arrangement is arranged in the order of shooting of the respective video frames, that is, in order of the shooting time of each video frame from the morning to the night.
  • the terminal For the first video frame in the video frame sequence, the terminal encodes the video frame by the first encoding resolution by default; for the remaining video frames in the video frame sequence, the terminal sequentially reads a video frame from the video frame sequence.
  • the video frame is used as the i-th video frame, and then steps 402-408 are performed to select the encoding resolution of the i-th video frame, and finally step 409 is performed to select the i-th video with the selected encoding resolution.
  • the frame is encoded, and i is a positive integer greater than or equal to 2.
  • the encoding resolution is a first encoding resolution or a second encoding resolution
  • the first encoding resolution is a resolution when the video frame is sampled
  • the second encoding resolution is a resolution when the video frame is downsampled. See the description in step 303 for details.
  • Step 402 For the i-th video frame of the at least two video frames, when the coding mode of the i-th video frame is the fixed-quality coding mode, reading the set quantization parameter, and determining the quantization parameter as the ith Step 404 is performed on the quantization parameters of the video frames.
  • the fixed quality coding mode refers to a mode in which a video frame is encoded with a constant picture quality. That is, if each video frame is encoded in a fixed quality coding mode, the picture quality of each video frame after encoding is constant.
  • the picture quality of the video frame is related to the quantization parameter
  • the quantization parameter when the picture quality is constant, it means that the quantization parameter is constant, so that a constant quantization parameter can be set in advance for the video frame of the fixed quality coding mode. That is, when the coding mode of the i-th video frame is the fixed-quality coding mode, the quantization parameter of the i-th video frame is preset, and the terminal directly reads the quantization parameter of the i-th video frame.
  • the terminal needs to assume the coding resolution of the i-th video frame, and read the quantization parameter corresponding to the coding resolution. .
  • the quantization parameter corresponding to the first coding resolution is greater than the quantization parameter corresponding to the second coding resolution.
  • the quantization parameter corresponding to the first coding resolution is 33
  • the quantization parameter corresponding to the second coding resolution is 27.
  • the terminal can assume that the encoding resolution of the i-th video frame is the first encoding resolution.
  • the terminal can also assume that the encoding resolution of the ith video frame is the second encoding resolution, which is not limited in this embodiment.
  • Step 403 For the i-th video frame of the at least two video frames, when the coding mode of the i-th video frame is a fixed rate coding mode, calculate a quantization parameter of the first coding block in the i-th video frame, The quantization parameter of the first coding block is determined as a quantization parameter of the i-th video frame.
  • the fixed rate encoding mode is a mode in which a video frame is encoded at a constant bit rate. That is, if a plurality of video frames per second in the fixed code rate encoding mode are encoded, the total size of all video frames in each second after encoding is constant.
  • the terminal needs to dynamically determine the quantization parameter according to the picture quality. That is, when the coding mode of the i-th video frame is the fixed rate coding mode, the terminal can dynamically calculate the quantization parameter of the i-th video frame.
  • the terminal needs to assume the coding resolution of the i-th video frame, and then calculate the quantization parameters based on the assumed coding resolution.
  • the algorithm for the quantization parameter is assumed to be the same when the first coding resolution and the second coding resolution are the same.
  • the calculating the quantization parameter of the first coding block in the i-th video frame may include the following four schemes:
  • the actual quantization parameter of all coding blocks in the i-1th video frame is calculated.
  • An average value of the first offset and the second offset; and a sum of the average value, the first offset, and the second offset is determined as a quantization parameter of the first coded block.
  • the terminal divides the i-1th video frame into at least two coding blocks, and the quantization parameters of each coding block are The set quantization parameter is equal to the quantization parameter set for each coding block, so the average value of the actual quantization parameters of all coding blocks is still the set quantization parameter.
  • the terminal divides the i-1th video frame into at least two coding blocks, according to an algorithm set in the encoder.
  • the actual quantization parameters of each coding block are calculated, and all the quantization parameters are added and then divided by the number of coding blocks to obtain an average value.
  • the quantization parameter of the first coding block of the i-1th video frame is first calculated, and then the quantization parameter is assumed to be the i-th Quantization parameter of 1 video frame.
  • the terminal calculates the actual quantization parameter of each coding block in the i-1th video frame, and the actual quantization parameter calculated here is different from the previously assumed quantization parameter, and the calculation process in this step is in the coding process. The average of the actual quantization parameters obtained.
  • the first offset is an offset between the quantization parameter corresponding to the first coding resolution and the quantization parameter corresponding to the second coding resolution, and may be an empirical value or may be calculated according to a formula, which is not limited in this embodiment.
  • the first offset is denoted as QP delta .
  • the first encoding resolution, the second encoding resolution, and the first offset have the following relationship: subtracting the first offset from the quantization parameter of the first encoding resolution to obtain a quantization parameter of the second encoding resolution, That is, the quantization parameter of the second coding resolution is added to the first offset to obtain a quantization parameter of the first coding resolution.
  • the second offset is an offset of the quantization parameter between the I frame and the P frame, and may be an empirical value, or may be calculated according to a formula, which is not limited in this embodiment.
  • the second offset is denoted as QP offset-I/P .
  • the sum of the three is used as the quantization parameter of the first coding block.
  • the i-1th video frame is an I frame and the i-1th video frame is encoded with the first encoding resolution, the actual quantization parameter of all coding blocks in the i-1th video frame is calculated. The average value; the second offset is obtained; the sum of the average value and the second offset is determined as the quantization parameter of the first coded block.
  • the sum of the two is used as the quantization parameter of the first coding block.
  • the actual quantization parameter of all coding blocks in the i-1th video frame is calculated. Average; the average is determined as the quantization parameter of the first coded block.
  • the average value is taken as the quantization parameter of the first coded block.
  • the actual quantization parameter of all coding blocks in the i-1th video frame is calculated.
  • the average value; the first offset is obtained; the sum of the average value and the first offset is determined as the quantization parameter of the first coding block.
  • the sum of the two is used as the quantization parameter of the first coding block.
  • one of the above four schemes may be selected according to the type and encoding resolution of the i-1th video frame, and then the selected one scheme is used to calculate the first one of the i-th video frames.
  • the quantization parameter of the coding block may be selected according to the type and encoding resolution of the i-1th video frame, and then the selected one scheme is used to calculate the first one of the i-th video frames.
  • Step 404 calculating a first coding cost when the i-th video frame is assumed to be an I frame.
  • the i-th video frame is actually an I frame or a P frame, it is necessary to assume that the i-th video frame is an I-frame to calculate a first coding cost, and assume that the i-th video frame is a P-frame to calculate a second. Coding cost.
  • the first coding cost when the i-th video frame is assumed to be an I frame is calculated, which may include the following steps:
  • Step 4041 Divide the ith video frame into at least two coding blocks.
  • the terminal can divide the ith video frame into multiple coding blocks according to different algorithms, which is not limited in this embodiment.
  • the number of coding blocks obtained by different algorithms may be the same or different.
  • the terminal divides the ith video frame into 8*8 coding blocks.
  • Step 4042 Perform intra prediction encoding on the coding block to obtain an intra coding cost.
  • the intraframe coding cost is equal to the sum of the absolute values of the prediction residuals of all pixels in the coding block.
  • the intraframe coding cost cost D+ ⁇ *R, where D is the degree of distortion of the coding block, and the absolute value of the difference between the reconstructed image and the original image can be reconstructed by using the coding of all pixels in the coding block. It is indicated that ⁇ is the number of Lagrangian systems and R is the number of bits occupied by the coding block.
  • Step 4043 determining the sum of the respective intra-frame coding costs as the first coding cost.
  • the first coding cost is recorded as Icost.
  • the method before dividing the ith video frame into at least two coding blocks, the method further includes: downsampling the ith video frame.
  • the terminal may downsample the ith video frame by using a simple downsampling algorithm to reduce the data amount of the i-th video frame, thereby improving the speed of the subsequent calculation of the first coding cost and the second coding cost, and finally improving. Determine the speed of the encoding resolution.
  • the terminal performs a 2:1 downsampling on the length and width of the i-th video frame.
  • the terminal can also perform other proportions of downsampling, which is not limited in this embodiment.
  • Step 405 calculating a second encoding cost when the i-th video frame is assumed to be a P-frame.
  • calculating a second encoding cost when the i-th video frame is assumed to be a P-frame may include the following steps:
  • Step 4051 Divide the ith video frame into at least two coding blocks.
  • the terminal can divide the ith video frame into multiple coding blocks according to different algorithms, which is not limited in this embodiment.
  • the number of coding blocks obtained by different algorithms may be the same or different.
  • the algorithm for dividing the coding block in this step is the same as the algorithm for dividing the coding block in step 4041, so that each coding block obtained in this step is the same as each coding block obtained in step 4041.
  • the terminal also divides the ith video frame into 8*8 coding blocks.
  • the terminal may directly read the execution result of step 4041 to obtain at least two coding blocks, to avoid time spent repeatedly dividing the coding block, and improve coding efficiency.
  • Step 4052 Perform interframe prediction coding on the coding block to obtain an interframe coding cost.
  • the algorithm for the inter-frame coding cost and the intra-frame coding cost is the same, and is not described here.
  • Step 4053 determining the sum of the respective inter-frame coding costs as the second coding cost.
  • the second coding cost is recorded as Pcost.
  • this embodiment does not limit the sequential execution sequence of step 404 and step 405. That is, the terminal may calculate the first coding cost first, and then calculate the second coding cost; or calculate the second coding cost first, and then calculate the first coding cost; and calculate the first coding cost and the second coding cost simultaneously.
  • Step 406 dividing the first coding cost by the second coding cost to obtain an coding cost ratio.
  • FIG. 5 shows the calculation process of the coding cost ratio.
  • the terminal first downsamples the i-th video frame, and then calculates the I-frame coding cost (ie, the first coding cost calculated when the i-th video frame is an I-frame) and the P-frame coding cost (ie, assumption The i-th video frame is a second coding cost calculated when the P-frame is obtained, and the I-frame coding cost is divided by the P-frame coding cost to obtain an encoding cost ratio.
  • the I-frame coding cost ie, the first coding cost calculated when the i-th video frame is an I-frame
  • the P-frame coding cost ie, assumption The i-th video frame is a second coding cost calculated when the P-frame is obtained
  • the I-frame coding cost is divided by the P-frame coding cost to obtain an encoding cost ratio.
  • Step 407 determining a quantization parameter threshold according to the coding cost ratio.
  • the terminal may input the coding cost ratio into the formula to calculate the quantization parameter threshold, or may set a correspondence between the coding cost ratio and the quantization parameter threshold, and the terminal searches for the quantization parameter threshold in the correspondence according to the coding cost ratio.
  • the quantization parameter threshold is recorded as QP TH .
  • the quantization cost threshold is determined in any way, and the coding cost ratio is positively correlated with the quantization parameter threshold. This is because the downsampling itself loses part of the video information, and the human eye is sensitive to the picture quality loss of the still scene and is not sensitive to the picture quality loss of the motion scene. Therefore, the terminal can set a larger video frame in the still scene.
  • the quantization parameter threshold is apt to be encoded with the first encoding resolution, thereby improving picture quality; setting a smaller quantization parameter threshold for the video frame in the motion scene, tending to encode with the second encoding resolution, thereby Increase the compression ratio of the data.
  • the quantization parameter threshold corresponds to the encoding resolution, that is, different encoding resolutions correspond to different quantization parameter thresholds.
  • the difference between the quantization parameter threshold corresponding to the first coding resolution and the quantization parameter threshold corresponding to the second coding resolution is equal to the first offset.
  • Step 408 when the quantization parameter is less than or equal to the quantization parameter threshold, determining that the encoding resolution of the i-th video frame is the first encoding resolution; when the quantization parameter is greater than the quantization parameter threshold, determining that the encoding resolution of the i-th video frame is Second encoding resolution.
  • the quantization parameter threshold since the quantization parameter corresponds to the encoding resolution, the quantization parameter threshold also corresponds to the encoding resolution. Therefore, before comparing the quantization parameter and the quantization parameter threshold, it is also required to ensure that the quantization parameter and the quantization parameter threshold correspond to the same encoding. Resolution.
  • the first implementation manner is to set a set of threshold values, and the threshold set corresponds to a coding resolution. After obtaining the quantization parameter, according to the coding resolution corresponding to the threshold set. The quantization parameter is converted, and the quantization parameter threshold is determined according to the final quantization parameter obtained after the conversion and the threshold set.
  • the second implementation manner is to set two sets of thresholds and the two sets of thresholds correspond to different coding resolutions. After obtaining the quantization parameters, first determine the coding resolution corresponding to the quantization parameters, and then based on the coding resolution from the two A set of thresholds is selected from the set of thresholds, and the quantized parameter threshold is determined according to the quantized parameters and the set of found thresholds.
  • the threshold set is a set including at least two quantization parameter thresholds, and a first correspondence relationship between the quantization parameter threshold and the encoding cost ratio is defined in the threshold set.
  • the set of thresholds represented includes two quantization threshold parameters, 33 and 36, respectively, and 33 corresponds to an encoding cost ratio value less than 3, and 36 corresponds to an encoding cost ratio value greater than or equal to 3.
  • the method further comprises: if calculating the quantization parameter It is assumed that the encoding resolution of the i-th video frame is the first encoding resolution, and the quantization parameter is determined as the final quantization parameter; if the quantization parameter is calculated, it is assumed that the encoding resolution of the i-th video frame is the second encoding resolution. Rate, then add the quantization parameter to the first offset to obtain the final quantization parameter.
  • the set of thresholds present corresponds to the first encoding resolution. If the quantization parameter QP is calculated, assuming that the encoding resolution of the i-th video frame is the first encoding resolution, the QP is used as the final quantization parameter. Step 409: If the quantization parameter QP is calculated and the encoding resolution of the i-th video frame is the second encoding resolution, then the QP+QP delta is used as the final quantization parameter, and step 409 is performed.
  • the method further comprises: if calculating the quantization When the parameter assumes that the encoding resolution of the i-th video frame is the first encoding resolution, the quantization parameter is subtracted from the first offset to obtain a final quantization parameter; if the quantization parameter is calculated, the encoding resolution of the i-th video frame is assumed.
  • the rate is the second coding resolution, and the quantization parameter is determined as the final quantization parameter.
  • the set of thresholds present corresponds to the second encoding resolution.
  • the quantization parameter QP is calculated, the encoding resolution of the i-th video frame is assumed to be the first encoding resolution, and the QP-QP delta is used as the final quantization.
  • step 409 is performed; if the quantization parameter QP is calculated, it is assumed that the encoding resolution of the i-th video frame is the second encoding resolution, then the QP is used as the final quantization parameter, and step 409 is performed.
  • the quantization parameter is calculated, it is assumed that the coding resolution of the i-th video frame is the first coding resolution, according to the coding cost ratio,
  • the two sets of threshold sets and the first encoding resolution determine a quantization threshold parameter.
  • the determining the quantization threshold parameter according to the coding cost ratio, the two threshold sets, and the first coding resolution includes: searching for a threshold set corresponding to the first coding resolution in the two sets of threshold sets; and searching according to the coding cost ratio
  • the quantization threshold parameter is looked up in the threshold set.
  • the second correspondence between the two sets of threshold sets and the different coding resolutions is preset, and then the terminal is determined according to the coding cost ratio, the two threshold sets, and the first coding resolution.
  • the threshold set corresponding to the first encoding resolution is The threshold set corresponding to the second encoding resolution is If the quantization parameter is calculated and the encoding resolution of the i-th video frame is assumed to be the first encoding resolution, the selected threshold set is If the coding cost ratio at this time is less than 3, the obtained quantization parameter threshold is 33; if the coding cost ratio at this time is greater than or equal to 3, the obtained quantization parameter threshold is 36.
  • the quantization parameter is calculated, it is assumed that the coding resolution of the i-th video frame is the second coding resolution, according to the coding cost ratio,
  • the two sets of threshold sets and the second encoding resolution determine quantization threshold parameters.
  • the determining the quantization threshold parameter according to the coding cost ratio, the two sets of threshold sets, and the second coding resolution includes: searching for a threshold set corresponding to the second coding resolution in the two sets of threshold sets; and searching according to the coding cost ratio
  • the quantization threshold parameter is looked up in the threshold set.
  • the second correspondence between the two sets of threshold sets and the different coding resolutions is preset, and when the quantization threshold parameters are determined according to the coding cost ratio, the two threshold sets, and the second coding resolution, the terminal First searching for a set of threshold sets corresponding to the second encoding resolution from the two sets of threshold sets based on the second correspondence, and then based on the first correspondence between the quantization parameter threshold and the encoding cost ratio defined in the set of threshold sets Relationship, looking up a quantization parameter threshold corresponding to the coding cost ratio.
  • the threshold set corresponding to the first encoding resolution is The threshold set corresponding to the second encoding resolution is If the quantization parameter is calculated to assume that the encoding resolution of the i-th video frame is the second encoding resolution, the selected threshold set is If the coding cost ratio at this time is less than 3, the obtained quantization parameter threshold is 27; if the coding cost ratio at this time is greater than or equal to 3, the obtained quantization parameter threshold is 30.
  • Step 409 encoding the i-th video frame with the encoding resolution.
  • the picture quality is better, and the data compression is relatively low; when the ith video frame is encoded with the second encoding resolution, the picture quality is poor.
  • the compression of the data is relatively high.
  • a video compression standard such as H.264, H.265, AVS (Audio Video coding standard) may be used to encode a video frame based on the above determined encoding resolution.
  • the video coding method determines the coding resolution of a video frame according to the quantization parameter and the quantization parameter threshold by respectively calculating a quantization parameter and a quantization parameter threshold of a video frame, so that the same type of video
  • the frames may correspond to the same coding resolution, or may correspond to different coding resolutions, and solve the problem that the coding mode is not flexible when the same type of video frame corresponds to the same coding resolution, thereby improving the flexibility of the coding mode. Sex.
  • the quantization parameter threshold is related to the required picture quality. Therefore, determining the coding resolution of the video frame according to the quantization parameter and the quantization parameter threshold is equivalent to selecting the coding of the video frame according to the picture quality and the required picture quality. Resolution.
  • the quality of the required picture is high, the video frame is encoded with a higher first encoding resolution to improve the picture quality; when the required picture quality is low, the video frame is encoded with a lower second encoding resolution. To increase the compression ratio of the data.
  • the data amount of the video frame can be reduced, thereby improving the speed of the subsequent calculation of the first coding cost and the second coding cost, and finally improving the determination of the coding resolution. speed.
  • FIG. 6 is a structural block diagram of a video encoding apparatus according to an embodiment of the present application.
  • the video encoding apparatus may be applied to the first terminal or the second terminal shown in FIG. 2 .
  • the video encoding device includes:
  • the obtaining module 610 is configured to obtain a video to be encoded, where the video includes at least two video frames arranged in sequence.
  • the implementation details of the obtaining module 610 are described in step 301 or step 401.
  • the calculation module 620 is configured to calculate, for an i-th video frame of the at least two video frames, a quantization parameter and a quantization parameter threshold of the i-th video frame, where i is a positive integer greater than or equal to 2, where the calculation module 620
  • i is a positive integer greater than or equal to 2
  • the calculation module 620 For details of the implementation of the quantization parameter of the i-th video frame, refer to the description in step 302 or step 402. The implementation details of calculating the quantization parameter threshold of the i-th video frame in the calculation module are detailed in step 302 or steps 403-407. description of.
  • the determining module 630 is configured to determine, according to the quantization parameter and the quantization parameter threshold obtained by the calculating module 620, the encoding resolution of the ith video frame, where the encoding resolution is the first encoding resolution or the second encoding resolution, and the first encoding resolution Is the resolution of the i-th video frame sampling, and the second encoding resolution is the resolution when the i-th video frame is down-sampled; wherein the implementation details of the determining module 630 are detailed in step 303 or step 408. description.
  • the encoding module 640 is configured to determine the encoding resolution determined by the module 630 to encode the ith video frame. The implementation details of the encoding module 640 are described in detail in step 304 or step 409.
  • the calculating module 620 is further configured to:
  • the set quantization parameter is read, and the quantization parameter is determined as the quantization parameter of the ith video frame; the implementation details are described in step 402.
  • the quantization parameter of the first coding block in the i-th video frame is calculated, and the quantization parameter of the first coding block is determined as the i-th video frame. Quantitative parameters, the implementation details of which are described in step 403.
  • the calculating module 620 is further configured to:
  • the average value of the actual quantization parameters of all the coding blocks in the i-1th video frame is calculated. Obtaining a first offset and a second offset; determining a sum of the average value, the first offset, and the second offset as a quantization parameter of the first coding block; and/or,
  • the average value of the actual quantization parameters of all the coding blocks in the i-1th video frame is calculated. Obtaining a second offset; determining a sum of the average value and the second offset as a quantization parameter of the first coding block; and/or,
  • the average value of the actual quantization parameters of all the coding blocks in the i-1th video frame is calculated. ; determining the average value as the quantization parameter of the first coding block; and/or,
  • the average value of the actual quantization parameters of all the coding blocks in the i-1th video frame is calculated. Obtaining a first offset; determining a sum of the average value and the first offset as a quantization parameter of the first coding block;
  • the first offset is an offset between a quantization parameter corresponding to the first coding resolution and a quantization parameter corresponding to the second coding resolution
  • the second offset is an offset of the quantization parameter between the I frame and the P frame.
  • the calculating module 620 is further configured to:
  • the quantization parameter threshold is determined according to the coding cost ratio, and the coding cost ratio is positively correlated with the quantization parameter threshold.
  • the calculating module 620 is further configured to:
  • the sum of the respective intra coding costs is determined as the first coding cost.
  • the calculating module 620 is further configured to:
  • Inter-predictive coding of the coding block to obtain an inter-frame coding cost
  • the sum of the inter-frame coding costs is determined as the second coding cost.
  • the calculating module 620 is further configured to downsample the ith video frame before dividing the ith video frame into the at least two coding blocks.
  • step 4043 the implementation details of downsampling the i-th video frame are described in detail in step 4043.
  • the calculating module 620 is further configured to:
  • the quantization threshold parameter is determined according to the encoding cost ratio, the two sets of threshold sets, and the first encoding resolution
  • the quantization threshold parameter is determined according to the encoding cost ratio, the two sets of threshold sets, and the second encoding resolution.
  • the calculating module 620 is further configured to:
  • a quantization threshold parameter is looked up in the found threshold set according to the coding cost ratio.
  • the calculating module 620 is further configured to:
  • a quantization threshold parameter is looked up in the found threshold set according to the coding cost ratio.
  • the determining module 630 is further configured to:
  • the quantization parameter is greater than the quantization parameter threshold, it is determined that the encoding resolution of the i-th video frame is the second encoding resolution.
  • step 409 the implementation details of determining the encoding resolution described above are described in detail in step 409.
  • the determining module 630 is further configured to: when calculating the quantization parameter, assume that the encoding resolution of the i-th video frame is the first encoding resolution. Then, the quantization parameter is determined as the final quantization parameter; if the quantization parameter is calculated to assume that the encoding resolution of the i-th video frame is the second encoding resolution, the quantization parameter is added to the first offset to obtain the final quantization parameter.
  • the determining module 630 is further configured to: when calculating the quantization parameter, assume that the encoding resolution of the i-th video frame is the first encoding resolution. Then, the quantization parameter is subtracted from the first offset to obtain a final quantization parameter; if the quantization parameter is calculated to assume that the encoding resolution of the i-th video frame is the second encoding resolution, the quantization parameter is determined as the final quantization parameter.
  • the video encoding apparatus determines the encoding resolution of the video frame according to the quantization parameter and the quantization parameter threshold by respectively calculating the quantization parameter and the quantization parameter threshold of one video frame, so that the same type of video
  • the frames may correspond to the same coding resolution, or may correspond to different coding resolutions, and solve the problem that the coding mode is not flexible when the same type of video frame corresponds to the same coding resolution, thereby improving the flexibility of the coding mode. Sex.
  • the quantization parameter threshold is related to the required picture quality. Therefore, determining the coding resolution of the video frame according to the quantization parameter and the quantization parameter threshold is equivalent to selecting the coding of the video frame according to the picture quality and the required picture quality. Resolution.
  • the quality of the required picture is high, the video frame is encoded with a higher first encoding resolution to improve the picture quality; when the required picture quality is low, the video frame is encoded with a lower second encoding resolution. To increase the compression ratio of the data.
  • the data amount of the video frame can be reduced, thereby improving the speed of the subsequent calculation of the first coding cost and the second coding cost, and finally improving the determination of the coding resolution. speed.
  • FIG. 7 is a structural block diagram of a terminal 700 provided by an exemplary embodiment of the present application.
  • the terminal 700 can be a portable mobile terminal, such as: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, a dynamic video expert compression standard audio layer 3), and an MP4 (Moving Picture Experts Group Audio Layer IV, dynamic Image experts compress standard audio layers 4) players, laptops or desktops.
  • Terminal 700 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal, and the like.
  • the terminal 700 includes a processor 701 and a memory 702.
  • Processor 701 can include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like.
  • the processor 701 may be configured by at least one of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). achieve.
  • the processor 701 may also include a main processor and a coprocessor.
  • the main processor is a processor for processing data in an awake state, which is also called a CPU (Central Processing Unit); the coprocessor is A low-power processor for processing data in standby.
  • the processor 701 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and rendering of the content that the display needs to display.
  • the processor 701 may also include an AI (Artificial Intelligence) processor for processing computational operations related to machine learning.
  • AI Artificial Intelligence
  • Memory 702 can include one or more computer readable storage media, which can be non-transitory. Memory 702 can also include high speed random access memory, as well as non-volatile memory, such as one or more disk storage devices, flash storage devices. In some embodiments, the non-transitory computer readable storage medium in memory 702 is configured to store at least one instruction for execution by processor 701 to implement the video encoding provided by the method embodiments of the present application. method.
  • the terminal 700 optionally further includes: a peripheral device interface 703 and at least one peripheral device.
  • the processor 701, the memory 702, and the peripheral device interface 703 can be connected by a bus or a signal line.
  • Each peripheral device can be connected to the peripheral device interface 703 via a bus, signal line or circuit board.
  • the peripheral device includes at least one of a radio frequency circuit 704, a touch display screen 705, a camera 706, an audio circuit 707, a positioning component 708, and a power source 709.
  • the peripheral device interface 703 can be used to connect at least one peripheral device associated with an I/O (Input/Output) to the processor 701 and the memory 702.
  • processor 701, memory 702, and peripheral interface 703 are integrated on the same chip or circuit board; in some other embodiments, any of processor 701, memory 702, and peripheral interface 703 or The two can be implemented on a separate chip or circuit board, which is not limited in this embodiment.
  • the radio frequency circuit 704 is configured to receive and transmit an RF (Radio Frequency) signal, also called an electromagnetic signal. Radio frequency circuit 704 communicates with the communication network and other communication devices via electromagnetic signals. The radio frequency circuit 704 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal.
  • the radio frequency circuit 704 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. Radio frequency circuit 704 can communicate with other terminals via at least one wireless communication protocol.
  • the wireless communication protocol includes, but is not limited to, a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and/or a WiFi (Wireless Fidelity) network.
  • the radio frequency circuit 704 may also include NFC (Near Field Communication) related circuitry, which is not limited in this application.
  • the display screen 705 is used to display a UI (User Interface).
  • the UI can include graphics, text, icons, video, and any combination thereof.
  • display 705 is a touch display
  • display 705 also has the ability to capture touch signals over the surface or surface of display 705.
  • the touch signal can be input to the processor 701 as a control signal for processing.
  • the display screen 705 can also be used to provide virtual buttons and/or virtual keyboards, also referred to as soft buttons and/or soft keyboards.
  • the display screen 705 may be one, and the front panel of the terminal 700 is disposed; in other embodiments, the display screen 705 may be at least two, respectively disposed on different surfaces of the terminal 700 or in a folded design; In still other embodiments, display screen 705 can be a flexible display screen disposed on a curved surface or a folded surface of terminal 700. Even the display screen 705 can be set to a non-rectangular irregular pattern, that is, a profiled screen.
  • the display screen 705 can be prepared by using an LCD (Liquid Crystal Display) or an OLED (Organic Light-Emitting Diode).
  • Camera component 706 is used to capture images or video.
  • camera assembly 706 includes a front camera and a rear camera.
  • the front camera is placed on the front panel of the terminal, and the rear camera is placed on the back of the terminal.
  • the rear camera is at least two, which are respectively a main camera, a depth camera, a wide-angle camera, and a telephoto camera, so as to realize the background blur function of the main camera and the depth camera, and the main camera Combine with a wide-angle camera for panoramic shooting and VR (Virtual Reality) shooting or other integrated shooting functions.
  • camera assembly 706 can also include a flash.
  • the flash can be a monochrome temperature flash or a two-color temperature flash.
  • the two-color temperature flash is a combination of a warm flash and a cool flash that can be used for light compensation at different color temperatures.
  • the audio circuit 707 can include a microphone and a speaker.
  • the microphone is used to collect sound waves of the user and the environment, and convert the sound waves into electrical signals for processing to the processor 701 for processing, or input to the radio frequency circuit 704 for voice communication.
  • the microphones may be multiple, and are respectively disposed at different parts of the terminal 700.
  • the microphone can also be an array microphone or an omnidirectional acquisition microphone.
  • the speaker is then used to convert electrical signals from processor 701 or radio frequency circuit 704 into sound waves.
  • the speaker can be a conventional film speaker or a piezoelectric ceramic speaker.
  • the audio circuit 707 can also include a headphone jack.
  • the location component 708 is used to locate the current geographic location of the terminal 700 to implement navigation or LBS (Location Based Service).
  • the positioning component 708 can be a positioning component based on a US-based GPS (Global Positioning System), a Chinese Beidou system, a Russian Greiner system, or an EU Galileo system.
  • Power source 709 is used to power various components in terminal 700.
  • the power source 709 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery.
  • the rechargeable battery can support wired charging or wireless charging.
  • the rechargeable battery can also be used to support fast charging technology.
  • terminal 700 also includes one or more sensors 710.
  • the one or more sensors 710 include, but are not limited to, an acceleration sensor 711, a gyro sensor 712, a pressure sensor 713, a fingerprint sensor 714, an optical sensor 715, and a proximity sensor 716.
  • the acceleration sensor 711 can detect the magnitude of the acceleration on the three coordinate axes of the coordinate system established by the terminal 700.
  • the acceleration sensor 711 can be used to detect components of gravity acceleration on three coordinate axes.
  • the processor 701 can control the touch display screen 705 to display the user interface in a landscape view or a portrait view according to the gravity acceleration signal collected by the acceleration sensor 711.
  • the acceleration sensor 711 can also be used for the acquisition of game or user motion data.
  • the gyro sensor 712 can detect the body direction and the rotation angle of the terminal 700, and the gyro sensor 712 can cooperate with the acceleration sensor 711 to collect the 3D motion of the user to the terminal 700. Based on the data collected by the gyro sensor 712, the processor 701 can implement functions such as motion sensing (such as changing the UI according to the user's tilting operation), image stabilization at the time of shooting, game control, and inertial navigation.
  • functions such as motion sensing (such as changing the UI according to the user's tilting operation), image stabilization at the time of shooting, game control, and inertial navigation.
  • the pressure sensor 713 may be disposed at a side border of the terminal 700 and/or a lower layer of the touch display screen 705.
  • the pressure sensor 713 When the pressure sensor 713 is disposed on the side frame of the terminal 700, the user's holding signal to the terminal 700 can be detected, and the processor 701 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor 713.
  • the operability control on the UI interface is controlled by the processor 701 according to the user's pressure operation on the touch display screen 705.
  • the operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.
  • the fingerprint sensor 714 is used to collect the fingerprint of the user.
  • the processor 701 identifies the identity of the user according to the fingerprint collected by the fingerprint sensor 714, or the fingerprint sensor 714 identifies the identity of the user according to the collected fingerprint. Upon identifying that the user's identity is a trusted identity, the processor 701 authorizes the user to perform related sensitive operations including unlocking the screen, viewing encrypted information, downloading software, paying and changing settings, and the like.
  • the fingerprint sensor 714 can be provided with the front, back or side of the terminal 700. When the physical button or vendor logo is provided on the terminal 700, the fingerprint sensor 714 can be integrated with the physical button or the manufacturer logo.
  • Optical sensor 715 is used to collect ambient light intensity.
  • the processor 701 can control the display brightness of the touch display 705 based on the ambient light intensity acquired by the optical sensor 715. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 705 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 705 is lowered.
  • the processor 701 can also dynamically adjust the shooting parameters of the camera assembly 706 according to the ambient light intensity collected by the optical sensor 715.
  • Proximity sensor 716 also referred to as a distance sensor, is typically disposed on the front panel of terminal 700.
  • Proximity sensor 716 is used to collect the distance between the user and the front side of terminal 700.
  • the proximity sensor 716 detects that the distance between the user and the front side of the terminal 700 is gradually decreasing
  • the touch screen 705 is controlled by the processor 701 to switch from the bright screen state to the screen state; when the proximity sensor 716 detects When the distance between the user and the front side of the terminal 700 gradually becomes larger, the processor 701 controls the touch display screen 705 to switch from the screen state to the bright screen state.
  • FIG. 7 does not constitute a limitation to the terminal 700, and may include more or less components than those illustrated, or may combine some components or adopt different component arrangements.
  • An embodiment of the present application provides a computer readable storage medium, where the storage medium stores at least one instruction, at least one program, a code set, or a set of instructions, the at least one instruction, the at least one program, and the A code set or set of instructions is loaded and executed by the processor to implement the video encoding method as described above.
  • An embodiment of the present application provides a video encoding apparatus including a processor and a memory, the memory storing at least one instruction loaded by the processor and executed to implement as described above Video encoding method.
  • the video encoding device when the video encoding device is a terminal-type electronic device, the structure of the video encoding device is described in detail in the embodiment shown in FIG. 7 for the structure of the terminal 700.
  • the video encoding apparatus provided by the foregoing embodiment is only illustrated by the division of each functional module in the video encoding, and in actual applications, the function allocation may be completed by different functional modules as needed. That is, the internal structure of the video encoding device is divided into different functional modules to complete all or part of the functions described above.
  • the video coding apparatus and the video coding method are provided in the same embodiment, and the specific implementation process is described in detail in the method embodiment, and details are not described herein again.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

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

Abstract

本申请实施例公开了一种视频编码方法、装置、存储介质及设备,属于编码技术领域。所述方法包括:获取待编码的视频,所述视频中包括按序排列的至少两个视频帧;对于至少两个视频帧中的第i个视频帧,计算所述第i个视频帧的量化参数和量化参数阈值,i为大于等于2的正整数;根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率,所述编码分辨率为第一编码分辨率或第二编码分辨率,所述第一编码分辨率是所述第i个视频帧采样时的分辨率,所述第二编码分辨率是对所述第i个视频帧进行下采样时的分辨率;以所述编码分辨率对所述第i个视频帧进行编码。本申请实施例提高了编码方式的灵活性,也提高了确定的编码分辨率的准确性。

Description

视频编码方法、装置、存储介质及设备
本申请要求于2018年04月27日提交的申请号为201810394329.9、发明名称为“视频编码方法、装置、存储介质及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及编码技术领域,特别涉及一种视频编码方法、装置、存储介质及设备。
背景技术
视频是由多个视频帧按序组成的视频帧序列。由于视频的数据量较大,所以,可以通过编码的方式对视频进行压缩,而编码时需要确定视频中每个视频帧的编码分辨率。下面对编码分辨率和视频帧的类型进行介绍。
相关技术提供了两种编码分辨率,第一编码分辨率是视频帧采样时的分辨率,第二编码分辨率是对该视频帧进行下采样时的分辨率。这里的下采样是指每间隔几个样值对样值序列取样一次,可见,第二编码分辨率低于第一编码分辨率。另一方面,相关技术提供了两种类型的视频帧,一类是I帧,另一类是P帧。I帧是帧内预测帧,其自带全部信息,无需参考其他帧即可进行编码;P帧是帧间预测帧,其需要参考其他帧才能进行编码。
基于上述两类视频帧的特点,终端在对每个视频帧进行编码时,需要确定该视频帧是I帧还是P帧,当该视频帧是I帧时,以第一编码分辨率对该视频帧进行编码;当该视频帧是P帧时,以第二编码分辨率对该视频帧进行编码。
上述方法中同类型的视频帧对应于同一种编码分辨率,导致编码方式不够灵活。
发明内容
本申请实施例提供了一种视频编码方法、装置、存储介质及设备,用于解决同类型的视频帧对应于同一种编码分辨率,导致编码方式不够灵活的问题。所述技术方案如下:
一方面,提供了一种视频编码方法,所述方法包括:
获取待编码的视频,所述视频中包括按序排列的至少两个视频帧;
对于所述至少两个视频帧中的第i个视频帧,计算所述第i个视频帧的量化参数和量化参数阈值,i为大于等于2的正整数;
根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率,所述编码分辨率为第一编码分辨率或第二编码分辨率,所述第一编码分辨率是所述第i个视频帧采样时的分辨率,所述第二编码分辨率是对所述第i个视频帧进行下采样时的分辨率;
以所述编码分辨率对所述第i个视频帧进行编码。
一方面,提供了一种视频编码装置,所述装置包括:
获取模块,用于获取待编码的视频,所述视频中包括按序排列的至少两个视频帧;
计算模块,用于对于所述至少两个视频帧中的第i个视频帧,计算所述第i个视频帧的量化参数和量化参数阈值,i为大于等于2的正整数;
确定模块,用于根据所述计算模块得到的所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率,所述编码分辨率为第一编码分辨率或第二编码分辨率,所述第一编码分辨率是所述第i个视频帧采样时的分辨率,所述第二编码分辨率是对所述第i个视频帧进行下采样时的分辨率;
编码模块,用于以所述确定模块确定的所述编码分辨率对所述第i个视频帧进行编码。
一方面,提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现如上所述的视频编码方法。
一方面,提供了一种视频编码设备,所述视频编码设备包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如上所述的视频编码方法。
本申请实施例提供的技术方案的有益效果至少包括:
通过分别计算一个视频帧的量化参数和量化参数阈值,根据量化参数和量化参数阈值确定视频帧的编码分辨率,这样,同类型的视频帧可能对应于同一种编码分辨率,也可能对应于不同的编码分辨率,解决了同类型的视频帧对应于同一种编码分辨率时,编码方式不够灵活的问题,从而提高了编码方式的灵活性。
由于量化参数和画面质量相关,量化参数阈值和需求画面质量相关,因此,根据量化参数和量化参数阈值确定视频帧的编码分辨率,也就相当于根据画面质量和需求画面质量选择视频帧的编码分辨率,可以提高确定的编码分辨率的准确性。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附 图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请部分实施例示出的确定编码分辨率的流程图;
图2是根据部分示例性实施例示出的一种视频编码系统的结构示意图;
图3是本申请一个实施例提供的视频编码方法的方法流程图;
图4是本申请另一实施例提供的视频编码方法的方法流程图;
图5是本申请另一实施例提供的计算编码代价比值的流程图;
图6是本申请一个实施例提供的视频编码装置的结构框图;
图7是本申请再一实施例提供的视频编码装置的结构框图。
具体实施方式
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。
在对本申请实施例进行详细地解释说明之前,先对本申请实施例的应用场景进行说明。
本申请实施例应用于视频压缩的应用场景中。在对视频进行压缩后,可以对视频进行传输,以节省视频在传输过程中所占用的带宽,并减少传输耗时;还可以对视频进行存储,以节省视频所占用的存储空间;还可以对视频进行其他操作,此处不作限定。
其中,视频传输包括实时传输和非实时传输,实时传输可以是利用即时通讯客户端进行实时视频通话、利用直播客户端进行实时直播等;非实时传输可以是视频上传、下载等。
本申请实施例概括来说可以分为五个步骤,第一步101是帧内/帧间预编码代价分析,以确定编码代价比值;第二步102是根据编码代价比值估计量化参数;第三步103是计算量化参数阈值;第四步104是根据量化参数和量化参数阈值选择编码分辨率;第五步105是以选出的编码分辨率对视频帧进行编码,请参考图1。其中,每个步骤的详细解释详见下面实施例中的描述。
本申请实施例中,视频中的各个I帧可能对应于同种编码分辨率,也可能对应于不同的编码分辨率;视频中的各个P帧可能对应于同种编码分辨率,也可能对应于不同的编码分辨率。即,同类型的视频帧可能对应于同种编码分辨率,也可能对应于不同的编码分辨率,从而提高了编码方式的灵活性。且由于量化参数和画面质量相关,量化参数阈值和需求画面质量相关,因此,根据量化参数和量化参数阈值确定视频帧的编码分辨率,也就相当于根据画 面质量和需求画面质量选择视频帧的编码分辨率,可以提高确定的编码分辨率的准确性。
下面对本申请实施例的系统架构进行说明。
请参考图2,其示出了本申请实施例提供的一种视频编码系统的结构示意图,以该视频编码系统应用于利用即时通讯客户端进行实时视频通话的场景中为例,则该视频编码系统至少包括第一终端210、第二终端220和服务器230。第一终端210与服务器230通过有线网络或无线网络建立连接,第二终端220与服务器230通过有线网络或无线网络建立连接。
第一终端210是具有视频数据流收发功能的设备,比如智能手机。第一终端210中安装有即时通讯客户端,比如微信客户端、QQ客户端等。
第二终端220是具有视频数据流收发功能的设备,比如智能手机。第二终端220与第一终端210中至少安装有一个相同的即时通讯客户端,且第二终端220中的即时通讯客户端与第一终端210中的即时通讯客户端可以通信。
服务器230是即时通讯客户端的后台服务器,可以是一台服务器或多台服务器组成的服务器集群或云计算中心。
本申请实施例中,可以由第一终端210通过服务器230向第二终端220发起实时视频通话;也可以由第二终端220通过服务器230向第一终端210发起实时视频通话。
在实时视频通话接通后,下面对使用第一终端210的第一用户和使用第二终端220的第二用户进行实时视频通话的过程进行介绍。第一终端210通过摄像头对第一用户的通话过程进行拍摄,得到第一视频,采用本申请实施例提供的视频编码方法对该第一视频进行编码,将编码后得到的第一视频数据流发送给服务器230,服务器230将该第一视频数据流转发给第二终端220,第二终端220根据该编码方式对应的解码方式对该第一视频数据流进行解码,并对解码后得到的第一视频进行播放。同时,第二终端220通过摄像头对第二用户的通话过程进行拍摄,得到第二视频,采用本申请实施例提供的编码方式对该第二视频进行编码,将编码后得到的第二视频数据流发送给服务器230,服务器230将该第二视频数据流转发给第一终端210,第一终端210根据该编码方式对应的解码方式对该第二视频数据流进行解码,并对解码后得到的第二视频进行播放。
可选的,第一终端210除了播放第二视频,还可以播放自身拍摄的第一视频,即,在第一终端210的显示界面的第一区域内播放第二视频,在第二区域内播放第一视频。同理,第二终端220除了播放第一视频,还可以播放自身拍摄的第二视频,即,在第二终端220的显示界面的第一区域内播放第一视频,在第二区域内播放第二视频。其中,第一终端210和第二终端220的显示界面如图2所示。
请参考图3,其示出了本申请一个实施例提供的视频编码方法的方法流程图,该视频编码方法可以应用于图2所示的第一终端或第二终端中。该视频编码方法,包括:
步骤301,获取待编码的视频,该视频中包括按序排列的至少两个视频帧。
视频可以是终端拍摄得到的,也可以是终端从网络中下载得到的,还可以是终端从其他设备获取到的,本实施例不对视频的来源作限定。
视频是包括按序排列的至少两个视频帧的视频帧序列。这里的按序排列是指按照各个视频帧的拍摄顺序排列,即,按照各个视频帧的拍摄时间由早到晚的顺序排列。
对于视频帧序列中的第一个视频帧,终端默认以第一编码分辨率对该视频帧进行编码;对于视频帧序列中剩余的视频帧,终端依次从该视频帧序列中读取一个视频帧,将该视频帧作为第i个视频帧,再执行步骤302-303来选择该第i个视频帧的编码分辨率,最后执行304来以选出的该编码分辨率对该第i个视频帧进行编码,i为大于等于2的正整数。其中,编码分辨率为第一编码分辨率或第二编码分辨率,详见步骤303中的解释。
步骤302,对于至少两个视频帧中的第i个视频帧,计算第i个视频帧的量化参数和量化参数阈值。
量化是指将连续信号采样为离散信号的处理方式,以减少需要编码的数据量,达到压缩数据的目的。
量化参数是量化视频帧的过程中涉及的参数。
量化参数是用于表示量化精度的参数。其中,量化参数与量化精度呈负相关关系。即,量化参数越小,表示量化越精细,此时的画面质量较好,数据的压缩比不高;量化参数越大,表示量化越粗糙,此时的画面质量较差,数据的压缩比较高。
量化参数是量化步长对应的序号。比如,H.264(Moving Picture Expert Group-4Advanced Video Codec,运动图像专家组-4高级视频编码)中有52个量化步长,则量化参数的数值为0~51,每个量化参数用于标识52个量化步长中的一个量化步长。
量化参数阈值是用于表示需求画面质量的阈值,这里的需求画面质量是用户主观上能接受的画面质量。其中,量化参数阈值与需求画面质量呈正相关关系。即,需求画面质量越低,量化参数阈值越小;需求画面质量越高,量化参数阈值越大。
这是因为,人眼对静止场景的画面质量损失敏感,对运动场景的画面质量损失不敏感,所以,人眼对静止场景下的视频帧的需求画面质量的要求较高,终端可以对静止场景下的视频帧设置较大的量化参数阈值,以倾向于采用第一编码分辨率进行编码,从而提高画面质量;人眼对运动场景下的视频帧的需求画面质量的要求较低,终端可以对运动场景下的视频帧设 置较小的量化参数阈值,以倾向于采用第二编码分辨率进行编码,从而提高数据的压缩比。
本实施例中,对于至少两个视频帧中的第i个视频帧,终端分别计算第i个视频帧的一个量化参数和一个量化参数阈值,这里的量化参数是终端估算出来的,可能与实际的量化参数不同。其中,终端计算量化参数的内容详见步骤402或403中的描述,计算量化参数阈值的内容详见步骤404-407中的描述。
步骤303,根据量化参数和量化参数阈值确定第i个视频帧的编码分辨率。
编码分辨率为第一编码分辨率或第二编码分辨率,第一编码分辨率是第i个视频帧采样时的分辨率,也可以称为全分辨率;第二编码分辨率是对第i个视频帧进行下采样时的分辨率,也可以称为下采样分辨率。其中,第二编码分辨率小于第一编码分辨率。
步骤304,以该编码分辨率对第i个视频帧进行编码。
当以第一编码分辨率对第i个视频帧进行编码时,画面质量较好,数据的压缩比较低;当以第二编码分辨率对第i个视频帧进行编码时,画面质量较差,数据的压缩比较高。
综上所述,本申请实施例提供的视频编码方法,通过分别计算一个视频帧的量化参数和量化参数阈值,根据量化参数和量化参数阈值确定视频帧的编码分辨率,这样,同类型的视频帧可能对应于同一种编码分辨率,也可能对应于不同的编码分辨率,解决了同类型的视频帧对应于同一种编码分辨率时,编码方式不够灵活的问题,从而提高了编码方式的灵活性。
由于量化参数和画面质量相关,量化参数阈值和需求画面质量相关,因此,根据量化参数和量化参数阈值确定视频帧的编码分辨率,也就相当于根据画面质量和需求画面质量选择视频帧的编码分辨率,可以提高确定的编码分辨率的准确性。
请参考图4,其示出了本申请另一实施例提供的视频编码方法的方法流程图,该视频编码方法可以应用于图2所示的第一终端或第二终端中。该视频编码方法,包括:
步骤401,获取待编码的视频,该视频中包括按序排列的至少两个视频帧。
视频可以是终端拍摄得到的,也可以是终端从网络中下载得到的,还可以是终端从其他设备获取到的,本实施例不对视频的来源作限定。
视频是包括按序排列的至少两个视频帧的视频帧序列。这里的按序排列是指按照各个视频帧的拍摄顺序排列,即,按照各个视频帧的拍摄时间由早到晚的顺序排列。
对于视频帧序列中的第一个视频帧,终端默认以第一编码分辨率对该视频帧进行编码;对于视频帧序列中剩余的视频帧,终端依次从该视频帧序列中读取一个视频帧,将该视频帧作为第i个视频帧,再执行步骤402-408来选择该第i个视频帧的编码分辨率,最后执行步骤409来以选出的该编码分辨率对该第i个视频帧进行编码,i为大于等于2的正整数。其中, 编码分辨率为第一编码分辨率或第二编码分辨率,第一编码分辨率是视频帧采样时的分辨率,第二编码分辨率是对该视频帧进行下采样时的分辨率,详见步骤303中的描述。
步骤402,对于至少两个视频帧中的第i个视频帧,当第i个视频帧的编码模式是固定质量编码模式时,读取设定的量化参数,将该量化参数确定为该第i个视频帧的量化参数,执行步骤404。
固定质量编码模式是指以恒定画面质量对视频帧进行编码的模式。也即,若以固定质量编码模式对每个视频帧进行编码,则编码后每个视频帧的画面质量恒定。
由于视频帧的画面质量和量化参数相关,当画面质量恒定时,也就意味着量化参数恒定,所以,可以预先对固定质量编码模式的视频帧设定恒定的量化参数。即,当第i个视频帧的编码模式是固定质量编码模式时,第i个视频帧的量化参数是预先设定的,终端直接读取即可获得该第i个视频帧的量化参数。
需要说明的是,不同编码分辨率对应于不同的量化参数,所以,在读取量化参数之前,终端还需要假定第i个视频帧的编码分辨率,读取与该编码分辨率对应的量化参数。其中,第一编码分辨率对应的量化参数大于第二编码分辨率对应的量化参数。比如,第一编码分辨率对应的量化参数为33,第二编码分辨率对应的量化参数为27。
实时视频通话的场景中的视频帧大多数以第一编码分辨率进行编码,以提高画面质量,所以,可选的,终端可以假定第i个视频帧的编码分辨率为第一编码分辨率。当然,终端也可以假定第i个视频帧的编码分辨率为第二编码分辨率,本实施例不作限定。
步骤403,对于至少两个视频帧中的第i个视频帧,当第i个视频帧的编码模式是固定码率编码模式时,计算第i个视频帧中第一个编码块的量化参数,将该第一个编码块的量化参数确定为该第i个视频帧的量化参数。
固定码率编码模式是以恒定比特率对视频帧进行编码的模式。也即,若以固定码率编码模式每一秒内的多个视频帧进行编码,则编码后每一秒内的所有视频帧的总大小恒定。
由于以恒定的比特率对视频帧进行编码后,视频帧的画面质量不稳定,而画面质量和量化参数相关,所以,终端需要根据画面质量来动态确定量化参数。即,当第i个视频帧的编码模式是固定码率编码模式时,终端可以动态计算第i个视频帧的量化参数。
需要说明的是,不同编码分辨率对应于不同的量化参数,所以,在计算量化参数之前,终端还需要假定第i个视频帧的编码分辨率,再基于假定的编码分辨率计算量化参数。其中,假定第一编码分辨率和第二编码分辨率时对量化参数的算法相同。
其中,计算第i个视频帧中第一个编码块的量化参数,可以包括如下四种方案:
1),若第i-1个视频帧为I帧且以第二编码分辨率对第i-1个视频帧进行了编码,则计算 第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移和第二偏移;将平均值、第一偏移和第二偏移之和确定为第一个编码块的量化参数。
若第i-1个视频帧的编码模式为固定质量编码模式,则在编码过程中,终端将该第i-1个视频帧划分为至少两个编码块,每个编码块的量化参数均为设定的量化参数,其为每个编码块设定的量化参数相等,所以,所有编码块实际的量化参数的平均值仍然为该设定的量化参数。
若第i-1个视频帧的编码模式为固定码率编码模式,则在编码过程中,终端将该第i-1个视频帧划分为至少两个编码块,根据编码器中设定的算法计算每个编码块实际的量化参数,将所有的量化参数相加后再除以编码块的数量,得到平均值。
需要说明的是,在对第i-1个视频帧进行预编码时,会先计算该第i-1个视频帧的第一个编码块的量化参数,再将该量化参数假设为第i-1个视频帧的量化参数。在实际编码时,终端会计算第i-1个视频帧中每一个编码块实际的量化参数,这里计算得到的实际的量化参数与之前假设的量化参数不同,本步骤中计算是的编码过程中得到的实际的量化参数的平均值。
第一偏移是第一编码分辨率对应的量化参数和第二编码分辨率对应的量化参数之间的偏移,可以是经验值,也可以是根据公式计算得到,本实施例不作限定。本实施例中将第一偏移记为QP delta。其中,第一编码分辨率、第二编码分辨率和第一偏移之间具有以下关系:将第一编码分辨率的量化参数减去第一偏移得到第二编码分辨率的量化参数,也即,将第二编码分辨率的量化参数加上第一偏移得到第一编码分辨率的量化参数。
第二偏移是I帧和P帧之间量化参数的偏移,可以是经验值,也可以是根据公式计算得到,本实施例不作限定。本实施例中将第二偏移记为QP offset-I/P
在得到平均值、第一偏移和第二偏移后,将这三者之和作为第一个编码块的量化参数。
2),若第i-1个视频帧为I帧且以第一编码分辨率对第i-1个视频帧进行了编码,则计算第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第二偏移;将平均值和第二偏移之和确定为第一个编码块的量化参数。
其中,计算平均值和获取第二偏移的流程详见上述描述,此处不作赘述。
在得到平均值和第二偏移后,将这两者之和作为第一个编码块的量化参数。
3),若第i-1个视频帧为P帧且以第一编码分辨率对第i-1个视频帧进行了编码,则计算第i-1个视频帧中所有编码块实际的量化参数的平均值;将平均值确定为第一个编码块的量化参数。
其中,计算平均值的流程详见上述描述,此处不作赘述。
在得到平均值后,将平均值作为第一个编码块的量化参数。
4),若第i-1个视频帧为P帧且以第二编码分辨率对第i-1个视频帧进行了编码,则计算第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移;将平均值和第一偏移之和确定为第一个编码块的量化参数。
其中,计算平均值和获取第一偏移的流程详见上述描述,此处不作赘述。
在得到平均值和第一偏移后,将这两者之和作为第一个编码块的量化参数。
本实施例中,可以根据第i-1个视频帧的类型和编码分辨率从上述四种方案中选择一种方案,再采用选出的一种方案来计算第i个视频帧中第一个编码块的量化参数。
步骤404,计算假定第i个视频帧为I帧时的第一编码代价。
本实施例中,无论第i个视频帧实际是I帧还是P帧,都需要假定第i个视频帧为I帧来计算第一编码代价,假定第i个视频帧为P帧来计算第二编码代价。
其中,计算假定第i个视频帧为I帧时的第一编码代价,可以包括如下几个步骤:
步骤4041,将第i个视频帧划分为至少两个编码块。
其中,终端可以根据不同的算法将第i个视频帧划分为多个编码块,本实施例不作限定。其中,不同算法得到的编码块的数量可以相同,也可以不同。
在一种可能的实现方式中,终端将第i个视频帧划分为8*8个编码块。
步骤4042,对编码块进行帧内预测编码,得到帧内编码代价。
其中,帧内编码代价的算法有很多种,下面对其中的两种算法进行介绍。
在第一种算法中,帧内编码代价等于编码块中所有像素的预测残差的绝对值之和。
在第二种算法中,帧内编码代价cost=D+λ*R,其中,D为编码块的失真程度,可以用该编码块中所有像素的编码重建图像和原始图像的差值的绝对值表示,λ为拉格朗日系统数,R为编码块占用的比特数。
步骤4043,将各个帧内编码代价之和确定为第一编码代价。
本实施例中,将第一编码代价记为Icost。
可选的,在将第i个视频帧划分为至少两个编码块之前,该方法还包括:对第i个视频帧进行下采样。
其中,终端可以以简单的下采样算法对第i个视频帧进行下采样,以减小第i个视频帧的数据量,从而提高后续计算第一编码代价和第二编码代价的速度,最终提高确定编码分辨率的速度。
在一种可能的实现方式中,终端对第i个视频帧的长和宽进行2:1的下采样。当然,终端也可以进行其他比例的下采样,本实施例不作限定。
步骤405,计算假定第i个视频帧为P帧时的第二编码代价。
其中,计算假定第i个视频帧为P帧时的第二编码代价,可以包括如下几个步骤:
步骤4051,将第i个视频帧划分为至少两个编码块。
其中,终端可以根据不同的算法将第i个视频帧划分为多个编码块,本实施例不作限定。其中,不同算法得到的编码块的数量可以相同,也可以不同。
需要说明的是,本步骤中划分编码块的算法与步骤4041中划分编码块的算法相同,使得本步骤中得到的各个编码块与步骤4041中得到的各个编码块相同。
在一种可能的实现方式中,终端也将第i个视频帧划分为8*8个编码块。
可选的,若终端先执行步骤4041,则终端可以直接读取步骤4041的执行结果,得到至少两个编码块,以避免重复划分编码块所消耗的时间,提高编码效率。
步骤4052,对编码块进行帧间预测编码,得到帧间编码代价。
其中,帧间编码代价和帧内编码代价的算法相同,此处不作赘述。
步骤4053,将各个帧间编码代价之和确定为第二编码代价。
本实施例中,将第二编码代价记为Pcost。
需要说明的是,本实施例不限定步骤404和步骤405的先后执行顺序。即,终端可以先计算第一编码代价,再计算第二编码代价;也可以先计算第二编码代价,再计算第一编码代价;还可以同时计算第一编码代价和第二编码代价。
步骤406,将第一编码代价除以第二编码代价,得到编码代价比值。
本实施例中将编码代价比值记为IPcost,则IPcost=Icost/Pcost。
请参考图5,其示出了编码代价比值的计算过程。图5中,终端先对第i个视频帧进行下采样,再计算I帧编码代价(即假定第i个视频帧是I帧时计算得到的第一编码代价)和P帧编码代价(即假定第i个视频帧是P帧时计算得到的第二编码代价),将I帧编码代价除以P帧编码代价,得到编码代价比值。
步骤407,根据编码代价比值确定量化参数阈值。
本实施例中,终端可以将编码代价比值输入公式来计算量化参数阈值,或者,可以设定编码代价比值与量化参数阈值的对应关系,终端根据编码代价比值在该对应关系中查找量化参数阈值,本实施例不作限定。这里将量化参数阈值记为QP TH
其中,无论以哪种方式确定量化阈值参数,编码代价比值与量化参数阈值都呈正相关关系。这是因为,下采样本身就会损失部分视频信息,而人眼对静止场景的画面质量损失敏感,对运动场景的画面质量损失不敏感,所以,终端可以对静止场景下的视频帧设置较大的量化参数阈值,以倾向于采用第一编码分辨率进行编码,从而提高画面质量;对运动场景下的视频帧设置较小的量化参数阈值,以倾向于采用第二编码分辨率进行编码,从而提高数据的压 缩比。
一般的,编码代价比值越小,表示当前场景运动越剧烈,需要设置较小的量化参数阈值,以倾向于采用第二编码分辨率进行编码;反之,编码代价比值越大,表示当前场景越静止,需要设置较大的量化参数阈值,以倾向于采用第一编码分辨率进行编码。
需要说明的是,量化参数阈值和编码分辨率对应,即不同的编码分辨率对应于不同的量化参数阈值。一般来说,对应于第一编码分辨率的量化参数阈值减去对应于第二编码分辨率的量化参数阈值的差值等于第一偏移。
步骤408,当量化参数小于等于量化参数阈值时,确定第i个视频帧的编码分辨率为第一编码分辨率;当量化参数大于量化参数阈值时,确定第i个视频帧的编码分辨率为第二编码分辨率。
本实施例中,由于量化参数与编码分辨率对应,量化参数阈值也与编码分辨率对应,所以,在比较量化参数和量化参数阈值之前,还需要保证量化参数和量化参数阈值对应于同一种编码分辨率。
本实施例提供了两种实现方式,第一种实现方式是设定一组阈值集合且该阈值集合对应于一种编码分辨率,在得到量化参数后,根据阈值集合所对应的编码分辨率对该量化参数进行转换,根据转换后得到的最终的量化参数和该阈值集合确定量化参数阈值。第二种实现方式是设定两组阈值集合且两组阈值集合对应于不同的编码分辨率,在得到量化参数后,先确定该量化参数对应的编码分辨率,再基于该编码分辨率从两组阈值集合中选择一组阈值集合,根据量化参数和查找到的阈值集合确定量化参数阈值。其中,阈值集合是包括至少两个量化参数阈值的集合,且阈值集合中定义有量化参数阈值和编码代价比值之间的第一对应关系。比如,
Figure PCTCN2019078432-appb-000001
表示的阈值集合包括两个量化阈值参数,分别是33和36,且33对应于小于3的编码代价比值,36对应于大于等于3的编码代价比值。
下面对这两种实现方式进行介绍。
第一种实现方式:
1)当存在一组阈值集合且该阈值集合与第一编码分辨率对应时,在根据量化参数和量化参数阈值确定第i个视频帧的编码分辨率之前,该方法还包括:若计算量化参数时假定第i个视频帧的编码分辨率是第一编码分辨率,则将该量化参数确定为最终的量化参数;若计算量化参数时假定第i个视频帧的编码分辨率是第二编码分辨率,则将该量化参数加上第一偏移得到最终的量化参数。
比如,存在的一组阈值集合对应于第一编码分辨率,若计算量化参数QP时假定第i个视 频帧的编码分辨率是第一编码分辨率,则将该QP作为最终的量化参数,执行步骤409;若计算量化参数QP时假定第i个视频帧的编码分辨率是第二编码分辨率,则将该QP+QP delta作为最终的量化参数,执行步骤409。
2)当存在一组阈值集合且该阈值集合与第二编码分辨率对应时,则在根据量化参数和量化参数阈值确定第i个视频帧的编码分辨率之前,该方法还包括:若计算量化参数时假定第i个视频帧的编码分辨率是第一编码分辨率,则将该量化参数减去第一偏移得到最终的量化参数;若计算量化参数时假定第i个视频帧的编码分辨率是第二编码分辨率,则将该量化参数确定为最终的量化参数。
比如,存在的一组阈值集合对应于第二编码分辨率,若计算量化参数QP时假定第i个视频帧的编码分辨率是第一编码分辨率,则将该QP-QP delta作为最终的量化参数,执行步骤409;若计算量化参数QP时假定第i个视频帧的编码分辨率是第二编码分辨率,则将该QP作为最终的量化参数,执行步骤409。
第二种实现方式:
1)当存在两组阈值集合且两组阈值集合对应于不同的编码分辨率时,若计算量化参数时假定第i个视频帧的编码分辨率是第一编码分辨率,则根据编码代价比值、两组阈值集合和第一编码分辨率确定量化阈值参数。其中,根据编码代价比值、两种阈值集合和第一编码分辨率确定量化阈值参数,包括:在两组阈值集合中查找第一编码分辨率所对应的阈值集合;根据编码代价比值在查找到的该阈值集合中查找量化阈值参数。
本实施例中,预先设定两组阈值集合和不同的编码分辨率之间的第二对应关系,则在根据编码代价比值、两种阈值集合和第一编码分辨率确定量化阈值参数时,终端先基于第二对应关系,从两组阈值集合中查找与第一编码分辨率对应的一组阈值集合,再基于该组阈值集合中所定义的量化参数阈值和编码代价比值之间的第一对应关系,查找与该编码代价比值对应的一个量化参数阈值。
比如,在第二对应关系中,对应于第一编码分辨率的阈值集合为
Figure PCTCN2019078432-appb-000002
对应于第二编码分辨率的阈值集合为
Figure PCTCN2019078432-appb-000003
若计算量化参数时假定第i个视频帧的编码分辨率是第一编码分辨率,则选择的阈值集合为
Figure PCTCN2019078432-appb-000004
若此时的编码代价比值小于3,则得到的量化参数阈值为33;若此时的编码代价比值大于等于3,则得到的量化参数阈值为36。
2)当存在两组阈值集合且两组阈值集合对应于不同的编码分辨率时,若计算量化参数时假定第i个视频帧的编码分辨率是第二编码分辨率,则根据编码代价比值、两组阈值集合和第二编码分辨率确定量化阈值参数。其中,根据编码代价比值、两组阈值集合和第二编码分辨率确定量化阈值参数,包括:在两组阈值集合中查找第二编码分辨率所对应的阈值集合;根据编码代价比值在查找到的该阈值集合中查找量化阈值参数。
本实施例中,预先设定两组阈值集合和不同的编码分辨率之间的第二对应关系,则在根据编码代价比值、两种阈值集合和第二编码分辨率确定量化阈值参数时,终端先基于第二对应关系,从两组阈值集合中查找与第二编码分辨率对应的一组阈值集合,再基于该组阈值集合中所定义的量化参数阈值和编码代价比值之间的第一对应关系,查找与该编码代价比值对应的一个量化参数阈值。
比如,在第二对应关系中,对应于第一编码分辨率的阈值集合为
Figure PCTCN2019078432-appb-000005
对应于第二编码分辨率的阈值集合为
Figure PCTCN2019078432-appb-000006
若计算量化参数时假定第i个视频帧的编码分辨率是第二编码分辨率,则选择的阈值集合为
Figure PCTCN2019078432-appb-000007
若此时的编码代价比值小于3,则得到的量化参数阈值为27;若此时的编码代价比值大于等于3,则得到的量化参数阈值为30。
步骤409,以该编码分辨率对第i个视频帧进行编码。
当以第一编码分辨率对第i个视频帧进行编码时,画面质量较好,数据的压缩比较低;当以第二编码分辨率对第i个视频帧进行编码时,画面质量较差,数据的压缩比较高。
本实施例可以采用H.264、H.265、AVS(Audio Video coding Standard,信源编码标准)等视频压缩标准,基于上述确定的编码分辨率对视频帧进行编码。
综上所述,本申请实施例提供的视频编码方法,通过分别计算一个视频帧的量化参数和量化参数阈值,根据量化参数和量化参数阈值确定视频帧的编码分辨率,这样,同类型的视频帧可能对应于同一种编码分辨率,也可能对应于不同的编码分辨率,解决了同类型的视频帧对应于同一种编码分辨率时,编码方式不够灵活的问题,从而提高了编码方式的灵活性。
由于量化参数和画面质量相关,量化参数阈值和需求画面质量相关,因此,根据量化参数和量化参数阈值确定视频帧的编码分辨率,也就相当于根据画面质量和需求画面质量选择视频帧的编码分辨率。当需求画面质量较高时,以较高的第一编码分辨率对视频帧进行编码,以提高画面质量;当需求画面质量较低时,以较低的第二编码分辨率对视频帧进行编码,以 提高数据的压缩比。
通过先对视频帧进行下采样,再计算视频帧的编码代价比值,可以减小视频帧的数据量,从而提高后续计算第一编码代价和第二编码代价的速度,最终提高确定编码分辨率的速度。
请参考图6,其示出了本申请一个实施例提供的视频编码装置的结构框图,该视频编码装置可以应用于图2所示的第一终端或第二终端中。该视频编码装置,包括:
获取模块610,用于获取待编码的视频,视频中包括按序排列的至少两个视频帧;其中,该获取模块610的实现细节详见步骤301或步骤401中的描述。
计算模块620,用于对于至少两个视频帧中的第i个视频帧,计算第i个视频帧的量化参数和量化参数阈值,i为大于等于2的正整数;其中,该计算模块620中计算第i个视频帧的量化参数的实现细节详见步骤302或步骤402中的描述,该计算模块中计算第i个视频帧的量化参数阈值的实现细节详见步骤302或步骤403-407中的描述。
确定模块630,用于根据计算模块620得到的量化参数和量化参数阈值确定第i个视频帧的编码分辨率,编码分辨率为第一编码分辨率或第二编码分辨率,第一编码分辨率是第i个视频帧采样时的分辨率,第二编码分辨率是对第i个视频帧进行下采样时的分辨率;其中,该确定模块630的实现细节详见步骤303或步骤408中的描述。
编码模块640,用于以确定模块630确定的编码分辨率对第i个视频帧进行编码。其中,该编码模块640的实现细节详见步骤304或步骤409中的描述。
可选的,计算模块620,还用于:
当第i个视频帧的编码模式是固定质量编码模式时,读取设定的量化参数,将量化参数确定为第i个视频帧的量化参数;其实现细节详见步骤402中的描述;
当第i个视频帧的编码模式是固定码率编码模式时,计算第i个视频帧中第一个编码块的量化参数,将第一个编码块的量化参数确定为第i个视频帧的量化参数,其实现细节详见步骤403中的描述。
可选的,计算模块620,还用于:
若第i-1个视频帧为I帧且以第二编码分辨率对第i-1个视频帧进行了编码,则计算第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移和第二偏移;将平均值、第一偏移和第二偏移之和确定为第一个编码块的量化参数;和/或,
若第i-1个视频帧为I帧且以第一编码分辨率对第i-1个视频帧进行了编码,则计算第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第二偏移;将平均值和第二偏移之和确定为第一个编码块的量化参数;和/或,
若第i-1个视频帧为P帧且以第一编码分辨率对第i-1个视频帧进行了编码,则计算第i-1个视频帧中所有编码块实际的量化参数的平均值;将平均值确定为第一个编码块的量化参数;和/或,
若第i-1个视频帧为P帧且以第二编码分辨率对第i-1个视频帧进行了编码,则计算第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移;将平均值和第一偏移之和确定为第一个编码块的量化参数;
其中,第一偏移是第一编码分辨率对应的量化参数和第二编码分辨率对应的量化参数之间的偏移,第二偏移是I帧和P帧之间量化参数的偏移。
需要说明的是,上述计算第i个视频帧中第一个编码块的量化参数的四种实现方式的实现细节详见步骤403中的描述。
可选的,计算模块620,还用于:
计算假定第i个视频帧为I帧时的第一编码代价;
计算假定第i个视频帧为P帧时的第二编码代价;
将第一编码代价除以第二编码代价,得到编码代价比值;
根据编码代价比值确定量化参数阈值,编码代价比值与量化参数阈值呈正相关关系。
需要说明的是,上述计算第i个视频帧的量化参数阈值的实现细节详见步骤404-407中的描述。
可选的,计算模块620,还用于:
将第i个视频帧划分为至少两个编码块;
对编码块进行帧内预测编码,得到帧内编码代价;
将各个帧内编码代价之和确定为第一编码代价。
需要说明的是,上述计算第一编码代价的实现细节详见步骤404中的描述。
可选的,计算模块620,还用于:
将第i个视频帧划分为至少两个编码块;
对编码块进行帧间预测编码,得到帧间编码代价;
将各个帧间编码代价之和确定为第二编码代价。
需要说明的是,上述计算第二编码代价的实现细节详见步骤405中的描述。
可选的,计算模块620,还用于在将第i个视频帧划分为至少两个编码块之前,对第i个视频帧进行下采样。
需要说明的是,上述对第i个视频帧进行下采样的实现细节详见步骤4043中的描述。
可选的,当存在两组阈值集合且两组阈值集合对应于不同的编码分辨率时,计算模块620, 还用于:
若计算量化参数时假定第i个视频帧的编码分辨率是第一编码分辨率,则根据编码代价比值、两组阈值集合和第一编码分辨率确定量化阈值参数;
若计算量化参数时假定第i个视频帧的编码分辨率是第二编码分辨率,则根据编码代价比值、两组阈值集合和第二编码分辨率确定量化阈值参数。
需要说明的是,上述计算量化参数阈值的实现细节详见步骤408中第二种实现方式的描述。
可选的,计算模块620,还用于:
在两组阈值集合中查找第一编码分辨率所对应的阈值集合;
根据编码代价比值在查找到的阈值集合中查找量化阈值参数。
需要说明的是,上述计算量化参数阈值的实现细节详见步骤408中第二种实现方式中的1)中的描述。
可选的,计算模块620,还用于:
在两组阈值集合中查找第二编码分辨率所对应的阈值集合;
根据编码代价比值在查找到的阈值集合中查找量化阈值参数。
需要说明的是,上述计算量化参数阈值的实现细节详见步骤408中第二种实现方式中的2)中的描述。
可选的,确定模块630,还用于:
当量化参数小于等于量化参数阈值时,确定第i个视频帧的编码分辨率为第一编码分辨率;
当量化参数大于量化参数阈值时,确定第i个视频帧的编码分辨率为第二编码分辨率。
需要说明的是,上述确定编码分辨率的实现细节详见步骤409中的描述。
可选的,当存在一组阈值集合且阈值集合与第一编码分辨率对应时,确定模块630,还用于若计算量化参数时假定第i个视频帧的编码分辨率是第一编码分辨率,则将量化参数确定为最终的量化参数;若计算量化参数时假定第i个视频帧的编码分辨率是第二编码分辨率,则将量化参数加上第一偏移得到最终的量化参数。
需要说明的是,上述计算量化参数阈值的实现细节详见步骤408中第一种实现方式中的1)中的描述。
可选的,当存在一组阈值集合且阈值集合与第二编码分辨率对应时,确定模块630,还用于若计算量化参数时假定第i个视频帧的编码分辨率是第一编码分辨率,则将量化参数减去第一偏移得到最终的量化参数;若计算量化参数时假定第i个视频帧的编码分辨率是第二 编码分辨率,则将量化参数确定为最终的量化参数。
需要说明的是,上述计算量化参数阈值的实现细节详见步骤408中第一种实现方式中的2)中的描述。
综上所述,本申请实施例提供的视频编码装置,通过分别计算一个视频帧的量化参数和量化参数阈值,根据量化参数和量化参数阈值确定视频帧的编码分辨率,这样,同类型的视频帧可能对应于同一种编码分辨率,也可能对应于不同的编码分辨率,解决了同类型的视频帧对应于同一种编码分辨率时,编码方式不够灵活的问题,从而提高了编码方式的灵活性。
由于量化参数和画面质量相关,量化参数阈值和需求画面质量相关,因此,根据量化参数和量化参数阈值确定视频帧的编码分辨率,也就相当于根据画面质量和需求画面质量选择视频帧的编码分辨率。当需求画面质量较高时,以较高的第一编码分辨率对视频帧进行编码,以提高画面质量;当需求画面质量较低时,以较低的第二编码分辨率对视频帧进行编码,以提高数据的压缩比。
通过先对视频帧进行下采样,再计算视频帧的编码代价比值,可以减小视频帧的数据量,从而提高后续计算第一编码代价和第二编码代价的速度,最终提高确定编码分辨率的速度。
图7示出了本申请一个示例性实施例提供的终端700的结构框图。该终端700可以是便携式移动终端,比如:智能手机、平板电脑、MP3播放器(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、笔记本电脑或台式电脑。终端700还可能被称为用户设备、便携式终端、膝上型终端、台式终端等其他名称。
通常,终端700包括有:处理器701和存储器702。
处理器701可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器701可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器701也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central Processing Unit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器701可以在集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器701还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。
存储器702可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非 暂态的。存储器702还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器702中的非暂态的计算机可读存储介质用于存储至少一个指令,该至少一个指令用于被处理器701所执行以实现本申请中方法实施例提供的视频编码方法。
在一些实施例中,终端700还可选包括有:外围设备接口703和至少一个外围设备。处理器701、存储器702和外围设备接口703之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口703相连。具体地,外围设备包括:射频电路704、触摸显示屏705、摄像头706、音频电路707、定位组件708和电源709中的至少一种。
外围设备接口703可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器701和存储器702。在一些实施例中,处理器701、存储器702和外围设备接口703被集成在同一芯片或电路板上;在一些其他实施例中,处理器701、存储器702和外围设备接口703中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。
射频电路704用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路704通过电磁信号与通信网络以及其他通信设备进行通信。射频电路704将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。可选地,射频电路704包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路704可以通过至少一种无线通信协议来与其它终端进行通信。该无线通信协议包括但不限于:城域网、各代移动通信网络(2G、3G、4G及5G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电路704还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。
显示屏705用于显示UI(User Interface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏705是触摸显示屏时,显示屏705还具有采集在显示屏705的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器701进行处理。此时,显示屏705还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏705可以为一个,设置终端700的前面板;在另一些实施例中,显示屏705可以为至少两个,分别设置在终端700的不同表面或呈折叠设计;在再一些实施例中,显示屏705可以是柔性显示屏,设置在终端700的弯曲表面上或折叠面上。甚至,显示屏705还可以设置成非矩形的不规则图形,也即异形屏。显示屏705可以采用LCD(Liquid  Crystal Display,液晶显示屏)、OLED(Organic Light-Emitting Diode,有机发光二极管)等材质制备。
摄像头组件706用于采集图像或视频。可选地,摄像头组件706包括前置摄像头和后置摄像头。通常,前置摄像头设置在终端的前面板,后置摄像头设置在终端的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件706还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。
音频电路707可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器701进行处理,或者输入至射频电路704以实现语音通信。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在终端700的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。扬声器则用于将来自处理器701或射频电路704的电信号转换为声波。扬声器可以是传统的薄膜扬声器,也可以是压电陶瓷扬声器。当扬声器是压电陶瓷扬声器时,不仅可以将电信号转换为人类可听见的声波,也可以将电信号转换为人类听不见的声波以进行测距等用途。在一些实施例中,音频电路707还可以包括耳机插孔。
定位组件708用于定位终端700的当前地理位置,以实现导航或LBS(Location Based Service,基于位置的服务)。定位组件708可以是基于美国的GPS(Global Positioning System,全球定位系统)、中国的北斗系统、俄罗斯的格雷纳斯系统或欧盟的伽利略系统的定位组件。
电源709用于为终端700中的各个组件进行供电。电源709可以是交流电、直流电、一次性电池或可充电电池。当电源709包括可充电电池时,该可充电电池可以支持有线充电或无线充电。该可充电电池还可以用于支持快充技术。
在一些实施例中,终端700还包括有一个或多个传感器710。该一个或多个传感器710包括但不限于:加速度传感器711、陀螺仪传感器712、压力传感器713、指纹传感器714、光学传感器715以及接近传感器716。
加速度传感器711可以检测以终端700建立的坐标系的三个坐标轴上的加速度大小。比如,加速度传感器711可以用于检测重力加速度在三个坐标轴上的分量。处理器701可以根据加速度传感器711采集的重力加速度信号,控制触摸显示屏705以横向视图或纵向视图进行用户界面的显示。加速度传感器711还可以用于游戏或者用户的运动数据的采集。
陀螺仪传感器712可以检测终端700的机体方向及转动角度,陀螺仪传感器712可以与 加速度传感器711协同采集用户对终端700的3D动作。处理器701根据陀螺仪传感器712采集的数据,可以实现如下功能:动作感应(比如根据用户的倾斜操作来改变UI)、拍摄时的图像稳定、游戏控制以及惯性导航。
压力传感器713可以设置在终端700的侧边框和/或触摸显示屏705的下层。当压力传感器713设置在终端700的侧边框时,可以检测用户对终端700的握持信号,由处理器701根据压力传感器713采集的握持信号进行左右手识别或快捷操作。当压力传感器713设置在触摸显示屏705的下层时,由处理器701根据用户对触摸显示屏705的压力操作,实现对UI界面上的可操作性控件进行控制。可操作性控件包括按钮控件、滚动条控件、图标控件、菜单控件中的至少一种。
指纹传感器714用于采集用户的指纹,由处理器701根据指纹传感器714采集到的指纹识别用户的身份,或者,由指纹传感器714根据采集到的指纹识别用户的身份。在识别出用户的身份为可信身份时,由处理器701授权该用户执行相关的敏感操作,该敏感操作包括解锁屏幕、查看加密信息、下载软件、支付及更改设置等。指纹传感器714可以被设置终端700的正面、背面或侧面。当终端700上设置有物理按键或厂商Logo时,指纹传感器714可以与物理按键或厂商Logo集成在一起。
光学传感器715用于采集环境光强度。在一个实施例中,处理器701可以根据光学传感器715采集的环境光强度,控制触摸显示屏705的显示亮度。具体地,当环境光强度较高时,调高触摸显示屏705的显示亮度;当环境光强度较低时,调低触摸显示屏705的显示亮度。在另一个实施例中,处理器701还可以根据光学传感器715采集的环境光强度,动态调整摄像头组件706的拍摄参数。
接近传感器716,也称距离传感器,通常设置在终端700的前面板。接近传感器716用于采集用户与终端700的正面之间的距离。在一个实施例中,当接近传感器716检测到用户与终端700的正面之间的距离逐渐变小时,由处理器701控制触摸显示屏705从亮屏状态切换为息屏状态;当接近传感器716检测到用户与终端700的正面之间的距离逐渐变大时,由处理器701控制触摸显示屏705从息屏状态切换为亮屏状态。
本领域技术人员可以理解,图7中示出的结构并不构成对终端700的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。
本申请一个实施例提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现如上所述的视频编码方法。
本申请一个实施例提供了一种视频编码设备,所述视频编码设备包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如上所述的视频编码方法。
其中,当视频编码设备是终端类的电子设备时,该视频编码设备的结构详见图7所示的实施例中对终端700的结构的描述。
需要说明的是:上述实施例提供的视频编码装置在进行视频编码时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将视频编码装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的视频编码装置与视频编码方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述并不用以限制本申请实施例,凡在本申请实施例的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请实施例的保护范围之内。

Claims (26)

  1. 一种视频编码方法,其特征在于,由终端执行,所述方法包括:
    获取待编码的视频,所述视频中包括按序排列的至少两个视频帧;
    对于所述至少两个视频帧中的第i个视频帧,计算所述第i个视频帧的量化参数和量化参数阈值,i为大于等于2的正整数;
    根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率,所述编码分辨率为第一编码分辨率或第二编码分辨率,所述第一编码分辨率是所述第i个视频帧采样时的分辨率,所述第二编码分辨率是对所述第i个视频帧进行下采样时的分辨率;
    以所述编码分辨率对所述第i个视频帧进行编码。
  2. 根据权利要求1所述的方法,其特征在于,所述计算所述第i个视频帧的量化参数,包括:
    当所述第i个视频帧的编码模式是固定质量编码模式时,读取设定的量化参数,将所述量化参数确定为所述第i个视频帧的量化参数;
    当所述第i个视频帧的编码模式是固定码率编码模式时,计算所述第i个视频帧中第一个编码块的量化参数,将所述第一个编码块的量化参数确定为所述第i个视频帧的量化参数。
  3. 根据权利要求2所述的方法,其特征在于,所述计算所述第i个视频帧中第一个编码块的量化参数,包括:
    若第i-1个视频帧为I帧且以所述第二编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移和第二偏移;将所述平均值、所述第一偏移和所述第二偏移之和确定为所述第一个编码块的量化参数;和/或,
    若第i-1个视频帧为I帧且以所述第一编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第二偏移;将所述平均值和所述第二偏移之和确定为所述第一个编码块的量化参数;和/或,
    若第i-1个视频帧为P帧且以所述第一编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;将所述平均值确定为所述第一个编码块的量化参数;和/或,
    若第i-1个视频帧为P帧且以所述第二编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移;将所述平均值和所述第一偏移之和确定为所述第一个编码块的量化参数;
    其中,所述第一偏移是所述第一编码分辨率对应的量化参数和所述第二编码分辨率对应的量化参数之间的偏移,所述第二偏移是I帧和P帧之间量化参数的偏移。
  4. 根据权利要求1所述的方法,其特征在于,所述计算所述第i个视频帧的量化参数阈值,包括:
    计算假定所述第i个视频帧为I帧时的第一编码代价;
    计算假定所述第i个视频帧为P帧时的第二编码代价;
    将所述第一编码代价除以所述第二编码代价,得到编码代价比值;
    根据所述编码代价比值确定所述量化参数阈值,所述编码代价比值与所述量化参数阈值呈正相关关系。
  5. 根据权利要求4所述的方法,其特征在于,所述计算假定所述第i个视频帧为I帧时的第一编码代价,包括:
    将所述第i个视频帧划分为至少两个编码块;
    对所述编码块进行帧内预测编码,得到帧内编码代价;
    将各个帧内编码代价之和确定为所述第一编码代价。
  6. 根据权利要求4所述的方法,其特征在于,所述计算假定所述第i个视频帧为P帧时的第二编码代价,包括:
    将所述第i个视频帧划分为至少两个编码块;
    对所述编码块进行帧间预测编码,得到帧间编码代价;
    将各个帧间编码代价之和确定为所述第二编码代价。
  7. 根据权利要求4所述的方法,其特征在于,当存在两组阈值集合且所述两组阈值集合对应于不同的编码分辨率时,所述根据所述编码代价比值确定所述量化参数阈值,包括:
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第一编码分辨率,则根据所述编码代价比值、所述两组阈值集合和所述第一编码分辨率确定所述量化阈值参数;
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第二编码分辨率,则根据所述编码代价比值、所述两组阈值集合和所述第二编码分辨率确定所述量化阈值参数。
  8. 根据权利要求7所述的方法,其特征在于,所述根据所述编码代价比值、所述两组阈值集合和所述第一编码分辨率确定所述量化阈值参数,包括:
    在所述两组阈值集合中查找所述第一编码分辨率所对应的一组阈值集合;
    根据所述编码代价比值在查找到的所述阈值集合中查找所述量化阈值参数。
  9. 根据权利要求7所述的方法,其特征在于,所述根据所述编码代价比值、所述两组阈值组合和所述第二编码分辨率确定所述量化阈值参数,包括:
    在所述两组阈值集合中查找所述第二编码分辨率所对应的一组阈值集合;
    根据所述编码代价比值在查找到的所述阈值集合中查找所述量化阈值参数。
  10. 根据权利要求1至9任一项所述的方法,其特征在于,所述根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率,包括:
    当所述量化参数小于等于所述量化参数阈值时,确定所述第i个视频帧的编码分辨率为所述第一编码分辨率;
    当所述量化参数大于所述量化参数阈值时,确定所述第i个视频帧的编码分辨率为所述 第二编码分辨率。
  11. 根据权利要求10所述的方法,其特征在于,当存在一组阈值集合且所述阈值集合与所述第一编码分辨率对应时,在所述根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率之前,所述方法还包括:
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第一编码分辨率,则将所述量化参数确定为最终的量化参数;
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第二编码分辨率,则将所述量化参数加上所述第一偏移得到最终的量化参数。
  12. 根据权利要求10所述的方法,其特征在于,当存在一组阈值集合且所述阈值集合与所述第二编码分辨率对应时,在所述根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率之前,所述方法还包括:
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第一编码分辨率,则将所述量化参数减去所述第一偏移得到最终的量化参数;
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第二编码分辨率,则将所述量化参数确定为最终的量化参数。
  13. 一种视频编码装置,其特征在于,所述装置包括:
    获取模块,用于获取待编码的视频,所述视频中包括按序排列的至少两个视频帧;
    计算模块,用于对于所述至少两个视频帧中的第i个视频帧,计算所述第i个视频帧的量化参数和量化参数阈值,i为大于等于2的正整数;
    确定模块,用于根据所述计算模块得到的所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率,所述编码分辨率为第一编码分辨率或第二编码分辨率,所述第一编码分辨率是所述第i个视频帧采样时的分辨率,所述第二编码分辨率是对所述第i个视频帧进行下采样时的分辨率;
    编码模块,用于以所述确定模块确定的所述编码分辨率对所述第i个视频帧进行编码。
  14. 根据权利要求13所述的装置,其特征在于,所述计算模块,还用于:
    当所述第i个视频帧的编码模式是固定质量编码模式时,读取设定的量化参数,将所述量化参数确定为所述第i个视频帧的量化参数;
    当所述第i个视频帧的编码模式是固定码率编码模式时,计算所述第i个视频帧中第一个编码块的量化参数,将所述第一个编码块的量化参数确定为所述第i个视频帧的量化参数。
  15. 根据权利要求14所述的装置,其特征在于,所述计算模块,还用于:
    若第i-1个视频帧为I帧且以所述第二编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移和第二偏移;将所述平均值、所述第一偏移和所述第二偏移之和确定为所述第一个编码块的量化参数;和/或,
    若第i-1个视频帧为I帧且以所述第一编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第二偏移;将所述平均值和所述第二偏移之和确定为所述第一个编码块的量化参数;和/或,
    若第i-1个视频帧为P帧且以所述第一编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;将所述平均值确定为所述第一个编码块的量化参数;和/或,
    若第i-1个视频帧为P帧且以所述第二编码分辨率对所述第i-1个视频帧进行了编码,则计算所述第i-1个视频帧中所有编码块实际的量化参数的平均值;获取第一偏移;将所述平均值和所述第一偏移之和确定为所述第一个编码块的量化参数;
    其中,所述第一偏移是所述第一编码分辨率对应的量化参数和所述第二编码分辨率对应的量化参数之间的偏移,所述第二偏移是I帧和P帧之间量化参数的偏移。
  16. 根据权利要求13所述的装置,其特征在于,所述计算模块,还用于:
    计算假定所述第i个视频帧为I帧时的第一编码代价;
    计算假定所述第i个视频帧为P帧时的第二编码代价;
    将所述第一编码代价除以所述第二编码代价,得到编码代价比值;
    根据所述编码代价比值确定所述量化参数阈值,所述编码代价比值与所述量化参数阈值呈正相关关系。
  17. 根据权利要求16所述的装置,其特征在于,所述计算模块,还用于:
    将所述第i个视频帧划分为至少两个编码块;
    对所述编码块进行帧内预测编码,得到帧内编码代价;
    将各个帧内编码代价之和确定为所述第一编码代价。
  18. 根据权利要求16所述的装置,其特征在于,所述计算模块,还用于:
    将所述第i个视频帧划分为至少两个编码块;
    对所述编码块进行帧间预测编码,得到帧间编码代价;
    将各个帧间编码代价之和确定为所述第二编码代价。
  19. 根据权利要求16所述的装置,其特征在于,当存在两组阈值集合且所述两组阈值集合对应于不同的编码分辨率时,所述计算模块,还用于:
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第一编码分辨率,则根据所述编码代价比值、所述两组阈值集合和所述第一编码分辨率确定所述量化阈值参数;
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第二编码分辨率,则根据所述编码代价比值、所述两组阈值集合和所述第二编码分辨率确定所述量化阈值参数。
  20. 根据权利要求19所述的装置,其特征在于,所述计算模块,还用于:
    在所述两组阈值集合中查找所述第一编码分辨率所对应的一组阈值集合;
    根据所述编码代价比值在查找到的所述阈值集合中查找所述量化阈值参数。
  21. 根据权利要求19所述的装置,其特征在于,所述计算模块,还用于:
    在所述两组阈值集合中查找所述第二编码分辨率所对应的一组阈值集合;
    根据所述编码代价比值在查找到的所述阈值集合中查找所述量化阈值参数。
  22. 根据权利要求13至21任一项所述的装置,其特征在于,所述确定模块,还用于:
    当所述量化参数小于等于所述量化参数阈值时,确定所述第i个视频帧的编码分辨率为所述第一编码分辨率;
    当所述量化参数大于所述量化参数阈值时,确定所述第i个视频帧的编码分辨率为所述第二编码分辨率。
  23. 根据权利要求22所述的装置,其特征在于,当存在一组阈值集合且所述阈值集合与所述第一编码分辨率对应时,所述确定模块,还用于在所述根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率之前:
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第一编码分辨率,则将所述量化参数确定为最终的量化参数;
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第二编码分辨率,则将所述量化参数加上所述第一偏移得到最终的量化参数。
  24. 根据权利要求22所述的装置,其特征在于,当存在一组阈值集合且所述阈值集合与所述第二编码分辨率对应时,所述确定模块,还用于在所述根据所述量化参数和所述量化参数阈值确定所述第i个视频帧的编码分辨率之前:
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第一编码分辨率,则将所述量化参数减去所述第一偏移得到最终的量化参数;
    若计算所述量化参数时假定所述第i个视频帧的编码分辨率是所述第二编码分辨率,则将所述量化参数确定为最终的量化参数。
  25. 一种计算机可读存储介质,其特征在于,所述存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现如权利要求1至12任一所述的视频编码方法。
  26. 一种视频编码设备,其特征在于,所述视频编码设备包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如权利要求1至12任一所述的视频编码方法。
PCT/CN2019/078432 2018-04-27 2019-03-18 视频编码方法、装置、存储介质及设备 WO2019205831A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP19792389.9A EP3787291B1 (en) 2018-04-27 2019-03-18 Method and device for video encoding, storage medium, and equipment
JP2020551298A JP7085014B2 (ja) 2018-04-27 2019-03-18 ビデオ符号化方法並びにその装置、記憶媒体、機器、及びコンピュータプログラム
US16/996,443 US11388403B2 (en) 2018-04-27 2020-08-18 Video encoding method and apparatus, storage medium, and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810394329.9A CN108391127B (zh) 2018-04-27 2018-04-27 视频编码方法、装置、存储介质及设备
CN201810394329.9 2018-04-27

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/996,443 Continuation US11388403B2 (en) 2018-04-27 2020-08-18 Video encoding method and apparatus, storage medium, and device

Publications (1)

Publication Number Publication Date
WO2019205831A1 true WO2019205831A1 (zh) 2019-10-31

Family

ID=63065777

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/078432 WO2019205831A1 (zh) 2018-04-27 2019-03-18 视频编码方法、装置、存储介质及设备

Country Status (5)

Country Link
US (1) US11388403B2 (zh)
EP (1) EP3787291B1 (zh)
JP (1) JP7085014B2 (zh)
CN (1) CN108391127B (zh)
WO (1) WO2019205831A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108391127B (zh) 2018-04-27 2021-08-10 腾讯科技(深圳)有限公司 视频编码方法、装置、存储介质及设备
WO2020066326A1 (ja) * 2018-09-26 2020-04-02 富士フイルム株式会社 画像処理装置、撮影装置、画像処理方法及び画像処理プログラム
CN110582022B (zh) * 2019-09-27 2022-12-30 腾讯科技(深圳)有限公司 视频编解码方法和装置及存储介质
CN110677692B (zh) * 2019-09-27 2022-12-06 腾讯科技(深圳)有限公司 视频解码方法及装置、视频编码方法及装置
CN110536134B (zh) * 2019-09-27 2022-11-04 腾讯科技(深圳)有限公司 视频编码、解码方法和装置、存储介质及电子装置
CN110636293B (zh) * 2019-09-27 2024-03-15 腾讯科技(深圳)有限公司 视频编码、解码方法和装置、存储介质及电子装置
CN111787322B (zh) 2020-08-04 2022-05-13 北京百度网讯科技有限公司 视频编码的方法、装置、电子设备及计算机可读存储介质
CN113573142B (zh) * 2021-09-22 2021-12-24 北京海誉动想科技股份有限公司 分辨率调整方法与装置
CN115225928B (zh) * 2022-05-11 2023-07-25 北京广播电视台 一种多类型音视频混播系统及方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1906949A (zh) * 2004-01-29 2007-01-31 国际商业机器公司 动态改变视频编码的分辨率的系统和方法
CN102461169A (zh) * 2009-06-12 2012-05-16 微软公司 基于运动的动态分辨率多比特率视频编码
US20170085872A1 (en) * 2015-09-17 2017-03-23 Harmonic, Inc. Video processing with dynamic resolution changes
CN107040781A (zh) * 2016-01-19 2017-08-11 谷歌公司 使用动态分辨率切换的实时视频编码器速率控制
CN108391127A (zh) * 2018-04-27 2018-08-10 腾讯科技(深圳)有限公司 视频编码方法、装置、存储介质及设备

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003032677A (ja) 2001-07-18 2003-01-31 Hitachi Ltd 動画像圧縮符号化装置
US8175147B1 (en) * 2005-08-08 2012-05-08 Texas Instruments Incorporated Video coding rate control
US7773672B2 (en) * 2006-05-30 2010-08-10 Freescale Semiconductor, Inc. Scalable rate control system for a video encoder
US9894361B2 (en) * 2009-03-31 2018-02-13 Citrix Systems, Inc. Framework for quality-aware video optimization
US8379718B2 (en) * 2009-09-02 2013-02-19 Sony Computer Entertainment Inc. Parallel digital picture encoding
JP2011223315A (ja) 2010-04-09 2011-11-04 Mitsubishi Electric Corp 画像符号化装置、画像復号装置、画像符号化方法及び画像復号方法
CN102625104B (zh) * 2012-03-26 2014-04-16 浙江大学 一种视频编码方法
US10425641B2 (en) * 2013-05-30 2019-09-24 Intel Corporation Quantization offset and cost factor modification for video encoding
KR101811721B1 (ko) * 2016-12-12 2018-01-25 삼성전자주식회사 계층적 부호화 단위의 크기에 따른 비디오 부호화 방법과 그 장치, 및 비디오 복호화 방법과 그 장치
CN107155107B (zh) * 2017-03-21 2018-08-03 腾讯科技(深圳)有限公司 视频编码方法和装置、视频解码方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1906949A (zh) * 2004-01-29 2007-01-31 国际商业机器公司 动态改变视频编码的分辨率的系统和方法
CN102461169A (zh) * 2009-06-12 2012-05-16 微软公司 基于运动的动态分辨率多比特率视频编码
US20170085872A1 (en) * 2015-09-17 2017-03-23 Harmonic, Inc. Video processing with dynamic resolution changes
CN107040781A (zh) * 2016-01-19 2017-08-11 谷歌公司 使用动态分辨率切换的实时视频编码器速率控制
CN108391127A (zh) * 2018-04-27 2018-08-10 腾讯科技(深圳)有限公司 视频编码方法、装置、存储介质及设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3787291A4 *

Also Published As

Publication number Publication date
CN108391127B (zh) 2021-08-10
JP2021516919A (ja) 2021-07-08
US20200382781A1 (en) 2020-12-03
EP3787291A1 (en) 2021-03-03
EP3787291B1 (en) 2024-03-06
EP3787291A4 (en) 2021-06-23
CN108391127A (zh) 2018-08-10
US11388403B2 (en) 2022-07-12
JP7085014B2 (ja) 2022-06-15

Similar Documents

Publication Publication Date Title
WO2019205831A1 (zh) 视频编码方法、装置、存储介质及设备
JP7026260B2 (ja) ビデオ符号化方法、ビデオ符号化装置およびコンピュータプログラム
EP3962086A1 (en) Prediction mode decoding method and apparatus and prediction mode encoding method and apparatus
US10986332B2 (en) Prediction mode selection method, video encoding device, and storage medium
CN112532975B (zh) 视频编码方法、装置、计算机设备及存储介质
WO2023087637A1 (zh) 视频编码方法和装置、电子设备和计算机可读存储介质
CN110049326B (zh) 视频编码方法及装置、存储介质
CN110166776B (zh) 视频编码方法、装置及存储介质
CN111107357A (zh) 一种图像处理的方法、装置及系统
CN110572679B (zh) 帧内预测的编码方法、装置、设备及可读存储介质
CN110177275B (zh) 视频编码方法及装置、存储介质
CN116074512A (zh) 视频编码方法、装置、电子设备以及存储介质
CN110087077A (zh) 视频编码方法及装置、存储介质
CN111698262B (zh) 带宽确定方法、装置、终端及存储介质
CN111770339B (zh) 视频编码方法、装置、设备及存储介质
CN116563771A (zh) 图像识别方法、装置、电子设备及可读存储介质
CN110460856B (zh) 视频编码方法、装置、编码设备及计算机可读存储介质
CN114422782B (zh) 视频编码方法、装置、存储介质及电子设备
CN110062226B (zh) 一种视频编码方法、视频解码方法、装置、系统及介质
CN113038124B (zh) 视频编码方法、装置、存储介质及电子设备
CN113938689B (zh) 量化参数确定方法和装置
CN117676170A (zh) 块效应检测的方法、装置、设备和存储介质
CN115474037B (zh) 视频的质量检测方法、装置、电子设备及可读存储介质
CN113891090A (zh) 视频编码方法、装置、存储介质及电子设备
CN116980627A (zh) 用于解码的视频滤波方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19792389

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2020551298

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2019792389

Country of ref document: EP