# Region-of-Interest Based Coding Scheme for Live Videos
## 3 Proposed Approach
### Region \(\lambda\) Infer  
Before implementing ROI-based rate control, we establish a dedicated ROI rate reservoir \(R\), which serves to track the bitrate consumption in both the ROI and ROU regions. As depicted in Figure 1, this ROI reservoir operates independently of the reservoir used by the original codec's rate control mechanism. In our algorithm, as more bits are allocated to the ROI area, causing an increase in bit rate \(\Delta R_{i}\), the water level in the ROI reservoir rises correspondingly. Conversely, when fewer bits (\(-\Delta R_{u}\)) are consumed in the ROU region, the water level in the ROI reservoir decreases. The video encoding process commences with the first step of utilizing mm-detection for object detection to identify and gather information on the ROI regions. The second step involves allocating GOP bits according to conventional rate control methods, ensuring consistency with prior processes. The third stage entails acquiring encoded QP and RDO information for each frame and using the subsequent model to calculate the rate control parameters for both ROI and ROU regions. The initial \(\lambda_{cu}\) values for each block within a frame can be derived from the r-\(\lambda\) rate control framework outlined above. However, to refine the rate allocation specifically for ROI and ROU, we need to adjust these base values and derive the final adjustment parameters \(\lambda_{roi}\) and \(\lambda_{rou}\) for the respective regions. This tailored approach ensures that the bitrate is optimally distributed between areas of interest and non-interest, enhancing overall perceptual quality while maintaining bitrate stability. When the reservoir has not yet reached its overflow threshold \(R_{over}\), adjustments to \(\lambda_{rou}\) alone are sufficient to ensure that the overall bitrate growth remains within an acceptable limit. When the reservoir's water level is low, the increment of \(\lambda_{rou}\) should be appropriately reduced to guarantee a steady bitrate consumption from the reservoir; conversely, when the water level rises high, the increment in \(\lambda_{rou}\) should increase proportionally to accelerate the continuous outflow of the coding rate from the reservoir. If the reservoir surpasses the overflow value \(R_{over}\), the adjustment to \(\lambda_{roi}\) should decrease,  
Figure 1: ROI Reservoir Model. thereby reducing the inflow of code rate into the reservoir and helping it maintain a level below the overflow threshold. The intensity of lambda adjustment for ROI (\(\lambda_{roi}\)) and ROU (\(\lambda_{rou}\)) is contingent upon the state of the ROI reservoir. A smaller \(\lambda\) value indicates a higher likelihood of dividing the CU into smaller blocks, which, in turn, leads to a smaller calculated quantization parameter and thus increased bitrate consumption in the corresponding region. The target quality enhancement factor for ROI is denoted as \(K_{roi}\), which is user-defined. For a given frame, the coding complexity of the ROI area is represented by \(C_{roi}\), computed as the sum of absolute transform coefficients (SATD) following motion compensation during the lookahead process. We conduct downsampling filtering on the current frame's image, resulting in a reduced-resolution image at half the original dimensions. Upon this lower-resolution image, we execute predictions with half-pixel accuracy and subsequently subtract the outcome from the original full-resolution image to yield the residual signal. Thereafter, we subject residual to the Hadamard transformation and compute the aggregate sum of absolute values, thereby obtaining the SATD. The sum of SATDs for all pixels within the ROI and the ROU region is \(C_{roi}\) and \(C_{rou}\), respectively. \[C_{roi}=\sum SATD_{roi} \tag{3}\]  
\[C_{rou}=\sum SATD_{rou} \tag{4}\]  
The size of the ROI is measured by the number of pixels in the region, \(P_{roi}\). Correspondingly, the coding complexity of the ROU is \(C_{rou}\), and its size is represented by \(P_{rou}\).