diff mbox series

[FFmpeg-devel,09/14] avcodec/huffyuvenc: Improve code locality

Message ID GV1P250MB073795300E65DD8FC6BC8E658F589@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit f9be667452524f9e1ca9dd6e0f4e357a9b1cfaac
Headers show
Series [FFmpeg-devel,01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 2, 2022, 12:06 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/huffyuvenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 020159a20e..f903b1924a 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -207,7 +207,7 @@  static av_cold int encode_init(AVCodecContext *avctx)
     HYuvContext *s = avctx->priv_data;
     int i, j;
     int ret;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+    const AVPixFmtDescriptor *desc;
 
     s->avctx = avctx;
     ff_huffyuv_common_init(avctx);
@@ -215,6 +215,8 @@  static av_cold int encode_init(AVCodecContext *avctx)
     ff_llvidencdsp_init(&s->llvidencdsp);
 
     avctx->extradata = av_mallocz(3*MAX_N + 4);
+    if (!avctx->extradata)
+        return AVERROR(ENOMEM);
     if (s->flags&AV_CODEC_FLAG_PASS1) {
 #define STATS_OUT_SIZE 21*MAX_N*3 + 4
         avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
@@ -223,9 +225,7 @@  static av_cold int encode_init(AVCodecContext *avctx)
     }
     s->version = 2;
 
-    if (!avctx->extradata)
-        return AVERROR(ENOMEM);
-
+    desc   = av_pix_fmt_desc_get(avctx->pix_fmt);
     s->bps = desc->comp[0].depth;
     s->yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
     s->chroma = desc->nb_components > 2;