[FIX] SCC character pair writing (#1210)

* scc: Fix character pair writing

The space was being inserted in the wrong position, so the first
character of each caption was being cut off. The last character was also
cut off in captions with even lengths.

Reported-By: Nils ANDRÉ-CHANG <nils@nilsand.re>

* scc: Apply pair writing to control codes

The same mandatory pair logic applies here.
This commit is contained in:
kdrag0n 2020-01-22 23:23:00 -08:00 committed by Carlos Fernandez Sanz
parent 424e67f5f4
commit a919ef4410

View File

@ -1139,7 +1139,7 @@ void write_character(const int fd, const unsigned char character, const bool dis
}
else
{
if (*bytes_written % 2 == 1)
if (*bytes_written % 2 == 0)
write(fd, " ", 1);
fdprintf(fd, "%02x", odd_parity(character));
@ -1165,7 +1165,7 @@ void write_control_code(const int fd, const unsigned char channel, const enum co
}
else
{
if (*bytes_written)
if (*bytes_written % 2 == 0)
write(fd, " ", 1);
fdprintf(fd, "%02x%02x", odd_parity(get_first_byte(channel, code)), odd_parity(get_second_byte(code)));