[FFmpeg-cvslog] avcodec/hevcdec: Add pointers to logctx and parent ctx to HEVCLocalCtx
Andreas Rheinhardt
git at videolan.org
Tue Jul 26 00:58:43 EEST 2022
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Jun 29 15:53:55 2022 +0200| [1837ae9d5f3eb8483c76dc708e68e466f9021cac] | committer: Andreas Rheinhardt
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1837ae9d5f3eb8483c76dc708e68e466f9021cac
---
libavcodec/hevcdec.c | 4 ++++
libavcodec/hevcdec.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 79e4c36d86..846077b6ab 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2662,6 +2662,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
res = AVERROR(ENOMEM);
goto error;
}
+ s->HEVClcList[i]->logctx = s->avctx;
+ s->HEVClcList[i]->parent = s->sList[i];
}
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);
if (!s->HEVClc || !s->HEVClcList || !s->sList)
return AVERROR(ENOMEM);
+ s->HEVClc->parent = s;
+ s->HEVClc->logctx = avctx;
s->HEVClcList[0] = s->HEVClc;
s->sList[0] = s;
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index f6acf845ae..271a55df2f 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -428,6 +428,9 @@ typedef struct HEVCLocalContext {
uint8_t first_qp_group;
+ void *logctx;
+ const struct HEVCContext *parent;
+
GetBitContext gb;
CABACContext cc;
More information about the ffmpeg-cvslog
mailing list