*4.3. PU Mode Decision*

The CU splitting or non-splitting is formulated as a binary classification problem *ωi*, where *i* = 0, 1. In this work, *ω*<sup>0</sup> and *ω*<sup>1</sup> respectively represent CU non-splitting and CU splitting, and the variable *x* represents the RD-cost of the PU. According to the Bayes' rule, the posterior probability *p*(*ωi*|*x*) can be calculated as follows:

$$p(\omega\_i|\mathbf{x}) = \frac{p(\mathbf{x}|\omega\_i)p(\omega\_i)}{p(\mathbf{x})}.\tag{6}$$

According to Bayesian decision theory, the prior probability *p*(*ωi*) and the conditional probability *p*(*x*|*ωi*) values must be known. Therefore, CU non-splitting (*ω*0) will be chosen if the following condition holds true:

$$p(\omega\_0|\mathbf{x}) > p(\omega\_1|\mathbf{x}).\tag{7}$$

Otherwise, CU splitting (*ω*1) will be chosen.

The conditional probability *p*(*x*|*ω*0) and *p*(*x*|*ω*1) are the probability density function of the RD cost, and they are approximated by normal distributions. Defining the mean values and covariance of RD cost of CU non-splitting and splitting as *N*(*μ*0, *σ*0) and *N*(*μ*1, *σ*1), the normal function can be given by

$$p(\mathbf{x}|\omega\_0) = \frac{1}{\sqrt{2\pi}\sigma\_0} \exp\{-\frac{(\mathbf{x}-\mu\_0)^2}{2\sigma\_0^2}\}, \quad p(\mathbf{x}|\omega\_1) = \frac{1}{\sqrt{2\pi}\sigma\_1} \exp\{-\frac{(\mathbf{x}-\mu\_1)^2}{2\sigma\_1^2}\}.\tag{8}$$

The prior probability *p*(*ωi*) is modeled with Gibbs Random Fields (GRF) model in set *G* [30], and *p*(*ωi*) will always have the Gibbsian form

$$p(\omega\_{\bar{i}}) = Z^{-1} \exp(-E(\omega\_{\bar{i}})), \quad E(\omega\_{\bar{i}}) = \sum\_{k \in G} \varrho(\omega\_{\bar{i}}, \overline{\omega\_k}). \tag{9}$$

where *Z* is a normalization constant, and *E*(*ωi*) is cost function. *k* is the index of set *G*, and *ω<sup>k</sup>* denotes the non-splitting or splitting value of the neighborhood *k*-CU (*ω<sup>k</sup>* = −1, 1). The CU size decision deals with the binary classification problem (*ω<sup>i</sup>* = −1, 1), and the clique potential *ϕ*(*ωi*, *ωk*) obeys the Ising model [31]:

$$
\mathfrak{g}(\omega\_i, \overline{\omega}\_k) = -\gamma \times (\omega\_i \times \overline{\omega}\_k),
\tag{10}
$$

where the parameter *γ* is the coupling factor, which denotes the strength of current CU correlation with neighborhood *k*-CU in set *G*. In this work, *γ* is set to "0.75". Then, the prior *p*(*ωi*) can be written in the factorized form:

$$p(\omega\_i) \propto \exp(-E(\omega\_i)) = \exp(\sum\_{k \in G} -\gamma \times (\omega\_i \times \varpi\_k)).\tag{11}$$

At last, the Equation (6) can be written as

$$p(\omega\_i|\mathbf{x}) \propto p(\mathbf{x}|\omega\_i)p(\omega\_i) \propto \exp(\sum\_{k \in G} -\gamma \times (\omega\_i \times \varpi\_k)) \times \frac{1}{\sigma\_i} \exp\{-\frac{(\mathbf{x}-\mu\_i)^2}{2\sigma\_i^2}\}.\tag{12}$$

Finally we can define the final CU decision function as *S*(*ωi*), which can be written in the exponential form

$$S(\omega\_i) = \exp(\sum\_{k \in G} -\gamma \times (\omega\_i \times \overline{\omega}\_k)) \times \frac{1}{\sigma\_i} \exp\{-\frac{(\mathbf{x} - \mu\_i)^2}{2\sigma\_i^2}\}.\tag{13}$$

It should be noted that the statistical parameters *p*(*x*|*ωi*) are estimated by using a non-parametric estimation with online learning, and are stored in a lookup table (LUT). The frames used for online updating of the values of (*μ*0, *σ*0) and (*μ*1, *σ*1) are shown as in Figure 5. In each group of pictures(GOP), the 1st frame that can be encoded by using the original H.265/HEVC coding will be used for the online update, while the successive frames are coded by using the proposed algorithm.

**Figure 5.** The statistical parameters are estimated with online learning.

Through the above analysis, the proposed PU decision based on Bayes' rule includes the CU termination decision (inter 2*N* ∗ 2*N*) and CU skip decision (inter 2*N* ∗ 2*N*, *N* ∗ 2*N*, 2*N* ∗ *N*). In the case of the CU termination decision, the current CU is not divided into sub-CUs in the sub-depth. In the case of the CU skip decision, the current PU mode in current CU depth is determined at the earliest possible stage. Therefore, the flowchart of the proposed PU mode decision is described as follows.


#### *4.4. The Overall Framework*

Based on the above analysis, the proposed overall algorithm incorporates the CTU depth decision and the PU mode decision algorithms to reduce the computation complexity of the H.265/HEVC encoder. The flowcharts are shown in Figures 6 and 7, respectively. The proposed CTU depth decision and PU mode decision algorithms have been discussed in Sections 4.2 and 4.3.

**Figure 6.** Flowchart of the proposed CTU depth decision.

**Figure 7.** Flowchart of the proposed prediction unit (PU) mode decision.

It is noted that the maximum GOP size is equal to "8" in this work, and the value of (*μ*0, *σ*0) and (*μ*1, *σ*1) are updated every GOP for PU mode decision.

#### *4.5. Encoder Hardware Architecture*

Figure 8 shows the core architecture of the H.265/HEVC with mode decision. By using the architecture, inter-frame prediction is used to eliminate the spatiotemporal redundancy. The proposed CU decision method can accelerate the inter-prediction module before fast rate-distortion optimization (RDO). The novel spatiotemporal neighboring set is used to reduce the complexity of inter encoder which leads to a very low-power cost. Moreover, video codec on mobile vehicles for VANETs need to be more energy efficient and more reliable, so reducing the complexity of the video encoder is important. Then, the proposed low-complexity and hardware-friendly H.265/HEVC encoder can ensure the reliability of the video codec for VANETs significantly. Moreover, as a benefit of the high complexity reduction rate, the energy consumption can be reduced for hardware design, significantly.

**Figure 8.** Mode decision process.
