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.

Is there a Demo for JPEG 2K encoder ( Not Transcoding)

Hi,

I have executed the J2k Transcoder, but it saves the file in  .RAW file, but i would like to if there is a demo for J2K Encoder which encodes YUV File into JPEG 2000 and saves the output in J2K... It would be great to have your guidance regarding this.

And one more thing i wanted to know is how can we play the .RAW file in Ubuntu, i have installed MPlayer aswellas VLC but nothing plays it. Would like to have your guidance.

Thanks and Regards

Venkatesh

  • Venkatesh,

    You've made several related posts on the same subject matter recently.  Please follow up to your existing posts instead of creating new posts when dealing with the same basic subject matter.

    Best Regards,

    Chad

  • Dear sir

    I am privileged to receive your response. But i couldnt find any post related to my query. If you know any solution or related answer please do share it here,  sorry for any inconvenience caused. 

    Thanks and regards

    Venkatesh Padmanabhan

  • Hi Venkatesh,

    Please run "demoDisplay.sh" (instead of "demoSave2File.sh") to display the output of J2K Transcoder.

    J2KENC demo has been included in the package of MCSDK Video for the TFTP mode @ mcsdk_video_2_1_0_8\dsp\siu\vct\testVecs\j2kenc. If you would like to create J2KENC demo for the PCIe mode, please use J2KDEC as the starting point. Then, use "-a J2KENC" in demoSave2File.sh. For codecParams.cfg, please take "static_param*, dynamic_param*, inargs*" from dsp\siu\vct\testVecs\j2kenc\codecParams.cfg. Also please update "multiClip.cfg" for your input/output file names.

    Thanks,

    Hongmei

  • Dear sir

    I am privileged with your response. I did just as you said but i am getting this error while reading the file,

    Number of Channels supported : 1

    checkHostBufReqs() Complete.

    Channel 1 Configuration:

    Channel . ..... 1
    Algorithm ..... J2KENC
    Width ......... 1998
    Height ........ 1080
    Verbosity ..... 0
    Team 1 ........ 0
    Team 2 ........ 1
    Team 3 ........ 2
    Team 4 ........ 3
    Team 5 ........ 4
    Team 6 ........ 5
    Team 7 ........ 6
    Team 8 ........ 7
    Team 9 ........ 8
    Team 10 ........ 9
    Team 11 ........ 10
    Team 12 ........ 11
    Team 13 ........ 12
    Team 14 ........ 13
    Team 15 ........ 14
    Team 16 ........ 15
    Team 17 ........ 16
    Team 18 ........ 17
    Team 19 ........ 18
    Team 20 ........ 19
    Team 21 ........ 20
    Team 22 ........ 21
    Team 23 ........ 22
    Team 24 ........ 23
    Team 25 ........ 24
    Team 26 ........ 25
    Team 27 ........ 26
    Team 28 ........ 27
    Team 29 ........ 28
    Team 30 ........ 29
    Team 31 ........ 30
    Team 32 ........ 31


    Node Mapping:
    1 2 3 4 5 6 7 8
    9 10 11 12 13 14 15 16
    17 18 19 20 21 22 23 24
    25 26 27 28 29 30 31 32

    initDevices() Complete.
    createDeviceIO(0) Complete.
    createDeviceIO(1) Complete.
    createDeviceIO(2) Complete.
    createDeviceIO(3) Complete.
    sendDeviceConfig(0) Complete.
    createOutputPipe(0) Complete.
    createReorder(0) Complete.
    createScheduler(0) Complete.
    utils_create_timer(0) Complete.
    ackDeviceConfig(0) Complete.
    [ERROR] FileReaderCreate(1) : Could not open input.yuv for reading. Terminating creation of thread.
    Error returned by createFileReader(0). Error code -1
    Terminating remaining threads...
    Test Complete.

    It would be great honour if you could guide me about this, 

    I first used the OUTPUT file produced for J2K DECODER as input but it couldnt process it, the terminal just stuck, then i again changed the input as YUV which i used for J2K Transcoding, but when i use this i get the above output, i used some other YUV formats too but no solution. It would be great if you can show lights on this issue.

    Thanks and regards

    Venkatesh Padmanabhan

  • Dear sir

    I tried changing the input files but there is no use. I am always getting the error please tell me whats the problem.

    ../testVecs/input/input.wmv
    ../testVecs/output/output.j2k
    440

    THE ABOVE IS My MULTICLIP.CFG FILE, I have changed the input with yuv, and 264 formats too but no change in the error.

    #!/bin/sh

    CLIP_CONFIG=multiClip.cfg
    CODEC_PARAMS=codecParams.cfg
    FRAME_RATE=24

    $MCSDK_VIDEO_HOSTBIN_DIR/demo_c667x -a J2KENC -f $CLIP_CONFIG -c $CODEC_PARAMS -t 0:31 --width=1998 --height=1080 --display-width=1280 --display-height=1024 --display-rate=$FRAME_RATE -i 100

    THIS IS MY DemoDisplay.sh

    #!/bin/sh

    CLIP_CONFIG=multiClip.cfg
    CODEC_PARAMS=codecParams.cfg

    $MCSDK_VIDEO_HOSTBIN_DIR/demo_c667x -a J2KENC -f $CLIP_CONFIG -c $CODEC_PARAMS -t 0:31 --width=1998 --height=1080

    This is My DemoSave2File.sh

    Awaiting your response.

    Thanks and regards

    Venkatesh Padmanabhan

  • if i use RAW output which i got using J2K Decoder i get the following error.

    checkHostBufReqs() Complete.

    Channel 1 Configuration:

    Channel . ..... 1
    Algorithm ..... J2KENC
    Width ......... 1998
    Height ........ 1080
    Verbosity ..... 0
    Team 1 ........ 0
    Team 2 ........ 1
    Team 3 ........ 2
    Team 4 ........ 3
    Team 5 ........ 4
    Team 6 ........ 5
    Team 7 ........ 6
    Team 8 ........ 7
    Team 9 ........ 8
    Team 10 ........ 9
    Team 11 ........ 10
    Team 12 ........ 11
    Team 13 ........ 12
    Team 14 ........ 13
    Team 15 ........ 14
    Team 16 ........ 15
    Team 17 ........ 16
    Team 18 ........ 17
    Team 19 ........ 18
    Team 20 ........ 19
    Team 21 ........ 20
    Team 22 ........ 21
    Team 23 ........ 22
    Team 24 ........ 23
    Team 25 ........ 24
    Team 26 ........ 25
    Team 27 ........ 26
    Team 28 ........ 27
    Team 29 ........ 28
    Team 30 ........ 29
    Team 31 ........ 30
    Team 32 ........ 31


    Node Mapping:
    1 2 3 4 5 6 7 8
    9 10 11 12 13 14 15 16
    17 18 19 20 21 22 23 24
    25 26 27 28 29 30 31 32

    initDevices() Complete.
    createDeviceIO(0) Complete.
    createDeviceIO(1) Complete.
    createDeviceIO(2) Complete.
    createDeviceIO(3) Complete.
    sendDeviceConfig(0) Complete.
    createOutputPipe(0) Complete.
    createReorder(0) Complete.
    createScheduler(0) Complete.
    ackDeviceConfig(0) Complete.
    createFileReader(0) Complete.
    createDataSrc(0) Complete.
    createFileWriter(0) Complete.
    createDataSnk(0) Complete.
    [ERROR] DeviceIORxThread(0) : Could not find output descriptor corresponding to output buffer 0x00000000

    Waiting to allow debugging... [Press Enter]

    [ERROR] DeviceIORxThread(1) : Could not find output descriptor corresponding to output buffer 0x00000000

    Waiting to allow debugging... [Press Enter]

    i used j2k as output and .raw as input in MULTICLIP.CFG as follows

    ../testVecs/input/img0018.raw
    ../testVecs/output/img0018.j2k
    1



  • Hi Venkatesh,

    I would suggest going step by step of Hongmei's reply. Please see below sanity questions:

    - Using "demoDisplay.sh" is now displaying in your setup J2K transcoding?

    - Have you tried J2KDEC as-is (no modifications), if so, it is working for you?

    - Input clips for JPEG2000 shall be 1920x1080 10-bit 4:2:2 YUV clips. Please check "Preparation for video demos" at http://processors.wiki.ti.com/index.php/MCSDK_VIDEO_2.1_PCIE_Demo_Guide. Please confirm you are using the right YUV input format

    - Could you please share with us used (when running PCI J2KENC) "demoSave2File.sh", "codecParams.cfg" and "multiClip.cfg"?

    - Just wondering, do you have a JTAG?

    Thank you,

    Paula

  • Dear Paula

    1) I have done the j2k transcoding it is working fine, i am able to get the output displayed.

    2) I have also done with the j2k Decoding and it was fine and no problem in the displaying of the output.

    3) I have concatenated the YUV clips as said and used for the demo of Transcoding it was fine, the RAW file was around 4 GB.

    4)I get problem only while changing it into J2K Encoder. I have also attached the message i got in my reply in this same post. Please do check it, it would be great help if you could suggest me where is the problem.

  • Dear Paula i was able to go to the next step, by using the YUV input i used to J2K transcoding but, everytimes it says 

    [ERROR] FileReaderThread(1) : Made 5912 attempts to allocate host input buffer.

    While saving the output to the file, and i am having a j2k output at the output folder but nothing is able to play it. I have tried with mplayer, or VLC. No player is able to play the output of Transcoder or Encoder. Atleast in Transcoder i am able to see the output. But here in Encoder. I am not even able to get a output 

    Channel 1 Configuration:

    Channel . ..... 1
    Algorithm ..... J2KENC
    Width ......... 1998
    Height ........ 1080
    Verbosity ..... 0
    Team 1 ........ 0
    Team 2 ........ 1
    Team 3 ........ 2
    Team 4 ........ 3
    Team 5 ........ 4
    Team 6 ........ 5
    Team 7 ........ 6
    Team 8 ........ 7
    Team 9 ........ 8
    Team 10 ........ 9
    Team 11 ........ 10
    Team 12 ........ 11
    Team 13 ........ 12
    Team 14 ........ 13
    Team 15 ........ 14
    Team 16 ........ 15
    Team 17 ........ 16
    Team 18 ........ 17
    Team 19 ........ 18
    Team 20 ........ 19
    Team 21 ........ 20
    Team 22 ........ 21
    Team 23 ........ 22
    Team 24 ........ 23
    Team 25 ........ 24
    Team 26 ........ 25
    Team 27 ........ 26
    Team 28 ........ 27
    Team 29 ........ 28
    Team 30 ........ 29
    Team 31 ........ 30
    Team 32 ........ 31


    Node Mapping:
    1 2 3 4 5 6 7 8
    9 10 11 12 13 14 15 16
    17 18 19 20 21 22 23 24
    25 26 27 28 29 30 31 32

    initDevices() Complete.
    createDeviceIO(0) Complete.
    createDeviceIO(1) Complete.
    createDeviceIO(2) Complete.
    createDeviceIO(3) Complete.
    sendDeviceConfig(0) Complete.
    createOutputPipe(0) Complete.
    createReorder(0) Complete.
    createScheduler(0) Complete.
    utils_create_timer(0) Complete.
    ackDeviceConfig(0) Complete.
    createFileReader(0) Complete.
    createDataSrc(0) Complete.
    createDisplay(0) Complete.
    createDataSnk(0) Complete.
    [ERROR] utils_wait_period(1) : Missed 21 frame periods.
    [ERROR] utils_wait_period(2) : Missed 1 frame periods.
    [ERROR] utils_wait_period(12) : Missed 1 frame periods.
    [ERROR] utils_wait_period(20) : Missed 1 frame periods.
    [ERROR] utils_wait_period(32) : Missed 1 frame periods.
    [ERROR] utils_wait_period(36) : Missed 1 frame periods.

    It would be great help if you could guide me, regarding this. I am just getting a screen with some distorted images with crossed lines. and the display gets stuck.

  • Hi Venkatesh, please use "demoSave2file.sh" instead of "demoDisplay.sh"

    Thank you,

    Paula

  • Dear Paula

    If i am doing that i am able to save only till 64 th frame in total of 500 frames. It is not able to save after that

    63, outputId 63, outBufPtr 0xAE000000, outBufSize 1251394, freeBufID 0
    [DEBUG] DeviceIORxReceiveFrame(3) : Attempting to DMA from DSP address 0xAE000000 into 4 buffers of the following lengths :
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #0 Phys Addr = 0x000000014B800000, User Addr = 0x8BC5F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #1 Phys Addr = 0x000000014BC00000, User Addr = 0x8B85F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #2 Phys Addr = 0x000000014C000000, User Addr = 0x8B45F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #3 Phys Addr = 0x000000014C400000, User Addr = 0x8B05F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Addr = 0xAE000000, dma_trans_id = 127
    [DEBUG] DeviceIOXferComplete(3) : DMA to device 3 Complete! dma_trans_id = 127
    [DEBUG] DeviceIORxThread(3) : XFER Complete... Polled for DMA completion 1218 times.
    [DEBUG] ReorderPut(1) : ID = 63
    [DEBUG] ReorderPut(1) : Writing to pipe...
    [DEBUG] DeviceIORxThread(3) : Placed message #63 in reorder queue.
    [DEBUG] FileWriterThread(1) : Got message #63
    [DEBUG] FileWriterThread(1) : File 0 / 1, Frame 62 / 500 ...
    [DEBUG] FileWriterThread(1) #62 : Rx Msg. #63, File: ../testVecs/output/output.j2k, Frame #62, Size 1251394 bytes.
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[0].length = 0x00400000
    [DEBUG] DeviceIORxThread(3) : Getting message from node #31 ...
    [DEBUG] DeviceIORxThread(3) : Found Mailbox Msg: Process Count 15, Free Task ID 64, outputId 64, outBufPtr 0xAF000000, outBufSize 1253544, freeBufID 0
    [DEBUG] DeviceIORxReceiveFrame(3) : Attempting to DMA from DSP address 0xAF000000 into 4 buffers of the following lengths :
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #0 Phys Addr = 0x000000014C800000, User Addr = 0x8AC5F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #1 Phys Addr = 0x000000014CC00000, User Addr = 0x8A85F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #2 Phys Addr = 0x000000014D000000, User Addr = 0x8A45F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Buf #3 Phys Addr = 0x000000014D400000, User Addr = 0x8A05F000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(3) : Addr = 0xAF000000, dma_trans_id = 128
    [DEBUG] FileWriterThread(1) : Wrote 1251394 bytes in 1351490 ns.
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[1].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[2].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[3].length = 0x00400000
    [DEBUG] DeviceIOXferComplete(3) : DMA to device 3 Complete! dma_trans_id = 128
    [DEBUG] DeviceIORxThread(3) : XFER Complete... Polled for DMA completion 1223 times.
    [DEBUG] ReorderPut(1) : ID = 64
    [DEBUG] ReorderPut(1) : Writing to pipe...
    [DEBUG] DeviceIORxThread(3) : Placed message #64 in reorder queue.
    [DEBUG] FileWriterThread(1) : Got message #64
    [DEBUG] FileWriterThread(1) : File 0 / 1, Frame 63 / 500 ...
    [DEBUG] FileWriterThread(1) #63 : Rx Msg. #64, File: ../testVecs/output/output.j2k, Frame #63, Size 1253544 bytes.
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[0].length = 0x00400000
    [DEBUG] FileWriterThread(1) : Wrote 1253544 bytes in 1277512 ns.
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[1].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[2].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[3].length = 0x00400000

    The terminal gets stuck. In this line

  • Hi Venkatesh, have you tried separating frames in different files? something like:

    Multiclip.cfg

    ../testVecs/input/1080P50_crowdrun_fr1_422pl_10bit_250fr.yuv

    ../testVecs/output/1080P50_crowdrun_fr1_422pl_10bit_250fr.j2k

    1

    ../testVecs/input/1080P50_crowdrun_fr2_422pl_10bit_250fr.yuv

    ../testVecs/output/1080P50_crowdrun_fr2_422pl_10bit_250fr.j2k

    1

    .........

    ../testVecs/input/1080P50_crowdrun_fr100_422pl_10bit_250fr.yuv

    ../testVecs/output/1080P50_crowdrun_fr100_422pl_10bit_250fr.j2k

    1

    Thank you,

    Paula

  • Hi Paula

    Thank you for your response, but does that mean i should convert every .SGI files into one YUV frame and give as input?. Is this the only way? can you please tell me what are all the other formats that i can give as input? i tried with .RAW as input but it couldnt read the signal, as well as i tried with another YUV file with same resolution i am getting same error that the input cannot be read. Is there any distinct set of input formats which can be given as input? Awaiting your response

    Thanks and regards

    Venkatesh Padmanabhan

  • Dear Paula

    I checked the same again with one more file downloaded and concatenated into YUV, i was able to play it using transcoding but when it comes to j2k Encoder i get stuck at frame number 64 again. I dont know whats the real problem. Awaiting your guidance

    thanks and regards

    Venkatesh Padmanabhan

  • Hi Venkatesh, Jpeg2k enc currently supports RGB, YUV444, YUV422, and YUV420 image formats. If you copied CodecParams.cfg from dsp\siu\vct\testVecs\j2kenc\codecParams.cfg you should have selected:

    static_param9   = 2    # inputChromaFormat: XDM_YUV_422P = 2

    Please check JPEG2K_Encoder_C6678_UserGuide.pdf  (located at ..\Texas Instruments\Codecs\C66x_j2e_01_00_00_01_ELF\packages\ti\sdo\codecs\j2e\Docs) for more information about supported formats.

    Thank you,

    Paula

     

  • Dear Paula 

    As you said i checked my input

    If i am giving an input of 500 frames as one input source, i am able to get only 64 frames. The execution is stuck in it.

    [DEBUG] FileWriterThread(1) : FrameDesc.buf[0].length = 0x00400000
    [DEBUG] FileWriterThread(1) : Wrote 1255959 bytes in 1577395 ns.
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[1].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[2].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[3].length = 0x00400000
    [DEBUG] FileWriterThread(1) : Got message #64
    [DEBUG] FileWriterThread(1) : File 0 / 1, Frame 63 / 70 ...
    [DEBUG] FileWriterThread(1) #63 : Rx Msg. #64, File: ../testVecs/output/output.j2k, Frame #63, Size 1255162 bytes.
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[0].length = 0x00400000
    [DEBUG] FileWriterThread(1) : Wrote 1255162 bytes in 1410709 ns.
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[1].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[2].length = 0x00400000
    [DEBUG] FileWriterThread(1) : FrameDesc.buf[3].length = 0x00400000

    This is what i always get, should i change anything in codecParams.cfg?.. i am not able to find a solution for this. I have also tried as you said giving as seperate images

    [DEBUG] FileReaderThread(1) : Read 4194304 bytes in 19037761 ns.
    [DEBUG] FileReaderThread(1) : Read 4100096 bytes in 18553121 ns.
    [DEBUG] FileReaderThread(1) : Iter = 0, Clip = ../testVecs/input/frame00059.yuv, Frame = 0 / 1, Size = 8294400
    [DEBUG] FileReaderThread(1) : Sending task #59 to device #1, node #15 ...
    [DEBUG] FileReaderThread(1) : Finished writing message.
    [DEBUG] DeviceIORxThread(2) : Getting message from node #16 ...
    [DEBUG] DeviceIORxThread(2) : Found Mailbox Msg: Process Count 8, Free Task ID 46, outputId 46, outBufPtr 0xA0000000, outBufSize 1248564, freeBufID 0
    [DEBUG] DeviceIORxReceiveFrame(2) : Attempting to DMA from DSP address 0xA0000000 into 4 buffers of the following lengths :
    [DEBUG] DeviceIORxReceiveFrame(2) : Buf #0 Phys Addr = 0x000000014B800000, User Addr = 0x8BC61000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(2) : Buf #1 Phys Addr = 0x000000014BC00000, User Addr = 0x8B861000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(2) : Buf #2 Phys Addr = 0x000000014C000000, User Addr = 0x8B461000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(2) : Buf #3 Phys Addr = 0x000000014C400000, User Addr = 0x8B061000 Length = 0x00400000
    [DEBUG] DeviceIORxReceiveFrame(2) : Addr = 0xA0000000, dma_trans_id = 84
    [DEBUG] DeviceIOXferComplete(2) : DMA to device 2 Complete! dma_trans_id = 84
    [DEBUG] DeviceIORxThread(2) : XFER Complete... Polled for DMA completion 1209 times.
    [DEBUG] ReorderPut(1) : ID = 46
    [DEBUG] DeviceIORxThread(2) : Placed message #46 in reorder queue.

    The execution is stuck at this. I am able to get only 22 j2k images, in 96 input given. I am really not able to understand where i am going wrong...

  • Hi Chad

    I am still figuring to findout the solution for my problem as i am getting output only till 60 frames, if i am providing more frames in multiclip cfg it gets stuck, what is the problem with it, i have also posted the errors in this post, please do check it. Awaiting your guidance.

    Regards

    Venkatesh

  • Hi Paula, i am awaiting your response, regarding my problem as i am not able to proceed further due to this bug, i am able to execute only upto 60 frames more than that it gets stuck. I couldnt get the output if i am giving more than 60 frames i tried giving them seperately too as you said but no improvement. Awaiting your valuable response.

    Thanks and regards

    Venkatesh 

  • Hi Mr Hongmei

    I am still trying to figure out a problem in execution on J2K encoder for PCIE demo. I am able to execute only till 64 frames. The process gets stuck at it. When i checked to take the remaining frames as another input from 65 to 500 (total), but it again gets stuck in the same point. I also tried to execute using single YUV file of 500 frames. But even that doesnt work. I clearly checked what all you adviced me to do. But i dont know what causes this problem. It would be of great help if you could guide me regarding this. Should i change anything else in codec parameters?. Or what else should i do.

    Awaiting your response

    Thanks and regards

    Venkatesh Padmanabhan

  • Hi Venkatesh, I will try to reproduce the issue today/tomorrow in my setup I will keep you post it.

    Thank you,

    Paula

  • Hi Venkatesh, I was able to reproduced, I will keep you post it. I used separate frames of YUV 4:2:2 10bits as input and I got 20 frames. I will start checking and let you know.

    thanks,

    Paula

  • Dear Paula

    Thanks for checking for me, i was able to reproduce 64 frames, in 500 frames which i downloaded as per suggestion of TI i used it for  J2K TRANSCODING, it worked perfectly. I used the same input ( Both as seperate inputs frames by frame aswellas in one single YUV file) I get stuck when i come to the 65 th frame.. That was the problem last 3 days i am trying to resolve it with different inputs, nothing worked either i give single input or inputs of single frames seperately i get stuck in 64th frame. I feel there is some bug in the codec Or parameters associated with J2K Encoder. as i was able to take 64 frames as one input and take remaining 64 frames as second time give it as input seperately (Frame 65 - frame 128) It worked perfectly.  But the problem comes when i am encoding more than 65 frames. Awaiting your valuable guidance.

    Regards

    Venkatesh Padmanabhan

  • Dear Paula

    If you want i can send you the log message which i produced during the execution but i couldnt get any error. Yet the execution stops at 64th frame. As its pretty long i am not able to post it here. To which email address can i send the log, i thought it might be helpful for you to understand my issue better. Awaiting your response.

    Thanks and regards

    Venkatesh Padmanabhan

  • Hi Venkatesh,

    It is indeed a bug, we will update you with a patch for the DSP source files. Quick question have you before built SV04 application? If not please check below links and try it in advance so you can be prepare to rebuild when we send you the patch files

    For linux environment please go to:

    http://processors.wiki.ti.com/index.php/MCSDK_VIDEO_2.1_Linux_Getting_Started_Guide "Build MCSDK Video DSP Application"

    For Windows environment (using MinGW) please go to:

    http://processors.wiki.ti.com/index.php/MCSDK_VIDEO_2.1_Windows_Getting_Started_Guide "Rebuild MCSDK Video Demo Builds"

    Thank you,

    Paula

  • Hi Paula,

    Thanks for the guidance, yeah i have already done it. I have built SV04, thats the reason i was able to compile other Demos correctly i guess. I am really thankful for your guidance, I am awaiting the patch for the bug

    Regards

    Venkatesh Padmanabhan

  • Venkatesh, please see attached siuVctEncode_xdm2p0.c with J2K enc fix. Please locate this file at /dsp/siu/vct and proceed to make SV04

    cd dsp/mkrel source setupenvMsys.sh
    make
    sv04


    This fix is for JPEG 2K encoder (you can make a copy of original siuVctEncode_xdm2p0.c in order to use it for other codecs)

    After making the .out please test it and let us know if it is working for you. I tested with separate frames.

    Thank you,
    Paula

    /******************************************************************************
    * FILE PURPOSE: Run Stand-alone XDM compliant Encoder
    ******************************************************************************
    * FILE NAME:   siuVctEncode.c
    *
    * DESCRIPTION: Contains routines that support stand-alone Encoder test
    *
    * TABS: NONE
    *
    *
    * (C) Copyright 2010, Texas Instruments Incorporated
     * 
     *  Redistribution and use in source and binary forms, with or without 
     *  modification, are permitted provided that the following conditions 
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright 
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the 
     *    documentation and/or other materials provided with the   
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
    */
    /* Standard C header files                                                    */
    #include <stdio.h>
    #include <stdlib.h>
    #include "siuVctCodecAPI.h"
    #include "siuVctBufferManager.h"
    #include "siuVctFileIO.h"
    
    #include "siuVctNeu.h"
    #include "osal/siuOsal.h"
    #include "osal/siuIpcOsal.h"
    #include "osal/siuFcOsal.h"
    #include "common/siuloc.h"
    #include <ti/xdais/ires.h>
    
    #include "siuVctRun.h"
    //#define PROCESS_CALL_PROFILE
    
    extern IALG_Handle ALG_create(IALG_Fxns *fxns, IALG_Handle p, IALG_Params *params);
    extern Void ALG_delete(IALG_Handle alg);
    
    
    #pragma DATA_SECTION( getVersionBuf, ".testCodecExtMem");
    #define VERSION_SIZE 100
    XDAS_Int8 getVersionBuf[VERSION_SIZE]; // Version of codec
    
    /*  Buffer for multicore synchronization in testapplication              */
    /*  End of stream indicator to slave. if multiCoreSync[0] is set      */
    /*  to 1 then slave exits the frame processing loop                      */
    extern XDAS_Int8  multiCoreSync[IVIDMC_NUM_BARRIERS];
    
    extern cregister volatile unsigned int TSCL;
    extern cregister volatile unsigned int DNUM;
    extern int CORE_TEAM_MAPPING[];
    
    
    
    XDAS_Int32 xdm2p0_vid_enc_create(mediaTaskContext_t *cxt, const char *codecname, 
                                     void *codecStaticParams, void *codecDynamicParams, XDAS_UInt32 framesToEncode)
    {
      vidEncoderAPI_t         *encAPI;
      IVIDMC_t                 mcVidEncParams;
      IVIDENC2_Params         *staticParams;
      //IVIDENC2_Status       *status; // Needed for GETVERSION
      void                    *encFxns;
    
      IRES_Fxns    *resFxns;
    
      if(cxt->coreId == 0)
      {
          multiCoreSync[0] = 0;
      }
    
      encAPI = getVidEncoderAPI(codecname);
    
      if (encAPI == NULL){
        printf("Encoder is not installed .. exiting \n");
        return -1;
      }
      cxt->algAPI = (void *)encAPI;
    
      if(encAPI->encInstanceSize >= MAX_ALG_INST_SIZE) {
          printf("Encoder Instance Size Exceeds allocated value.. exiting \n");
          return -1;
      }
    
    #ifdef SIU_VCT_MULTICHIP
      siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR9,cxt->numCores);
    #else
      siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR9,cxt->numCores);
    #endif
    
      encAPI->encInitInstance((void *)cxt->algInst);
    
      /* Current IVIDMC implementation does not support multiple masters, which is 
       * the case for JPEG2000 Encode.
       *
       * Use setMcParams method to determine if IVIDMC is needed. 
       *
       * NOTE: Barriers still work since implementation checks if the number of 
       *       cores in the team is greater than 1 before proceeding to the 
       *       barrier. 
       */
      if (encAPI->encSetMcParams)
      {
        /* Initialization of multi-core params. Do this before encSetStaticParams
            so that it can be populated to StaticParams */
    #ifdef SIU_VCT_MULTICHIP
        siuVidMc_Multichip_Init_ShmemTab(cxt->coreId);
        mcVidEncParams.swbarr        = siuVidMc_Multichip_Swbarr;
        mcVidEncParams.shmmap        = siuVidMc_Multichip_Map_Shmem;
        mcVidEncParams.shmmunmap     = siuVidMc_Multichip_Unmap_Shmem;
        mcVidEncParams.shmmap_sync   = siuVidMc_Multichip_Shmem_Sync;
    #else
        siuVidMc_Init_ShmemTab(CORE_TEAM_MAPPING[cxt->coreId]);
        mcVidEncParams.swbarr        = siuVidMc_Swbarr;
        mcVidEncParams.shmmap        = siuVidMc_Map_Shmem;
        mcVidEncParams.shmmunmap     = siuVidMc_Unmap_Shmem;
        mcVidEncParams.shmmap_sync   = siuVidMc_Shmem_Sync;
    #endif
        mcVidEncParams.Lock          = NULL;
        mcVidEncParams.UnLock        = NULL;
        mcVidEncParams.ncores        = cxt->numCores;
        mcVidEncParams.core_task_ID  = (cxt->coreId==0)?IVIDMC_TASK_MASTER:IVIDMC_TASK_SLAVE;
        mcVidEncParams.coreID        = cxt->coreId;
    
        encAPI->encSetMcParams((void *)cxt->algInst, &mcVidEncParams);
      }
    
      /* Initialization of parameters needed for Algorithm Instance create */
      siu_exc_assert(encAPI->encSetStaticParams((void *)cxt->algInst, (void *)codecStaticParams, framesToEncode)==TRUE, 
                     SIUVCT_EXC_CODEC_STATIC_PARAM_NULL, &siuContext);
    
    
      /* Get XDM2.0 pointers from the codec */
      encFxns               =  encAPI->encGetFxns((void *)cxt->algInst);
      staticParams          = (IVIDENC2_Params *)encAPI->encGetStaticParams((void *)cxt->algInst);
    
    #ifdef SIU_VCT_MULTICHIP
      siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR10,cxt->numCores);
    #else
      siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR10,cxt->numCores);
    #endif
    
      if ((cxt->algHandle =  (IALG_Handle)ALG_create (
          (IALG_Fxns *) encFxns, 
          (IALG_Handle) NULL, 
          (IALG_Params *) staticParams)) == NULL)
      {
        printf("\nFailed to Create Instance at core %d. Exiting for this configuration..", CORE_TEAM_MAPPING[cxt->coreId]);
        if (cxt->coreId == 0)
        {
          multiCoreSync[0] = 1;
        }
    #ifdef SIU_VCT_MULTICHIP
        siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR11,cxt->numCores);
    #else
        siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR11,cxt->numCores);
    #endif
        return -1;
      }
    #ifdef SIU_VCT_MULTICHIP
      siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR11,cxt->numCores);
    #else
      siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR11,cxt->numCores);
    #endif
      if (multiCoreSync[0])
        return -1;
    
      printf("\nAlgorithm Instance Creation Done @ core %d...\n", CORE_TEAM_MAPPING[cxt->coreId]);
    
    
      if ( cxt->algHandle->fxns->algActivate )
        cxt->algHandle->fxns->algActivate((IALG_Handle)cxt->algHandle);
    
      /* Set Run time dynamic parameters */
      siu_exc_assert(encAPI->encSetDynamicParams((void *)cxt->algInst, (void *)codecDynamicParams)==TRUE, 
                     SIUVCT_EXC_CODEC_DYNAMIC_PARAM_NULL, &siuContext);
    
      cxt->algParams = (void *)codecStaticParams;
    
      /* Assign resources to the algorithm */
      resFxns = encAPI->encGetIresFxns();
      if (siu_osal_fc_assign_resources((void *)cxt->algHandle, (void *)resFxns, SIU_FC_USER_CODEC) == FALSE) {
        printf("Assign Resource Failed for core %d.. Exiting \n", CORE_TEAM_MAPPING[cxt->coreId]);
        multiCoreSync[0] = 1;
        return ( -1 );
      }
    
      if ( cxt->algHandle->fxns->algDeactivate )
        cxt->algHandle->fxns->algDeactivate((IALG_Handle)cxt->algHandle);
    
      siu_osal_wbinv_cache_all();
    
      return ( 0 );
    }
    
    
    XDAS_UInt32 xdm2p0_vid_enc_buf_query(mediaTaskContext_t *cxt, XDAS_Int32* numInBufs, XDAS_Int32 *bufSizes)
    {
      vidEncoderAPI_t         *encAPI = (vidEncoderAPI_t *) cxt->algAPI;
      IVIDENC2_Fxns           *ividEncfxns=(IVIDENC2_Fxns *)cxt->algHandle->fxns;;
      IVIDENC2_DynamicParams  *dynamicParams;
      IVIDENC2_Status         *status; 
      XDAS_Int32               i;
      XDAS_UInt32              totalSize = 0;
    
      dynamicParams         = (IVIDENC2_DynamicParams *)encAPI->encGetDynamicParams((void *)cxt->algInst);
      status                = (IVIDENC2_Status *)encAPI->encGetStatus((void *)cxt->algInst);
    
      if ( ividEncfxns->control ) {
          if ( cxt->algHandle->fxns->algActivate ) {
            cxt->algHandle->fxns->algActivate((IALG_Handle)cxt->algHandle);
          }
          ividEncfxns->control((IVIDENC2_Handle)cxt->algHandle, XDM_GETBUFINFO, dynamicParams, status);
          if (cxt->algHandle->fxns->algDeactivate) {
            cxt->algHandle->fxns->algDeactivate((IALG_Handle)cxt->algHandle);
          }
          *numInBufs = status->bufInfo.minNumInBufs;
          for(i=0;i<status->bufInfo.minNumInBufs;i++) {
            bufSizes[i] = status->bufInfo.minInBufSize[i].bytes;
            totalSize += bufSizes[i];
          }
      }
      return totalSize;
    }
    
    XDAS_Int32 xdm2p0_vid_set_iobufdesc(mediaTaskContext_t  *cxt, IVIDEO2_BufDesc *pInputBufDesc, XDM2_BufDesc *pOutputBufDesc)
    {
      XDAS_Int32 retVal, i;
      XDAS_UInt32 captureWidth, captureHeight;
      vidEncoderAPI_t         *encAPI = (vidEncoderAPI_t *) cxt->algAPI;
      IVIDENC2_Fxns           *ividEncfxns;
      IVIDENC2_Params         *staticParams;
      IVIDENC2_DynamicParams  *dynamicParams;
      IVIDENC2_Status         *status; 
    
      /* Get XDM2.0 pointers from the codec */
      ividEncfxns           = (IVIDENC2_Fxns *)cxt->algHandle->fxns;
      staticParams          = (IVIDENC2_Params *)encAPI->encGetStaticParams((void *)cxt->algInst);
      dynamicParams         = (IVIDENC2_DynamicParams *)encAPI->encGetDynamicParams((void *)cxt->algInst);
      status                = (IVIDENC2_Status *)encAPI->encGetStatus((void *)cxt->algInst);
    
      captureWidth   =  (dynamicParams->captureWidth + 15) & ~15;
      if(captureWidth == 0)
      {
        captureWidth =  (dynamicParams->inputWidth + 15) & ~15;
      }
      captureHeight   = (dynamicParams->inputHeight + 15) & ~15 ;
    
      if ( ividEncfxns->control )
      {
          if ( cxt->algHandle->fxns->algActivate )
          cxt->algHandle->fxns->algActivate((IALG_Handle)cxt->algHandle);
    
          retVal= ividEncfxns->control((IVIDENC2_Handle)cxt->algHandle, XDM_GETBUFINFO, dynamicParams, status);
    
          if ( cxt->algHandle->fxns->algDeactivate )
          cxt->algHandle->fxns->algDeactivate((IALG_Handle)cxt->algHandle);
    
          if(retVal == XDM_EFAIL)
          {
            printf("\n XDM_GETBUFINFO Control function returned an Error...  exiting");
            return -1; 
          }
      }
    
        /*------------------------------------------------------------------------*/
        /*  Initialize the input buffer properties as required by algorithm       */
        /*  based on info received by preceding GETBUFINFO call.                  */
        /*------------------------------------------------------------------------*/
        pInputBufDesc->numPlanes = status->bufInfo.minNumInBufs;
        pInputBufDesc->numMetaPlanes = 0;
    
        /*------------------------------------------------------------------------*/
        /* Set entire Image region in the buffer  by using config parameters      */
        /*------------------------------------------------------------------------*/
        pInputBufDesc->imageRegion.topLeft.x = 0;
        pInputBufDesc->imageRegion.topLeft.y = 0;
        pInputBufDesc->imageRegion.bottomRight.x = captureWidth;
        pInputBufDesc->imageRegion.bottomRight.y = captureHeight;
    
        /*------------------------------------------------------------------------*/
        /* Image pitch is capture width                                           */
        /*------------------------------------------------------------------------*/
        pInputBufDesc->imagePitch[0] = dynamicParams->captureWidth;
        pInputBufDesc->imagePitch[1] = dynamicParams->captureWidth;
    
        /*------------------------------------------------------------------------*/
        /* Set Content type and chroma format from encoder parameters             */
        /*------------------------------------------------------------------------*/
        pInputBufDesc->contentType = staticParams->inputContentType;
        pInputBufDesc->chromaFormat = staticParams->inputChromaFormat;
    
        /*------------------------------------------------------------------------*/
        /* Assign memory pointers and sizes for all the input buffers         */
        /*------------------------------------------------------------------------*/
        pInputBufDesc->numPlanes = 0;
    
        cxt->algOutArgs.frameBytesConsumed = 0;
        for(i = 0; i < status->bufInfo.minNumInBufs; i++)
        {
          pInputBufDesc->numPlanes++;
          pInputBufDesc->planeDesc[i].memType = (XDAS_Int16)(status->bufInfo.inBufMemoryType[i]);
          pInputBufDesc->planeDesc[i].bufSize.bytes = status->bufInfo.minInBufSize[i].bytes;
          printf("Input buffer %d size : 0x%X \n", i, status->bufInfo.minInBufSize[i].bytes);
          if(i == 0)
            pInputBufDesc->planeDesc[i].buf = (XDAS_Int8*)cxt->algInArgs.inputBufs[0];
          else
            pInputBufDesc->planeDesc[i].buf = pInputBufDesc->planeDesc[i-1].buf + 
                                          status->bufInfo.minInBufSize[i-1].bytes;
          cxt->algOutArgs.frameBytesConsumed += pInputBufDesc->planeDesc[i].bufSize.bytes;
        }
        fflush(stdout);
    
        pInputBufDesc->dataLayout         = 0; //encoderParams->dataLayout;
        pInputBufDesc->topFieldFirstFlag  = 0; //encoderParams->topFieldFirstFlag;
    
        if(staticParams->metadataType[pInputBufDesc->numMetaPlanes]== 258) // IH264_USER_DEFINED_SCALINGMATRIX
        {
          pInputBufDesc->metadataPlaneDesc[pInputBufDesc->numMetaPlanes].buf = (XDAS_Int8 *)(encAPI->metaDataPlane);
          pInputBufDesc->metadataPlaneDesc[pInputBufDesc->numMetaPlanes].bufSize.bytes = encAPI->metaDataSize;
          pInputBufDesc->numMetaPlanes++;
        }
    
        /*------------------------------------------------------------------------*/
        /* Initialise output descriptors                                          */
        /*------------------------------------------------------------------------*/
        pOutputBufDesc->numBufs = 0;
        for(i = 0; i < status->bufInfo.minNumOutBufs; i++)
        {
          pOutputBufDesc->numBufs++;
          pOutputBufDesc->descs[i].memType = status->bufInfo.outBufMemoryType[i];
          pOutputBufDesc->descs[i].bufSize.bytes = status->bufInfo.minOutBufSize[i].bytes;
          if(i == 0)
            pOutputBufDesc->descs[0].buf = (XDAS_Int8*)cxt->algInArgs.outputBufs[0];
          else
            pOutputBufDesc->descs[i].buf = pOutputBufDesc->descs[i-1].buf + 
                                          status->bufInfo.minOutBufSize[i-1].bytes;
        } 
    
        return 0;
    }
    
    #ifdef PROCESS_CALL_PROFILE
    XDAS_UInt32 processCycleAllFrame[SIU_NUM_FRAME_PROFILING];
    XDAS_UInt32 barwaitCycleAllFrame[SIU_NUM_FRAME_PROFILING];
    XDAS_UInt32 barwaitCycleFrame;
    #endif
    
    XDAS_Int32 xdm2p0_vid_enc_process(
      mediaTaskContext_t  *cxt, 
      XDAS_Int8           *inputBuf, 
      XDAS_Int32           inputId, 
      XDAS_Int8           *outputBuf, 
      XDAS_Int32          *outputId, 
      XDAS_Int32          *freeBufIDs,
      void                *codecParams
      )
    {
      vidEncoderAPI_t         *encAPI = (vidEncoderAPI_t *) cxt->algAPI;
      IVIDENC2_Fxns           *ividEncfxns;
      IVIDENC2_Params         *staticParams;
      IVIDENC2_DynamicParams  *dynamicParams;
      IVIDENC2_InArgs         *inArgs;
      IVIDENC2_OutArgs        *outArgs;
      IVIDENC2_Status         *status; 
    
      /* Input/Output Buffer Descriptor variables */
      IVIDEO2_BufDesc  inputBufDesc; //xdm2.0
      XDM2_BufDesc     outputBufDesc;	// xdm2.0
      
      XDAS_Int8 bigEndByte;
      XDAS_Int32 retVal = 0, i, j;
    #ifdef PROCESS_CALL_PROFILE
      XDAS_UInt32  TSCL_Begin, TSCL_End;
    #endif
    
      /* Set any dynamic configuration received */
      //encAPI->encSetDynamicParams(cxt->algInst, codecParams); 
      siu_exc_assert(encAPI->encSetInArgs(cxt->algInst, codecParams)==TRUE, 
                     SIUVCT_EXC_CODEC_INARG_NULL, &siuContext);
    
      /* Get XDM2.0 pointers from the codec */
      ividEncfxns           = (IVIDENC2_Fxns *)cxt->algHandle->fxns;
      inArgs                = (IVIDENC2_InArgs *)encAPI->encGetInArgs((void *)cxt->algInst);
      outArgs               = (IVIDENC2_OutArgs *)encAPI->encGetOutArgs((void *)cxt->algInst);
      staticParams          = (IVIDENC2_Params *)encAPI->encGetStaticParams((void *)cxt->algInst);
      dynamicParams         = (IVIDENC2_DynamicParams *)encAPI->encGetDynamicParams((void *)cxt->algInst);
      status                = (IVIDENC2_Status *)encAPI->encGetStatus((void *)cxt->algInst);
    
      do {  
        if ( cxt->coreId == 0 )
        {
          cxt->algInArgs.inputBufs[0]   = inputBuf;
          cxt->algInArgs.outputBufs[0]  = outputBuf;
        }
    #ifdef SIU_VCT_MULTICHIP
        siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
    #else
        siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
    #endif
    
        if(cxt->coreId != 0)
        {
            /*-------------------------------------------------------------------------*/
            /* Slave core - Check for end of frames                                    */
            /*-------------------------------------------------------------------------*/
            if(multiCoreSync[0]) {
              break;
            }
        }
    
        xdm2p0_vid_set_iobufdesc(cxt, &inputBufDesc, &outputBufDesc);
    
        inArgs->inputID = inputId;
    
        if ( ividEncfxns->control )
        {
          /* Activate the Algorithm                                               */
          if ( cxt->algHandle->fxns->algActivate )
            cxt->algHandle->fxns->algActivate(cxt->algHandle);
    
          retVal = ividEncfxns->control((IVIDENC2_Handle)cxt->algHandle, XDM_SETPARAMS, dynamicParams, status);
    
          if ( cxt->algHandle->fxns->algDeactivate )
            cxt->algHandle->fxns->algDeactivate(cxt->algHandle);
    
          if(retVal == XDM_EFAIL)
          {
              printf("\n Control function returned an Error @ core %d...  ", CORE_TEAM_MAPPING[cxt->coreId]);
              return -2; /* Error Condition: Application may want to break off          */
          }
        }
    
        if(cxt->coreId == 0) 
        {
          if(staticParams->dataEndianness==5)
          {
            for(i=0; i < inputBufDesc.numPlanes; i++)
            {
              // Swap bytes in InputBuffer 
              for(j=0; j< (inputBufDesc.planeDesc[i].bufSize.bytes); j+=2)
              {
                bigEndByte                            = inputBufDesc.planeDesc[i].buf[j];
                inputBufDesc.planeDesc[i].buf[j]      = inputBufDesc.planeDesc[i].buf[j+1];
                inputBufDesc.planeDesc[i].buf[j+1]    = bigEndByte;
              }
            }
          }
        }
        siu_osal_wbinv_cache_all();
    #ifdef SIU_VCT_MULTICHIP
        siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR13,cxt->numCores);
    #else
        siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR13,cxt->numCores);
    #endif
    
        if ( cxt->algHandle->fxns->algActivate )
          cxt->algHandle->fxns->algActivate(cxt->algHandle);
    
    #ifdef PROCESS_CALL_PROFILE
        barwaitCycleFrame = 0;
        TSCL_Begin = TSCL;
    #endif
        /* Basic Algorithm process() call */
        retVal = ividEncfxns->process((IVIDENC2_Handle)cxt->algHandle, 
            (IVIDEO2_BufDesc *)&inputBufDesc,
            (XDM2_BufDesc *)&outputBufDesc,
            (IVIDENC2_InArgs *)inArgs,
            (IVIDENC2_OutArgs *)outArgs);
    #ifdef PROCESS_CALL_PROFILE
        TSCL_End   = TSCL;
    #endif
    
        #ifdef SIU_VCT_MULTICHIP
        siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR14,cxt->numCores);
    #else
        siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR14,cxt->numCores);
    #endif
        fflush(stdout);
        siu_osal_wbinv_cache_all();
    
    #ifdef PROCESS_CALL_PROFILE
        if(cxt->algOutArgs.frameCount < SIU_NUM_FRAME_PROFILING) {
            processCycleAllFrame[cxt->algOutArgs.frameCount] = (TSCL_End - TSCL_Begin);
            barwaitCycleAllFrame[cxt->algOutArgs.frameCount] = barwaitCycleFrame;
        }
    
        printf("\n Encoded Frame # %d, Cycles consumed = %d  ",cxt->algOutArgs.frameCount, processCycleAllFrame[cxt->algOutArgs.frameCount]);
    #endif
    
        cxt->algOutArgs.frameCount++;
    
        if(retVal == XDM_EFAIL)
        {
          printf("\n Process function returned an Error...  %d", outArgs->extendedError);
          ((XDAS_Int32 *)outputBuf)[0] = outArgs->extendedError;
          return ( -3 ); /* Error Condition: Application may want to break off          */
        }
    
        if(cxt->coreId == 0)
        {
          /* Optional: Read status via control()                                  */
          if ( ividEncfxns->control )
            ividEncfxns->control((IVIDENC2_Handle)cxt->algHandle, XDM_GETSTATUS, dynamicParams, status);
        }
    
        /* DeActivate the Algorithm                                             */
        if ( cxt->algHandle->fxns->algDeactivate )
          cxt->algHandle->fxns->algDeactivate(cxt->algHandle);
    
    
    #ifdef SIU_VCT_MULTICHIP
        siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR15,cxt->numCores);
    #else
        siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR15,cxt->numCores);
    #endif
        if(multiCoreSync[0])
        {
          printf("multiCoreSync[0] is wrongly set, exit process call...");
          return (-4);
        }
      } while ( cxt->coreId );
    
      i = 0;
      while ( outArgs->freeBufID[i] != 0 ) {
        freeBufIDs[i] = outArgs->freeBufID[i];
        cxt->algOutArgs.buffEleFreeBufId[i] = outArgs->freeBufID[i];
        i++;
      }
    
      /* Set freeBufIDs for J2E */
      if(!(strcmp(encAPI->name, "J2KENC"))) {
        freeBufIDs[0] = inputId;
        cxt->algOutArgs.buffEleFreeBufId[0] = freeBufIDs[0];
      }
    
      cxt->algOutArgs.displayFrame++;
      if(outArgs->bytesGenerated <= 0)
      {
        cxt->algOutArgs.displayFrame--;
        *outputId = 0;
      }
      else
      {
        *outputId = inputId - (cxt->algOutArgs.frameCount - cxt->algOutArgs.displayFrame);
      }
      
      return ( outArgs->bytesGenerated );
    }
    
    extern XDAS_Int32 first_time_enter_flush;
    extern XDAS_Int8  flushFlag;
    XDAS_Int32 xdm2p0_vid_enc_flush(mediaTaskContext_t *cxt, XDAS_Int8 *outputBuf, XDAS_Int32 *freeBufIDs, XDAS_Int32 *outputID)
    {
      vidEncoderAPI_t         *encAPI = (vidEncoderAPI_t *) cxt->algAPI;
      IVIDENC2_Fxns           *ividEncfxns;
      IVIDENC2_InArgs         *inArgs;
      IVIDENC2_OutArgs        *outArgs;
      IVIDENC2_DynamicParams  *dynamicParams;
      IVIDENC2_Status         *status; 
      XDAS_Int32 retVal = 0, i;
      IVIDEO2_BufDesc  inputBufDesc; 
      XDM2_BufDesc     outputBufDesc;
    
      dynamicParams         = (IVIDENC2_DynamicParams *)encAPI->encGetDynamicParams((void *)cxt->algInst);
      ividEncfxns           = (IVIDENC2_Fxns *)cxt->algHandle->fxns;
      inArgs                = (IVIDENC2_InArgs *)encAPI->encGetInArgs((void *)cxt->algInst);
      outArgs               = (IVIDENC2_OutArgs *)encAPI->encGetOutArgs((void *)cxt->algInst);
      status                = (IVIDENC2_Status *)encAPI->encGetStatus((void *)cxt->algInst);
    
      if (first_time_enter_flush) {
          if (cxt->coreId == 0) {
              /* Allow slave cores to break out of process loop. */
              multiCoreSync[0] = 1;
        #ifdef SIU_VCT_MULTICHIP
              siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
        #else
              siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
        #endif
          }
          /* wait for all the cores enter flush */
    #ifdef SIU_VCT_MULTICHIP
          siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR13,cxt->numCores);
    #else
          siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR13,cxt->numCores);
    #endif
          if (cxt->coreId == 0) {
              multiCoreSync[0] = 0;
          }
          first_time_enter_flush = 0;
      }
    
      /* Reset flushFlag */
      if ((cxt->coreId == 0) && 
          (cxt->algOutArgs.displayFrame >= cxt->algOutArgs.frameCount)) {
          flushFlag = 0;
      }
    #ifdef SIU_VCT_MULTICHIP
      siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR14,cxt->numCores);
    #else
      siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR14,cxt->numCores);
    #endif
    
      /* Flush is not needed, return with 0 as the outputBuf size */
      if (flushFlag == 0) {
          return 0;
      }
      
      xdm2p0_vid_set_iobufdesc(cxt, &inputBufDesc, &outputBufDesc);
    
      if ( ividEncfxns->control )
      {
            if ( cxt->algHandle->fxns->algActivate )
            cxt->algHandle->fxns->algActivate((IALG_Handle)cxt->algHandle);
    
            retVal= ividEncfxns->control((IVIDENC2_Handle)cxt->algHandle, XDM_FLUSH, dynamicParams, status);
    
            if(retVal == XDM_EFAIL)
            {
            printf("\n XDM_FLUSH Control function returned an Error...  exiting");
            return -1; 
            }
            /* DeActivate the Algorithm   */
            if ( cxt->algHandle->fxns->algDeactivate )
                cxt->algHandle->fxns->algDeactivate(cxt->algHandle);
      }
    
      do
      {
          if ( cxt->coreId == 0 ) {
              cxt->algInArgs.outputBufs[0]  = (XDAS_Int8 *)((XDAS_UInt32)outputBuf);
    
              inArgs->inputID    = 1;
              inputBufDesc.planeDesc[0].buf   = 0;
              inputBufDesc.planeDesc[1].buf   = 0;
              inputBufDesc.planeDesc[2].buf   = 0;
          }
    #ifdef SIU_VCT_MULTICHIP
          siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
    #else
          siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
    #endif
          outputBufDesc.numBufs = 1;
          outputBufDesc.descs[0].buf = (XDAS_Int8*)cxt->algInArgs.outputBufs[0];
          outputBufDesc.descs[0].bufSize.bytes = status->bufInfo.minOutBufSize[0].bytes;
        
        if(cxt->coreId != 0)
        {
            /*-------------------------------------------------------------------------*/
            /* Slave core - Check for end of frames                                    */
            /*-------------------------------------------------------------------------*/
            if(multiCoreSync[0]) {
              break;
            }
        }
    
        if ( cxt->algHandle->fxns->algActivate )
          cxt->algHandle->fxns->algActivate((IALG_Handle)cxt->algHandle);
    
        /* Basic Algorithm process() call */
        retVal = ividEncfxns->process((IVIDENC2_Handle)cxt->algHandle, 
            (IVIDEO2_BufDesc *)&inputBufDesc,
            (XDM2_BufDesc *)&outputBufDesc,
            (IVIDENC2_InArgs *)inArgs,
            (IVIDENC2_OutArgs *)outArgs);
    
        /* DeActivate the Algorithm   */
        if ( cxt->algHandle->fxns->algDeactivate )
            cxt->algHandle->fxns->algDeactivate(cxt->algHandle);
    
    #ifdef SIU_VCT_MULTICHIP
          siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR13,cxt->numCores);
    #else
          siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR13,cxt->numCores);
    #endif
        siu_osal_wbinv_cache_all();
    
    #ifdef SIU_VCT_MULTICHIP
        siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR14,cxt->numCores);
    #else
        siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR14,cxt->numCores);
    #endif
    
      } while (cxt->coreId != 0);
    
      cxt->algOutArgs.displayFrame++;
      *outputID = cxt->algOutArgs.displayFrame;
      i = 0;
      while ( outArgs->freeBufID[i] != 0 ) {
          freeBufIDs[i] = outArgs->freeBufID[i];
          cxt->algOutArgs.buffEleFreeBufId[i] = outArgs->freeBufID[i];
          i++;
      }
      return (outArgs->bytesGenerated);
    }
    
    XDAS_Int32 xdm2p0_vid_enc_delete(mediaTaskContext_t *cxt)
    {
      vidEncoderAPI_t         *encAPI = (vidEncoderAPI_t *) cxt->algAPI;
      IRES_Fxns               *resFxns = encAPI->encGetIresFxns();
    
      if ( cxt->coreId == 0 ) {
          /* Allow slave cores to break out of process/flush loop. */
          multiCoreSync[0] = 1;
    #ifdef SIU_VCT_MULTICHIP
          siuVidMc_Multichip_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
    #else
          siuVidMc_Swbarr(cxt->coreId,IVIDMC_SWBARR12,cxt->numCores);
    #endif
      }
    
      /* Activate the Algorithm */
      if ( cxt->algHandle->fxns->algActivate ) {
        cxt->algHandle->fxns->algActivate(cxt->algHandle);
      }
      if ( siu_osal_fc_free_resources((IALG_Handle)cxt->algHandle, resFxns, SIU_FC_USER_CODEC) == FALSE)
      {
        printf("Free Resource Failed \n");
      }
      /* Deactivate the Algorithm                                              */
      if ( cxt->algHandle->fxns->algDeactivate ) {
        cxt->algHandle->fxns->algDeactivate(cxt->algHandle);
      }
    
      /* Delete the Algorithm instance object specified by handle */
      ALG_delete (cxt->algHandle);
    
      if(cxt->algOutArgs.frameCount == 0) 
      {
        cxt->algOutArgs.frameCount = 1; /* To avoid division with zero */
      }
    
      if(cxt->coreId == 0) {
    
        printf("\n --------------  SUMMARY --------------------\n");
        printf("  Total number of Frames          = %d\n",
            (XDAS_UInt32)cxt->algOutArgs.frameCount);
        //printf("  Bit Rate at 30 frames/Sec       = %d Kbps\n",(
        //    XDAS_UInt32)(((bytesGenerated*8*30)/cxt->algStats.frameCount)/1000));
        //printf("  Width and Height                = %d, %d \n",
        //    dynamicParams->inputWidth, 
        //    dynamicParams->inputHeight);
        printf (" --------------    END   --------------------\n");
      } else {
        printf("\nSee master core output for summary.\n");
      }
    
      printf("\n End of execution\n");
    
      return(0);
    }
    
    
    /* nothing past this point */
    

  • Venkatesh, about the siuVctEncode_xdm2p0.c you can safely replace it, no need to make a copy. Other demos will work as well.

    Thank you,

    Paula