mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-07-18 17:52:00 +00:00
cpu encoder: fix chroma row advance timing in YUV420/YVU420 planar path
_jpeg_write_scanlines_yuv_planar() advanced chroma1_data/chroma2_data after building the current luma row instead of before, so every even luma row (>=2) read the previous chroma-row-pair's samples instead of its own. Move the existing advance check to the top of the loop body, before the row is built, so it takes effect before the chroma pointers are read for that row. Condition and stride math are unchanged.
This commit is contained in:
@@ -223,6 +223,11 @@ static void _jpeg_write_scanlines_yuv_planar(struct jpeg_compress_struct *jpeg,
|
||||
const u8 *chroma2_data = frame->data + luma_array_size + chroma_array_size;
|
||||
|
||||
while (jpeg->next_scanline < frame->height) {
|
||||
if (jpeg->next_scanline > 0 && jpeg->next_scanline % 2 == 0) {
|
||||
chroma1_data += (frame->width + padding) >> 1;
|
||||
chroma2_data += (frame->width + padding) >> 1;
|
||||
}
|
||||
|
||||
u8 *ptr = line_buf;
|
||||
|
||||
for (uint x = 0; x < frame->width; ++x) {
|
||||
@@ -253,11 +258,6 @@ static void _jpeg_write_scanlines_yuv_planar(struct jpeg_compress_struct *jpeg,
|
||||
|
||||
data += frame->width + padding;
|
||||
|
||||
if (jpeg->next_scanline > 0 && jpeg->next_scanline % 2 == 0) {
|
||||
chroma1_data += (frame->width + padding) >> 1;
|
||||
chroma2_data += (frame->width + padding) >> 1;
|
||||
}
|
||||
|
||||
JSAMPROW scanlines[1] = {line_buf};
|
||||
jpeg_write_scanlines(jpeg, scanlines, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user