Content adaptive quantization intensity and bit rate modeling system, method and device

By generating a mapping model between bit size and quantization strength in the video encoder and adjusting the quantization parameters, the challenges of bit rate and picture quality in video encoding are solved, efficient video encoding and decoding is achieved, and visual quality and coding efficiency are improved.

CN112868230BActive Publication Date: 2024-09-27ATI TECHNOLOGIES ULC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201980068194.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-10-31
Filing Date
2019-06-25
Publication Date
2024-09-27
Estimated Expiration
2039-06-25

AI Technical Summary

Technical Problem

During the video encoding process, there is a challenge between controlling the bit rate and picture quality of the encoded video stream, and existing techniques struggle to maintain acceptable visual quality while meeting the bandwidth requirements of specific video applications.

Method used

By using a combination of precoders and encoders in the video encoder, a model is generated that maps the video frame bit size to the quantization intensity, adjusting the quantization parameter (QP) to meet the given bit budget, reducing the quantization intensity adjustment and improving the quantization intensity. The visual quality of the encoded video bitstream.

Benefits of technology

It is possible to improve the visual quality of encoded video frames while controlling the video stream bit rate, meet the bandwidth requirements of different video applications, and improve encoding efficiency and quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112868230B_ABST
    Figure CN112868230B_ABST
Patent Text Reader

Abstract

Disclosed are systems, devices, and methods for generating a model for determining quantization strength for use when encoding a video frame. A precoder performs multiple encoding passes using different quantization strengths for a portion or all of one or more preprocessed video frames. For each of the multiple encoding passes, the precoder captures the bit size of the encoded output. Then, based on the multiple encoding passes, the precoder generates a model for mapping the bit size to the quantization strength to encode the video frame or its (multiple) portions. When the encoder starts the last encoding for one or more given video frames or any (multiple) portions thereof, the encoder uses the model to map the preferred bit size to a given quantization strength. The encoder uses the given quantization strength when encoding the (multiple) given video frames or (multiple) frame portions to meet the specified bit rate of the encoded bit stream.
Need to check novelty before this filing date? Find Prior Art

Description

Background of the Invention

[0002] Description of Related Technology

[0003] Various applications perform encoding and decoding of image or video content. For example, video transcoding, desktop sharing, cloud gaming, and game viewing activities are some of the applications that include support for encoding and decoding of content. One of the parameters that determines how the content is encoded is the quantization parameter (QP). In various block-based video encoding schemes, such as those that comply with the H.264 standard, the QP adjusts how much detail is retained during the encoding process. The QP selected for each video frame or each block of a frame is directly related to the size of the encoded video frame or the size of the encoded block. Selecting a lower QP value will retain more details while producing a larger encoded size. Selecting a higher QP value will result in the loss of more details while producing a smaller encoded size. Note that the term "quantization parameter" may also be more generally referred to as "quantization strength." BRIEF DESCRIPTION OF THE DRAWINGS

[0004] Advantages of the methods and mechanisms described herein may be better understood by referring to the following description in conjunction with the accompanying drawings, in which:

[0005] Figure 1 is a block diagram of one implementation of a system for encoding and decoding content.

[0006] Figure 2 is a block diagram of one implementation of software components of a server for encoding frames of a video.

[0007] Figure 3 It is a block diagram of one implementation of the encoding logic.

[0008] Figure 4 The figure shows an example of a diagram mapping QPs to bit counts.

[0009] Figure 5 The diagram illustrates one implementation of a graph for determining a QP value to match a target bit count.

[0010] Figure 6 is a generalized flow diagram illustrating one implementation of a method for generating a mapping of bit size to QP.

[0011] Figure 7 is a generalized flow chart illustrating one implementation of a method for encoding a video frame. DETAILED DESCRIPTION

[0012] In the following description, numerous specific details are set forth to provide a thorough understanding of the methods and mechanisms presented herein. However, it will be appreciated by those of ordinary skill in the art that various implementations may be practiced without these specific details. In some cases, well-known structures, components, signals, computer program instructions, and techniques are not shown in detail to avoid obfuscating the methods described herein. It will be appreciated that for ease and clarity of illustration, the elements shown in the figures may not be drawn to scale. For example, the size of some of the elements may be enlarged relative to other elements.

[0013] Disclosed herein are systems, devices, and methods for generating and implementing a video coding model for mapping encoded video frame bit sizes to quantization strengths. In one implementation, a system includes at least an encoder, a precoder, and a memory coupled to the encoder and the precoder. The precoder runs multiple precoding passes on at least a portion of an input video frame. In one implementation, the input video frame is preprocessed before the precoding passes. Each precoding pass uses a different quantization strength setting. In one implementation, the quantization strength setting refers to a specific quantization parameter (QP) used during the encoding process. For each precoding pass, the precoder captures the output bit size of (multiple) encoded portions of the input video frame. The precoder uses the captured output bit size to generate a model for mapping the encoded video bit stream bit size to the quantization strength.

[0014] Before the encoder encodes the (multiple) parts of the input video frame, the encoder uses the model to map the specified bit size to the corresponding quantization strength. In one implementation, the encoder provides the specified bit size to the model, and the model output will produce the quantization strength value of the specified bit size. The encoder then uses the quantization strength value provided by the model to encode the (multiple) parts of the input video frame to meet the given bit budget. In one implementation, by using the quantization strength value provided by the model, the encoder is able to make fewer quantization strength adjustments during the frame. This helps to improve the visual quality of the resulting encoded video bit stream.

[0015] Reference now Figure 1 , a block diagram of one implementation of a system 100 for encoding and decoding content is shown. The system 100 includes a server 105, a network 110, a client 115, and a display 120. In other implementations, the system 100 includes a plurality of clients connected to the server 105 via the network 110, wherein the plurality of clients receive the same bitstream or different bitstreams generated by the server 105. The system 100 can also include more than one server 105 for generating a plurality of bitstreams for a plurality of clients.

[0016] In one implementation, the system 100 implements encoding and decoding of video content. In various implementations, the system 100 implements different applications, such as video game applications, cloud game applications, virtual desktop infrastructure applications, or screen sharing applications. In other implementations, the system 100 executes other types of applications. In one implementation, the server 105 renders video or image frames, encodes the rendered frames into a bitstream, and then transmits the encoded bitstream to the client 115 via the network 110. The client 115 decodes the encoded bitstream and generates a video or image frame to drive to the display 120 or display synthesizer.

[0017] Quantization is a mechanism used in video standards (e.g., High Efficiency Video Coding (HEVC) standard, Advanced Video Coding (AVC)) to control the size of the encoded video stream to meet the bandwidth requirements of a specific video application. This allows the system 100 to send the encoded video stream from the server 105 to the client 115 in a consistent manner. It can be challenging to provide acceptable picture quality while controlling the bit rate of the encoded video stream. In one implementation, the preferred bit count for each video frame is equal to the bit rate of the encoded video stream divided by the frame rate of the video sequence. Please note that the term "bit count" is used interchangeably with the term "bit size" in this article. In one implementation, the server 105 adjusts the quantization parameter (QP) used to encode the input video sequence to control the bit count of each frame of the encoded video stream. In this implementation, the server 105 generates a model that maps the bit count to the QP. Depending on the implementation, the server 105 receives an indication of the desired bit count, or the server 105 calculates the desired bit count for each video frame. Once the server 105 knows the expected bit count for each video frame, the server 105 uses the model to map the expected bit count to a specific QP value. The server 105 then sets the QP to this specific QP value when encoding a given video frame. In one implementation, the server 105 generates a different model for each video frame (or a portion of each video frame). In other implementations, the server 105 reuses a given model for multiple video frames.

[0018] The network 110 represents any type of network or combination of networks, including wireless connections, direct local area networks (LANs), metropolitan area networks (MANs), wide area networks (WANs), intranets, the Internet, wired networks, packet switching networks, fiber optic networks, routers, storage area networks, or other types of networks. Examples of LANs include Ethernet networks, fiber distributed data interface (FDDI) networks, and token ring networks. In various implementations, the network 110 includes remote direct memory access (RDMA) hardware and / or software, transmission control protocol / Internet protocol (TCP / IP) hardware and / or software, routers, repeaters, switches, power grids, and / or other components.

[0019] The server 105 includes any combination of software and / or hardware for rendering video / image frames, generating a model that maps bit counts to QPs, and / or encoding frames into bitstreams using the QPs provided by the model. In one implementation, the server 105 includes one or more software applications executed on one or more processors of one or more servers. The server 105 also includes network communication capabilities, one or more input / output devices, and / or other components. The processors of the server 105 include any number and type of processors (e.g., graphics processing units (GPUs), central processing units (CPUs), digital signal processors (DSPs), field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs)). The processor is coupled to one or more memory devices that store program instructions that can be executed by the processor. Similarly, the client 115 includes any combination of software and / or hardware for decoding the bitstream and driving the frame to the display 120. In one implementation, the client 115 includes one or more software applications executed on one or more processors of one or more computing devices. In various implementations, the client 115 is a computing device, a game console, a mobile device, a streaming media player, or other type of device.

[0020] Now go to Figure 2 , a block diagram of one implementation of software components of the server 200 for encoding frames of a video is shown. Note that in other implementations, the server 200 includes other components and / or is used in a manner similar to the embodiment of the present invention. Figure 2The server 200 receives a new frame 205 of video and provides the new frame to a pre-encoder 220 and an encoder 230. Each of the pre-encoder 220 and the encoder 230 is implemented using any suitable combination of hardware and / or software. The pre-encoder 220 generates a quantization parameter (QP) 225 for use by the encoder 230 when encoding the new frame 205. In one implementation, the pre-encoder 220 generates the QP 225 based on the model 215. In one implementation, the model 215 identifies a target QP 225 for achieving a specified bit rate or bit size of the encoded frame. Note that the term "encoded frame" may also be referred to as a "compressed frame."

[0021] In one implementation, the precoder 220 receives the preprocessed frame 210 and performs one or more operations on the preprocessed frame 210. In another implementation, the precoder 220 generates the preprocessed frame 210 from the new frame 205. In one implementation, the preprocessed frame 210 is a downsampled version of the new frame 205. In other implementations, the preprocessed frame 210 represents the new frame 205 after performing one or more other types of operations (e.g., filtering) other than or in addition to downsampling on the new frame 205. In one implementation, the preprocessed frame 210 is stored in a memory 240. The memory 240 represents any number and type of memory or cache device for storing data and / or instructions associated with the encoding process. Depending on the implementation, the preprocessed frame 210 corresponds to the entirety or a portion of the original new frame 205.

[0022] In one implementation, the precoder 220 performs a plurality of precoding passes on the preprocessed frame 210 to generate the model 215. For example, in one implementation, the precoder 220 performs a first precoding pass on the preprocessed frame 210 using a first QP setting to determine a bit size of an output frame for the first QP setting. In addition, in this implementation, the precoder 220 performs a second precoding pass on the preprocessed frame 210 using a second QP setting to determine a bit size of a resulting encoded frame for the second QP setting. For the purpose of discussion, it is assumed that the second QP setting is different from the first QP setting. The precoder 220 is also capable of performing additional precoding passes using other QP settings. After capturing the bit size of the encoded frame for different passes at different QP settings, the precoder 220 generates a model 215 that maps the QP setting to the bit size. The desired bit size is then provided to the model 215 to generate a corresponding QP 225.

[0023] The encoder 230 receives the new frame 205 and encodes the new frame 205 using a QP value equal to the QP 225 generated by the precoder 220. In one implementation, when the encoder 230 begins encoding the new frame 205, the encoder sets the starting QP value equal to the QP 225 generated by the model 215. If the encoder 230 determines that the amount of encoded data being generated is too far from the target bit size, the starting QP value may be adjusted during the encoding process of the new frame 205. The output of the encoder 230 is an encoded frame 235, which is transmitted to one or more clients (e.g., Figure 1 The precoder 220 generates a new model 215 and QP 225 for each new frame 205. In another implementation, the precoder 220 reuses the model 215 and QP 225 for one or more subsequent frames. In yet another implementation, the precoder 220 generates the model 215 from a portion of the new frame 205 and then uses the model 215 to generate the QP 225 to be used to encode other portions of the new frame 205. In yet another implementation, the precoder 220 generates multiple models 215 for the new frame 205, where each model 215 represents a different portion of the new frame 205. In this implementation, the precoder 220 generates multiple QP values ​​225 to be used to encode different portions of the new frame 205. In general, the precoder 220 generates the QP value 225 for encoding the new frame 205 based on the bit rate that has been selected for the resulting encoded bitstream. By selecting an appropriate starting QP value 225, the encoder 230 will typically make fewer QP adjustments during encoding of a new frame 205. This helps improve the visual quality of the resulting encoded frame 235.

[0024] Reference now Figure 3 , a block diagram of one implementation of the encoding logic 300 is shown. The encoder 305 and the reduction unit 310 receive the original input video frame. In one implementation, the original input video frame is in the YUV color space. In other implementations, the original input video frame is encoded in other color spaces. The encoder 305 encodes the input video frame and generates an encoded bitstream, which is transmitted to the memory 315. The memory 315 represents any number and type of memory devices. In one implementation, the encoded bitstream is formatted according to the High Efficiency Video Coding (HEVC) standard. In one implementation, the encoded bitstream is formatted according to the Advanced Video Coding (AVC) standard. In one implementation, the encoded bitstream is formatted according to other coding standards.

[0025] The downscaling unit 310 generates downscaled frames from the original input video frames and transmits the downscaled frames to the memory 315. Due to the relationship shown in equation 330, the downscaled frames can be used to generate a model for mapping bit counts to QPs. As indicated by equation 330, for a given video frame, the ratio between the bit counts of the low-resolution version of the given video frame and the bit counts of the high-resolution version of the given video frame is constant for a given QP. Accordingly, the pre-encoding unit 320 processes the downscaled frames at different QPs, and the relationship between the resulting bit counts will represent the relationship between the bit counts of the different QPs used to encode the original frames. In other implementations, the downscaling unit 310 performs other types of filtering and / or preprocessing on the input video frames in addition to or different from downscaling. For example, in other implementations, the downscaling unit 310 performs noise reduction, grayscale conversion, and / or other types of preprocessing steps.

[0026] The downscaled frame is transmitted to the pre-encoding unit 320. In one implementation, the pre-encoding unit 320 performs at least two separate encodings on the downscaled frame using different QPs. In some implementations, the pre-encoding unit 320 performs at least two separate encodings on a portion of the downscaled frame using different QPs. Then, based on the size of the encoded frame (or the size of the encoded portion of the frame), the pre-encoding unit 320 creates a model that maps the output bit size to the QP. The statistical information for this model, labeled "encoded statistics", is stored in the memory 315. The encoded statistics are also transmitted to the encoder 305. The encoder 305 uses the encoded statistics when determining which QP to select for the input video frame in order to meet the desired bit size of the resulting encoded frame. In one implementation, the desired bit size of each encoded frame is determined based on the desired bit rate of the encoded bitstream produced by the encoder 305. For example, in one implementation, the desired bit rate is specified in bits per second (e.g., 3 megabits per second (Mbps)), and the frame rate of the video sequence is specified in frames per second (fps) (e.g., 60fps, 24fps). In this implementation, the encoder 305 divides the desired bit rate by the frame rate to calculate the desired bit size for each encoded frame.

[0027] Note that in other implementations, the encoding logic 300 modifies the above techniques to select the optimal quantization strength to encode the video data to meet a given bit budget. For example, in another implementation, the pre-encoding unit 320 encodes a portion of a frame using different quantization strength settings. The pre-encoding unit 320 then captures the bit sizes of the encoded portions at the different quantization strength settings. In yet another implementation, the pre-encoding unit 320 encodes two or more frames using different quantization strength settings and then captures the bit sizes of the corresponding encoded frames.

[0028] Now go to Figure 4 , shows an example of a graph 400 that maps bit counts to QP. Graph 410 represents the bit counts for different values ​​of QP used to encode a particular frame, a portion of a frame, or two or more frames of a video sequence. In one implementation, the relationship between bit count and QP is modeled using the following formula: Bit count = α2 β*QP . In one implementation, the values ​​of α and β are determined experimentally. For example, in one implementation, the values ​​of α and β are determined by pre-encoding a portion or the entire frame using two or more different QPs in two or more different pre-encoding passes. The size of the encoded portion or the entire frame is captured, and then the QP and the captured bit size are used to solve the values ​​of α and β in the above equation. Next, the values ​​of α and β are used to generate a model that determines the relationship between bit count and QP. When the encoder determines the expected bit count for a given video frame, the encoder uses the model to map the expected bit count to a specific QP value. The encoder then uses the specific QP value when encoding the given video frame to produce an encoded video frame with the expected bit count.

[0029] Reference now Figure 5 , shows one implementation of a graph 500 for determining a QP value to match a target bit count. In one implementation, the control logic or pre-coding unit implements two pre-coding passes on a video frame using different QP values, QP1 and QP2. The control logic captures the bit counts of the two pre-coding passes. In other implementations, the control logic performs more than two pre-coding passes on a video frame using different QP values. The bit count b1 corresponds to the pre-coding pass using QP1 and is labeled 510 on the graph 505. The bit count b2 corresponds to the pre-coding pass using QP2 and is labeled 515 on the graph 505. After capturing the bit counts b1 and b2 for the pre-coding passes using QP1 and QP2, respectively, the control logic generates a graph 505 mapping the relationship between the bit count and the QP. Then, when the desired bit count target 520 is determined, the control logic maps the target 520 to the QP value of QP3 on the graph 505. Then, when encoding the video frame and / or one or more subsequent video frames, the encoder sets the QP to a QP3 value. Alternatively, when encoding one or more portions (e.g., blocks, coding units) of the video frame and / or one or more portions of other video frames, the encoder uses a QP3 value.

[0030] Go to Figure 6 , shows one implementation of a method 600 for generating a model that maps bit size to a quantization parameter (QP). For discussion purposes, the steps and Figure 7 However, please note that in various implementations of the described method, one or more of the described elements are performed simultaneously, in a different order than shown, or omitted entirely. Other additional elements are also performed when necessary. Any of the various systems or devices described herein is configured to implement method 600.

[0031] The precoder performs a first encoding on at least a portion of a first video frame using a first quantization parameter (QP) setting (box 605). The precoder then captures the first bit size of the encoded portion of the first video frame (box 610). Note that the term "bit size" may also be referred to as "bit count" herein. Next, the precoder performs a second encoding on at least the portion of the first video frame using a second QP setting (box 615). For the purposes of discussion, it is assumed that the second QP setting is different from the first QP setting. Note that the first encoding and the second encoding may also be referred to as "pre-encoding." The precoder then captures the second bit size of the encoded portion of the first video frame (box 620). Next, the precoder generates a model for mapping the bit size to the QP based on the relationship between the first QP and the second QP and the first bit size and the second bit size (box 625). After box 625, method 600 ends. Note that "model" may also be referred to as "mapping" herein. In one implementation, the model is generated by solving the values ​​of α and β in the equation: bit size = α2 β*QP For example, the values ​​of α and β are solved using the first bit size and the second bit size produced by the first encoding and the second encoding using the first QP and the second QP, respectively. In other implementations, other techniques are used to generate the model.

[0032] In some implementations, the precoder performs more than two different encodings using more than two different QP settings. The precoder then generates a model of QP and bit size using the more than two different QP settings (and corresponding bit sizes). Note that method 600 may be performed regularly or periodically, depending on the implementation. In one implementation, method 600 is performed for each portion of a given video frame. In another implementation, method 600 is performed for each video frame of a video stream. In yet another implementation, method 600 is performed once every N video frames, where N is a positive integer greater than one. The frequency of performing method 600 may alternate between these instances based on one or more factors. In other implementations, subsequent iterations of method 600 are performed according to other schedules.

[0033] Reference now Figure 7, one implementation of a method for encoding a video frame is shown. An encoder receives a video frame for encoding (block 705). The encoder determines a preferred encoded video frame size for the video frame (block 710). Depending on the implementation, the encoder receives the preferred encoded video frame size from another processing unit, the encoder retrieves the preferred encoded video frame size from a register or other memory location, the encoder calculates the preferred encoded video frame size based on a target bit rate for the encoded bitstream, or the encoder otherwise determines the preferred encoded video frame size.

[0034] The encoder determines which QP to select for encoding the received video frame based on a mapping between the encoded video frame size and the QP (block 715). Figure 6 An example of how to generate a mapping that maps bit size to QP is described in the above discussion of method 600 of . Next, the encoder generates an encoded video frame by setting the QP to the QP value for the preferred encoded video frame size provided by the model, where the encoded video frame represents the received video frame (box 720). Depending on the implementation, the mapping is implemented in a variety of different ways. In one implementation, the mapping is set directly by a software application. In another implementation, the mapping is implemented as a lookup table process derived by running multiple experiments. In yet another implementation, the mapping is implemented as a closed-loop control method that checks whether the stimulus applicator drives the system to a closer desired result (e.g., a preferred bit rate). In other implementations, the mapping is implemented using machine learning techniques, neural networks, regression models, or other types of models that use quality metrics (e.g., peak signal-to-noise ratio (PSNR), structural similarity (SSIM) index, video multi-method assessment fusion (VMAF)) to optimize settings that affect perceptual quality.

[0035] After block 720, the encoder transmits the encoded video frame to the decoder for display (block 725). After block 725, method 700 ends. Note that method 700 may be repeated for each video frame received by the encoder. Note also that the mapping may be updated for each portion of a subsequent video frame, for each subsequent video frame, or after two or more video frames have been encoded.

[0036] In various implementations, the method and / or mechanism described herein are implemented using program instructions of a software application. For example, program instructions that can be executed by a general or special processor are expected. In various implementations, such program instructions can be represented by a high-level programming language. In other implementations, program instructions can be compiled from a high-level programming language into a binary form, an intermediate form, or other forms. Alternatively, program instructions describing the behavior or design of hardware can be written. Such program instructions can be represented by a high-level programming language such as C. Alternatively, a hardware design language (HDL) such as Verilog can be used. In various implementations, program instructions are stored on any of a variety of non-temporary computer-readable storage media. During use, a computing system can access a storage medium to provide program instructions to the computing system for program execution. Generally speaking, such a computing system includes at least one or more memories and one or more processors configured to execute program instructions.

[0037] It should be emphasized that the above implementations are only non-limiting examples of implementations. Once the above disclosure is fully understood, many changes and modifications will become apparent to those skilled in the art. The attached claims are intended to be interpreted as covering all such changes and modifications.

Claims

1. A system, comprising: a precoder configured to generate a mapping of a frame size as a bit count measure to a quantization parameter (QP) based on a plurality of precoding passes of a portion of a first video frame using different QP settings, wherein the mapping defines an exponential relationship between the frame size and the QP; as well as An encoder, the encoder being configured to: determining a given QP value from the mapping based on a preferred encoded video frame size; generating the encoded video frame by setting the QP to the given QP value for at least a portion of an encoded video frame, wherein the encoded video frame is an encoded version of the first video frame; and The encoded video frames are transmitted to a decoder for display.

2. The system of claim 1, wherein the precoder is further configured to: performing a first encoding of at least the portion of the first video frame using a first QP setting; capturing a first size of a result of the first encoding; performing a second encoding on the portion of the first video frame using a second QP setting; capturing a second size of a result of the second encoding; and The mapping of frame size to QP is generated based on a relationship between the first QP setting and the second QP setting and the first size and the second size, respectively.

3. The system of claim 2, wherein prior to performing the first encoding and the second encoding, the system is configured to downscale the portion of the first video frame.

4. The system of claim 2, wherein the encoder is configured to utilize the mapping to determine an initial QP to be used when encoding the first video frame.

5. The system of claim 2, wherein the second QP setting is different from the first QP setting.

6. The system of claim 1, wherein the encoder is configured to use the mapping for a second video frame that follows the first video frame in a video sequence.

7. A method comprising: generating, by a precoder based on a plurality of pre-encoding passes of a portion of a first video frame using different quantization parameter (QP) settings, a mapping of a frame size to a QP as a bit count measure, wherein the mapping defines an exponential relationship between the frame size and the QP; determining, by the encoder, a given QP value from the mapping based on a preferred encoded video frame size; generating, by the encoder, the encoded video frame by setting the QP to the given QP value for at least a portion of an encoded video frame, wherein the encoded video frame is an encoded version of the first video frame; as well as The encoded video frames are transmitted by the encoder to a decoder for display.

8. The method of claim 7, further comprising: performing, by the pre-encoder, a first encoding of at least the portion of the first video frame using a first QP setting; capturing, by the precoder, a first size of a result of the first encoding; performing, by the pre-encoder, a second encoding on the portion of the first video frame using a second QP setting; capturing, by the precoder, a second size of a result of the second encoding; as well as The mapping of frame size to QP is generated by the precoder based on a relationship between the first QP setting and the second QP setting and the first size and the second size, respectively.

9. The method of claim 8, wherein the portion of the first video frame is downsampled prior to performing the first encoding and the second encoding.

10. The method of claim 8, further comprising determining, by the encoder based on the mapping generated by the pre-encoder, how to set an initial QP when encoding the first video frame for the last time. The method of claim 8 , wherein the second QP setting is different from the first QP setting.

12. The method of claim 7, further comprising using the mapping for a second video frame that follows the first video frame in a video sequence.

13. A device, comprising: Memory; as well as an encoder coupled to the memory, wherein the encoder is configured to: determining a given quantization parameter (QP) value from a mapping based on a preferred encoded video frame size, and wherein the mapping specifies a relationship between a bit size and a QP based on performing two or more pre-encoding passes on a portion of a first video frame using different QP settings by a pre-encoder different from the encoder and including circuitry configured to generate the mapping, wherein the mapping defines an exponential relationship between frame size and QP; generating the encoded video frame by setting the QP to the given QP value for at least a portion of an encoded video frame, wherein the encoded video frame is an encoded version of the first video frame; and The encoded video frames are transmitted to a decoder for display.

14. The apparatus of claim 13, wherein the two or more pre-encoding passes are performed on a portion of the first video frame that was downsampled prior to the two or more pre-encoding passes.

15. The apparatus of claim 13, wherein the two or more pre-encoding passes are performed on a portion of the first video frame that was pre-processed prior to the two or more pre-encoding passes.

16. The apparatus of claim 13, wherein the encoder is configured to determine, based on the mapping, how to set an initial QP when the first video frame is last encoded.