V210 issue fix + correct packing

This commit is contained in:
Dmitry Sergeev
2026-09-18 01:30:11 +03:00
parent efa958723a
commit 4d8035a434
24 changed files with 218 additions and 84 deletions
+6 -5
View File
@@ -189,15 +189,16 @@ func (o *TextOverlay) pack() {
// ApplyV210 stamps the pre-packed text tile over a packed v210 frame.
// The tile occupies whole 16-byte blocks, so this is a row-wise copy.
func (o *TextOverlay) ApplyV210(dest []byte) error {
lastPixel := (o.y+o.h-1)*o.frameW + o.x + o.w - 1
if need := (lastPixel/6 + 1) * 16; len(dest) < need {
frameStride := V210LineSize(o.frameW)
tileStride := (o.w / 6) * 16
need := (o.y+o.h-1)*frameStride + o.x/6*16 + tileStride
if len(dest) < need {
return fmt.Errorf("text: dest %d bytes too small, need %d", len(dest), need)
}
tileStride := (o.w / 6) * 16
for row := 0; row < o.h; row++ {
frameBlock := ((o.y+row)*o.frameW + o.x) / 6
frameOffset := (o.y+row)*frameStride + o.x/6*16
src := o.blocks[row*tileStride : (row+1)*tileStride]
copy(dest[frameBlock*16:frameBlock*16+tileStride], src)
copy(dest[frameOffset:frameOffset+tileStride], src)
}
return nil
}