AV1 specification を読む 2018-03-26 (7.10.1 Intra Prediction Process) 

#AV1 specification 日本語訳 (2018-03-26)

## 7.10. Prediction Processes

> The following sections define the processes used for predicting the sample values.

本節では、画素値を予測する処理を定義します。

>These processes are triggered at points defined by function calls to predict_intra, predict_inter,
predict_chroma_from_luma, and predict_palette in the residual syntax table described in section 5.9.32.

これらの処理は、residual（5.9.32節）の predict_intra, predict_inter,
predict_chroma_from_luma, predict_palette の呼び出しで実行します。

### 7.10.1. Intra Prediction Process

> The intra prediction process is invoked for intra coded blocks to predict a part of the block corresponding to a transform
block. When the transform size is smaller than the block size, this process can be invoked multiple times within a single
block for the same plane, and the invocations are in raster order within the block.

イントラ予測処理は、変換ブロックに対応するブロックの一部を予測するために、イントラ符号化ブロックで呼び出されます。
変換サイズがブロックサイズよりも小さい場合には、この処理は同じプレーンの1つのブロックについて複数回呼ばれます。
呼び出し順はブロック内でラスタ順です。

> This process is triggered by a call to predict_intra.

この処理は predict_intra() で実行します。

> The inputs to this process are:
 * a variable plane specifying which plane is being predicted,
 * variables x and y specifying the location of the top left sample in the CurrFrame[ plane ] array of the current transform block,
 * a variable haveLeft that is equal to 1 if there are valid samples to the left of this transform block,
 * a variable haveAbove that is equal to 1 if there are valid samples above this transform block,
 * a variable haveAboveRight that is equal to 1 if there are valid samples above the transform block to the right of this transform block,
 * a variable haveBelowLeft that is equal to 1 if there are valid samples to the left of the transform block below this transform block,
 * a variable mode specifying the type of intra prediction to apply,
 * a variable log2W specifying the base 2 logarithm of the width of the region to be predicted,
 * a variable log2H specifying the base 2 logarithm of the height of the region to be predicted.


この処理の入力は以下の通りです。

 * どのプレーンを予測するかを指定する plane
 * カレント変換ブロック左上角の CurrFrame[plane] 内座標 (x, y)
 * 変換ブロックの左に有効な画素があるかどうかの変数 haveLeft
 * 変換ブロックの上に有効な画素があるかどうかの変数 haveAbove
 * 変換ブロックの右上に有効な画素があるかどうかの変数 haveAboveLeft
 * 変換ブロックの左下に有効な画素があるかどうかの変数 haveBelowLeft
 * イントラ予想モード mode
 * 予測領域のlog2幅　log2W
 * 予測領域のlog2高さ　log2H

> The process makes use of the already reconstructed samples in the current frame CurrFrame to form a prediction for the current block.

この処理では、カレントフレーム CurrFrame の再構成済み画素を、カレントブロックの予測に使います。

> The outputs of this process are intra predicted samples in the current frame CurrFrame.

この処理の出力は、カレントフレーム CurrFrame のイントラ予測値でう。

> The variable w is set equal to 1 << log2W.
The variable h is set equal to 1 << log2H.
The variable maxX is set equal to ( MiCols * MI_SIZE ) - 1.
The variable maxY is set equal to ( MiRows * MI_SIZE ) - 1.

w = 1 << log2W
h = 1 << log2H
maxX = (MiCols * MI_SIZE) - 1
maxY = (MiRows * MI_SIZE) - 1

> If plane is greater than 0, then:
 * maxX is set equal to ( ( MiCols * MI_SIZE ) >> subsampling_x ) - 1.
 * maxY is set equal to ( ( MiRows * MI_SIZE ) >> subsampling_y ) - 1.

plane>0 ならば

 * maxX = ((MiCols * MI_SIZE) >> subasmpling_x) - 1
 * maxX = ((MiRows * MI_SIZE) >> subasmplingy_y) - 1

> The array AboveRow[ i ] for i = 0..w + h - 1 is derived as follows:
 * If haveAbove is equal to 0 and haveLeft is equal to 1, AboveRow[ i ] is set equal to CurrFrame[ plane ][ y ][ x - 1 ].
 * Otherwise, if haveAbove is equal to 0 and haveLeft is equal to 0, AboveRow[ i ] is set equal to ( 1 << ( BitDepth - 1 ) ) - 1.
 * Otherwise, the following applies:
  * The variable aboveLimit is set equal to Min( maxX, x + ( haveAboveRight ? 2 * w : w ) - 1 ).
  * AboveRow[ i ] is set equal to CurrFrame[ plane ][ y-1 ][ Min(aboveLimit, x+i) ].

配列 AboveRow[i], i=0..(w+h-1) を以下のように求めます。

 * haveAbove==0 && haveLeft==1 ならば、AboveRw[i] = CurrFrane[plane][y][x-1]
 * そうではなく、haveAbove==0 && haveLeft=0 ならば、AboveRow[i] = (1 << (BitDepth-1))-1
 }
 * そうではなければ、以下を適用します。
  * aboveLimit = Min( maxX, x + ( haveAboveRight ? 2 * w : w ) - 1 )
  * AboveRow[i] = CurrFrame[ plane ][ y-1 ][ Min(aboveLimit, x+i) ]

> The array LeftCol[ i ] for i = 0..w + h - 1 is derived as follows:
 * If haveLeft is equal to 0 and haveAbove is equal to 1, LeftCol[ i ] is set equal to CurrFrame[ plane ][ y - 1 ][ x ].
 * Otherwise, if haveLeft is equal to 0 and haveAbove is equal to 0, LeftCol[ i ] is set equal to ( 1 << ( BitDepth - 1 ) ) + 1.
 * Otherwise, the following applies:
  * The variable leftLimit is set equal to Min( maxY, y + ( haveBelowLeft ? 2 * h : h ) - 1 ).
  * LeftCol[ i ] is set equal to CurrFrame[ plane ][ Min(leftLimit, y+i) ][ x-1 ].

配列 LeftCol[i], i=0..(w+h-1) を以下のように求めます。

 * haveLeft==0 && haveAbove==1 ならば、AboveRw[i] = CurrFrane[plane][y-1][x]
 * そうではなく、haveLeft==0 && haveAbove=0 ならば、LeftCol[i] = (1 << (BitDepth-1))-1
 }
 * そうではなければ、以下を適用します。
  * leftLimit = Min( maxY, y + ( haveBelowLeft ? 2 * h : h ) - 1 )
  * LeftCol[i] = CurrFrame[ plane ][ Min(leftLimit, y+i) ][ x-1 ]

> The array AboveRow[ i ] for i = -1 is specified by:
 * If haveAbove is equal to 1 and haveLeft is equal to 1, AboveRow[ -1 ] is set equal to CurrFrame[ plane ][ y-1 ][
x-1 ].
 * Otherwise if haveAbove is equal to 1, AboveRow[ -1 ] is set equal to CurrFrame [ plane ][ y - 1 ][ x ].
 * Otherwise if haveLeft is equal to 1, AboveRow[ -1 ] is set equal to CurrFrame [ plane ][ y ][ x - 1 ].
 * Otherwise, AboveRow[ -1 ] is set equal to 1 << ( BitDepth - 1 ).

配列 AboveRow[i], i=-1 を貴下のように規定します。

 * haveAbove==1 && haveLeft==1 ならば、AboveRow[-1] = CurrFrame[plane][y-1][x-1]
 * そうではなく、haveAbove==1 ならば、AboveRow[-1] = CurrFrame[plane][y-1][x]
 * そうではなく、haveLeft==1 ならば、AboveRow[-1] = CurrFrame[plane][y][x-1]
 * そうではなければ、AboveRow[-1] = 1 << (BitDpeth-1)

> The array LeftCol[ i ] for i = -1 is set equal to AboveRow[ -1 ].

LeftCol[-1] = AboveRow[-1]

> A 2D array named pred containing the intra predicted samples is constructed as follows:
 * If plane is equal to 0 and use_filter_intra is true, the recursive intra prediction process specified in section
7.10.1.2 is invoked with w and h as inputs, and the output is assigned to pred.
 * Otherwise, if is_directional_mode( mode ) is true, the directional intra prediction process specified in section
7.10.1.3 is invoked with plane, x, y, haveLeft, haveAbove, mode, w, h, maxX, maxY as inputs and the output is
assigned to pred.
 * Otherwise if mode is equal to SMOOTH_PRED or SMOOTH_V_PRED or SMOOTH_H_PRED, the smooth intra
prediction process specified in section 7.10.1.5 is invoked with mode, log2W, log2H, w, and h as inputs, and the
output is assigned to pred.
 * Otherwise if mode is equal to DC_PRED, the DC intra prediction process specified in section 7.10.1.4 is invoked
with haveLeft, haveAbove, log2W, log2H, w, and h as inputs and the output is assigned to pred.
 * Otherwise, the basic intra prediction process specified in section 7.10.1.1 is invoked with mode, w, and h as
inputs, and the output is assigned to pred.

イントラ予測画素を含む配列 pred を以下のように構成します。

 * plane==0 && use_filter_intra==TRUE ならば、再帰イントラ予測処理（7.10.1.2節）を、w,h を入力として呼び出し、出力を pred に割り当てます。
 * そうではなく、is_directional_mode(mode)==TRUE ならば、方向的イントラ予測処理（7.10.1.3節）を、plane, x, y, haveLeft, haveAbove, mode, w, h, maxX, maxY を入力として呼び出し、出力を pred に割り当てます。
 * そうではなく、mode==SMOOTH_PRED || SMOOTH_V_PRED || SMOOTH_H_PRED ならば、スムースイントラ予測処理（7.10.1.5節）を、mode, log2W, log2H, w, h を入力として呼び出し、出力を pred に割り当てます。
 * そうではなく、mode==DC_PRED ならば、DCイントラよく処理（7.10.1.4節）を、haveLeft, haveAbove, log2W, log2H, w, h を入力として呼び出し、出力を pred に割り当てます。
 * そうではなければ、基本イントラ予測処理（7.10.1.1節）を、mode, w, h を入力として呼び出し、出力を pred に割り当てます。

> The current frame is updated as follows:
 * CurrFrame[ plane ][ y + i ][ x + j ] is set equal to pred[ i ][ j ] for i = 0..h-1 and j = 0..w-1.

カレントフレームを以下のように更新します。

 * CurrFrame[plane][y+i][x+j] = pred[i][j], i=0..h-1, j=0..w-1