Skip to content

Commit 7fa1489

Browse files
committed
Add AMD64 implementations (SSE2/AVX2) of copyMacroblock
1 parent 2e8c211 commit 7fa1489

File tree

2 files changed

+1116
-0
lines changed

2 files changed

+1116
-0
lines changed

video_amd64.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//go:build amd64 && !noasm
2+
3+
package mpeg
4+
5+
var isAVX2 bool
6+
7+
func init() {
8+
isAVX2 = hasAVX2()
9+
}
10+
11+
func hasAVX2() bool
12+
13+
//go:noescape
14+
func copyMacroblockSSE2(motionH, motionV, mbRow, mbCol, lumaWidth, chromaWidth int, s, d *Frame)
15+
16+
//go:noescape
17+
func copyMacroblockAVX2(motionH, motionV, mbRow, mbCol, lumaWidth, chromaWidth int, s, d *Frame)
18+
19+
func copyMacroblock(motionH, motionV, mbRow, mbCol, lumaWidth, chromaWidth int, s, d *Frame) {
20+
if isAVX2 {
21+
copyMacroblockAVX2(motionH, motionV, mbRow, mbCol, lumaWidth, chromaWidth, s, d)
22+
} else {
23+
copyMacroblockSSE2(motionH, motionV, mbRow, mbCol, lumaWidth, chromaWidth, s, d)
24+
}
25+
}

0 commit comments

Comments
 (0)