annotate os2thread.c @ 5131:757efe20a3c8 libavcodec

Blackfin dct_quantize_bfin routine 2x performance boost in performing quantization for mpeg encoding
author mhoffman
date Tue, 12 Jun 2007 19:13:50 +0000
parents 4dbe6578f811
children 2b72f9bc4f06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3081
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
1 /*
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
2 * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
3 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3517
diff changeset
4 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3517
diff changeset
5 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3517
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
3081
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3517
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
3081
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
10 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3517
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
3081
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
14 * Lesser General Public License for more details.
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
15 *
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3517
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
3517
84c509024ee9 Fix FSF postal address.
diego
parents: 3081
diff changeset
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3081
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
19 *
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
20 */
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
21 //#define DEBUG
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
22
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
23 // Ported by Vlad Stelmahovsky
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
24
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
25 #include "avcodec.h"
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
26
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
27 #define INCL_DOS
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
28 #define INCL_DOSERRORS
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
29 #define INCL_DOSDEVIOCTL
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
30 #include <os2.h>
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
31
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
32 typedef struct ThreadContext{
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
33 AVCodecContext *avctx;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
34 int thread;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
35 HEV work_sem;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
36 HEV done_sem;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
37 int (*func)(AVCodecContext *c, void *arg);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
38 void *arg;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
39 int ret;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
40 }ThreadContext;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
41
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
42
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
43 void thread_func(void *v){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
44 ThreadContext *c= v;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
45
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
46 for(;;){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
47 //printf("thread_func %X enter wait\n", (int)v); fflush(stdout);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
48 DosWaitEventSem(c->work_sem, SEM_INDEFINITE_WAIT);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
49 // WaitForSingleObject(c->work_sem, INFINITE);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
50 //printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
51 if(c->func)
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
52 c->ret= c->func(c->avctx, c->arg);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
53 else
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
54 return;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
55 //printf("thread_func %X signal complete\n", (int)v); fflush(stdout);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
56 DosPostEventSem(c->done_sem);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
57 // ReleaseSemaphore(c->done_sem, 1, 0);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
58 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
59
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
60 return;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
61 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
62
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
63 /**
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
64 * free what has been allocated by avcodec_thread_init().
5127
4dbe6578f811 misc spelling fixes
diego
parents: 4962
diff changeset
65 * must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running
3081
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
66 */
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
67 void avcodec_thread_free(AVCodecContext *s){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
68 ThreadContext *c= s->thread_opaque;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
69 int i;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
70
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
71 for(i=0; i<s->thread_count; i++){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
72
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
73 c[i].func= NULL;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
74 DosPostEventSem(c[i].work_sem);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
75 // ReleaseSemaphore(c[i].work_sem, 1, 0);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
76 DosWaitThread((PTID)&c[i].thread,DCWW_WAIT);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
77 // WaitForSingleObject(c[i].thread, INFINITE);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
78 if(c[i].work_sem) DosCloseEventSem(c[i].work_sem);//CloseHandle(c[i].work_sem);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
79 if(c[i].done_sem) DosCloseEventSem(c[i].done_sem);//CloseHandle(c[i].done_sem);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
80 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
81
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
82 av_freep(&s->thread_opaque);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
83 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
84
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
85 int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
86 ThreadContext *c= s->thread_opaque;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
87 int i;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
88
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
89 assert(s == c->avctx);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
90 assert(count <= s->thread_count);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
91
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
92 /* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
93
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
94 for(i=0; i<count; i++){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
95
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
96 c[i].arg= arg[i];
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
97 c[i].func= func;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
98 c[i].ret= 12345;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
99
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
100 DosPostEventSem(c[i].work_sem);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
101 // ReleaseSemaphore(c[i].work_sem, 1, 0);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
102 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
103 for(i=0; i<count; i++){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
104 DosWaitEventSem(c[i].done_sem,SEM_INDEFINITE_WAIT);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
105 // WaitForSingleObject(c[i].done_sem, INFINITE);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
106
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
107 c[i].func= NULL;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
108 if(ret) ret[i]= c[i].ret;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
109 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
110 return 0;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
111 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
112
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
113 int avcodec_thread_init(AVCodecContext *s, int thread_count){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
114 int i;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
115 ThreadContext *c;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
116 uint32_t threadid;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
117
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
118 s->thread_count= thread_count;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
119
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
120 assert(!s->thread_opaque);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
121 c= av_mallocz(sizeof(ThreadContext)*thread_count);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
122 s->thread_opaque= c;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
123
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
124 for(i=0; i<thread_count; i++){
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
125 //printf("init semaphors %d\n", i); fflush(stdout);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
126 c[i].avctx= s;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
127
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
128 if (DosCreateEventSem(NULL,&c[i].work_sem,DC_SEM_SHARED,0))
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
129 goto fail;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
130 if (DosCreateEventSem(NULL,&c[i].done_sem,DC_SEM_SHARED,0))
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
131 goto fail;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
132
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
133 //printf("create thread %d\n", i); fflush(stdout);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
134 // c[i].thread = (HANDLE)_beginthreadex(NULL, 0, thread_func, &c[i], 0, &threadid );
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
135 c[i].thread = _beginthread(thread_func, NULL, 0x10000, &c[i]);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
136 if( c[i].thread <= 0 ) goto fail;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
137 }
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
138 //printf("init done\n"); fflush(stdout);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
139
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
140 s->execute= avcodec_thread_execute;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
141
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
142 return 0;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
143 fail:
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
144 avcodec_thread_free(s);
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
145 return -1;
4bf348f8e2b1 os2 thread, network and freetype2 support by (Paul Smedley | paulat a t smedleydot d o t info)
michael
parents:
diff changeset
146 }