I want to use the example of jpegenc in dvsdk to transform a grey format (i get only Y from YUV) to a jpeg format, so i change the parameter 'chromaformat' from XDM_YUV_422ILE to XDM_GREY, but i can allocate and initialize image encoder on the engine.
WHY?. And how can i use grey format in jpegenc?
the part of code is as follow:
#define HEIGHT 480
#define WIDTH 720
#define SCANS 4
#define QVALUE 73
#define CHROMAFORMAT XDM_GREY
#define BUFALIGN Memory_DEFAULTALIGNMENT
Int smain(Int argc, String argv[])
{
Engine_Handle ce = NULL;
IMGENC1_Handle enc = NULL;
IMGENC1_Params encParams;
IMGENC1_DynamicParams dynParams;
IMGENC1_Status imgStatus;
FILE *in = NULL;
FILE *out = NULL;
String inFile, outFile;
if (argc <= 1) {
inFile = "../in.dat";
outFile = "../out.dat";
}
else if (argc == 3) {
progName = argv[0];
inFile = argv[1];
outFile = argv[2];
}
else {
fprintf(stderr, usage, argv[0]);
exit(1);
}
GT_0trace(curMask, GT_1CLASS, "Application started.\n");
/* open file streams for input and output */
if ((in = fopen(inFile, "rb")) == NULL) {
fprintf(stderr, "ERROR: can't read file %s\n", inFile);
goto end;
}
if ((out = fopen(outFile, "wb")) == NULL) {
fprintf(stderr, "ERROR: can't write to file %s\n", outFile);
goto end;
}
/* open the Codec Engine */
if ((ce = Engine_open(engineName, NULL, NULL)) == NULL) {
fprintf(stderr, "ERROR: can't open engine %s\n", engineName);
goto end;
}
/* allocate and initialize image encoder on the engine */
encParams.size = sizeof(IMGENC1_Params);
encParams.maxWidth = WIDTH;
encParams.maxHeight = HEIGHT;
encParams.maxScans = SCANS;
encParams.dataEndianness = XDM_DEFAULT;
encParams.forceChromaFormat = CHROMAFORMAT;
enc = IMGENC1_create(ce, encoderName, &encParams);
if (enc == NULL) {
fprintf(stderr, "%s: error: can't open codec %s\n",
progName, encoderName);
goto end;
}
/* set the parameters for encoding */
dynParams.size = sizeof(IMGENC1_DynamicParams);
dynParams.numAU = XDM_DEFAULT;
dynParams.inputChromaFormat = CHROMAFORMAT;
dynParams.inputHeight = HEIGHT;
dynParams.inputWidth = WIDTH;
dynParams.captureWidth = 0;
dynParams.generateHeader = XDM_ENCODE_AU;
dynParams.qValue = QVALUE;
imgStatus.size = sizeof(imgStatus);
if (IMGENC1_control(enc, XDM_SETPARAMS, &dynParams, &imgStatus) ==
XDM_EFAIL) {
fprintf(stderr, "%s: error: could not set PARAMS: 0x%x\n", progName,
imgStatus.extendedError);
goto end;
}
/* ask the codec for buffer sizes - these are typically conservative */
if (IMGENC1_control(enc, XDM_GETBUFINFO, &dynParams, &imgStatus) ==
XDM_EFAIL) {
fprintf(stderr, "%s: error: could not get BUFINFO: 0x%x\n", progName,
imgStatus.extendedError);
goto end;
}
/* allocate input, encoded buffers based on GETBUFINFO */
inBufSize = imgStatus.bufInfo.minInBufSize[0];
inBuf = (XDAS_Int8 *)Memory_contigAlloc(inBufSize, BUFALIGN);
encodedBufSize = imgStatus.bufInfo.minOutBufSize[0];
encodedBuf = (XDAS_Int8 *)Memory_contigAlloc(encodedBufSize, BUFALIGN);
if ((inBuf == NULL) || (encodedBuf == NULL)) {
goto end;
}
/* use engine to encode the data */
encode(enc, in, out);
end:
/* free buffers */
if (encodedBuf) {
Memory_contigFree(encodedBuf, encodedBufSize);
}
if (inBuf) {
Memory_contigFree(inBuf, inBufSize);
}
/* teardown the codec */
if (enc) {
IMGENC1_delete(enc);
}
/* close the engine */
if (ce) {
Engine_close(ce);
}
/* close the files */
if (in) {
fclose(in);
}
if (out) {
fclose(out);
}
return (0);
}
And the RESULT is
error: can't open codec jpegnec