ffmpeg-bb/tests/ref/fate/sub-mcc-remux-eia608-bsf
Martin Storsjö 26da3d0069 fate: Fix the sub-mcc tests on Windows in eastern time zones
Previously, these tests failed when running on Windows, if the
system is configured with a time zone east of Greenwich, i.e.
with a positive GMT offset.

The muxer converts the creation_date given by the user using
av_parse_time to unix time, as a time_t. The creation_date is
interpreted as a local time, i.e. according to the current time
zone. (This time_t value is then converted back to a broken out
local time form with localtime_r.)

The given reference date/time, "1970-01-01T00:00:00", is the
origin point for unix time, corresponding to time_t zero. However
when interpreted as local time, this doesn't map to exactly zero.
Time zones east of Greenwich reached this time a number of hours
before the point of zero time_t - so the corresponding time_t
value essentially is minus the GMT offset, in seconds.

Windows mktime returns an error, returning (time_t)-1, when given
such a "struct tm", while e.g. glibc mktime happily returns a
negative time_t. av_parse_time doesn't check the return value of
mktime for potential errors.

This is observable with the following test snippet:

    struct tm tm = { 0 };
    tm.tm_year = 70;
    tm.tm_isdst = -1;
    tm.tm_mday = 1;
    tm.tm_hour = 0;
    time_t t = mktime(&tm);
    printf("%d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
    printf("t %d\n", (int)t);

By varying the value of tm_hour and the system time zone, one
can observe that Windows mktime returns -1 for all time_t values
that would have been negative.

This range limit is also documented by Microsoft in detail at
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mktime-mktime32-mktime64.

To avoid the issue, pick a different, arbitrary reference time,
which should have a nonnegative time_t for all time zones.

(cherry picked from commit 13139d6d83e8bdcf8a2c81af14ed2c3e30b5e1c1)
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-08-12 13:45:57 +03:00

77 lines
3.1 KiB
Plaintext

File Format=MacCaption_MCC V2.0
///////////////////////////////////////////////////////////////////////////////////
// Computer Prompting and Captioning Company
// Ancillary Data Packet Transfer File
//
// Permission to generate this format is granted provided that
// 1. This ANC Transfer file format is used on an as-is basis and no warranty is given, and
// 2. This entire descriptive information text is included in a generated .mcc file.
//
// General file format:
// HH:MM:SS:FF(tab)[Hexadecimal ANC data in groups of 2 characters]
// Hexadecimal data starts with the Ancillary Data Packet DID (Data ID defined in S291M)
// and concludes with the Check Sum following the User Data Words.
// Each time code line must contain at most one complete ancillary data packet.
// To transfer additional ANC Data successive lines may contain identical time code.
// Time Code Rate=[24, 25, 30, 30DF, 50, 60, 60DF]
//
// ANC data bytes may be represented by one ASCII character according to the following schema:
// G FAh 00h 00h
// H 2 x (FAh 00h 00h)
// I 3 x (FAh 00h 00h)
// J 4 x (FAh 00h 00h)
// K 5 x (FAh 00h 00h)
// L 6 x (FAh 00h 00h)
// M 7 x (FAh 00h 00h)
// N 8 x (FAh 00h 00h)
// O 9 x (FAh 00h 00h)
// P FBh 80h 80h
// Q FCh 80h 80h
// R FDh 80h 80h
// S 96h 69h
// T 61h 01h
// U E1h 00h 00h 00h
// Z 00h
//
///////////////////////////////////////////////////////////////////////////////////
UUID=0087C4F6-A6B4-5469-8C8E-BBF44950401D
Creation Program=FFmpeg
Creation Date=Friday, January 2, 1970
Creation Time=00:00:00
Time Code Rate=30DF
00:00:58:29.0,11 T49S497F43FFFF72F4QROO74FFFF93AB
00:00:59:00.0,11 T49S497F43ZZ72F4QROO74ZZ8FAB
00:00:59:01.0,11 T49S497F43Z0172F4QROO74Z018DAB
00:00:59:02.0,11 T49S497F43Z0272F4QROO74Z028BAB
00:00:59:03.0,11 T49S497F43Z0372F4QROO74Z0389AB
00:00:59:04.0,11 T49S497F43Z0472F4QROO74Z0487AB
00:00:59:05.0,11 T49S497F43Z0572F4QROO74Z0585AB
00:00:59:06.0,11 T49S497F43Z0672F4QROO74Z0683AB
00:00:59:07.0,11 T49S497F43Z0772F4QROO74Z0781AB
00:00:59:08.0,11 T49S497F43Z0872F4QROO74Z087FAB
00:00:59:09.0,11 T49S497F43Z0972F4QROO74Z097DAB
00:00:59:10.0,11 T49S497F43Z0A72F4QROO74Z0A7BAB
00:00:59:11.0,11 T49S497F43Z0B72F4QROO74Z0B79AB
00:00:59:12.0,11 T49S497F43Z0C72F4QROO74Z0C77AB
00:00:59:13.0,11 T49S497F43Z0D72F4QROO74Z0D75AB
00:00:59:14.0,11 T49S497F43Z0E72F4QROO74Z0E73AB
00:00:59:15.0,11 T49S497F43Z0F72F4QROO74Z0F71AB
00:00:59:16.0,11 T49S497F43Z1072F4QROO74Z106FAB
00:00:59:17.0,11 T49S497F43Z1172F4QROO74Z116DAB
00:00:59:18.0,11 T49S497F43Z1272F4QROO74Z126BAB
00:00:59:19.0,11 T49S497F43Z1372F4QROO74Z1369AB
00:00:59:20.0,11 T49S497F43Z1472F4QROO74Z1467AB
00:00:59:21.0,11 T49S497F43Z1572F4QROO74Z1565AB
00:00:59:22.0,11 T49S497F43Z1672F4QROO74Z1663AB
00:00:59:23.0,11 T49S497F43Z1772F4QROO74Z1761AB
00:00:59:24.0,11 T49S497F43Z1872F4QROO74Z185FAB
00:00:59:25.0,11 T49S497F43Z1972F4QROO74Z195DAB
00:00:59:26.0,11 T49S497F43Z1A72F4QROO74Z1A5BAB
00:00:59:27.0,11 T49S497F43Z1B72F4QROO74Z1B59AB
00:00:59:28.0,11 T49S497F43Z1C72F4QROO74Z1C57AB
00:00:59:29.0,11 T49S497F43Z1D72F4QROO74Z1D55AB
00:01:00:02.0,11 T49S497F43Z1E72F4QROO74Z1E53AB