# Adaptive Rate-Compatible Non-Binary LDPC Coding Scheme for the B5G Mobile System
## 3 Channel Clustering Based on the K-Means++ Algorithm
### Complexity Optimization of the End-to-End Distortion Model Based on the Clustering Algorithm  
Traditional rate allocation schemes often need to traverse all combinations of coding parameters to achieve adaptive-rate allocation by iterating all combinations. In this paper, the clustering algorithm is introduced to quickly cluster the channel environment to obtain the channel-coding scheme, so as to achieve the goal of adaptive-rate allocation. Compared with the traditional scheme, the proposed method can effectively reduce the computational complexity. The joint source channel-coding design based on rate allocation is to obtain the optimal video reconstruction quality through bit allocation between the channel and the source in the case of limited bandwidth and channel interference. A block diagram of the bit allocation strategy for joint source channel coding is shown in Figure 11.  
In the joint source channel-coding system, end-to-end distortion is one of the important means to measure the quality of the system. The performance of the transmission system is measured by calculating the mean square error between the reconstructed video image and the original video image at the encoder end. The end-to-end distortion model is derived below. First, define the pixel in the \(n^{th}\) frame as \(i\), and the pixel of the reference frame \(ref\) is \(j\). Let \(f_{n}^{i}\) be the original value of the pixel, let \(\widehat{f}_{n}^{i}\) and \(\widehat{f}_{n}^{i}\) be the reconstructed values of the encoder and decoder, respectively, and let \(\hat{r}_{n}^{i}\) be the reconstructed residual of the encoder, i.e., \(\widehat{f}_{n}^{i}=\widehat{f}_{ref}^{i}+\hat{r}_{n}^{i}\). If the current pixel is lost at the decoder side, it will copy the pixels of the \((n-1)^{th}\) frame. Assuming that the transmission error rate is \(p\), the pixel value of the reconstructed image can be expressed by:  
\[\widehat{f}_{n}^{i}=\left\{ \begin{array}{ll}\widehat{f}_{ref}^{i}+\hat{r}_{ n}^{i}&1-p\\ \widehat{f}_{n-1}^{k}&p\end{array} \right. \tag{7}\]  
Therefore, the estimated end-to-end distortion of the decoder can be expressed as:  
\[ \begin{array}{ll}d(n,i)&=E\bigg{\{}\left(f_{n}^{i}-\widehat{f}_{n}^{i} \right)^{2}\bigg{\}}\\ &=(1-p)E\bigg{\{}\left(f_{n}^{i}-\left(\widehat{f}_{ref}^{i}+\hat{r}_{n}^{i} \right)\right)^{2}\bigg{\}}+pE\bigg{\{}\left(f_{n}^{i}-\widehat{f}_{n-1}^{k} \right)^{2}\bigg{\}}\\ &=(1-p)E\bigg{\{}\left(f_{n}^{i}-\hat{r}_{n}^{i}\right)^{2}\bigg{\}}+(1-p)E \bigg{\{}\left(\widehat{f}_{ref}^{i}-\widehat{f}_{ref}^{i}\right)^{2}\bigg{\}} +pE\bigg{\{}\left(f_{n}^{i}-\widehat{f}_{n-1}^{k}\right)^{2}\bigg{\}}\\ &=(1-p)d_{s}(n,i)+(1-p)d_{ep}(ref,j)+pd_{ce}(n,i)\end{array}  \tag{8}\]  
It can be seen that the end-to-end distortion can be represented by the sum of the three items \(d_{s}(n,i)\), \(d_{ep}(ref,j)\) and \(d_{ce}(n,i)\), where \(d_{s}(n,i)\) represents source distortion, \(d_{ep}(ref,j)\) represents error propagation distortion from the reference frame, and \(d_{ce}(n,i)\) represents error concealment distortion. Error propagation distortion refers to the use of predictive coding in HEVC coding. If an error occurs in a reference frame or a referenced module, the distortion is propagated to the corresponding frame or pixel with reference to it. Error concealment refers to the distortion caused by the recovery of errors or lost modules generated by transmissions in the channel using temporal or spatial correlation. Usually, in the time domain, the motion-compensated content of the previous frame is used to replace the lost portion of the current frame, and the spatial correlation is used to recover the lost portion in the spatial domain. Since \(d_{s}(n,i)\) can be obtained by source-encoded parameters at the encoder side, end-to-end distortion mainly depends on the calculation of \(d_{ep}(ref,j)\) and \(d_{ce}(n,i)\). The result shown in Equation (9) can be obtained by calculating \(d_{ce}(n,i)\):  
Figure 11: The bit allocation strategy for joint source channel coding. \[