diff mbox series

[FFmpeg-devel,6/6] avcodec/libx264: Use av_pix_fmt_count_planes() where appropriate

Message ID AS8P250MB0744AD60F380BC20EE4B05678FB99@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit a6e9d01f88a707f8a2057e01b5ad2e8968109530
Headers show
Series [FFmpeg-devel,1/3] avfilter/vf_ssim360: Use correct type in sizeof | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt March 13, 2023, 1:22 p.m. UTC
This also fixes the number of planes for the NV formats
(this seems to not have caused any problems).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/libx264.c | 24 +-----------------------
 1 file changed, 1 insertion(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 94006d2b20..92828fabc3 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -189,28 +189,6 @@  static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
     return 1;
 }
 
-static int avfmt2_num_planes(int avfmt)
-{
-    switch (avfmt) {
-    case AV_PIX_FMT_YUV420P:
-    case AV_PIX_FMT_YUVJ420P:
-    case AV_PIX_FMT_YUV420P9:
-    case AV_PIX_FMT_YUV420P10:
-    case AV_PIX_FMT_YUV444P:
-        return 3;
-
-    case AV_PIX_FMT_BGR0:
-    case AV_PIX_FMT_BGR24:
-    case AV_PIX_FMT_RGB24:
-    case AV_PIX_FMT_GRAY8:
-    case AV_PIX_FMT_GRAY10:
-        return 1;
-
-    default:
-        return 3;
-    }
-}
-
 static void reconfig_encoder(AVCodecContext *ctx, const AVFrame *frame)
 {
     X264Context *x4 = ctx->priv_data;
@@ -440,7 +418,7 @@  static int setup_frame(AVCodecContext *ctx, const AVFrame *frame,
 #endif
     if (bit_depth > 8)
         pic->img.i_csp |= X264_CSP_HIGH_DEPTH;
-    pic->img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
+    pic->img.i_plane = av_pix_fmt_count_planes(ctx->pix_fmt);
 
     for (int i = 0; i < pic->img.i_plane; i++) {
         pic->img.plane[i]    = frame->data[i];