The disclosed embodiments of the present invention relate to video encoding, and more particularly, to a method and apparatus for adaptive video encoding.
The conventional video coding standards generally adopt a block based coding technique to exploit spatial and temporal redundancy. For example, the basic approach is to divide the whole source frame into a plurality of blocks, perform prediction on each block, transform residues of each block using discrete cosine transform, and perform quantization and entropy encoding. Besides, a reconstructed frame is generated in a coding loop to provide reference pixel data used for coding following blocks under inter prediction. For certain video coding standards, in-loop filter(s) may be used for enhancing the image quality of the reconstructed frame.
For certain real-time communication application such as video over LTE (ViLTE), the available channel bandwidth may vary due to channel variation. If video frames are encoded at a fixed frame rate by a transmitter end, it is possible that large quantization parameters are needed by encoding of blocks in video frames for allowing the resulting encoded video frames generated at the fixed frame rate to be successfully transmitted over a channel with a small channel bandwidth. After the encoded video frames are decoded at a receiver end, the image quality of the decoded video frames is poor due to artifacts introduced by quantization that uses large quantization parameters. Moreover, if the encoding setting of a video frame is not properly set, the coding efficiency of the video frame may be poor.
Thus, there is a need for an adaptive video encoding scheme which is capable of improving the image quality of the decoded video frames at a decoder end and/or the coding efficiency of the video frames at an encoder end by adaptively adjusting the video encoding operation at the encoder end.
In accordance with exemplary embodiments of the present invention, a method and apparatus for adaptive video encoding are proposed to solve the above-mentioned problem.
According to a first aspect of the present invention, an exemplary adaptive video encoding method is disclosed. The exemplary adaptive video encoding method includes: encoding, by an encoding circuit, a current frame to generate a current encoded frame; and after the current frame is encoded, obtaining quantization parameter information of at least one encoded frame, wherein said at least one encoded frame comprises the current encoded frame, and referring to the quantization parameter information to adaptively adjust a frame rate of at least one next frame to be actually encoded by the encoding circuit.
According to a second aspect of the present invention, an exemplary adaptive video encoding method is disclosed. The exemplary adaptive video encoding method includes: encoding, by an encoding circuit, a current frame to generate a current encoded frame; and after the current frame is encoded, setting re-encode indication according to at least encoding-related information of the current frame, and referring to the re-encode indication for adaptively re-encoding, by the encoding circuit, the current frame to update the current encoded frame.
According to a third aspect of the present invention, an exemplary video encoder for adaptive video encoding is disclosed. The exemplary video encoder includes an encoding circuit and a control circuit. The encoding circuit is arranged to encode a current frame to generate a current encoded frame. After the current frame is encoded, the control circuit is arranged to obtain quantization parameter information of at least one encoded frame, wherein said at least one encoded frame comprises the current encoded frame; and refer to the quantization parameter information to adaptively adjust a frame rate of at least one next frame to be actually encoded by the encoding circuit.
According to a fourth aspect of the present invention, an exemplary video encoder for adaptive video encoding is disclosed. The exemplary video encoder includes an encoding circuit and a control circuit. The encoding circuit is arranged to encode a current frame to generate a current encoded frame. After the current frame is encoded, the control circuit is arranged to set re-encode indication according to at least encoding-related information of the current frame, and the encoding circuit is further arranged to refer to the re-encode indication for adaptively re-encoding the current frame to update the current encoded frame.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
Certain terms are used throughout the description and following claims to refer to particular components. As one skilled in the art will appreciate, manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following description and in the claims, the terms “include” and “comprise” are used in an open-ended fashion, and thus should be interpreted to mean “include, but not limited to . . . ”. Also, the term “couple” is intended to mean either an indirect or direct electrical connection. Accordingly, if one device is coupled to another device, that connection may be through a direct electrical connection, or through an indirect electrical connection via other devices and connections.
The control circuit 104 is implemented to control an adaptive video encoding function of the video encoder 100. In this embodiment, the control circuit 104 gets encoding-related information INFenc of frames encoded by the encoding circuit 103, and adaptively adjusts the drop-frame level LVdf according to the encoding-related information INFenc. For example, the control circuit 104 obtains quantization parameter information QPenc of at least one encoded frame according to the encoding-related information INFenc.
In this embodiment, after the encoding circuit 103 encodes a current frame (i.e., a current un-encoded frame) to generate a current encoded frame, the control circuit 104 obtains the quantization parameter information QPenc of at least one encoded frame, wherein the at least one encoded frame includes the current encoded frame. For example, the control circuit 104 determines the quantization parameter information QPenc by applying an arithmetic operation to quantization parameters (QPs) derived from quantization parameters assigned to blocks that are encoded in the at least one encoded frame, wherein the arithmetic operation may be used to obtain an average value of QPs, a weighted sum value of average QPs, a minimum value of QPs, or a maximum value of QPs.
In a first exemplary design, the control circuit 104 may obtain the quantization parameter information QPenc of the current encoded frame. For example, the quantization parameter information QPenc is the average of quantization parameters assigned to blocks that are encoded in the current encoded frame. For another example, the quantization parameter information QPenc is the maximum value among quantization parameters assigned to blocks that are encoded in the current encoded frame.
In a second exemplary design, the control circuit 104 may obtain the quantization parameter information QPenc of the current encoded frame and one or more previous encoded frames. For example, the quantization parameter information QPenc is the weighted sum of the average QP of the current encoded frame and average QP(s) of previous encoded frame(s). The computation of the quantization parameter information QPenc may be expressed using the following equation: QPenc=QPfrm0×½+QPfrm1×¼+QPfrm2×⅛+ . . . , where QPfrm0 is the average QP of encoded frame 0 (i.e., current encoded frame), QPfrm1 is the average QP of encoded frame 1 (i.e., previous encoded frame) that is generated immediately before encoded frame 0, and QPfrm2 is the average QP of encoded frame 2 (i.e., previous encoded frame) that is generated immediately before encoded frame 1. Hence, when a next frame becomes a current frame and is encoded to generate a current encoded frame with the average QP denoted by QPfrm0, the quantization parameter information QPenc may be updated by using the equation: QPenc=QPfrm0×½+QPenc×½. For another example, the quantization parameter information QPenc is the maximum value among quantization parameters assigned to blocks that are encoded in the current encoded frame and the previous encoded frame(s).
When the quantization parameter information QPenc is obtained after the current frame is encoded, the control circuit 104 refers to the quantization parameter information QPenc to adaptively adjust/control a frame rate of at least one next frame to be actually encoded by the encoding circuit 103. In this embodiment, the control circuit 104 determines a next drop-frame level LVdf according to a current drop-frame level LVdf and the quantization parameter information QPenc, and the frame dropping circuit 102 adaptively adjusts/controls the frame rate of next frame(s) by selectively dropping at least one frame received from the frame source device 101 according to the next drop-frame level LVdf set by the control circuit 104.
Regarding the flow shown in
The frame rate is determined/controlled by the drop-frame level LVdf. In this embodiment, the drop-frame level 0 (i.e., LVdf=0) means no dropping of un-encoded frames received from the frame source device 101, such that the new frame rate is equal to the maximum frame rate FR_MAX; the drop-frame level 1 (i.e., LVdf=1) means dropping 1 un-encoded frame among 5 consecutive un-encoded frames received from the frame source device 101, such that the new frame rate is equal to FR_MAX*(4/5); the drop-frame level 2 (i.e., LVdf=2) means dropping 1 un-encoded frame among 3 consecutive un-encoded frames received from the frame source device 101, such that the new frame rate is equal to FR_MAX*(2/3) ; and the drop-frame level 3 (i.e., LVdf=3) means dropping 1 un-encoded frame among 2 consecutive un-encoded frames received from the frame source device 101, such that the new frame rate is equal to FR_MAX*(1/2).
The following table shows a first example of the corresponding frame rates at different drop-frame levels, where the frame rate at the drop-frame level 0 is 30 fps (frames per second).
The following table shows a second example of the corresponding frame rates at different drop-frame levels, where the frame rate at the drop-frame level 0 is 20 fps.
In the embodiment shown in
The control circuit 404 is implemented to control an adaptive video encoding function of the video encoder 400. In this embodiment, the control circuit 404 gets encoding-related information INFenc of frames encoded by the encoding circuit 402, and adaptively adjusts/controls the frame-rate level LVfr according to the encoding-related information INFenc. For example, the control circuit 404 obtains quantization parameter information QPenc of at least one encoded frame according to the encoding-related information INFenc.
In this embodiment, after the encoding circuit 402 encodes a current frame to generate a current encoded frame, the control circuit 404 obtains the quantization parameter information QPenc of at least one encoded frame, wherein the at least one encoded frame includes the current encoded frame. For example, the control circuit 404 determines the quantization parameter information QPenc by applying an arithmetic operation to quantization parameters (QPs) derived from quantization parameters assigned to blocks that are encoded in the at least one encoded frame, wherein the arithmetic operation may be used to obtain an average value of QPs, a weighted sum value of average QPs, a minimum value of QPs, or a maximum value of QPs.
In a first exemplary design, the control circuit 404 may obtain the quantization parameter information QPenc of the current encoded frame. For example, the quantization parameter information QPenc is the average of quantization parameters assigned to blocks that are encoded in the current encoded frame. For another example, the quantization parameter information QPenc is the maximum value among quantization parameters assigned to blocks that are encoded in the current encoded frame.
In a second exemplary design, the control circuit 404 may obtain the quantization parameter information QPenc of the current encoded frame and one or more previous encoded frames. For example, the quantization parameter information QPenc is the weighted sum of the average QP of the current encoded frame and average QP(s) of previous encoded frame(s). The computation of the quantization parameter information QPenc may be expressed using the following equation: QPenc=QPfrm0×½+QPfrm1×¼+QPfrm2×⅛+ . . . , where QPfrm0 is the average QP of encoded frame 0 (i.e., current encoded frame), QPfrm1 is the average QP of encoded frame 1 (i.e., previous encoded frame) that is generated immediately before encoded frame 0, and QPfrm2 is the average QP of encoded frame 2 (i.e., previous encoded frame) that is generated immediately before encoded frame 1. Hence, when a next frame becomes a current frame and is encoded to generate a current encoded frame with the average QP denoted by QPfrm0, the quantization parameter information QPenc may be updated by using the equation: QPenc=QPfrm0×½+QPencx×½. For another example, the quantization parameter information QPenc is the maximum value among quantization parameters assigned to blocks that are encoded in the current encoded frame and previous encoded frame(s).
When the quantization parameter information QPenc is obtained after the current frame is encoded, the control circuit 404 refers to the quantization parameter information QPenc to adaptively adjust/control a frame rate of at least one next frame to be actually encoded by the encoding circuit 402. In this embodiment, the control circuit 404 determines a next frame-rate level LVfr according to a current frame-rate level LVfr and the quantization parameter information QPenc, and instructs the frame source device 401 to provide at least one frame at a frame rate that is designated by the next frame-rate level LVfr. In this way, the frame rate of at least one next frame to be actually encoded by the encoding circuit 402 can be adaptively adjusted.
Regarding the flow shown in
The frame rate is determined/controlled by the frame-rate level LVfr. In this embodiment, the frame-rate level 0 (i.e., LVfr=0) means a highest frame rate in all selectable frame-rate levels; the frame-rate level 1 (i.e., LVfr=1) means a frame rate lower than the frame-rate level 0; the frame-rate level 2 (i.e., LVfr=2) means a frame rate lower than the frame-rate level 1; and the frame-rate level 3 (i.e., LVfr=3) means a frame rate lower than the frame-rate level 2.
The following table shows a first example of the corresponding frame rates at different frame-rate levels, where the frame rate at the frame-rate level 0 is 30 fps (frames per second).
The following table shows a second example of the corresponding frame rates at different frame-rate levels, where the frame rate at the frame-rate level 0 is 20 fps.
Each of the video encoders 100 and 400 applies an adaptive frame-rate encoding policy to adaptively adjust/control a frame rate at which un-encoded frames are fed into the encoding circuit 103/402, thus resulting in an adaptively controlled frame rate at which encoded frames are generated from the encoding circuit 103/402 and transmitted via communication channel(s). When the next frame rate determined by the adaptive frame-rate encoding policy for next frame(s) to be encoded becomes lower, it implies that the quality of the current encoded frame generated from encoding the current frame with a current frame rate (which is higher than the determined next frame rate) is poor. In some embodiments of the present invention, each of the video encoders 100 and 400 may be further configured to support an adaptive re-encoding function. Hence, after the next frame rate is determined by the adaptive frame-rate encoding policy for next frame(s) to be encoded, the current frame may be adaptively re-encoded to update the current encoded frame that will be transmitted via communication channel(s).
Please refer to
Hence, after the current frame with the first frame rate is encoded, the control circuit 104 checks if the second frame rate determined by the adaptive frame-rate encoding policy is lower than the first frame rate of the current frame. When the second frame rate determined by the adaptive frame-rate encoding policy is lower than the first frame rate, the control circuit 104 sets the re-encode indication INDreenc as true to thereby enable re-encoding of the current frame. When the second frame rate determined by the adaptive frame-rate encoding policy is not lower than the first frame rate, the control circuit 104 sets the re-encode indication INDreenc as false to thereby disable re-encoding of the current frame. To put it simply, the encoding circuit 103 re-encodes the current frame to update the current encoded frame when the re-encode indication INDreenc is true, and does not re-encode the current frame to update the current encoded frame when the re-encode indication INDreenc is false.
Please refer to
Hence, after the current frame with the first frame rate is encoded, the control circuit 404 checks if the second frame rate determined by the adaptive frame-rate encoding policy is lower than the first frame rate of the current frame. When the second frame rate determined by the adaptive frame-rate encoding policy is lower than the first frame rate, the control circuit 404 sets the re-encode indication INDreenc as true to thereby enable re-encoding of the current frame. When the second frame rate determined by the adaptive frame-rate encoding policy is not lower than the first frame rate, the control circuit 404 sets the re-encode indication INDreenc as false to thereby disable re-encoding of the current frame. To put it simply, the encoding circuit 402 re-encodes the current frame to update the current encoded frame when the re-encode indication INDreenc is true, and does not re-encode the current frame to update the current encoded frame when the re-encode indication INDreenc is false.
Re-encoding of the current frame may be achieved by using a different frame rate, a different frame type, a different initial quantization parameter, and/or a different resolution. Further details of the proposed adaptive re-encoding scheme implemented in the video encoder 100/400 are described as below.
When the second frame rate is lower than the first frame rate, the control circuit 104/404 sets the re-encode indication INDreenc as true to enable re-encoding of the current frame. Hence, at step 708, the encoding circuit 103/402 re-encodes the current frame with the second frame rate that is different from (e.g., lower than) the first frame rate. Next, the flow proceeds with step 710 for processing a next frame that is received by the encoding circuit 103/402 and becomes a current frame to be encoded by the encoding circuit 103/402. It should be noted that the same adaptive re-encoding policy may also be applied to the next frame for adaptively re-encoding the next frame with a different frame rate.
When the second frame rate is lower than the first frame rate, the control circuit 104/404 sets the re-encode indication INDreenc as true to enable re-encoding of the current frame. Hence, at step 808, the encoding circuit 103/402 re-encodes the current frame with the second frame rate and a second frame type, wherein the second frame rate is different from (e.g., lower than) the first frame rate, and the second frame type is different from the first frame type.
For example, the encoding-related information INFenc may further include mode type information of blocks that are encoded in the current encoded frame. One block in a frame may be encoded in an intra mode or an inter mode when a frame type of the frame is an inter frame. Each block in a frame is encoded in an intra mode when a frame type of the frame is an intra frame. The second frame type may be determined by the control circuit 404 according to the mode type information of blocks that are encoded in the current encoded frame. Suppose that the first frame type is an inter frame. Hence, the current frame with the first frame type may have all blocks encoded in the inter mode, or may have all blocks encoded in the intra mode, or may have some blocks encoded in the intra mode and some blocks encoded in the inter mode. Since one block may be encoded in the intra mode or the inter mode when the frame type is an inter frame, the mode type of each block that is encoded in the current encoded frame is required to be signaled. In other words, extra bits in the bitstream are needed to signal mode types of blocks that are encoded in the current encoded frame. If a ratio of blocks in the current frame that are encoded in intra mode to all blocks in the current frame is larger than a predetermined threshold, the coding efficiency of the current frame can be improved by re-encoding the current frame with the second frame type that is determined as an intra frame. Since the current frame with the second frame type may have all blocks encoded in the intra mode only, the number of extra bits in the bitstream that are used to signal mode types of blocks encoded in the current encoded frame can be significantly reduced. Hence, if the first frame type is an inter frame and a ratio of blocks in the current frame that are encoded in intra mode to all blocks in the current frame is larger than a predetermined threshold, the second frame type may be determined as an intra frame.
After the current frame is re-encoded at step 808, the flow proceeds with step 810 for processing a next frame that is received by the encoding circuit 103/402 and becomes a current frame to be encoded by the encoding circuit 103/402. It should be noted that the same adaptive re-encoding policy may also be applied to the next frame for adaptively re-encoding the next frame with a different frame type.
When the second frame rate is lower than the first frame rate, the control circuit 104/404 sets the re-encode indication INDreenc as true to enable re-encoding of the current frame. Hence, at step 908, the encoding circuit 103/402 re-encodes the current frame with the second frame rate and a second initial quantization parameter, wherein the second frame rate is different from (e.g., lower than) the first frame rate, and the second initial quantization parameter is different from the first initial quantization parameter. As mentioned above, the encoding-related information INFenc may include quantization parameters assigned to blocks that are encoded in the current encoded frame. If the first initial quantization parameter is not properly set (e.g., the first initial quantization parameter is set by a small value), it is possible that the quantization parameters assigned to blocks change frequently. The coding efficiency of the current frame may be poor due to more bits needed to record different quantization parameter settings. The coding efficiency of the current frame can be improved by re-encoding the current frame with the second frame type that is determined according to the quantization parameters assigned to blocks that are encoded in the current encoded frame. In this embodiment, the control circuit 104 determines the second initial quantization parameter by applying an arithmetic operation to quantization parameters assigned to blocks that are encoded in the current encoded frame. For example, the second initial quantization parameter is the average of quantization parameters assigned to blocks that are encoded in the current encoded frame. For another example, the second initial quantization parameter is the maximum value among quantization parameters assigned to blocks that are encoded in the current encoded frame. For yet another example, the second initial quantization parameter is the median value among quantization parameters assigned to blocks that are encoded in the current encoded frame.
After the current frame is re-encoded at step 908, the flow proceeds with step 910 for processing a next frame that is received by the encoding circuit 103/402 and becomes a current frame to be encoded by the encoding circuit 103/402. It should be noted that the same adaptive re-encoding policy may also be applied to the next frame for adaptively re-encoding the next frame with a different initial quantization parameter.
When the second frame rate is lower than the first frame rate, the control circuit 104/404 sets the re-encode indication INDreenc as true to enable re-encoding of the current frame. Hence, at step 1008, the encoding circuit 103/402 re-encodes the current frame with the second frame rate and a second resolution, wherein the second frame rate is different from (e.g., lower than) the first frame rate, and the second resolution is different from (e.g., smaller than) the first resolution.
The encoding-related information INFenc may further include bit-budget information of the current frame. If the first resolution is high, it is possible that the bit budget after encoding the current frame with the first resolution is lower than a predetermined threshold. That is, the difference between a bit budget assigned to the current frame and the number of bits of the current encoded frame may be lower than the predetermined threshold. The number of bits of the current encoded frame can be reduced by re-encoding the current frame with the second resolution that is determined according to the bit-budget information of the current frame. For example, if the bit budget after encoding the current frame with the first resolution is lower than the predetermined threshold, the control circuit 104/404 sets the second resolution by a value smaller than the first resolution.
After the current frame is re-encoded at step 1008, the flow proceeds with step 1010 for processing a next frame that is received by the encoding circuit 103/402 and becomes a current frame to be encoded by the encoding circuit 103/402. It should be noted that the same adaptive re-encoding policy may also be applied to the next frame for adaptively re-encoding the next frame with a different resolution.
In some embodiments of the present invention, the video encoder 100/400 may employ the proposed adaptive frame-rate encoding policy without using the proposed adaptive re-encoding policy. Taking the video encoder 100 for example, the control circuit 104 may adaptively adjust the drop-frame level LVdf without adaptively setting the re-encode indication INDreenc. Taking the video encoder 400 for example, the control circuit 404 may adaptively adjust the frame-rate level LVfr without adaptively setting the re-encode indication INDreenc.
In some embodiments of the present invention, the video encoder 100/400 may employ the proposed adaptive frame-rate encoding policy as well as the proposed adaptive re-encoding policy. Taking the video encoder 100 for example, the control circuit 104 may adaptively adjust the drop-frame level LVdf, and may also adaptively set the re-encode indication INDreenc. Taking the video encoder 400 for example, the control circuit 404 may adaptively adjust the frame-rate level LVfr, and may also adaptively set the re-encode indication INDreenc. Note that a frame rate determined by the adaptive frame-rate encoding policy is involved in controlling the adaptive re-encoding policy. However, this is for illustrative purposes only, and is not meant to be a limitation of the present invention. In an alternative design, the adaptive re-encoding may be controlled by re-encode indication INDreenc that is not set according to a comparison of a first frame rate and a second frame.
The control circuit 1104 is implemented to control an adaptive re-encoding function of the video encoder 1100. In this embodiment, after the current frame is encoded to generate the current encoded frame, the control circuit 1104 gets encoding-related information INFenc of the current frame encoded by the encoding circuit 1103, and sets the re-encode indication INDreenc according to at least the encoding-related information INFenc. The encoding circuit 1103 refers to the re-encode indication INDreenc for adaptively re-encoding the current frame to update the current encoded frame that will be transmitted via communication channel(s). Hence, when the control circuit 1104 sets the re-encode indication INDreenc as true, re-encoding of the current frame is enabled at the encoding circuit 1103; and when the control circuit 1104 sets the re-encode indication INDreenc as false, re-encoding of the current frame is disabled at the encoding circuit 1103.
Re-encoding of the current frame may be achieved by using a different frame type, a different initial quantization parameter, and/or a different resolution. Further details of the proposed adaptive re-encoding scheme implemented in the video encoder 1100 are described as below.
For example, the encoding-related information INFenc may include mode type information of blocks that are encoded in the current encoded frame. One block of a frame may be encoded in an intra mode or an inter mode when a frame type of the frame is an inter frame. Each block of a frame is encoded in an intra mode when a frame type of the frame is an intra frame. A second frame type maybe determined by the control circuit 1104 according to the mode type information of blocks that are encoded in the current encoded frame. In a first exemplary design, the controller 1104 sets the re-encode indication INDreenc as true when the second frame type determined for re-encoding the current frame is different from the first frame type; otherwise, the control circuit 1104 sets the re-encode indication INDreenc as false.
Suppose that the first frame type is an inter frame. Hence, the current frame with the first frame type may have all blocks encoded in the inter mode, or may have all blocks encoded in the intra mode, or may have some blocks encoded in the intra mode and some blocks encoded in the inter mode. Since one block may be encoded in the intra mode or the inter mode when the frame type is an inter frame, the mode type of each block that is encoded in the current encoded frame is required to be signaled. In other words, extra bits in the bitstream are needed to signal mode types of blocks that are encoded in the current encoded frame. If a ratio of blocks in the current frame that are encoded in intra mode to all blocks in the current frame is larger than a predetermined threshold, the coding efficiency of the current frame can be improved by re-encoding the current frame with the second frame type that is determined as an intra frame. Since the current frame with the second frame type may have all blocks encoded in the intra mode only, the number of extra bits in the bitstream that are used to signal mode types of blocks encoded in the current encoded frame can be significantly reduced. In a second exemplary design, the controller 1104 sets the re-encode indication INDreenc as true if the first frame type is an inter frame and a ratio of blocks in the current frame that are encoded in intra mode to all blocks in the current frame is larger than a predetermined threshold; otherwise, the controller 1104 sets the re-encode indication INDreenc as false.
At step 1206, the encoding circuit 1103 checks if the re-encode indication INDreenc is true. When the re-encode indication INDreenc is false, re-encoding of the current frame is disabled, and the flow proceeds with step 810 for processing a next frame that is received by the encoding circuit 1103 and becomes a current frame to be encoded by the encoding circuit 1103. As mentioned above, the same adaptive re-encoding policy may also be applied to the next frame for adaptively re-encoding the next frame with a different frame type. When the re-encode indication INDreenc is true, re-encoding of the current frame is enabled. Hence, at step 808, the encoding circuit 1103 re-encodes the current frame with the second frame type, wherein the second frame type is different from the first frame type. For example, if the first frame type is an inter frame and a ratio of blocks in the current frame that are encoded in intra mode to all blocks in the current frame is larger than a predetermined threshold, the second frame type is determined as an intra frame.
For example, the encoding-related information INFenc may include quantization parameters assigned to blocks that are encoded in the current encoded frame. In a first exemplary design, the control circuit 1104 sets the re-encode indication INDreenc as true when a quantization parameter calculation result is larger than a first predetermined threshold; otherwise, the control circuit 1104 sets the re-encode indication INDreenc as false. The quantization parameter calculation result may be derived from applying an arithmetic operation to quantization parameters assigned to blocks that are encoded in the current encoded frame. For example, the quantization parameter calculation result can be the absolute difference of the maximum value and the minimum value among the quantization parameters assigned to blocks that are encoded in the current encoded frame. For another example, the quantization parameter calculation result can be the variance of the quantization parameters assigned to blocks that are encoded in the current encoded frame. For yet another example, the quantization parameter calculation result can be the average value of the quantization parameters assigned to blocks that are encoded in the current encoded frame. For further another example, the quantization parameter calculation result can be the maximum value (or the minimum value) of the quantization parameters assigned to blocks that are encoded in the current encoded frame.
If the first initial quantization parameter is not properly set (e.g., the first initial quantization parameter is set by a small value), it is possible that the quantization parameters assigned to blocks change frequently. The coding efficiency of the current frame may be poor due to more bits needed to record the different quantization parameter settings. The coding efficiency of the current frame can be improved by re-encoding the current frame with the second frame type that is determined according to the quantization parameters assigned to blocks that are encoded in the current encoded frame. In a second exemplary design, the controller 1104 sets the re-encode indication INDreenc as true when a difference between the first initial quantization parameter and the second initial quantization parameter determined for re-encoding the current frame is larger than a second predetermined threshold; otherwise, the control circuit 1104 sets the re-encode indication INDreenc as false.
At step 1306, the encoding circuit 1103 checks if the re-encode indication INDreenc is true. When the re-encode indication INDreenc is false, re-encoding of the current frame is disabled, and the flow proceeds with step 910 for processing a next frame that is received by the encoding circuit 1103 and becomes a current frame to be encoded by the encoding circuit 1103. As mentioned above, the same adaptive re-encoding policy may also be applied to the next frame for adaptively re-encoding the next frame with a different initial quantization parameter. When the re-encode indication INDreenc is true, re-encoding of the current frame is enabled. Hence, at step 908, the encoding circuit 1103 re-encodes the current frame with the second initial quantization parameter, wherein the second initial quantization parameter is different from the first initial quantization parameter. The control circuit 104 may determine the second initial quantization parameter by applying an arithmetic operation to quantization parameters assigned to blocks that are encoded in the current encoded frame. For example, the second initial quantization parameter is the average of quantization parameters assigned to blocks that are encoded in the current encoded frame. For another example, the second initial quantization parameter is the maximum value among quantization parameters assigned to blocks that are encoded in the current encoded frame. For yet another example, the second initial quantization parameter is the median value among quantization parameters assigned to blocks that are encoded in the current encoded frame.
For example, the encoding-related information INFenc may include bit-budget information of the current frame. If the first resolution is high, it is possible that the bit budget after encoding the current frame with the first resolution is lower than a predetermined threshold. That is, the difference between a bit budget assigned to the current frame and the number of bits of the current encoded frame may be lower than the predetermined threshold. The number of bits of the current encoded frame can be reduced by re-encoding the current frame with the second resolution that is determined according to the bit-budget information of the current frame. In a first exemplary design, the controller 1104 sets the re-encode indication INDreenc as true when a ratio of the first resolution to the second resolution determined for re-encoding the current frame is larger than a first predetermined threshold; otherwise, the control circuit 1104 sets the re-encode indication INDreenc as false. The first resolution is defined by an image width W1 and an image height H1. The second resolution is defined by an image width W2 and an image height H2, where W2≠W1 and/or H2≠H1. The ratio of the first resolution to the second resolution may be expressed as W1*H1/W2*H2.
In a second exemplary design, the controller 1104 sets the re-encode indication INDreenc as true when the bit budget after encoding the current frame with the first resolution is lower than a second predetermined threshold; otherwise, the control circuit 1104 sets the re-encode indication INDreenc as false.
At step 1406, the control circuit 1104 checks if the re-encode indication INDreenc is true. When the re-encode indication INDreenc is false, re-encoding of the current frame is disabled, and the flow proceeds with step 1010 for processing a next frame that is received by the encoding circuit 1103 and becomes a current frame to be encoded by the encoding circuit 1103. As mentioned above, the same adaptive re-encoding policy may also be applied to the next frame for adaptively re-encoding the next frame with a different resolution. When the re-encode indication INDreenc is true, re-encoding of the current frame is enabled. Hence, at step 1008, the encoding circuit 1103 re-encodes the current frame with the second resolution, wherein the second resolution is different from (e.g., smaller than) the first resolution. For example, if the bit budget after encoding the current frame with the first resolution is lower than the second predetermined threshold, the control circuit 1104 sets the second resolution by a value smaller than the first resolution.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
This application claims the benefit of U.S. provisional application No. 62/502,831, filed on May 8, 2017 and incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
62502831 | May 2017 | US |