[FFmpeg-devel] [PATCH 1/2] lavu/aes: add x86 AESNI optimizations

Michael Niedermayer michael at niedermayer.cc
Mon Oct 12 13:18:10 CEST 2015


On Mon, Oct 12, 2015 at 01:13:34PM +0200, Michael Niedermayer wrote:
> On Mon, Oct 12, 2015 at 02:54:28AM -0500, Rodger Combs wrote:
> > ---
> >  libavutil/aes.c          |  2 +
> >  libavutil/aes_internal.h |  2 +
> >  libavutil/x86/Makefile   |  4 +-
> >  libavutil/x86/aes.asm    | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  libavutil/x86/aes_init.c | 37 ++++++++++++++++++
> >  5 files changed, 142 insertions(+), 1 deletion(-)
> >  create mode 100644 libavutil/x86/aes.asm
> >  create mode 100644 libavutil/x86/aes_init.c
> 
> segfaults with:
> ./ffmpeg -i matrixbench_mpeg2.mpg -encryption_key 0123456789abcdef0011223344556677  -encryption_iv aabbccddeeff11335577999876542222  crypto:file.nut


==25780== Invalid write of size 8
==25780==    at 0xF5DF95: ??? (aes.asm:96)
==25780==    by 0x579EAE: crypto_write (crypto.c:247)
==25780==    by 0x5679D5: retry_transfer_wrapper (avio.c:326)
==25780==    by 0x567BB3: ffurl_write (avio.c:375)
==25780==    by 0x56870E: writeout (aviobuf.c:132)
==25780==    by 0x5687BB: flush_buffer (aviobuf.c:144)
==25780==    by 0x568A7F: avio_flush (aviobuf.c:200)
==25780==    by 0x61C36B: write_packet (mux.c:665)
==25780==    by 0x61D57D: av_interleaved_write_frame (mux.c:970)
==25780==    by 0x42B27B: write_frame (ffmpeg.c:774)
==25780==    by 0x42B8E8: do_audio_out (ffmpeg.c:852)
==25780==    by 0x42DE80: reap_filters (ffmpeg.c:1385)
==25780==    by 0x439499: transcode_step (ffmpeg.c:3925)
==25780==    by 0x439572: transcode (ffmpeg.c:3968)
==25780==    by 0x439B73: main (ffmpeg.c:4151)
==25780==  Address 0x2d060110 is 0 bytes after a block of size 16 alloc'd
==25780==    at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
==25780==    by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
==25780==    by 0xF355BB: av_malloc (mem.c:97)
==25780==    by 0x579D87: crypto_write (crypto.c:237)
==25780==    by 0x5679D5: retry_transfer_wrapper (avio.c:326)
==25780==    by 0x567BB3: ffurl_write (avio.c:375)
==25780==    by 0x56870E: writeout (aviobuf.c:132)
==25780==    by 0x5687BB: flush_buffer (aviobuf.c:144)
==25780==    by 0x568A7F: avio_flush (aviobuf.c:200)
==25780==    by 0x61C36B: write_packet (mux.c:665)
==25780==    by 0x61D57D: av_interleaved_write_frame (mux.c:970)
==25780==    by 0x42B27B: write_frame (ffmpeg.c:774)
==25780==    by 0x42B8E8: do_audio_out (ffmpeg.c:852)
==25780==    by 0x42DE80: reap_filters (ffmpeg.c:1385)
==25780==    by 0x439499: transcode_step (ffmpeg.c:3925)
==25780==    by 0x439572: transcode (ffmpeg.c:3968)
==25780==    by 0x439B73: main (ffmpeg.c:4151)
==25780==
==25780== Invalid read of size 8
==25780==    at 0xF5DF06: ??? (aes.asm:96)
==25780==    by 0x579EAE: crypto_write (crypto.c:247)
==25780==    by 0x5679D5: retry_transfer_wrapper (avio.c:326)
==25780==    by 0x567BB3: ffurl_write (avio.c:375)
==25780==    by 0x56870E: writeout (aviobuf.c:132)
==25780==    by 0x5687BB: flush_buffer (aviobuf.c:144)
==25780==    by 0x568A7F: avio_flush (aviobuf.c:200)
==25780==    by 0x61C36B: write_packet (mux.c:665)
==25780==    by 0x61D57D: av_interleaved_write_frame (mux.c:970)
==25780==    by 0x42B27B: write_frame (ffmpeg.c:774)
==25780==    by 0x42B8E8: do_audio_out (ffmpeg.c:852)
==25780==    by 0x42DE80: reap_filters (ffmpeg.c:1385)
==25780==    by 0x439499: transcode_step (ffmpeg.c:3925)
==25780==    by 0x439572: transcode (ffmpeg.c:3968)
==25780==    by 0x439B73: main (ffmpeg.c:4151)
==25780==  Address 0x11a128bf is 32,767 bytes inside a block of size 32,768 alloc'd
==25780==    at 0x4C2A6C5: memalign (vg_replace_malloc.c:727)
==25780==    by 0x4C2A760: posix_memalign (vg_replace_malloc.c:876)
==25780==    by 0xF355BB: av_malloc (mem.c:97)
==25780==    by 0x56A637: ffio_fdopen (aviobuf.c:787)
==25780==    by 0x56ACD0: avio_open2 (aviobuf.c:927)
==25780==    by 0x4227E6: open_output_file (ffmpeg_opt.c:2259)
==25780==    by 0x424E7D: open_files (ffmpeg_opt.c:2911)
==25780==    by 0x425070: ffmpeg_parse_options (ffmpeg_opt.c:2962)
==25780==    by 0x439ADA: main (ffmpeg.c:4129)
==25780==
==25780==
==25780== Process terminating with default action of signal 11 (SIGSEGV)
==25780==  Bad permissions for mapped region at address 0x11B12000
==25780==    at 0xF5DF06: ??? (aes.asm:96)
==25780==    by 0x579EAE: crypto_write (crypto.c:247)
==25780==    by 0x5679D5: retry_transfer_wrapper (avio.c:326)
==25780==    by 0x567BB3: ffurl_write (avio.c:375)
==25780==    by 0x56870E: writeout (aviobuf.c:132)
==25780==    by 0x5687BB: flush_buffer (aviobuf.c:144)
==25780==    by 0x568A7F: avio_flush (aviobuf.c:200)
==25780==    by 0x61C36B: write_packet (mux.c:665)
==25780==    by 0x61D57D: av_interleaved_write_frame (mux.c:970)
==25780==    by 0x42B27B: write_frame (ffmpeg.c:774)
==25780==    by 0x42B8E8: do_audio_out (ffmpeg.c:852)
==25780==    by 0x42DE80: reap_filters (ffmpeg.c:1385)
==25780==    by 0x439499: transcode_step (ffmpeg.c:3925)
==25780==    by 0x439572: transcode (ffmpeg.c:3968)
==25780==    by 0x439B73: main (ffmpeg.c:4151)
==25780==
==25780== HEAP SUMMARY:
==25780==     in use at exit: 21,904,301 bytes in 4,513 blocks
==25780==   total heap usage: 14,903 allocs, 10,390 frees, 33,013,008 bytes allocated
==25780==
==25780== 3,952 bytes in 13 blocks are possibly lost in loss record 595 of 676
==25780==    at 0x4C2A964: calloc (vg_replace_malloc.c:593)
==25780==    by 0x4012074: _dl_allocate_tls (dl-tls.c:297)
==25780==    by 0xD23DABC: pthread_create@@GLIBC_2.2.5 (allocatestack.c:571)
==25780==    by 0xA456B2: ff_slice_thread_init (pthread_slice.c:232)
==25780==    by 0xDE03AF: ff_thread_init (pthread.c:75)
==25780==    by 0xAFDED9: avcodec_open2 (utils.c:1318)
==25780==    by 0x433737: init_output_stream (ffmpeg.c:2599)
==25780==    by 0x43604E: transcode_init (ffmpeg.c:3164)
==25780==    by 0x4394BA: transcode (ffmpeg.c:3939)
==25780==    by 0x439B73: main (ffmpeg.c:4151)
==25780==
==25780== 3,952 bytes in 13 blocks are possibly lost in loss record 596 of 676
==25780==    at 0x4C2A964: calloc (vg_replace_malloc.c:593)
==25780==    by 0x4012074: _dl_allocate_tls (dl-tls.c:297)
==25780==    by 0xD23DABC: pthread_create@@GLIBC_2.2.5 (allocatestack.c:571)
==25780==    by 0xA456B2: ff_slice_thread_init (pthread_slice.c:232)
==25780==    by 0xDE03AF: ff_thread_init (pthread.c:75)
==25780==    by 0xAFDED9: avcodec_open2 (utils.c:1318)
==25780==    by 0x4333C7: init_input_stream (ffmpeg.c:2540)
==25780==    by 0x4360A1: transcode_init (ffmpeg.c:3171)
==25780==    by 0x4394BA: transcode (ffmpeg.c:3939)
==25780==    by 0x439B73: main (ffmpeg.c:4151)
==25780==
==25780== 7,904 bytes in 26 blocks are possibly lost in loss record 622 of 676
==25780==    at 0x4C2A964: calloc (vg_replace_malloc.c:593)
==25780==    by 0x4012074: _dl_allocate_tls (dl-tls.c:297)
==25780==    by 0xD23DABC: pthread_create@@GLIBC_2.2.5 (allocatestack.c:571)
==25780==    by 0x471488: thread_init_internal (pthread.c:187)
==25780==    by 0x471557: ff_graph_thread_init (pthread.c:218)
==25780==    by 0x45EB76: avfilter_graph_alloc_filter (avfiltergraph.c:182)
==25780==    by 0x46FD13: create_filter (graphparser.c:114)
==25780==    by 0x46FF52: parse_filter (graphparser.c:176)
==25780==    by 0x4707B5: avfilter_graph_parse2 (graphparser.c:411)
==25780==    by 0x428D64: configure_filtergraph (ffmpeg_filter.c:1002)
==25780==    by 0x435544: transcode_init (ffmpeg.c:3007)
==25780==    by 0x4394BA: transcode (ffmpeg.c:3939)
==25780==    by 0x439B73: main (ffmpeg.c:4151)
==25780==
==25780== LEAK SUMMARY:
==25780==    definitely lost: 0 bytes in 0 blocks
==25780==    indirectly lost: 0 bytes in 0 blocks
==25780==      possibly lost: 15,808 bytes in 52 blocks
==25780==    still reachable: 21,888,493 bytes in 4,461 blocks
==25780==         suppressed: 0 bytes in 0 blocks
==25780== Reachable blocks (those to which a pointer was found) are not shown.
==25780== To see them, rerun with: --leak-check=full --show-reachable=yes



[...]


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151012/b9ef2eb7/attachment.sig>


More information about the ffmpeg-devel mailing list