Skip to content

Commit

Permalink
[trunk] fixes issue #357. MCT is automatically disabled when
Browse files Browse the repository at this point in the history
subsamppling is detected.
  • Loading branch information
detonin committed Jul 3, 2014
1 parent a38b97f commit 7d21871
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/jp2/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -3018,7 +3018,7 @@ static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *p
{
unsigned char value = 0;
for(compno = 0; compno < numcomps; compno++) {
int nloop = (w*h)/(raw_cp->rawComps[compno].dx*raw_cp->rawComps[compno].dx);
int nloop = (w*h)/(raw_cp->rawComps[compno].dx*raw_cp->rawComps[compno].dy);
for (i = 0; i < nloop; i++) {
if (!fread(&value, 1, 1, f)) {
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
Expand Down
10 changes: 10 additions & 0 deletions src/bin/jp2/opj_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,16 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
}
}

/* If subsampled image is provided, automatically disable MCT */
if ( ((parameters->decod_format == RAW_DFMT)
|| (parameters->decod_format == RAWL_DFMT))
&& ((raw_cp->rawComps[1].dx > 1)
|| (raw_cp->rawComps[1].dy > 1)
|| (raw_cp->rawComps[2].dx > 1)
|| (raw_cp->rawComps[2].dy > 1))) {
parameters->tcp_mct = 0;
}

return 0;
}

Expand Down
9 changes: 9 additions & 0 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -6453,6 +6453,15 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k,
opj_j2k_setup_mct_encoding(tcp,image);
}
else {
if(tcp->mct==1 && image->numcomps == 3) { // RGB->YCC MCT is enabled
if ((image->comps[0].dx != image->comps[1].dx) ||
(image->comps[0].dx != image->comps[2].dx) ||
(image->comps[0].dy != image->comps[1].dy) ||
(image->comps[0].dy != image->comps[2].dy)) {
opj_event_msg(p_manager, EVT_WARNING, "Cannot perform MCT on components with different sizes. Disabling MCT.\n");
tcp->mct = 0;
}
}
for (i = 0; i < image->numcomps; i++) {
opj_tccp_t *tccp = &tcp->tccps[i];
opj_image_comp_t * l_comp = &(image->comps[i]);
Expand Down

0 comments on commit 7d21871

Please sign in to comment.