MBOOL
JpegCodec::
checkIfNeedImgTransform(
    ImgBufInfo const rSrcBufInfo, 
    ImgBufInfo const rDstBufInfo, 
    Rect const rROI, 
    MUINT32 const u4Rotation, 
    MUINT32 const u4Flip 
)
{
    FUNCTION_LOG_START;
    // format 
    // resize
    if (rDstBufInfo.u4ImgWidth != rSrcBufInfo.u4ImgWidth ||
         rDstBufInfo.u4ImgHeight != rSrcBufInfo.u4ImgHeight) 
    {
        MY_LOGD("Resize src =(%d,%d), dst=(%d,%d)", 
                 rSrcBufInfo.u4ImgWidth, rSrcBufInfo.u4ImgHeight, 
                 rDstBufInfo.u4ImgWidth, rDstBufInfo.u4ImgHeight); 
        return MTRUE; 
    }
    // check dest image width/height if align to 16x 
    if ((rDstBufInfo.u4ImgWidth & 0xf != 0) || 
        (rDstBufInfo.u4ImgHeight & 0xf != 0))
    {
        MY_LOGD("Dest width/height not aligh to 16x, dst =(%d, %d)", 
                 rDstBufInfo.u4ImgWidth, rDstBufInfo.u4ImgHeight); 
        return MTRUE; 
    }
    
    // roi 
    if (rROI.x != 0 || rROI.y != 0 
        || rROI.w != rSrcBufInfo.u4ImgWidth 
        || rROI.h != rSrcBufInfo.u4ImgHeight)
    {
        MY_LOGD("Crop , roi = (%d, %d, %d, %d)", rROI.x, rROI.y, 
                                                 rROI.w, rROI.h); 
        return MTRUE; 
    } 
    // rotation 
    if (0 != u4Rotation)
    {
        MY_LOGD("rotation: %d", u4Rotation); 
        return MTRUE; 
    }
    // flip 
    if (0 != u4Flip)
    {
        MY_LOGD("flip:%d", u4Flip); 
        return MTRUE; 
    }
    // JPEG format but source format not support 
    if (!isSupportedFormat(rSrcBufInfo.eImgFmt))
    {
        MY_LOGD("Not JPEG codec support fmt:0x%x", rSrcBufInfo.eImgFmt); 
        return MTRUE; 
    }
    //
    MY_LOGD("No need to do image transform"); 

    FUNCTION_LOG_END;
    return MFALSE; 
}
Ejemplo n.º 2
0
void edwParseSubmitFile(struct sqlConnection *conn, char *submitLocalPath, char *submitUrl, 
    struct submitFileRow **retSubmitList)
/* Load and parse up this file as fielded table, make sure all required fields are there,
 * and calculate indexes of required fields.   This produces an edwFile list, but with
 * still quite a few fields missing - just what can be filled in from submit filled in. 
 * The submitUrl is just used for error reporting.  If it's local, just make it the
 * same as submitLocalPath. */
{
char *requiredFields[] = {"file_name", "format", "output_type", "experiment", "replicate", 
    "enriched_in", "md5_sum", "size",  "modified", "valid_key"};
struct fieldedTable *table = fieldedTableFromTabFile(submitLocalPath, submitUrl,
	requiredFields, ArraySize(requiredFields));

/* Get offsets of all required fields */
int fileIx = stringArrayIx("file_name", table->fields, table->fieldCount);
int formatIx = stringArrayIx("format", table->fields, table->fieldCount);
int outputIx = stringArrayIx("output_type", table->fields, table->fieldCount);
int experimentIx = stringArrayIx("experiment", table->fields, table->fieldCount);
int replicateIx = stringArrayIx("replicate", table->fields, table->fieldCount);
int enrichedIx = stringArrayIx("enriched_in", table->fields, table->fieldCount);
int md5Ix = stringArrayIx("md5_sum", table->fields, table->fieldCount);
int sizeIx = stringArrayIx("size", table->fields, table->fieldCount);
int modifiedIx = stringArrayIx("modified", table->fields, table->fieldCount);
int validIx = stringArrayIx("valid_key", table->fields, table->fieldCount);

/* See if we're doing replacement and check have all columns needed if so. */
int replacesIx = stringArrayIx(replacesTag, table->fields, table->fieldCount);
int replaceReasonIx = stringArrayIx(replaceReasonTag, table->fields, table->fieldCount);
boolean doReplace = (replacesIx != -1);
if (doReplace)
    if (replaceReasonIx == -1)
        errAbort("Error: got \"%s\" column without \"%s\" column in %s.", 
	    replacesTag, replaceReasonTag, submitUrl);

/* Loop through and make sure all field values are ok */
struct fieldedRow *fr;
for (fr = table->rowList; fr != NULL; fr = fr->next)
    {
    char **row = fr->row;
    char *fileName = row[fileIx];
    allGoodFileNameChars(fileName);
    char *format = row[formatIx];
    if (!isSupportedFormat(format))
	errAbort("Format %s is not supported", format);
    allGoodSymbolChars(row[outputIx]);
    char *experiment = row[experimentIx];
    if (!isExperimentId(experiment))
        errAbort("%s in experiment field does not seem to be an encode experiment", experiment);
    char *replicate = row[replicateIx];
    if (differentString(replicate, "pooled") && differentString(replicate, "n/a") )
	if (!isAllNum(replicate))
	    errAbort("%s is not a good value for the replicate column", replicate);
    char *enriched = row[enrichedIx];
    if (!encode3CheckEnrichedIn(enriched))
        errAbort("Enriched_in %s is not supported", enriched);
    char *md5 = row[md5Ix];
    if (strlen(md5) != 32 || !isAllHexLower(md5))
        errAbort("md5 '%s' is not in all lower case 32 character hexadecimal format.", md5);
    char *size = row[sizeIx];
    if (!isAllNum(size))
        errAbort("Invalid size '%s'", size);
    char *modified = row[modifiedIx];
    if (!isAllNum(modified))
        errAbort("Invalid modification time '%s'", modified);
    char *validIn = row[validIx];
    char *realValid = encode3CalcValidationKey(md5, sqlLongLong(size));
    if (!sameString(validIn, realValid))
        errAbort("The valid_key %s for %s doesn't fit", validIn, fileName);
    freez(&realValid);

    if (doReplace)
	{
	char *replaces = row[replacesIx];
	char *reason = row[replaceReasonIx];
	if (!isEmptyOrNa(replaces))
	    {
	    char *prefix = edwLicensePlateHead(conn);
	    if (!startsWith(prefix, replaces))
		errAbort("%s in replaces column is not an ENCODE file accession", replaces);
	    if (isEmptyOrNa(reason))
		errAbort("Replacing %s without a reason\n", replaces);
	    }
	}
    }

*retSubmitList = submitFileRowFromFieldedTable(conn, table, 
    fileIx, md5Ix, sizeIx, modifiedIx, replacesIx, replaceReasonIx);
}