Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2 1/2] libavcodec/mpegvideo_enc: fix multi-threaded motion estimation rounding for mpeg4
@ 2024-05-08 15:19 Ramiro Polla
  2024-05-08 15:19 ` [FFmpeg-devel] [PATCH v2 2/2] libavcodec/motion_est: fix penalty_factor for b frames Ramiro Polla
  2024-05-09  0:44 ` [FFmpeg-devel] [PATCH v2 1/2] libavcodec/mpegvideo_enc: fix multi-threaded motion estimation rounding for mpeg4 Michael Niedermayer
  0 siblings, 2 replies; 6+ messages in thread
From: Ramiro Polla @ 2024-05-08 15:19 UTC (permalink / raw)
  To: ffmpeg-devel

ff_init_me() was being called after ff_update_duplicate_context(),
which caused the propagation of the initialization to other thread
contexts to be delayed by one frame.

In the case of mpeg4 (or flipflop_rounding), this would make the
hpel_put functions differ between the first thread (which would be
correctly initialized) and the other threads (which would be stale
from the previous frame).
---
 libavcodec/mpegvideo_enc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 2a75973ac4..b601a1a9e4 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3623,6 +3623,9 @@ static int encode_picture(MpegEncContext *s)
         s->q_chroma_intra_matrix16 = s->q_intra_matrix16;
     }
 
+    if(ff_init_me(s)<0)
+        return -1;
+
     s->mb_intra=0; //for the rate distortion & bit compare functions
     for(i=1; i<context_count; i++){
         ret = ff_update_duplicate_context(s->thread_context[i], s);
@@ -3630,9 +3633,6 @@ static int encode_picture(MpegEncContext *s)
             return ret;
     }
 
-    if(ff_init_me(s)<0)
-        return -1;
-
     /* Estimate motion for every MB */
     if(s->pict_type != AV_PICTURE_TYPE_I){
         s->lambda  = (s->lambda  * s->me_penalty_compensation + 128) >> 8;
-- 
2.30.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-11  8:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-08 15:19 [FFmpeg-devel] [PATCH v2 1/2] libavcodec/mpegvideo_enc: fix multi-threaded motion estimation rounding for mpeg4 Ramiro Polla
2024-05-08 15:19 ` [FFmpeg-devel] [PATCH v2 2/2] libavcodec/motion_est: fix penalty_factor for b frames Ramiro Polla
2024-05-08 21:47   ` Michael Niedermayer
2024-05-11  7:42     ` Ramiro Polla
2024-05-09  0:44 ` [FFmpeg-devel] [PATCH v2 1/2] libavcodec/mpegvideo_enc: fix multi-threaded motion estimation rounding for mpeg4 Michael Niedermayer
2024-05-11  8:25   ` Ramiro Polla

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git