diff mbox series

[FFmpeg-devel,08/21] avcodec/mpeg12enc: Return early if no Sequence Header is written

Message ID AM7PR03MB66607F736CDDCD559AAA4C078F5F9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit d3a2d066333061fe3d9248b52d23de1e363d5b84
Headers show
Series [FFmpeg-devel,01/21] avcodec/h263: Remove declaration for inexistent function | expand

Checks

Context Check Description
andriy/make_fate_x86 success Make fate finished
andriy/make_x86 warning New warnings during build
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_aarch64_jetson warning New warnings during build

Commit Message

Andreas Rheinhardt Jan. 25, 2022, 5:41 p.m. UTC
Allows to avoid one level of indentation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg12enc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index a19100a42d..e30e41027c 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -264,16 +264,18 @@  static void mpeg1_encode_sequence_header(MpegEncContext *s)
     MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s;
     unsigned int vbv_buffer_size, fps, v;
     int i, constraint_parameter_flag;
+    AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
     uint64_t time_code;
     int64_t best_aspect_error = INT64_MAX;
     AVRational aspect_ratio = s->avctx->sample_aspect_ratio;
+    int aspect_ratio_info;
+
+    if (!s->current_picture.f->key_frame)
+        return;
 
     if (aspect_ratio.num == 0 || aspect_ratio.den == 0)
         aspect_ratio = (AVRational){1,1};             // pixel aspect 1.1 (VGA)
 
-    if (s->current_picture.f->key_frame) {
-        AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
-        int aspect_ratio_info;
 
         /* MPEG-1 header repeated every GOP */
         put_header(s, SEQ_START_CODE);
@@ -414,7 +416,6 @@  static void mpeg1_encode_sequence_header(MpegEncContext *s)
         put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
         put_bits(&s->pb, 1, !!(s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) || s->intra_only || !s->gop_picture_number);
         put_bits(&s->pb, 1, 0);                     // broken link
-    }
 }
 
 static inline void encode_mb_skip_run(MpegEncContext *s, int run)