summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d1c7bf0)
raw | patch | inline | side by side (parent: d1c7bf0)
author | Amarinder Bindra <a-bindra@ti.com> | |
Thu, 16 Jan 2014 12:42:16 +0000 (18:12 +0530) | ||
committer | Amarinder Bindra <a-bindra@ti.com> | |
Thu, 20 Mar 2014 12:04:15 +0000 (17:34 +0530) |
For dual decode, use the pthreads to use the viddec3test application
as a multithread application rather than doing the the process calls
in a sequential way.
Signed-off-by: Ram Prasad <x0038811@ti.com>
Signed-off-by: Amarinder Bindra <a-bindra@ti.com>
as a multithread application rather than doing the the process calls
in a sequential way.
Signed-off-by: Ram Prasad <x0038811@ti.com>
Signed-off-by: Amarinder Bindra <a-bindra@ti.com>
Makefile.am | patch | blob | history | |
viddec3test.c | patch | blob | history |
diff --git a/Makefile.am b/Makefile.am
index f56e29cce9318997f30d0b251339b1b79c991ba6..c83c3c9be6442dfac67ca6e45aa5686a741d8b8c 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
LDADD_COMMON = util/libutil.la @DRM_LIBS@ @DCE_LIBS@ @GBM_LIBS@ @EGL_LIBS@ @GLES2_LIBS@
AM_CFLAGS = @DRM_CFLAGS@ @DCE_CFLAGS@ @GBM_CFLAGS@ @EGL_CFLAGS@ @GLES2_CFLAGS@ @WARN_CFLAGS@ -I$(top_srcdir)/util
-LDFLAGS = -lm -lavcodec
+LDFLAGS = -lm -lavcodec -lpthread
fliptest_SOURCES = fliptest.c
fliptest_LDADD = $(LDADD_COMMON)
diff --git a/viddec3test.c b/viddec3test.c
index b5f796f141eb5fb2e3b4c5bd1e691e9271bcf985..3fae551ffb1177383781b31f786de908eca4516d 100644 (file)
--- a/viddec3test.c
+++ b/viddec3test.c
#include <omap_drm.h>
#include <omap_drmif.h>
+#include <pthread.h>
+
#include "util.h"
#include "demux.h"
return (inBufs->numBufs > 0) ? 0 : -1;
}
+void *decode_stream(void *decoderHandle)
+{
+ int n = 0;
+ struct decoder *decoders = (struct decoder*)decoderHandle;
+
+ do {
+ if (decoders) {
+ int ret = decoder_process(decoders);
+ if (ret) {
+ decoder_close(decoders);
+ decoders = NULL;
+ n = 0;
+ continue;
+ }
+ n++;
+ }
+ } while(n > 0);
+
+ return NULL;
+}
+
int
main(int argc, char **argv)
{
struct decoder *decoders[8] = {};
- int i, n, first = 0, ndecoders = 0;
+ int i, first = 0, ndecoders = 0;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
}
argv[first] = argv[0];
+
decoders[ndecoders++] = decoder_open(i - first, &argv[first]);
- do {
- for (i = 0, n = 0; i < ndecoders; i++) {
+ if (ndecoders > 1) {
+ pthread_t threadIds[8];
+
+ for (i = 0; i < ndecoders; i++) {
if (decoders[i]) {
- int ret = decoder_process(decoders[i]);
- if (ret) {
- decoder_close(decoders[i]);
- decoders[i] = NULL;
- continue;
- }
- n++;
+ int ret = pthread_create(&threadIds[i], NULL,
+ &decode_stream, decoders[i]);
+ if (ret != 0)
+ ERROR("%p: creation of pthread, error: %d",
+ decoders[i], ret);
}
}
- } while(n > 0);
+
+ for (i = 0; i < ndecoders; i++) {
+ pthread_join(threadIds[i], NULL);
+ }
+ }
+ else {
+ decode_stream(decoders[0]);
+ }
return 0;
}