Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Nov 5, 2023
1 parent 2fc079b commit 450d311
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions highgui/src/jpeg_encoder_rk_mpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,33 @@ int jpeg_encoder_rk_mpp_impl::encode(const unsigned char* bgrdata, const char* o
{
void* mapped_ptr = mpp_buffer_get_ptr(buffer);

for (int i = 0; i < height; i++)
if (format == MPP_FMT_YUV420SP)
{
my_memcpy((unsigned char*)mapped_ptr + i * hor_stride, bgrdata + i * width * 3, width * 3);
for (int i = 0; i < height; i++)
{
my_memcpy((unsigned char*)mapped_ptr + i * hor_stride, bgrdata + i * width, width);
}
for (int i = 0; i < height; i++)
{
my_memset((unsigned char*)mapped_ptr + height * hor_stride, 128, height * hor_stride / 2);
}
}
if (format == MPP_FMT_BGR888)
{
if (ch == 3)
{
for (int i = 0; i < height; i++)
{
my_memcpy((unsigned char*)mapped_ptr + i * hor_stride, bgrdata + i * width * 3, width * 3);
}
}
if (ch == 4)
{
for (int i = 0; i < height; i++)
{
my_memcpy_drop_alpha((unsigned char*)mapped_ptr + i * hor_stride, bgrdata + i * width * 4, width);
}
}
}
}

Expand Down

0 comments on commit 450d311

Please sign in to comment.