From 67be5b312ac5b2f5ca28131c6d72ba2254c955a8 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 2 Mar 2025 00:34:19 +0100
Subject: [PATCH 10/77] avcodec/speedhqenc: Avoid indirection

Namely use avctx directly instead of s->avctx. While just at it,
also move the switch to the other checks involving avctx.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/speedhqenc.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index de1bc0cfca..2e09016935 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -112,6 +112,20 @@ static av_cold int speedhq_encode_init(AVCodecContext *avctx)
         return AVERROR_PATCHWELCOME;
     }
 
+    switch (avctx->pix_fmt) {
+    case AV_PIX_FMT_YUV420P:
+        avctx->codec_tag = MKTAG('S','H','Q','0');
+        break;
+    case AV_PIX_FMT_YUV422P:
+        avctx->codec_tag = MKTAG('S','H','Q','2');
+        break;
+    case AV_PIX_FMT_YUV444P:
+        avctx->codec_tag = MKTAG('S','H','Q','4');
+        break;
+    default:
+        av_assert0(0);
+    }
+
     s->min_qcoeff = -2048;
     s->max_qcoeff = 2047;
 
@@ -129,20 +143,6 @@ static av_cold int speedhq_encode_init(AVCodecContext *avctx)
 
     ff_thread_once(&init_static_once, speedhq_init_static_data);
 
-    switch (s->avctx->pix_fmt) {
-    case AV_PIX_FMT_YUV420P:
-        s->avctx->codec_tag = MKTAG('S','H','Q','0');
-        break;
-    case AV_PIX_FMT_YUV422P:
-        s->avctx->codec_tag = MKTAG('S','H','Q','2');
-        break;
-    case AV_PIX_FMT_YUV444P:
-        s->avctx->codec_tag = MKTAG('S','H','Q','4');
-        break;
-    default:
-        av_assert0(0);
-    }
-
     return 0;
 }
 
-- 
2.45.2