summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbuddy.liong2013-12-03 18:17:21 -0600
committerbuddy.liong2013-12-04 10:40:02 -0600
commit1d2fcbbbecb2e82b1ce0c79b146a92c8c3cbd707 (patch)
tree21a684174ef1502b2bc129fdb3b86bc270e733e6
parentcb7080738ebb729184aa8afcd31c2f54d940f6b2 (diff)
downloadrepo-libdce-1d2fcbbbecb2e82b1ce0c79b146a92c8c3cbd707.tar.gz
repo-libdce-1d2fcbbbecb2e82b1ce0c79b146a92c8c3cbd707.tar.xz
repo-libdce-1d2fcbbbecb2e82b1ce0c79b146a92c8c3cbd707.zip
[LIBDCE] Add non-TILER input buffer for dce_enc_test
Adding capability for the QNX dce_enc_test to use buffer allocated through shmallocator instead of TILER memory on the input buffer. Fixing the submission on http://review.omapzoom.org/34254 as originally it was pressumed that TI encoder codec required the input to be 2D TILER buffer. With this patch when executing dce_enc_test with "nontiler" argument, the input and output buffers will be using the non TILER (through shmallocator). Change-Id: I14aff91a4f5491dd0efcab316d584585263fb666 Signed-off-by: buddy.liong <buddy.budiono@ti.com>
-rw-r--r--test_qnx/dce_enc_test/dce_enc_test.c132
1 files changed, 88 insertions, 44 deletions
diff --git a/test_qnx/dce_enc_test/dce_enc_test.c b/test_qnx/dce_enc_test/dce_enc_test.c
index 07afb04..c8f6eed 100644
--- a/test_qnx/dce_enc_test/dce_enc_test.c
+++ b/test_qnx/dce_enc_test/dce_enc_test.c
@@ -183,7 +183,7 @@ static int allocate_nonTiler(shm_buf* shmBuf, int size)
183 ERROR("Failed to check memory contiguous ret %d errno %d\n", ret, errno); 183 ERROR("Failed to check memory contiguous ret %d errno %d\n", ret, errno);
184 SHM_release(shmBuf); 184 SHM_release(shmBuf);
185 return (-ENOMEM); 185 return (-ENOMEM);
186 } else if( len != (size)) { 186 } else if( len != (size) ) {
187 ERROR("Failed to check len %d != %d\n", len, size); 187 ERROR("Failed to check len %d != %d\n", len, size);
188 SHM_release(shmBuf); 188 SHM_release(shmBuf);
189 return (-ENOMEM); 189 return (-ENOMEM);
@@ -223,7 +223,7 @@ static const char *get_path(const char *pattern, int cnt)
223 /* It would be better to not assume the pattern doesn't expand to 223 /* It would be better to not assume the pattern doesn't expand to
224 * less than 10 chars it's original length.. 224 * less than 10 chars it's original length..
225 */ 225 */
226 if((strlen(pattern) + 10) > len ) { 226 if( (strlen(pattern) + 10) > len ) {
227 len = strlen(pattern) + 10; 227 len = strlen(pattern) + 10;
228 path = realloc(path, len); 228 path = realloc(path, len);
229 } 229 }
@@ -281,7 +281,12 @@ int read_input(const char *pattern, int cnt, char *input)
281 DEBUG("Reading REACH EOF - return -1"); 281 DEBUG("Reading REACH EOF - return -1");
282 return (-1); //Cannot read anymore input 282 return (-1); //Cannot read anymore input
283 } 283 }
284 input = (char *) ((int)input + 4096); 284
285 if( tiler ) {
286 input = (char *) ((int)input + 4096);
287 } else {
288 input = (char *) ((int)input + width);
289 }
285 } 290 }
286 } 291 }
287 292
@@ -344,6 +349,7 @@ int main(int argc, char * *argv)
344 char *output_mvbuf = NULL; 349 char *output_mvbuf = NULL;
345 shm_buf output_mvbuf_nonTiler; 350 shm_buf output_mvbuf_nonTiler;
346 shm_buf output_nonTiler; 351 shm_buf output_nonTiler;
352 shm_buf input_nonTiler;
347 int output_size = 0; 353 int output_size = 0;
348 int mvbufinfo_size = 0; 354 int mvbufinfo_size = 0;
349 char *in_pattern, *out_pattern; 355 char *in_pattern, *out_pattern;
@@ -377,7 +383,7 @@ int main(int argc, char * *argv)
377 383
378#endif 384#endif
379 385
380 if((argc >= 2) && !strcmp(argv[1], "-1")) { 386 if( (argc >= 2) && !strcmp(argv[1], "-1") ) {
381 oned = TRUE; 387 oned = TRUE;
382 argc--; 388 argc--;
383 argv++; 389 argv++;
@@ -418,12 +424,12 @@ int main(int argc, char * *argv)
418 * Configuration based on the input parameters 424 * Configuration based on the input parameters
419 */ 425 */
420 426
421 if((!(strcmp(vid_codec, "h264")))) { 427 if( (!(strcmp(vid_codec, "h264"))) ) {
422 ivahd_encode_type = IVAHD_H264_ENCODE; 428 ivahd_encode_type = IVAHD_H264_ENCODE;
423 codec_switch = DCE_ENC_TEST_H264; 429 codec_switch = DCE_ENC_TEST_H264;
424 if((!(strcmp(profile, "baseline")))) { 430 if( (!(strcmp(profile, "baseline"))) ) {
425 profile_value = IH264_BASELINE_PROFILE; 431 profile_value = IH264_BASELINE_PROFILE;
426 } else if((!(strcmp(profile, "high")))) { 432 } else if( (!(strcmp(profile, "high"))) ) {
427 profile_value = IH264_HIGH_PROFILE; 433 profile_value = IH264_HIGH_PROFILE;
428 } else { 434 } else {
429 printf("Wrong profile value. Please use: baseline or high. See 'use dce_enc_test'.\n"); 435 printf("Wrong profile value. Please use: baseline or high. See 'use dce_enc_test'.\n");
@@ -458,7 +464,7 @@ int main(int argc, char * *argv)
458 ivahd_encode_type = IVAHD_MPEG4_ENCODE; 464 ivahd_encode_type = IVAHD_MPEG4_ENCODE;
459 codec_switch = DCE_ENC_TEST_MPEG4; 465 codec_switch = DCE_ENC_TEST_MPEG4;
460 466
461 if((!(strcmp(profile, "simple")))) { 467 if( (!(strcmp(profile, "simple"))) ) {
462 profile_value = 3; 468 profile_value = 3;
463 } else { 469 } else {
464 printf("Wrong profile value. Please use: simple. See 'use dce_enc_test'.\n"); 470 printf("Wrong profile value. Please use: simple. See 'use dce_enc_test'.\n");
@@ -485,7 +491,7 @@ int main(int argc, char * *argv)
485 ivahd_encode_type = IVAHD_H263_ENCODE; 491 ivahd_encode_type = IVAHD_H263_ENCODE;
486 codec_switch = DCE_ENC_TEST_H263; 492 codec_switch = DCE_ENC_TEST_H263;
487 493
488 if((!(strcmp(profile, "simple")))) { 494 if( (!(strcmp(profile, "simple"))) ) {
489 profile_value = 3; 495 profile_value = 3;
490 } else { 496 } else {
491 printf("Wrong profile value. Please use: simple. See 'use dce_enc_test'.\n"); 497 printf("Wrong profile value. Please use: simple. See 'use dce_enc_test'.\n");
@@ -559,7 +565,6 @@ int main(int argc, char * *argv)
559 inBufs->imageRegion.topLeft.x = 0; 565 inBufs->imageRegion.topLeft.x = 0;
560 inBufs->imageRegion.topLeft.y = 0; 566 inBufs->imageRegion.topLeft.y = 0;
561 inBufs->imageRegion.bottomRight.x = width; 567 inBufs->imageRegion.bottomRight.x = width;
562 inBufs->imagePitch[0] = 4096;
563 568
564 inBufs->topFieldFirstFlag = 0; //Only valid for interlace content. 569 inBufs->topFieldFirstFlag = 0; //Only valid for interlace content.
565 inBufs->contentType = IVIDEO_PROGRESSIVE; 570 inBufs->contentType = IVIDEO_PROGRESSIVE;
@@ -575,31 +580,66 @@ int main(int argc, char * *argv)
575 inBufs->secondFieldOffsetWidth[0] = 0; 580 inBufs->secondFieldOffsetWidth[0] = 0;
576 inBufs->secondFieldOffsetHeight[0] = 0; 581 inBufs->secondFieldOffsetHeight[0] = 0;
577 582
578 inBufs->planeDesc[0].memType = XDM_MEMTYPE_TILED8; 583 if( !(strcmp(tilerbuffer, "tiler")) ) {
579 inBufs->planeDesc[0].bufSize.tileMem.width = width; 584 DEBUG("Input allocate through TILER 2D");
580 inBufs->planeDesc[0].bufSize.tileMem.height = height; 585 tiler = 1;
581 586
582 inBufs->imagePitch[1] = 4096; 587 inBufs->imagePitch[0] = 4096;
583 inBufs->secondFieldOffsetWidth[1] = 1; 588 inBufs->planeDesc[0].memType = XDM_MEMTYPE_TILED8;
584 inBufs->secondFieldOffsetHeight[1] = 0; 589 inBufs->planeDesc[0].bufSize.tileMem.width = width;
590 inBufs->planeDesc[0].bufSize.tileMem.height = height;
585 591
586 inBufs->planeDesc[1].memType = XDM_MEMTYPE_TILED16; 592 inBufs->secondFieldOffsetWidth[1] = 1;
587 inBufs->planeDesc[1].bufSize.tileMem.width = width; /* UV interleaved width is same a Y */ 593 inBufs->secondFieldOffsetHeight[1] = 0;
588 inBufs->planeDesc[1].bufSize.tileMem.height = height / 2;
589 594
590 // INPUT BUFFER MUST BE TILED NV12. Encoder codec doesn't support non TILED input buffer. 595 inBufs->imagePitch[1] = 4096;
591 buf = calloc(sizeof(InputBuffer), 1); 596 inBufs->planeDesc[1].memType = XDM_MEMTYPE_TILED16;
592 DEBUG(" ----------------- create INPUT TILER buf 0x%x --------------------", (unsigned int)buf); 597 inBufs->planeDesc[1].bufSize.tileMem.width = width; /* UV interleaved width is same a Y */
593 buf->buf = tiler_alloc(width, height); 598 inBufs->planeDesc[1].bufSize.tileMem.height = height / 2;
594 if( buf->buf ) {
595 buf->y = (SSPtr)buf->buf;
596 buf->uv = (SSPtr)buf->buf + (height * 4096);
597 599
598 DEBUG("INPUT TILER buf=%p, buf->buf=%p y=%08x, uv=%08x", buf, buf->buf, buf->y, buf->uv); 600 // INPUT BUFFER MUST BE TILED NV12. Encoder codec doesn't support non TILED input buffer.
601 buf = calloc(sizeof(InputBuffer), 1);
602 DEBUG(" ----------------- create INPUT TILER buf 0x%x --------------------", (unsigned int)buf);
603 buf->buf = tiler_alloc(width, height);
604 if( buf->buf ) {
605 buf->y = (SSPtr)buf->buf;
606 buf->uv = (SSPtr)buf->buf + (height * 4096);
607
608 DEBUG("INPUT TILER buf=%p, buf->buf=%p y=%08x, uv=%08x", buf, buf->buf, buf->y, buf->uv);
609 } else {
610 ERROR(" ---------------- tiler_alloc failed --------------------");
611 free(buf);
612 goto shutdown;
613 }
599 } else { 614 } else {
600 ERROR(" ---------------- tiler_alloc failed --------------------"); 615 DEBUG("Input allocate through NON-TILER");
601 free(buf); 616 tiler = 0;
602 goto shutdown; 617
618 inBufs->imagePitch[0] = width;
619 inBufs->planeDesc[0].memType = XDM_MEMTYPE_RAW;
620 inBufs->planeDesc[0].bufSize.bytes = width * height;
621 inBufs->secondFieldOffsetWidth[1] = 1;
622 inBufs->secondFieldOffsetHeight[1] = 0;
623
624 inBufs->imagePitch[1] = width;
625 inBufs->planeDesc[1].memType = XDM_MEMTYPE_RAW;
626 inBufs->planeDesc[1].bufSize.bytes = width * height / 2;
627 buf = calloc(sizeof(InputBuffer), 1);
628 DEBUG(" ----------------- create NON INPUT TILER buf 0x%x --------------------", (unsigned int)buf);
629 err = allocate_nonTiler(&input_nonTiler, width * height * 3/2);
630 if( err < 0 ) {
631 ERROR(" ---------------- allocate_nonTiler failed --------------------");
632 free(buf);
633 goto shutdown;
634 }
635 else
636 {
637 buf->buf = (char*)input_nonTiler.vir_addr;
638 buf->y = (SSPtr)input_nonTiler.vir_addr;
639 buf->uv = (SSPtr)input_nonTiler.vir_addr + (height * width);
640
641 DEBUG("INPUT NON TILER buf=%p, buf->buf=%p y=%08x, uv=%08x", buf, buf->buf, buf->y, buf->uv);
642 }
603 } 643 }
604 644
605#ifdef PROFILE_TIME 645#ifdef PROFILE_TIME
@@ -1128,20 +1168,18 @@ int main(int argc, char * *argv)
1128 output_size = status->bufInfo.minOutBufSize[0].bytes; 1168 output_size = status->bufInfo.minOutBufSize[0].bytes;
1129 mvbufinfo_size = status->bufInfo.minOutBufSize[1].bytes; 1169 mvbufinfo_size = status->bufInfo.minOutBufSize[1].bytes;
1130 1170
1131 if (codec_switch == DCE_ENC_TEST_H264) { 1171 if( codec_switch == DCE_ENC_TEST_H264 ) {
1132 outBufs->numBufs = status->bufInfo.minNumOutBufs; // this value is 1 1172 outBufs->numBufs = status->bufInfo.minNumOutBufs; // this value is 1
1133 } else if( codec_switch == DCE_ENC_TEST_MPEG4 || codec_switch == DCE_ENC_TEST_H263 ) { 1173 } else if( (codec_switch == DCE_ENC_TEST_MPEG4) || (codec_switch == DCE_ENC_TEST_H263) ) {
1134 outBufs->numBufs = 1; 1174 outBufs->numBufs = 1;
1135 } 1175 }
1136 1176
1137 if( !(strcmp(tilerbuffer, "tiler"))) { 1177 if( tiler ) {
1138 DEBUG("Output allocate through TILER 1D"); 1178 DEBUG("Output allocate through TILER 1D");
1139 tiler = 1;
1140 output = tiler_alloc(output_size, 0); 1179 output = tiler_alloc(output_size, 0);
1141 1180
1142 } else { 1181 } else {
1143 DEBUG("Output allocate through NON-TILER"); 1182 DEBUG("Output allocate through NON-TILER");
1144 tiler = 0;
1145 err = allocate_nonTiler(&output_nonTiler, output_size); 1183 err = allocate_nonTiler(&output_nonTiler, output_size);
1146 if( err < 0 ) { 1184 if( err < 0 ) {
1147 ERROR("fail: %d", err); 1185 ERROR("fail: %d", err);
@@ -1156,8 +1194,8 @@ int main(int argc, char * *argv)
1156 1194
1157 DEBUG("Is TILER %d outBufs->descs[0].buf %p output %p output_nonTiler %p mvbufinfo_size %d", tiler, outBufs->descs[0].buf, output, &output_nonTiler, mvbufinfo_size); 1195 DEBUG("Is TILER %d outBufs->descs[0].buf %p output %p output_nonTiler %p mvbufinfo_size %d", tiler, outBufs->descs[0].buf, output, &output_nonTiler, mvbufinfo_size);
1158 1196
1159 if (mvbufinfo_size > 0) { 1197 if( mvbufinfo_size > 0 ) {
1160 if (tiler) { 1198 if( tiler ) {
1161 output_mvbuf = tiler_alloc(mvbufinfo_size, 0); 1199 output_mvbuf = tiler_alloc(mvbufinfo_size, 0);
1162 DEBUG("MVBufInfo: TILER outBufs->descs[1].buf %p output_mvbuf %p", outBufs->descs[1].buf, output_mvbuf); 1200 DEBUG("MVBufInfo: TILER outBufs->descs[1].buf %p output_mvbuf %p", outBufs->descs[1].buf, output_mvbuf);
1163 } 1201 }
@@ -1196,7 +1234,7 @@ int main(int argc, char * *argv)
1196 //Read the NV12 frame to input buffer to be encoded. 1234 //Read the NV12 frame to input buffer to be encoded.
1197 n = read_input(in_pattern, in_cnt, buf->buf); 1235 n = read_input(in_pattern, in_cnt, buf->buf);
1198 1236
1199 if( n && (n != -1)) { 1237 if( n && (n != -1) ) {
1200 eof = 0; 1238 eof = 0;
1201 inBufs->planeDesc[0].buf = (XDAS_Int8 *)buf->y; 1239 inBufs->planeDesc[0].buf = (XDAS_Int8 *)buf->y;
1202 inBufs->planeDesc[1].buf = (XDAS_Int8 *)buf->uv; 1240 inBufs->planeDesc[1].buf = (XDAS_Int8 *)buf->uv;
@@ -1211,7 +1249,7 @@ int main(int argc, char * *argv)
1211 if( codec_switch == DCE_ENC_TEST_H264 ) { 1249 if( codec_switch == DCE_ENC_TEST_H264 ) {
1212 h264enc_inArgs = (IH264ENC_InArgs *) inArgs; 1250 h264enc_inArgs = (IH264ENC_InArgs *) inArgs;
1213 DEBUG("TEST inArgs->inputID %d h264enc_inArgs->videnc2InArgs.inputID %d", inArgs->inputID, h264enc_inArgs->videnc2InArgs.inputID); 1251 DEBUG("TEST inArgs->inputID %d h264enc_inArgs->videnc2InArgs.inputID %d", inArgs->inputID, h264enc_inArgs->videnc2InArgs.inputID);
1214 } else if( codec_switch == DCE_ENC_TEST_MPEG4 || codec_switch == DCE_ENC_TEST_H263 ) { 1252 } else if( (codec_switch == DCE_ENC_TEST_MPEG4) || (codec_switch == DCE_ENC_TEST_H263) ) {
1215 mpeg4enc_inArgs = (IMPEG4ENC_InArgs *) inArgs; 1253 mpeg4enc_inArgs = (IMPEG4ENC_InArgs *) inArgs;
1216 DEBUG("TEST inArgs->inputID %d mpeg4enc_inArgs->videnc2InArgs.inputID %d", inArgs->inputID, mpeg4enc_inArgs->videnc2InArgs.inputID); 1254 DEBUG("TEST inArgs->inputID %d mpeg4enc_inArgs->videnc2InArgs.inputID %d", inArgs->inputID, mpeg4enc_inArgs->videnc2InArgs.inputID);
1217 } 1255 }
@@ -1247,7 +1285,7 @@ int main(int argc, char * *argv)
1247 inArgs->inputID = 0; 1285 inArgs->inputID = 0;
1248 if( codec_switch == DCE_ENC_TEST_H264 ) { 1286 if( codec_switch == DCE_ENC_TEST_H264 ) {
1249 h264enc_inArgs = (IH264ENC_InArgs *) inArgs; 1287 h264enc_inArgs = (IH264ENC_InArgs *) inArgs;
1250 } else if( codec_switch == DCE_ENC_TEST_MPEG4 || codec_switch == DCE_ENC_TEST_H263 ) { 1288 } else if( (codec_switch == DCE_ENC_TEST_MPEG4) || (codec_switch == DCE_ENC_TEST_H263) ) {
1251 mpeg4enc_inArgs = (IMPEG4ENC_InArgs *) inArgs; 1289 mpeg4enc_inArgs = (IMPEG4ENC_InArgs *) inArgs;
1252 } 1290 }
1253 inBufs->planeDesc[0].buf = NULL; 1291 inBufs->planeDesc[0].buf = NULL;
@@ -1286,7 +1324,7 @@ int main(int argc, char * *argv)
1286 inArgs->inputID = 0; 1324 inArgs->inputID = 0;
1287 if( codec_switch == DCE_ENC_TEST_H264 ) { 1325 if( codec_switch == DCE_ENC_TEST_H264 ) {
1288 h264enc_inArgs = (IH264ENC_InArgs *) inArgs; 1326 h264enc_inArgs = (IH264ENC_InArgs *) inArgs;
1289 } else if( codec_switch == DCE_ENC_TEST_MPEG4 || codec_switch == DCE_ENC_TEST_H263 ) { 1327 } else if( (codec_switch == DCE_ENC_TEST_MPEG4) || (codec_switch == DCE_ENC_TEST_H263) ) {
1290 mpeg4enc_inArgs = (IMPEG4ENC_InArgs *) inArgs; 1328 mpeg4enc_inArgs = (IMPEG4ENC_InArgs *) inArgs;
1291 } 1329 }
1292 inBufs->planeDesc[0].buf = NULL; 1330 inBufs->planeDesc[0].buf = NULL;
@@ -1365,7 +1403,7 @@ int main(int argc, char * *argv)
1365 DEBUG("DETAIL EXTENDED ERROR h264enc_status->extErrorCode[%d]=%08x", i, (uint)h264enc_status->extErrorCode[i]); 1403 DEBUG("DETAIL EXTENDED ERROR h264enc_status->extErrorCode[%d]=%08x", i, (uint)h264enc_status->extErrorCode[i]);
1366 } 1404 }
1367 1405
1368 if( XDM_ISFATALERROR(h264enc_outArgs->videnc2OutArgs.extendedError)) { 1406 if( XDM_ISFATALERROR(h264enc_outArgs->videnc2OutArgs.extendedError) ) {
1369 ERROR("process returned error: %d\n", err); 1407 ERROR("process returned error: %d\n", err);
1370 //ERROR("extendedError: %08x", outArgs->extendedError); 1408 //ERROR("extendedError: %08x", outArgs->extendedError);
1371 ERROR("extendedError: %08x", h264enc_outArgs->videnc2OutArgs.extendedError); 1409 ERROR("extendedError: %08x", h264enc_outArgs->videnc2OutArgs.extendedError);
@@ -1489,7 +1527,7 @@ out:
1489 } 1527 }
1490 1528
1491 printf("\nFreeing output %p... output_mvbuf %p...\n", output, output_mvbuf); 1529 printf("\nFreeing output %p... output_mvbuf %p...\n", output, output_mvbuf);
1492 if (tiler) { 1530 if( tiler ) {
1493 if( output ) { 1531 if( output ) {
1494 MemMgr_Free(output); 1532 MemMgr_Free(output);
1495 } 1533 }
@@ -1513,7 +1551,13 @@ out:
1513 printf("\nFreeing buf %p...\n", buf); 1551 printf("\nFreeing buf %p...\n", buf);
1514 if( buf ) { 1552 if( buf ) {
1515 if( buf->buf ) { 1553 if( buf->buf ) {
1516 MemMgr_Free(buf->buf); 1554 if( tiler ) {
1555 printf("\nFreeing buf->buf %p...\n", buf->buf);
1556 MemMgr_Free(buf->buf);
1557 } else {
1558 printf("\nFreeing input_nonTiler %p...\n", &input_nonTiler);
1559 free_nonTiler(&input_nonTiler);
1560 }
1517 } 1561 }
1518 free(buf); 1562 free(buf);
1519 } 1563 }