History

Implement execute2 for w32thread

Originally committed as revision 20225 to svn://svn.ffmpeg.org/ffmpeg/trunk

Reimar Döffinger committed 17 years ago

Commit 75377261 parent 1e6ff471 file · +15 −0Browse files

Unified · Split

libavcodec/w32thread.c+15−0
@@ -32,10 +32,12 @@ typedef struct ThreadContext{ · 31 unmodified lines
3232 HANDLE job_sem;
3333 HANDLE done_sem;
3434 int (*func)(AVCodecContext *c, void *arg);
35+ int (*func2)(AVCodecContext *c, void *arg, int, int);
3536 void *arg;
3637 int argsize;
3738 int *jobnr;
3839 int *ret;
40+ int threadnr;
3941 }ThreadContext;
4042
4143
@@ -52,6 +54,8 @@ static unsigned WINAPI attribute_align_arg thread_func(void *v){ · 10 unmodified lines
5254 //printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout);
5355 if(c->func)
5456 ret= c->func(c->avctx, (uint8_t *)c->arg + jobnr*c->argsize);
57+ else if (c->func2)
58+ ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr);
5559 else
5660 return 0;
5761 if (c->ret)
@@ -74,6 +78,7 @@ void avcodec_thread_free(AVCodecContext *s){ · 16 unmodified lines
7478 for(i=0; i<s->thread_count; i++){
7579
7680 c[i].func= NULL;
81+ c[i].func2= NULL;
7782 }
7883 ReleaseSemaphore(c[0].work_sem, s->thread_count, 0);
7984 for(i=0; i<s->thread_count; i++){
@@ -110,6 +115,14 @@ int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, vo · 30 unmodified lines
110115 return 0;
111116 }
112117
118+int avcodec_thread_execute2(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count){
119+ ThreadContext *c= s->thread_opaque;
120+ int i;
121+ for(i=0; i<s->thread_count; i++)
122+ c[i].func2 = func;
123+ avcodec_thread_execute(s, NULL, arg, ret, count, 0);
124+}
125+
113126 int avcodec_thread_init(AVCodecContext *s, int thread_count){
114127 int i;
115128 ThreadContext *c;
@@ -133,6 +146,7 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){ · 17 unmodified lines
133146 c[i].work_sem = c[0].work_sem;
134147 c[i].job_sem = c[0].job_sem;
135148 c[i].done_sem = c[0].done_sem;
149+ c[i].threadnr = i;
136150
137151 //printf("create thread %d\n", i); fflush(stdout);
138152 c[i].thread = (HANDLE)_beginthreadex(NULL, 0, thread_func, &c[i], 0, &threadid );
@@ -141,6 +155,7 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){ · 2 unmodified lines
141155 //printf("init done\n"); fflush(stdout);
142156
143157 s->execute= avcodec_thread_execute;
158+ s->execute2= avcodec_thread_execute2;
144159
145160 return 0;
146161 fail:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t