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
+2 -2
View File
@@ -132,8 +132,8 @@ func (v Video) Validate() error {
if v.ColorSpace != ColorSpaceBT709 {
return fmt.Errorf("colorspace must be %q, got %q", ColorSpaceBT709, v.ColorSpace)
}
if v.FrameWidth == 0 || v.FrameWidth%6 != 0 {
return fmt.Errorf("frame_width must be greater than zero and divisible by 6, got %d", v.FrameWidth)
if v.FrameWidth == 0 || v.FrameWidth%2 != 0 {
return fmt.Errorf("frame_width must be greater than zero and even for 4:2:2 video, got %d", v.FrameWidth)
}
if v.FrameHeight == 0 {
return fmt.Errorf("frame_height must be greater than zero")
+3 -3
View File
@@ -28,10 +28,10 @@ func TestNewV210Video(t *testing.T) {
}
}
func TestNewV210VideoRejectsInvalidWidth(t *testing.T) {
func TestNewV210VideoRejectsOddWidth(t *testing.T) {
_, err := NewV210Video(testVideoID, 1919, 1080, Rational{Numerator: 25, Denominator: 1})
if err == nil || !strings.Contains(err.Error(), "divisible by 6") {
t.Fatalf("error = %v, want width divisibility error", err)
if err == nil || !strings.Contains(err.Error(), "even") {
t.Fatalf("error = %v, want even-width error", err)
}
}