---
 libavcodec/encode.c | 48 +++++++++++++++++++++++----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 2da9f6ba23..0d44f70ee9 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -550,6 +550,7 @@ int attribute_align_arg 
avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
 
 static int encode_preinit_video(AVCodecContext *avctx)
 {
+    const AVCodec *c = avctx->codec;
     const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
     int i;
 
@@ -559,20 +560,20 @@ static int encode_preinit_video(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
-    if (avctx->codec->pix_fmts) {
-        for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
-            if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
+    if (c->pix_fmts) {
+        for (i = 0; c->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
+            if (avctx->pix_fmt == c->pix_fmts[i])
                 break;
-        if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE) {
+        if (c->pix_fmts[i] == AV_PIX_FMT_NONE) {
             av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is not 
supported\n",
                    av_get_pix_fmt_name(avctx->pix_fmt));
             return AVERROR(EINVAL);
         }
-        if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
-            avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ411P ||
-            avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ422P ||
-            avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ440P ||
-            avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
+        if (c->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
+            c->pix_fmts[i] == AV_PIX_FMT_YUVJ411P ||
+            c->pix_fmts[i] == AV_PIX_FMT_YUVJ422P ||
+            c->pix_fmts[i] == AV_PIX_FMT_YUVJ440P ||
+            c->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
             avctx->color_range = AVCOL_RANGE_JPEG;
     }
 
@@ -625,6 +626,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 static int encode_preinit_audio(AVCodecContext *avctx)
 {
+    const AVCodec *c = avctx->codec;
     int i;
 
     if (!av_get_sample_fmt_name(avctx->sample_fmt)) {
@@ -633,28 +635,28 @@ static int encode_preinit_audio(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
-    if (avctx->codec->sample_fmts) {
-        for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
-            if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
+    if (c->sample_fmts) {
+        for (i = 0; c->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
+            if (avctx->sample_fmt == c->sample_fmts[i])
                 break;
             if (avctx->ch_layout.nb_channels == 1 &&
                 av_get_planar_sample_fmt(avctx->sample_fmt) ==
-                av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) {
-                avctx->sample_fmt = avctx->codec->sample_fmts[i];
+                av_get_planar_sample_fmt(c->sample_fmts[i])) {
+                avctx->sample_fmt = c->sample_fmts[i];
                 break;
             }
         }
-        if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
+        if (c->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
             av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is not 
supported\n",
                    av_get_sample_fmt_name(avctx->sample_fmt));
             return AVERROR(EINVAL);
         }
     }
-    if (avctx->codec->supported_samplerates) {
-        for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
-            if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
+    if (c->supported_samplerates) {
+        for (i = 0; c->supported_samplerates[i] != 0; i++)
+            if (avctx->sample_rate == c->supported_samplerates[i])
                 break;
-        if (avctx->codec->supported_samplerates[i] == 0) {
+        if (c->supported_samplerates[i] == 0) {
             av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not 
supported\n",
                    avctx->sample_rate);
             return AVERROR(EINVAL);
@@ -665,12 +667,12 @@ static int encode_preinit_audio(AVCodecContext *avctx)
                 avctx->sample_rate);
         return AVERROR(EINVAL);
     }
-    if (avctx->codec->ch_layouts) {
-        for (i = 0; avctx->codec->ch_layouts[i].nb_channels; i++) {
-            if (!av_channel_layout_compare(&avctx->ch_layout, 
&avctx->codec->ch_layouts[i]))
+    if (c->ch_layouts) {
+        for (i = 0; c->ch_layouts[i].nb_channels; i++) {
+            if (!av_channel_layout_compare(&avctx->ch_layout, 
&c->ch_layouts[i]))
                 break;
         }
-        if (!avctx->codec->ch_layouts[i].nb_channels) {
+        if (!c->ch_layouts[i].nb_channels) {
             char buf[512];
             int ret = av_channel_layout_describe(&avctx->ch_layout, buf, 
sizeof(buf));
             if (ret > 0)
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to