Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
73065b67
Commit
73065b67
authored
Mar 21, 2011
by
Yunqing Wang
Committed by
Code Review
Mar 21, 2011
Browse files
Merge "Fix multithreaded encoding for 1 MB wide frame"
parents
2cbd9620
bfe803bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
vp8/encoder/encodeframe.c
View file @
73065b67
...
...
@@ -808,7 +808,7 @@ void vp8_encode_frame(VP8_COMP *cpi)
vp8cx_init_mbrthread_data
(
cpi
,
x
,
cpi
->
mb_row_ei
,
1
,
cpi
->
encoding_thread_count
);
for
(
i
=
0
;
i
<
cm
->
mb_rows
;
i
++
)
cpi
->
mt_current_mb_col
[
i
]
=
0
;
cpi
->
mt_current_mb_col
[
i
]
=
-
1
;
for
(
i
=
0
;
i
<
cpi
->
encoding_thread_count
;
i
++
)
{
...
...
vp8/encoder/ethreading.c
View file @
73065b67
...
...
@@ -24,8 +24,6 @@ extern void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x);
extern
void
vp8_build_block_offsets
(
MACROBLOCK
*
x
);
extern
void
vp8_setup_block_ptrs
(
MACROBLOCK
*
x
);
#if CONFIG_MULTITHREAD
extern
void
loopfilter_frame
(
VP8_COMP
*
cpi
,
VP8_COMMON
*
cm
);
static
THREAD_FUNCTION
loopfilter_thread
(
void
*
p_data
)
...
...
@@ -51,7 +49,6 @@ static THREAD_FUNCTION loopfilter_thread(void *p_data)
return
0
;
}
#endif
static
THREAD_FUNCTION
thread_encoding_proc
(
void
*
p_data
)
...
...
@@ -458,53 +455,58 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
void
vp8cx_create_encoder_threads
(
VP8_COMP
*
cpi
)
{
c
pi
->
b_multi_threaded
=
0
;
c
onst
VP8_COMMON
*
cm
=
&
cpi
->
common
;
cpi
->
b_multi_threaded
=
0
;
cpi
->
encoding_thread_count
=
0
;
cpi
->
processor_core_count
=
32
;
//vp8_get_proc_core_count();
if
(
cpi
->
processor_core_count
>
1
&&
cpi
->
oxcf
.
multi_threaded
>
1
)
{
int
ithread
;
int
th_count
=
cpi
->
oxcf
.
multi_threaded
-
1
;
if
(
cpi
->
oxcf
.
multi_threaded
>
cpi
->
processor_core_count
)
cpi
->
encoding_thread_count
=
cpi
->
processor_core_count
-
1
;
else
cpi
->
encoding_thread_count
=
cpi
->
oxcf
.
multi_threaded
-
1
;
CHECK_MEM_ERROR
(
cpi
->
h_encoding_thread
,
vpx_malloc
(
sizeof
(
pthread_t
)
*
cpi
->
encoding_thread_count
));
CHECK_MEM_ERROR
(
cpi
->
h_event_start_encoding
,
vpx_malloc
(
sizeof
(
sem_t
)
*
cpi
->
encoding_thread_count
));
CHECK_MEM_ERROR
(
cpi
->
mb_row_ei
,
vpx_memalign
(
32
,
sizeof
(
MB_ROW_COMP
)
*
cpi
->
encoding_thread_count
));
vpx_memset
(
cpi
->
mb_row_ei
,
0
,
sizeof
(
MB_ROW_COMP
)
*
cpi
->
encoding_thread_count
);
CHECK_MEM_ERROR
(
cpi
->
en_thread_data
,
vpx_malloc
(
sizeof
(
ENCODETHREAD_DATA
)
*
cpi
->
encoding_thread_count
));
CHECK_MEM_ERROR
(
cpi
->
mt_current_mb_col
,
vpx_malloc
(
sizeof
(
*
cpi
->
mt_current_mb_col
)
*
cpi
->
common
.
mb_rows
));
//cpi->h_event_main = CreateEvent(NULL, FALSE, FALSE, NULL);
th_count
=
cpi
->
processor_core_count
-
1
;
/* we have th_count + 1 (main) threads processing one row each */
/* no point to have more threads than the sync range allows */
if
(
th_count
>
((
cm
->
mb_cols
/
cpi
->
mt_sync_range
)
-
1
))
{
th_count
=
(
cm
->
mb_cols
/
cpi
->
mt_sync_range
)
-
1
;
}
if
(
th_count
==
0
)
return
;
CHECK_MEM_ERROR
(
cpi
->
h_encoding_thread
,
vpx_malloc
(
sizeof
(
pthread_t
)
*
th_count
));
CHECK_MEM_ERROR
(
cpi
->
h_event_start_encoding
,
vpx_malloc
(
sizeof
(
sem_t
)
*
th_count
));
CHECK_MEM_ERROR
(
cpi
->
mb_row_ei
,
vpx_memalign
(
32
,
sizeof
(
MB_ROW_COMP
)
*
th_count
));
vpx_memset
(
cpi
->
mb_row_ei
,
0
,
sizeof
(
MB_ROW_COMP
)
*
th_count
);
CHECK_MEM_ERROR
(
cpi
->
en_thread_data
,
vpx_malloc
(
sizeof
(
ENCODETHREAD_DATA
)
*
th_count
));
CHECK_MEM_ERROR
(
cpi
->
mt_current_mb_col
,
vpx_malloc
(
sizeof
(
*
cpi
->
mt_current_mb_col
)
*
cm
->
mb_rows
));
sem_init
(
&
cpi
->
h_event_end_encoding
,
0
,
0
);
cpi
->
b_multi_threaded
=
1
;
cpi
->
encoding_thread_count
=
th_count
;
//printf("[VP8:] multi_threaded encoding is enabled with %d threads\n\n", (cpi->encoding_thread_count +1));
/*
printf("[VP8:] multi_threaded encoding is enabled with %d threads\n\n",
(cpi->encoding_thread_count +1));
*/
for
(
ithread
=
0
;
ithread
<
cpi
->
encoding_thread
_count
;
ithread
++
)
for
(
ithread
=
0
;
ithread
<
th
_count
;
ithread
++
)
{
ENCODETHREAD_DATA
*
ethd
=
&
cpi
->
en_thread_data
[
ithread
];
//cpi->h_event_mbrencoding[ithread] = CreateEvent(NULL, FALSE, FALSE, NULL);
sem_init
(
&
cpi
->
h_event_start_encoding
[
ithread
],
0
,
0
);
ethd
->
ithread
=
ithread
;
ethd
->
ptr1
=
(
void
*
)
cpi
;
ethd
->
ptr2
=
(
void
*
)
&
cpi
->
mb_row_ei
[
ithread
];
//printf(" call begin thread %d \n", ithread);
//cpi->h_encoding_thread[ithread] = (HANDLE)_beginthreadex(
// NULL, // security
// 0, // stksize
// thread_encoding_proc,
// (&cpi->en_thread_data[ithread]), // Thread data
// 0,
// NULL);
pthread_create
(
&
cpi
->
h_encoding_thread
[
ithread
],
0
,
thread_encoding_proc
,
ethd
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment