diff mbox series

[FFmpeg-devel,10/11] doc/examples/transcode: simplify selection of pix_fmt

Message ID 20230902151921.1712373-11-stefasab@gmail.com
State New
Headers show
Series [FFmpeg-devel,01/11] lavc/avcodec.h: fix typos in AVCodecContext.pkt_timebase description | expand

Checks

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

Commit Message

Stefano Sabatini Sept. 2, 2023, 3:19 p.m. UTC
Use ternary operator.
---
 doc/examples/transcode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c
index 524bb47f50..1d22a4b09e 100644
--- a/doc/examples/transcode.c
+++ b/doc/examples/transcode.c
@@ -178,11 +178,10 @@  static int open_output_file(const char *filename)
                 enc_ctx->height = dec_ctx->height;
                 enc_ctx->width = dec_ctx->width;
                 enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
-                /* take first format from list of supported formats */
-                if (encoder->pix_fmts)
-                    enc_ctx->pix_fmt = encoder->pix_fmts[0];
-                else
-                    enc_ctx->pix_fmt = dec_ctx->pix_fmt;
+
+                /* take first format from list of supported formats or use decoder one */
+                enc_ctx->pix_fmt = encoder->pix_fmts ? encoder->pix_fmts[0] : dec_ctx->pix_fmt;
+
                 /* video time_base can be set to whatever is handy and supported by encoder */
                 enc_ctx->time_base = av_inv_q(dec_ctx->framerate);
             } else {