Designs and Implementations in Neural Network-based Video Coding
The past decade has witnessed the huge success of deep learning in well-known
artificial intelligence applications such as face recognition, autonomous
driving, and large language model like ChatGPT. Recently, the application of
deep learning has been extended to a much wider range, with neural
network-based video coding being one of them. Neural network-based video coding
can be performed at two different levels: embedding neural network-based
(NN-based) coding tools into a classical video compression framework or
building the entire compression framework upon neural networks. This paper
elaborates some of the recent exploration efforts of JVET (Joint Video Experts
Team of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC29) in the name of neural
network-based video coding (NNVC), falling in the former category.
Specifically, this paper discusses two major NN-based video coding
technologies, i.e. neural network-based intra prediction and neural
network-based in-loop filtering, which have been investigated for several
meeting cycles in JVET and finally adopted into the reference software of NNVC.
Extensive experiments on top of the NNVC have been conducted to evaluate the
effectiveness of the proposed techniques. Compared with VTM-11.0_nnvc, the
proposed NN-based coding tools in NNVC-4.0 could achieve {11.94%, 21.86%,
22.59%}, {9.18%, 19.76%, 20.92%}, and {10.63%, 21.56%, 23.02%} BD-rate
reductions on average for {Y, Cb, Cr} under random-access, low-delay, and
all-intra configurations respectively.
Yue Li, Junru Li, Chaoyi Lin, Kai Zhang, Li Zhang, Franck Galpin, Thierry Dumas, Hongtao Wang, Muhammed Coban, Jacob Ström, Du Liu, Kenneth Andersson
# Designs and Implementations in Neural Network-based Video Coding

###### Abstract

The past decade has witnessed the huge success of deep learning in well-known artificial intelligence applications such as face recognition, autonomous driving, and large language model like ChatGPT. Recently, the application of deep learning has been extended to a much wider range, with neural network-based video coding being one of them. Neural network-based video coding can be performed at two different levels: embedding neural network-based (NN-based) coding tools into a classical video compression framework or building the entire compression framework upon neural networks. This paper elaborates some of the recent exploration efforts of JVET (Joint Video Experts Team of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC29) in the name of neural network-based video coding (NNVC), falling in the former category. Specifically, this paper discusses two major NN-based video coding technologies, i.e. neural network-based intra prediction and neural network-based in-loop filtering, which have been investigated for several meeting cycles in JVET and finally adopted into the reference software of NNVC. Extensive experiments on top of the NNVC have been conducted to evaluate the effectiveness of the proposed techniques. Compared with VTM-11.0_nnvc1, the proposed NN-based coding tools in NNVC-4.0 could achieve {11,94%, 21.86%, 22.59%}, {9,18%, 19.76%, 20.92%}, and {10.63%, 21.56%, 23.02%} BD-rate reductions on average for {Y, Ch, Cr} under random-access, low-delay, and all-intra configurations respectively.

 In-loop filter, intra prediction, neural-network-based video coding, Versatile Video Coding, video compression.

## I Introduction

With the popularization of smart phones and rapid development of video-based applications, the volume of video material has been increasing at a unprecedented speed in recent years. The efficient storage and transmission of mass data have become a great challenge. To cope with this challenge, the Joint Video Experts Team of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC29 has developed and finalized the latest video coding standard, namely Versatile Video Coding (VVC), to provide a more compact representation of video data [3]. VVC/H.266 has made significant progresses in terms of coding efficiency, providing approximately a 50% bit-rate saving for equivalent perceptual quality relative to the performance of the prior standard High Efficiency Video Coding (HEVC)/H.265 [4]. While VVC offers a new level of capability for video compression, the necessity of developing more advanced video coding techniques still exists.

Classical video coding schemes epitomized by VVC adopt a sophisticated framework comprising numerous manually optimized and hand-crafted coding tools. After development of several generations of video coding standards such as AVC/H.264 [5], HEVC/H.265, and VVC/H.266, further improvement has become more and more difficult along this path. Therefore, experts are exploring other learning-based schemes to improve coding efficiency.

Due to the availability of powerful computing resources and abundant training data, deep learning has made a significant breakthrough in well-known artificial intelligence applications such as face recognition [6, 7], autonomous driving [8, 9], and large language model like ChatGPT [10] in the past decade. Recently, the application of deep learning has been extended to a much wider range, especially to scenarios which can be easily formulated as a supervised problem. The target of video compression can be conceptualized as constructing a mapping from an original space (i.e., raw video data) to a latent domain (i.e., a bit stream), and back again, fitting the scope of deep learning. There exists two ways to build the mapping: utilizing both deep learning-based modules and non-learning-based modules, or utilizing purely deep learning-based modules [11, 12]. Accordingly, the efforts exploring neural network-based video coding are distributed in two categories: embedding neural network-based (NN-based) coding tools into a classical video compression framework [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], or building the entire compression framework upon neural networks [25, 26, 27, 28, 29, 30]. In the former category, people usually design NN-based alternatives, e.g. NN-based intra/inter predictor [13, 14, 15, 16, 17], transform [18], arithmetic probability estimator [19], in-loop/post filter [20, 21, 22], re-sampler [23], etc. to compete with the non-NN-based counterparts within the classical coding framework and rely on rate-distortion optimization to guarantee an improved performance. While in the latter category, people adopt predictive coding-based
method [25, 26, 27], which first generates the predicted frame e.g. by using optical flow and then encodes residue e.g. with auto-encoder, or conditional coding-based method [28, 29], where prediction is embedded into the latent domain of auto-encoder.

This paper elaborates some of the recent exploration efforts in JVET focusing on developing neural network-based video coding (NNVC) technologies beyond the capabilities of VVC. After investigation activities of several meeting cycles, the experts in JVET have identified two promising NN-based tools as an enhancement of conventional modules in the existing VVC design, i.e. neural network-based intra prediction and neural network-based in-loop filtering, and adopted them into the reference software of NNVC to demonstrate a reference implementation of encoding techniques, decoding process, as well as the training methods for these tools. To generate a better intra prediction, a nonlinear mapping from causal neighboring samples to a prediction of the current block is derived using fully connected neural networks [14, 31]. In addition, the neural network yields side outputs beneficial for subsequent Most Probable Mode (MPM) list construction and the transform kernel selection processes. To better recover details lost during compression, a convolutional neural network-based in-loop filter is designed [32, 33, 34, 35, 36]. The deep filter is trained iteratively to address the over-filtering issue [36]. To further improve performance, the deep filter design also considers elements including coded information exploitation, parameter selection, inference granularity adaptation, residual scaling, temporal filtering, combination with deblocking filtering, harmonization with RDO, etc.

Extensive experiments on top of the Versatile Video Coding have been conducted to evaluate the techniques included in NNVC. Compared with VTM-11.0_nnvc, the proposed NN-based coding tools in NNVC-4.0 could achieve {11.94%, 21.86%, 22.59%}, {9.18%, 19.76%, 20.92%}, and {10.63%, 21.56%, 23.02%} BD-rate reductions on average for {Y, Cb, Cr} under random-access, low-delay, and all-intra configurations respectively.

The remainder of the paper is organized as follows. Section II introduces NN-based intra prediction technique. Section III elaborates NN-based in-loop filtering technique. Section IV describes the small ad-hoc deep learning (SADL) library for inference of NN-based models in NNVC. Performance evaluation of NNVC techniques is presented in Section V. Finally, Section VI concludes the paper.

## II NN-based Intra Prediction

### _VVC coding tools directly interacting with the NN-based intra prediction_

To justify the design of the NN-based intra prediction in Section II-B, the VVC coding tools featuring the strongest interactions in terms of compression efficiency with the NN-based intra prediction mode to be put into VVC must be detailed.

Any intra prediction mode, including a NN-based one, interacts in particular with the other intra prediction modes partly because the entropy coding in the signaling of the index of the intra prediction mode selected to predict a given block creates competition between them. Moreover, any intra prediction mode depends on transform coding as the residue resulting from the intra prediction of a given block is passed on to transform coding [37]. This dependency grows even more in the case of the secondary transforms in VVC, called Low-Frequency Non-Separable Transform (LFNST), as different LFNST kernels are specialized to different intra modes.

Precisely, for a given block predicted in intra and using the Discrete Cosine Transform-2 (DCT-2) horizontally and the DCT-2 vertically as primary transform, LFNST consists in applying a non-separable transform to the top-left region of the block of coefficients arising from the primary transform [37, 38]. LFNST gathers \(4\) transform sets with \(2\) kernels per set. Note that, for a given kernel in a given transform set, the used matrix of weights and the shape of the top-left region involved in the second transform are determined by the size of the current block. The signaling of LFNST is decomposed into a so-called explicit signaling of the kernel set index and a so-called implicit signaling of the transform set index. In the explicit signaling, _lfnstIdx_\(\in\{0,1,2\}\) is written to the bitstream. _lfnstIdx_\(=0\) means that LFNST does not apply for the current block whereas, if _lfnstIdx_\(\{1,2\}\), _lfnstIdx_ - 1 indicates the used kernel set index. In the implicit signaling, the index of the intra prediction mode selected to predict the current block directly maps to the transform set index and whether the block of primary transform coefficients is transposed before applying LFNST. As no relationship between the _directionality_ of the prediction of a given block via a NN and the index of the NN-based intra prediction mode exists [39], this mapping must not be reused for a block predicted via NN, and rather be produced by the NN, see Section II-B.

### _Framework_

The NN-based intra prediction mode contains \(7\) neural networks, each predicting blocks of a different size in \(\{4\times 4,8\times 4,16\times 4,32\times 4,8\times 8,16\times 8,16\times 16\}\).

In this NN-based intra prediction mode, the neural network predicting blocks of size \(w\times h\) is denoted \(f_{h,w}\) ( : \(\mathbf{\theta}_{h,w}\)) where \(\mathbf{\theta}_{h,w}\) gathers its parameters. For a given \(w\times h\) block \(\mathbf{Y}\) to be predicted, \(f_{h,w}\) ( : \(\mathbf{\theta}_{h,w}\)) takes a preprocessed version \(\mathbf{\widetilde{X}}\) of the context \(\mathbf{X}\) made of \(n_{a}\) rows of \(n_{l}+2w+e_{w}\) decoded reference samples located above this block and \(n_{l}\) columns of \(2h+e_{h}\) decoded reference samples located on its left side to provide \(\mathbf{\widetilde{Y}}\), see Fig. 1. The application of a postprocessing to \(\mathbf{\widetilde{Y}}\) yields a prediction \(\mathbf{\hat{Y}}\) of \(\mathbf{Y}\). The above-mentioned preprocessing and postprocessing are fully specified in Section II-C. Besides, to replace the mapping in the LFNST implicit signaling presented in Section II-A, \(f_{h,w}\) ( : \(\mathbf{\theta}_{h,w}\)) returns two indices grpldx\({}_{1}\) and grpldx\({}_{2}\). For \(i\in\{1,2\}\), grpldx\({}_{i}\) denotes the index characterizing the LFNST transform set index and whether the primary transform coefficients resulting from the application of the DCT-2 horizontally and the DCT-2 vertically to the residue of the neural network prediction are transposed when lfnstIdx\(=i\). Furthermore, for efficient synergy between the VVC intra prediction modes, i.e. PLANAR, DC, and the
\(65\) directional intra prediction modes, and the NN-based intra prediction, c.f. Section II-D, \(f_{h,w}\left(\ \cdot\ ;\ \mathbf{\theta}_{h,w}\right)\) returns the index repldx \(\in[0,66]\) of the VVC intra prediction mode whose prediction of \(\mathbf{Y}\) from one row of decoded reference samples above \(\mathbf{Y}\) and one column of decoded reference samples on its left side is the closest to \(\hat{\mathbf{Y}}\).

Note that \(n_{a}\), \(n_{l}\), \(e_{w}\), and \(e_{h}\) together define the shape of the context \(\mathbf{X}\) of \(\mathbf{Y}\). \(n_{a}\), \(n_{l}\), \(e_{w}\), and \(e_{h}\) depend on \(h\) and \(w\), these dependencies being further explained in Section II-E.

### _Preprocessing and Postprocessing_

The preprocessing of the context fed into a neural network, shared by the training and test phases, is designed to obtain a range of values at the neural network input that eases optimization during the training phase [40]. Precisely, the preprocessing in Fig. 1 consists in the four following steps.

* The mean \(\mu\) of the available reference samples \(\overline{\mathbf{X}}\) in \(\mathbf{X}\) is subtracted from \(\overline{\mathbf{X}}\), where the context \(\mathbf{X}\) of the current \(w\times h\) block \(\mathbf{Y}\) is decomposed into the available reference samples \(\overline{\mathbf{X}}\) and the unavailable reference samples \(\mathbf{X}_{u}\), see Fig. 2.
* The reference samples in the context \(\mathbf{X}\) are multiplied by \(\rho=1/(2^{b-8})\), \(b\) being the internal bitdepth, i.e. 10 in VVC.
* All the unavailable reference samples \(\mathbf{X}_{u}\) in \(\mathbf{X}\) are set to 0.
* The context resulting from the previous step is flattened, yielding the vector \(\widetilde{\mathbf{X}}\) of size \(n_{a}(n_{l}+2w+e_{w})+(2h+e_{h})n_{l}\).

The postprocessing of the output of a neural network must approximatively reverses the above preprocessing. Precisely, the postprocessing depicted in Fig. 1 consists in reshaping the vector \(\hat{\mathbf{Y}}\) of size \(hw\) into a rectangle of height \(h\) and width \(w\), dividing the result of the reshape by \(\rho\), adding the mean \(\mu\) of the available reference samples in the context of the current block, and clipping to \([0,\ 2^{b}-1]\). Therefore, the postprocessing can be summarized as

\[\hat{\mathbf{Y}}=\min\Bigg{(}\max\Bigg{(}\frac{\text{reshape}\Big{(}\widetilde{ \mathbf{Y}}\Big{)}}{\rho}+\mu,\ 0\Bigg{)}\,\ 2^{b}-1\Bigg{)}. \tag{1}\]

Note that the above preprocessing and postprocessing apply to a neural network in floats. For a neural network in signed-integers exclusively, \(\rho=2^{Q_{in}-b+8}\), \(Q_{in}\) denoting the input quantizer. For integer width \(16\), \(Q_{in}=7\). For integer width \(32\), \(Q_{in}=23\).

### _MPM List Generation_

In VVC, an efficient entropy coding of the index of the intra prediction mode selected to predict the current luma Coding Block (CB) involves a list of \(6\) Most Probable Modes (MPMs). This list includes the index of the intra prediction mode selected to predict the luma CB above the current one and the index of the intra prediction mode selected to predict the luma CB on the left side of the current one.

In VVC with the NN-based intra prediction mode, if a non-NN-based intra prediction mode is selected to predict the current luma CB and the current luma CB is surrounded by luma CBs predicted via the NN-based intra prediction mode, the relevance of the list of MPMs of the current luma CB can be maintained thanks to repldx. Indeed, if its left luma CB is predicted via the NN-based mode, the repldx returned during the prediction of the left luma CB can become a candidate index to be put into the list of MPMs. If its above luma CB is predicted via the NN-based mode, the repldx collected during the prediction of the above luma CB can become a candidate index to be put into the list of MPMs.

Fig. 2: Decomposition of the context \(\mathbf{X}\) of decoded reference samples around the current \(w\times h\) block \(\mathbf{Y}\) into the available reference samples \(\mathbf{X}\) and the unavailable reference samples \(\mathbf{X}_{u}\). In this figure, \(h=4\), \(w=8\), \(n_{a}=n_{l}=e_{h}=e_{w}=4\), and the number of unavailable reference samples reaches its maximum value.
### _Context Transformations_

As said at the beginning of Section II-B, the NN-based intra prediction mode comprises the \(7\) neural networks \(\{f_{h,w}\left(\.\ ;\mathbf{\theta}_{h,w}\right)\}_{(h,w)\in S}\), \(S=\{\left(4,4\right),\left(4,8\right),\left(4,16\right)\), \(\left(4,32\right),\left(8,8\right),\left(8,16\right),\left(16,16\right)\}\), each predicting blocks of corresponding shape in \(S\). For a given \(w\times h\) block to be predicted, the NN-based intra prediction mode may not contain \(f_{h,w}\left(\.\ ;\mathbf{\theta}_{h,w}\right)\). To circumvent this, context transformations help. Specifically, the context of the current block can be down-sampled vertically by a factor \(\delta\) and/or down-sampled horizontally by a factor \(\gamma\) and/or transposed before the step "preprocessing" in Fig. 1. Then, the prediction of the current block can be transposed and/or up-sampled vertically by the factor \(\delta\) and/or up-sampled horizontally by the factor \(\gamma\) after the step "postprocessing" in Fig. 1. The transposition of the context of the current block and the prediction, \(\delta\), and \(\gamma\) are chosen so that a neural network belonging to the NN-based intra prediction mode can be picked for prediction, see Table I. Note that the NN-based intra prediction mode is disallowed for \(\left(h,w\right)\) absent from Table I.

To limit the complexity of the neural network prediction, \(n_{a}\left(h,w\right)\) and \(n_{l}\left(h,w\right)\) are defined such that, after the potential context transformations, the number of rows and the number of columns in the resulting context never exceed \(8\).

### _Signaling of the NN-based Intra Prediction Mode_

#### Iv-F1 Signaling in luma

Given that the NN-based intra prediction mode predicts blocks of each shape in \(\overline{S}=S\cup\{\left(8,4\right),\left(16,4\right)\), \(\left(32,4\right)\), \(\left(16,8\right)\), \(\left(8,32\right)\), \(\left(32,8\right)\), \(\left(16,32\right)\), \(\left(32,16\right)\), \(\left(32,32\right)\), \(\left(64,64\right)\}\), c.f. Section II-E, the intra prediction mode signaling of the current \(w\times h\) luma CB can be adapted to incorporate the NN-based mode, at low cost, by introducing a flag \(nnFlagY\) only if \(\left(h,w\right)\in\overline{S}\). In details, the adapted intra prediction mode signaling \(\mathcal{S}_{a}\) of the current \(w\times h\) luma CB whose top-left pixel is at position \(\left(y,x\right)\) in the current luma channel is split into two cases, see Fig. 3.

* If \(\left(h,w\right)\in\overline{S}\), \(nnFlagY\) appears. \(nnFlagY=1\) means that the NN-based mode is selected, then END. \(nnFlagY=0\) tells that the NN-based mode is not selected, then the regular VVC intra prediction mode signaling \(\mathcal{S}_{Y}\) of the current luma CB applies.
* Otherwise, \(\mathcal{S}_{Y}\) applies.

Note that, in the case \(\left(h,w\right)\in\overline{S}\)\(\&\&\)\(nnFlagY=1\), if the context of the current luma CB goes out of the current luma channel bounds, i.e. \(x<n_{l}\parallel y<n_{a}\), PLANAR replaces the NN-based intra prediction.

#### Iv-G2 Signaling in chroma

Before presenting the signaling of the NN-based mode in chroma, the Direct Mode (DM) in VVC must be detailed. For a given pair of chroma CBs predicted via the DM, the intra prediction mode selected to predict the luma CB being collocated with this pair of chroma CBs is used to predict each of these two chroma CBs [41].

Based on the principle of the proposed signaling in luma, c.f. II-F1, the adapted intra prediction mode signaling of the current pair of \(w\times h\) chroma CBs whose top-left pixel is at position \(\left(y,x\right)\) in the current pair of chroma channels is decomposed into two cases.

* If the luma CB collocated with this pair of chroma CBs is predicted by the NN-based mode
* If \(\left(h,w\right)\in\overline{S}\), denoted Case \(\left[*\right]\), the DM becomes the NN-based intra prediction mode.
* Otherwise, the DM is set to PLANAR.

* If \(\left(h,w\right)\in\overline{S}\), \(nnFlagC\) is placed before the DM flag in the decision tree of the intra prediction mode signaling in chroma. \(nnFlagC=1\), a.k.a Case \(\left[**\right]\), indicates that the NN-based mode is selected, then END. \(nnFlagC=0\) tells that the NN-based mode is not selected, then the regular VVC intra prediction mode signaling \(\mathcal{S}_{C}\) of the current pair of chroma CBs resumes from the DM flag.
* Otherwise, \(\mathcal{S}_{C}\) applies.

Note that, in Cases \(\left[*\right]\) and \(\left[**\right]\), if the context of the current chroma CB goes out of the current chroma channel bounds, i.e. \(x<n_{l}\parallel y<n_{a}\), PLANAR replaces the NN-based intra prediction mode.

### _Training_

In an Intra-slice (I-slice) in VVC, as the partitioning is mainly driven by the intra prediction, the reference-samples-to-block relationships specific to the VVC intra prediction modes are usually retrieved in the pairs of a partitioned block

Fig. 3: Adapted intra prediction mode signaling \(\mathcal{S}_{a}\) of the current \(w\times h\) luma CB. This CB is framed in orange using dashed line. The bin value of \(nnFlagY\) appears in bold gray.
and its reference samples [14]. Thus, the training of a neural network on pairs a block extracted from the VVC partitioning of a given frame and its context leads to the neural network learning essentially the VVC intra prediction capability. To bypass this, an iterative training of neural networks for intra prediction is developed, see Fig. 4.

* At cycle \(0\), VTM-11.0 anchor produces pairs of a block and its context. Then, the \(7\) neural networks are trained on them, initializing their parameters randomly.
* At cycle \(1\), VTM-11.0 with the NN-based intra prediction mode using the parameters trained at cycle \(0\) produces pairs of a block and its context. Then, the \(7\) neural networks are trained on them, initializing their parameters from their state at the end of cycle \(0\).
* At cycle \(2\), VTM-11.0 including the NN-based intra prediction mode using the parameters trained at cycle \(1\) generates pairs of a block and its context. Then, the \(7\) neural networks are trained on them, initializing their parameters from their state at the end of cycle \(1\). Then, using the same training data, the trainings of these \(7\) neural networks are resumed, introducing this time a sparsity constraint on their weights.
* At cycle \(3\), VTM-11.0 with the NN-based intra prediction mode using the parameters trained at cycle \(2\) gives training data. Then, the portion computing grpldx\({}_{1}\) and grpldx\({}_{2}\) in each of the \(7\) neural networks is trained on them, initializing their parameters from their state at the end of cycle \(2\).

### _Inference Details_

Small Ad-hoc Deep Learning library (SADL), c.f. Section IV, runs the inference of the NN-based intra prediction, see Table II, using its fixed point-based implementation where both neurons and weights are represented as 16-bit signed integer. In each neural network, each intermediate representation features \(1216\) neurons. In each layer, LeakyReLU is chosen as non-linearity, excluding the last layer without non-linearity.

### _Relation to the state-of-the-art_

Prior to the proposed NN-based intra prediction mode in VVC, neural networks for intra prediction have been integrated into either VVC or one of its predecessor. Especially, in [42, 43], multiple neural networks are jointly trained and then integrated as a single intra prediction mode into a predecessor of VVC: HEVC enhanced with non-square partitions and VTM-1.0 respectively. Precisely, in this mode, a different set of neural network predicts blocks of each size. During the training phase, the use of a partitioner and an objective function being the minimum rate-distortion cost computed from the neural network predictions over all partitions of each training block into sub-blocks induces a specialization of different neural networks to different classes of textures. Note that the iterative simplifications of this NN-based intra prediction mode [44, 45] has led to Matrix-based Intra Prediction (MIP), being part of VVC.

Note that, as MIP is a VVC intra prediction mode, the experiments \(M_{1}\) in Table VIII reflects the rate-distortion performance of the proposed NN-based intra prediction mode on top of MIP.

## III NN-based In-loop Filter

The proposed NN-based in-loop filter is known as filter set #1 [32] in NNVC-4.0. The filter architectures are introduced first, followed by an elaboration on parameter selection, residual scaling, temporal filtering, harmonization with RDO, etc. At last, we describe the inference and training details of the filter.

### _Network Architecture_

Fig. 5 illustrates the diagram of CNN-based in-loop filter for luma component, comprising feature extraction, backbone, and reconstruction parts.

It is asserted in [46] that applying existing in-loop filters in VVC prior to the CNN filter may cause the loss of important information. Therefore, the reconstruction samples (Rec in Fig. 5) refer to samples unfiltered by existing in-loop filters in VTM. Note that in-loop filters such as SAO (sample adaptive offset, [47]) or ALF (adaptive loop filter, [48]) create nontrivial bitrate overhead to lower the compression distortion. When placed after the deep filter, this overhead may be reduced. Besides reconstruction, auxiliary inputs are utilized to improve the performance. Intra/inter prediction is the key process for reducing spatial and temporal redundancy. The encoder selects a prediction mode with the best rate-distortion trade-off from a list of candidates during the encoding process. In other words, the prediction samples from the decoder side could reflect decisions made by the encoder, providing important clues about original samples. In addition, compression distortion is directly caused by the quantization on the residues in the transform domain, while residues are highly dependent on the quality of prediction samples, therefore prediction samples can also significantly impact the type and strength of artifacts in the decoded images. Taking the above analysis into account, prediction samples (Pred in Fig. 5) are fed into the filter as an additional auxiliary input. Similarly, boundary strength (BS in Fig. 5) generated during deblocking process reflects the strength of compression artifact near block boundaries. Inputs of QP and IPB make the filter aware of high-level compression conditions, i.e., quantization parameter and prediction types (intra, uni-inter, bi-inter). Given these two auxiliary inputs, a single model is capable of handling contents compressed with different QPs and block prediction types. For instance, if the IPB information states that a block has been inter predicted
rather than intra predicted, this means that the block has likely been NN-filtered once already, and the NN model can lower the filtering strength to avoid over-filtering.

The feature extraction part accounts for aggregating informations from different inputs. Specifically, individual features are extracted separately, concatenated together along the channel dimension, shrunk through a \(1\times 1\) convolutional layer, and downsampled to half resolution, to form a compact representation of all inputs. The network backbone, which is consisting of 8 cascaded residual blocks, transforms the compact representation into clean features with less compression artifacts. At last, the reconstruction part maps the clean features into the pixel domain to predict the details lost during compression. Note that the CNN-based in-loop filter is actually designed to learn the mapping from distorted input to lost details (residual between groundtruth and distorted input), thus the final output can be obtained by,

\[\mathbf{R}_{nn}=\mathbf{R}_{no}+f(\mathbf{R}_{no}) \tag{2}\]

where \(\mathbf{R}_{no}\) and \(\mathbf{R}_{nn}\) denote the unfiltered samples and filtered samples respectively, while \(f\) is the CNN-based in-loop filter.

Coding tools such as CCLM [49] and CCALF [50] utilize luma information for boosting chroma performance. Similarly, the luma information is exploited for the chroma in-loop filtering. In the YUV 4:2:0 format where the luma resolution is higher than that for chroma, features are first extracted separately from luma and chroma. Then luma features are downsampled and concatenated with chroma features. Note that IPB information is not included in the chroma filter, as no benefits are observed from this input for chroma. The same network backbone and reconstruction parts from the luma network are used for the chroma network.

### _Parameter Selection_

As analyzed in [36], the content propagation phenomenon that exists in the inter coding case may deteriorate the efficiency of in-loop filtering significantly, as samples filtered in one frame may be propagated to a following frame and filtered again, leading to over-filtering. Intuitively, providing options with multiple filtering strengths may mitigate the over-filtering issue. To adjust the filtering strengths of a candidate filter, one possible way is to modify its input parameter QP

Fig. 4: Iterative training of the neural networks belonging to the NN-based intra prediction mode.

Fig. 5: Schematic of CNN-based in-loop filter. Rec, Pred, BS, QP, and IPB stand for reconstruction samples, prediction samples, boundary strength, quantization parameter and prediction types respectively. Number of feature maps is 96 for all internal layers.
slightly, because distortion levels at different QPs should cause filtering behaviors with corresponding strengths during the training process.

Without loss of generality, a candidate list containing three QP parameters is considered by default. Using more parameters may bring better performances at the cost of higher encoding complexity, and vice versa. At encoder side, each picture or block could determine whether to apply the CNN-based in-loop filter or not. When the CNN-based filter is determined to be applied to a picture or a block, the QP parameter must be selected from a candidate list. Specifically, all blocks in the current picture are filtered using three QP parameters in the encoder. Then five costs, i.e. _Cost_0_,..., _Cost_5_, are calculated and compared against each other to find the best rate-distortion trade-off. In _Cost_0_, CNN-based filter is prohibited for all blocks. In _Cost_i_, _i = 1, 2, 3_, CNN-based filter with \(i^{th}\) parameter is used for all blocks. In _Cost_4_, different blocks may prefer different parameters, and the information regarding whether to use CNN-based filter, and if so, which parameter to use is signaled for each block. At decoder side, whether to use CNN-based filter and which parameter to use for a block is based on the _Param_Id_ parsed from the bit-stream

Denote the sequence level QP as q, the candidate list {Param_1, Param_2, Param_3} is set as {q, q-5, q-10} and {q, q-5, q+5} for low and high temporal layers respectively. Stronger filtering strength is used for high temporal layers, because coarser quantization used in these layers may yield large distortion, and since higher temporal layers are used less for prediction, over-filtering is less of a problem. A shared parameter is used for the two chroma components to lower the worst-case complexity at the decoder side. In addition, the number of parameter candidates could be specified at the encoder side. For the all-intra configuration, the parameter selection is disabled while filter on/off control is still preserved, since there is no content propagation issue in this configuration.

For further improving the adaptation capability, granularity (block size) of the on/off control and the parameter selection is made dependent on resolution and bitrate. For a higher resolution, the granularity will be coarser as content tends to change slower, and vice versa. For a higher bitrate, the granularity will be finer since more overhead bits can be afforded, and vice versa.

### _Residual Scaling_

As pointed out in Section III-B, varying the filtering strength according to picture content may alleviate the over-filtering issue. Residual scaling is another mechanism (besides parameter selection) to achieve the purpose of filtering strength adjustment, and can be formulated as,

\[\mathbf{R}_{nn}=\omega\cdot(\mathbf{R}_{nn}-\mathbf{R}_{db})+\mathbf{R}_{db} \tag{3}\]

where \(\mathbf{R}_{db}\) is the deblocking filtered samples, \(\omega\) is the scaling factor derived based on least square method. (3) indicates that the residual between deblocking filtered samples and NN filtered samples can be scaled by a scaling factor and then added back to the deblocking filtered samples. For each color component, a scaling factor is signaled. It is worth noting that (3) can be written as,

\[\mathbf{R}_{nn}=\omega\cdot\mathbf{R}_{nn}+(1-\omega)\cdot\mathbf{R}_{db} \tag{4}\]

(4) implies a convex combination of NN filtering and deblocking filtering. It is asserted that using \(\mathbf{R}_{db}\) instead of \(\mathbf{R}_{no}\) in (4) benefits perceptual quality [51]. The reason is that the NN filter has the effect of removing deblocking artifacts, but if turned off in (4) (i.e., \(\omega=0\)), the result would be an output without any deblocking, given \(\mathbf{R}_{db}\) was replaced by \(\mathbf{R}_{no}\). In contrast, (4) guarantees that the output will be deblocked one way or the other, either through the NN filter or through the regular deblocking filter.

### _Temporal Filtering_

In video coding, neighboring reconstructed pictures might have a higher quality than the current picture since quality fluctuation usually exists across compressed pictures. This has motivated work on multi-frame quality enhancement [52], which take advantage of adjacent pictures with higher quality to enhance the current picture.

Since the hierarchical coding structure under the random-access configuration naturally leads to previously coded pictures of higher quality, the temporal information from the reference picture can be exploited for the in-loop filtering of current picture. Specifically, NNVC includes an additional in-loop filter as shown in Fig. 6, namely temporal filter, taking collocated blocks from the first picture in both reference picture lists to improve performance. Note that, to avoid complexity, the two collocated blocks are directly concatenated and fed into the temporal filter without any explicit temporal alignment operations. In addition, this temporal filter is only activated for pictures in the three highest temporal layers, because in low temporal layers, the temporal correlation between collocated blocks and the current block is weak and thus limits the performance.

### _Encoder Optimization with NN Filter_

Rate-distortion optimization (RDO) of the partitioning tree structure plays a vital role to to increase coding efficiency,

Fig. 6: Temporal in-loop filter. Only feature extraction part is illustrated, other parts remain the same as in Fig. 5. {Col_0, Col_1} refers to collocated samples from the first picture in both reference picture lists.
both for traditional codecs such as VVC as well as for NNVC. However, in NNVC, there exists a gap between the reconstruction samples used for distortion calculation during the RDO and the ultimate reconstruction samples, since the latter are eventually filtered using the NN model. To bridge this gap, a NN filter is inserted into the RDO process for partitioning mode selection.

Specifically, a NN filter is applied on the reconstruction samples before comparing them with the original samples to calculate the distortion. The optimal partitioning mode is then selected based on the refined RD cost. To reduce complexity, several fast algorithms are introduced. First, instead of using the full NN in-loop filter, an aggressively simplified version of the NN filter is used. Second, the parameter selection is omitted. Third, coding unit allowing using this technique should have a size no larger than 64. At last, the refined cost will be used only if the difference to the original R-D costs lies in a predefined range.

### _Training Details_

An iteratively conducted two-stage method is adopted to train the NN-based in-loop filters as shown in Fig. 7. The iterative training explicitly takes the filtering effect on reference frames into account during training process, in order to ease the over-filtering issue described in Section III-B.

* In the first stage, NNVC with NN filtering disabled (equivalent to the VTM anchor) is used to compress training images and videos under all-intra and random-access configurations. The reconstructed images and videos together with other auxiliary information are collected and utilized for training intra and inter filters.
* In the second stage, NNVC equipped with the models from the previous training stage is used to compress the training videos in the random-access setting. That is to say, intra pictures and inter pictures will be processed by the intra filters and inter filters obtained in training stage 1, respectively. Then, the intra training data from stage 1 and inter training data from stage 2 are combined to train the unified intra and inter models (one model for both intra luma and inter luma, one model for both intra chroma and inter chroma).

Note that the temporal filter can be trained using a similar strategy. Training images and videos are from the DIV2K dataset [53] and the BVI-DVC dataset [54]. PyTorch [55] serves as the training platform. More details regarding training can be found in the NNVC training folder2.

Footnote 2: [https://vcgit.hbi.fraunhofer.de/jvet-ahg-mvc/VVCSoftware_VTM/-/tree/VTM-1.0_mvc/training](https://vcgit.hbi.fraunhofer.de/jvet-ahg-mvc/VVCSoftware_VTM/-/tree/VTM-1.0_mvc/training)

### _Inference Details_

SADL (see Section IV) is used for the inference of the NN-based in-loop filters. Both floating point-based and fixed point-based implementations are supported, however a real codec would need to use fixed-point arithmetics to avoid drift. In the fixed-point implementation, both weights and feature maps are represented with int16 precision using a static quantization method. In total, there are three filter models, i.e luma filter, chroma filter, and temporal filter. Other details regarding the inference is provided in Table III.

Fig. 8 depicts how to harmonize the NN-based filter with existing loop filters in VVC [56]. Deblocking and NN filtering are performed in parallel and then convexly combined via (4). SAO is disabled as no additional benefits are observed on top, while ALF and CCALF are placed after the CNN-based filtering to reduce overhead. As analyzed in Section III-D, temporal NN filter is proposed for pictures at high temporal layers (\(Tid\geq 3\)) while regular NN filter handles the others.

## IV Small Ad-hoc Deep-Learning Library

### _Overview_

Small Ad-hoc Deep-Learning library (SADL) is a header-only small library for neural network inference available at [57]. SADL provides both floating-point-based and integer-based inference capabilities. The inference of all neural networks in NNVC is based on the SADL. Table IV summarizes the framework characteristics.

### _Integerized Model_

In video compression area, the fixed point implementation is crucial to allow reproducibility of the decoding, independently of the platform or environment. The SADL framework provides both floating point and fixed point implementation for all layers.

To lower the complexity of integer arithmetic of quantized model, the quantization operations required for computational layers are minimized and performed using only bit-shifting, without zero-point shifting, compared to existing method in Tensorflow [58] or PyTorch.
Both weights and latents tensors use the internal integer representation, e.g. int16. For intermediate computation, the integer with twice the number of bits is used. For example, for int16 format, int32 is used for computation. Compared to the float version, the operation are adapted as

* BiasAdd: \(y=C\left(\left(x_{0}\gg\left(q_{0}-q_{1}\right)\right)+x_{1}\right),q=q_{1}\)
* Add: \(y=C\left(\left(x_{0}\gg\left(q_{0}-q\right)\right)+\left(x_{1}\gg\left(q_{1}-q \right)\right)\right),q=\min\left(q_{0},q_{1}\right)\)
* Mul/MatMul/Conv2D: \(y=C(\sum x_{0}x_{1}\gg\left(q_{1}+q_{i}\right)),q=q_{0}-q_{i}\)
* Concat: \(y=x_{0}\gg\left(q_{0}-q\right)\mid x_{1}\gg\left(q_{1}-q\right)\mid...,q=\min( q_{k})\)
* LeakyReLU: si \(x<0,y=\left(\alpha x_{0}\right)\gg q_{\alpha}\), assuming \(\left|\alpha\right|<1\) (no overflow possible), \(q=q_{0}\). The quantizer \(q_{\alpha}\) of the slope \(\alpha\) of LeakyReLU always takes the maximum possible value to represent \(\alpha\) without overflow.
* Maximum: \(y=\max(x_{0},x_{1}\ll\left(q_{0}-q_{1}\right)),q=q_{0}\)
* for layer with only one input, the output will take the quantizer of this input.

Where:

* \(C(.)\) represents the clipping operation associated with the internal bitdepth of the latent. For example for int16 integer \(C\left(x\right)=\max\left(-2^{15}+1,\min\left(2^{15}-1,x\right)\right)\)
* \(x_{0}\), \(x_{1}\): inputs
* \(y\): output
* \(q_{0}\) and \(q_{1}\): shift of the quantizers. The floating value associated to a quantized input \(x\) of quantizer \(q\) can be recovered via \(f\left(x,q\right)=x/\left(1\ll q\right)\)
* \(q_{i}\): internal shift for some layers.

Conversion from trained models using floating point to integerized model can be done either using static quantization where optimal quantizers for each layer is chosen and floating point weights are converted to fixed points, or a quantization aware model training is performed. Fig. 9 shows an example of adaptation of the convolution layer: quantization/clipping/dequantization stages are added for both the weights and the output of the layer.

### _Sparse Matrix Multiplication_

In order to lower the complexity of the dense layer, counted in MAC (Multiply-Accumulate), a sparse matrix representation associated with a sparse matrix/vector is available. The sparse matrix uses a variant of the CSR (Compressed Sparse Row) representation [59], where run-length of non-zero values is aligned on the required SIMD alignment for efficient multiply-and-add implementation on CPU: all run-length are constrained to be of a lenght modulo of 8 or 16, then each runlength is indexed in a vector and mutliply by the corresponding values of the input vector.

For example, the NN-based intra prediction model II-B using the sparse dense layer allows to decrease the complexity as depicted in Table V.

### _Other Implementability Aspects_

In order to evaluate and compare solutions explored in JVET, complexity measurement of a model is also provided in the library. It allows to extract the real number of MACs and

Fig. 8: Embedding of CNN-based in-loop filter into codec.

Fig. 7: Iterative training of CNN-based in-loop filter with two stages.

Fig. 9: Quantization aware convolution layer using fixed point operations.
other operations during the inference of a particular model, independently of an underlying implementation.

A requirement of JVET evaluation is also to compare practical implementation using a reproducible environment in order to compare explored solutions to a given anchor. For these reasons, pure CPU (as opposed to GPU based) and single-threaded implementation is provided by the framework.

## V Experimental Results

This section verifies performances of the proposed techniques in NNVC using NNVC-4.03, the reference software of NNVC. Techniques are tested under all-intra, random-access, and low-delay configurations using QP [22, 27, 32, 37, 42] suggested by NNVC common test conditions (CTC) [60]. BD-rate [61] is adopted to measure the compression efficiency, where the quality metric bases on PSNR. Test sequences are known as classes A1, A2, B, C, D, E, F [60].

Footnote 3: [https://vcgit.hhi.fraunhofer.de/jvet-abg-nmvcVVCSoftware_VTM/](https://vcgit.hhi.fraunhofer.de/jvet-abg-nmvcVVCSoftware_VTM/)

### _Overall Results_

Table VI gives overall performances of the proposed techniques in NNVC-4.0 over VTM-11.0_nnvc. Following JVET common test conditions [62], we exclude classes D and F when computing the overall average. As can be observed, NNVC-4.0 with the proposed techniques outperforms VTM-11.0_nnvc significantly, achieving on average {11.94%, 21.86%, 22.59%}, {9.18%, 19.76%, 20.92%}, and {10.63%, 21.56%, 23.02%} BD-rate reductions for {Y, Cb, Cr}, under random-access, low-delay, and all-intra configurations, respectively. The proposed NN models are tuned on natural contents, therefore gains are limited on Class F containing screen content sequences.

Fig. 10 shows R-D curves for sequences from different classes. Trends can be observed that NNVC-4.0 offers relatively higher coding gains at middle bit-rates. The phenomenon may be related to the distortion characteristics at different bit-rates. The low bit-rate tends to yield larger distortion, making it more difficult to infer the lost details from existing contexts while the high bit-rate usually means low distortion level, leaving limited space for further reduction.

Currently, the implementation of the NN-based models is not fully optimized and is CPU-based, thus the encoding/decoding time of NNVC-4.0 is much longer than that of the highly optimized VVC reference software. Table VII presents the computational time comparison. Encoding complexities are 2.1, 2.2, and 2.5 times for random-access, low-delay, and all-intra cases, respectively. Regarding decoding complexities, they are 324.9, 307.4, and 196.5 times for random-access, low-delay, and all-intra cases, respectively. Note that in real applications, inference of NN-based models could be accelerated significantly with more efficient architectures such as GPUs (graphics processing units), TPUs (tensor processing units, a kind of application-specific integrated circuits) or full custom ASIC silicon. Besides running time, number of total parameters and multiply-accumulates (MACs) are important measurements concerning complexity considered in NNVC. Details regarding these measurements could be found in Table II and Table III.

### _Ablation Test_

Table VIII gives performances of NNVC-4.0 configured in different modes. BD-rate changes are shown for luma component in all-intra and random-access settings. NN tools enabled in each mode are explained below,

* \(M_{1}\), NN-based intra prediction.
* \(M_{2}\), basic NN-based in loop filter, i.e. without temporal filtering (Section III-D) and encoder optimization (Section III-E).
* \(M_{3}\), NN-based intra prediction, basic NN-based in loop filter.
* \(M_{4}\), NN-based intra prediction, basic NN-based in loop filter, temporal filtering (Section III-D).
* \(M_{5}\), NN-based intra prediction, basic NN-based in loop filter, temporal filtering, encoder optimization (Section III-E).

Compared with VTM-11.0_nnvc, NN-based intra prediction and basic in-loop filter provide on average {1.81%, 3.61%} and {9.60%, 7.39%} BD-rate reductions for the luma component under random-access and all-intra settings respectively (as observed from columns \(M_{1}\) and \(M_{2}\)). By combing the two tools, BD-rate reductions rise to {11.02%, 10.40%} for random-access and all-intra settings as shown in column \(M_{3}\). Comparison of columns \(M_{1}\), \(M_{2}\), and \(M_{3}\) suggests gains of NN-based intra prediction and in-loop filtering are almost additive, yet the tools are trained and optimized separately. Results in columns \(M_{4}\) and \(M_{5}\) can reflect additional improvements due to temporal filtering and encoder optimization techniques, i.e. an approximate BD-rate reduction of 0.6% from temporal filter and 0.3% from encoder optimization in the random-access setting.

## VI Conclusion

Joint Video Experts Team of ITU-T SG 16 WP 3 and ISO/IEC JTC 1/SC29 is working together on an exploration study to evaluate potential NNVC technology beyond the capabilities of VVC. The exploration activity has identified two promising NN-based coding tools as an enhancement of existing intra prediction and in-loop filtering techniques in VVC design. This paper introduced technical features, encoding methods, and training methods of some of these tools. Implementation of these tools in NNVC reference software is based on SADL. Effectivenesses of the NNVC techniques have been verified by the experimental results about NNVC-4.0, i.e. {11.94%, 21.86%, 22.59%}, {9.18%, 19.76%, 20.92%}, and {10.63%, 21.56%, 23.02%} BD-rate reductions on average for {Y, Cb, Cr} compared with VVC under random-access, low-delay, and all-intra settings respectively. Future works on complexity reduction and other competitive NN tools are encouraged.
