diff mbox series

[FFmpeg-devel,02/57] avcodec/mpegvideo_enc: Avoid branches for flipping no_rounding

Message ID GV1P250MB0737178265DAE3D3BD9F1A868FC02@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,01/57] avcodec/vc1: Combine identical checks | 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 June 12, 2024, 1:47 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index eda2305630..6ad5b0eb39 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -713,6 +713,7 @@  av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
         s->modified_quant  = s->h263_aic;
         s->loop_filter     = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
         s->unrestricted_mv = s->obmc || s->loop_filter || s->umvplus;
+        s->flipflop_rounding = 1;
 
         /* /Fx */
         /* These are just to be sure */
@@ -746,6 +747,7 @@  av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
         s->out_format      = FMT_H263;
         s->h263_pred       = 1;
         s->unrestricted_mv = 1;
+        s->flipflop_rounding = 1;
         s->low_delay       = s->max_b_frames ? 0 : 1;
         avctx->delay       = s->low_delay ? 0 : (s->max_b_frames + 1);
         break;
@@ -1829,10 +1831,7 @@  vbv_retry:
                 s->mb_skipped = 0;        // done in frame_start()
                 // done in encode_picture() so we must undo it
                 if (s->pict_type == AV_PICTURE_TYPE_P) {
-                    if (s->flipflop_rounding          ||
-                        s->codec_id == AV_CODEC_ID_H263P ||
-                        s->codec_id == AV_CODEC_ID_MPEG4)
-                        s->no_rounding ^= 1;
+                    s->no_rounding ^= s->flipflop_rounding;
                 }
                 if (s->pict_type != AV_PICTURE_TYPE_B) {
                     s->time_base       = s->last_time_base;
@@ -3576,8 +3575,7 @@  static int encode_picture(MpegEncContext *s, const AVPacket *pkt)
     if(s->pict_type==AV_PICTURE_TYPE_I){
         s->no_rounding = s->msmpeg4_version >= MSMP4_V3;
     }else if(s->pict_type!=AV_PICTURE_TYPE_B){
-        if(s->flipflop_rounding || s->codec_id == AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_MPEG4)
-            s->no_rounding ^= 1;
+        s->no_rounding ^= s->flipflop_rounding;
     }
 
     if (s->avctx->flags & AV_CODEC_FLAG_PASS2) {