harbor run -t openthoughts/tasktrove-mix-h2-language-proportional-mix-h2-lang-proportional-3203harbor download openthoughts/tasktrove-mix-h2-language-proportional-mix-h2-lang-proportional-3203You are required to implement the image scaling functionalities for the LibYuv project, which includes supporting both 8-bit and 16-bit image formats as well as various filtering modes. The code needs to be placed in the /app/ directory. Below are the specific requirements to fulfill this task:
I420Scale Functionality: Implement the I420Scale function that takes source image buffers in I420 format (Y, U, V planes) and scales them to a specified width and height using a given filter mode. The scaling should support the following filter modes:
I420Scale_16 Functionality: Implement a similar I420Scale_16 function that supports 16-bit depth images, using the same parameters and filtering modes as I420Scale.
Function Signatures:
void I420Scale(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
int src_width, int src_height,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int dst_width, int dst_height,
FilterMode filter);
void I420Scale_16(const uint16* src_y, int src_stride_y,
const uint16* src_u, int src_stride_u,
const uint16* src_v, int src_stride_v,
int src_width, int src_height,
uint16* dst_y, int dst_stride_y,
uint16* dst_u, int dst_stride_u,
uint16* dst_v, int dst_stride_v,
int dst_width, int dst_height,
FilterMode filter);
Functionality Detail:
I420Scale function should accurately scale the image from source dimensions (src_width, src_height) to target dimensions (dst_width, dst_height), applying the specified filter.I420Scale_16 function must perform similar functionality but for 16-bit pixel values. Ensure the output matches the expected results according to the tests.Error Handling: Validate inputs (e.g., ensure width and height are positive) and handle any potential errors appropriately.
Testing: The implementations should pass comprehensive tests already provided in the test code. Ensure that the maximum pixel difference allowed for the different filters meets the requirements stated (typically, no difference for "None" filter and limited differences for others).
Resource Management: Use the existing allocation functions and alignments as indicated in the test code to manage input and output buffers efficiently.
Complete your implementation in /app/, ensuring compliance with the above specifications and that your code integrates seamlessly with the existing testing framework.