Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
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
Show 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
]);
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);
sem_wait
(
&
cpi
->
h_event_end_encoding
);
/* wait for other threads to finish */
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;
}
*/
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
...
...
@@ -8,15 +8,16 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "onyx_int.h"
#include "threading.h"
#include "common.h"
#include "extend.h"
extern
int
vp8cx_encode_inter_macroblock
(
VP8_COMP
*
cpi
,
MACROBLOCK
*
x
,
TOKENEXTRA
**
t
,
int
recon_yoffset
,
int
recon_uvoffset
);
extern
int
vp8cx_encode_intra_macro_block
(
VP8_COMP
*
cpi
,
MACROBLOCK
*
x
,
TOKENEXTRA
**
t
);
extern
int
vp8cx_encode_inter_macroblock
(
VP8_COMP
*
cpi
,
MACROBLOCK
*
x
,
TOKENEXTRA
**
t
,
int
recon_yoffset
,
int
recon_uvoffset
);
extern
int
vp8cx_encode_intra_macro_block
(
VP8_COMP
*
cpi
,
MACROBLOCK
*
x
,
TOKENEXTRA
**
t
);
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
);
...
...
@@ -30,6 +31,7 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
MB_ROW_COMP
*
mbri
=
(
MB_ROW_COMP
*
)(((
ENCODETHREAD_DATA
*
)
p_data
)
->
ptr2
);
ENTROPY_CONTEXT_PLANES
mb_row_left_context
;
const
int
nsync
=
cpi
->
mt_sync_range
;
//printf("Started thread %d\n", ithread);
while
(
1
)
...
...
@@ -38,21 +40,23 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
break
;
//if(WaitForSingleObject(cpi->h_event_mbrencoding[ithread], INFINITE) == WAIT_OBJECT_0)
if
(
sem_wait
(
&
cpi
->
h_event_mbrencoding
[
ithread
])
==
0
)
{
if
(
cpi
->
b_multi_threaded
==
FALSE
)
// we're shutting down
break
;
else
if
(
sem_wait
(
&
cpi
->
h_event_start_encoding
[
ithread
])
==
0
)
{
VP8_COMMON
*
cm
=
&
cpi
->
common
;
int
mb_row
=
mbri
->
mb_row
;
int
mb_row
;
MACROBLOCK
*
x
=
&
mbri
->
mb
;
MACROBLOCKD
*
xd
=
&
x
->
e_mbd
;
TOKENEXTRA
**
tp
=
&
mbri
->
tp
;
TOKENEXTRA
*
tp
;
int
*
segment_counts
=
mbri
->
segment_counts
;
int
*
totalrate
=
&
mbri
->
totalrate
;
if
(
cpi
->
b_multi_threaded
==
FALSE
)
// we're shutting down
break
;
for
(
mb_row
=
ithread
+
1
;
mb_row
<
cm
->
mb_rows
;
mb_row
+=
(
cpi
->
encoding_thread_count
+
1
))
{
int
i
;
int
recon_yoffset
,
recon_uvoffset
;
int
mb_col
;
...
...
@@ -63,10 +67,9 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
volatile
int
*
last_row_current_mb_col
;
INT64
activity_sum
=
0
;
if
(
ithread
>
0
)
last_row_current_mb_col
=
&
cpi
->
mb_row_ei
[
ithread
-
1
].
current_mb_col
;
else
last_row_current_mb_col
=
&
cpi
->
current_mb_col_main
;
tp
=
cpi
->
tok
+
(
mb_row
*
(
cm
->
mb_cols
*
16
*
24
));
last_row_current_mb_col
=
&
cpi
->
mt_current_mb_col
[
mb_row
-
1
];
// reset above block coeffs
xd
->
above_context
=
cm
->
above_context
;
...
...
@@ -78,8 +81,7 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
recon_yoffset
=
(
mb_row
*
recon_y_stride
*
16
);
recon_uvoffset
=
(
mb_row
*
recon_uv_stride
*
8
);
cpi
->
tplist
[
mb_row
].
start
=
*
tp
;
cpi
->
tplist
[
mb_row
].
start
=
tp
;
//printf("Thread mb_row = %d\n", mb_row);
...
...
@@ -88,11 +90,14 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
{
int
seg_map_index
=
(
mb_row
*
cm
->
mb_cols
);
while
(
mb_col
>
(
*
last_row_current_mb_col
-
1
)
&&
*
last_row_current_mb_col
!=
cm
->
mb_cols
-
1
)
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
);
}
}
// Distance of Mb to the various image edges.
// These specified to 8th pel as they are always compared to values that are in 1/8th pel units
...
...
@@ -115,7 +120,7 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
x
->
rddiv
=
cpi
->
RDDIV
;
x
->
rdmult
=
cpi
->
RDMULT
;
if
(
cpi
->
oxcf
.
tuning
==
VP8_TUNE_SSIM
)
if
(
cpi
->
oxcf
.
tuning
==
VP8_TUNE_SSIM
)
activity_sum
+=
vp8_activity_masking
(
cpi
,
x
);
// Is segmentation enabled
...
...
@@ -123,8 +128,8 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
if
(
xd
->
segmentation_enabled
)
{
// Code to set segment id in xd->mbmi.segment_id for current MB (with range checking)
if
(
cpi
->
segmentation_map
[
seg_map_index
+
mb_col
]
<=
3
)
xd
->
mode_info_context
->
mbmi
.
segment_id
=
cpi
->
segmentation_map
[
seg_map_index
+
mb_col
];
if
(
cpi
->
segmentation_map
[
seg_map_index
+
mb_col
]
<=
3
)
xd
->
mode_info_context
->
mbmi
.
segment_id
=
cpi
->
segmentation_map
[
seg_map_index
+
mb_col
];
else
xd
->
mode_info_context
->
mbmi
.
segment_id
=
0
;
...
...
@@ -137,14 +142,14 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
if
(
cm
->
frame_type
==
KEY_FRAME
)
{
*
totalrate
+=
vp8cx_encode_intra_macro_block
(
cpi
,
x
,
tp
);
*
totalrate
+=
vp8cx_encode_intra_macro_block
(
cpi
,
x
,
&
tp
);
#ifdef MODE_STATS
y_modes
[
xd
->
mbmi
.
mode
]
++
;
#endif
}
else
{
*
totalrate
+=
vp8cx_encode_inter_macroblock
(
cpi
,
x
,
tp
,
recon_yoffset
,
recon_uvoffset
);
*
totalrate
+=
vp8cx_encode_inter_macroblock
(
cpi
,
x
,
&
tp
,
recon_yoffset
,
recon_uvoffset
);
#ifdef MODE_STATS
inter_y_modes
[
xd
->
mbmi
.
mode
]
++
;
...
...
@@ -163,31 +168,32 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
// Count of last ref frame 0,0 useage
if
((
xd
->
mode_info_context
->
mbmi
.
mode
==
ZEROMV
)
&&
(
xd
->
mode_info_context
->
mbmi
.
ref_frame
==
LAST_FRAME
))
cpi
->
inter_zz_count
++
;
cpi
->
inter_zz_count
++
;
// Special case code for cyclic refresh
// If cyclic update enabled then copy xd->mbmi.segment_id; (which may have been updated based on mode
// during vp8cx_encode_inter_macroblock()) back into the global sgmentation map
if
(
cpi
->
cyclic_refresh_mode_enabled
&&
xd
->
segmentation_enabled
)
{
cpi
->
segmentation_map
[
seg_map_index
+
mb_col
]
=
xd
->
mode_info_context
->
mbmi
.
segment_id
;
const
MB_MODE_INFO
*
mbmi
=
&
xd
->
mode_info_context
->
mbmi
;
cpi
->
segmentation_map
[
seg_map_index
+
mb_col
]
=
mbmi
->
segment_id
;
// If the block has been refreshed mark it as clean (the magnitude of the -ve influences how long it will be before we consider another refresh):
// Else if it was coded (last frame 0,0) and has not already been refreshed then mark it as a candidate for cleanup next time (marked 0)
// else mark it as dirty (1).
if
(
xd
->
mode_info_context
->
mbmi
.
segment_id
)
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
=
-
1
;
else
if
((
xd
->
mode_info_context
->
mbmi
.
mode
==
ZEROMV
)
&&
(
xd
->
mode_info_context
->
mbmi
.
ref_frame
==
LAST_FRAME
))
if
(
mbmi
->
segment_id
)
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
=
-
1
;
else
if
((
mbmi
->
mode
==
ZEROMV
)
&&
(
mbmi
->
ref_frame
==
LAST_FRAME
))
{
if
(
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
==
1
)
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
=
0
;
if
(
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
==
1
)
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
=
0
;
}
else
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
=
1
;
cpi
->
cyclic_refresh_map
[
seg_map_index
+
mb_col
]
=
1
;
}
}
cpi
->
tplist
[
mb_row
].
stop
=
*
tp
;
cpi
->
tplist
[
mb_row
].
stop
=
tp
;
x
->
gf_active_ptr
++
;
// Increment pointer into gf useage flags structure for next mb
...
...
@@ -203,16 +209,14 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
recon_uvoffset
+=
8
;
// Keep track of segment useage
segment_counts
[
xd
->
mode_info_context
->
mbmi
.
segment_id
]
++
;
segment_counts
[
xd
->
mode_info_context
->
mbmi
.
segment_id
]
++
;
// skip to next mb
xd
->
mode_info_context
++
;
x
->
partition_info
++
;
xd
->
above_context
++
;
cpi
->
mb_row_ei
[
ithread
].
current_mb_col
=
mb_col
;
cpi
->
mt_current_mb_col
[
mb_row
]
=
mb_col
;
}
//extend the recon for intra prediction
...
...
@@ -234,14 +238,11 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
xd
->
mode_info_context
+=
xd
->
mode_info_stride
*
cpi
->
encoding_thread_count
;
x
->
partition_info
+=
xd
->
mode_info_stride
*
cpi
->
encoding_thread_count
;
if
(
ithread
==
(
cpi
->
encoding_thread_count
-
1
)
||
mb_row
==
cm
->
mb_rows
-
1
)
if
(
mb_row
==
cm
->
mb_rows
-
1
)
{
//SetEvent(cpi->h_event_main);
sem_post
(
&
cpi
->
h_event_main
);
}
sem_post
(
&
cpi
->
h_event_end_encoding
);
/* signal frame encoding end */
}
}
}
}
...
...
@@ -363,7 +364,6 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
}
}
void
vp8cx_init_mbrthread_data
(
VP8_COMP
*
cpi
,
MACROBLOCK
*
x
,
MB_ROW_COMP
*
mbr_ei
,
...
...
@@ -414,7 +414,6 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
mb
->
src
.
u_buffer
+=
8
*
x
->
src
.
uv_stride
*
(
i
+
1
);
mb
->
src
.
v_buffer
+=
8
*
x
->
src
.
uv_stride
*
(
i
+
1
);
vp8_build_block_offsets
(
mb
);
vp8_setup_block_dptrs
(
mbd
);
...
...
@@ -431,7 +430,6 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
}
}
void
vp8cx_create_encoder_threads
(
VP8_COMP
*
cpi
)
{
cpi
->
b_multi_threaded
=
0
;
...
...
@@ -451,14 +449,15 @@ void vp8cx_create_encoder_threads(VP8_COMP *cpi)
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_
mbr
encoding
,
vpx_malloc
(
sizeof
(
sem_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);
sem_init
(
&
cpi
->
h_event_
ma
in
,
0
,
0
);
sem_init
(
&
cpi
->
h_event_
end_encod
in
g
,
0
,
0
);
cpi
->
b_multi_threaded
=
1
;
...
...
@@ -466,11 +465,13 @@ void vp8cx_create_encoder_threads(VP8_COMP *cpi)
for
(
ithread
=
0
;
ithread
<
cpi
->
encoding_thread_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_
mbr
encoding
[
ithread
],
0
,
0
);
cpi
->
en_thread_data
[
ithread
].
ithread
=
ithread
;
cpi
->
en_thread_data
[
ithread
].
ptr1
=
(
void
*
)
cpi
;
cpi
->
en_thread_data
[
ithread
].
ptr2
=
(
void
*
)
&
cpi
->
mb_row_ei
[
ithread
];
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);
...
...
@@ -482,8 +483,7 @@ void vp8cx_create_encoder_threads(VP8_COMP *cpi)
// 0,
// NULL);
pthread_create
(
&
cpi
->
h_encoding_thread
[
ithread
],
0
,
thread_encoding_proc
,
(
&
cpi
->
en_thread_data
[
ithread
]));
pthread_create
(
&
cpi
->
h_encoding_thread
[
ithread
],
0
,
thread_encoding_proc
,
ethd
);
}
}
...
...
@@ -505,18 +505,21 @@ void vp8cx_remove_encoder_threads(VP8_COMP *cpi)
for
(
i
=
0
;
i
<
cpi
->
encoding_thread_count
;
i
++
)
{
//SetEvent(cpi->h_event_mbrencoding[i]);
sem_post
(
&
cpi
->
h_event_
mbr
encoding
[
i
]);
sem_post
(
&
cpi
->
h_event_
start_
encoding
[
i
]);
pthread_join
(
cpi
->
h_encoding_thread
[
i
],
0
);
}
for
(
i
=
0
;
i
<
cpi
->
encoding_thread_count
;
i
++
)
sem_destroy
(
&
cpi
->
h_event_mbrencoding
[
i
]);
sem_destroy
(
&
cpi
->
h_event_start_encoding
[
i
]);
}
}
sem_destroy
(
&
cpi
->
h_event_end_encoding
);
//free thread related resources
vpx_free
(
cpi
->
h_event_
mbr
encoding
);
vpx_free
(
cpi
->
h_event_
start_
encoding
);
vpx_free
(
cpi
->
h_encoding_thread
);
vpx_free
(
cpi
->
mb_row_ei
);
vpx_free
(
cpi
->
en_thread_data
);
vpx_free
(
cpi
->
mt_current_mb_col
);
}
#endif
...
...
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