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.

Clarifications on H264 Encoder resolution on DM365

Hi to all, I'm using dvsdk 2.10.01.18 on the DM365 platform. Codec Engine version is 2.24 and codec version is 01.00.06. I use DMAI v. 1.21.00.10.

There are two points I'd like to address:

When I try to encode H264 video streams, the encoder can only be initialized for resolutions 1280x720, 720x480, 720x576 and 640x480. That is, when I try to create an H264 encoder with resolution 1024x768 (for example), the Venc1_create call fails with this log (I used CE_DEBUG=2):

Creating an encoder instance in the InstanceTable, hjEngine is @ 0xeaaec, encoder name is h264enc
@1,348,002us: [+2 T:0x4001eed0] ti.sdo.dmai - [Venc1] Creating encoder h264enc for max 1024x768 bitrate 4000000 ratectrl 1
@1,349,857us: [+0 T:0x4001eed0] ti.sdo.ce.video1.VIDENC1 - VIDENC1_create> Enter (engine=0xed380, name='h264enc', params=0xbe901a8c)
@1,351,542us: [+0 T:0x4001eed0] CV - VISA_create(0xed380, 'h264enc', 0xbe901a8c, 0x2496, 'ti.sdo.ce.video1.IVIDENC1')
@1,353,498us: [+0 T:0x4001eed0] CV - VISA_create2(0xed380, 'h264enc', 0xbe901a8c, 0x30, 0x2496, 'ti.sdo.ce.video1.IVIDENC1')
@1,355,177us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_create> Enter(fxns=0xea640, idma3Fxns=0x0, iresFxns=0xea6cc, params=0xbe901a8c, attrs=0xbe90189c)
@1,357,059us: [+0 T:0x4001eed0] ti.sdo.ce.alg - ALG_create> Enter (scratchId=1, fxns=0xea640, parentAlg=0x0, params=0xbe901a8c)
@1,358,794us: [+2 T:0x4001eed0] ti.sdo.ce.alg - ALG_create> algNumAlloc 12 memory recs
@1,360,784us: [+7 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_create> Algorithm creation FAILED; make sure that 1) alg params are correct/appropriate, 2) there is enough internal and external algorithm memory available -- check DSKT2 settings for heap assignments and scratch allocation
@1,362,708us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_delete> Enter(alg=0xed5f0)
@1,364,514us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_delete> Exit
@1,366,104us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_create> return (0x0)
@1,367,835us: [+2 T:0x4001eed0] CV - VISA_create2> FAILED to create local codec.
@1,369,423us: [+0 T:0x4001eed0] CV - VISA_delete(0xed5b8)
@1,371,169us: [+5 T:0x4001eed0] CV - VISA_delete> deleting codec (localQueue=0xffff, remoteQueue=0xffff)
@1,372,916us: [+0 T:0x4001eed0] ti.sdo.ce.video1.VIDENC1 - VIDENC1_create> return (0x0)
@1,374,676us: [+7 T:0x4001eed0] ti.sdo.dmai - [Venc1] Failed to open video encode algorithm: h264enc (0x0)
ERR[/home/janesconference/develop/progetti/NetBeans projects/brahma/Brahma/365Encoder.c, initEncoderInstance(), 141]: Failed to create video encoder: h264enc

The same for 800x600 resolution. What can the problem be? Are there two resolutions (1024x768 and 800x600) not supported by codec version 01.00.06 or am I doing something wrong?

 

The second point is that, while 1280x720 and 640x480 resolution seem to encode smoothly, 720x480 and 720x576 give me strange "slanted" frames, as if the input buffer addresses are wrong or off-set. Is this a known behaviour?

  • Hi,

    First I suggest you to move the the latest version of codec. The migration and download link can be obtained from http://processors.wiki.ti.com/index.php/Migration/Integration_Guide_for_DM36x_H.264_version_2.x_codecs

    Let me know if you face any issue.

    Regarding the slanted frame, I suggest that you check the input buffer pointer you are passing to the codec. These resolutions are verfied working fine in the codec and demo.

    regards

    Yashwant

  • Yashwant Dutt said:

    Hi,

    First I suggest you to move the the latest version of codec. The migration and download link can be obtained from http://processors.wiki.ti.com/index.php/Migration/Integration_Guide_for_DM36x_H.264_version_2.x_codecs

    Let me know if you face any issue.

    Regarding the slanted frame, I suggest that you check the input buffer pointer you are passing to the codec. These resolutions are verfied working fine in the codec and demo.

    regards

    Yashwant

    HI, I migrated to the latest version of codec (02_00_00_10_production) and it resolved my past issues, but it caused another: when I try to encode 1920x1080, the codec initializes correctly, but Venc1_process returns an error. This is the log on the first frame I try to encode with CE_DEBUG=2:

    @2,253,086us: [+0 T:0x4001eed0] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Enter (handle=0x10d5e0, inBufs=0xbe9259d0, outBufs=0xbe9259c4, inArgs=0xbe9259b4, outArgs=0xbe92593c)
    @2,254,736us: [+5 T:0x4001eed0] CV - VISA_enter(visa=0x10d5e0): algHandle = 0x10d618
    @2,256,285us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x10d618)
    @2,257,942us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit
    @2,259,569us: [+5 T:0x4001eed0] CV - VISA_exit(visa=0x10d5e0): algHandle = 0x10d618
    @2,261,122us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x10d618)
    @2,262,921us: [+0 T:0x4001eed0] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit
    @2,264,480us: [+0 T:0x4001eed0] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Exit (handle=0x10d5e0, retVal=0xffffffff)
    @2,266,062us: [+2 T:0x4001eed0] ti.sdo.dmai - [Venc1] VIDENC1_process() ret -1 inId 0 outID 69363 generated 0 bytes
    @2,267,673us: [+7 T:0x4001eed0] ti.sdo.dmai - [Venc1] VIDENC1_process() failed with error (-1 ext: 0x8006)

  • Hi,

    Did you upgrade to the specified version of FC and LinuxUtils as said in the migration guide ?

    regards

    Yashwant

  • Yashwant Dutt said:

    Hi,

    Did you upgrade to the specified version of FC and LinuxUtils as said in the migration guide ?

    regards

    Yashwant

    Hi, yes, I did. I now have

    linuxutils_2_24_03
    framework_components_2_24_01
    xdais_6_25_02_11

    as specified in the migration guide.

    Please note that 1280x960 works perfectly, and that 1920x1080 only fails at encoding, not at creating the H264 encoder instance (so it's not a cmem pools problem).

    I tried to trace the logs many times, and the problems seems to generate the same outID and ext error code everytime:

    ti.sdo.dmai - [Venc1] VIDENC1_process() ret -1 inId 0 outID 69363 generated 0 bytes
    ti.sdo.dmai - [Venc1] VIDENC1_process() failed with error (-1 ext: 0x8006)

     

  • Hi,

    Have you ensured that you have set MEMTCM in your codec engine .cfg file? I am showing it for your reference.

    var MEMTCM = xdc.useModule('ti.sdo.fc.ires.memtcm.MEMTCM');
    MEMTCM.cmemBlockId = 1; //Since we use _1 in our insmod command.

    Also, if i look at the error code, it says 0x8006. This means some problem with the INBUFS. Can you ensure that you have got the input buffers allocated correctly for the codec and are passing the buffer address correctly. Also, you might want to check the size of the buffers allocated and passed to the codec.

    Regards,

    Anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

     

  • DVSDK 2.10.00.18 did not have native support of 1080P encode at capture driver layer. Have you done any change in the capture driver/demo layer to support 1080P? Just adding the codec will not let you get 1080P.

    regards

    Yashwant

  • Anshuman Saxena said:

    Hi,

    Have you ensured that you have set MEMTCM in your codec engine .cfg file? I am showing it for your reference.

    var MEMTCM = xdc.useModule('ti.sdo.fc.ires.memtcm.MEMTCM');
    MEMTCM.cmemBlockId = 1; //Since we use _1 in our insmod command.

    Also, if i look at the error code, it says 0x8006. This means some problem with the INBUFS. Can you ensure that you have got the input buffers allocated correctly for the codec and are passing the buffer address correctly. Also, you might want to check the size of the buffers allocated and passed to the codec.

    Regards,

    Anshuman


    Thanks Anshuman, I'll verify these two things and be back to this thread later.

  • Yashwant Dutt said:

    DVSDK 2.10.00.18 did not have native support of 1080P encode at capture driver layer. Have you done any change in the capture driver/demo layer to support 1080P? Just adding the codec will not let you get 1080P.

    regards

    Yashwant

    Yes, we support far more than 1080p in the capture layer (anyway, I can do it in MJPEG with no problems).

    Regards,

    Cristiano.

     

  • Cristiano,

    Please mark this post as verified, if you think it has answered your question. Thanks.

    regards

    yashwant

  • Hi,

    Anshuman Saxena said:

    Hi,

    Have you ensured that you have set MEMTCM in your codec engine .cfg file? I am showing it for your reference.

    var MEMTCM = xdc.useModule('ti.sdo.fc.ires.memtcm.MEMTCM');
    MEMTCM.cmemBlockId = 1; //Since we use _1 in our insmod command.

    Yes, I got these lines in the .cfg

     

    Anshuman Saxena said:

    Also, if i look at the error code, it says 0x8006. This means some problem with the INBUFS. Can you ensure that you have got the input buffers allocated correctly for the codec and are passing the buffer address correctly. Also, you might want to check the size of the buffers allocated and passed to the codec.

    My INBUFS are an array of DMAI Buffer_Handle.

     

    Because we allocate them directly in our driver, each of them is a reference  buffer (attrs->reference = 1) and is set to a length of (width * height * 3) / 2; please note that this kind of configuration works *perfectly* for all the other resolution; I experience error (-1 ext: 0x8006) *only* when I try to encode with width = 1920 height = 1080.

    Regards,

    Cristiano.

  • Additionally, I perform Buffer_print() on the INBUF and the OUTBUF before encoding:

    Buffer_print (inBuf);
    Buffer_print (outBuf);

    and what I get is:

    [0] @ 0x4034c020 (0x86000020 phys) numBytes 3110400 (3110400) useMask 0 (0) ref yes
        Width 1920, Height 1080, LineLength 1920
    [0] @ 0x431ed000 (0x8f69e000 phys) numBytes 0 (3133440) useMask 0 (1) ref no
        Width 1920, Height 1080, LineLength 1920

    To me, everything is regular, but then Venc1_process can't encode the frame.

  • Hi,

    Since 1080P is a non multiple of 16, you need to make sure that the buffer gives is atleast multiple of 16. Please see http://processors.wiki.ti.com/index.php/DM36x_H.264_encoder_FAQ , item 1 for more details. Hopefully this should solve the problem.

    regards

    Yashwant

  • Yashwant Dutt said:

    Hi,

    Since 1080P is a non multiple of 16, you need to make sure that the buffer gives is atleast multiple of 16. Please see http://processors.wiki.ti.com/index.php/DM36x_H.264_encoder_FAQ , item 1 for more details. Hopefully this should solve the problem.

    regards

    Yashwant

    Great, this should do the trick. I'll try this and come back with the "resolved" state if everything goes well :)

    Thank you,

    Cristiano.

  • Hi Cristiano,

    i am getting similar problem for encoding video at 1920x1080 resolution. all other resolution it works fine.

    i was going through Yashwant's suggestion, but i have already taken care of buffer size multiple of 16.

    still i am getting the same error code 0x8006 before process call.

    following are my buffer sizes.

    ------------------------------------

    input buffer 0 size = 2088960 

    input buffer 0 address = 474bc000 

    input buffer 1 size = 1044480 

    input buffer 1 address = 476b6400 

    Fail to encode H264 with error (-1 ext :0x8006)

    width = 1920 

    height = 1080 

    lineLength = 1920 

    -----------------------------------

    can you please let me know what you have done for the same.

  • Hi Yashwant,

    i am getting similar problem for encoding video at 1920x1080 resolution. all other resolution it works fine.

    i was going through your suggestion, but i have already taken care of buffer size multiple of 16.

    still i am getting the same error code 0x8006 before process call. no video encode happens.

    following are my buffer sizes.

    ------------------------------------

     

    input buffer 0 size = 2088960 

    input buffer 0 address = 474bc000 

    input buffer 1 size = 1044480 

    input buffer 1 address = 476b6400 

    Fail to encode H264 with error (-1 ext :0x8006)

    width = 1920 

    height = 1080 

    lineLength = 1920 

     

    -----------------------------------

     

  • Hi

    got the problem solved.

    the problem was even though i have taken care of the buffer size, 

    my inputbuffer.frameHeight  parameter was going thru encoder as 1080 only.

    i modified to 1088 and it's working fine.