summaryrefslogtreecommitdiff
path: root/libavcodec/hevcdec.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2017-05-24 11:46:07 -0400
committerRonald S. Bultje <rsbultje@gmail.com>2017-05-25 10:29:07 -0400
commitca2209d67af0a73fe0edb2fce1cea2445dbfd8db (patch)
tree8195440acc607e5ae37d62f456c13b27e2299af6 /libavcodec/hevcdec.c
parent4dc3714c48e74e75a3a9c7d9fb52fd5917107508 (diff)
hevc: fix race condition in max_ra/seq_decode.
These variables are shared between frame threads, but they are updated post-setup_finished() if a EOB/EOS slice type occurs. Moving the EOB/EOS slices to the next frame thread instance (by parsing them leading into the next picture instead of trailing behind the last picture) effectively prevents this race condition. This fixes tsan failures on hevc-conformance-NoOutPrior_A_Qualcomm_1.
Diffstat (limited to 'libavcodec/hevcdec.c')
-rw-r--r--libavcodec/hevcdec.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ee001fd9f2..fc9a5b749e 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2890,6 +2890,7 @@ fail:
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
{
int i, ret = 0;
+ int eos_at_start = 1;
s->ref = NULL;
s->last_eos = s->eos;
@@ -2907,8 +2908,15 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
for (i = 0; i < s->pkt.nb_nals; i++) {
if (s->pkt.nals[i].type == HEVC_NAL_EOB_NUT ||
- s->pkt.nals[i].type == HEVC_NAL_EOS_NUT)
- s->eos = 1;
+ s->pkt.nals[i].type == HEVC_NAL_EOS_NUT) {
+ if (eos_at_start) {
+ s->last_eos = 1;
+ } else {
+ s->eos = 1;
+ }
+ } else {
+ eos_at_start = 0;
+ }
}
/* decode the NAL units */