[FFmpeg-devel] [PATCH 02/57] avcodec/mpegvideo_enc: Avoid branches for flipping no_rounding
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Jun 12 16:47:58 EEST 2024
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/mpegvideo_enc.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
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) {
--
2.40.1
More information about the ffmpeg-devel
mailing list