aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'test_qnx/dce_test/dce_test.c')
-rw-r--r--test_qnx/dce_test/dce_test.c460
1 files changed, 387 insertions, 73 deletions
diff --git a/test_qnx/dce_test/dce_test.c b/test_qnx/dce_test/dce_test.c
index 7e60dd0..3852b8d 100644
--- a/test_qnx/dce_test/dce_test.c
+++ b/test_qnx/dce_test/dce_test.c
@@ -63,6 +63,8 @@
63#include "ti/shmemallocator/SharedMemoryAllocatorUsr.h" 63#include "ti/shmemallocator/SharedMemoryAllocatorUsr.h"
64 64
65#define PRINT_DEBUG 65#define PRINT_DEBUG
66//#define PRINT_DEBUG_LOW
67
66#define ERROR(FMT, ...) printf("%s:%d:\t%s\terror: " FMT "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 68#define ERROR(FMT, ...) printf("%s:%d:\t%s\terror: " FMT "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
67// enable below to print debug information 69// enable below to print debug information
68#ifdef PRINT_DEBUG 70#ifdef PRINT_DEBUG
@@ -70,6 +72,13 @@
70#else 72#else
71#define DEBUG(FMT, ...) 73#define DEBUG(FMT, ...)
72#endif 74#endif
75
76#ifdef PRINT_DEBUG_LOW
77#define DEBUGLOW(FMT, ...) printf("%s:%d:\t%s\tdebug: " FMT "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
78#else
79#define DEBUGLOW(FMT, ...)
80#endif
81
73#define INFO(FMT, ...) printf("%s:%d:\t%s\tinfo: " FMT "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 82#define INFO(FMT, ...) printf("%s:%d:\t%s\tinfo: " FMT "\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
74#define MIN(a, b) (((a) < (b)) ? (a) : (b)) 83#define MIN(a, b) (((a) < (b)) ? (a) : (b))
75 84
@@ -82,6 +91,8 @@
82// Getting codec version through XDM_GETVERSION 91// Getting codec version through XDM_GETVERSION
83#define GETVERSION 92#define GETVERSION
84 93
94#define STRIDE 4096
95
85enum { 96enum {
86 IVAHD_AVC1_DECODE, 97 IVAHD_AVC1_DECODE,
87 IVAHD_H264_DECODE, 98 IVAHD_H264_DECODE,
@@ -94,12 +105,20 @@ enum {
94 IVAHD_JPEGV_DECODE 105 IVAHD_JPEGV_DECODE
95}; 106};
96 107
108// Used when datamode == IVIDEO_NUMROWS
109static int numBlock = 2;
110static int output_y_offset = 0;
111static int output_uv_offset = 0;
112static int numRow_y_offset = 0;
113static int numRow_uv_offset = 0;
114char *out_pattern;
115char *outBuf_lowlatency;
116
97/* 117/*
98 * A very simple VIDDEC3 client which will decode h264 frames (one per file), 118 * A very simple VIDDEC3 client which will decode h264 frames (one per file),
99 * and write out raw (unstrided) nv12 frames (one per file). 119 * and write out raw (unstrided) nv12 frames (one per file).
100 */ 120 */
101 121int orig_width, orig_height, width, height, frames_to_write, padded_width, padded_height, num_buffers, tiler;
102int width, height, frames_to_write, padded_width, padded_height, num_buffers, tiler;
103Engine_Handle engine = NULL; 122Engine_Handle engine = NULL;
104VIDDEC3_Handle codec = NULL; 123VIDDEC3_Handle codec = NULL;
105VIDDEC3_Params *params = NULL; 124VIDDEC3_Params *params = NULL;
@@ -129,6 +148,7 @@ IJPEGVDEC_Status *mjpeg_status = NULL;
129IMPEG2VDEC_Params *mpeg2_params = NULL; 148IMPEG2VDEC_Params *mpeg2_params = NULL;
130IMPEG2VDEC_DynamicParams *mpeg2_dynParams = NULL; 149IMPEG2VDEC_DynamicParams *mpeg2_dynParams = NULL;
131IMPEG2VDEC_Status *mpeg2_status = NULL; 150IMPEG2VDEC_Status *mpeg2_status = NULL;
151int out_cnt = 0;
132 152
133unsigned int frameSize[64000]; /* Buffer for keeping frame sizes */ 153unsigned int frameSize[64000]; /* Buffer for keeping frame sizes */
134static int input_offset = 0; 154static int input_offset = 0;
@@ -218,7 +238,7 @@ get_mem_type (uint32_t paddr)
218/* list of free buffers, not locked by codec! */ 238/* list of free buffers, not locked by codec! */
219static OutputBuffer *head = NULL; 239static OutputBuffer *head = NULL;
220 240
221#if 0 241#if 0 // OLD implementation when using DCE RLS 3.x
222/*! @brief Start address of DDR region for 1GB RAM */ 242/*! @brief Start address of DDR region for 1GB RAM */
223#define DDR_1G_ADDRESS_START 0x80000000 243#define DDR_1G_ADDRESS_START 0x80000000
224/*! @brief End address of DDR region for 1GB RAM */ 244/*! @brief End address of DDR region for 1GB RAM */
@@ -386,8 +406,8 @@ int output_allocate_nonTiler(XDM2_BufDesc *outBufs, int cnt,
386 406
387 if((y_type < 0) || (uv_type < 0)) { 407 if((y_type < 0) || (uv_type < 0)) {
388 DEBUG("non TILER buffer address translation buf->y %x buf->uv %x", buf->y, buf->uv); 408 DEBUG("non TILER buffer address translation buf->y %x buf->uv %x", buf->y, buf->uv);
389 //buf->y = SysLinkMemUtils_translateAddr(buf->y); 409 //buf->y = SysLinkMemUtils_translateAddr(buf->y); // Old Implementation when using DCE 3.x
390 //buf->uv = SysLinkMemUtils_translateAddr(buf->uv); 410 //buf->uv = SysLinkMemUtils_translateAddr(buf->uv); // Old Implementation when using DCE 3.x
391 y_type = XDM_MEMTYPE_RAW; 411 y_type = XDM_MEMTYPE_RAW;
392 uv_type = XDM_MEMTYPE_RAW; 412 uv_type = XDM_MEMTYPE_RAW;
393 DEBUG("buf->y %x buf->uv %x", buf->y, buf->uv); 413 DEBUG("buf->y %x buf->uv %x", buf->y, buf->uv);
@@ -495,12 +515,143 @@ int read_input(const char *pattern, int cnt, char *input)
495 return (sz); 515 return (sz);
496} 516}
497 517
518//#define DUMP_PARTIAL_OUTPUT
519
520// Used when outputDataMode = IVIDEO_NUMROWS
521#ifdef DUMP_PARTIAL_OUTPUT
522static int GlobalFileCount = 0;
523#endif
524static int total_numRows = 0;
525//Create 2 temp buffers for Y and UV
526char *y_buffer = NULL;
527int y_buffer_offset = 0;
528char *orig_y_buffer = NULL;
529char *uv_buffer = NULL;
530int uv_buffer_offset = 0;
531char *orig_uv_buffer = NULL;
532
533/* helper to write partial data into output file based on numRows (1 numRows = 16 row of height for luma and 8 row of height for chroma */
534int write_partial_output(const char *pattern, char *y, char *uv, int stride, int numRows)
535{
536 DEBUGLOW("write_partial_output pattern %s y 0x%x uv 0x%x numRow_y_offset %d numRow_uv_offset %d orig_width %d numRows %d",
537 pattern, (unsigned int) y, (unsigned int) uv, numRow_y_offset, numRow_uv_offset, orig_width, numRows);
538
539 int sz = 0, i;
540
541#ifdef DUMP_PARTIAL_OUTPUT
542 int size;
543 FILE *fp = NULL;
544
545 DEBUGLOW("write_partial_output total_numRows %d y_buffer 0x%x y_buffer_offset 0x%x uv_buffer 0x%x uv_buffer_offset 0x%x",
546 total_numRows, (unsigned int) y_buffer, (unsigned int) y_buffer_offset, (unsigned int) uv_buffer, (unsigned int)uv_buffer_offset);
547
548 char Buff1[100];
549 sprintf(Buff1, "/tmp/dec_y_dump%d.bin", GlobalFileCount);
550 fp = fopen(Buff1,"wb+");
551 if(fp == NULL)
552 ERROR(">> error in file create ");
553#endif
554
555 DEBUGLOW("write_partial_output y_buffer 0x%x y_buffer_offset 0x%x y 0x%x numRow_y_offset %d stride %d orig_width %d",
556 (unsigned int) y_buffer, (unsigned int) y_buffer_offset, (unsigned int) y, numRow_y_offset, stride, orig_width);
557
558 DEBUGLOW("memcpy y_buffer dst 0x%x src 0x%x size %d", (unsigned int) y_buffer + y_buffer_offset, (unsigned int) y + (numRow_y_offset * stride), orig_width);
559
560 for ( i = 0; i < (numRows * 16 ); i++) {
561 memcpy(y_buffer + y_buffer_offset, y + (numRow_y_offset * stride), orig_width);
562
563#ifdef DUMP_PARTIAL_OUTPUT
564 size = fwrite(y_buffer + y_buffer_offset, 1, orig_width, fp);
565 if(size)
566 DEBUGLOW(">> dumped size = %d in file %s", orig_width, Buff1);
567 else
568 ERROR(">> writing % size", size);
569#endif
570
571 y_buffer_offset += orig_width;
572 sz += orig_width;
573 numRow_y_offset++;
574 }
575
576#ifdef DUMP_PARTIAL_OUTPUT
577 fclose(fp);
578
579 char Buff2[100];
580 sprintf(Buff2, "/tmp/dce_uv_dump%d.bin", GlobalFileCount);
581 fp = fopen(Buff2,"wb+");
582 if(fp == NULL)
583 ERROR(">> error in file create ");
584#endif
585
586 DEBUGLOW("write_partial_output uv_buffer 0x%x uv_buffer_offset 0x%x uv 0x%x numRow_uv_offset %d stride %d orig_width %d",
587 (unsigned int) uv_buffer, (unsigned int) uv_buffer_offset, (unsigned int) uv, numRow_uv_offset, stride, orig_width);
588
589 DEBUGLOW("memcpy uv_buffer dst 0x%x src 0x%x size %d", (unsigned int) uv_buffer + uv_buffer_offset, (unsigned int) uv + (numRow_uv_offset * stride), orig_width);
590
591 for ( i = 0; i < (numRows * 8 ); i++) {
592 memcpy(uv_buffer + uv_buffer_offset, uv + (numRow_uv_offset * stride), orig_width);
593
594#ifdef DUMP_PARTIAL_OUTPUT
595 size = fwrite(uv_buffer + uv_buffer_offset, 1, orig_width, fp);
596 if(size)
597 DEBUGLOW(">> dumped size = %d in file %s", orig_width, Buff2);
598 else
599 ERROR(">> writing % size", size);
600#endif
601
602 uv_buffer_offset += orig_width;
603 sz += orig_width;
604 numRow_uv_offset++;
605 }
606
607#ifdef DUMP_PARTIAL_OUTPUT
608 fclose(fp);
609 GlobalFileCount++;
610#endif
611
612 total_numRows += numRows;
613 DEBUGLOW("total_numRows %d height / 16 = %d", total_numRows, height / 16);
614
615 if (total_numRows == (height / 16)) {
616 // Meaning 1 full frame has been reached. Need to write the temp y_buffer and uv_buffer to file.
617 if( out_cnt < frames_to_write ) {
618 DEBUGLOW("write_partial_output writing the output file");
619
620 FILE* fd = fopen(pattern,"ab+");
621 if( fd < 0 ) {
622 ERROR("could open output file: %s (%d)", pattern, errno);
623 return (0);
624 }
625
626 fwrite(y_buffer, 1, orig_width * orig_height, fd);
627 DEBUGLOW("write_partial_output writing %d size from Y_buffer 0x%x", orig_width * orig_height, (unsigned int) y_buffer);
628 fwrite(uv_buffer, 1, orig_width * orig_height/2, fd);
629 DEBUGLOW("write_partial_output writing %d size from UV_buffer 0x%x", orig_width * orig_height/2, (unsigned int) uv_buffer);
630
631 fclose(fd);
632 }
633
634 out_cnt++;
635 numRow_y_offset = 0;
636 numRow_uv_offset = 0;
637 y_buffer_offset = 0;
638 uv_buffer_offset = 0;
639 total_numRows = 0;
640 }
641
642 DEBUGLOW("write_partial_output is returning size of %d", sz);
643 return (sz);
644}
645
646
498/* helper to write one frame of output */ 647/* helper to write one frame of output */
499int write_output(const char *pattern, int cnt, char *y, char *uv, int stride) 648int write_output(const char *pattern, int cnt, char *y, char *uv, int stride)
500{ 649{
501 int sz = 0, n = 0, i; 650 int sz = 0, n = 0, i;
502 const char *path = get_path(pattern, cnt); 651 const char *path = get_path(pattern, cnt);
503 652
653 DEBUG("write_output y 0x%x uv 0x%x", (unsigned int) y, (unsigned int) uv);
654
504 if( path == NULL ) { 655 if( path == NULL ) {
505 return (sz); 656 return (sz);
506 } 657 }
@@ -512,9 +663,9 @@ int write_output(const char *pattern, int cnt, char *y, char *uv, int stride)
512 return (0); 663 return (0);
513 } 664 }
514 665
515 for( i = 0; i < height; i++ ) { 666 for( i = 0; i < orig_height; i++ ) {
516 char *p = y; 667 char *p = y;
517 int len = width; 668 int len = orig_width;
518 669
519 while( len && ((n = write(fd, p, len)) > 0)) { 670 while( len && ((n = write(fd, p, len)) > 0)) {
520 sz += n; 671 sz += n;
@@ -530,9 +681,9 @@ int write_output(const char *pattern, int cnt, char *y, char *uv, int stride)
530 } 681 }
531 682
532 if( n >= 0 ) { 683 if( n >= 0 ) {
533 for( i = 0; i < height / 2; i++ ) { 684 for( i = 0; i < orig_height / 2; i++ ) {
534 char *p = uv; 685 char *p = uv;
535 int len = width; 686 int len = orig_width;
536 687
537 while( len && ((n = write(fd, p, len)) > 0)) { 688 while( len && ((n = write(fd, p, len)) > 0)) {
538 sz += n; 689 sz += n;
@@ -588,14 +739,73 @@ FILE *inputDump;
588#define VERSION_SIZE 128 739#define VERSION_SIZE 128
589#endif 740#endif
590 741
742/* Function callback for low latency decoder with NUMROWS*/
743/* Client is expected to read the dataSyncDesc information especially numBlocks for decoded output that is ready. */
744/* numBlocks is filled based on the output data being filled into the output buffer that was passed in VIDDEC3_process */
745/* The return value of this function is NULL when okay; if there is a problem return value < 0, then LIBDCE will print and Error and continue. */
746/* It is up to client to stop when client is not able to read/save the decoded output from output buffer pointer. */
747XDAS_Int32 H264D_MPU_PutDataFxn(XDM_DataSyncHandle dataSyncHandle, XDM_DataSyncDesc *dataSyncDesc)
748{
749 int numRows;
750
751 DEBUGLOW("-----------------------H264D_MPU_PutDataFxn START--------------------------------dataSyncHandle 0x%x dataSyncDesc->numBlocks %d ",
752 (unsigned int)dataSyncHandle, dataSyncDesc->numBlocks);
753 //Need to read the information in dataSyncDesc->numBlocks which specifies how many numBlocks that are ready in
754 //the output buffer pointer. Only write that much.
755 numRows = dataSyncDesc->numBlocks;
756
757 // This callback should be called when libdce is getting the putDataFxn on the 2nd MmRpc instances.
758 // At this point application/client receive information that numRows is ready in output buffers.
759 // Call the write_partial_output to write the available output YUV NV12 (1 numBlock = 16 row of height on luma section and 8 row of heigh on chroma section.
760
761 if (outBuf_lowlatency) {
762 DEBUGLOW("H264D_MPU_PutDataFxn tiler %d", tiler);
763 if( tiler ) {
764 DEBUGLOW("TILER outArgs->outputID[%d] 0x%x", 0, outArgs->outputID[0]);
765
766 /* calculate offset to region of interest */
767 XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion);
768
769 DEBUGLOW("r->topLeft.y 0x%x r->topLeft.x 0x%x", r->topLeft.y, r->topLeft.x);
770
771 int yoff = (r->topLeft.y * STRIDE) + r->topLeft.x;
772 int uvoff = (r->topLeft.y * (STRIDE / 2)) + (STRIDE * padded_height) + r->topLeft.x;
773
774 DEBUGLOW("outBuf_lowlatency 0x%x yoff 0x%x uvoff 0x%x numRow_y_offset %d", (unsigned int) outBuf_lowlatency, yoff, uvoff, numRow_y_offset);
775 DEBUGLOW("H264D_MPU_PutDataFxn TILER getting partial output buffer on outBuf_lowlatency : (%p) y 0x%x uv 0x%x",
776 outBuf_lowlatency, (unsigned int) outBuf_lowlatency + yoff, (unsigned int) outBuf_lowlatency + uvoff);
777 write_partial_output(out_pattern, outBuf_lowlatency + yoff, outBuf_lowlatency + uvoff, STRIDE, numRows);
778 } else {
779 DEBUGLOW("NONTILER outArgs->outputID[%d] 0x%x", 0, outArgs->outputID[0]);
780
781 /* calculate offset to region of interest */
782 XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion);
783
784 DEBUGLOW("r->topLeft.y 0x%x r->topLeft.x 0x%x", r->topLeft.y, r->topLeft.x);
785
786 int yoff = (r->topLeft.y * padded_width) + r->topLeft.x;
787 int uvoff = (r->topLeft.y * (padded_width / 2)) + (padded_height * padded_width) + r->topLeft.x;
788
789 DEBUGLOW("outBuf_lowlatency 0x%x yoff 0x%x uvoff 0x%x numRow_y_offset %d", (unsigned int) outBuf_lowlatency, yoff, uvoff, numRow_y_offset);
790 DEBUGLOW("H264D_MPU_PutDataFxn nonTILER getting partial output buffer on outBuf_lowlatency : (%p) y 0x%x uv 0x%x",
791 outBuf_lowlatency, (unsigned int) outBuf_lowlatency + yoff, (unsigned int) outBuf_lowlatency + uvoff);
792 write_partial_output(out_pattern, outBuf_lowlatency + yoff, outBuf_lowlatency + uvoff, padded_width, numRows);
793 }
794 }
795
796 DEBUGLOW("-----------------------H264D_MPU_PutDataFxn END--------------------------------");
797 return (0);
798}
799
800
591/* decoder body */ 801/* decoder body */
592int main(int argc, char * *argv) 802int main(int argc, char * *argv)
593{ 803{
594 Engine_Error ec; 804 Engine_Error ec;
595 XDAS_Int32 err; 805 XDAS_Int32 err;
596 char *input = NULL; 806 char *input = NULL;
597 char *in_pattern, *out_pattern, *frameData; 807 char *in_pattern, *frameData;
598 int in_cnt = 0, out_cnt = 0; 808 int in_cnt = 0;
599 int oned, stride; 809 int oned, stride;
600 unsigned int frameCount = 0; 810 unsigned int frameCount = 0;
601 FILE *frameFile; 811 FILE *frameFile;
@@ -605,8 +815,10 @@ int main(int argc, char * *argv)
605 char *temp_data = NULL; 815 char *temp_data = NULL;
606 char vid_codec[10]; 816 char vid_codec[10];
607 char tilerbuffer[10]; 817 char tilerbuffer[10];
818 char row_mode[10];
608 unsigned int codec_switch = 0; 819 unsigned int codec_switch = 0;
609 Bool outBufsInUse = FALSE; 820 Bool outBufsInUse = FALSE;
821 int datamode;
610 822
611#ifdef PROFILE_TIME 823#ifdef PROFILE_TIME
612 uint64_t init_start_time = 0; 824 uint64_t init_start_time = 0;
@@ -616,7 +828,7 @@ int main(int argc, char * *argv)
616#endif 828#endif
617 829
618#if 0 830#if 0
619 int loop = 0; 831 volatile int loop = 0;
620 832
621 while( loop == 0 ) { 833 while( loop == 0 ) {
622 loop = 0; 834 loop = 0;
@@ -632,21 +844,21 @@ int main(int argc, char * *argv)
632 oned = FALSE; 844 oned = FALSE;
633 } 845 }
634 846
635 if( argc != 9 ) { 847 if( argc != 10 ) {
636 printf("usage: %s width height frames_to_write framefile inpattern outpattern codec tilerbuffer\n", argv[0]); 848 printf("usage: %s width height frames_to_write framefile inpattern outpattern codec tilerbuffer mode\n", argv[0]);
637 printf("example: %s 320 240 30 frame.txt in.h264 out.yuv h264 tiler\n", argv[0]); 849 printf("example: %s 320 240 30 frame.txt in.h264 out.yuv h264 tiler numrow/slice/fixed/full\n", argv[0]);
638 printf("example: %s 640 480 30 frame.txt in.m4v out.yuv mpeg4 nontiler\n", argv[0]); 850 printf("example: %s 640 480 30 frame.txt in.m4v out.yuv mpeg4 nontiler full\n", argv[0]);
639 printf("example: %s 720 480 30 frame.txt in.vc1 out.yuv vc1ap tiler\n", argv[0]); 851 printf("example: %s 720 480 30 frame.txt in.vc1 out.yuv vc1ap tiler full\n", argv[0]);
640 printf("example: %s 320 240 30 frame.txt in.vc1 out.yuv vc1smp nontiler\n", argv[0]); 852 printf("example: %s 320 240 30 frame.txt in.vc1 out.yuv vc1smp nontiler full\n", argv[0]);
641 printf("example: %s 1280 720 30 frame.txt in.bin out.yuv mjpeg tiler\n", argv[0]); 853 printf("example: %s 1280 720 30 frame.txt in.bin out.yuv mjpeg tiler full\n", argv[0]);
642 printf("example: %s 1920 1088 30 frame.txt in.bin out.yuv mpeg2 nontiler\n", argv[0]); 854 printf("example: %s 1920 1088 30 frame.txt in.bin out.yuv mpeg2 nontiler full\n", argv[0]);
643 printf("Currently supported codecs: h264, mpeg4, vc1ap, vc1smp, mjpeg, mpeg2\n"); 855 printf("Currently supported codecs: h264, mpeg4, vc1ap, vc1smp, mjpeg, mpeg2\n");
644 return (1); 856 return (1);
645 } 857 }
646 858
647 /* error checking? */ 859 // Extracting the input parameters
648 width = atoi(argv[1]); 860 orig_width = atoi(argv[1]);
649 height = atoi(argv[2]); 861 orig_height = atoi(argv[2]);
650 frames_to_write = atoi(argv[3]); 862 frames_to_write = atoi(argv[3]);
651 frameData = argv[4]; 863 frameData = argv[4];
652 in_pattern = argv[5]; 864 in_pattern = argv[5];
@@ -655,9 +867,14 @@ int main(int argc, char * *argv)
655 strcpy(vid_codec, temp_data); 867 strcpy(vid_codec, temp_data);
656 temp_data = argv[8]; 868 temp_data = argv[8];
657 strcpy(tilerbuffer, temp_data); 869 strcpy(tilerbuffer, temp_data);
870 temp_data = argv[9];
871 strcpy(row_mode, temp_data);
658 872
659 printf("Selected codec: %s\n", vid_codec); 873 printf("Selected codec: %s\n", vid_codec);
660 printf("Selected buffer: %s\n", tilerbuffer); 874 printf("Selected buffer: %s\n", tilerbuffer);
875 printf("Decode mode: %s\n", row_mode);
876 printf("in_pattern: %s\n", in_pattern);
877 printf("out_pattern: %s\n", out_pattern);
661 878
662 if( frames_to_write == -1 ) { 879 if( frames_to_write == -1 ) {
663 /* Default : 30 frames to write into output file */ 880 /* Default : 30 frames to write into output file */
@@ -676,7 +893,6 @@ int main(int argc, char * *argv)
676 if((!(strcmp(vid_codec, "h264")))) { 893 if((!(strcmp(vid_codec, "h264")))) {
677 ivahd_decode_type = IVAHD_H264_DECODE; 894 ivahd_decode_type = IVAHD_H264_DECODE;
678 codec_switch = DCE_TEST_H264; 895 codec_switch = DCE_TEST_H264;
679
680 } else if((!(strcmp(vid_codec, "mpeg4")))) { 896 } else if((!(strcmp(vid_codec, "mpeg4")))) {
681 ivahd_decode_type = IVAHD_MP4V_DECODE; 897 ivahd_decode_type = IVAHD_MP4V_DECODE;
682 codec_switch = DCE_TEST_MPEG4; 898 codec_switch = DCE_TEST_MPEG4;
@@ -702,6 +918,28 @@ int main(int argc, char * *argv)
702 return (1); 918 return (1);
703 } 919 }
704 920
921 if((!(strcmp(row_mode, "full")))) {
922 datamode = IVIDEO_ENTIREFRAME;
923 } else if ((!(strcmp(row_mode, "numrow")))) {
924 datamode = IVIDEO_NUMROWS;
925 } else if ((!(strcmp(row_mode, "slice")))) {
926 datamode = IVIDEO_SLICEMODE;
927 ERROR("SLICE mode is not supported.");
928 goto shutdown;
929 } else if ((!(strcmp(row_mode, "fixed")))) {
930 datamode = IVIDEO_FIXEDLENGTH;
931 ERROR("FIXED LENGTH mode is not supported.");
932 goto shutdown;
933 } else {
934 ERROR("WRONG argument mode %s", row_mode);
935 goto shutdown;
936 }
937
938 if( (ivahd_decode_type != IVAHD_H264_DECODE) && (datamode != IVIDEO_ENTIREFRAME) ) {
939 ERROR("WRONG argument codec type %s mode %s", vid_codec, row_mode);
940 goto shutdown;
941 }
942
705 DEBUG("Storing frame size data"); 943 DEBUG("Storing frame size data");
706 frameFile = fopen(frameData, "rb"); 944 frameFile = fopen(frameData, "rb");
707 DEBUG("frameFile open %p errno %d", frameFile, errno); 945 DEBUG("frameFile open %p errno %d", frameFile, errno);
@@ -723,11 +961,11 @@ int main(int argc, char * *argv)
723 } 961 }
724 } 962 }
725 963
726 DEBUG("Num Frames is %d width=%d, height=%d", frameCount, width, height); 964 DEBUG("Num Frames is %d orig_width=%d, orig_height=%d width=%d height=%d", frameCount, orig_width, orig_height, width, height);
727 965
728 /* calculate output buffer parameters: */ 966 /* calculate output buffer parameters: */
729 width = ALIGN2(width, 4); /* round up to MB */ 967 width = ALIGN2(orig_width, 4); /* round up to MB */
730 height = ALIGN2(height, 4); /* round up to MB */ 968 height = ALIGN2(orig_height, 4); /* round up to MB */
731 969
732 switch( codec_switch ) { 970 switch( codec_switch ) {
733 case DCE_TEST_H264 : 971 case DCE_TEST_H264 :
@@ -741,7 +979,7 @@ int main(int argc, char * *argv)
741 case DCE_TEST_MPEG4 : 979 case DCE_TEST_MPEG4 :
742 padded_width = ALIGN2(width + PADX_MPEG4, 7); 980 padded_width = ALIGN2(width + PADX_MPEG4, 7);
743 padded_height = height + PADY_MPEG4; 981 padded_height = height + PADY_MPEG4;
744 num_buffers = 8; 982 num_buffers = 4;
745 break; 983 break;
746 case DCE_TEST_VC1SMP : 984 case DCE_TEST_VC1SMP :
747 case DCE_TEST_VC1AP : 985 case DCE_TEST_VC1AP :
@@ -767,8 +1005,8 @@ int main(int argc, char * *argv)
767 stride = 4096; 1005 stride = 4096;
768 } 1006 }
769 1007
770 DEBUG("padded_width=%d, padded_height=%d, stride=%d, num_buffers=%d", 1008 DEBUG("width=%d, height=%dpadded_width=%d, padded_height=%d, stride=%d, num_buffers=%d",
771 padded_width, padded_height, stride, num_buffers); 1009 width, height, padded_width, padded_height, stride, num_buffers);
772#ifdef PROFILE_TIME 1010#ifdef PROFILE_TIME
773 init_start_time = mark_microsecond(NULL); 1011 init_start_time = mark_microsecond(NULL);
774#endif 1012#endif
@@ -790,12 +1028,24 @@ int main(int argc, char * *argv)
790 } 1028 }
791 params->size = sizeof(IH264VDEC_Params); 1029 params->size = sizeof(IH264VDEC_Params);
792 params->maxBitRate = 10000000; 1030 params->maxBitRate = 10000000;
793 params->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO; 1031 if (datamode == IVIDEO_NUMROWS) {
794 params->numOutputDataUnits = 0; 1032 // Constraint: display order not being same as decode order with IVIDDEC3_Params::outputDataMode = IVIDEO_NUMROWS, is an erroneous situation
1033 params->displayDelay = IVIDDEC3_DECODE_ORDER;
1034 DEBUG("low latency with IVIDDEC3_DECODE_ORDER");
1035 // If outputDataMode == IVIDEO_NUMROWS, then it defines the frequency
1036 // at which decoder should inform to application about data availability.
1037 // For example, numOutputDataUnits = 2 means that after every 2MB row (2*16 lines)
1038 // availability in display buffer, decoder should inform to application.
1039 params->numOutputDataUnits = numBlock;
1040 } else if (datamode == IVIDEO_ENTIREFRAME) {
1041 params->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO;
1042 params->numOutputDataUnits = 0;
1043 }
795 params->maxWidth = width; 1044 params->maxWidth = width;
1045
796 break; 1046 break;
797 case DCE_TEST_MPEG4 : 1047 case DCE_TEST_MPEG4 :
798 params = dce_alloc(sizeof(IMPEG4VDEC_Params)); 1048 params = dce_alloc(sizeof(IMPEG4VDEC_Params));
799 if( !params ) { 1049 if( !params ) {
800 ERROR("DCE_TEST_FAIL: Parameter memory allocation failed"); 1050 ERROR("DCE_TEST_FAIL: Parameter memory allocation failed");
801 goto out; 1051 goto out;
@@ -852,13 +1102,18 @@ int main(int argc, char * *argv)
852 params->dataEndianness = XDM_BYTE; 1102 params->dataEndianness = XDM_BYTE;
853 params->forceChromaFormat = XDM_YUV_420SP; 1103 params->forceChromaFormat = XDM_YUV_420SP;
854 params->operatingMode = IVIDEO_DECODE_ONLY; 1104 params->operatingMode = IVIDEO_DECODE_ONLY;
855 //params->displayDelay = IVIDDEC3_DECODE_ORDER;
856 params->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED; 1105 params->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED;
857 params->inputDataMode = IVIDEO_ENTIREFRAME; 1106 params->inputDataMode = IVIDEO_ENTIREFRAME;
858 params->metadataType[0] = IVIDEO_METADATAPLANE_NONE; 1107 params->metadataType[0] = IVIDEO_METADATAPLANE_NONE;
859 params->metadataType[1] = IVIDEO_METADATAPLANE_NONE; 1108 params->metadataType[1] = IVIDEO_METADATAPLANE_NONE;
860 params->metadataType[2] = IVIDEO_METADATAPLANE_NONE; 1109 params->metadataType[2] = IVIDEO_METADATAPLANE_NONE;
861 params->outputDataMode = IVIDEO_ENTIREFRAME; 1110
1111 if (datamode == IVIDEO_NUMROWS) {
1112 params->outputDataMode = IVIDEO_NUMROWS;
1113 } else if (datamode == IVIDEO_ENTIREFRAME) {
1114 params->outputDataMode = IVIDEO_ENTIREFRAME;
1115 }
1116
862 params->numInputDataUnits = 0; 1117 params->numInputDataUnits = 0;
863 params->errorInfoMode = IVIDEO_ERRORINFO_OFF; 1118 params->errorInfoMode = IVIDEO_ERRORINFO_OFF;
864 1119
@@ -952,6 +1207,11 @@ int main(int argc, char * *argv)
952 case DCE_TEST_H264 : 1207 case DCE_TEST_H264 :
953 dynParams = dce_alloc(sizeof(IH264VDEC_DynamicParams)); 1208 dynParams = dce_alloc(sizeof(IH264VDEC_DynamicParams));
954 dynParams->size = sizeof(IH264VDEC_DynamicParams); 1209 dynParams->size = sizeof(IH264VDEC_DynamicParams);
1210 if (datamode == IVIDEO_NUMROWS) {
1211 dynParams->putDataFxn = (XDM_DataSyncPutFxn) H264D_MPU_PutDataFxn;
1212 dynParams->putDataHandle = codec;
1213 DEBUG("dynParams->putDataFxn %p dynParams->putDataHandle 0x%x", dynParams->putDataFxn, (unsigned int) dynParams->putDataHandle);
1214 }
955 break; 1215 break;
956 case DCE_TEST_MPEG4 : 1216 case DCE_TEST_MPEG4 :
957 dynParams = dce_alloc(sizeof(IMPEG4VDEC_DynamicParams)); 1217 dynParams = dce_alloc(sizeof(IMPEG4VDEC_DynamicParams));
@@ -991,8 +1251,9 @@ int main(int argc, char * *argv)
991#ifdef GETVERSION 1251#ifdef GETVERSION
992 // Allocating memory to store the Codec version information from Codec. 1252 // Allocating memory to store the Codec version information from Codec.
993 char *codec_version = NULL; 1253 char *codec_version = NULL;
1254 DEBUG("Codec version Size %d ", sizeof(VERSION_SIZE));
994 codec_version = dce_alloc(VERSION_SIZE); 1255 codec_version = dce_alloc(VERSION_SIZE);
995 DEBUG("codec_version 0x%x", codec_version); 1256 DEBUG("codec_version 0x%x", (unsigned int) codec_version);
996#endif 1257#endif
997 1258
998 switch( codec_switch ) { 1259 switch( codec_switch ) {
@@ -1144,10 +1405,11 @@ int main(int argc, char * *argv)
1144 1405
1145 DEBUG("VIDDEC3_control XDM_SETPARAMS successful"); 1406 DEBUG("VIDDEC3_control XDM_SETPARAMS successful");
1146 1407
1147 DEBUG("input buffer configuration width %d height %d", width, height); 1408 DEBUG("input buffer configuration orig_width %d orig_height %d width %d height %d", orig_width, orig_height, width, height);
1409
1148 inBufs = dce_alloc(sizeof(XDM2_BufDesc)); 1410 inBufs = dce_alloc(sizeof(XDM2_BufDesc));
1149 inBufs->numBufs = 1; 1411 inBufs->numBufs = 1;
1150 input = dce_alloc(width * height); 1412 input = dce_alloc(orig_width * orig_height);
1151 inBufs->descs[0].buf = (XDAS_Int8 *)input; 1413 inBufs->descs[0].buf = (XDAS_Int8 *)input;
1152 inBufs->descs[0].memType = XDM_MEMTYPE_RAW; 1414 inBufs->descs[0].memType = XDM_MEMTYPE_RAW;
1153 1415
@@ -1174,6 +1436,27 @@ int main(int argc, char * *argv)
1174 padded_width, padded_height, stride); 1436 padded_width, padded_height, stride);
1175 } 1437 }
1176 1438
1439 if (datamode == IVIDEO_NUMROWS) {
1440 y_buffer = dce_alloc(width * height);
1441 if (!y_buffer) {
1442 ERROR("Failed to allocate luma buffer for temporary Y buffer on Low Latency case");
1443 goto shutdown;
1444 }
1445 orig_y_buffer = y_buffer;
1446 uv_buffer = dce_alloc(width * height/2);
1447 if (!uv_buffer) {
1448 ERROR("Failed to allocate chroma buffer for temporary UV buffer on Low Latency case");
1449 goto shutdown;
1450 }
1451 orig_uv_buffer = uv_buffer;
1452
1453 if (tiler) {
1454 output_uv_offset = output_y_offset + (4096 * height);
1455 } else {
1456 output_uv_offset = output_y_offset + (width * height);
1457 }
1458 }
1459
1177#ifdef PROFILE_TIME 1460#ifdef PROFILE_TIME
1178 output_alloc_time = mark_microsecond(&alloc_time_start); 1461 output_alloc_time = mark_microsecond(&alloc_time_start);
1179#endif 1462#endif
@@ -1344,20 +1627,28 @@ int main(int argc, char * *argv)
1344 fflush(inputDump); 1627 fflush(inputDump);
1345 fclose(inputDump); 1628 fclose(inputDump);
1346 inputDump = NULL; 1629 inputDump = NULL;
1347 #endif 1630#endif
1348 1631
1349 int iters = 0; 1632 int iters = 0;
1350 1633
1351 do { 1634 do {
1352 DEBUG("Calling VIDDEC3_process inArgs->inputID=%x inBufs->descs[0].buf %p inBufs->descs.bufSize %d input %p", 1635 DEBUG("Calling VIDDEC3_process inArgs->inputID=%d inBufs->descs[0].buf %p inBufs->descs.bufSize %d input %p",
1353 inArgs->inputID, inBufs->descs[0].buf, (int) inBufs->descs[0].bufSize.bytes, input); 1636 inArgs->inputID, inBufs->descs[0].buf, (int) inBufs->descs[0].bufSize.bytes, input);
1354#ifdef PROFILE_TIME 1637#ifdef PROFILE_TIME
1355 codec_process_time = mark_microsecond(NULL); 1638 codec_process_time = mark_microsecond(NULL);
1356#endif 1639#endif
1640
1641 if (datamode == IVIDEO_NUMROWS) {
1642 outBuf_lowlatency = (Char*) outBufs->descs[0].buf;
1643 DEBUG("Before calling VIDDEC3_process checking outBufs %p outBufs->descs[0].buf %p outBuf_lowlatency %p",
1644 outBufs, outBufs->descs[0].buf, outBuf_lowlatency);
1645 }
1646
1357 err = VIDDEC3_process(codec, inBufs, outBufs, inArgs, outArgs); 1647 err = VIDDEC3_process(codec, inBufs, outBufs, inArgs, outArgs);
1358#ifdef PROFILE_TIME 1648#ifdef PROFILE_TIME
1359 INFO("processed returned in: %llu us", (uint64_t) mark_microsecond(&codec_process_time)); 1649 INFO("processed returned in: %llu us", (uint64_t) mark_microsecond(&codec_process_time));
1360#endif 1650#endif
1651 DEBUG("VIDDEC3_process complete");
1361 if( err == DCE_EXDM_FAIL ) { 1652 if( err == DCE_EXDM_FAIL ) {
1362 if( XDM_ISFATALERROR(outArgs->extendedError)) { 1653 if( XDM_ISFATALERROR(outArgs->extendedError)) {
1363 ERROR("process returned error: %d\n", err); 1654 ERROR("process returned error: %d\n", err);
@@ -1400,51 +1691,62 @@ int main(int argc, char * *argv)
1400 goto shutdown; 1691 goto shutdown;
1401 } 1692 }
1402 1693
1403 /* 1694 if (datamode == IVIDEO_ENTIREFRAME) {
1404 * Handling of output data from codec 1695 /*
1405 */ 1696 * Handling of output data from codec
1406 if( tiler ) { 1697 */
1407 for( i = 0; outArgs->outputID[i]; i++ ) { 1698 DEBUG("low latency check outArgs->outputID[0] %p", (void*) outArgs->outputID[0]);
1408 /* calculate offset to region of interest */ 1699 if( tiler ) {
1409 XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion); 1700 for( i = 0; outArgs->outputID[i]; i++ ) {
1701 /* calculate offset to region of interest */
1702 XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion);
1703
1704 int yoff = (r->topLeft.y * stride) + r->topLeft.x;
1705 int uvoff = (r->topLeft.y * stride / 2) + (stride * padded_height) + r->topLeft.x;
1410 1706
1411 int yoff = (r->topLeft.y * stride) + r->topLeft.x; 1707 /* get the output buffer and write it to file */
1412 int uvoff = (r->topLeft.y * stride / 2) + (stride * padded_height) + r->topLeft.x; 1708 buf = (OutputBuffer *)outArgs->outputID[i];
1709 DEBUG("pop: %d (%p)", out_cnt, buf);
1413 1710
1414 /* get the output buffer and write it to file */ 1711 DEBUG("TILER buf->buf %p yoff 0x%x uvoff 0x%x", buf->buf, yoff, uvoff);
1415 buf = (OutputBuffer *)outArgs->outputID[i];
1416 DEBUG("pop: %d (%p)", out_cnt, buf);
1417 1712
1418 if( out_cnt < frames_to_write ) { // write first 30 frames to output file out_cnt < 300 1713 if( out_cnt < frames_to_write ) { // write first 30 frames to output file out_cnt < 300
1419 write_output(out_pattern, out_cnt++, buf->buf + yoff, 1714 write_output(out_pattern, out_cnt++, buf->buf + yoff,
1420 buf->buf + uvoff, stride); 1715 buf->buf + uvoff, stride);
1421 } else { 1716 } else {
1422 out_cnt++; 1717 out_cnt++;
1718 }
1423 } 1719 }
1424 } 1720 } else {
1425 } else { 1721 for( i = 0; outArgs->outputID[i]; i++ ) {
1426 for( i = 0; outArgs->outputID[i]; i++ ) { 1722 /* calculate offset to region of interest */
1427 /* calculate offset to region of interest */ 1723 XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion);
1428 XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion); 1724
1725 int yoff = (r->topLeft.y * padded_width) + r->topLeft.x;
1726 int uvoff = (r->topLeft.y * padded_width / 2) + (padded_height * padded_width) + r->topLeft.x;
1429 1727
1430 int yoff = (r->topLeft.y * padded_width) + r->topLeft.x; 1728 /* get the output buffer and write it to file */
1431 int uvoff = (r->topLeft.y * padded_width / 2) + (padded_height * padded_width) + r->topLeft.x; 1729 buf = (OutputBuffer *)outArgs->outputID[i];
1730 DEBUG("pop: %d (%p)", out_cnt, buf);
1432 1731
1433 /* get the output buffer and write it to file */ 1732 DEBUG("NONTILER buf->buf %p yoff 0x%x uvoff 0x%x", buf->buf, yoff, uvoff);
1434 buf = (OutputBuffer *)outArgs->outputID[i];
1435 DEBUG("pop: %d (%p)", out_cnt, buf);
1436 1733
1437 if( out_cnt < frames_to_write ) { // write first frames_to_write frames to output file as 1734 if( out_cnt < frames_to_write ) { // write first frames_to_write frames to output file as
1438 write_output(out_pattern, out_cnt++, buf->buf + yoff, 1735 write_output(out_pattern, out_cnt++, buf->buf + yoff,
1439 buf->buf + uvoff, padded_width); 1736 buf->buf + uvoff, padded_width);
1440 } else { 1737 } else {
1441 out_cnt++; 1738 out_cnt++;
1739 }
1442 } 1740 }
1443 } 1741 }
1444 } 1742 }
1445 1743
1744 if (datamode == IVIDEO_NUMROWS) {
1745 DEBUG("Check outArgs->freeBufID[0] %p", (void*) outArgs->freeBufID[0]);
1746 }
1747
1446 for( i = 0; outArgs->freeBufID[i]; i++ ) { 1748 for( i = 0; outArgs->freeBufID[i]; i++ ) {
1447 DEBUG("freeBufID[%d] = %d", i, outArgs->freeBufID[i]); 1749 DEBUG("freeBufID[%d] = %p", i, (void*) outArgs->freeBufID[i]);
1448 buf = (OutputBuffer *)outArgs->freeBufID[i]; 1750 buf = (OutputBuffer *)outArgs->freeBufID[i];
1449 output_release(buf); 1751 output_release(buf);
1450 } 1752 }
@@ -1463,8 +1765,10 @@ int main(int argc, char * *argv)
1463 1765
1464shutdown: 1766shutdown:
1465 1767
1466 printf("\nDeleting codec...\n"); 1768 printf("\nDeleting codec 0x%x...\n", (unsigned int) codec);
1467 VIDDEC3_delete(codec); 1769 if( codec ) {
1770 VIDDEC3_delete(codec);
1771 }
1468 1772
1469out: 1773out:
1470 if( engine ) { 1774 if( engine ) {
@@ -1495,6 +1799,16 @@ out:
1495 dce_free(input); 1799 dce_free(input);
1496 } 1800 }
1497 1801
1802 if (datamode == IVIDEO_NUMROWS) {
1803 if (y_buffer) {
1804 dce_free(y_buffer);
1805 }
1806
1807 if (uv_buffer) {
1808 dce_free(uv_buffer);
1809 }
1810 }
1811
1498 output_free(); 1812 output_free();
1499 1813
1500 fclose(frameFile); 1814 fclose(frameFile);