|
1 | 1 | @testset "Interlaced video codec properties" begin |
2 | 2 | # Test with an interlaced H.264 video |
3 | 3 | interlaced_path = joinpath(testdir, "references", "interlaced_h264.mp4") |
4 | | - |
| 4 | + |
5 | 5 | if !isfile(interlaced_path) |
6 | 6 | @test_skip "Interlaced test video not found at $interlaced_path" |
7 | 7 | return |
8 | 8 | end |
9 | | - |
| 9 | + |
10 | 10 | VideoIO.openvideo(interlaced_path) do reader |
11 | 11 | # Verify codec_descriptor is not null |
12 | 12 | @test reader.codec_context.codec_descriptor != C_NULL |
13 | | - |
| 13 | + |
14 | 14 | # Check if it's a field-based codec (should be for interlaced H.264) |
15 | 15 | is_field_based = (reader.codec_context.codec_descriptor.props & VideoIO.AV_CODEC_PROP_FIELDS) != 0 |
16 | 16 | @test is_field_based |
17 | | - |
| 17 | + |
18 | 18 | # For interlaced video, framerate calculation should account for fields |
19 | 19 | # The video was created at 30fps but with interlacing, so the field rate is 60 |
20 | 20 | fps = VideoIO.framerate(reader) |
21 | 21 | @test fps > 0 |
22 | 22 | @test isfinite(fps) |
23 | | - |
| 23 | + |
24 | 24 | # The framerate should be 60 (field rate) for interlaced content |
25 | 25 | @test fps == 60 // 1 |
26 | | - |
| 26 | + |
27 | 27 | # Verify we can read frames without error |
28 | 28 | frame = read(reader) |
29 | 29 | @test !isnothing(frame) |
|
34 | 34 | @testset "Codec descriptor null safety" begin |
35 | 35 | # Test that the null check works properly for various codecs |
36 | 36 | testvid_path = joinpath(VideoIO.TestVideos.videodir, "ladybird.mp4") |
37 | | - |
| 37 | + |
38 | 38 | VideoIO.openvideo(testvid_path) do reader |
39 | 39 | # Verify codec_descriptor is not null |
40 | 40 | @test reader.codec_context.codec_descriptor != C_NULL |
41 | | - |
| 41 | + |
42 | 42 | # The AV_CODEC_PROP_FIELDS flag indicates the codec SUPPORTS fields, |
43 | 43 | # not that this specific video is interlaced. H.264 always has this flag. |
44 | 44 | # What matters is that our code handles both cases without crashing. |
45 | | - |
| 45 | + |
46 | 46 | # Get framerate - should work regardless of field flag |
47 | 47 | fps = VideoIO.framerate(reader) |
48 | 48 | @test fps > 0 |
49 | 49 | @test isfinite(fps) |
50 | | - |
| 50 | + |
51 | 51 | # For ladybird.mp4, we expect a reasonable framerate |
52 | 52 | @test 20 <= fps <= 60 |
53 | 53 | end |
|
0 commit comments