This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MJPEG encode problem(01.00.00.09)

Hi,

i'm facing MJPEG encode issue.

mjpeg codec lib version:01.00.00.09

i try to encode 320x192 video and output 192x180 resolution, but the actual output resolution is only 320x176

can you give me some suggestion? thanks in advance.

my parameters setting:

    dynamicParams.size = sizeof(IMGENC1_DynamicParams);
    dynamicParams.numAU = XDM_DEFAULT;
    dynamicParams.inputChromaFormat = XDM_YUV_420SP;
    dynamicParams.inputHeight = 180;
    dynamicParams.inputWidth = 320;
    dynamicParams.captureWidth = 0;
    dynamicParams.generateHeader = XDM_ENCODE_AU;
    dynamicParams.qValue = 60;

  • I believe this query is related to DM36x. Have you tried using captureWidth parmatere. Please set captureWidth = 320 and inputWidth = 192. This should work.

     

    regards

    Yashwant

  • i try to implement this solution based on your suggestion, but the output size is 192x176. i want to get 320x180 size

    my setting:

    captureWidth = 320

    inputWidth = 192

    inputHeight= 180

  • Hi William, 

    It's not clear if you want the output size to be 320x180 or 192x180. Can you please clarify?

    Also, can you also let us know all your input parameters?

     

    Thanks & Regards,

     

    Akshay

  • Hi Akshay,

    sorry bring you any confuse, I made a mistake in the first mail, now, i want to clarify my problem once again.

    my input video data is 320x192, after MJPEG encode, i want to get 320x180(16:9) output, but my MJPEG encode engine always output 320x176 size.

    however, similarly, when input video data is 640x368, 640x360(16:9) MJPEG encode data can be output correctly.

    MJPEG codec lib is : 01.00.00.09

    all paramenters listed as follows:

    params.size = sizeof(IMGENC1_Params);
        params.maxWidth = 320;
        params.maxHeight = 192;
        params.maxScans = 1;
        params.dataEndianness = XDM_BYTE;
        params.forceChromaFormat = XDM_YUV_420P;

    dynamicParams.size = sizeof(IMGENC1_DynamicParams);
        dynamicParams.numAU = XDM_DEFAULT;
        dynamicParams.inputChromaFormat = XDM_YUV_420SP;
        dynamicParams.inputHeight = 180;
        dynamicParams.inputWidth = 320;
        dynamicParams.captureWidth = 0;
        dynamicParams.generateHeader = XDM_ENCODE_AU;
        dynamicParams.qValue = 60;

     

  • In addition, MJPEG encode process inbuf and outbuf setting as following:

    offset = width * height;

     inBufDesc.numBufs  = 2;
     inBufDesc.descs[0].bufSize = width*height;
     inBufDesc.descs[0].buf = (XDAS_Int8*)inBuf;
     inBufDesc.descs[0].accessMask = 0;

     inBufDesc.descs[1].bufSize = width * height / 2;
     inBufDesc.descs[1].buf = (XDAS_Int8*)(inBuf + offset);
     inBufDesc.descs[1].accessMask = 0;

     outBufDesc.numBufs = 1;
     outBufDesc.descs[0].bufSize = 1280x720x3/2;
     outBufDesc.descs[0].buf = (XDAS_Int8*)outBuf;
     outBufDesc.descs[0].accessMask = 0;

     inArgs.size = sizeof(IMGENC1_InArgs);
     outArgs.size = sizeof(IMGENC1_OutArgs);

     /* perform the image (JPEG) encoding */
     status = IMGENC1_process(hEncode, &inBufDesc, &outBufDesc, &inArgs,&outArgs);

  • do you any idea? it's urgent for us!!!!!!!!!

  • Hi William,

    I checked the jpeg encoder with the params you have mentioned. I am able to get 320x180 output from a 320x192 420SP YUV. 

     

    The JPEG encoder does support cropping by width by means of the inputWidth and captureWidth parameters. However, there isn't inherent support for cropping height. But since you are using 420SP input, it can be done by manipulating the input buffer pointers accordingly. 

    In your case, the input chroma buffer would need to be offset by 320x192 from the input luma buffer, even though the inputHeight you are passing to the encoder is 180. 

    Let me know how it goes.

    Regards,

    Akshay

     

     

     

     

  • Akshay,

    i'm really appreaciate for your reply.

    but i'm still confused, why my 640x368 input data can be MJPEG encoded and then output 640x360 correctly?

    at the same time, i'll follow your suggestion and let you know anything. thanks once again.

  • in addition, can you provide your all MJPEG encode parameters?

    i'll check what's different between my setting and yours. 

  • Hi William,

    I'm not really sure what width*height are referred to in the code snippet you posted. But if it's equal to what you're using as maxWidth*maxHeight, then I guess you've taken care of it already. 

    -Akshay

     

  • William,

     

    I'm running this in the dvtb test environment. My test parameters are:

     

     codec                           =>  jpegenc1

             maxHeight                       =>  192

             maxWidth                         =>  320

             maxScans                         =>  0

             dataEndianness                 =>  1

             forceChromaFormat           =>  1

             numAU                           =>  0

             inputChromaFormat           =>  9

             inputHeight                     =>  180

             inputWidth                       =>  320

             captureWidth                     =>  0

             generateHeader                 =>  0

             qValue                           =>  73

             halfBufCB                       =>  0

             halfBufCBarg                     =>  0

             extDynParamsRstInterval =>  4

             extDynParamsDisableEOI =>  0

             extDynParamsRotation             =>  0

             customQ                         =>  0

     

    -Akshay

  • Akshay,

    maybe you are still not able to my problem. so I'll describle it again.

    firstly, my problem mainly focus on MJPEG encode. mjpeg codec lib version:01.00.00.09

    1: when input YUV data size is 320x192, after MJPEG encode, only 320x176 size MJPEG data can be output correctly view by VLC, but i want to get 320x180 size MJPEG encoded data. all paramenters as following:

    params.size = sizeof(IMGENC1_Params);
        params.maxWidth = 320;
        params.maxHeight = 192;
        params.maxScans = 1;
        params.dataEndianness = XDM_BYTE;
        params.forceChromaFormat = XDM_YUV_420P;

    dynamicParams.size = sizeof(IMGENC1_DynamicParams);
        dynamicParams.numAU = XDM_DEFAULT;
        dynamicParams.inputChromaFormat = XDM_YUV_420SP;
        dynamicParams.inputHeight = 180;
        dynamicParams.inputWidth = 320;
        dynamicParams.captureWidth = 0;
        dynamicParams.generateHeader = XDM_ENCODE_AU;
        dynamicParams.qValue = 60;

    offset = 320* 192;

     inBufDesc.numBufs  = 2;
     inBufDesc.descs[0].bufSize = 320* 192;
     inBufDesc.descs[0].buf = (XDAS_Int8*)inBuf;
     inBufDesc.descs[0].accessMask = 0;

     inBufDesc.descs[1].bufSize = 320* 192 / 2;
     inBufDesc.descs[1].buf = (XDAS_Int8*)(inBuf + offset);
     inBufDesc.descs[1].accessMask = 0;

     outBufDesc.numBufs = 1;
     outBufDesc.descs[0].bufSize = 1280x720x3/2;
     outBufDesc.descs[0].buf = (XDAS_Int8*)outBuf;
     outBufDesc.descs[0].accessMask = 0;

     inArgs.size = sizeof(IMGENC1_InArgs);
     outArgs.size = sizeof(IMGENC1_OutArgs);

     /* perform the image (JPEG) encoding */
     status = IMGENC1_process(hEncode, &inBufDesc, &outBufDesc, &inArgs,&outArgs);

     

    2: However, when input YUV data size is 640x368, after MJPEG encode, 640x360 size MJPEG data can be output correctly view by VLC. all paramenters as following:

    params.size = sizeof(IMGENC1_Params);
        params.maxWidth = 640;
        params.maxHeight = 368;
        params.maxScans = 1;
        params.dataEndianness = XDM_BYTE;
        params.forceChromaFormat = XDM_YUV_420P;

    dynamicParams.size = sizeof(IMGENC1_DynamicParams);
        dynamicParams.numAU = XDM_DEFAULT;
        dynamicParams.inputChromaFormat = XDM_YUV_420SP;
        dynamicParams.inputHeight = 360;
        dynamicParams.inputWidth = 640;
        dynamicParams.captureWidth = 0;
        dynamicParams.generateHeader = XDM_ENCODE_AU;
        dynamicParams.qValue = 60;

    offset = 640* 368;

     inBufDesc.numBufs  = 2;
     inBufDesc.descs[0].bufSize = 640* 368;
     inBufDesc.descs[0].buf = (XDAS_Int8*)inBuf;
     inBufDesc.descs[0].accessMask = 0;

     inBufDesc.descs[1].bufSize = 640* 368 / 2;
     inBufDesc.descs[1].buf = (XDAS_Int8*)(inBuf + offset);
     inBufDesc.descs[1].accessMask = 0;

     outBufDesc.numBufs = 1;
     outBufDesc.descs[0].bufSize = 1280x720x3/2;
     outBufDesc.descs[0].buf = (XDAS_Int8*)outBuf;
     outBufDesc.descs[0].accessMask = 0;

     inArgs.size = sizeof(IMGENC1_InArgs);
     outArgs.size = sizeof(IMGENC1_OutArgs);

     /* perform the image (JPEG) encoding */
     status = IMGENC1_process(hEncode, &inBufDesc, &outBufDesc, &inArgs,&outArgs);

  • William, 

    MJPEG is just a series of JPEG frames, so it makes no difference, as such.

    Can you attach the 320x176 output you are getting here, so that I can have a look?

    If it works with 640x360 then it really should work for 320x180 too.... 

    -Akshay

  • Akshay,

    that's my confused points. i don't know why 640x360 is ok, but 320x180 is not ok.

    i have set all parameters the same with yours, but i still only get 320x176,

    i have encosed my 320x176 output data for your reference.

    thanks for you help.

  • Hi Akshay,

    as you mentioned, you are running this in the dvtb test environment, my test results is based on DVSDK_3,

    my app interface as follows:
    IMGENC1_create;

    IMGENC1_control;

    IMGENC1_process

    i don't if it's related with my unexpected output?

  • William,

     

    I'm using dvtb framework from dvsdk 2.10.00.16.

    I'm sorry, but I do not have access to the dvsdk 3 environment at present.

    The steps you are following are proper, I do not see an issue with those.

     

    -Akshay

  • I have tried to do my best, but i'm still not able to find the root cause.

    which MJPEG encode codec lib version are you using?

  • I'm using 1.00.00.09 as well.

    -Akshay

  • if my input YUV is 320x192,

    then set inputHeight=184, MJPEG encode output will be 320x184 properly,

    if set inputHeight=182 or 180, MJPEG encode output will be 320x176,

  • do you have any update for this issue, we must fix it, how can i do it?

  • Hi William,

    Can you provide me with the all the input pointers as well as buffer sizes that your application has generated.

    -Akshay

     

     

     

  • thanks for your reply,

    all parameters and input as well as buffer are listed as follows:

    1: when input YUV data size is 320x192, after MJPEG encode, only 320x176 size MJPEG data can be output correctly view by VLC, but i want to get 320x180 size MJPEG encoded data. all paramenters as following:

    params.size = sizeof(IMGENC1_Params);
        params.maxWidth = 320;
        params.maxHeight = 192;
        params.maxScans = 1;
        params.dataEndianness = XDM_BYTE;
        params.forceChromaFormat = XDM_YUV_420P;

    dynamicParams.size = sizeof(IMGENC1_DynamicParams);
        dynamicParams.numAU = XDM_DEFAULT;
        dynamicParams.inputChromaFormat = XDM_YUV_420SP;
        dynamicParams.inputHeight = 180;
        dynamicParams.inputWidth = 320;
        dynamicParams.captureWidth = 0;
        dynamicParams.generateHeader = XDM_ENCODE_AU;
        dynamicParams.qValue = 60;

    offset = 320* 192;

     inBufDesc.numBufs  = 2;
     inBufDesc.descs[0].bufSize = 320* 192;
     inBufDesc.descs[0].buf = (XDAS_Int8*)inBuf;
     inBufDesc.descs[0].accessMask = 0;

     inBufDesc.descs[1].bufSize = 320* 192 / 2;
     inBufDesc.descs[1].buf = (XDAS_Int8*)(inBuf + offset);
     inBufDesc.descs[1].accessMask = 0;

     outBufDesc.numBufs = 1;
     outBufDesc.descs[0].bufSize = 1280x720x3/2;
     outBufDesc.descs[0].buf = (XDAS_Int8*)outBuf;
     outBufDesc.descs[0].accessMask = 0;

     inArgs.size = sizeof(IMGENC1_InArgs);
     outArgs.size = sizeof(IMGENC1_OutArgs);

     /* perform the image (JPEG) encoding */
     status = IMGENC1_process(hEncode, &inBufDesc, &outBufDesc, &inArgs,&outArgs);

     

    2: However, when input YUV data size is 640x368, after MJPEG encode, 640x360 size MJPEG data can be output correctly view by VLC. all paramenters as following:

    params.size = sizeof(IMGENC1_Params);
        params.maxWidth = 640;
        params.maxHeight = 368;
        params.maxScans = 1;
        params.dataEndianness = XDM_BYTE;
        params.forceChromaFormat = XDM_YUV_420P;

    dynamicParams.size = sizeof(IMGENC1_DynamicParams);
        dynamicParams.numAU = XDM_DEFAULT;
        dynamicParams.inputChromaFormat = XDM_YUV_420SP;
        dynamicParams.inputHeight = 360;
        dynamicParams.inputWidth = 640;
        dynamicParams.captureWidth = 0;
        dynamicParams.generateHeader = XDM_ENCODE_AU;
        dynamicParams.qValue = 60;

    offset = 640* 368;

     inBufDesc.numBufs  = 2;
     inBufDesc.descs[0].bufSize = 640* 368;
     inBufDesc.descs[0].buf = (XDAS_Int8*)inBuf;
     inBufDesc.descs[0].accessMask = 0;

     inBufDesc.descs[1].bufSize = 640* 368 / 2;
     inBufDesc.descs[1].buf = (XDAS_Int8*)(inBuf + offset);
     inBufDesc.descs[1].accessMask = 0;

     outBufDesc.numBufs = 1;
     outBufDesc.descs[0].bufSize = 1280x720x3/2;
     outBufDesc.descs[0].buf = (XDAS_Int8*)outBuf;
     outBufDesc.descs[0].accessMask = 0;

     inArgs.size = sizeof(IMGENC1_InArgs);
     outArgs.size = sizeof(IMGENC1_OutArgs);

     /* perform the image (JPEG) encoding */
     status = IMGENC1_process(hEncode, &inBufDesc, &outBufDesc, &inArgs,&outArgs);

  • Hi William,

     

    Parameters seem to be proper.

    For further analysis, can you please provide us the output MJPEG files generated in following two cases : 320x180 and 320x184?

     

    Regards, RSV

  • RSV,

    Thanks,

    keep input YUV data 320x192,

    when set MJPEG height to 184, MJPEG encode data can output properly.

    6036.mjpeg_360x184.mp4

     

    if set MJPEG height to 182 or 180, MJPEG encode data will output 320x176, whatever, not able to output 180 height size.

    7701.mjpeg_320x176.mp4

  • Hi William,

     

    The file that you have provide for 180/182 as input height -- "7701.mjpeg_5F00_320x176.mp4", is showing completely black when I played with different players. Is that the input you provided to encoder?

     

    Regards, RSV

  • RSV,

    you are right, that's my input, but i want to say what there is no any effect whatever color or black scene as input.

  • Hi William,

     

    Thanks for clarifying on the input. Still we couldn't reproduce this in our setup.

    Here is my analysis based on the inputs provided by you till now:

    1. Working resolutions : 320x184, 640x360 --> both cases height is non-multiple of 16 but it is multiple of 8

    2. Non-working resolutions : 320x180, 320x182 --> both cases height is non-multiple of 16 also non-multiple of 8

    It looks to me that encoder is being given height as 176 in case of point 2 above, can you please check if any other module is changing input height to multiples of 8 before encoder control (Setparams) call? 

    Regards, RSV

  • Hi RSV,

    thanks for your response.

    my test results based on DVSDK3, not dvtb. so I don't know if there are some differences?

    I'll doulbe check if any other module is changing input height to multiples of 8.

    thanks once again.

  • Hi RSV,

    it's difficult to me tracking SDK module.

    I want to track imgenc1.c to verify if DVSDK module set the height to multiple of 8. but the compile is not available to me (dvsdk_3_10_00_19/codec_engine_2_25_05_16/packages/ti/sdo/ce/image1), I guess it's a lib and compile codec_engine is limited to developer, that's correct?

    How can i compile them?

  • Hi William,

    I thought you have the access to codec engine source.

    Give us sometime, we will try to look at ways to debug this internally and get back to you with our findings.

    Regards, RSV

  • Hi RSV,

    thanks, look forward to your findings. the sooner the better.

  • Hi William,

    One of our other customers was facing a similar problem where the height was being restricted to a multiple of 8. It turned out that they were using RTSP streaming and RTSP has a restriction that width and height be multiples of 8.

    Are you also using RTSP streaming to view your output? 

    Regards,

    Akshay

  • Hi Akshay,

    thanks for your information.

    we are using RTSP both H264 and MJPEG streaming, but my H264 streaming(320x180) works fine.

    anyway, we'll check whehter my RTSP has the restriction.

  • Hi Akshay,

    this issue caused by MJPEG RTP header restrict.

    many thanks for your continuious support.

  • Hi William,

     

    Glad we could close this issue. 

     

    -Akshay