## 3 Materials and Methods
### Proposed Forward Error Correction Framework  
Forward error correction is an error correcting technique in which the data are recovered from errors that occur during transmission. Unlike ARQ (automatic repeat request), when an error is detected, FEC restores the data that are affected by the channel errors without requesting retransmission from the sender. In FEC, redundant bits are added to the original bitstream by the FEC encoder. The decoder uses these redundant or additional bits to guess the original data in case the original bits are corrupted or lost during transmission. We inserted errors into YUV video sequences by implementing the GE channel error model with the help of the H.264/AVC CABAC entropy coder to test the working of our proposed FEC method, which can detect up to one error in each macroblock of the video frame. Each macroblock is a 16 \(\times\) 16 array of pixels. The proposed framework involves the following steps implemented, as shown in Algorithm 1, using the H.264/AVC CABAC entropy encoder to encrypt and then correctly guess and correct the errors that occurred due to a noisy channel to provide recovered data to the receiver. The H.264/AVC CABAC entropy coder was used via the JSVM software tool, developed by the Joint Video Team (JVT) of ITU-T and ISO/IEC, with contributions from Fraunhofer HHI, Berlin, Germany. ```
**Algorithm 1** Overall steps involved in proposed FEC algorithm

The encrypted bitstream of video data is encoded through our FEC algorithm at the sending device, which is then sent to the destination device through the noisy transmission channel simulated by the GE model. The generating function of the FEC encoder divides the encrypted bitstream into \(d\)-bit data blocks, called datawords, and adds \(r=c-d\) parity bits to generate \(c\)-bits codewords, where \(r\), \(c\), and \(d\) represent parity bits, codewords, and datawords, respectively. The crypto-encoded bitstreams of the codewords are transmitted over the noisy channel, which is employed using the Gilbert-Elliott model. The checking function of the FEC decoder identifies the valid codewords after receiving the erroneous data at the receiving end. If the codeword is valid, its corresponding dataword is extracted. If the codeword is invalid, the algorithm tries to identify the location of the error by adding the position of the incorrect parity bit and flips the bit at that position. After correcting the possible error, the dataword is extracted from the codeword. Ciphered MVD and TC is XORed using the symmetric key for decryption with the decoder. Decrypted blocks are then combined to regenerate the original blocks of the videos. The pseudocode of the _generating function_ performed at the sending end consists of the following steps listed in Algorithm 2. ```  
INPUT: Video Frames  
OUTPUT: H.264 encoded bitstream  
```
1: Split the video bit stream into blocks of size \(d\)
2:for each block:
3: Generate codewords using bitstream, data block size d, and codeword length \(c\)
4: Calculate number if parity bits by \(r=c-d\)
5:for\(x=0\) to \(r-1\)
6: Insert parity bit \(r_{x}\) at \(2^{x}\) position checks each alternate data bit and skips \(x\) data bit in the block to maintain even parity
7:endfor
8:endfor
```  
**Algorithm 2** Pseudocode of _generating function_ of proposed FEC performed at sender  
Algorithm 3 lists the steps performed at the receiving end by the _checking function_ implemented by the decoder for error detection and correction. The proposed methodology for the enhancement of video quality using H.264/AVC syntax-based selective encryption and the FEC mechanism is shown in Figure 5.  
The state-of-the-art error correction techniques, including machine learning and deep learning approaches, offer high performance potential but exhibit higher computational overhead and require large training and validation sets.