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 support create two h264enc on dm365

hi,
 i want to encode one video stream twice with different resolution,and will encode to jpeg file,should i create two h264 codecs?like follow config file:
var MPEG4ENC = xdc.useModule('ti.sdo.codecs.mpeg4enc.ce.MPEG4ENC');
var H264ENC = xdc.useModule('ti.sdo.codecs.h264enc.ce.H264ENC');
var JPEGENC = xdc.useModule('ti.sdo.codecs.jpegenc.ce.JPEGENC');
var G711ENC = xdc.useModule('viga.sdo.codecs.g711.G711ENC');
var SPEEXENC = xdc.useModule('viga.sdo.codecs.speex.SPEEXENC');
var Engine = xdc.useModule('ti.sdo.ce.Engine');
var myEngine = Engine.create("encode", [
    {name: "mpeg4enc", mod: MPEG4ENC, local: true, groupId: 1},
    {name: "h264enc", mod: H264ENC, local: true, groupId: 1},
    {name: "h264enc2", mod: H264ENC, local: true, groupId: 1},
    {name: "jpegenc", mod: JPEGENC, local: true,groupId: 1},
    {name: "g711enc", mod: G711ENC, local: true},
    {name: "speexenc", mod: SPEEXENC, local: true},
]);
i create two h264enc in two differrent threads,and got this:
CMEMK Error: Failed to find a pool which fits 56
CMEM Error: getPool: Failed to get a pool fitting a size 56
Error: Failed to create video encoder: h264enc2

i you want get more info tell me,thank you.
  • Hi Yangchar,

    Pl solve CMEM allocation issues by adding required pool in loadmodule.sh, and run the encoder with codec debug library to get the reason codec creation failure. To run the codec with debug library link your app with h264venc_ti_arm926_debug.a lib OR rename h264venc_ti_arm926.a to h264venc_ti_arm926_production.a and h264venc_ti_arm926_debug.a to h264venc_ti_arm926.a.

    Thannks,

    Veeranna

  • hi Veeranna,

    thank you so much to answer my question,and i think i should tell you more details:

    i work in dvsdk_2_10_01_18 and my h264 codec and jpeg codec version are H264ENC.version.01.00.00.18.wizardversion.0.5.2  JPEGENC.version.01.00.00.05.wizardversion.0.5.2, i did not see h264venc_ti_arm926_debug.a,so i change h264 codec to H264ENC.version.02.10.00.06.wizardversion.0.5.2, but i got the same error print info:

    root@192.168.4.230:/opt/viga# ./encode -v enc.264 -s enc.spx -j enc.jpg
    Encode demo started.
    CMEMK Error: Failed to find a pool which fits 384
    CMEM Error: getPool: Failed to get a pool fitting a size 384
    Error: Failed to create speech decoder: speexenc
    davinci_previewer davinci_previewer.2: ipipe_set_preview_config
    davinci_previewer davinci_previewer.2: ipipe_set_preview_config
    vpfe ccdc capture vpfe ccdc capture.1: IMP chained
    vpfe ccdc capture vpfe ccdc capture.1: Resizer present
    CMEMK Error: Failed to find a pool which fits 1808
    CODEC_DEBUG_ENABLE: Inside FuntiCMEMK Error: Failed to find a pool which fits 1808
    on to get memtab Requirement -> CMEMK Error: Failed to find a pool which fits 0
    H264VENC_TI_numAlloc
    CODEC_DEBUG_ENABLE: Number of memtabs required: 15
    CODEC_DEBUG_ENABLE: Inside Funtion to get memtab Requirement -> H264VENC_TI_numAlloc
    CODEC_DEBUG_ENABLE: Number of memtabs required: 15
    CODEC_DEBUG_ENABLE: Inside Funtion to Get Memory Requirements of the current algoirthm instance -> H264VENC_TI_alloc
    CODEC_DEBUG_ENABLE: H264VENC_TI_Obj-memTab[0].size = 0x0710
    CODEC_DEBUG_ENABLE: tH264EncState-memTab[1].size = 0x1670
    CODEC_DEBUG_ENABLE: tH264EncState-memTab[2].size = 0x1670
    CODEC_DEBUG_ENABLE: EXT_MEM_SCRATCH-memTab[3].size = 0x5000
    CODEC_DEBUG_ENABLE: EXT_MEM_PERSIST-memTab[4].size = 0x0800
    CODEC_DEBUG_ENABLE: MAX_REF_BUFFERS-memTab[5].size = 0x23e080
    CODEC_DEBUG_ENABLE: LIST_SLICE_SIZES-memTab[6].size = 0x0320
    CODEC_DEBUG_ENABLE: Inside Funtion to Get Memory Requirements of the current algoirthm instance -> H264VENC_TI_alloc
    CODEC_DEBUG_ENABLE: H264VENC_TI_Obj-memTab[0].size = 0x0710
    CODEC_DEBUG_ENABLE: tH264EncState-memTab[1].size = 0x1670
    CODEC_DEBUG_ENABLE: tH264EncState-memTab[2].size = 0x1670
    CODEC_DEBUG_ENABLE: EXT_MEM_SCRATCH-memTab[3].size = 0x5000
    CODEC_DEBUG_ENABLE: EXT_MEM_PERSIST-memTab[4].size = 0x0800
    CODEC_DEBUG_ENABLE: MAX_REF_BUFFERS-memTab[5].size = 0x17eb00
    CODEC_DEBUG_ENABLE: LIST_SLICE_SIZES-memTab[6].size = 0x0320
    CODEC_DEBUG_ENABLE: uiMaxCodeSize-memTab[7].size = 0xcd78
    CODEC_DEBUG_ENABLE: uiMaxCodeSize-memTab[8].size = 0xcd78
    CODEC_DEBUG_ENABLE: KALEIDO_COMMANDS-memTab[9].size = 0x10180
    CODEC_DEBUG_ENABLE: AIR_BIT_STORAGE-memTab[10].size = 0x20000
    CODEC_DEBUG_ENABLE: AIR_BIT_STORAGE-memTab[11].size = 0x40000
    CODEC_DEBUG_ENABLE: tStPhysicalAddrHandle-memTab[12].size = 0x0280
    CODEC_DEBUG_ENABLE: IMCOP_TO_DDR-memTab[13].size = 0xc000
    CODEC_DEBUG_ENABLE: MEGAPIX_IMCOP_TO_DDR-memTab[14].size = 0x3900
    CODEC_DEBUG_ENABLE: Exiting Funtion H264VENC_TI_alloc
    CMEM Error: getPool: Failed to get a pool fitting a size 1808
    Error: Failed to create video encoder: h264enc2
    CODEC_DEBUG_ENABLE: uiMaxCodeSize-memTab[7].size = 0xcd78
    CODEC_DEBUG_ENABLE: uiMaxCodeSize-memTab[8].size = 0xcd78
    CODEC_DEBUG_ENABLE: KALEIDO_COMMANDS-memTab[9].size = 0x10180
    CODEC_DEBUG_ENABLE: AIR_BIT_STORAGE-memTab[10].size = 0x20000
    CODEC_DEBUG_ENABLE: AIR_BIT_STORAGE-memTab[11].size = 0x40000
    CODEC_DEBUG_ENABLE: tStPhysicalAddrHandle-memTab[12].size = 0x0280
    CODEC_DEBUG_ENABLE: IMCOP_TO_DDR-memTab[13].size = 0xc000
    CODEC_DEBUG_ENABLE: MEGAPIX_IMCOP_TO_DDR-memTab[14].size = 0x3900
    CODEC_DEBUG_ENABLE: Exiting Funtion H264VENC_TI_alloc
    CMEM Error: getPool: Failed to get a pool fitting a size 1808
    Error: Failed to create video encoder: h264enc
    Error: Failed to joinin video RTS
    CMEM Error: getPool: Failed to get a pool fitting a size 0
    Failed to allocate memory.
    Error: Failed to allocate contiguous buffers
    vpfe ccdc capture vpfe ccdc capture.1: hpitch = 720, vpitch = 576, bpp = 1
    vpfe ccdc capture vpfe ccdc capture.1: hpitch = 720, vpitch = 576, bpp = 1
    Starting ccdc_config_ycbcr...<7>
    starting ccdc_reset...<7>
    End of ccdc_reset...<7>
    Starting ccdc_setwin...<7>ipipe_set_resizer, resizer - A enabled
    DavinciDisplay DavinciDisplay.1: Before finishing with S_FMT:
    layer.pix_fmt.bytesperline = 736,
    layer.pix_fmt.width = 720,
    layer.pix_fmt.height = 576,
    layer.pix_fmt.sizeimage =635904
    DavinciDisplay DavinciDisplay.1: pixfmt->width = 720,
    layer->layer_info.config.line_length= 736

    loadmodules.sh
    # Pools configuration
    insmod cmemk.ko phys_start=0x84000000 phys_end=0x88000000
    pools=4x56,1x384,1x1344,6x4096,2x8192,1x11908,2x13184,1x2697152,6x4096,1x30720,3x81920,1x3185664,64x56,1x320,1x640,1x81920,1x6650880,2x608,1x296,1x28,2x24,30x1548288,1x1542881x154288 allowOverlap=1 phys_start_1=0x00001000 phys_end_1=0x00008000 pools_1=1x28672

    H264ENC.version.02.10.00.06.wizardversion.0.5.2
    var MPEG4ENC = xdc.useModule('ti.sdo.codecs.mpeg4enc.ce.MPEG4ENC');
    var H264ENC = xdc.useModule('ti.sdo.codecs.h264enc.ce.H264ENC');
    var JPEGENC = xdc.useModule('ti.sdo.codecs.jpegenc.ce.JPEGENC');
    var G711ENC = xdc.useModule('viga.sdo.codecs.g711.G711ENC');
    var SPEEXENC = xdc.useModule('viga.sdo.codecs.speex.SPEEXENC');
    var Engine = xdc.useModule('ti.sdo.ce.Engine');
    var myEngine = Engine.create("encode", [
    {name: "mpeg4enc", mod: MPEG4ENC, local: true, groupId: 1},
    {name: "h264enc", mod: H264ENC, local: true, groupId: 1},
    {name: "h264enc2", mod: H264ENC, local: true, groupId: 1},
    {name: "jpegenc", mod: JPEGENC, local: true,groupId: 1},
    {name: "g711enc", mod: G711ENC, local: true},
    {name: "speexenc", mod: SPEEXENC, local: true},
    ]);

    i'm realy confused why the cmem need a pool fitting a size 0?

    BTW,the encode can work  with  two H264ENC and H264ENC+JPEGENC,but when i run  two H264ENC+JPEGENC i got this error; and i also change the H264ENC and JPEGENC run in parallel(link),i alse got this message.

    wish you can replay me soon.

                                                                                           yangchar

                          

  • Hi,

    yangchar said:
    i'm realy confused why the cmem need a pool fitting a size 0?

    Pl solve CMEM errors before this, once you solve those you will not get such a error. As you are going to create 2 encoders so requirement of pool will be more, so please allocate enough pools.

    Thanks,

    Veeranna

  • hi,Veeranna

    i'm so sorry,i don't understand what PI means?and i think i have allocated enough pools,thanks.

    Regards,

    yangchar

  • Hi,

    I am sorry not being clear. I meant there cmem pool errors before zero size error. I wanted you to fix them. And in log I am not seeing any codec related error to cause codec creation failure.

    Thanks,

    Veeranna

  • hi,Veeranna 

    i really did what you want me to do,i add pools like this:

    pools=4x56,16x384,16x1344

    but i got error print messages like

    CMEMK Error: Failed to find a pool which fits 384
    CMEM Error: getPool: Failed to get a pool fitting a size 384

    so i don't know what to do next,and thank you so much.

    Regards,

    yangchar


  • Hi Yangchar,

    You can use heap for the codecs by making ALG_MEM.useHeap = true; in alg_server.cfg file.

    Also you should NOT have 2 entries for H264 encoder in the codec engine config table.

    But you can create multiple instances of the H264 encoder.

    regards,

    Anand

  • Hi, Anand

         It's works,thank you so much,but i want to know why can't i create 2 entries for  H264 encoder(it  also can work)?

        Does two entries  will cost more resources of CMEM  ?

    regards,

    yangchar