1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avcodec/hevcdec: Add pointers to logctx and parent ctx to HEVCLocalCtx

It is safe for a slice thread to read the main context
and therefore it is safe to add a pointer to const HEVCContext
(namely the parent context) to each HEVCLocalContext.
It is also safe (and actually redundant) to add a pointer
to a logcontext to HEVCLocalContext.

Doing so allows to pass the HEVCLocalContext as context in
the parts of the code that is run slice-threaded when slice-threading
is in use (currently these parts of the code use ordinary
HEVCContext*). This way one is not tempted to modify
the main context from the slice contexts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-06-29 15:53:55 +02:00
parent c8d9d15f5e
commit 1837ae9d5f
2 changed files with 7 additions and 0 deletions

View File

@ -2662,6 +2662,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
res = AVERROR(ENOMEM); res = AVERROR(ENOMEM);
goto error; goto error;
} }
s->HEVClcList[i]->logctx = s->avctx;
s->HEVClcList[i]->parent = s->sList[i];
} }
offset = (lc->gb.index >> 3); offset = (lc->gb.index >> 3);
@ -3643,6 +3645,8 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
s->sList = av_mallocz(sizeof(HEVCContext*) * s->threads_number); s->sList = av_mallocz(sizeof(HEVCContext*) * s->threads_number);
if (!s->HEVClc || !s->HEVClcList || !s->sList) if (!s->HEVClc || !s->HEVClcList || !s->sList)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
s->HEVClc->parent = s;
s->HEVClc->logctx = avctx;
s->HEVClcList[0] = s->HEVClc; s->HEVClcList[0] = s->HEVClc;
s->sList[0] = s; s->sList[0] = s;

View File

@ -428,6 +428,9 @@ typedef struct HEVCLocalContext {
uint8_t first_qp_group; uint8_t first_qp_group;
void *logctx;
const struct HEVCContext *parent;
GetBitContext gb; GetBitContext gb;
CABACContext cc; CABACContext cc;