ffmpeg-bb/tests/ref/fate/sub-mcc-remux-eia608-recode
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 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 T49S494F43ZZ72F4QROO74ZZBFAB
00:00:59:00 T49S494F43Z0172F4QROO74Z01BDAB
00:00:59:01 T49S494F43Z0272F4QROO74Z02BBAB
00:00:59:02 T49S494F43Z0372F4QROO74Z03B9AB
00:00:59:03 T49S494F43Z0472F4QROO74Z04B7AB
00:00:59:04 T49S494F43Z0572F4QROO74Z05B5AB
00:00:59:05 T49S494F43Z0672F4QROO74Z06B3AB
00:00:59:06 T49S494F43Z0772F4QROO74Z07B1AB
00:00:59:07 T49S494F43Z0872F4QROO74Z08AFAB
00:00:59:08 T49S494F43Z0972F4QROO74Z09ADAB
00:00:59:09 T49S494F43Z0A72F4QROO74Z0AABAB
00:00:59:10 T49S494F43Z0B72F4QROO74Z0BA9AB
00:00:59:11 T49S494F43Z0C72F4QROO74Z0CA7AB
00:00:59:12 T49S494F43Z0D72F4QROO74Z0DA5AB
00:00:59:13 T49S494F43Z0E72F4QROO74Z0EA3AB
00:00:59:14 T49S494F43Z0F72F4QROO74Z0FA1AB
00:00:59:15 T49S494F43Z1072F4QROO74Z109FAB
00:00:59:16 T49S494F43Z1172F4QROO74Z119DAB
00:00:59:17 T49S494F43Z1272F4QROO74Z129BAB
00:00:59:18 T49S494F43Z1372F4QROO74Z1399AB
00:00:59:19 T49S494F43Z1472F4QROO74Z1497AB
00:00:59:20 T49S494F43Z1572F4QROO74Z1595AB
00:00:59:21 T49S494F43Z1672F4QROO74Z1693AB
00:00:59:22 T49S494F43Z1772F4QROO74Z1791AB
00:00:59:23 T49S494F43Z1872F4QROO74Z188FAB
00:00:59:24 T49S494F43Z1972F4QROO74Z198DAB
00:00:59:25 T49S494F43Z1A72F4QROO74Z1A8BAB
00:00:59:26 T49S494F43Z1B72F4QROO74Z1B89AB
00:00:59:27 T49S494F43Z1C72F4QROO74Z1C87AB
00:00:59:28 T49S494F43Z1D72F4QROO74Z1D85AB
00:00:59:29 T49S494F43Z1E72F4QROO74Z1E83AB
00:01:00:02 T49S494F43Z1F72F4QROO74Z1F81AB