diff mbox series

[FFmpeg-devel,07/39] avcodec/vp8: Constify slice threads' ptr to main context

Message ID DB6PR0101MB22145AF382BB79D72202416C8F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 9c4f7d1e880a000a070f445386c870427e57971c
Headers show
Series [FFmpeg-devel,01/39] avcodec/hevcdsp: Constify src pointers | expand

Commit Message

Andreas Rheinhardt July 26, 2022, 10:07 p.m. UTC
Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vp8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ronald S. Bultje July 27, 2022, 10:24 a.m. UTC | #1
Hi,

On Wed, Jul 27, 2022 at 5:31 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Modifying the main context from a slice thread is (usually)
> a data race, so it must not happen. So only use a pointer to const
> to access the main context.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/vp8.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index e474fc5de5..d0c26ba00d 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -2582,7 +2582,7 @@ static av_always_inline
>  int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int
> jobnr,
>                                int threadnr, int is_vp7)
>  {
> -    VP8Context *s = avctx->priv_data;
> +    const VP8Context *s = avctx->priv_data;
>      VP8ThreadData *td = &s->thread_data[jobnr];
>      VP8ThreadData *next_td = NULL, *prev_td = NULL;
>      VP8Frame *curframe = s->curframe;
> --
> 2.34.1
>

OK.

Ronald
diff mbox series

Patch

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index e474fc5de5..d0c26ba00d 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2582,7 +2582,7 @@  static av_always_inline
 int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr,
                               int threadnr, int is_vp7)
 {
-    VP8Context *s = avctx->priv_data;
+    const VP8Context *s = avctx->priv_data;
     VP8ThreadData *td = &s->thread_data[jobnr];
     VP8ThreadData *next_td = NULL, *prev_td = NULL;
     VP8Frame *curframe = s->curframe;