You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Measure speed against ffmpeg (single core) and file the gaps #2
Wave D1 (#1) left the speed comparison undone: the machine's 1-minute load was
36 to 50 throughout, and a measurement is not taken above 8.
To do, when load allows: single core (GOMAXPROCS=1), interleaved rounds, ffmpeg -threads 1 -f null as the reference, on the 1080p and 720p clips the
README lists and a CIF conformance stream. Report frames/s for both and the
ratio; anything slower than ffmpeg is a defect to open against go.264 with the
profile (algorithm first, then SIMD kernels through go-simd / go-asmgen).
Only indication so far, not a measurement (load ~50): a 900-picture 1080p clip
decoded in 28.7 s wall clock.
Also: decode.Decoder copies every output picture out of the reference buffer
(one allocation per frame); a caller-supplied buffer or pool is the obvious
first saving.
Speed against ffmpeg, single core: v0.3.0 is slower on every input measured (open defect)
Baseline: clean clone of tag v0.3.0 (library code identical to main; the only addition is the jvt bench command from the PR that will follow). Apple M4 Max, darwin/arm64, Go 1.27.3, ffmpeg 9.0.2 (Homebrew, clang). Ours: GOMAXPROCS=1, whole input decoded from memory, pictures counted and dropped. ffmpeg: -threads 1 -benchmark -f null - -fps_mode passthrough, fps taken from its own rtime. Interleaved rounds (ours, ffmpeg, ours, ffmpeg...), 5 rounds each, median and (min-max). The harness refuses to start a run when the 1-minute load is >= 8.
Load before each run: 7.21 / 7.65 / 7.97 (min / median / max) for the bitstreams, 5.89 / 6.62 / 7.69 for the real clips. Times are indicative at that load (the ratios are stable across rounds, spread below); allocation counts are exact.
Notes on the inputs. The committed bitstreams are a few pictures long, so each was concatenated 100 times (valid: each copy opens with its IDR) into a durable directory and both sides decode that file; ffmpeg's clock has 1 ms resolution, the unrepeated run is not measurable. The two real files are stream-copy clips cut with ffmpeg from local files at minute 40 (-ss 2400, 600 and 60 packets), nothing committed. No real HEVC Main file exists in the library (both x265 files are Main 10, 2160p); HEVC Main is covered by main_ipb/main_wpp_slices only. The JVT/JCT-VC conformance bitstreams themselves are not in the repository (md5 only), so they were not used. Frame counts equal on both sides for every input.
Open defects (every row is slower than ffmpeg)
Profile (jvt bench --cpuprofile, pprof top) of the two real inputs. Nothing below was changed.
H.264, ratio 0.21. The profile is spread over go.264's pure Go kernels, no single hot spot in our wrapper:
oops1/go.264@v1.12.0/internal/simd/generic.go:197-203hFilter1, the 6-tap luma filter, 15.7 % flat (4.6 s of 29.3 s); with vFilter1 (:206), sixTapHorizGeneric (:225), sixTapVertGeneric, sixTapHVGeneric the interpolation is about 35 % cumulative.
Cause: internal/simd/dispatch_generic.go:40 (sixTapHorizGeneric) is the build for everything that is not amd64; the assembly kernels exist only in kernels_amd64.s. On arm64 there is no NEON path, while ffmpeg uses NEON. (This table is arm64; an amd64 measurement is needed to know whether AVX2 closes the gap.)
CABAC residual decoding is next: internal/cabacDecodeDecision 15 % cumulative, ResidualBlock8x8 11 %. Then deblocking (internal/deblock.filterEdge 5 %), transform.Inverse8x8 4.7 %.
Our wrapper: decode.go:257-276(*Decoder).frame (the per-picture plane copy) is 0.44 % of CPU, so the "one allocation per frame" noted in the issue is not the cause of the gap. Allocation is 46 per picture and 6.7 MiB per 1920x808 picture, while the output planes are 2.3 MiB: the rest is allocated inside go.264, not attributed.
HEVC Main 10, ratio 0.37 (Main 0.30-0.37 on the small streams). gen2brain/h265@v0.2.4:
hevc/interpred.go:63-199mcLuma[uint16] 39 % cumulative (4.16 s of 10.6 s), mcChroma[uint16] 15 %. The assembly kernels are taken only when bitDepth == 8 && w%8 == 0 (interpred.go:96-104); at 10 bits they fall to the scalar loops, with the 8-tap inner loop through the closure at at interpred.go:90-92 (1.1 s flat on that line alone) and the separable 2-D case at interpred.go:177-197 (about 2.8 s). So the Main 10 path has no SIMD motion compensation at all.
predBiGo[uint16] 5 %, decodeResidual 11 % cumulative; idctCols4NEON is present (0.7 s), so the transforms are partly vectorised already.
Our wrapper: hevc.go:235-243cropPlane16 (16-bit planes to little-endian bytes, byte by byte) is 3.9 % of CPU, a small wrapper-side saving available (encoding/binary or a unsafe-free bulk copy when no cropping is needed); not done.
Allocation: 20.4 MiB per 3840x1606 picture against 18.5 MiB of output planes.
The gap is therefore mostly upstream (no arm64 SIMD in go.264; no 16-bit SIMD in h265 motion compensation) and should be filed there after the amd64 numbers are in, per the doctrine of putting kernels in the lowest shared library (go-simd / go-asmgen); not filed from this task. Wrapper-side: cropPlane16, and caller-supplied buffers to remove the per-frame allocation (memory, not time).
Harness: jvt bench in the tools module (PR to follow, Refs #2): jvt bench --rounds 5 [--repeat N --workdir D] [--cpuprofile F] [--wait 8m] PATH....
Audio (wave D3, #11, #14, #15): speed against ffmpeg was not measured. The 1-minute load was 18 when the work began and 36 when a measurement was tried, above the limit of 8.
What is ready for it: BenchmarkAudioTrack in the audio branches decodes the file named by DECODE_BENCH_FILE (a long .mp3, .flac or .ogg) through DecodeAudioTrack and reports MB/s of PCM; the comparison is ffmpeg -threads 1 -i FILE -f null - timed over the same file, interleaved rounds, at load below 8. FLAC (mewkiz/flac), MP3 (tphakala/go-mp3, a minimp3 port) and Opus (pion/opus) are the three to measure; a gap is an open defect.
hevc-main-ipb.mp4 / hevc-main10-ipb.mp4: ffmpeg returns 10 pictures, we return 12 (localised: not a decode defect)
Follow-up to the 12/10 count seen while measuring above; checked before anything else, as a correctness question.
Evidence (ffmpeg 9.0.2, -threads 1, -f framemd5):
mp4ff-info: both files have elst with one entry segmentDuration=480000 mediaTime=96000 (timescale 1200000, so the edit starts 2 frames into the media; mdhd duration is 576000 = 12 frames), a single stts entry, and no ctts box, although the streams contain B pictures. ffprobe -show_entries packet therefore gives pts = dts = -2, -1, 0, ... frames and flags the first two packets D (discard: before the edit start).
ffmpeg default and -fps_mode passthrough give 9 and 10 pictures; the null/framemd5 muxer's frame-rate logic only changes how timestamps repeat, it is not what drops pictures.
-ignore_editlist 1 gives 12 pictures, and the same 12 MD5s as ffmpeg decoding the raw main_ipb.265 stream, and as our DecodeTrack (checked: ours == -ignore_editlist, ours != default).
The two pictures ffmpeg drops are display indexes 0 and 4 of our output: the I and the first P, i.e. the pictures of the first two samples in decoding order. Without ctts the decoding order is the presentation order the edit list is applied to.
Verdict: (b). All 12 pictures are really in the stream; ffmpeg's default drops those that the edit list places before the start of presentation. decode returns every decoded picture with its PTS and leaves presentation trimming to the caller (avkit's edit-list handling), so there is no defect here and no change. The fixtures are valid files, only unusual (elst without ctts, as an ffmpeg remux of a raw HEVC stream gives).
Same check on the H.264 fixtures: bframes.mp4, bframes-delayed.mp4 and bframes.mkv return 10/10 with identical MD5s on both sides. bframes.mp4 also has an elst (mediaTime=1280, 2 frames) but carries a ctts that shifts the presentation times by the same amount, so nothing is trimmed. (hvc1.mp4 is the deliberately undecodable fixture.)
Consequence for the oracle: comparing a container file with ffmpeg -f framemd5 is exact only when the file's edit list trims no picture; -ignore_editlist 1 is the flag that compares decoding alone. The real-file hashes in testdata/*real-files.txt are stream-copy clips whose counts matched, so they are unaffected.
AAC-LC speed against ffmpeg: not measured. The 1-minute load was 19 to 61 each time I tried on 2026-11-10 (the limit is 8), so no number is given. BenchmarkAACDecode (aac_bench_test.go, PR #31) decodes the pinned conformance stream al05_48 (stereo, 48 kHz, about 7.4 s) single core; run it with AAC_CONFORMANCE_DIR set and -cpu 1, interleaved with ffmpeg -threads 1 -benchmark -i al05_48.mp4 -f null - (and -cpuflags 0 for the C paths) once the load is low. An indication under load, not a result: 9.3 ms per op for the benchmark, which is about 800 times real time.
Activity
tannevaled commentedon Nov 10, 2026
Speed against ffmpeg, single core: v0.3.0 is slower on every input measured (open defect)
Baseline: clean clone of tag
v0.3.0(library code identical tomain; the only addition is thejvt benchcommand from the PR that will follow). Apple M4 Max, darwin/arm64, Go 1.27.3, ffmpeg 9.0.2 (Homebrew, clang). Ours:GOMAXPROCS=1, whole input decoded from memory, pictures counted and dropped. ffmpeg:-threads 1 -benchmark -f null - -fps_mode passthrough, fps taken from its ownrtime. Interleaved rounds (ours, ffmpeg, ours, ffmpeg...), 5 rounds each, median and (min-max). The harness refuses to start a run when the 1-minute load is >= 8.Load before each run: 7.21 / 7.65 / 7.97 (min / median / max) for the bitstreams, 5.89 / 6.62 / 7.69 for the real clips. Times are indicative at that load (the ratios are stable across rounds, spread below); allocation counts are exact.
Notes on the inputs. The committed bitstreams are a few pictures long, so each was concatenated 100 times (valid: each copy opens with its IDR) into a durable directory and both sides decode that file; ffmpeg's clock has 1 ms resolution, the unrepeated run is not measurable. The two real files are stream-copy clips cut with ffmpeg from local files at minute 40 (
-ss 2400, 600 and 60 packets), nothing committed. No real HEVC Main file exists in the library (both x265 files are Main 10, 2160p); HEVC Main is covered bymain_ipb/main_wpp_slicesonly. The JVT/JCT-VC conformance bitstreams themselves are not in the repository (md5 only), so they were not used. Frame counts equal on both sides for every input.Open defects (every row is slower than ffmpeg)
Profile (
jvt bench --cpuprofile, pprof top) of the two real inputs. Nothing below was changed.H.264, ratio 0.21. The profile is spread over go.264's pure Go kernels, no single hot spot in our wrapper:
oops1/go.264@v1.12.0/internal/simd/generic.go:197-203hFilter1, the 6-tap luma filter, 15.7 % flat (4.6 s of 29.3 s); withvFilter1(:206),sixTapHorizGeneric(:225),sixTapVertGeneric,sixTapHVGenericthe interpolation is about 35 % cumulative.internal/simd/dispatch_generic.go:40(sixTapHorizGeneric) is the build for everything that is not amd64; the assembly kernels exist only inkernels_amd64.s. On arm64 there is no NEON path, while ffmpeg uses NEON. (This table is arm64; an amd64 measurement is needed to know whether AVX2 closes the gap.)internal/cabacDecodeDecision15 % cumulative,ResidualBlock8x811 %. Then deblocking (internal/deblock.filterEdge5 %),transform.Inverse8x84.7 %.decode.go:257-276(*Decoder).frame(the per-picture plane copy) is 0.44 % of CPU, so the "one allocation per frame" noted in the issue is not the cause of the gap. Allocation is 46 per picture and 6.7 MiB per 1920x808 picture, while the output planes are 2.3 MiB: the rest is allocated inside go.264, not attributed.HEVC Main 10, ratio 0.37 (Main 0.30-0.37 on the small streams). gen2brain/h265@v0.2.4:
hevc/interpred.go:63-199mcLuma[uint16]39 % cumulative (4.16 s of 10.6 s),mcChroma[uint16]15 %. The assembly kernels are taken only whenbitDepth == 8 && w%8 == 0(interpred.go:96-104); at 10 bits they fall to the scalar loops, with the 8-tap inner loop through the closureatatinterpred.go:90-92(1.1 s flat on that line alone) and the separable 2-D case atinterpred.go:177-197(about 2.8 s). So the Main 10 path has no SIMD motion compensation at all.predBiGo[uint16]5 %,decodeResidual11 % cumulative;idctCols4NEONis present (0.7 s), so the transforms are partly vectorised already.hevc.go:235-243cropPlane16(16-bit planes to little-endian bytes, byte by byte) is 3.9 % of CPU, a small wrapper-side saving available (encoding/binaryor aunsafe-free bulk copy when no cropping is needed); not done.The gap is therefore mostly upstream (no arm64 SIMD in go.264; no 16-bit SIMD in h265 motion compensation) and should be filed there after the amd64 numbers are in, per the doctrine of putting kernels in the lowest shared library (go-simd / go-asmgen); not filed from this task. Wrapper-side:
cropPlane16, and caller-supplied buffers to remove the per-frame allocation (memory, not time).Harness:
jvt benchin the tools module (PR to follow,Refs #2):jvt bench --rounds 5 [--repeat N --workdir D] [--cpuprofile F] [--wait 8m] PATH....tools/jvt: bench builds on Windows, CPU time from getrusage only on unix
tannevaled commentedon Nov 10, 2026
Audio (wave D3, #11, #14, #15): speed against ffmpeg was not measured. The 1-minute load was 18 when the work began and 36 when a measurement was tried, above the limit of 8.
What is ready for it:
BenchmarkAudioTrackin the audio branches decodes the file named byDECODE_BENCH_FILE(a long .mp3, .flac or .ogg) throughDecodeAudioTrackand reports MB/s of PCM; the comparison isffmpeg -threads 1 -i FILE -f null -timed over the same file, interleaved rounds, at load below 8. FLAC (mewkiz/flac), MP3 (tphakala/go-mp3, a minimp3 port) and Opus (pion/opus) are the three to measure; a gap is an open defect.tannevaled commentedon Nov 10, 2026
hevc-main-ipb.mp4 / hevc-main10-ipb.mp4: ffmpeg returns 10 pictures, we return 12 (localised: not a decode defect)
Follow-up to the 12/10 count seen while measuring above; checked before anything else, as a correctness question.
Evidence (ffmpeg 9.0.2,
-threads 1,-f framemd5):mp4ff-info: both files haveelstwith one entrysegmentDuration=480000 mediaTime=96000(timescale 1200000, so the edit starts 2 frames into the media;mdhdduration is 576000 = 12 frames), a singlesttsentry, and nocttsbox, although the streams contain B pictures.ffprobe -show_entries packettherefore gives pts = dts = -2, -1, 0, ... frames and flags the first two packetsD(discard: before the edit start).-fps_mode passthroughgive 9 and 10 pictures; the null/framemd5 muxer's frame-rate logic only changes how timestamps repeat, it is not what drops pictures.-ignore_editlist 1gives 12 pictures, and the same 12 MD5s as ffmpeg decoding the rawmain_ipb.265stream, and as ourDecodeTrack(checked: ours ==-ignore_editlist, ours != default).cttsthe decoding order is the presentation order the edit list is applied to.Verdict: (b). All 12 pictures are really in the stream; ffmpeg's default drops those that the edit list places before the start of presentation.
decodereturns every decoded picture with its PTS and leaves presentation trimming to the caller (avkit's edit-list handling), so there is no defect here and no change. The fixtures are valid files, only unusual (elst without ctts, as an ffmpeg remux of a raw HEVC stream gives).Same check on the H.264 fixtures:
bframes.mp4,bframes-delayed.mp4andbframes.mkvreturn 10/10 with identical MD5s on both sides.bframes.mp4also has anelst(mediaTime=1280, 2 frames) but carries acttsthat shifts the presentation times by the same amount, so nothing is trimmed. (hvc1.mp4is the deliberately undecodable fixture.)Consequence for the oracle: comparing a container file with
ffmpeg -f framemd5is exact only when the file's edit list trims no picture;-ignore_editlist 1is the flag that compares decoding alone. The real-file hashes intestdata/*real-files.txtare stream-copy clips whose counts matched, so they are unaffected.tools/jvt: state the cause of the 10 of 12 picture count in the bench…
tannevaled commentedon Nov 10, 2026
AAC-LC speed against ffmpeg: not measured. The 1-minute load was 19 to 61 each time I tried on 2026-11-10 (the limit is 8), so no number is given.
BenchmarkAACDecode(aac_bench_test.go, PR #31) decodes the pinned conformance stream al05_48 (stereo, 48 kHz, about 7.4 s) single core; run it withAAC_CONFORMANCE_DIRset and-cpu 1, interleaved withffmpeg -threads 1 -benchmark -i al05_48.mp4 -f null -(and-cpuflags 0for the C paths) once the load is low. An indication under load, not a result: 9.3 ms per op for the benchmark, which is about 800 times real time.