subsamppling is detected.
{
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");
}
}
+ /* 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;
}
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]);