Picture-level QP rate control for HEVC encoding
A method and system for controlling a bit rate of an encoded video including a plurality of pictures is provided. In the method, each of the plurality of pictures is one of a plurality of picture types. For the method, a number of bits required to encode a current picture as well as other pictures in a window is determined, and the fullness of a buffer storing the current picture and other picture data is estimated and compared to buffer fullness limits. This process is repeated for different quantization values to determine a suitable quantization value.
1. A method of controlling a bit rate of an encoded video comprising a plurality of pictures, each of the plurality of pictures being of one of a plurality of picture types, comprising:
(a) defining a window of M pictures comprising a plurality of window pictures;
(b) defining a parameter set for each picture type T, each parameter set comprising:
a quantization parameter (Q T );
a first parameter (α T );
a second parameter (β T );
(c) estimating a number of bits R needed to encode a current picture of picture type T; according to:
R
cur
=
e
Q
cur
T
-
α
cur
T
β
cur
T
wherein:
Q cur T is a value of Q T of the current picture of type T;
α cur T is a value of α T of the current picture of type T;
β cur T is a value of β T of the current picture of type T;
(d) estimating a number of bits R i needed to encode each remaining picture i of the window of M pictures of picture type T according to:
R
i
=
e
Q
i
T
-
α
i
T
β
i
T
wherein:
Q i T is a value of Q T of each remaining picture i of type T;
α i T is a value of α T of each remaining picture i of type T;
β i T is a value of β T of each remaining picture i of type T;
(e) determining, for the current picture and each remaining picture i of the window of M pictures and from the estimated number of bits to needed to encode the current picture R cur and the estimated number of bits needed encode each remaining picture i of the window of M pictures, if a maximum video buffer boundary B upper or a minimum video buffer boundary B low are exceeded;
(f) if the maximum video buffer boundary B upper or the minimum video buffer boundary B low are exceeded, adjusting Q cur T for the current picture of picture type T and Q i T of each remaining picture i of picture type T, and repeating (d)-(f); and
(g) if the maximum video buffer boundary B upper and the minimum video buffer boundary B low are not exceeded, designating Q cur T as a value for coding the current picture:
coding the current picture according to Q cur T ,
after coding the current picture according to Q cur T :
updating α T and β T for the picture type T of the current picture;
setting a next remaining picture as the current picture and performing steps (c)-(g);
determining the actual number of bits R r used to code the current picture;
determining a difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture; and
updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε;
wherein updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε comprises:
computing updated values for α T and β T for the picture type of the current picture that minimize the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r .
2. The method of claim 1 , further comprising:
repeating (d)-(g) for further adjusted values for the current picture of picture type T and Q i T of each remaining picture i of picture type T;
choosing an optimal Q i T from among the adjusted and further adjusted values; and
coding the current picture according to the optimal Q i T .
3. A method of controlling a bit rate of an encoded video comprising a plurality of pictures, each of the plurality of pictures being of one of a plurality of picture types, comprising:
(a) defining a window of M pictures comprising a plurality of window pictures;
(b) defining a parameter set for each picture type T, each parameter set comprising:
a quantization parameter (Q T );
a first parameter (α T );
a second parameter (β T );
(c) estimating a number of bits R needed to encode a current picture of picture type T; according to:
R
cur
=
e
Q
cur
T
-
α
cur
T
β
cur
T
wherein:
Q cur T is a value of Q T of the current picture of type T;
α cur T is a value of α T of the current picture of type T;
β cur T is a value of β T of the current picture of type T;
(d) estimating a number of bits R i needed to encode each remaining picture i of the window of M pictures of picture type T according to:
R
i
=
e
Q
i
T
-
α
i
T
β
i
T
wherein:
Q i T is a value of Q T of each remaining picture i of type T;
α i T is a value of α T of each remaining picture i of type T;
β i T is a value of β T of each remaining picture i of type T;
(e) determining, for the current picture and each remaining picture i of the window of M pictures and from the estimated number of bits to needed to encode the current picture R cur and the estimated number of bits needed encode each remaining picture i of the window of M pictures, if a maximum video buffer boundary B upper or a minimum video buffer boundary B low are exceeded;
(f) if the maximum video buffer boundary B upper or the minimum video buffer boundary B low are exceeded, adjusting Q cur T for the current picture of picture type T and Q i T of each remaining picture i of picture type T, and repeating (d)-(f); and
(g) if the maximum video buffer boundary B upper and the minimum video buffer boundary B low are not exceeded, designating Q cur T as a value for coding the current picture:
coding the current picture according to Q cur T ,
after coding the current picture according to Q cur T :
updating α T and β T for the picture type T of the current picture;
setting a next remaining picture as the current picture and performing steps (c)-(g);
determining the actual number of bits R r used to code the current picture;
determining a difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture; and
updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε;
wherein:
the first parameter α T has a maximum value α max T and a minimum value α min T , and the second parameter β T has a maximum value β max T and a minimum value β min T for each picture type T, and
updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε comprises:
(i) setting α j T =α cur T ;
(ii) setting β j T =β cur T ;
(iii) setting α L =α min T ;
(iv) setting β L =β min T ;
(v) setting β H =α max T ;
(vi) setting β H =β max T ;
(vii) determining if
e
Q
i
T
-
α
j
T
β
j
T
-
R
r
<
ɛ
;
if
e
Q
i
T
-
α
j
T
β
j
T
-
R
r
<
ɛ
determining the updated values for α T and β T as the current values for α j T and β j T ;
if
e
Q
i
T
-
α
j
T
β
j
T
-
R
r
≥
ɛ
:
determining if
e
Q
j
T
-
α
L
T
β
L
T
<
R
r
<
e
Q
j
T
-
α
j
T
β
j
T
;
if
e
Q
j
T
-
α
L
T
β
L
T
<
R
r
<
e
Q
j
T
-
α
j
T
β
j
T
:
setting α H =α j T
setting β H =β j T
computing
α
j
+
1
T
=
α
L
+
α
H
2
computing
β
j
+
1
T
=
β
L
+
β
H
2
setting j=j+1;
repeating step (vii);
determining if
e
Q
j
T
-
α
j
T
β
j
t
<
R
r
<
e
Q
j
T
-
α
H
T
β
j
t
;
if
e
Q
j
T
-
α
j
T
β
j
t
<
R
r
<
e
Q
j
T
-
α
H
T
β
j
t
:
setting α L =α j T
setting β L =β j T
computing
α
j
+
1
T
=
α
L
+
α
H
2
computing
β
j
+
1
T
=
β
L
+
β
H
2
setting j=j+1;
repeating step (vii).
4. The method of claim 1 , wherein determining, for the current picture and each remaining picture i of the window of M pictures and from the estimated number of bits to needed to encode the current picture R cur and the estimated number of bits needed encode each remaining picture i of the window of M pictures, if a maximum video buffer boundary B upper or a minimum video buffer boundary B low are exceeded comprises:
determining an estimated video buffer fullness immediately before the coding of the current picture as B cur− =B (cur−1)+ +R pic nominal <B upper , wherein B (cur−2)+ is the video buffer fullness just after the picture temporally previous to the current picture, and R pic nominal is a nominal number of bits per picture;
determining an estimated video buffer fullness immediately after the coding of the current picture as B cur+ =B cur− −R cur <B low ;
determining an estimated video buffer fullness immediately before the coding of each picture i as B i− =B (i−1)+ +R pic nominal <B upper , wherein B (i−2)+ is the video buffer fullness just after the temporally previous picture;
determining an estimated video buffer fullness immediately after the coding of picture i as B 1+ =B i− −R i <B low ;
determining that a maximum video buffer boundary B upper or a minimum video buffer boundary B low are exceeded only if:
B cur− −B upper ;
B cur+ <B low ;
B i− <B upper ; or
B i+ <B low .
5. The method of claim 1 , wherein the quantization parameter Q T for each picture type T differs from a quantization parameter for other picture types by an offset.
6. The method of claim 1 , wherein the quantization parameter Q T for each picture type T has the same value.
7. The method of claim 1 , wherein defining a parameter set for each picture type T comprises:
setting α T to an initial value α T initial ;
setting β T to an initial value β T initial ; and
setting Q T equal to an initial value Q T initial .
8. The method of claim 1 , wherein:
Q cur T has the value of Q T for a most previously coded picture of the same type T as the current picture.
9. The method of claim 1 , wherein:
α cur T has the value of α T for a most previously coded picture of the same type T as the current picture;
β cur T has a value of a β T value for a most previously coded picture of the same type T as the current picture;
α i T has the value of α T for a most previously coded picture of the same type T as the picture i; and
β cur T has a value of a β T value for a most previously coded picture of the same type T as the picture i.
10. The method of claim 9 , wherein:
the values of α cur T and β cur T are stored in a different memory than the values of α i T and β i T for each remaining picture; and
the values of α i T and β i T for each remaining picture i are stored in a different memory other values of α i T and β i T for the other remaining pictures.
11. An apparatus for controlling a bit rate of an encoded video comprising a plurality of pictures, each of the plurality of pictures being of one of a plurality of picture types, comprising:
a processor;
a memory, communicatively coupled to the processor, the memory storing instructions comprising instructions for:
(a) defining a window of M pictures comprising a plurality of window pictures;
(b) defining a parameter set for each picture type T, each parameter set comprising:
a quantization parameter (Q T );
a first parameter (α T );
a second parameter (β T );
(c) estimating a number of bits R needed to encode a current picture of picture type T according to;
R
cur
=
e
Q
cur
T
-
α
curr
T
β
cur
T
wherein:
Q cur T is a value of Q T of the current picture of type T;
α cur T is a value of α T of the current picture of type T;
β cur T is a value of β T of the current picture of type T;
(d) estimating a number of bits R i needed to encode each remaining picture i of the window of M pictures of picture type T according to:
R
i
=
e
Q
i
T
-
α
i
T
β
i
t
wherein:
Q i T is a value of Q T of each remaining picture i of type T;
α i T is a value of α T of each remaining picture i of type T;
β i T is a value of β T of each remaining picture i of type T;
(e) determining, for the current picture and each remaining picture i of the window of M pictures and from the estimated number of bits to needed to encode the current picture R cur and the estimated number of bits needed encode each remaining picture i of the window of M pictures, if a maximum video buffer boundary B upper or a minimum video buffer boundary B low are exceeded;
(f) if the maximum video buffer boundary B upper or the minimum video buffer boundary B low are exceeded, adjusting Q cur T for the current picture of picture type T and Q i T of each remaining picture i of picture type T, and repeating (d)-(f); and
(g) if the maximum video buffer boundary B upper and the minimum video buffer boundary B low are not exceeded, designating Q cur T as a value for coding the current picture
wherein the instructions further comprise coding the current picture according to Q cur T ,
wherein the instructions further comprise instructions for:
after coding the current picture according to Q cur T :
updating α T and β T for the picture type T of the current picture;
setting a next remaining picture as the current picture and performing instructions (c)-(g);
determining the actual number of bits R r used to code the current picture;
determining a difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture; and
updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε;
wherein the instructions for updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε comprise instructions for:
computing updated values for α T and β T for the picture type of the current picture that minimize the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r .
12. An apparatus for controlling a bit rate of an encoded video comprising a plurality of pictures, each of the plurality of pictures being of one of a plurality of picture types, comprising:
a processor;
a memory, communicatively coupled to the processor, the memory storing instructions comprising instructions for:
(a) defining a window of M pictures comprising a plurality of window pictures;
(b) defining a parameter set for each picture type T, each parameter set comprising:
a quantization parameter (Q T );
a first parameter (α T );
a second parameter (β T );
(c) estimating a number of bits R needed to encode a current picture of picture type T according to:
R
cur
=
e
Q
cur
T
-
α
cur
T
β
cur
T
wherein:
Q cur T is a value of Q T of the current picture of type T;
α cur T is a value of α T of the current picture of type T;
β cur T is a value of β T of the current picture of type T;
(d) estimating a number of bits R i needed to encode each remaining picture i of the window of M pictures of picture type T according to:
R
i
=
e
Q
i
T
-
α
i
T
β
i
T
wherein:
Q i T is a value of Q T of each remaining picture i of type T;
α i T is a value of α T of each remaining picture i of type T;
β i T is a value of β T of each remaining picture i of type T;
(e) determining, for the current picture and each remaining picture i of the window of M pictures and from the estimated number of bits to needed to encode the current picture R cur and the estimated number of bits needed encode each remaining picture i of the window of M pictures, if a maximum video buffer boundary B upper or a minimum video buffer boundary B low are exceeded;
(f) if the maximum video buffer boundary B upper or the minimum video buffer boundary B low are exceeded, adjusting Q cur T for the current picture of picture type T and Q i T of each remaining picture i of picture type T, and repeating (d)-(f); and
(g) if the maximum video buffer boundary B upper and the minimum video buffer boundary B low are not exceeded, designating Q cur T as a value for coding the current picture,
wherein the instructions further comprise coding the current picture according to Q cur T ,
wherein the instructions further comprise instructions for:
after coding the current picture according to Q cur T :
updating α T and β T for the picture type T of the current picture;
setting a next remaining picture as the current picture and performing instructions (c)-(g);
determining the actual number of bits R r used to code the current picture;
determining a difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture; and
updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε;
wherein:
the first parameter α T has a maximum value α max T and a minimum value α min T , and the second parameter β T has a maximum value β max T and a minimum value β min T for each picture type T, and
the instructions for updating α T and β T for the picture type T of the current picture only if the difference between the estimated number of bits R cur to encode the current picture and the actual number of bits used to code the current picture R r exceeds a value ε comprise instructions for:
(i) setting α j T =α cur T ;
(ii) setting β j T =β cur T ;
(iii) setting α L =α min T ;
(iv) setting β L =β min T ;
(v) setting β H =α max T ;
(vi) setting β H =β max T ;
(vii) determining if
e
Q
i
T
-
α
j
T
β
j
T
-
R
r
<
ɛ
;
(viii) if
e
Q
i
T
-
α
j
T
β
j
T
-
R
r
<
ɛ
determining the updated values for α T and β T as the current values for α j T and β j T ;
(ix)
if
e
Q
i
T
-
α
j
T
β
j
T
-
R
r
≥
ɛ
:
determining if
e
Q
i
T
-
α
L
T
β
L
T
<
R
r
<
e
Q
i
T
-
α
j
T
β
j
T
;
if
e
Q
i
T
-
α
L
T
β
L
T
<
R
r
<
e
Q
i
T
-
α
j
T
β
j
T
:
setting α H =α j T
setting β H =β j T
computing
α
j
+
1
T
=
α
L
+
α
H
2
computing
β
j
+
1
T
=
β
L
+
β
H
2
setting j=j+1;
repeating step (vii);
determining if
e
Q
i
T
-
α
j
T
β
j
T
<
R
r
<
e
Q
i
T
-
α
H
T
β
H
T
;
if
e
Q
i
T
-
α
L
T
β
L
T
<
R
r
<
e
Q
i
T
-
α
j
T
β
j
T
:
setting α L =α j T
setting β L =β j T
computing
α
j
+
1
T
=
α
L
+
α
H
2
computing
β
j
+
1
T
=
β
L
+
β
H
2
setting j=j+1;
repeating step (vii).