JP6470191B2 - Video encoding method, video encoding apparatus, and video encoding program - Google Patents
Video encoding method, video encoding apparatus, and video encoding program Download PDFInfo
- Publication number
- JP6470191B2 JP6470191B2 JP2016001281A JP2016001281A JP6470191B2 JP 6470191 B2 JP6470191 B2 JP 6470191B2 JP 2016001281 A JP2016001281 A JP 2016001281A JP 2016001281 A JP2016001281 A JP 2016001281A JP 6470191 B2 JP6470191 B2 JP 6470191B2
- Authority
- JP
- Japan
- Prior art keywords
- code amount
- pictures
- picture
- buffer
- encoding
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Compression Or Coding Systems Of Tv Signals (AREA)
Description
本発明は、映像符号化の並列処理において、並列処理数を適切に算出する映像符号化方法、映像符号化装置及び映像符号化プログラムに関する。 The present invention relates to a video encoding method, a video encoding device, and a video encoding program that appropriately calculate the number of parallel processes in parallel processing of video encoding.
映像の符号化を高速に行う方法として、複数のピクチャの符号化処理を並列に行う方法がある。図4は、各ピクチャについてその復号時に参照される他のピクチャとの関係(以下、「参照構造」という。)を表示順に示した図である。ピクチャとは、符号化対象映像の1フレーム(または1画面)である。この図は、片方向予測ピクチャ(以下、「Pピクチャ」という。)1枚に対し、双方向予測ピクチャ(以下、「Bピクチャ」という。)が2枚あるM=3と呼ばれる参照構造を示したものである。各ピクチャの上もしくは下に描かれた矢印は各ピクチャが参照する先のピクチャを表している。 As a method of encoding video at high speed, there is a method of performing encoding processing of a plurality of pictures in parallel. FIG. 4 is a diagram showing the relationship (hereinafter referred to as “reference structure”) of each picture with other pictures referenced at the time of decoding in the order of display. A picture is one frame (or one screen) of an encoding target video. This figure shows a reference structure called M = 3 in which one bidirectional prediction picture (hereinafter referred to as “P picture”) has two bidirectional prediction pictures (hereinafter referred to as “B pictures”). It is a thing. An arrow drawn above or below each picture represents a destination picture to which each picture refers.
この図において、符号化順は各ピクチャの下に数字で示した通り、I1→P1→B1→B2→P2→B3→B4という順番である。しかし参照構造によれば、P1の符号化が終了すると、B1のみではなくB2及びP2も符号化可能である。従って、符号化処理を並列に行えるシステムにおいては、これら3ピクチャを同時に符号化処理することができる。 In this figure, the encoding order is the order of I 1 → P 1 → B 1 → B 2 → P 2 → B 3 → B 4 as indicated by numbers below each picture. However, according to the reference structure, when encoding of P 1 is completed, not only B 1 but also B 2 and P 2 can be encoded. Therefore, in a system that can perform encoding processing in parallel, these three pictures can be encoded simultaneously.
次に、HEVCやH.264をはじめとする一般的な映像符号化規格における符号化部の装置構成を説明する。図5は、一般的な映像符号化規格における符号化部の装置構成を示すブロック図である。図5に示す装置は、原画像バッファ1、復号画像バッファ10及び符号化部12を備える。
Next, HEVC and H.C. An apparatus configuration of an encoding unit in a general video encoding standard such as H.264 will be described. FIG. 5 is a block diagram illustrating a device configuration of an encoding unit in a general video encoding standard. The apparatus shown in FIG. 5 includes an original image buffer 1, a decoded
符号化部12は、減算器2、加算器3、DCT(離散コサイン変換)計算器(図中「DCT」)4、量子化器(図中「Q」)5、逆量子化器(図中「IQ」)6、IDCT(逆離散コサイン変換)計算器(図中「IDCT」)7、予測モード選択部8、ループフィルタ9及びエントロピー符号化部11を備える。
The
原画像バッファ1は、表示順に入力された原画像を保持し、符号化順に並べ替えて順に出力する。減算器2は、原画像バッファ1から送られた原画と予測モード選択部8から送られた予測画像の差分を取って予測残差信号を計算し、DCT計算器4に出力する。
The original image buffer 1 holds the original images input in the display order, rearranges them in the encoding order, and outputs them in order. The
加算器3は、予測モード選択部8から出力された予測画像と、IDCT計算器7から送られる量子化後の予測残差信号の和を計算し、フィルタ前の復号画像としてループフィルタ9に送る。DCT計算器4は、予測残差信号に離散コサイン変換を施し、算出されたDCT係数を量子化器5へ送る。
The
量子化器5は、DCT計算器4から送られたDCT係数を、外部から与えられた量子化パラメータQPを用いて量子化し、DCT係数の量子化値としてエントロピー符号化部11と逆量子化器6へ送る。逆量子化器6は、量子化器5で求まった量子化後のDCT係数を、外部から与えられた量子化パラメータQPを用いて逆量子化し、量子化後のDCT係数としてIDCT計算器7に送る。
The
IDCT計算器7では、逆量子化器6から送られた量子化後のDCT係数に逆離散コサイン変換を施し、量子化後の予測残差信号を求める。予測モード選択部8は、入力された原画像に最も近い予測画像を、同じく入力された参照画像から作成して出力すると共に、その予測モードの情報をエントロピー符号化器11へ送る。
The
ループフィルタ9は、加算器3から送られたフィルタ前の復号画像にフィルタ処理を施し、復号画像として復号画像バッファ10に送る。復号画像バッファ10は、ループフィルタ9から出力された復号画像を保存し、予測モード選択部8に対して参照画像として出力する。
The
エントロピー符号化部11は、量子化器5から送られるDCT係数の量子化値と予測モード選択部8から送られる予測モード情報を可変長符号化し、符号化ストリームとして出力する。
The entropy encoding unit 11 performs variable length encoding on the quantized value of the DCT coefficient sent from the
次に、図6を参照して、図5に示す装置の処理動作を説明する。図6は、図5に示すHEVCやH.264をはじめとする一般的な映像符号化規格における符号化装置の動作を示すフローチャートである。処理が始まると、まず原画像バッファ1は、入力された各ピクチャを符号化順に並べ替える(ステップS21)。 Next, the processing operation of the apparatus shown in FIG. 5 will be described with reference to FIG. 6 shows HEVC or H.264 shown in FIG. 2 is a flowchart showing an operation of an encoding device in a general video encoding standard such as H.264. When the process starts, first, the original image buffer 1 rearranges the inputted pictures in the encoding order (step S21).
以降、符号化部12は各ピクチャを符号化順に処理する。各ピクチャは矩形のブロックに分割される。予測モード選択部8は、ブロックごとに予測モードを決定する(ステップS22)。減算器2は、予測モードに対応する予測画像と原画像との差分を取得する。減算器2は、取得された差分に基づいて予測残差信号を出力する(ステップS23)。
Thereafter, the
次に、DCT計算器4は、出力された予測残差信号にDCT(ステップS24)を施す。量子化器5は、DCT係数に対して量子化(ステップS25)を施す。逆量子化器6は、逆量子化を行う(ステップS26)。IDCT計算器7は、IDCTを計算する(ステップS27)。
Next, the
次に、加算器3は、予測画像と量子化後の予測残差信号とを加算し復号画像を生成する(ステップS28)。ループフィルタ9は、生成された復号画像にループフィルタを掛けて(ステップS29)、復号画像バッファ1に復号画像として保存する(ステップS30)。保存された復号画像は、以降の予測画像生成に利用される。
Next, the
一方、エントロピー符号化部11は、DCTと量子化を施した量子化済みのDCT係数と、対応する予測モード情報とに対して可変長符号化を施し、符号化ストリームとして出力する(ステップS31)。 On the other hand, the entropy encoding unit 11 performs variable-length encoding on the DCT and quantized DCT coefficients that have been subjected to quantization and corresponding prediction mode information, and outputs the result as an encoded stream (step S31). .
図6に示す処理(ステップS22〜S31)が行われる際には、各ピクチャに対して量子化パラメータQPが与えられる必要がある。量子化パラメータQPは、量子化の粗さを表す。量子化パラメータQPが大きいほど粗く量子化され、符号化ノイズが多くなる。一方、量子化パラメータQPが大きいほど、圧縮率が高くなるため発生する符号量は少なくなる。量子化パラメータQPは、予め定められたビットレート及びバッファサイズを元に、デコーダのバッファモデルを順守するように算出される。 When the processing shown in FIG. 6 (steps S22 to S31) is performed, the quantization parameter QP needs to be given to each picture. The quantization parameter QP represents the roughness of quantization. As the quantization parameter QP is larger, the quantization is coarser and coding noise increases. On the other hand, the larger the quantization parameter QP, the higher the compression rate, and the smaller the amount of code generated. The quantization parameter QP is calculated based on a predetermined bit rate and buffer size so as to comply with the buffer model of the decoder.
ここで、デコーダのバッファモデルについて説明する。映像デコーダには符号化ストリームを保存する受信バッファがあり、この受信バッファには外部から受信した符号化ストリームが蓄積される。また、復号の際には1フレーム分ずつ符号化ストリームを受信バッファから引き抜いて復号する。 Here, the buffer model of the decoder will be described. The video decoder has a reception buffer for storing the encoded stream, and the encoded stream received from the outside is stored in the reception buffer. In decoding, the encoded stream is extracted from the reception buffer one frame at a time and decoded.
この受信バッファのサイズは有限のため、受信した符号化ストリームを受信バッファに蓄積する速度と、受信バッファに蓄積された符号化ストリームをバッファから引き抜く速度は釣り合っている必要がある。 Since the size of this reception buffer is finite, the speed at which the received encoded stream is accumulated in the reception buffer and the speed at which the encoded stream accumulated in the reception buffer is extracted from the buffer must be balanced.
例えば、前者の速度が速い場合は受信バッファがフルになって符号化ストリームを受信できなくなる「バッファオーバーフロー」(以下、「オーバーフロー」という。)が発生し、逆に後者の速度が速い場合は受信バッファが空になってピクチャの復号が停止してしまう「バッファアンダーフロー」(以下、「アンダーフロー」という。)が発生する。 For example, when the former speed is high, the reception buffer becomes full and a "buffer overflow" (hereinafter referred to as "overflow") that prevents receiving the encoded stream occurs. Conversely, when the latter speed is high, reception occurs. A “buffer underflow” (hereinafter referred to as “underflow”) occurs in which the buffer becomes empty and decoding of the picture stops.
そこで一般的な映像符号化器では、上記のよう受信バッファのオーバーフローやアンダーフローが起こらないよう、各ピクチャの発生符号量、ひいては量子化パラメータQPを適切に制御するレート制御部と呼ばれる機構が組み込まれている。 Therefore, a general video encoder incorporates a mechanism called a rate control unit that appropriately controls the amount of code generated in each picture and thus the quantization parameter QP so as not to cause overflow or underflow of the reception buffer as described above. It is.
ここで復号順でn枚目ピクチャの復号時刻をt(n)、n枚目ピクチャを復号した直後の受信バッファのデータ蓄積量をBt_after(t(n))と表記する。次のn+1枚目ピクチャを復号する時刻t(n+1)は、フレームレートFPS[フレーム/秒]を用いて、t(n+1)=t(n)+1/FPSと表記できる。 Here, in the decoding order, the decoding time of the nth picture is expressed as t (n), and the data accumulation amount in the reception buffer immediately after decoding the nth picture is expressed as Bt_after (t (n)). The time t (n + 1) at which the next n + 1-th picture is decoded can be expressed as t (n + 1) = t (n) + 1 / FPS using the frame rate FPS [frame / second].
このことから、一般的なCBRモデル(ビットレート一定モデル)の場合、n+1枚目ピクチャを復号する直前の受信バッファのデータ蓄積量Bt_before(t(n+1))は、ビットレートb[bit/秒]を用いて
Bt_before(t(n+1))=Bt_after(t(n))+b/FPS
と表せる。
Therefore, in the case of a general CBR model (constant bit rate model), the data accumulation amount Bt_before (t (n + 1)) of the reception buffer immediately before decoding the (n + 1) th picture is the bit rate b [bit / second]. Using Bt_before (t (n + 1)) = Bt_after (t (n)) + b / FPS
It can be expressed.
ここでn+1枚目ピクチャの発生符号量がG(n+1)だったとすれば、n+1枚目ピクチャを復号した直後の受信バッファにおけるデータ蓄積量Bt_after(t(n+1))は
Bt_after(t(n+1))=Bt_before(t(n+1))−G(n+1)
と表せる。
If the generated code amount of the (n + 1) th picture is G (n + 1), the data accumulation amount Bt_after (t (n + 1)) in the reception buffer immediately after decoding the (n + 1) th picture is Bt_after (t (n + 1)) = Bt_before (t (n + 1))-G (n + 1)
It can be expressed.
ここで、もし、G(n+1)>Bt_before(t(n+1))であった場合、Bt_after(t(n+1))<0となり、バッファアンダーフローが発生する。一方、受信バッファサイズをSと置いたとき、G(n+1)<Bt_before(t(n+1))+b/FPS−Sであった場合、Bt_after(t(n+1))>Sとなり、バッファオーバーフローが発生する。 Here, if G (n + 1)> Bt_before (t (n + 1)), Bt_after (t (n + 1)) <0 and a buffer underflow occurs. On the other hand, when the reception buffer size is set to S, if G (n + 1) <Bt_before (t (n + 1)) + b / FPS-S, Bt_after (t (n + 1))> S and buffer overflow occurs. .
そのため前述のレート制御部では、このようにバッファアンダーフローやオーバーフローが起こらないよう各ピクチャの発生符号量Gの適切な値を算出し、またそのような発生符号量となるようにQPを決定する機構となる。 For this reason, the above-described rate control unit calculates an appropriate value of the generated code amount G of each picture so that the buffer underflow or overflow does not occur in this way, and determines the QP so as to be such a generated code amount. It becomes a mechanism.
この発生符号量Gと量子化パラメータQPの関係であるが、ある量子化パラメータQPに対応する量子化幅をQstep(QP)と表すと、量子化幅Qstep(QP)と、その時の発生符号量Gの間にはおおよそ反比例の関係がある。この両者の積を取ったものをこのピクチャの複雑さ指数X=G×Qstep(QP)と呼ぶ。この複雑さ指数Xは、直前に符号化したピクチャのものとおよそ近い値となることから、直前に符号化した結果の積からXを求め、次ピクチャのGとQPの算出に用いられることが多い。 The relationship between the generated code amount G and the quantization parameter QP. When the quantization width corresponding to a certain quantization parameter QP is expressed as Qstep (QP), the quantization width Qstep (QP) and the generated code amount at that time There is a roughly inverse relationship between G. The product of these two is called the complexity index X = G × Qstep (QP) of this picture. Since this complexity index X is approximately the same as that of the picture encoded immediately before, X can be obtained from the product of the result of encoding immediately before and used for calculating G and QP of the next picture. Many.
また、各ピクチャの適切な発生符号量Gの計算方法としては、MPEG−2のTM5モデルがよく用いられる。これは、Iから始まる一連のピクチャ群であるGOP(Group of Pictures)に対して使用可能な符号量を設定し、各ピクチャタイプI・P・Bに対する複雑さ指数Xi、Xp、Xbに応じて、GOP内の各ピクチャに符号量を分配する、というものである。 Also, as a method for calculating an appropriate generated code amount G for each picture, the MPEG-5 TM5 model is often used. This sets the amount of code that can be used for GOP (Group of Pictures), which is a series of pictures starting from I, according to the complexity indices Xi, Xp, and Xb for each picture type I, P, and B. The code amount is distributed to each picture in the GOP.
1ピクチャずつ符号化する毎に割り当て符号量と実際の発生符号量の間の誤差をフィードバックし、バッファアンダーフローやオーバーフローを抑止しつつ、目的のビットレートbとなるよう各ピクチャの符号量配分を決定する。 Each time one picture is encoded, an error between the allocated code amount and the actual generated code amount is fed back, and the code amount distribution of each picture is distributed to achieve the target bit rate b while suppressing buffer underflow and overflow. decide.
ここで、レート制御部の処理例を示す。レート制御部の処理は前処理と後処理の2パートに大別される。まず前処理について説明する。処理が始まると、まずバッファ位置Bt_beforeを予め定められた初期値にて初期化する。また、各ピクチャタイプに対する複雑さ指数Xi、Xp、Xbを予め定められた定数で初期化する。 Here, a processing example of the rate control unit is shown. The processing of the rate control unit is roughly divided into two parts, pre-processing and post-processing. First, preprocessing will be described. When the process starts, first, the buffer position Bt_before is initialized with a predetermined initial value. Also, the complexity indices Xi, Xp, and Xb for each picture type are initialized with predetermined constants.
次に1GOPに割り当てる符号量Rの初期値を設定する。例えば、1GOPに含まれるピクチャ枚数をNとすれば、Rの初期値は、R=b×N/FPSなどと計算される。また、1GOPに含まれる各タイプ毎のピクチャ枚数をそれぞれNi(=Iピクチャの枚数=1)、Np(=Pピクチャの枚数)、Nb(=Bピクチャの枚数)に代入する。 Next, an initial value of the code amount R assigned to 1 GOP is set. For example, if the number of pictures included in one GOP is N, the initial value of R is calculated as R = b × N / FPS. Also, the number of pictures of each type included in one GOP is substituted into Ni (= number of I pictures = 1), Np (= number of P pictures), and Nb (= number of B pictures), respectively.
次に、符号化対象のピクチャ毎に以下のような処理により割り当て符号量Tを算出する。符号化対象ピクチャがIピクチャの場合、TはT=(Xi×R)/(Xi×Ni+Xp×Np+Xb×Nb)として算出する。その後、Niの値を1デクリメントする。同様に符号化対象ピクチャがPピクチャの場合はT=(Xp×R)/(Xi×Ni+Xp×Np+Xb×Nb)として算出後、Npの値を1デクリメントする。Bピクチャの場合はT=(Xb×R)/(Xi×Ni+Xp×Np+Xb×Nb)として算出後、Nbの値を1デクリメントする。 Next, the allocated code amount T is calculated for each picture to be encoded by the following process. When the encoding target picture is an I picture, T is calculated as T = (Xi × R) / (Xi × Ni + Xp × Np + Xb × Nb). Thereafter, the value of Ni is decremented by 1. Similarly, when the encoding target picture is a P picture, after calculating as T = (Xp × R) / (Xi × Ni + Xp × Np + Xb × Nb), the value of Np is decremented by 1. In the case of a B picture, after calculating as T = (Xb × R) / (Xi × Ni + Xp × Np + Xb × Nb), the value of Nb is decremented by 1.
上記で求めた符号量Tについて、符号化のバッファ位置推定値Bt_afterを
Bt_after=Bt_before−T
として算出する。この時Bt_after <0(バッファアンダーフロー)、もしくはバッファサイズをSとした時にBt_after+b/FPS>S(バッファオーバーフロー)とならないよう、TをBt_before+b/FPS−S≦T≦Bt_beforeの範囲にクリップする。
For the code amount T obtained above, the encoding buffer position estimated value Bt_after is set to Bt_after = Bt_before-T
Calculate as At this time, T is clipped to a range of Bt_before + b / FPS−S ≦ T ≦ Bt_before so that Bt_after + b / FPS> S (buffer overflow) when Bt_after <0 (buffer underflow) or when the buffer size is S is set.
次に、この割り当て符号量Tに相当する量子化パラメータQPを算出する。この量子化パラメータQPをターゲットQPと名付ける。前述の通り、複雑さ指数Xと発生符号量Gとの間にはおよそ以下の関係が成立する。
X=G×Qstep(QP)
Next, a quantization parameter QP corresponding to the allocated code amount T is calculated. This quantization parameter QP is named target QP. As described above, the following relationship is established between the complexity index X and the generated code amount G.
X = G × Qstep (QP)
そのため、例えばIピクチャの場合は符号量TとQstep(QP)の積がXiに最も近くなるQPをターゲットQPとすればよい。同様に、Pピクチャの場合は積がXpに最も近くなるQP、Bピクチャの場合はXbに最も近くなるQPをターゲットQPとすればよい。 Therefore, for example, in the case of an I picture, a QP in which the product of the code amount T and Qstep (QP) is closest to Xi may be set as the target QP. Similarly, the target QP may be the QP whose product is closest to Xp in the case of a P picture, and the QP that is closest to Xb in the case of a B picture.
ここまでが前処理となる。このようにして求めたターゲットQPを用いて実際に符号化を行った後、レート制御部では後処理を行う。この処理は具体的には以下の通りである。まず、符号化結果から複雑さ指数の値を更新する。符号化したピクチャの発生符号量をG、その時のターゲットQPに対応する量子化幅をQstep(ターゲットQP)とすれば、複雑さ指数は両者の積で求められる。 This is the preprocessing. After actually performing encoding using the target QP thus obtained, the rate control unit performs post-processing. Specifically, this processing is as follows. First, the value of the complexity index is updated from the encoding result. If the generated code amount of the encoded picture is G, and the quantization width corresponding to the target QP at that time is Qstep (target QP), the complexity index can be obtained by the product of both.
そこで符号化したピクチャのピクチャタイプがIピクチャであればXi、PピクチャであればXp、BピクチャであればXbをG×Qstep(ターゲットQP)の値に更新する。また、符号量Rの値も更新する。具体的にはRから発生符号量Gを引いたものを新たに符号量Rとする。 Therefore, Xi is updated to the value of G × Qstep (target QP) if the picture type of the encoded picture is I picture, Xp if it is a P picture, and Xb if it is a B picture. Also, the value of the code amount R is updated. Specifically, a value obtained by subtracting the generated code amount G from R is newly set as the code amount R.
次に、発生符号量Gを用いてバッファ位置Bt_beforeの値を更新する。これは、
Bt_before=Bt_before−G+b/FPS
として計算される。以上がレート制御部の後処理となる。
Next, the value of the buffer position Bt_before is updated using the generated code amount G. this is,
Bt_before = Bt_before−G + b / FPS
Is calculated as The above is the post-processing of the rate control unit.
その後、またレート制御部の前処理に戻って次の符号化ピクチャに関するターゲットQPを算出する処理を行うことを繰り返す。1GOP分の符号化が終わったら、Rの値を更新し、次のGOPに対してまた同様の処理を繰り返す。具体的には、Rの値について、その時点で保持している値に対し、b×N/FPSを加算する。また、Ni、Np、Nbの値を1GOPに含まれる各ピクチャタイプの枚数に戻す。 Thereafter, returning to the preprocessing of the rate control unit, the process of calculating the target QP for the next coded picture is repeated. When encoding for 1 GOP is completed, the value of R is updated, and the same processing is repeated for the next GOP. Specifically, for the value of R, b × N / FPS is added to the value held at that time. Further, the values of Ni, Np, and Nb are returned to the number of pictures of each picture type included in 1 GOP.
このような処理を行うことで、バッファを破綻させないようにしつつも目的のビットレートに沿ったビットストリームを生成できる(例えば、非特許文献1参照)。 By performing such processing, it is possible to generate a bit stream in accordance with the target bit rate while preventing the buffer from failing (see Non-Patent Document 1, for example).
次に、前述したような複数ピクチャを同時に符号化するための装置の装置構成を説明する。図7は、前述したような複数ピクチャを同時に符号化するための装置の装置構成を示すブロック図である。この装置は、原画像バッファ1、復号画像バッファ10、N(Nは自然数)個の符号化部12−1〜N、ストリームバッファ13、並列処理割り当て部14、バッファ計算部15、割り当て符号量算出部16、QP計算部17、複雑さ計算部18から構成される。バッファ計算部15、割り当て符号量算出部16、QP計算部17及び複雑さ計算部18によってレート制御部19が構成されている。
Next, an apparatus configuration of an apparatus for simultaneously encoding a plurality of pictures as described above will be described. FIG. 7 is a block diagram showing a device configuration of a device for simultaneously encoding a plurality of pictures as described above. This apparatus includes an original image buffer 1, a decoded
原画像バッファ1は前述のものと同様、原画像を符号化順に並べ替え、符号化部12−1〜Nに送る。ただし、本構成では符号化部12−1〜Nが複数あるため、並列処理割り当て部14から送られる原画割り当て情報を元に、符号化順でN枚分のピクチャをN個ある符号化部12−1〜Nへそれぞれ送信する。
Similar to the above, the original image buffer 1 rearranges the original images in the encoding order and sends them to the encoding units 12-1 to 12 -N. However, since there are a plurality of encoding units 12-1 to 12 -N in this configuration,
復号画像バッファ10は前述のものと同様、符号化部12−1〜Nから送られる復号画像を保存し、また必要に応じて参照画像として符号化部12−1〜Nへ送る。但し、本構成では符号化部12−1〜Nが複数あるため、このバッファも複数の復号画像の同時保存、及び複数の参照画像の同時送出に対応している。
Similar to the above, the decoded
符号化部12−1〜Nは図5の点線で囲まれた符号化部12と同等の機能を有し、本構成例ではそれがN個並列に備わっている。ストリームバッファ13は、各符号化部12−1〜Nから送られる符号化ストリームを保存すると共に、そのデータサイズを発生符号量としてバッファ計算部15、割り当て符号量算出部16、複雑さ計算部8に送る。
The encoding units 12-1 to 12 -N have the same function as the
並列処理割り当て部14は、入力された並列処理数を元に、原画像バッファのどのピクチャをN個あるどの符号化部(符号化部12−1〜Nのいずれか)へ送るかを求め、原画像バッファ1へ割り当て情報として送信する。
The parallel
バッファ計算部15は、処理が始まるとレート制御設定情報を元にバッファ位置の初期値Bt_before(0)を計算して保持する。また、ストリームバッファ13から各ピクチャの発生符号量が求まるたびにBt_beforeの値を計算し、割り当て符号量算出部16へ送る。
When the process starts, the
割り当て符号量算出部16は、外部から与えられるレート制御設定と並列数、バッファ位置、各ピクチャの発生符号量を元に、向こうNピクチャ分の各ピクチャの割り当て符号量T(1)〜T(N)を求め、QP計算部17へ送る。QP計算部17は、複雑さ計算部18から送られる各ピクチャタイプの複雑さ指数と各ピクチャの割り当て符号量を元に、Nピクチャ分のターゲットQPを計算して対応するN個の符号化部12−1〜Nへ送る。
The allocation code amount calculation unit 16 allocates code amounts T (1) to T (1) to T (1) to T (pictures) for the next N pictures based on the rate control setting and the parallel number, buffer position, and the generated code amount of each picture. N) is obtained and sent to the
複雑さ計算部18は、QP計算部17から送られる各ピクチャの量子化パラメータQPと、ストリームバッファ13から送られる対象ピクチャの発生符号量からピクチャタイプ毎の複雑さ指数を計算し、割り当て符号量算出部16とQP計算部17へ送る。
The
次に、図8を参照して、図7に示す装置の処理動作を説明する。図8は、前述したような複数ピクチャを同時に符号化する装置が行う処理動作を示すフローチャートである。符号化を開始すると、まず図6のフローと同様、原画像バッファ1は、ピクチャを符号化順に並べ替える(ステップS41)。 Next, the processing operation of the apparatus shown in FIG. 7 will be described with reference to FIG. FIG. 8 is a flowchart showing processing operations performed by the apparatus for simultaneously encoding a plurality of pictures as described above. When encoding is started, the original image buffer 1 first rearranges the pictures in the encoding order (step S41), as in the flow of FIG.
次に、前述のレート制御部19の処理を元に、割り当て符号量算出部16は、向こうN枚分のピクチャに対する割り当て符号量を算出する(ステップS42)。この時、N枚分のピクチャのうち、1枚目ピクチャの割り当て符号量算出は前述の通りに行えばよい。しかし2枚目以降のピクチャに関しては前述の式のままでは割り当て符号量算出ができない。
Next, based on the processing of the
これは、例えば2枚目ピクチャの計算を行うには1枚目ピクチャの符号化結果から求まる発生符号量を使い、バッファ位置Bt_before、符号量R、及び対応するピクチャタイプの複雑さ指数を更新する必要があるためである。 For example, in order to calculate the second picture, the generated code quantity obtained from the encoding result of the first picture is used, and the buffer position Bt_before, the code quantity R, and the complexity index of the corresponding picture type are updated. This is necessary.
同様に3枚目ピクチャは1枚目と2枚目ピクチャの符号化結果、4枚目ピクチャは1〜3枚目ピクチャの発生符号量が必要となる。しかしこの時点ではこれらピクチャの発生符号量が無いことから、割り当て符号量を発生符号量の代用に用いる。 Similarly, the encoding result of the first and second pictures is required for the third picture, and the generated code amount of the first to third pictures is required for the fourth picture. However, since there is no generated code amount of these pictures at this time, the allocated code amount is used as a substitute for the generated code amount.
従って2枚目ピクチャに関して言えば、複雑さ指数は1枚目と共通とし、バッファ位置Bt_before(2)は、1枚目ピクチャに関するバッファ位置Bt_before(1)と1枚目ピクチャの割り当て符号量T(1)から
Bt_before’(2)=Bt_before(1)−T(1)+b/FPS
となる。
Therefore, regarding the second picture, the complexity index is the same as that of the first picture, and the buffer position Bt_before (2) is the buffer position Bt_before (1) related to the first picture and the assigned code amount T ( From 1) Bt_before ′ (2) = Bt_before (1) −T (1) + b / FPS
It becomes.
また符号量R(2)は1枚目ピクチャ計算時の符号量R(1)から符号量T(1)を引いた
R(2)=R(1)−T(1)
を用いるとする。これらの値を用い、2枚目ピクチャに対する割り当て符号量T(2)を計算すればよい。同様に3枚目ピクチャに関しても複雑さ指数は1枚目計算時と共通で、バッファ位置Bt_before(3)は
Bt_before(3)=Bt_before(2)−T(2)+b/FPS
=Bt_before(1)−(T(1)+T(2))+2×b/FPS
The code amount R (2) is obtained by subtracting the code amount T (1) from the code amount R (1) at the time of calculating the first picture. R (2) = R (1) −T (1)
Is used. Using these values, the allocated code amount T (2) for the second picture may be calculated. Similarly, the complexity index for the third picture is the same as that for calculating the first picture, and the buffer position Bt_before (3) is Bt_before (3) = Bt_before (2) −T (2) + b / FPS.
= Bt_before (1)-(T (1) + T (2)) + 2 × b / FPS
また、符号量R(3)は
R(3)=R(2)−T(2)=R(1)−(T(1)+T(2))
と表せ、これらから割り当て符号量T(3)を算出すればよい。
The code amount R (3) is R (3) = R (2) −T (2) = R (1) − (T (1) + T (2)).
The allocated code amount T (3) may be calculated from these.
上記の計算によりNピクチャ分の割り当て符号量T(1)〜T(N)を算出したら、QP計算部17は、これらの割り当て符号量に対応する各ピクチャの量子化パラメータQPを算出する(ステップS43)。これは、各ピクチャのピクチャタイプに対する複雑さ指数XiもしくはXpもしくはXbを各ピクチャの割り当て符号量で除した値に最も近い量子化幅となるQPを求めればよい。例えば、1枚目ピクチャのピクチャタイプがIピクチャであれば量子化幅はXi/T(1)で算出でき、この量子化幅に最も近い量子化パラメータQPが1枚目ピクチャのターゲットQPとなる。
After calculating the allocated code amounts T (1) to T (N) for N pictures by the above calculation, the
同様にNピクチャ分全てのターゲットQPを算出したら、符号化部12−1〜Nは、これらNピクチャを同時並列に符号化する(ステップS44)。この処理は、具体的には図6に示すフローチャート中の破線で囲まれた「符号化処理のコアフロー」に従って各ピクチャを同時に符号化することに相当する。 Similarly, after calculating the target QP for all N pictures, the encoding units 12-1 to 12-N encode these N pictures in parallel at the same time (step S44). Specifically, this processing corresponds to the simultaneous encoding of each picture in accordance with the “core flow of encoding processing” surrounded by a broken line in the flowchart shown in FIG.
Nピクチャ分の符号化が終わったら、各ピクチャに対応する発生符号量G(1)〜G(N)が求まるので、複雑さ計算部18は、この結果を元に複雑さ指数の更新(ステップS45)し、バッファ計算部15は、バッファ位置の更新を行う(ステップS46)。複雑さ指数の更新に関しては、発生符号量とターゲットQPに対応するQstepの積で当該ピクチャの複雑さ指数が求まるので、ピクチャタイプ毎に分類し、平均値を求めて当該ピクチャタイプの新たな複雑さ指数とするなどすればよい。
When encoding for N pictures is completed, the generated code amounts G (1) to G (N) corresponding to each picture are obtained, and the
一方バッファ位置の更新については、Nピクチャ分の発生符号量G(1)〜G(N)を元にバッファ位置Bt_before(N+1)を以下の通り求める。
Bt_before(N+1)=Bt_before(1)−(T(1)+T(2)+…T(N))+N×b/FPS
On the other hand, for updating the buffer position, the buffer position Bt_before (N + 1) is obtained as follows based on the generated code amounts G (1) to G (N) for N pictures.
Bt_before (N + 1) = Bt_before (1) − (T (1) + T (2) +... T (N)) + N × b / FPS
以上の処理を全てのピクチャに対して行う(ステップS47)ことで、複数ピクチャ並列に符号化処理を行うことができる。 By performing the above process on all the pictures (step S47), it is possible to perform the encoding process in parallel with a plurality of pictures.
ところで、上記の複数ピクチャを同時に符号化する方式においては、各ピクチャの割り当て符号量に関して、必ずしも正確な情報を元に計算できていない。具体的に言えば、上記において符号量T(1)は正確なバッファ位置Bt_before(1)及び符号量R(1)を元に計算できているが、符号量T(2)に関して言えば、計算の元となるバッファ位置Bt_before(2)及びR(2)は仮の値となっている。 By the way, in the above-described method of encoding a plurality of pictures at the same time, the allocation code amount of each picture cannot always be calculated based on accurate information. Specifically, in the above, the code amount T (1) can be calculated based on the exact buffer position Bt_before (1) and the code amount R (1). The buffer positions Bt_before (2) and R (2) that are the origins of are temporary values.
一般的に映像の符号化では、割り当て符号量Tと実際の発生符号量Gの間には乖離が起きる。そのため、割り当て符号量の計算時点ではバッファ破綻が起こっていないとしても、実際にNピクチャ符号化した時にはバッファ破綻が起こっている可能性がある。 In general, in video coding, a divergence occurs between the allocated code amount T and the actual generated code amount G. For this reason, even if there is no buffer failure at the time of calculation of the allocated code amount, there is a possibility that a buffer failure occurs when N pictures are actually encoded.
特に並列数Nの値が大きければ大きいほど各ピクチャの割り当て符号量Tと実際の発生符号量Gの乖離の影響を大きく受けるため、バッファ破綻を起こす可能性が高いことが分かる。従って複数ピクチャの同時並列処理は、並列処理数が多いほど処理時間も短縮できるが、バッファ破綻のリスクも並列処理数の増加に伴って高まるという問題がある。 In particular, it can be understood that the larger the value of the parallel number N, the greater the influence of the difference between the allocated code amount T of each picture and the actual generated code amount G, and thus the higher the possibility of buffer failure. Therefore, the simultaneous parallel processing of a plurality of pictures can shorten the processing time as the number of parallel processes increases, but there is a problem that the risk of buffer failure increases as the number of parallel processes increases.
なお、このバッファ破綻に関して、バッファオーバーフローの場合は空データ(fillerデータ)を間に挟むことで回避する手段が存在する。一方、バッファ位置が0未満となるバッファアンダーフローに関してはこのような回避手段が存在しないため、複数ピクチャ並列符号化においては特にこのバッファアンダーフローの回避が大きな問題となる。 Note that there is a means for avoiding this buffer failure by inserting empty data (filler data) in the case of buffer overflow. On the other hand, since there is no such avoidance means for buffer underflow where the buffer position is less than 0, avoiding this buffer underflow is a big problem particularly in the multi-picture parallel coding.
本発明は、このような事情に鑑みてなされたもので、バッファアンダーフローのリスクを低く抑えつつ、可能な限り並列処理数を高めることにより高速に符号化することができるようにするための並列処理数を算出することができる映像符号化方法、映像符号化装置及び映像符号化プログラムを提供することを目的とする。 The present invention has been made in view of such circumstances, and it is possible to perform high-speed encoding by increasing the number of parallel processes as much as possible while keeping the risk of buffer underflow low. It is an object of the present invention to provide a video encoding method, a video encoding device, and a video encoding program capable of calculating the number of processes.
本発明の一態様は、最大N(Nは2以上の自然数)枚までの複数ピクチャを並列に符号化する符号化部と、N枚の各ピクチャに対する割り当て符号量を算出する割り当て符号量算出部と、前記割り当て符号量に相当する量子化パラメータであるターゲットQPを算出するQP計算部とを備え、映像を符号化する映像符号化装置が行う映像符号化方法であって、前記N枚の各ピクチャに対する前記割り当て符号量の誤差に基づいて、前記割り当て符号量を再算出する割り当て符号量再算出ステップと、N枚の各ピクチャに対する前記割り当て符号量から各ピクチャの符号化後のバッファのデータ蓄積量の推定量を示すバッファ位置推定値を算出するバッファ位置推定値算出ステップと、算出した各ピクチャの前記符号化後のバッファ位置推定値と、予め定められた閾値との大小を比較する比較ステップと、前記大小の比較の結果に基づき、前記閾値以上となっているピクチャの枚数を求める枚数算出ステップと、前記ピクチャの枚数に基づいて、前記符号化部によって並列に符号化するピクチャの枚数である並列数を算出する並列数算出ステップとを有する映像符号化方法である。 One aspect of the present invention is an encoding unit that encodes a plurality of pictures up to N (N is a natural number of 2 or more) in parallel, and an allocation code amount calculation unit that calculates an allocation code amount for each of the N pictures. And a QP calculation unit that calculates a target QP that is a quantization parameter corresponding to the allocated code amount, and is a video encoding method performed by a video encoding device that encodes video, each of the N sheets An allocation code amount recalculation step for recalculating the allocation code amount based on an error of the allocation code amount for a picture, and data storage in a buffer after encoding each picture from the allocation code amount for each of N pictures A buffer position estimated value calculating step for calculating a buffer position estimated value indicating an estimated amount of the quantity, and a buffer position estimated value after the encoding of each calculated picture A comparison step for comparing the magnitude with a predetermined threshold, a number calculation step for obtaining the number of pictures that are equal to or greater than the threshold based on the result of the magnitude comparison, and a number based on the number of pictures. And a parallel number calculating step of calculating a parallel number that is the number of pictures to be encoded in parallel by the encoding unit.
本発明の一態様は、前記映像符号化方法であって、前記割り当て符号量再算出ステップでは、各ピクチャの割り当て符号量に対してあらかじめ定めた1以上の係数を乗算する。 One aspect of the present invention is the video encoding method, wherein in the allocation code amount recalculation step, the allocation code amount of each picture is multiplied by one or more predetermined coefficients.
本発明の一態様は、前記映像符号化方法であって、前記割り当て符号量再算出ステップでは、各ピクチャの割り当て符号量に予め定めた固定値を加算する。 One aspect of the present invention is the video encoding method, wherein in the allocation code amount recalculation step, a predetermined fixed value is added to the allocation code amount of each picture.
本発明の一態様は、前記映像符号化方法であって、前記割り当て符号量再算出ステップでは、各ピクチャの割り当て符号量を予め定めた四則演算による方程式に代入して算出した値を用いることによって前記誤差に基づいた前記割り当て符号量を求める。 One aspect of the present invention is the video encoding method, wherein in the allocation code amount recalculation step, a value calculated by substituting the allocation code amount of each picture into a predetermined equation based on four arithmetic operations is used. The allocated code amount based on the error is obtained.
本発明の一態様は、前記映像符号化方法であって、前記バッファ位置推定値算出ステップでは、前記バッファのバッファ位置として入力された初期バッファ位置を起点として前記並列数によって規定されるピクチャ枚数分の符号化後の前記バッファの前記バッファ位置推定値を、各ピクチャに関して前記誤差に基づいた前記割り当て符号量から計算する。 One aspect of the present invention is the video encoding method, wherein in the buffer position estimation value calculation step, an initial buffer position input as the buffer position of the buffer is used as a starting point for the number of pictures defined by the parallel number. The buffer position estimation value of the buffer after encoding is calculated from the allocated code amount based on the error for each picture.
本発明の一態様は、 映像を符号化する映像符号化装置であって、最大N(Nは2以上の自然数)枚までの複数ピクチャを並列に符号化する符号化部と、N枚の各ピクチャに対する割り当て符号量を算出する割り当て符号量算出部と、前記割り当て符号量に相当する量子化パラメータであるターゲットQPを算出するQP計算部と、前記N枚の各ピクチャに対する前記割り当て符号量の誤差に基づいて、前記割り当て符号量を再算出する割り当て符号量再再算出部と、N枚の各ピクチャに対する前記割り当て符号量から各ピクチャの符号化後のバッファのデータ蓄積量の推定量を示すバッファ位置推定値を算出するバッファ位置推定値算出部と、算出した各ピクチャの前記符号化後のバッファ位置推定値と、予め定められた閾値との大小を比較する比較部と、前記大小の比較の結果に基づき、前記閾値以上となっているピクチャの枚数を求める枚数算出部と、前記ピクチャの枚数に基づいて、前記符号化部によって並列に符号化するピクチャの枚数である並列数を算出する並列数算出部とを備える映像符号化装置である。 One aspect of the present invention is a video encoding device that encodes video, an encoding unit that encodes a plurality of pictures up to N (N is a natural number of 2 or more) in parallel, and each of the N images An allocation code amount calculation unit that calculates an allocation code amount for a picture, a QP calculation unit that calculates a target QP that is a quantization parameter corresponding to the allocation code amount, and an error in the allocation code amount for each of the N pictures An allocation code amount re-recalculation unit that recalculates the allocation code amount based on the above, and a buffer that indicates an estimated amount of data accumulation in a buffer after encoding each picture from the allocation code amount for each of N pictures A buffer position estimated value calculation unit for calculating a position estimated value, and a ratio between the calculated buffer position estimated value of each picture after encoding and a predetermined threshold value are compared. A comparison unit, a number calculation unit for determining the number of pictures that are equal to or greater than the threshold based on the result of the size comparison, and a picture that is encoded in parallel by the encoding unit based on the number of pictures It is a video coding apparatus provided with the parallel number calculation part which calculates the parallel number which is the number of sheets.
本発明の一態様は、コンピュータに、前記映像符号化方法を実行させるための映像符号化プログラムである。 One aspect of the present invention is a video encoding program for causing a computer to execute the video encoding method.
本発明によれば、バッファアンダーフローのリスクを低く抑えつつ、可能な限り並列処理数を高めることにより高速に符号化することができるようにするための並列処理数を算出することができるという効果が得られる。 According to the present invention, it is possible to calculate the number of parallel processes for enabling high-speed encoding by increasing the number of parallel processes as much as possible while suppressing the risk of buffer underflow. Is obtained.
以下、図面を参照して、本発明の一実施形態による映像符号化装置を説明する。図1は同実施形態の構成を示すブロック図である。この図に示す装置が図7に示す従来の装置と異なる点は、並列数算出部20が新たに設けられている点である。
Hereinafter, a video encoding apparatus according to an embodiment of the present invention will be described with reference to the drawings. FIG. 1 is a block diagram showing the configuration of the embodiment. The apparatus shown in this figure is different from the conventional apparatus shown in FIG. 7 in that a parallel
なお、並列処理割り当て部14の入力に関して、図7に示す構成では外部から与えられた並列数が固定値として与えられていたが、図1に示す構成では並列数算出部20から出力される並列処理数mが入力となっている。
As for the input to the parallel
図1に示す装置は、図7に示す装置と同様に、原画像バッファ1、復号画像バッファ10、N(Nは自然数)個の符号化部12−1〜N、ストリームバッファ13、並列処理割り当て部14、バッファ計算部15、割り当て符号量算出部16、QP計算部17、複雑さ計算部18から構成される。バッファ計算部15、割り当て符号量算出部16、QP計算部17及び複雑さ計算部18によってレート制御部19が構成されている。そして、新たに設けられた並列数算出部20が備えられている。図1に示す装置は、並列数算出部20を除く構成は、図7に示す構成と同様であるため、ここでは、説明を簡単に行う。
The apparatus shown in FIG. 1 is the same as the apparatus shown in FIG. 7. The original image buffer 1, the decoded
原画像バッファ1は、原画像を符号化順に並べ替え、符号化部12−1〜Nに送る。ただし、本構成では符号化部12−1〜Nが複数あるため、並列処理割り当て部14から送られる原画割り当て情報を元に、符号化順でm枚分のピクチャを、N個ある符号化部12−1〜Nのなかの任意のm個に対してそれぞれ送信する。
The original image buffer 1 rearranges the original images in the encoding order and sends them to the encoding units 12-1 to 12 -N. However, since there are a plurality of encoding units 12-1 to 12 -N in this configuration, N encoding units for m pictures in the encoding order based on the original image allocation information sent from the parallel
復号画像バッファ10は、符号化部12−1〜Nから送られる復号画像を保存し、また必要に応じて参照画像として符号化部12−1〜Nへ送る。ただし、本構成では符号化部12−1〜Nが複数あるため、この復号画像バッファ10も複数の復号画像の同時保存、及び複数の参照画像の同時送出に対応している。
The decoded
符号化部12−1〜Nは図5に示す符号化部12と同等の機能を有し、本構成例では符号化部12それがN個並列に備わっている。ストリームバッファ13は、各符号化部12−1〜Nから送られる符号化ストリームを保存すると共に、そのデータサイズを発生符号量としてバッファ計算部15、割り当て符号量算出部16、複雑さ計算部8に送る。
The encoding units 12-1 to 12-N have the same function as the
並列処理割り当て部14は、入力された並列処理数mを元に、原画像バッファ1のどのピクチャをN個あるどの符号化部(符号化部12−1〜Nのいずれか)へ送るかを求め、原画像バッファ1へ割り当て情報として送信する。原画像バッファ1のピクチャの符号化部12−1〜Nへの割り当て方法としては、例えば、m枚を前詰めで割り当てればよい。
The parallel
バッファ計算部15は、処理が始まるとレート制御設定情報を元にバッファ位置の初期値Bt_before(0)を計算して保持する。また、ストリームバッファ13から各ピクチャの発生符号量が求まるたびにBt_beforeの値を計算し、割り当て符号量算出部16及び並列数算出部20へ送る。
When the process starts, the
割り当て符号量算出部16は、外部から与えられるレート制御設定と並列数、バッファ位置、各ピクチャの発生符号量を元に、向こうNピクチャ分の各ピクチャの割り当て符号量T(1)〜T(N)を求め、QP計算部17及び並列数算出部20へ送る。QP計算部17は、複雑さ計算部18から送られる各ピクチャタイプの複雑さ指数と各ピクチャの割り当て符号量を元に、Nピクチャ分のターゲットQPを計算して対応するN個の符号化部12−1〜Nへ送る。
The allocation code amount calculation unit 16 allocates code amounts T (1) to T (1) to T (1) to T (pictures) for the next N pictures based on the rate control setting and the parallel number given from the outside, the buffer position, and the generated code amount of each picture. N) is obtained and sent to the
複雑さ計算部18は、QP計算部17から送られる各ピクチャの量子化パラメータQPと、ストリームバッファ13から送られる対象ピクチャの発生符号量からピクチャタイプ毎の複雑さ指数を計算し、割り当て符号量算出部16とQP計算部17へ送る。
The
並列数算出部20は、割り当て符号量算出部16が出力する各ピクチャの割り当て符号量と、バッファ計算部15が出力するバッファ位置と、外部から指定される並列数とから符号化部12−1〜Nにおける並列処理数mを出力する。ここで、出力される並列処理数mは、N≧mを満たすことが条件である。
The parallel
次に、図2を参照して、図1に示す並列数算出部20の構成を説明する。図2は、図1に示す並列数算出部20の構成を示すブロック図である。並列数算出部20は、誤差考慮済み符号量計算部21、バッファ推移推定部22、閾値判定部23、並列処理数決定部24から構成される。並列数算出部20には、各ピクチャの割り当て符号量と、並列数と、バッファ位置とが入力される。
Next, the configuration of the parallel
誤差考慮済み符号量計算部21は、入力された並列数で指定されるピクチャ数分の割り当て符号量を入力とし、それらにあらかじめ定められた誤差係数k=1.2を乗じた値を各ピクチャの誤差考慮済み符号量としてバッファ推移推定部22に送る。ここで、誤差係数kとして、1.2を乗じているが、この値に限るものではなく、任意の値を用いることが可能である。
The error-considered code
バッファ推移推定部22は、バッファ位置として入力された初期バッファ位置を起点として並列数によって規定されるピクチャ枚数分の符号化後バッファ位置(n枚目ピクチャを復号した直後の受信バッファのデータ蓄積量Bt_after)を各ピクチャに関する誤差考慮済み割り当て符号量から計算して閾値判定部23に送る。
The buffer transition estimation unit 22 uses the initial buffer position input as the buffer position as a starting point and the encoded buffer position for the number of pictures defined by the parallel number (the amount of data stored in the reception buffer immediately after decoding the nth picture) Bt_after) is calculated from the error-considered allocated code amount for each picture and sent to the threshold
閾値判定部23は、並列数によって規定されたピクチャ数分の符号化後バッファ位置(各ピクチャのBt_after)に関して、予め定められた閾値Thとの間で大小比較を施し、その結果を並列処理数決定部24に送る。
The
並列処理数決定部24は、閾値判定部23の出力を入力し、並列数で規定された値以下の範囲で、閾値判定結果が常に閾値Th以上となる最大のピクチャ番号を求め、それを並列処理数mとして出力する。
The parallel processing
次に、図3を参照して、図2に示す並列数算出部20を含む図1に示す映像符号化装置の動作を説明する。図3は、図1に示す映像符号化装置の動作を示すフローチャートである。
Next, the operation of the video encoding device shown in FIG. 1 including the parallel
まず、符号化が始まると、従来法と同様、原画像バッファ1は、入力画像を符号化順に並べ替える(ステップS1)。続いて、割り当て符号量算出部16は、向こうN(Nは自然数)枚分のピクチャに関して割り当て符号量を算出する(ステップS2)。算出方法は前述した通りである。 First, when encoding starts, as in the conventional method, the original image buffer 1 rearranges the input images in the encoding order (step S1). Subsequently, the allocated code amount calculation unit 16 calculates the allocated code amount for N pictures (N is a natural number) beyond (step S2). The calculation method is as described above.
次に、誤差考慮済み符号量計算部21は、算出した各ピクチャの割り当て符号量T(1)〜T(N)に対して誤差を加味する(ステップS3)。具体的にはT(1)〜T(N)に誤差係数k=1.2を掛け、誤差考慮済み符号量T’(1)〜T’(N)を算出する。
Next, the error-considered code
次に、バッファ推移推定部22は、バッファ推移の推定を行う(ステップS4)。具体的には各ピクチャの符号化終了時点の推定バッファ位置Bt_after(1)〜Bt_after(N)を以下のように求める。
Bt_after(1)=Bt_before(1)−T’(1)
Bt_after(2)=Bt_before(2)−T’(2)
=Bt_before(1)−(T’(1)+T’(2))+b/FPS
…
Bt_after(N)= Bt_before(N) −T’(N)
=Bt_before(1)−(T’(1)+T’(2)+…T’(N))+(N−1)×b/FPS
Next, the buffer transition estimation unit 22 estimates buffer transition (step S4). Specifically, the estimated buffer positions Bt_after (1) to Bt_after (N) at the end of encoding of each picture are obtained as follows.
Bt_after (1) = Bt_before (1) −T ′ (1)
Bt_after (2) = Bt_before (2) −T ′ (2)
= Bt_before (1)-(T '(1) + T' (2)) + b / FPS
...
Bt_after (N) = Bt_before (N) −T ′ (N)
= Bt_before (1) − (T ′ (1) + T ′ (2) +... T ′ (N)) + (N−1) × b / FPS
そして、閾値判定部23は、Bt_after(1)〜Bt_after(N)を予め定めた閾値Thと比較する(ステップS5)。この比較結果に基づき、並列処理数決定部24は、符号化順に見て最も早く閾値Thを下回るピクチャ番号を見つけ、その直前のピクチャ番号を並列処理数mとして出力する(ステップS6)。例えばBt_after(1)、Bt_after(2)は閾値Thを上回り、Bt_after(3)が閾値Thを下回っていた場合、並列処理数mは2とする。
Then, the
その後、QP計算部17は、向こうm(並列処理数)枚分のピクチャに対して量子化パラメータQPを算出する(ステップS7)。この時の量子化パラメータQPの計算では、誤差係数k(例えば、1.2)を掛ける前の符号量T(1)〜T(m)の値を元に量子化パラメータQPを算出する。
After that, the
次に、向こうm枚分のピクチャに対するターゲットQPが求まったら、以降は従来法と同様、符号化部12−1〜Nは、m(並列処理数)枚分のピクチャを並列処理して符号化を行う(ステップS8)。m枚の符号化に必ずしも符号化部12−1〜Nの全てが使われる訳ではなく、m個の符号化部のみが使われることになる。そして、複雑さ計算部18は、求まった発生符号量を元に、複雑さ指数を更新する(ステップS9)。
Next, when target QPs for m pictures beyond are obtained, the encoding units 12-1 to 12-N encode and process m (parallel processing number) pictures in parallel as in the conventional method. Is performed (step S8). Not all of the encoding units 12-1 to 12 -N are necessarily used for encoding m sheets, but only m encoding units are used. Then, the
また、バッファ計算部15は、求まった発生符号量を元に、バッファ位置を更新する(ステップS10)。そして、符号化フレームが残っていたら向こうN枚分のピクチャに対する割り当て符号量算出処理に戻って符号化処理を最後まで繰り返す(ステップS11)。
Further, the
なお、前述した説明では割り当て符号量に誤差を加味する方法として誤差係数k=1.2を乗算する例を説明したが、誤差係数kを乗算することに限るものではない。例えば、固定値を加算してもよい。また、乗算や加算に限らず、各ピクチャの割り当て符号量を予め定めた誤差係数kを算出するための四則演算による方程式に代入して得られた値に基づいた割り当て符号量としてもよい。 In the above description, an example in which the error coefficient k = 1.2 is multiplied as a method for adding an error to the allocated code amount, but the present invention is not limited to multiplication by the error coefficient k. For example, a fixed value may be added. Further, not only multiplication and addition, but an allocation code amount based on a value obtained by substituting the allocation code amount of each picture into an equation based on four arithmetic operations for calculating a predetermined error coefficient k may be used.
また、誤差係数kを乗算する際の誤差係数kは、割り当て符号量に対して、予め定めた1以上の係数を掛けて安全側に設定することを目的とするため、1以上の係数であればよい。特に、本実施形態では、割り当て符号量T(N)と、実際の発生符号量G(N)の間に乖離が生じるため、その分を補償する際に、安全側に設定するため、1以上の誤差係数を乗算するようにしている。そのため、例えば並列化を行わない状態で予め符号化を行って割り当て符号量T(N)と実際の発生符号量G(N)を算出し、その比を以って「1以上の係数」を定めれるようにしてもよい。 Further, the error coefficient k when multiplying by the error coefficient k is set to a safe side by multiplying the assigned code amount by one or more predetermined coefficients, so that it should be one or more coefficients. That's fine. In particular, in the present embodiment, there is a divergence between the allocated code amount T (N) and the actual generated code amount G (N). Is multiplied by the error coefficient. Therefore, for example, encoding is performed in advance in a state where parallelization is not performed, and an allocated code amount T (N) and an actual generated code amount G (N) are calculated. It may be determined.
例えば、大量のあらゆる映像を予めエンコードして割り当て符号量T(N)と実際の発生符号量G(N)の平均値をそれぞれ求め、その比を「1以上の係数」とすると手法を用いて誤差係数kを設定することができる。 For example, a method is used in which a large amount of all images are encoded in advance to obtain an average value of the allocated code amount T (N) and the actual generated code amount G (N), and the ratio is “one or more coefficients”. An error coefficient k can be set.
また、誤差係数kは必ずしも固定値である必要はない。実際にエンコードを行っていくと各フレームの割り当て符号量T(N)と実際の発生符号量G(N)の値が順次求まるので、その最新Mフレーム分の平均値を以って順次更新したり、先頭からずっと積算し続けた値の平均値を使ったりすることも可能である。 Further, the error coefficient k is not necessarily a fixed value. When encoding is actually performed, the assigned code amount T (N) and the actual generated code amount G (N) of each frame are obtained sequentially, and are updated sequentially with the average value for the latest M frames. It is also possible to use an average value of values continuously accumulated from the beginning.
以上説明したように、実施形態における映像符号化装置は、複数のピクチャを同時に符号化を行う際に、割り当て符号量に誤差を加味したうえでバッファ推移の推定を行う。そして、映像符号化装置は、同時に符号化を行う適切なピクチャ数を設定する。この構成によれば、復号時においてバッファオーバーフロー及びバッファアンダーフローの発生を低く抑えることができるとともに、符号化速度の高速化を実現することができる。 As described above, when encoding a plurality of pictures at the same time, the video encoding apparatus according to the embodiment performs buffer transition estimation in consideration of an error in the allocated code amount. The video encoding apparatus sets an appropriate number of pictures to be encoded at the same time. According to this configuration, it is possible to suppress the occurrence of buffer overflow and buffer underflow at the time of decoding, and it is possible to increase the encoding speed.
特に、バッファ位置が下がっている場合は、並列数算出部20が並列処理数を少なくすることで処理速度が遅くなる代わりにバッファアンダーフローのリスクを下げることが可能になる。逆に、バッファ位置が上がっている場合などバッファアンダーフローの危険性が低い場合は、並列数算出部20が並列数を多くすることで処理速度を高めることが可能になる。この結果、バッファアンダーフローのリスクを低く抑えつつ、可能な限り並列処理数を高めることにより高速にエンコードすることができる。
In particular, when the buffer position is lowered, it is possible to reduce the risk of buffer underflow instead of reducing the processing speed by reducing the number of parallel processes by the parallel
前述した実施形態における映像符号化装置の全部または一部をコンピュータで実現するようにしてもよい。その場合、この機能を実現するためのプログラムをコンピュータ読み取り可能な記録媒体に記録して、この記録媒体に記録されたプログラムをコンピュータシステムに読み込ませ、実行することによって実現してもよい。なお、ここでいう「コンピュータシステム」とは、OSや周辺機器等のハードウェアを含むものとする。また、「コンピュータ読み取り可能な記録媒体」とは、フレキシブルディスク、光磁気ディスク、ROM、CD−ROM等の可搬媒体、コンピュータシステムに内蔵されるハードディスク等の記憶装置のことをいう。さらに「コンピュータ読み取り可能な記録媒体」とは、インターネット等のネットワークや電話回線等の通信回線を介してプログラムを送信する場合の通信線のように、短時間の間、動的にプログラムを保持するもの、その場合のサーバやクライアントとなるコンピュータシステム内部の揮発性メモリのように、一定時間プログラムを保持しているものも含んでもよい。また上記プログラムは、前述した機能の一部を実現するためのものであってもよく、さらに前述した機能をコンピュータシステムにすでに記録されているプログラムとの組み合わせで実現できるものであってもよく、PLD(Programmable Logic Device)やFPGA(Field Programmable Gate Array)等のハードウェアを用いて実現されるものであってもよい。 You may make it implement | achieve all or one part of the video coding apparatus in embodiment mentioned above with a computer. In that case, a program for realizing this function may be recorded on a computer-readable recording medium, and the program recorded on this recording medium may be read into a computer system and executed. Here, the “computer system” includes an OS and hardware such as peripheral devices. The “computer-readable recording medium” refers to a storage device such as a flexible medium, a magneto-optical disk, a portable medium such as a ROM and a CD-ROM, and a hard disk incorporated in a computer system. Furthermore, the “computer-readable recording medium” dynamically holds a program for a short time like a communication line when transmitting a program via a network such as the Internet or a communication line such as a telephone line. In this case, a volatile memory inside a computer system serving as a server or a client in that case may be included and a program held for a certain period of time. Further, the program may be a program for realizing a part of the above-described functions, and may be a program capable of realizing the functions described above in combination with a program already recorded in a computer system. It may be realized using hardware such as PLD (Programmable Logic Device) or FPGA (Field Programmable Gate Array).
以上、図面を参照して本発明の実施の形態を説明してきたが、上記実施の形態は本発明の例示に過ぎず、本発明が上記実施の形態に限定されるものではないことは明らかである。したがって、本発明の技術思想及び範囲を逸脱しない範囲で構成要素の追加、省略、置換、その他の変更を行ってもよい。 As mentioned above, although embodiment of this invention has been described with reference to drawings, the said embodiment is only the illustration of this invention, and it is clear that this invention is not limited to the said embodiment. is there. Therefore, additions, omissions, substitutions, and other modifications of the components may be made without departing from the technical idea and scope of the present invention.
バッファアンダーフローのリスクを低く抑えつつ、可能な限り並列処理数を高めることにより高速に符号化することが不可欠な用途に適用できる。 It can be applied to applications where it is essential to perform high-speed encoding by increasing the number of parallel processes as much as possible while keeping the risk of buffer underflow low.
1・・・原画像バッファ、10・・・復号画像バッファ、12−1〜N・・・符号化部、13・・・ストリームバッファ、14・・・並列処理割り当て部、15・・・バッファ計算部、16・・・割り当て符号量算出部、17・・・QP計算部、18・・・複雑さ計算部、19・・・レート制御部、20・・・並列数算出部 DESCRIPTION OF SYMBOLS 1 ... Original image buffer, 10 ... Decoded image buffer, 12-1 to N ... Encoding part, 13 ... Stream buffer, 14 ... Parallel processing allocation part, 15 ... Buffer calculation , 16 ... Allocation code amount calculation unit, 17 ... QP calculation unit, 18 ... Complexity calculation unit, 19 ... Rate control unit, 20 ... Parallel number calculation unit
Claims (7)
前記N枚の各ピクチャに対する前記割り当て符号量の誤差に基づいて、前記割り当て符号量を再算出する割り当て符号量再算出ステップと、
N枚の各ピクチャに対する前記割り当て符号量から各ピクチャの符号化後のバッファのデータ蓄積量の推定量を示すバッファ位置推定値を算出するバッファ位置推定値算出ステップと、
算出した各ピクチャの前記符号化後のバッファ位置推定値と、予め定められた閾値との大小を比較する比較ステップと、
前記大小の比較の結果に基づき、前記閾値以上となっているピクチャの枚数を求める枚数算出ステップと、
前記ピクチャの枚数に基づいて、前記符号化部によって並列に符号化するピクチャの枚数である並列数を算出する並列数算出ステップと
を有する映像符号化方法。 An encoding unit that encodes a plurality of pictures up to N (N is a natural number of 2 or more) in parallel, an allocation code amount calculation unit that calculates an allocation code amount for each of the N pictures, and the allocation code amount A video encoding method performed by a video encoding device that encodes video, comprising a QP calculation unit that calculates a target QP that is a corresponding quantization parameter,
An allocation code amount recalculation step of recalculating the allocation code amount based on an error of the allocation code amount for each of the N pictures;
A buffer position estimated value calculating step for calculating a buffer position estimated value indicating an estimated amount of data accumulation in the buffer after encoding each picture from the allocated code amount for each of N pictures;
A comparison step for comparing the calculated buffer position estimated value of each picture with a predetermined threshold value;
A number-of-sheets calculating step for determining the number of pictures that are equal to or greater than the threshold based on the result of the comparison of the magnitudes;
And a parallel number calculating step of calculating a parallel number that is the number of pictures to be encoded in parallel by the encoding unit based on the number of pictures.
最大N(Nは2以上の自然数)枚までの複数ピクチャを並列に符号化する符号化部と、
N枚の各ピクチャに対する割り当て符号量を算出する割り当て符号量算出部と、
前記割り当て符号量に相当する量子化パラメータであるターゲットQPを算出するQP計算部と、
前記N枚の各ピクチャに対する前記割り当て符号量の誤差に基づいて、前記割り当て符号量を再算出する割り当て符号量再再算出部と、
N枚の各ピクチャに対する前記割り当て符号量から各ピクチャの符号化後のバッファのデータ蓄積量の推定量を示すバッファ位置推定値を算出するバッファ位置推定値算出部と、
算出した各ピクチャの前記符号化後のバッファ位置推定値と、予め定められた閾値との大小を比較する比較部と、
前記大小の比較の結果に基づき、前記閾値以上となっているピクチャの枚数を求める枚数算出部と、
前記ピクチャの枚数に基づいて、前記符号化部によって並列に符号化するピクチャの枚数である並列数を算出する並列数算出部と
を備える映像符号化装置。 A video encoding device for encoding video,
An encoding unit for encoding a plurality of pictures up to N (N is a natural number of 2 or more) in parallel;
An allocation code amount calculation unit for calculating an allocation code amount for each of the N pictures;
A QP calculation unit for calculating a target QP that is a quantization parameter corresponding to the allocated code amount;
An allocation code amount re-recalculation unit that recalculates the allocation code amount based on an error of the allocation code amount for each of the N pictures;
A buffer position estimated value calculating unit that calculates a buffer position estimated value indicating an estimated amount of data accumulation in a buffer after encoding each picture from the allocated code amount for each of N pictures;
A comparing unit that compares the calculated buffer position estimated value of each picture after the encoding with a predetermined threshold;
A number calculation unit for determining the number of pictures that are equal to or greater than the threshold based on the result of the magnitude comparison;
A video encoding apparatus comprising: a parallel number calculating unit that calculates a parallel number that is the number of pictures to be encoded in parallel by the encoding unit based on the number of pictures.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2016001281A JP6470191B2 (en) | 2016-01-06 | 2016-01-06 | Video encoding method, video encoding apparatus, and video encoding program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2016001281A JP6470191B2 (en) | 2016-01-06 | 2016-01-06 | Video encoding method, video encoding apparatus, and video encoding program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2017123545A JP2017123545A (en) | 2017-07-13 |
JP6470191B2 true JP6470191B2 (en) | 2019-02-13 |
Family
ID=59306654
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2016001281A Active JP6470191B2 (en) | 2016-01-06 | 2016-01-06 | Video encoding method, video encoding apparatus, and video encoding program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6470191B2 (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11323703B2 (en) | 2018-07-03 | 2022-05-03 | Nec Corporation | Moving-image encoding device, moving-image encoding method, and program |
WO2021084679A1 (en) * | 2019-10-31 | 2021-05-06 | 株式会社ソシオネクスト | Video encoding method, encoding processing method, video encoding apparatus, and encoding processing apparatus |
CN112333526B (en) * | 2020-10-26 | 2022-08-16 | 浙江大华技术股份有限公司 | Video buffer adjustment method and device, storage medium and electronic device |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3621598B2 (en) * | 1999-03-04 | 2005-02-16 | 日本電信電話株式会社 | Parallel software image encoding method and recording medium recording parallel software image encoding program |
JP5706759B2 (en) * | 2011-06-01 | 2015-04-22 | ルネサスエレクトロニクス株式会社 | Image coding apparatus and image coding method |
JP2015171114A (en) * | 2014-03-11 | 2015-09-28 | キヤノン株式会社 | Moving image encoder |
-
2016
- 2016-01-06 JP JP2016001281A patent/JP6470191B2/en active Active
Also Published As
Publication number | Publication date |
---|---|
JP2017123545A (en) | 2017-07-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9282329B2 (en) | Methods and devices for data compression using offset-based adaptive reconstruction levels | |
JP5152402B2 (en) | Moving picture coding apparatus, moving picture coding method, and moving picture coding computer program | |
JP5472105B2 (en) | Image processing apparatus and image processing method | |
KR101391661B1 (en) | Video coding control method, video coding device and video coding program | |
US6229849B1 (en) | Coding device and method | |
KR101494562B1 (en) | Moving picture encoding device, moving picture encoding method and computer-readable recording medium storing computer program for moving picture encoding | |
US8582898B2 (en) | Method and apparatus for encoding and decoding image based on code table selection adapted to residual value distribution | |
US9955168B2 (en) | Constraining number of bits generated relative to VBV buffer | |
KR101389919B1 (en) | Moving image encoding control method, moving image encoding apparatus and moving image encoding program | |
KR100796857B1 (en) | Moving image encoding method and apparatus | |
JP4668767B2 (en) | Moving picture coding apparatus and moving picture coding program | |
JP6470191B2 (en) | Video encoding method, video encoding apparatus, and video encoding program | |
JP7343817B2 (en) | Encoding device, encoding method, and encoding program | |
JP2006295535A (en) | Dynamic image coding apparatus, and method | |
JP4485996B2 (en) | Image encoding apparatus and image encoding program | |
KR20040007818A (en) | Method for controlling DCT computational quantity for encoding motion image and apparatus thereof | |
JP7001159B2 (en) | Video coding device, video coding method, program | |
JP2012138661A (en) | Image processing apparatus and method | |
JP5741073B2 (en) | Image encoding apparatus, image encoding method, and image encoding program | |
JP3889552B2 (en) | Code amount allocation apparatus and method | |
JP2009200871A (en) | Encoding apparatus | |
JP4962609B2 (en) | Moving picture coding apparatus and moving picture coding program | |
JP4582710B2 (en) | Video encoding device | |
JP6985899B2 (en) | Image coding device and its control method and program | |
JP2004349855A (en) | Coder |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20180219 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20181205 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20190115 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20190117 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 6470191 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |