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.

How to Add a new encode resolution in DM365 IPNC?

Hi,

I am trying to add a new encode resolution option in DM365 IPNC, but there are some problem,

While I choose  the encode resolution I added (the resolution is 352*288), it seems only encode 30 frames, then the stream stop.

The console window show the message below :


 CAPTURE  |          33.41 |      29.93 |      30100 |          901 |              
 ENCODE0  |           3.94 |     254.10 |        122 |           31 |              
 STREAM     |           0.32 |    3100.00 |         10 |           31 |              
 OSD0          |           0.51 |    1968.33 |        442 |          870 |              
 AEWB         |           1.47 |     682.09 |       1318 |          899 |              
                                                                                   
                                                                                   
 Module        | Avg Time/Frame | Frame-rate | Total time | Total Frames |              
 CAPTURE   |          33.45 |      29.90 |      30135 |          901 |              
 OSD0           |           0.50 |    1988.96 |        453 |          901 |              
 AEWB          |           1.43 |     697.91 |       1291 |          901 |              
                                                                                   
                                                                                   
 Module        | Avg Time/Frame | Frame-rate | Total time | Total Frames |              
 CAPTURE  |          33.44 |      29.90 |      30129 |          901 |              
 OSD0          |           0.50 |    2006.68 |        449 |          901 |              
 AEWB         |           1.44 |     696.83 |       1293 |          901 |              

It seems the STREAM and ENCODE task stoped.

I add new resolution by add a new AVSERVER_UI_CAPTURE_MODE :

typedef enum{
    AVSERVER_UI_CAPTURE_MODE_D1 = 0,
    AVSERVER_UI_CAPTURE_MODE_D1_D1,
    AVSERVER_UI_CAPTURE_MODE_720P,
    AVSERVER_UI_CAPTURE_MODE_720P_VGA,
    AVSERVER_UI_CAPTURE_MODE_720P_VGA_30,
    AVSERVER_UI_CAPTURE_MODE_720P_720P,
    AVSERVER_UI_CAPTURE_MODE_720P_720P_30,
    AVSERVER_UI_CAPTURE_MODE_720P_MAX,
    AVSERVER_UI_CAPTURE_MODE_1080P,
    AVSERVER_UI_CAPTURE_MODE_1080P_D1,
    AVSERVER_UI_CAPTURE_MODE_SXVGA,
    AVSERVER_UI_CAPTURE_MODE_2_MEGA,
    AVSERVER_UI_CAPTURE_MODE_3_MEGA,
    AVSERVER_UI_CAPTURE_MODE_5_MEGA,
    AVSERVER_UI_CAPTURE_MODE_CIF           <--------------------added
}AVSERVER_UI_CAPTURE_MODE;

And while the user choosing H264:CIF resolution, the cmd ./av_server.out DM365 CIF H264 3000000 VBR will run on linux.

Then I add the switch case to set config  as below :

  switch(gAVSERVER_UI_config.mode) {
         case AVSERVER_UI_CAPTURE_MODE_CIF:
            config->sensorMode                  = gAVSERVER_UI_config.winmodeEnable?DRV_IMGS_SENSOR_MODE_1920x1080:DRV_IMGS_SENSOR_MODE_352x288;
            config->sensorFps                   = 30;
              config->aewb_config.aewbBinEnable    = TRUE;

            config->vstabTskEnable      = gAVSERVER_UI_config.vsEnable;
            config->ldcTskEnable        = gAVSERVER_UI_config.ldcEnable;
            config->vnfTskEnable        = (gAVSERVER_UI_config.snfEnable | gAVSERVER_UI_config.tnfEnable);
            config->encryptTskEnable    = FALSE;

            config->captureSingleResize = FALSE;
            config->captureYuvFormat    = DRV_DATA_FORMAT_YUV420;

            config->numCaptureStream    = 2;

            if(numEncodes > config->numCaptureStream)
              numEncodes = config->numCaptureStream;

            config->numEncodeStream     = numEncodes;

            config->faceDetectConfig.captureStreamId = 1;
            config->faceDetectConfig.fdEnable        = gAVSERVER_UI_config.fdEnable;

            config->displayConfig.captureStreamId    = 0;
            config->displayConfig.width              = 640;
            config->displayConfig.height             = 480;
            config->displayConfig.expandH               = TRUE;

            i=0;

            k=0;
            config->captureConfig[i].width              = 352;
            config->captureConfig[i].height             = 288;

            config->captureConfig[i].ldcEnable          = gAVSERVER_UI_config.ldcEnable;
            config->captureConfig[i].snfEnable          = gAVSERVER_UI_config.snfEnable;
            config->captureConfig[i].tnfEnable          = gAVSERVER_UI_config.tnfEnable;
            config->captureConfig[i].vsEnable           = gAVSERVER_UI_config.vsEnable;

            if(numEncodes>0)
              config->captureConfig[i].numEncodes       = ((gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P)||(gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P_30))?2:1;

            config->captureConfig[i].encodeStreamId[k++]= 0;
            if((gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P)||(gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P_30))
                config->captureConfig[i].encodeStreamId[k++]= 1;

            config->captureConfig[i].frameSkipMask      = 0x3FFFFFFF;
            i++;

            k=0;
            config->captureConfig[i].width              = 320;
            config->captureConfig[i].height             = 192;
            config->captureConfig[i].ldcEnable          = gAVSERVER_UI_config.ldcEnable;
            config->captureConfig[i].snfEnable          = (numEncodes>1)?gAVSERVER_UI_config.snfEnable:FALSE;
            config->captureConfig[i].tnfEnable          = (numEncodes>1)?gAVSERVER_UI_config.tnfEnable:FALSE;
            config->captureConfig[i].vsEnable           = gAVSERVER_UI_config.vsEnable;

            if(numEncodes>1)
              config->captureConfig[i].numEncodes       = ((gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P)||(gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P_30))?0:1;

            config->captureConfig[i].encodeStreamId[k++]= 1;

            config->captureConfig[i].frameSkipMask      = (gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P)?0x1AAAAAAA:0x3FFFFFFF;
            i++;

            i=0;
          
            config->encodeConfig[i].captureStreamId              = 0;
            config->encodeConfig[i].cropWidth                    = ALIGN_ENCODE(352);
            config->encodeConfig[i].cropHeight                   = ALIGN_ENCODE(288);

            config->encodeConfig[i].frameRateBase                   = config->sensorFps*1000;
            config->encodeConfig[i].frameSkipMask                = 0x3FFFFFFF;
            config->encodeConfig[i].codecType                    = gAVSERVER_UI_config.codecType[i];
            config->encodeConfig[i].codecBitrate                 = gAVSERVER_UI_config.codecBitrate[i];
            config->encodeConfig[i].encryptEnable                = FALSE;
            config->encodeConfig[i].fileSaveEnable               = FALSE;
            config->encodeConfig[i].motionVectorOutputEnable     = FALSE;
            config->encodeConfig[i].qValue                       = gAVSERVER_UI_config.codecBitrate[i];
            i++;

            if((gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P)||(gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P_30)) {
              config->encodeConfig[i].captureStreamId         = 0;
                config->encodeConfig[i].cropWidth               = ALIGN_ENCODE(1280);
                config->encodeConfig[i].cropHeight              = ALIGN_ENCODE(720);
                config->encodeConfig[i].frameRateBase             = (gAVSERVER_UI_config.mode==AVSERVER_UI_CAPTURE_MODE_720P_720P)?(config->sensorFps*1000)>>1:(config->sensorFps*1000);
            }
            else {
              config->encodeConfig[i].captureStreamId         = 1;
                config->encodeConfig[i].cropWidth               = ALIGN_ENCODE(320);
                config->encodeConfig[i].cropHeight              = ALIGN_ENCODE(192);
                config->encodeConfig[i].frameRateBase             = (config->sensorFps*1000);
              }
            config->encodeConfig[i].frameSkipMask             = 0x3FFFFFFF;
            config->encodeConfig[i].codecType                    = gAVSERVER_UI_config.codecType[i];
            config->encodeConfig[i].codecBitrate                 = gAVSERVER_UI_config.codecBitrate[i];
            config->encodeConfig[i].encryptEnable                = FALSE;
            config->encodeConfig[i].fileSaveEnable               = FALSE;
            config->encodeConfig[i].motionVectorOutputEnable     = FALSE;
            config->encodeConfig[i].qValue                       = gAVSERVER_UI_config.codecBitrate[i];
            i++;

             break;

Can someone tell me why this happened, please.

Do I miss something important ?

Thanks a lot.

 

Regards,

Stevie.

  • Hello Stevie,

    Have you checked that the "CIF" mode you have added is correctly handled in av_capture/application/ipnc/av_server/src/common/avServerMain.c ? This does the binning to the piece of code you have added above. This should be something like

     if(strcmp(argv[i], "CIF")==0)
          gAVSERVER_UI_config.mode =
    AVSERVER_UI_CAPTURE_MODE_CIF;

    You may check also that a command like 'echo "720P-60" > /sys/class/davinci_display/ch0/mode' should not fail

    Regards

    Guillaume

  • I found that I didn't added framerate in framerate table enc_framerate_day_1_dm365[10][6][4],

    So I added it as

    const unsigned int enc_framerate_day_1_dm365[10][6][4] =
    {
        {
            {30000,24000,15000,8000},
            {30000,24000,15000,8000},
            {30000,24000,15000,8000},
            {23000,15000,8000},
            {45000},
            {45000,30000,15000,8000}, 
        },

    then it is working fine.

    Thanks.

    Regards,

    Stevie.

  • Hello Guillaume,

    Thank you for your reply.

    I did add the code in avServerMain.c as below

         if(strcmp(argv[i], "352CIF")==0) //Stevie ADDED 20110513
             gAVSERVER_UI_config.mode = AVSERVER_UI_CAPTURE_MODE_CIF;

    And I found that the problem is that I didn't add the frame rate table in framerate_tables.c with corresponding frame rate,

    so the variable frameSkipMask will be set to 0 , then encoder will skip all frame.

    I have solved the problem by adding code in framerate_tables.c

    const unsigned int enc_framerate_day_1_dm365[10][6][4] =
    {
        {
            {30000,24000,15000,8000},
            {30000,24000,15000,8000},
            {30000,24000,15000,8000},
            {23000,15000,8000},
            {45000},
            {45000,30000,15000,8000},  
        },

    Then it is work.

    Thank you.

    Regards,

    Stevie