Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
aom-rav1e
Commits
a8703156
Commit
a8703156
authored
Feb 03, 2011
by
Yunqing Wang
Committed by
Code Review
Feb 03, 2011
Browse files
Options
Browse Files
Download
Plain Diff
Merge "Improved encoder threading"
parents
a5ecaca6
385c2a76
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
244 additions
and
223 deletions
+244
-223
vp8/encoder/encodeframe.c
vp8/encoder/encodeframe.c
+47
-38
vp8/encoder/ethreading.c
vp8/encoder/ethreading.c
+181
-178
vp8/encoder/onyx_if.c
vp8/encoder/onyx_if.c
+12
-1
vp8/encoder/onyx_int.h
vp8/encoder/onyx_int.h
+4
-6
No files found.
vp8/encoder/encodeframe.c
View file @
a8703156
...
...
@@ -487,6 +487,16 @@ void encode_mb_row(VP8_COMP *cpi,
int
recon_uv_stride
=
cm
->
yv12_fb
[
ref_fb_idx
].
uv_stride
;
int
seg_map_index
=
(
mb_row
*
cpi
->
common
.
mb_cols
);
#if CONFIG_MULTITHREAD
const
int
nsync
=
cpi
->
mt_sync_range
;
const
int
rightmost_col
=
cm
->
mb_cols
-
1
;
volatile
const
int
*
last_row_current_mb_col
;
if
((
cpi
->
b_multi_threaded
!=
0
)
&&
(
mb_row
!=
0
))
last_row_current_mb_col
=
&
cpi
->
mt_current_mb_col
[
mb_row
-
1
];
else
last_row_current_mb_col
=
&
rightmost_col
;
#endif
// reset above block coeffs
xd
->
above_context
=
cm
->
above_context
;
...
...
@@ -532,6 +542,21 @@ void encode_mb_row(VP8_COMP *cpi,
x
->
rddiv
=
cpi
->
RDDIV
;
x
->
rdmult
=
cpi
->
RDMULT
;
#if CONFIG_MULTITHREAD
if
((
cpi
->
b_multi_threaded
!=
0
)
&&
(
mb_row
!=
0
))
{
if
((
mb_col
&
(
nsync
-
1
))
==
0
)
{
while
(
mb_col
>
(
*
last_row_current_mb_col
-
nsync
)
&&
(
*
last_row_current_mb_col
)
!=
(
cm
->
mb_cols
-
1
))
{
x86_pause_hint
();
thread_sleep
(
0
);
}
}
}
#endif
if
(
cpi
->
oxcf
.
tuning
==
VP8_TUNE_SSIM
)
activity_sum
+=
vp8_activity_masking
(
cpi
,
x
);
...
...
@@ -628,7 +653,12 @@ void encode_mb_row(VP8_COMP *cpi,
x
->
partition_info
++
;
xd
->
above_context
++
;
cpi
->
current_mb_col_main
=
mb_col
;
#if CONFIG_MULTITHREAD
if
(
cpi
->
b_multi_threaded
!=
0
)
{
cpi
->
mt_current_mb_col
[
mb_row
]
=
mb_col
;
}
#endif
}
//extend the recon for intra prediction
...
...
@@ -642,11 +672,14 @@ void encode_mb_row(VP8_COMP *cpi,
xd
->
mode_info_context
++
;
x
->
partition_info
++
;
x
->
activity_sum
+=
activity_sum
;
}
#if CONFIG_MULTITHREAD
if
((
cpi
->
b_multi_threaded
!=
0
)
&&
(
mb_row
==
cm
->
mb_rows
-
1
))
{
sem_post
(
&
cpi
->
h_event_end_encoding
);
/* signal frame encoding end */
}
#endif
}
void
vp8_encode_frame
(
VP8_COMP
*
cpi
)
{
...
...
@@ -800,22 +833,16 @@ void vp8_encode_frame(VP8_COMP *cpi)
vp8cx_init_mbrthread_data
(
cpi
,
x
,
cpi
->
mb_row_ei
,
1
,
cpi
->
encoding_thread_count
);
for
(
mb_row
=
0
;
mb_row
<
cm
->
mb_rows
;
mb_row
+=
(
cpi
->
encoding_thread_count
+
1
))
{
cpi
->
current_mb_col_main
=
-
1
;
for
(
i
=
0
;
i
<
cm
->
mb_rows
;
i
++
)
cpi
->
mt_current_mb_col
[
i
]
=
0
;
for
(
i
=
0
;
i
<
cpi
->
encoding_thread_count
;
i
++
)
{
if
((
mb_row
+
i
+
1
)
>=
cm
->
mb_rows
)
break
;
cpi
->
mb_row_ei
[
i
].
mb_row
=
mb_row
+
i
+
1
;
cpi
->
mb_row_ei
[
i
].
tp
=
cpi
->
tok
+
(
mb_row
+
i
+
1
)
*
(
cm
->
mb_cols
*
16
*
24
);
cpi
->
mb_row_ei
[
i
].
current_mb_col
=
-
1
;
//SetEvent(cpi->h_event_mbrencoding[i]);
sem_post
(
&
cpi
->
h_event_mbrencoding
[
i
]);
}
for
(
i
=
0
;
i
<
cpi
->
encoding_thread_count
;
i
++
)
{
sem_post
(
&
cpi
->
h_event_start_encoding
[
i
]);
}
for
(
mb_row
=
0
;
mb_row
<
cm
->
mb_rows
;
mb_row
+=
(
cpi
->
encoding_thread_count
+
1
))
{
vp8_zero
(
cm
->
left_context
)
tp
=
cpi
->
tok
+
mb_row
*
(
cm
->
mb_cols
*
16
*
24
);
...
...
@@ -830,26 +857,10 @@ void vp8_encode_frame(VP8_COMP *cpi)
xd
->
mode_info_context
+=
xd
->
mode_info_stride
*
cpi
->
encoding_thread_count
;
x
->
partition_info
+=
xd
->
mode_info_stride
*
cpi
->
encoding_thread_count
;
if
(
mb_row
<
cm
->
mb_rows
-
1
)
//WaitForSingleObject(cpi->h_event_main, INFINITE);
sem_wait
(
&
cpi
->
h_event_main
);
}
/*
for( ;mb_row<cm->mb_rows; mb_row ++)
{
vp8_zero( cm->left_context)
tp = cpi->tok + mb_row * (cm->mb_cols * 16 * 24);
encode_mb_row(cpi, cm, mb_row, x, xd, &tp, segment_counts, &totalrate);
// adjust to the next row of mbs
x->src.y_buffer += 16 * x->src.y_stride - 16 * cm->mb_cols;
x->src.u_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
x->src.v_buffer += 8 * x->src.uv_stride - 8 * cm->mb_cols;
sem_wait
(
&
cpi
->
h_event_end_encoding
);
/* wait for other threads to finish */
}
*/
cpi
->
tok_count
=
0
;
for
(
mb_row
=
0
;
mb_row
<
cm
->
mb_rows
;
mb_row
++
)
...
...
@@ -859,7 +870,6 @@ void vp8_encode_frame(VP8_COMP *cpi)
if
(
xd
->
segmentation_enabled
)
{
int
i
,
j
;
if
(
xd
->
segmentation_enabled
)
...
...
@@ -871,7 +881,6 @@ void vp8_encode_frame(VP8_COMP *cpi)
segment_counts
[
j
]
+=
cpi
->
mb_row_ei
[
i
].
segment_counts
[
j
];
}
}
}
for
(
i
=
0
;
i
<
cpi
->
encoding_thread_count
;
i
++
)
...
...
vp8/encoder/ethreading.c
View file @
a8703156
This diff is collapsed.
Click to expand it.
vp8/encoder/onyx_if.c
View file @
a8703156
...
...
@@ -1465,6 +1465,17 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
vpx_internal_error
(
&
cpi
->
common
.
error
,
VPX_CODEC_MEM_ERROR
,
"Failed to allocate firstpass stats"
);
#endif
#if CONFIG_MULTITHREAD
if
(
width
<
640
)
cpi
->
mt_sync_range
=
1
;
else
if
(
width
<=
1280
)
cpi
->
mt_sync_range
=
4
;
else
if
(
width
<=
2560
)
cpi
->
mt_sync_range
=
8
;
else
cpi
->
mt_sync_range
=
16
;
#endif
}
...
...
@@ -4413,7 +4424,7 @@ static void encode_frame_to_data_rate
}
// Update the GF useage maps.
//
Update the GF useage maps.
//
This is done after completing the compression of a frame when all modes etc. are finalized but before loop filter
// This is done after completing the compression of a frame when all modes etc. are finalized but before loop filter
vp8_update_gf_useage_maps
(
cpi
,
cm
,
&
cpi
->
mb
);
...
...
vp8/encoder/onyx_int.h
View file @
a8703156
...
...
@@ -191,11 +191,8 @@ typedef struct
typedef
struct
{
MACROBLOCK
mb
;
int
mb_row
;
TOKENEXTRA
*
tp
;
int
segment_counts
[
MAX_MB_SEGMENTS
];
int
totalrate
;
int
current_mb_col
;
}
MB_ROW_COMP
;
typedef
struct
...
...
@@ -593,7 +590,8 @@ typedef struct
signed
char
*
cyclic_refresh_map
;
// multithread data
int
current_mb_col_main
;
int
*
mt_current_mb_col
;
int
mt_sync_range
;
int
processor_core_count
;
int
b_multi_threaded
;
int
encoding_thread_count
;
...
...
@@ -606,8 +604,8 @@ typedef struct
#if CONFIG_MULTITHREAD
//events
sem_t
*
h_event_
mbr
encoding
;
sem_t
h_event_
ma
in
;
sem_t
*
h_event_
start_
encoding
;
sem_t
h_event_
end_encod
in
g
;
#endif
TOKENLIST
*
tplist
;
...
...
Write
Preview
Markdown
is supported
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