Skip to content

Commit d4665db

Browse files
committed
debug dump SOF0
1 parent 098b42e commit d4665db

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/gpujpeg_reader.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,9 @@ static const char *array_serialize(int comp_count, const uint8_t *comp_id) {
691691
return buffer;
692692
}
693693

694+
/**
695+
* checks component ID to determine if JPEG is in YCbCr (component IDs 1, 2, 3) or RGB (component IDs 'R', 'G', 'B')
696+
*/
694697
static enum gpujpeg_color_space gpujpeg_reader_process_cid(int comp_count, uint8_t *comp_id, enum gpujpeg_color_space header_color_space) {
695698
_Static_assert(GPUJPEG_MAX_COMPONENT_COUNT >= 3, "An array of at least 3 components expected");
696699
static const uint8_t ycbcr_ids[] = { 1, 2, 3 };
@@ -727,6 +730,21 @@ static enum gpujpeg_color_space gpujpeg_reader_process_cid(int comp_count, uint8
727730
return GPUJPEG_NONE;
728731
}
729732

733+
static void
734+
sof0_dump(int comp_count, const struct gpujpeg_component_sampling_factor* sampling_factor, const uint8_t* id,
735+
const int* map)
736+
{
737+
printf("SOF0 subsampling:");
738+
for (int comp = 0; comp < comp_count; ++comp) {
739+
printf(" %dx%d", sampling_factor[comp].horizontal, sampling_factor[comp].vertical);
740+
}
741+
printf("\nSOF0 component quantization tab usage:");
742+
for (int comp = 0; comp < comp_count; ++comp) {
743+
printf(" %" PRIu8 "->%d", id[comp], map[comp]);
744+
}
745+
printf("\n");
746+
}
747+
730748
/**
731749
* Read start of frame block from image
732750
*
@@ -791,6 +809,10 @@ gpujpeg_reader_read_sof0(struct gpujpeg_parameters * param, struct gpujpeg_image
791809
length -= 3;
792810
}
793811

812+
if (param->verbose >= LL_DEBUG2) {
813+
sof0_dump(param->comp_count, param->sampling_factor, comp_id, quant_map);
814+
}
815+
794816
// Deduce color space if not known from headers
795817
enum gpujpeg_color_space detected_color_space = gpujpeg_reader_process_cid(param->comp_count, comp_id, header_color_space);
796818
if (header_color_space == GPUJPEG_NONE && detected_color_space != GPUJPEG_NONE) {

0 commit comments

Comments
 (0)