Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mdevaev committed Oct 12, 2023
1 parent 55e432a commit 05e5db0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ustreamer/encoders/cpu/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


#include "encoder.h"
#include <stdint.h>


typedef struct {
Expand Down Expand Up @@ -65,7 +64,7 @@ void us_cpu_encoder_compress(const us_frame_s *src, us_frame_s *dest, unsigned q
jpeg.image_width = src->width;
jpeg.image_height = src->height;
jpeg.input_components = 3;
jpeg.in_color_space = (src->format == V4L2_PIX_FMT_YUYV || src->format == V4L2_PIX_FMT_UYVY)? JCS_YCbCr: JCS_RGB;
jpeg.in_color_space = ((src->format == V4L2_PIX_FMT_YUYV || src->format == V4L2_PIX_FMT_UYVY) ? JCS_YCbCr : JCS_RGB);

jpeg_set_defaults(&jpeg);
jpeg_set_quality(&jpeg, quality, TRUE);
Expand Down Expand Up @@ -120,9 +119,9 @@ static void _jpeg_write_scanlines_yuyv(struct jpeg_compress_struct *jpeg, const
uint8_t *ptr = line_buf;

for (unsigned x = 0; x < frame->width; ++x) {
// see also: https://www.kernel.org/doc/html/v4.8/media/uapi/v4l/pixfmt-yuyv.html
// See also: https://www.kernel.org/doc/html/v4.8/media/uapi/v4l/pixfmt-yuyv.html
const bool is_odd_pixel = x & 1;
const uint8_t y = data[is_odd_pixel ? 2: 0];
const uint8_t y = data[is_odd_pixel ? 2 : 0];
const uint8_t u = data[1];
const uint8_t v = data[3];

Expand All @@ -131,7 +130,7 @@ static void _jpeg_write_scanlines_yuyv(struct jpeg_compress_struct *jpeg, const
ptr[2] = v;
ptr += 3;

data += is_odd_pixel? 4: 0;
data += (is_odd_pixel ? 4: 0);
}
data += padding;

Expand All @@ -153,9 +152,9 @@ static void _jpeg_write_scanlines_uyvy(struct jpeg_compress_struct *jpeg, const
uint8_t *ptr = line_buf;

for (unsigned x = 0; x < frame->width; ++x) {
// see also: https://www.kernel.org/doc/html/v4.8/media/uapi/v4l/pixfmt-uyvy.html
// See also: https://www.kernel.org/doc/html/v4.8/media/uapi/v4l/pixfmt-uyvy.html
const bool is_odd_pixel = x & 1;
const uint8_t y = data[is_odd_pixel ? 3: 1];
const uint8_t y = data[is_odd_pixel ? 3 : 1];
const uint8_t u = data[0];
const uint8_t v = data[2];

Expand All @@ -164,7 +163,7 @@ static void _jpeg_write_scanlines_uyvy(struct jpeg_compress_struct *jpeg, const
ptr[2] = v;
ptr += 3;

data += is_odd_pixel? 4: 0;
data += (is_odd_pixel ? 4 : 0);
}
data += padding;

Expand Down

0 comments on commit 05e5db0

Please sign in to comment.