diff --git a/apps/plugins/jpeg/jpeg.c b/apps/plugins/jpeg/jpeg.c index 5f9999a..945e2d2 100644 --- a/apps/plugins/jpeg/jpeg.c +++ b/apps/plugins/jpeg/jpeg.c @@ -935,6 +935,7 @@ int load_and_show(char* filename) struct t_disp* p_disp; /* currenly displayed image */ int cx, cy; /* view center */ +DEBUGF("read jpeg file %s\n",filename); fd = rb->open(filename, O_RDONLY); if (fd < 0) { diff --git a/apps/plugins/jpeg/jpeg_decoder.c b/apps/plugins/jpeg/jpeg_decoder.c index 71d5088..bc27227 100644 --- a/apps/plugins/jpeg/jpeg_decoder.c +++ b/apps/plugins/jpeg/jpeg_decoder.c @@ -560,7 +560,17 @@ int process_markers(unsigned char* p_src, long size, struct jpeg* p_jpeg) if (p_jpeg->frameheader[i].horizontal_sampling > 2 || p_jpeg->frameheader[i].vertical_sampling > 2) return -3; /* Unsupported SOF0 subsampling */ + DEBUGF("channel %d hsub %d vsub %d\n",i,p_jpeg->frameheader[i].horizontal_sampling,p_jpeg->frameheader[i].vertical_sampling); } + /* Check for subsampled luma, or different per-chroma-channel + subsampling */ + if (n == 3 && (p_jpeg->frameheader[0].vertical_sampling > 1 || + p_jpeg->frameheader[0].horizontal_sampling > 1 || + p_jpeg->frameheader[1].vertical_sampling != + p_jpeg->frameheader[2].vertical_sampling || + p_jpeg->frameheader[1].horizontal_sampling != + p_jpeg->frameheader[2].horizontal_sampling)) + return -3; p_jpeg->blocks = n; } break; @@ -921,9 +931,10 @@ void build_lut(struct jpeg* p_jpeg) p_jpeg->store_pos[i] = i; /* default ordering */ /* assignments for the decoding of blocks */ - if (p_jpeg->frameheader[0].horizontal_sampling == 2 - && p_jpeg->frameheader[0].vertical_sampling == 1) + if (p_jpeg->frameheader[1].horizontal_sampling == 2 + && p_jpeg->frameheader[1].vertical_sampling == 1) { /* 4:2:2 */ +DEBUGF("chroma 2x1 subsampled\n"); p_jpeg->blocks = 4; p_jpeg->x_mbl = (p_jpeg->x_size+15) / 16; p_jpeg->x_phys = p_jpeg->x_mbl * 16; @@ -944,9 +955,10 @@ void build_lut(struct jpeg* p_jpeg) p_jpeg->subsample_y[1] = 1; p_jpeg->subsample_y[2] = 1; } - if (p_jpeg->frameheader[0].horizontal_sampling == 1 - && p_jpeg->frameheader[0].vertical_sampling == 2) + if (p_jpeg->frameheader[1].horizontal_sampling == 1 + && p_jpeg->frameheader[1].vertical_sampling == 2) { /* 4:2:2 vertically subsampled */ +DEBUGF("chroma 1x2 subsampled\n"); p_jpeg->store_pos[1] = 2; /* block positions are mirrored */ p_jpeg->store_pos[2] = 1; p_jpeg->blocks = 4; @@ -969,9 +981,10 @@ void build_lut(struct jpeg* p_jpeg) p_jpeg->subsample_y[1] = 2; p_jpeg->subsample_y[2] = 2; } - else if (p_jpeg->frameheader[0].horizontal_sampling == 2 - && p_jpeg->frameheader[0].vertical_sampling == 2) + else if (p_jpeg->frameheader[1].horizontal_sampling == 2 + && p_jpeg->frameheader[1].vertical_sampling == 2) { /* 4:2:0 */ +DEBUGF("chroma 2x2 subsampled\n"); p_jpeg->blocks = 6; p_jpeg->x_mbl = (p_jpeg->x_size+15) / 16; p_jpeg->x_phys = p_jpeg->x_mbl * 16; @@ -996,10 +1009,11 @@ void build_lut(struct jpeg* p_jpeg) p_jpeg->subsample_y[1] = 2; p_jpeg->subsample_y[2] = 2; } - else if (p_jpeg->frameheader[0].horizontal_sampling == 1 - && p_jpeg->frameheader[0].vertical_sampling == 1) + else if (p_jpeg->frameheader[1].horizontal_sampling == 1 + && p_jpeg->frameheader[1].vertical_sampling == 1) { /* 4:4:4 */ /* don't overwrite p_jpeg->blocks */ +DEBUGF("chroma not subsampled\n"); p_jpeg->x_mbl = (p_jpeg->x_size+7) / 8; p_jpeg->x_phys = p_jpeg->x_mbl * 8; p_jpeg->y_mbl = (p_jpeg->y_size+7) / 8;