[FFmpeg-devel] [FFmpeg-cvslog] avcodec/asvenc: Don't waste bits encoding non-visible part
Martin Storsjö
martin at martin.st
Mon May 26 08:20:38 EEST 2025
On Mon, 26 May 2025, Andreas Rheinhardt wrote:
> ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu May 22 15:57:13 2025 +0200| [0401ca714a2714743573e27c384ffa810fd31a92] | committer: Andreas Rheinhardt
>
> avcodec/asvenc: Don't waste bits encoding non-visible part
>
> Up until now, the encoder replicated all the border pixels
> for incomplete 16x16 macroblocks. In case the available width
> or height is <= 8, some of the luma blocks of the MB
> do not correspond to actual input, so that we should encode
> them using the least amount of bits. Zeroing the block coefficients
> (as this commit does) achieves this, replicating the pixels
> and performing an FDCT does not.
>
> This commit also removes the frame copying code for insufficiently
> aligned dimensions.
>
> The vsynth3-asv[12] FATE tests use a 34x34 input file and are
> therefore affected by this. As the ref updates show, the size
> and checksum of the encoded changes, yet the decoded output
> stays the same.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
>
>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0401ca714a2714743573e27c384ffa810fd31a92
> ---
>
> libavcodec/asvenc.c | 131 ++++++++++++++++++++++++++----------------
> tests/ref/vsynth/vsynth3-asv1 | 4 +-
> tests/ref/vsynth/vsynth3-asv2 | 4 +-
> 3 files changed, 84 insertions(+), 55 deletions(-)
As noted on irc, this broke the fate-vsynth3-asv1 and fate-vsynth3-asv2
tests on arm.
The issue is not AV_COPY128 as Andreas wondered on irc; the reason is
a->pdsp.get_pixels. We have a backtrace like this:
#0 0x00cfdd2a in ff_get_pixels_neon ()
at src/libavcodec/arm/pixblockdsp_neon.S:47
#1 0x0082ea54 in dct_get (mb_y=0, mb_x=0, frame=0xf6202f40, a=0x297f450)
at src/libavcodec/asvenc.c:222
#2 encode_frame (avctx=0x297f150, pkt=0xf6202ec0, pict=0xf6202f40,
got_packet=0xf7df4af0) at src/libavcodec/asvenc.c:304
The arguments to a->pdsp.get_pixels are this on entry:
(gdb) info registers r0 r1 r2
r0 0x297f4a0 43512992
r1 0x297caa0 43502240
r2 0x22 34
After one iteration, it hits the bus error due to unaligned reads from the
source, which was expected to stay aligned after incrementing by the
stride.
// Martin
More information about the ffmpeg-devel
mailing list