[FFmpeg-devel] [PATCH 1/5] lavf/mxfdec: Speed up klv_read_packet()
Tomas Härdin
git at haerdin.se
Sun Sep 22 19:33:49 EEST 2024
This patchset speeds up mxfdec in various ways. The test file has been
generated with
ffmpeg -t 10000 -f lavfi -i testsrc -s 160x120 out2.mxf
Performance is measured with callgrind using the command
valgrind --tool=callgrind ./ffmpeg_g -loglevel quiet -i out2.mxf -codec copy -f null -
The callgraph has then been inspected using kcachegrind. The results
are as follows:
task_wrapper
5 812 306 937 a577d31
5 669 552 343 Speed up klv_read_packet()
5 648 440 947 Add and use IS_KLV_KEY_FAST() in some places
5 633 846 074 Add and use mxf_is_encrypted_triplet_key()
3 667 721 703 Speed up mxf_edit_unit_absolute_offset()
3 587 869 726 Remove a call to avio_tell() in klv_read_packet()
mxf_read_packet (250 001 calls)
3 821 662 859 a577d31
3 665 058 265 Speed up klv_read_packet()
3 647 320 931 Add and use IS_KLV_KEY_FAST() in some places
3 624 081 036 Add and use mxf_is_encrypted_triplet_key()
1 660 495 552 Speed up mxf_edit_unit_absolute_offset()
1 592 469 709 Remove a call to avio_tell() in klv_read_packet()
The biggest difference is made by speeding up
mxf_edit_unit_absolute_offset(). Here's how many cycles it uses before
and after patch 4:
mxf_edit_unit_absolute_offset.constprop.31
2 076 774 255 Add and use mxf_is_encrypted_triplet_key()
105 047 878 Speed up mxf_edit_unit_absolute_offset()
Of the remaining cycles in mxf_edit_unit_absolute_offset(), 67 882 294
are spent in mxf_absolute_bodysid_offset() (272 cycles per call). Since
it already does a binary search it didn't seem worthwhile to mess with.
Patches 2 and 3 are somewhat dubious, but I've included them anyway to
get some feedback. We could both speed up the demuxer and cut down on
.text by omitting the first 4 bytes of every key.
/Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavf-mxfdec-Speed-up-klv_read_packet.patch
Type: text/x-patch
Size: 1703 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240922/32524d79/attachment.bin>
More information about the ffmpeg-devel
mailing list