From: "Chen, Wenbin" <wenbin.chen-at-intel.com@ffmpeg.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/mpegvideo_enc: Fix a chroma mb size error in sse_mb() Date: Mon, 4 Jul 2022 02:14:19 +0000 Message-ID: <BY5PR11MB387988BBF810C9E4A9C6E7BDF8BE9@BY5PR11MB3879.namprd11.prod.outlook.com> (raw) In-Reply-To: <20220701201513.GW396728@pb2> > On Fri, Jul 01, 2022 at 01:34:34PM +0800, Wenbin Chen wrote: > > For 422 frames we should not use hard coded 8 to calculate mb size for > > uv plane. Chroma shift should be taken into consideration to be > > compatiple with different sampling format. > > > > The error is reported by fate test when av_cpu_max_align() return 64 > > on the platform supporting AVX512. This is a hidden error and it is > > exposed after commit 17a59a634c39b00a680c6ebbaea58db95594d13d. > > > > mpeg2enc has a mechanism to reuse frames. When it computes SSE (sum > of > > squared error) on current mb, reconstructed mb will be wrote to the > > previous mb space, so that the memory can be saved. However if the align > > is 64, the frame is shared in somewhere else, so the frame cannot be > > reused and a new frame to store reconstrued data is created. Because the > > height of mb is wrong when compute sse on 422 frame, starting from the > > second line of macro block, changed data is read when frame is reused > > (we need to read row 16 rather than row 8 if frame is 422), and unchanged > > data is read when frame is not reused (a new frame is created so the > > original frame will not be changed). > > > > That is why commit 17a59a634c39b00a680c6ebbaea58db95594d13d > exposes this > > issue, because it add av_cpu_max_align() and this function return 64 on > > platform supporting AVX512 which lead to creating a frame in mpeg2enc, > > and this lead to the different outputs. > > > > Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> > > --- > > libavcodec/mpegvideo_enc.c | 29 +++++++++++++------ > > tests/ref/seek/vsynth_lena-mpeg2-422 | 40 +++++++++++++------------- > > tests/ref/vsynth/vsynth1-mpeg2-422 | 8 +++--- > > tests/ref/vsynth/vsynth2-mpeg2-422 | 8 +++--- > > tests/ref/vsynth/vsynth3-mpeg2-422 | 8 +++--- > > tests/ref/vsynth/vsynth_lena-mpeg2-422 | 8 +++--- > > 6 files changed, 56 insertions(+), 45 deletions(-) > > > > diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c > > index d6a85a037a..c9d9e2a764 100644 > > --- a/libavcodec/mpegvideo_enc.c > > +++ b/libavcodec/mpegvideo_enc.c > > @@ -2558,24 +2558,35 @@ static int sse(MpegEncContext *s, uint8_t *src1, > uint8_t *src2, int w, int h, in > > static int sse_mb(MpegEncContext *s){ > > int w= 16; > > int h= 16; > > + int chroma_mb_w = w >> s->chroma_x_shift; > > + int chroma_mb_h = h >> s->chroma_y_shift; > > > > if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16; > > if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16; > > > > if(w==16 && h==16) > > if(s->avctx->mb_cmp == FF_CMP_NSSE){ > > > - return s->mecc.nsse[0](s, s->new_picture->data[0] + s->mb_x * 16 + s- > >mb_y * s->linesize * 16, s->dest[0], s->linesize, 16) + > > + return s->mecc.nsse[0](s, s->new_picture->data[0] + s->mb_x * 16 + > s->mb_y * s->linesize * 16, > > + s->dest[0], s->linesize, 16) + > > This doesnt belong in this patch, its not a functional change and makes it > harder to see what is changed > > please seperate this in a seperate patch if you want to suggest this > whitespace change > > thx Ok, I will separate it into two patches and resubmit them. Thanks > > > > - s->mecc.nsse[1](s, s->new_picture->data[1] + s->mb_x * 8 + s- > >mb_y * s->uvlinesize * 8, s->dest[1], s->uvlinesize, 8) + > > - s->mecc.nsse[1](s, s->new_picture->data[2] + s->mb_x * 8 + s- > >mb_y * s->uvlinesize * 8, s->dest[2], s->uvlinesize, 8); > > + s->mecc.nsse[1](s, s->new_picture->data[1] + s->mb_x * > chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h, > > + s->dest[1], s->uvlinesize, chroma_mb_h) + > > + s->mecc.nsse[1](s, s->new_picture->data[2] + s->mb_x * > chroma_mb_w + s->mb_y * s->uvlinesize * chroma_mb_h, > > + s->dest[2], s->uvlinesize, chroma_mb_h); > > [...] > -- > Michael GnuPG fingerprint: > 9FF2128B147EF6730BADF133611EC787040B0FAB > > If you fake or manipulate statistics in a paper in physics you will never > get a job again. > If you fake or manipulate statistics in a paper in medicin you will get > a job for life at the pharma industry. _______________________________________________ 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".
next prev parent reply other threads:[~2022-07-04 2:14 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-01 5:34 Wenbin Chen 2022-07-01 7:59 ` Xiang, Haihao 2022-07-01 8:12 ` Paul B Mahol 2022-07-01 8:47 ` Chen, Wenbin 2022-07-01 8:55 ` Paul B Mahol 2022-07-01 20:15 ` Michael Niedermayer 2022-07-04 2:14 ` Chen, Wenbin [this message] 2022-07-01 21:19 ` Soft Works
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=BY5PR11MB387988BBF810C9E4A9C6E7BDF8BE9@BY5PR11MB3879.namprd11.prod.outlook.com \ --to=wenbin.chen-at-intel.com@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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