summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2f8f882)
This was all broken after
adc0df0, it seems. It not only assumed 4:2:2,
but had broken chroma pitch, too.
unsigned chroma_width_blocks = mcu_width_blocks * dinfo.comp_info[1].h_samp_factor;
PBO pbo = global_pbo_pool->alloc_pbo();
unsigned chroma_width_blocks = mcu_width_blocks * dinfo.comp_info[1].h_samp_factor;
PBO pbo = global_pbo_pool->alloc_pbo();
+ const size_t chroma_width = dinfo.image_width / frame->chroma_subsampling_x;
+ const size_t chroma_height = dinfo.image_height / frame->chroma_subsampling_y;
size_t cb_offset = dinfo.image_width * dinfo.image_height;
size_t cb_offset = dinfo.image_width * dinfo.image_height;
- size_t cr_offset = cb_offset + (dinfo.image_width / 2) * dinfo.image_height;
+ size_t cr_offset = cb_offset + chroma_width * chroma_height;
uint8_t *y_pix = pbo.ptr;
uint8_t *cb_pix = pbo.ptr + cb_offset;
uint8_t *cr_pix = pbo.ptr + cr_offset;
unsigned pitch_y = luma_width_blocks * DCTSIZE;
uint8_t *y_pix = pbo.ptr;
uint8_t *cb_pix = pbo.ptr + cb_offset;
uint8_t *cr_pix = pbo.ptr + cr_offset;
unsigned pitch_y = luma_width_blocks * DCTSIZE;
- unsigned pitch_chroma = chroma_width_blocks * DCTSIZE * 2;
+ unsigned pitch_chroma = chroma_width_blocks * DCTSIZE;
if (dinfo.marker_list != nullptr &&
dinfo.marker_list->marker == JPEG_APP0 + 1 &&
if (dinfo.marker_list != nullptr &&
dinfo.marker_list->marker == JPEG_APP0 + 1 &&
// FIXME: what about resolutions that are not divisible by the block factor?
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo.pbo);
frame->y = create_texture_2d(frame->width, frame->height, GL_R8, GL_RED, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
// FIXME: what about resolutions that are not divisible by the block factor?
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo.pbo);
frame->y = create_texture_2d(frame->width, frame->height, GL_R8, GL_RED, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
- frame->cb = create_texture_2d(frame->width / 2, frame->height, GL_R8, GL_RED, GL_UNSIGNED_BYTE, BUFFER_OFFSET(cb_offset));
- frame->cr = create_texture_2d(frame->width / 2, frame->height, GL_R8, GL_RED, GL_UNSIGNED_BYTE, BUFFER_OFFSET(cr_offset));
+ frame->cb = create_texture_2d(chroma_width, chroma_height, GL_R8, GL_RED, GL_UNSIGNED_BYTE, BUFFER_OFFSET(cb_offset));
+ frame->cr = create_texture_2d(chroma_width, chroma_height, GL_R8, GL_RED, GL_UNSIGNED_BYTE, BUFFER_OFFSET(cr_offset));
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
- glFlushMappedNamedBufferRange(pbo.pbo, 0, dinfo.image_width * dinfo.image_height * 2);
+ glFlushMappedNamedBufferRange(pbo.pbo, 0, dinfo.image_width * dinfo.image_height + chroma_width * chroma_height * 2);
glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT);
pbo.upload_done = RefCountedGLsync(GL_SYNC_GPU_COMMANDS_COMPLETE, /*flags=*/0);
frame->uploaded_ui_thread = pbo.upload_done;
glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT);
pbo.upload_done = RefCountedGLsync(GL_SYNC_GPU_COMMANDS_COMPLETE, /*flags=*/0);
frame->uploaded_ui_thread = pbo.upload_done;