aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBuddy Liong2013-11-04 11:38:17 -0600
committerGerrit Code Review2013-11-06 12:35:42 -0600
commit45096679732728cd039b4372b75a7e7140fd9f5a (patch)
tree9474b220708956f2880c660a1a07bd81e046e808 /test_qnx
parent693d836d994d1c255b7453f3b3a1d04006e5e94e (diff)
downloadrepo-libdce-45096679732728cd039b4372b75a7e7140fd9f5a.tar.gz
repo-libdce-45096679732728cd039b4372b75a7e7140fd9f5a.tar.xz
repo-libdce-45096679732728cd039b4372b75a7e7140fd9f5a.zip
[LIBDCE] Remove memcpy in read_input for dce_enc_test
Remove memcpy in read_input() for dce_enc_test since it is not needed. In the current implementation, read_input() creates a temporary buffer "pTmpBuffer" to store the input frame after reading for the input file. Then it performs memcpy from "PTmpBuffer" into input Buffer in TILER 2D which is passed down to IVA-HD video encoder. The "pTmpBuffer" is allocated using calloc() which allocates space from the heap which may/may not be contiguous. During robustness test, it causes hang during memcpy which indicates that QNX calloc doesn't allocate contiguous memory. The solution is to read the input frame directly from the input file and store directly into input Buffer in TILER 2D. Additional clean up in removing unused TMPDUMPDATA and DUMPINPUTDATA0. Internal reference: this solution fix the issue reported in DRT OMAPS00300892. Change-Id: If5f4941f4d2adc4a82ec4e60652d4792a72866d7 Signed-off-by: Buddy Liong <buddy.budiono@ti.com>
Diffstat (limited to 'test_qnx')
-rw-r--r--test_qnx/dce_enc_test/dce_enc_test.c92
1 files changed, 15 insertions, 77 deletions
diff --git a/test_qnx/dce_enc_test/dce_enc_test.c b/test_qnx/dce_enc_test/dce_enc_test.c
index 6d337bb..b3a2594 100644
--- a/test_qnx/dce_enc_test/dce_enc_test.c
+++ b/test_qnx/dce_enc_test/dce_enc_test.c
@@ -280,17 +280,12 @@ static const char *get_path(const char *pattern, int cnt)
280} 280}
281 281
282//#define DUMPINPUTDATA 282//#define DUMPINPUTDATA
283//#define TMPDUMPDATA
284//#define DUMPOUTPUTDATA 283//#define DUMPOUTPUTDATA
285 284
286#ifdef DUMPINPUTDATA 285#ifdef DUMPINPUTDATA
287FILE *inputDump; 286FILE *inputDump;
288#endif 287#endif
289 288
290#ifdef TMPDUMPDATA
291FILE *tmpDump;
292#endif
293
294#ifdef DUMPOUTPUTDATA 289#ifdef DUMPOUTPUTDATA
295FILE *outputDump; 290FILE *outputDump;
296#endif 291#endif
@@ -300,42 +295,21 @@ FILE *outputDump;
300int read_input(const char *pattern, int cnt, char *input) 295int read_input(const char *pattern, int cnt, char *input)
301{ 296{
302 int sz = 0, n = 0, num_planes, i, buf_height; 297 int sz = 0, n = 0, num_planes, i, buf_height;
303 int *pTmpBuffer = NULL, *pTmpBufferPos = NULL;
304 298
305 const char *path = get_path(pattern, cnt); 299 const char *path = get_path(pattern, cnt);
306 int fd = open(path, O_RDONLY); 300 int fd = open(path, O_RDONLY);
307 301
308 //DEBUG("Open file fd %d errno %d", fd, errno); 302 //DEBUG("Open file fd %d errno %d", fd, errno);
309 /* if we can't find the file, then at the end of stream */
310 if( fd < 0 ) { 303 if( fd < 0 ) {
311 DEBUG("open input file failed"); 304 DEBUG("open input file failed");
312 return (0); 305 return (-1);
313 } 306 }
314 307
315 sz = width * height * 3 / 2; 308 sz = width * height * 3 / 2;
316 pTmpBuffer = calloc(sz, 1);
317 pTmpBufferPos = pTmpBuffer;
318
319 //Read 1 frame of NV12 YUV into input. Since it's TILER - stride = 4096
320 lseek(fd, input_offset, SEEK_SET);
321 n = read(fd, pTmpBuffer, sz); //reading 1 input frame width * height * 3/2
322 DEBUG("reading input[%p] size of n = %d where input_offset is %d", input, n, input_offset);
323 if( n ) {
324 input_offset += n;
325 } else {
326 sz = -1; //cannot read more input
327 free(pTmpBuffer);
328 close(fd);
329
330 DEBUG("sz=%d", sz);
331 return (sz);
332 }
333
334#ifdef TMPDUMPDATA
335 char Buff[100];
336 int static GlobalCount = 0;
337#endif
338 309
310 // Filling the input in TILER 2D mode; where
311 // Luma has size of Stride "4096" * height.
312 // and Chroma has size of Stride "4096 * height / 2.
339 for( num_planes = 0; num_planes < 2; num_planes++ ) { 313 for( num_planes = 0; num_planes < 2; num_planes++ ) {
340 if( num_planes ) { //UV location 314 if( num_planes ) { //UV location
341 buf_height = height / 2; 315 buf_height = height / 2;
@@ -344,36 +318,19 @@ int read_input(const char *pattern, int cnt, char *input)
344 } 318 }
345 319
346 for( i = 0; i < buf_height; i++ ) { 320 for( i = 0; i < buf_height; i++ ) {
347 memcpy(input, pTmpBufferPos, width); 321 lseek(fd, input_offset, SEEK_SET);
348 322 n = read(fd, input, width);
349#ifdef TMPDUMPDATA 323 if( n ) {
350 324 input_offset += n;
351 if( GlobalCount < buf_height ) { 325 } else {
352 DEBUG("[DCE_ENC_TEST] GlobalCount %d\n", GlobalCount); 326 close(fd);
353 sprintf(Buff, "/sd/dce_enc_dump/dcefiledump%d.bin", GlobalCount); 327 DEBUG("Reading REACH EOF - return -1");
354 tmpDump = fopen(Buff, "wb+"); 328 return (-1); //Cannot read anymore input
355 if( tmpDump == NULL ) {
356 DEBUG("[DCE_ENC_TEST] Error opening /sd/dce_enc_dump/dcefiledump\n");
357 } else {
358 GlobalCount++;
359 //DEBUG("Before Input [%p]\n", input);
360 fwrite(input, 1, width, tmpDump);
361
362 fflush(tmpDump);
363 fclose(tmpDump);
364 tmpDump = NULL;
365 }
366 } 329 }
367
368#endif
369 pTmpBufferPos = (int *) ((int)pTmpBufferPos + width);
370 input = (char *) ((int)input + 4096); 330 input = (char *) ((int)input + 4096);
371 //DEBUG("After Input [%p]\n", input);
372
373 } 331 }
374 } 332 }
375 333
376 free(pTmpBuffer);
377 close(fd); 334 close(fd);
378 335
379 DEBUG("sz=%d", sz); 336 DEBUG("sz=%d", sz);
@@ -665,11 +622,11 @@ int main(int argc, char * *argv)
665 inBufs->secondFieldOffsetHeight[1] = 0; 622 inBufs->secondFieldOffsetHeight[1] = 0;
666 623
667 inBufs->planeDesc[1].memType = XDM_MEMTYPE_TILED16; 624 inBufs->planeDesc[1].memType = XDM_MEMTYPE_TILED16;
668 inBufs->planeDesc[1].bufSize.tileMem.width = width / 2; /* UV interleaved width is same a Y */ 625 inBufs->planeDesc[1].bufSize.tileMem.width = width; /* UV interleaved width is same a Y */
669 inBufs->planeDesc[1].bufSize.tileMem.height = height / 2; 626 inBufs->planeDesc[1].bufSize.tileMem.height = height / 2;
670 627
671 buf = calloc(sizeof(InputBuffer), 1); 628 buf = calloc(sizeof(InputBuffer), 1);
672 DEBUG(" ----------------- create TILER buf 0x%x --------------------", (unsigned int)buf); 629 DEBUG(" ----------------- create INPUT TILER buf 0x%x --------------------", (unsigned int)buf);
673 buf->buf = tiler_alloc(width, height); 630 buf->buf = tiler_alloc(width, height);
674 if( buf->buf ) { 631 if( buf->buf ) {
675 //buf->y = TilerMem_VirtToPhys(buf->buf); 632 //buf->y = TilerMem_VirtToPhys(buf->buf);
@@ -677,7 +634,7 @@ int main(int argc, char * *argv)
677 //buf->uv = TilerMem_VirtToPhys(buf->buf + (height * 4096)); 634 //buf->uv = TilerMem_VirtToPhys(buf->buf + (height * 4096));
678 buf->uv = (SSPtr)buf->buf + (height * 4096); 635 buf->uv = (SSPtr)buf->buf + (height * 4096);
679 636
680 DEBUG("buf=%p, buf->buf=%p y=%08x, uv=%08x", buf, buf->buf, buf->y, buf->uv); 637 DEBUG("INPUT TILER buf=%p, buf->buf=%p y=%08x, uv=%08x", buf, buf->buf, buf->y, buf->uv);
681 } else { 638 } else {
682 ERROR(" ---------------- tiler_alloc failed --------------------"); 639 ERROR(" ---------------- tiler_alloc failed --------------------");
683 free(buf); 640 free(buf);
@@ -1218,25 +1175,6 @@ int main(int argc, char * *argv)
1218 //Read the NV12 frame to input buffer to be encoded. 1175 //Read the NV12 frame to input buffer to be encoded.
1219 n = read_input(in_pattern, in_cnt, buf->buf); 1176 n = read_input(in_pattern, in_cnt, buf->buf);
1220 1177
1221#ifdef DUMPINPUTDATA0
1222 DEBUG("input data buf->buf[%p]", buf->buf);
1223
1224 //Dump the file
1225 if( inputDump == NULL ) {
1226 inputDump = fopen("/sd/dce_enc_dump/inputdump.yuv", "ab");
1227 //DEBUG("input data dump file open %p errno %d", inputDump, errno);
1228 if( inputDump == NULL ) {
1229 DEBUG("Opening input Dump /sd/dce_enc_dump/inputdump.yuv file FAILED");
1230 }
1231 }
1232 //DEBUG("input data dump file open %p Successful", inputDump);
1233
1234 fwrite(buf->buf, sizeof(char), 4096 * height * 3 / 2, inputDump);
1235 DEBUG("Dumping input file of NV12 format with read data of %d inside buffersize = %d", n, 4096 * height * 3 / 2);
1236 fflush(inputDump);
1237 fclose(inputDump);
1238 inputDump = NULL;
1239#endif
1240 1178
1241 if( n && (n != -1)) { 1179 if( n && (n != -1)) {
1242 eof = 0; 1180 eof = 0;