Commit Graph

1696 Commits

Author SHA1 Message Date
Nils
e98137e059
[FIX] Fix tags displaying incorrectly (#1229)
This was caused by 19241744d7, moving from
`unsigned char` to `enums` for colors and fonts. The problem with this is
that each colour isn't one byte next to each other so memcpy and memset
didn't work anymore.

The problem:

```patch
6812,6813c6812,6813
< EDITION OF AMERICA'S NEXT TOP
< <i> MODEL</i> ON WEDNESDAYS.<i>          </i>
---
> EDITION OF<i> AMERICA'S NEXT TOP</i>
> <i> MODEL</i> ON WEDNESDAYS.
6817c6817
< EDITION OF AMERICA'S NEXT TOP
---
> EDITION OF<i> AMERICA'S NEXT TOP</i>
6819c6819
< >><i> THE VAMPIRE DIARIES         </i>
---
> >><i> THE VAMPIRE DIARIES</i>
6824,6825c6824,6825
< >><i> THE VA</i>MPIRE DIARIES
< AND<i> THE SECRET CIRCLE          </i>
---
> >><i> THE VAMPIRE DIARIES</i>
> AND<i> THE SECRET CIRCLE</i>
6829,6831c6829,6831
< >><i> THE VA</i>MPIRE DIARIES
< AND<i> THE S</i>ECRET CIRCLE
< ON THURSDAYS.<i>                  </i>
---
> >><i> THE VAMPIRE DIARIES</i>
> AND<i> THE SECRET CIRCLE</i>
> ON THURSDAYS.
6835c6835
< AND<i> THE S</i>ECRET CIRCLE
---
> AND<i> THE SECRET CIRCLE</i>
```
2020-02-12 15:01:15 -08:00
Ed Marshall
6697ed3496
[FIX] Fix multiple definitions with new -fno-common default in GCC 10 (#1226)
* Fix multiple definitions with new -fno-common default in GCC 10

* Add GCC 10 fix to changelog
2020-02-01 22:26:48 -08:00
Nils ANDRÉ-CHANG
722d52420c
[IMPROVEMENT] Clang format (#1222)
* Add .clang-format

* Add clang-format github action

* Set more explicit name to GitHub workflow

Co-Authored-By: Willem <github@canihavesome.coffee>

Co-authored-by: Willem <github@canihavesome.coffee>
2020-01-30 09:00:00 -08:00
Nils ANDRÉ-CHANG
af6d8282cb
[IMPROVEMENT] Move dependencies to a third party directory (#1219)
* Move dependencies in a folder

* Windows

* MacOS
2020-01-30 04:58:37 -08:00
kdrag0n
732b20aefa
[FIX] Clang warning fixes (#1205)
* file_buffer: Fix unitialized variable usage warning

Clang warns:

In file included from src/lib_ccx/asf_functions.c:5:
src/lib_ccx/file_buffer.h:76:7: warning: variable 'result' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                if (buffer)
                    ^~~~~~
src/lib_ccx/file_buffer.h:86:9: note: uninitialized use occurs here
        return result;
               ^~~~~~
src/lib_ccx/file_buffer.h:76:3: note: remove the 'if' if its condition is always true
                if (buffer)
                ^~~~~~~~~~~
src/lib_ccx/file_buffer.h:73:15: note: initialize the variable 'result' to silence this warning
        size_t result;
                     ^
                      = 0

* common_timing: Fix uninitialized variable usage warning

The vast majority of the code is already using fatal(), so I don't see
why this should be an exception.

Clang warns:

src/lib_ccx/ccx_common_timing.c:274:3: warning: variable 'fts' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
                default:
                ^~~~~~~
src/lib_ccx/ccx_common_timing.c:280:9: note: uninitialized use occurs here
        return fts;
               ^~~
src/lib_ccx/ccx_common_timing.c:261:11: note: initialize the variable 'fts' to silence this warning
        LLONG fts;
                 ^
                  = 0

* encoders: Fix handling of multibyte characters in UTF-8 converter

This is actually incorrect because characters longer than 1 byte will be
butchered.

Clang warns:

src/lib_ccx/ccx_encoders_common.c:178:12: warning: result of comparison of constant 256 with expression of
type 'unsigned char' is always true [-Wtautological-constant-out-of-range-compare]
                                        if (c < 256)
                                            ~ ^ ~~~
src/lib_ccx/ccx_encoders_common.c:193:12: warning: result of comparison of constant 256 with expression of
type 'unsigned char' is always true [-Wtautological-constant-out-of-range-compare]
                                        if (c < 256)
                                            ~ ^ ~~~
src/lib_ccx/ccx_encoders_common.c:209:12: warning: result of comparison of constant 256 with expression of
type 'unsigned char' is always true [-Wtautological-constant-out-of-range-compare]
                                        if (c < 256)
                                            ~ ^ ~~~
src/lib_ccx/ccx_encoders_common.c:229:12: warning: result of comparison of constant 256 with expression of type 'unsigned char' is always true [-Wtautological-constant-out-of-range-compare]
                                        if (c < 256)
                                            ~ ^ ~~~

* gxf: Fix tautological comparison warnings

Clang warns:

src/lib_ccx/ccx_gxf.c:425:17: warning: result of comparison of constant 256 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare]
                                if (tag_len > STR_LEN)
                                    ~~~~~~~ ^ ~~~~~~~
src/lib_ccx/ccx_gxf.c:542:17: warning: result of comparison of constant 256 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare]
                                if (tag_len > STR_LEN)
                                    ~~~~~~~ ^ ~~~~~~~
src/lib_ccx/ccx_gxf.c:617:17: warning: result of comparison of constant 256 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare]
                                if (tag_len > STR_LEN)
                                    ~~~~~~~ ^ ~~~~~~~

* gxf: Fix uninitialized variable usage warnings

Clang warns:

src/lib_ccx/ccx_gxf.c:1449:8: warning: variable 'first_field_nb' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
                case TRACK_TYPE_MPEG1_525:
                     ^~~~~~~~~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1475:35: note: uninitialized use occurs here
        debug("first field number %d\n", first_field_nb);
                                         ^~~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:28:115: note: expanded from macro 'debug'
                                                                                                                  ^~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1450:8: warning: variable 'first_field_nb' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
                case TRACK_TYPE_MPEG2_525:
                     ^~~~~~~~~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1475:35: note: uninitialized use occurs here
        debug("first field number %d\n", first_field_nb);
                                         ^~~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:28:115: note: expanded from macro 'debug'
                                                                                                                  ^~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1456:3: warning: variable 'first_field_nb' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
                default:
                ^~~~~~~
src/lib_ccx/ccx_gxf.c:1475:35: note: uninitialized use occurs here
        debug("first field number %d\n", first_field_nb);
                                         ^~~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:28:115: note: expanded from macro 'debug'
                                                                                                                  ^~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1410:30: note: initialize the variable 'first_field_nb' to silence this warning
        unsigned char first_field_nb;
                                    ^
                                     = '\0'
src/lib_ccx/ccx_gxf.c:1449:8: warning: variable 'last_field_nb' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
                case TRACK_TYPE_MPEG1_525:
                     ^~~~~~~~~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1476:34: note: uninitialized use occurs here
        debug("last field number %d\n", last_field_nb);
                                        ^~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:28:115: note: expanded from macro 'debug'
                                                                                                                  ^~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1450:8: warning: variable 'last_field_nb' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
                case TRACK_TYPE_MPEG2_525:
                     ^~~~~~~~~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1476:34: note: uninitialized use occurs here
        debug("last field number %d\n", last_field_nb);
                                        ^~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:28:115: note: expanded from macro 'debug'
                                                                                                                  ^~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1456:3: warning: variable 'last_field_nb' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
                default:
                ^~~~~~~
src/lib_ccx/ccx_gxf.c:1476:34: note: uninitialized use occurs here
        debug("last field number %d\n", last_field_nb);
                                        ^~~~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:28:115: note: expanded from macro 'debug'
                                                                                                                  ^~~~~~~~~~~
src/lib_ccx/ccx_gxf.c:1411:29: note: initialize the variable 'last_field_nb' to silence this warning
        unsigned char last_field_nb;
                                   ^
                                    = '\0'

* ts_functions: Fix incorrect enumeration type in get_buffer_type

Clang warns:

src/lib_ccx/ts_functions.c:127:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_PES;
                ~~~~~~ ^~~~~~~
src/lib_ccx/ts_functions.c:131:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_H264;
                ~~~~~~ ^~~~~~~~
src/lib_ccx/ts_functions.c:135:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_DVB_SUBTITLE;
                ~~~~~~ ^~~~~~~~~~~~~~~~
src/lib_ccx/ts_functions.c:139:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_ISDB_SUBTITLE;
                ~~~~~~ ^~~~~~~~~~~~~~~~~
src/lib_ccx/ts_functions.c:143:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_HAUPPAGE;
                ~~~~~~ ^~~~~~~~~~~~
src/lib_ccx/ts_functions.c:147:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_TELETEXT;
                ~~~~~~ ^~~~~~~~~~~~
src/lib_ccx/ts_functions.c:151:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_PRIVATE_MPEG2_CC;
                ~~~~~~ ^~~~~~~~~~~~~~~~~~~~
src/lib_ccx/ts_functions.c:155:10: warning: implicit conversion from enumeration type 'enum ccx_bufferdata_type' to different enumeration type 'enum ccx_stream_type' [-Wenum-conversion]
                return CCX_PES;
                ~~~~~~ ^~~~~~~
src/lib_ccx/ts_functions.c:491:24: warning: implicit conversion from enumeration type 'enum ccx_stream_type' to different enumeration type 'enum ccx_bufferdata_type' [-Wenum-conversion]
        ptr->bufferdatatype = get_buffer_type(cinfo);
                            ~ ^~~~~~~~~~~~~~~~~~~~~~

* utility: Fix tautological comparison warnings

Clang warns:

src/lib_ccx/utility.c:605:24: warning: result of comparison of constant 65536 with expression of type 'unsigned short' is always true [-Wtautological-constant-out-of-range-compare]
        } else if (utf16_char < 0x010000) {
                   ~~~~~~~~~~ ^ ~~~~~~~~
src/lib_ccx/utility.c:610:24: warning: result of comparison of constant 1114112 with expression of type 'unsigned short' is always true [-Wtautological-constant-out-of-range-compare]
        } else if (utf16_char < 0x110000) {
                   ~~~~~~~~~~ ^ ~~~~~~~~

* ocr: Fix floating point -> integer abs() warning

Clang warns:

src/lib_ccx/ocr.c:529:8: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                                if(abs(h-h0)>50) // Color has changed
                                   ^
src/lib_ccx/ocr.c:529:8: note: use function 'fabsf' instead
                                if(abs(h-h0)>50) // Color has changed
                                   ^~~
                                   fabsf
src/lib_ccx/ocr.c:529:8: note: include the header <math.h> or explicitly provide a declaration for 'fabsf'

* encoders: Fix incorrect string types when EIA-608 is in use

Clang warns:

src/lib_ccx/ccx_encoders_helpers.c: In function ‘clever_capitalize’:
src/lib_ccx/ccx_encoders_helpers.c:186:4: warning: case label value exceeds maximum value for type
  186 |    case 0x89: // This is a transparent space
      |    ^~~~

* ocr: Fix implicit struct declaration warning

Clang warns:

In file included from src/lib_ccx/dvd_subtitle_decoder.c:10:
src/lib_ccx/ocr.h:18:54: warning: ‘struct encoder_ctx’ declared inside parameter list will not be visible outside of this definition or declaration
   18 | char *paraof_ocrtext(struct cc_subtitle *sub, struct encoder_ctx *context);
      |                                                      ^~~~~~~~~~~
2020-01-29 21:39:40 -08:00
Nils ANDRÉ-CHANG
54318d0402
Allow the user the choose between CRLF and LF (#1220)
Defaults to CRLF
2020-01-28 21:18:10 -08:00
kdrag0n
5f61fae0c7 scc: Switch to CRLF line endings (#1209)
All the SCC and CCD examples I can find have CRLF line endings. VLC and
libavformat (used by MPV) don't care, so just go with the popular
convention and switch to CRLF. There's no reason a user would want to
choose their line endings in this scenario.
2020-01-25 19:33:22 -08:00
kdrag0n
0afba56a26 scc: Implement colors (#1213) 2020-01-25 16:16:00 -08:00
Carlos Fernandez Sanz
75af5f2e8c Applied clang formatting to our .c files. Tried to leave everyone else's alone. 2020-01-25 13:29:18 -08:00
Nils ANDRÉ-CHANG
8d8dc9ccc2 Improve and simplify dprintf implementation (#1185)
It now returns a value like the rest of the printf family. It doesn't
brute force the amount of memory that needs to be allocated.

It also removes a warning.

I do not believe there should be any performance concerns with this
implementation as it is what `glibc` does:

https://code.woboq.org/userspace/glibc/libio/iovdprintf.c.html
2020-01-24 23:58:44 -08:00
Nils ANDRÉ-CHANG
e37a21aace Fix longer subtitles (#1216) 2020-01-23 19:05:19 -08:00
Nils ANDRÉ-CHANG
40a603d366 Fix documentation (#1218) 2020-01-23 18:49:58 -08:00
kdrag0n
c5bed1e3b2 [FIX] GCC warning fixes (#1204)
* cea708: Fix missing new line in log message

* subtype: Remove unused CC_708 type

CEA-708 inputs are coerced to CC_608 before hitting encode_sub.

GCC warns:

src/lib_ccx/ccx_encoders_common.c: In function ‘encode_sub’:
src/lib_ccx/ccx_encoders_common.c:1119:2: warning: enumeration value ‘CC_708’ not handled in switch [-Wswitch]
 1119 |  switch (sub->type)
      |  ^~~~~~

* build: Disable pointer-sign warning

This warning triggers all over the codebase due to the widespread use of
unsigned char arrays for parsed subtitle strings and them being passed
to string functions that expect signed ones. Since this won't actually
cause issues, silence the warning across the entire codebase.

* splitbysentence: Fix warnings

GCC warns:

src/lib_ccx/ccx_encoders_splitbysentence.c: In function ‘sbs_is_pointer_on_sentence_breaker’:
src/lib_ccx/ccx_encoders_splitbysentence.c:170:7: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
  170 |  char p = *(current - 1);
      |       ^
src/lib_ccx/ccx_encoders_splitbysentence.c: In function ‘sbs_find_insert_point_partial’:
src/lib_ccx/ccx_encoders_splitbysentence.c:231:1: warning: multi-line comment [-Wcomment]
  231 | //   sprintf(fmtbuf, "SBS: sbs_find_insert_point_partial: compare\n\
      | ^
src/lib_ccx/ccx_encoders_splitbysentence.c:263:1: warning: multi-line comment [-Wcomment]
  263 | //   LOG_DEBUG("SBS: sbs_find_insert_point_partial: LEFT CHANGED,\n\tbuf:[%s]\n\tstr:[%s]\n\
      | ^
src/lib_ccx/ccx_encoders_splitbysentence.c:297:1: warning: multi-line comment [-Wcomment]
  297 | //   sprintf(fmtbuf, "SBS: sbs_find_insert_point_partial: REPLACE ENTIRE TAIL !!\n\
      | ^
src/lib_ccx/ccx_encoders_splitbysentence.c:222:6: warning: unused variable ‘i’ [-Wunused-variable]
  222 |  int i; // top level indexer for strings
      |      ^
src/lib_ccx/ccx_encoders_splitbysentence.c: In function ‘reformat_cc_bitmap_through_sentence_buffer’:
src/lib_ccx/ccx_encoders_splitbysentence.c:730:8: warning: unused variable ‘str’ [-Wunused-variable]
  730 |  char *str;
      |        ^~~
src/lib_ccx/ccx_encoders_splitbysentence.c:729:6: warning: unused variable ‘i’ [-Wunused-variable]
  729 |  int i = 0;
      |      ^
src/lib_ccx/ccx_encoders_splitbysentence.c:728:6: warning: unused variable ‘used’ [-Wunused-variable]
  728 |  int used;
      |      ^~~~
src/lib_ccx/ccx_encoders_splitbysentence.c:727:18: warning: unused variable ‘ms_end’ [-Wunused-variable]
  727 |  LLONG ms_start, ms_end;
      |                  ^~~~~~
src/lib_ccx/ccx_encoders_splitbysentence.c:727:8: warning: unused variable ‘ms_start’ [-Wunused-variable]
  727 |  LLONG ms_start, ms_end;
      |        ^~~~~~~~
src/lib_ccx/ccx_encoders_splitbysentence.c:726:20: warning: unused variable ‘rect’ [-Wunused-variable]
  726 |  struct cc_bitmap* rect;
      |                    ^~~~

* spupng: Fix warnings

GCC warns:

src/lib_ccx/ccx_encoders_spupng.c: In function ‘init_face’:
src/lib_ccx/ccx_encoders_spupng.c:644:6: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  644 |  if (error = FT_New_Face(ft_library, font, 0, face))
      |      ^~~~~
src/lib_ccx/ccx_encoders_spupng.c:651:6: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  651 |  if (error = FT_Set_Pixel_Sizes(*face, 0, FONT_SIZE))
      |      ^~~~~
src/lib_ccx/ccx_encoders_spupng.c: In function ‘spupng_export_string2png’:
src/lib_ccx/ccx_encoders_spupng.c:698:7: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  698 |   if (error = FT_Init_FreeType(&ft_library))
      |       ^~~~~
src/lib_ccx/ccx_encoders_spupng.c:706:6: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  706 |  if (error = init_face(&face_regular, ccx_options.enc_cfg.render_font))
      |      ^~~~~
src/lib_ccx/ccx_encoders_spupng.c:708:6: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  708 |  if (error = init_face(&face_italics, ccx_options.enc_cfg.render_font_italics))
      |      ^~~~~
src/lib_ccx/ccx_encoders_spupng.c:850:9: warning: unused variable ‘height’ [-Wunused-variable]
  850 |     int height = slot->bitmap.rows;
      |         ^~~~~~
src/lib_ccx/ccx_encoders_spupng.c:849:9: warning: unused variable ‘width’ [-Wunused-variable]
  849 |     int width = slot->bitmap.width;
      |         ^~~~~
src/lib_ccx/ccx_encoders_webvtt.c: In function ‘write_webvtt_header’:
src/lib_ccx/ccx_encoders_webvtt.c:263:1: warning: control reaches end of non-void function [-Wreturn-type]
  263 | }
      | ^

* webvtt: Fix missing return warning

The return value of this function is never used, so just drop the
values.

GCC warns:

src/lib_ccx/ccx_encoders_webvtt.c: In function ‘write_webvtt_header’:
src/lib_ccx/ccx_encoders_webvtt.c:263:1: warning: control reaches end of non-void function [-Wreturn-type]
  263 | }
      | ^

* gxf: Fix MIN macro redefinition warning

GCC warns:

src/lib_ccx/ccx_gxf.c:23: warning: "MIN" redefined
   23 | #define MIN(a, b) ( (a < b) ? a : b)
      |
In file included from src/lib_ccx/ccx_demuxer.h:8,
                 from src/lib_ccx/ccx_gxf.h:4,
                 from src/lib_ccx/ccx_gxf.c:13:
src/lib_ccx/utility.h:8: note: this is the location of the previous definition
    8 | #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
      |

* dvd: Fix unused variable warnings

GCC warns:

src/lib_ccx/dvd_subtitle_decoder.c: In function ‘get_bitmap’:
src/lib_ccx/dvd_subtitle_decoder.c:133:9: warning: unused variable ‘discard’ [-Wunused-variable]
  133 |     int discard = get_bits(ctx, &nextbyte, &pos, &m);
      |         ^~~~~~~
src/lib_ccx/dvd_subtitle_decoder.c:172:9: warning: unused variable ‘discard’ [-Wunused-variable]
  172 |     int discard = get_bits(ctx, &nextbyte, &pos, &m);
      |         ^~~~~~~
src/lib_ccx/dvd_subtitle_decoder.c: In function ‘write_dvd_sub’:
src/lib_ccx/dvd_subtitle_decoder.c:320:6: warning: unused variable ‘ret’ [-Wunused-variable]
  320 |  int ret =0;
      |      ^~~

* es_functions: Fix unused variable warning

This also removes the stale commented code that used this variable.

GCC warns:

src/lib_ccx/es_functions.c: In function ‘read_pic_info’:
src/lib_ccx/es_functions.c:682:7: warning: unused variable ‘frame_type_to_char’ [-Wunused-variable]
  682 |  char frame_type_to_char[] = { '?', 'I', 'P','B', 'D', '?', '?','?' };
      |       ^~~~~~~~~~~~~~~~~~

* dvb: Fix unused variable warning when OCR is disabled

GCC warns:

src/lib_ccx/dvb_subtitle_decoder.c: In function ‘write_dvb_sub’:
src/lib_ccx/dvb_subtitle_decoder.c:1509:6: warning: unused variable ‘ret’ [-Wunused-variable]
 1509 |  int ret = 0;
      |      ^~~

* general_loop: Fix warnings

GCC warns:

src/lib_ccx/general_loop.c: In function ‘general_loop’:
src/lib_ccx/general_loop.c:1113:15: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
 1113 |      (enc_ctx && (enc_ctx->srt_counter || enc_ctx->cea_708_counter) ||
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At top level:
src/lib_ccx/general_loop.c:25:28: warning: ‘DO_NOTHING’ defined but not used [-Wunused-const-variable=]
   25 | const static unsigned char DO_NOTHING[] = {0x80, 0x80};
      |                            ^~~~~~~~~~

* networking: Fix unknown pragma warning for non-MSVC compilers

GCC warns:

src/lib_ccx/networking.c:22: warning: ignoring #pragma warning  [-Wunknown-pragmas]
   22 | #pragma warning( suppress : 4005)
      |

* networking: Fix unused variable warnings on non-Windows platforms

GCC warns:

src/lib_ccx/networking.c: In function ‘net_udp_read’:
src/lib_ccx/networking.c:342:12: warning: variable ‘addr’ set but not used [-Wunused-but-set-variable]
  342 |  in_addr_t addr;
      |            ^~~~
src/lib_ccx/networking.c:340:12: warning: unused variable ‘len’ [-Wunused-variable]
  340 |  socklen_t len = sizeof(source_addr);
      |            ^~~
src/lib_ccx/networking.c:338:7: warning: unused variable ‘ip’ [-Wunused-variable]
  338 |  char ip[INET_ADDRSTRLEN];
      |       ^~

* params: Fix unused variable warning when OCR is disabled

GCC warns:

src/lib_ccx/params.c: In function ‘version’:
src/lib_ccx/params.c:1015:8: warning: unused variable ‘leptversion’ [-Wunused-variable]
 1015 |  char *leptversion;
      |        ^~~~~~~~~~~

* params_dump: Fix empty encoding when ASCII is used

GCC warns:

src/lib_ccx/params_dump.c: In function ‘params_dump’:
src/lib_ccx/params_dump.c:110:2: warning: enumeration value ‘CCX_ENC_ASCII’ not handled in switch [-Wswitch]
  110 |  switch (ccx_options.enc_cfg.encoding)
      |  ^~~~~~

* params_dump: Fix comparison between mismatching enums

GCC warns:

src/lib_ccx/params_dump.c: In function ‘print_file_report’:
src/lib_ccx/params_dump.c:402:18: warning: comparison between ‘enum ccx_stream_type’ and ‘enum ccx_stream_mode_enum’ [-Wenum-compare]
  402 |    (info->stream == CCX_SM_TRANSPORT ||
      |                  ^~
src/lib_ccx/params_dump.c:403:18: warning: comparison between ‘enum ccx_stream_type’ and ‘enum ccx_stream_mode_enum’ [-Wenum-compare]
  403 |     info->stream == CCX_SM_PROGRAM ||
      |                  ^~
src/lib_ccx/params_dump.c:404:18: warning: comparison between ‘enum ccx_stream_type’ and ‘enum ccx_stream_mode_enum’ [-Wenum-compare]
  404 |     info->stream == CCX_SM_ASF ||
      |                  ^~
src/lib_ccx/params_dump.c:405:18: warning: comparison between ‘enum ccx_stream_type’ and ‘enum ccx_stream_mode_enum’ [-Wenum-compare]
  405 |     info->stream == CCX_SM_WTV))
      |                  ^~

* telxcc: Fix unused variable warning

GCC warns:

src/lib_ccx/telxcc.c: In function ‘process_telx_packet’:
src/lib_ccx/telxcc.c:928:10: warning: unused variable ‘flag_subtitle’ [-Wunused-variable]
  928 |  uint8_t flag_subtitle;
      |          ^~~~~~~~~~~~~

* ts_functions: Fix unused variable warnings

GCC warns:

src/lib_ccx/ts_functions.c: In function ‘get_pts’:
src/lib_ccx/ts_functions.c:642:11: warning: variable ‘pes_packet_length’ set but not used [-Wunused-but-set-variable]
  642 |  uint16_t pes_packet_length;
      |           ^~~~~~~~~~~~~~~~~
src/lib_ccx/ts_functions.c:641:10: warning: variable ‘pes_stream_id’ set but not used [-Wunused-but-set-variable]
  641 |  uint8_t pes_stream_id;
      |          ^~~~~~~~~~~~~

* ts_tables_epg: Fix warnings

GCC warns:

src/lib_ccx/ts_tables_epg.c: In function ‘EPG_add_event’:
src/lib_ccx/ts_tables_epg.c:380:6: warning: unused variable ‘isnew’ [-Wunused-variable]
  380 |  int isnew=true, j;
      |      ^~~~~
src/lib_ccx/ts_tables_epg.c: In function ‘EPG_DVB_decode_string’:
src/lib_ccx/ts_tables_epg.c:469:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
  469 |  int ret=-1;
      |      ^~~
src/lib_ccx/ts_tables_epg.c: In function ‘EPG_ATSC_decode_EIT’:
src/lib_ccx/ts_tables_epg.c:802:25: warning: variable ‘emt_location’ set but not used [-Wunused-but-set-variable]
  802 |   uint8_t title_length, emt_location;
      |                         ^~~~~~~~~~~~
src/lib_ccx/ts_tables_epg.c:764:10: warning: variable ‘table_id’ set but not used [-Wunused-but-set-variable]
  764 |  uint8_t table_id;
      |          ^~~~~~~~
src/lib_ccx/ts_tables_epg.c: In function ‘EPG_ATSC_decode_VCT’:
src/lib_ccx/ts_tables_epg.c:837:10: warning: variable ‘table_id’ set but not used [-Wunused-but-set-variable]
  837 |  uint8_t table_id;
      |          ^~~~~~~~
src/lib_ccx/ts_tables_epg.c: In function ‘EPG_DVB_decode_EIT’:
src/lib_ccx/ts_tables_epg.c:883:10: warning: variable ‘segment_last_section_number’ set but not used [-Wunused-but-set-variable]
  883 |  uint8_t segment_last_section_number;
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib_ccx/ts_tables_epg.c:882:10: warning: variable ‘last_section_number’ set but not used [-Wunused-but-set-variable]
  882 |  uint8_t last_section_number;
      |          ^~~~~~~~~~~~~~~~~~~
src/lib_ccx/ts_tables_epg.c: In function ‘parse_EPG_packet’:
src/lib_ccx/ts_tables_epg.c:1041:11: warning: unused variable ‘transport_error_indicator’ [-Wunused-variable]
 1041 |  unsigned transport_error_indicator = (tspacket[1]&0x80)>>7;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~

* matroska: Fix unused variable warning

The call is left alone since it might create a decoder context.
GCC warns:

src/lib_ccx/matroska.c: In function ‘matroska_save_all’:
src/lib_ccx/matroska.c:1182:27: warning: unused variable ‘dec_ctx’ [-Wunused-variable]
 1182 |     struct lib_cc_decode *dec_ctx = update_decoder_list(mkv_ctx->ctx);
      |                           ^~~~~~~

* utility: Only define MIN when necessary

GCC warns:

In file included from src/lib_ccx/ccx_demuxer.h:8,
                 from src/lib_ccx/lib_ccx.h:15,
                 from src/gpacmp4/mp4.c:6:
src/lib_ccx/utility.h:8: warning: "MIN" redefined
    8 | #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
      |
In file included from src/gpacmp4/gpac/tools.h:33,
                 from src/gpacmp4/gpac/isomedia.h:50,
                 from src/gpacmp4/mp4.c:5:
src/gpacmp4/gpac/setup.h:324: note: this is the location of the previous definition
  324 | #define MIN(X, Y) ((X)<(Y)?(X):(Y))
      |
2020-01-23 18:49:16 -08:00
Nils ANDRÉ-CHANG
8db3398eb7 [IMPROVEMENT] Implement subtitle modifications for each encoder (#1214)
* Implement subtitle modification for all 608 encoders

This is done by modifying the subtitles in `ccx_encoders_common.c`
rather than per encoder.

* Use `char *` instead of subtitle data to capitalize

* Implement subtitle modification for OCR encoders

* Remove signness warnings

* Remove two-word profanity

They do not work for the moment

* Deal with different encoding

* Mention in changelog
2020-01-23 18:45:56 -08:00
Nils ANDRÉ-CHANG
7b038ab649 Fix use-after-free (#1215) 2020-01-23 09:39:45 -08:00
kdrag0n
7d0c2ede26 [IMPROVEMENT] Clean up SCC control codes (#1212)
* scc: Reformat control code list

- Separate sections with a blank line
- Align with 4-wide tabs rather than spaces
- Rewrite some comments

* scc: Revamp control code handling

This can be made much more readable by adding a small info struct that
contains all the information about a control code (first byte odd &
even, second byte, and assembly). Information is stored in and retrieved
from an array, created using an array initializer with the enum values
as indices.

This allows us to remove the massive switch-case blocks, leading to much
cleaner and more streamlined code.
2020-01-22 23:26:23 -08:00
Nils ANDRÉ-CHANG
60773bb859 [IMPROVEMENT] Add noreturn attribute to fatal (#1179)
* Set no return

* Add MSVC
2020-01-22 23:25:43 -08:00
kdrag0n
a919ef4410 [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.
2020-01-22 23:23:00 -08:00
kdrag0n
424e67f5f4 [FIX] Fix SCC timing and lingering captions (#1211)
* scc: Fix timing and lingering captions

- Write EDM codes at end times to clear them from the screen as intended
  by the captioners
- Show captions at the correct times:
  - EOC+ENM *shows* the caption. It doesn't clear it -- that's EDM's job.
  - The caption is *not* shown immediately after loading. EOC (End Of
    Caption) is required for it to actually show.

Old behavior:
Start time: Load caption
End time: Show loaded caption

New behavior:
Start time: Load and show caption
End time: Clear displayed caption

These changes fix the issue where captions were always one line off --
that is, caption 1 would show when caption 2 was supposed to show.

* scc: Calculate frame number using a more precise frame rate

* scc: Fix timecode format specifiers

These are ints are unsigned.
2020-01-22 23:18:18 -08:00
Nils ANDRÉ-CHANG
4097831b9b Remove useless O(N) operations and memory allocations (#1207) 2020-01-22 09:03:21 -08:00
kdrag0n
1764aa1f92 scc: Write all characters in pairs (#1208)
This is how every example appears to be structured. MPV doesn't display
anything without this.

Before: "e5 f2 e5 20"
After: "e5f2 e520"
2020-01-22 08:01:53 -08:00
kdrag0n
19de49763a [FIX] Fix minor memory leak in OCR code (#1206)
* ocr: Fix minor memory leak

Detected by Valgrind:

==1203168== 2,880 bytes in 57 blocks are definitely lost in loss record 3 of 4
==1203168==    at 0x483877F: malloc (vg_replace_malloc.c:309)
==1203168==    by 0x51ADBEE: strdup (in /usr/lib/libc-2.30.so)
==1203168==    by 0x24D1F8: ocr_bitmap (ocr.c:569)
==1203168==    by 0x24E25B: ocr_rect (ocr.c:907)
==1203168==    by 0x284832: write_dvb_sub (dvb_subtitle_decoder.c:1665)
==1203168==    by 0x284B7A: dvbsub_handle_display_segment (dvb_subtitle_decoder.c:1720)
==1203168==    by 0x285024: dvbsub_decode (dvb_subtitle_decoder.c:1828)
==1203168==    by 0x2406AF: process_data (general_loop.c:648)
==1203168==    by 0x2416D0: general_loop (general_loop.c:1025)
==1203168==    by 0x1AC89A: api_start (ccextractor.c:214)
==1203168==    by 0x16EC03: main (ccextractor.c:536)

* changes: Document OCR memory leak fix
2020-01-21 08:19:19 -08:00
kdrag0n
a0b4e389f9 [FIX] EIA-608 screen clearing fix (#1203)
* eia608: Re-use constant rather than hard-coding length in arrays

Hard-coding them is less clear and more prone to breakage.

* eia608: Add and use constant for max number of rows

Hard-coding it everywhere is unclear and prone to breakage.

* eia608: Initialize colors and fonts properly with a loop

memset is for single-byte types; an enum is defined to be the size of an
int, so using memset to fill an array of enum values is incorrect.

Fix it by using a simple loop to fill the elements, as there is no
memset-like function for arbitrary item lengths in C.

GCC warns:

src/lib_ccx/ccx_decoders_608.c: In function ‘clear_eia608_cc_buffer’:
src/lib_ccx/ccx_decoders_608.c:111:3: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
  111 |   memset(data->colors[i], context->settings->default_color, CCX_DECODER_608_SCREEN_WIDTH + 1);
      |   ^~~~~~
src/lib_ccx/ccx_decoders_608.c:112:3: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
  112 |   memset(data->fonts[i], FONT_REGULAR, CCX_DECODER_608_SCREEN_WIDTH + 1);
      |   ^~~~~~
2020-01-20 19:06:06 -08:00
Nils ANDRÉ-CHANG
2281051d3d Remove warning when calling paraof_ocrtext (#1199) 2020-01-19 16:51:41 -08:00
Nils ANDRÉ-CHANG
66d59e498b Make -ocrlang work (#1200) 2020-01-19 11:44:16 -08:00
Nils ANDRÉ-CHANG
84ba7c5238 Fix segfault (#1192) 2020-01-18 12:15:40 -08:00
Nils ANDRÉ-CHANG
e8cb55e739 [FIX] Fix free segfault (#1190)
* Fix free segfault

I restricted the scope and used free because the features of freep
aren't needed here.

Restricting the scope makes it clear when freeing the variable should be
done.

* Mention that freeing should be done
2020-01-18 09:29:58 -08:00
Nils ANDRÉ-CHANG
30613b224a Fix memory leak (#1187)
Addresses https://github.com/CCExtractor/ccextractor/pull/402#discussion_r368041348
2020-01-18 08:53:43 -08:00
Nils ANDRÉ-CHANG
19241744d7 [FEATURE] SCC and CCD encoder (#1154)
* Fix indentation, use switch instead of if

* Remove confusing comment

Enums are abstractions and should be used as such. They shouldn't be
used like integers.

* Return a const char* instead of char * allocated on heap

* Test return value inline

* Add SCC output

* Add CCD format

* Add channel header to CCD

* Return const pointer

* Revert formatting change

* Colour -> Color

* Fix formatting

* Move comment to relevant place

* Improve readability

* Fix formatting

* Fix erroneous comment

* Use different parity function not requiring GNU extension

* Use enum instead of int

* Fix bug

* Implement channel functionality

* Fix CI errors

* Fix CI build

* Add options to help menu

* Mention change in changelog

* Add file to build systems

* Remove uneeded link against zlib

* Remove the use of <stdbool.h> and use const char

* Rewrite SCC formatter

* Use fdprintf
2020-01-18 08:52:03 -08:00
Nils André-Chang
34282c17b8 Fix implicit declaration of function 'add_word'
Fix #1188
2020-01-18 16:16:34 +00:00
Nils ANDRÉ-CHANG
227f149670 [FIX] Allow -dvblang that doesn't follow ISO 639-2 (#1183)
* Allow `-dvblang` that doesn't follow ISO 639-2

Fix #1161

* Allows 'und' to be specified to `-dvblang`
2020-01-16 12:03:13 -08:00
Nils ANDRÉ-CHANG
27477e9f7c [IMPROVEMENT] Remove warnings (#1186)
* [Warning] Make subtitle modification work on unsigned char *

* Remove LOG_DEBUG no side effect warning
2020-01-16 08:25:25 -08:00
Jacob Shin
b3018e083e [FIX] Add FT_Done_Face to destroy face objects after they're used (#1184)
* Add FT_Done_Face to destroy face objects after they're used

* Update CHANGES.TXT
2020-01-14 17:11:18 -08:00
Nils ANDRÉ-CHANG
96de55429d Remove freep warnings (#1182) 2020-01-14 11:22:31 -08:00
Nils ANDRÉ-CHANG
863eacc440 Revert "Remove freep warning (#1180)" (#1181)
This reverts commit 78249045f8.
2020-01-13 14:12:39 -08:00
Nils ANDRÉ-CHANG
78249045f8 Remove freep warning (#1180) 2020-01-13 12:16:42 -08:00
Nils ANDRÉ-CHANG
dad108b7e1 Fix wrong format string (#1177) 2020-01-13 07:54:15 -08:00
Dhrumil Patel
79f18b996b [FIX] Added the option to disable timestamps for WebVTT (#1176)
* Added the option to disable timestamps for WebVTT

* Mentioned in changelog

* Added the option to params.c

* Encoder checks its context nwo

* Encoder checks its context
2020-01-12 18:06:26 -08:00
Nils ANDRÉ-CHANG
987c5cd301 Remove useless nulling of pointer (#1171) 2020-01-09 17:36:10 -08:00
Nils ANDRÉ-CHANG
34d0df1d96 [Fix] Make -delay all output formats (#1167)
* Fix indentation

* Calculate subs_delay in encode_sub rather than in the individual encoders

Fix #1103

* Use precalculated times when sub->type == CC_TEXT

* Use calculate delay in encode_sub when sub->type == CC_608
2020-01-09 17:35:19 -08:00
Willem
af67596e66
Merge pull request #1139 from NilsIrl/filter_bad_words
Adds a built-in method to filter bad words to the program.
2020-01-05 18:41:37 +01:00
Jacob Shin
86f98ddf5f Used the INET_ADDRSTRLEN constant for network functions (#1172) 2020-01-04 07:34:10 +01:00
eshandhawan51
bba6c4fcfd [FIX] Solved issue #1131 (#1169)
* Removed invalid free condition for multiple files

* Apply suggestions from code review

statement to free pointer

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

Co-authored-by: Nils ANDRÉ-CHANG <nils@nilsand.re>
2020-01-02 17:56:02 +01:00
Nils André-Chang
af64fa8a3d Remove multi word profanity 2020-01-01 21:44:02 +00:00
Nils André-Chang
e1d3060232 Fix crash 2020-01-01 17:15:53 +00:00
Jacob Shin
ecec3ea22b Change inet_ntop to inet_ntoa for Windows XP compatibility 2019-12-30 11:55:30 -05:00
Jacob Shin
c854d25963 [FIX] Get rid of a few compilation warnings (#1160)
* Added underline support

* Added changes to CHANGES.TXT

* Delete CHANGES.TXT~

* Delete .CHANGES.TXT.un~

* Update CHANGES.TXT

* Changed strncpy to memcpy when the size of the data being transferred is known

* Add declaration of struct image_copy before function

* Used strdup for duplicating strings

* Added error checking for strdup
2019-12-29 22:26:30 +01:00
Nils André-Chang
4fe32b1482 Fix syntax error because of forgotten brace 2019-12-28 23:34:55 +00:00
Nils ANDRÉ-CHANG
5fcb31d279 Rename spell_correct to capitalization_list 2019-12-28 23:24:04 +00:00
Nils ANDRÉ-CHANG
b2d3a2fefc Fix error where wrong return valued is checked 2019-12-28 23:24:04 +00:00