I answered my own question. It turns out there were two problems, first one was that the value for rstInterval wasn't proper (needs to be > 3). Also, I wasn't passing the extended dynamic parameters into the _control call when getting buffer info (XDM_GETBUFINFO), I was still using the regular parameters. So, just to post what worked for me in case anybody has the same problems in the future....

   IMGENC1_DynamicParams dynParams;
   IMGENC1_Status imgStatus;
   IMGENC1_Params params;
   IMGENC1_Handle hVidEncode = NULL;
   IJPEGENC_DynamicParams extDynParams;

   /* allocate and initialize image encoder on the engine */
   params.size = sizeof(IMGENC1_Params);
   params.maxWidth = width;
   params.maxHeight = height;
   params.maxScans = SCANS;
   params.dataEndianness = XDM_DEFAULT;
   params.forceChromaFormat = CHROMAFORMAT;
   hVidEncode = IMGENC1_create(hEngine, encoderName, &params);
   if (hVidEncode == NULL) {
       fprintf(stderr, "%s: error: can't open codec %s\n",
           progName, encoderName);
       return FAILURE;
   }

   /* set the parameters for encoding */
   dynParams.size = sizeof(IJPEGENC_DynamicParams);
   dynParams.numAU = XDM_DEFAULT;
   dynParams.inputChromaFormat = CHROMAFORMAT;
   dynParams.inputHeight = height;
   dynParams.inputWidth = width;
   dynParams.captureWidth = width;
   dynParams.generateHeader = XDM_ENCODE_AU;
   dynParams.qValue = QVALUE;

   /* set the extended dynamic parameters */
   extDynParams.imgencDynamicParams = dynParams;
   extDynParams.rstInterval = 84;
   extDynParams.disableEOI = XDM_DEFAULT;
   extDynParams.rotation = 180;
   extDynParams.customQ = NULL;

   imgStatus.size = sizeof(imgStatus);
if (IMGENC1_control(hVidEncode, XDM_SETPARAMS, (IMGENC1_DynamicParams*)&extDynParams,
                       (IMGENC1_Status*)&imgStatus) == XDM_EFAIL) {
fprintf(stderr, "%s: error: could not set PARAMS: 0x%x\n", "jpeg encoder",
           imgStatus.extendedError);
       return FAILURE;
   }

   /* ask the codec for buffer sizes - these are typically conservative */
if (IMGENC1_control(hVidEncode, XDM_GETBUFINFO, (IMGENC1_DynamicParams*)&extDynParams,
                       &imgStatus) == XDM_EFAIL) {
fprintf(stderr, "%s: error: could not get BUFINFO: 0x%x\n", "jpeg encoder",
           imgStatus.extendedError);
       return FAILURE;
   }


bj wrote:
Hey Chris, How did that actually work for you? When I try to run the same thing my call to _control fails with the error "could not set PARAMS: 0x10c000". I also was reading through the jpeg codec engine users guide (sprufe5c) and it makes no mention of resizing dynParams (although their example doesn't work for me either). Resizing dynParams using the addition of the two sizes seems fundamentally wrong since IJPEGENC_DynamicParams contains an IMGENC1_DynamicParams member which would already make the size of extDynParams correct wouldn't it?
My confusion is rising...

I've attached my code is below, any ideas?

    IMGENC1_DynamicParams dynParams;
    IJPEGENC_DynamicParams extDynParams;

---- snip creating the engine ----

    /* set the parameters for encoding */
dynParams.size = sizeof(IMGENC1_DynamicParams) + sizeof(IJPEGENC_DynamicParams);
    dynParams.numAU = XDM_DEFAULT;
    dynParams.inputChromaFormat = CHROMAFORMAT;
    dynParams.inputHeight = height;
    dynParams.inputWidth = width;
    dynParams.captureWidth = width;
    dynParams.generateHeader = XDM_ENCODE_AU;
    dynParams.qValue = QVALUE;

    /* set the extended dynamic parameters */
    extDynParams.imgencDynamicParams = dynParams;

    extDynParams.rstInterval = XDM_DEFAULT;
    extDynParams.disableEOI = XDM_DEFAULT;
    extDynParams.rotation = 180;
    extDynParams.customQ = NULL;

    imgStatus.size = sizeof(imgStatus);
if (IMGENC1_control(hVidEncode,XDM_SETPARAMS,(IMGENC1_DynamicParams*)&extDynParams,
                        (IMGENC1_Status*)&imgStatus) == XDM_EFAIL) {

fprintf(stderr, "%s: error: could not set PARAMS: 0x%x\n", "jpeg encoder",
            imgStatus.extendedError);
        return FAILURE;
    }


Chris Stillson wrote:

    Hey Jeff,

    I just got this working. I think what you forgot to do was

          dynParams.size = sizeof(IMGENC1_DynamicParams) + 
sizeof(IJPEGENC_DynamicParams);

    It's the size change that cues the library that extended data is present.

    good luck
    Chris


    On Wed, Jun 18, 2008 at 1:55 PM, Jeff Cooper <[EMAIL PROTECTED]> wrote:
        I'm trying to use the JPEG codec to rotate an image but I'm not having 
any
        luck with it and was wondering if anyone else has done it.

        I'm setting up my dynamic parameters as follows:
          IMGENC1_DynamicParams dynParams;
          IJPEGENC_DynamicParams extDynParams;

          /* set the parameters for encoding */
          dynParams.size = sizeof(IMGENC1_DynamicParams);
          dynParams.numAU = XDM_DEFAULT;
          dynParams.inputChromaFormat = CHROMAFORMAT;
          dynParams.inputHeight = VID_HEIGHT;
          dynParams.inputWidth = VID_WIDTH;
          dynParams.captureWidth = VID_WIDTH;
          dynParams.generateHeader = XDM_ENCODE_AU;
          dynParams.qValue = QVALUE;

          /* set the extended parameters for encoding */
          extDynParams.imgencDynamicParams = dynParams;
          dynParams.size = sizeof(IJPEGENC_DynamicParams);
          extDynParams.rstInterval = XDM_DEFAULT;
          extDynParams.disableEOI = XDM_DEFAULT;
          extDynParams.rotation = 180;
          extDynParams.customQ = NULL;

        Then I call:

          imgStatus.size = sizeof(imgStatus);
          if (IMGENC1_control(m_Private->enc, XDM_SETPARAMS, 
(IMGENC1_DynamicParams
        *)&extDynParams, &imgStatus) ==
              XDM_EFAIL) {

              ERROR("Could not set PARAMS."
                  << hparam("Error", imgStatus.extendedError));
              return;
          }

        I don't have any warning when I compile and I don't get any runtime 
errors,
        but my image doesn't rotate.

        Does anyone see anything obvious that I'm doing wrong?

        thanks,
        Jeff

        --
        Jeff Cooper // senior embedded software engineer

        LOGIC // engineering design services
        411 Washington Ave. N. Suite 400
        Minneapolis, MN 55401
        T // 612.436.5176
        F // 612.672.9489

        [EMAIL PROTECTED]
        www.logicpd.com

        / / / / / / / / / / / / / / / / / / / / / / / / / / / /
        This message (including any attachments) contains confidential
        information intended for a specific individual and purpose, and
        is protected by law. If you are not the intended recipient, you
        should delete this message and are hereby notified that any
        disclosure, copying, distribution, or other use of this message,
        or the taking of any action based on it, is strictly prohibited.



        _______________________________________________
        Davinci-linux-open-source mailing list
        [email protected]
        http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

    _______________________________________________
    Davinci-linux-open-source mailing list
    [email protected]
    http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to