Skip to content

Commit 4ef4df6

Browse files
authored
Merge branch 'master' into null-terminated-frames
2 parents e6b85da + 9f250b1 commit 4ef4df6

17 files changed

Lines changed: 298 additions & 91 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22

33
**In raising this pull request, I confirm the following (please check boxes):**
44

5+
Reason for this PR:
6+
7+
- [ ] This PR adds new functionality.
8+
- [ ] This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
9+
- [ ] This PR is porting code from C to Rust.
10+
11+
Sanity check:
512
- [ ] I have read and understood the [contributors guide](https://github.com/CCExtractor/ccextractor/blob/master/.github/CONTRIBUTING.md).
613
- [ ] I have checked that another pull request for this purpose does not exist.
7-
- [ ] I have considered, and confirmed that this submission will be valuable to others.
8-
- [ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
9-
- [ ] I give this submission freely, and claim no ownership to its content.
10-
- [ ] **I have mentioned this change in the [changelog](https://github.com/CCExtractor/ccextractor/blob/master/docs/CHANGES.TXT).**
14+
- [ ] If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
15+
- [ ] I am NOT adding new C code unless it's to fix an existing, reproducible bug.
16+
17+
Repro instructions:
18+
19+
This is *essential*. We will not merge ANY PR that doesn't come with detailed instructions, *including a sample*. We don't want
20+
"fixes" for theoretical issues that an AI agent found, without context. If you can't reproduce the bug, don't send a PR.
1121

12-
**My familiarity with the project is as follows (check one):**
22+
Creating PRs with AI is very quick, but we still have humans (even if AI assisted) going over each.
1323

14-
- [ ] I have never used CCExtractor.
15-
- [ ] I have used CCExtractor just a couple of times.
16-
- [ ] I absolutely love CCExtractor, but have not contributed previously.
17-
- [ ] I am an active contributor to CCExtractor.
24+
Be mindful of reviewers' time.
1825

1926
---
2027

.github/workflows/build_linux.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: sudo apt update && sudo apt-get install libgpac-dev libtesseract-dev libavcodec-dev libavdevice-dev libx11-dev libxcb1-dev libxcb-shm0-dev
3434
- uses: actions/checkout@v6
3535
- name: build
36-
run: ./build -hardsubx
36+
run: ./build -hardsubx -min-rust
3737
working-directory: ./linux
3838
- name: Display version information
3939
run: ./ccextractor --version
@@ -49,6 +49,29 @@ jobs:
4949
with:
5050
name: CCExtractor Linux build
5151
path: ./linux/artifacts
52+
build_shell_migrations:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Install dependencies
56+
run: sudo apt update && sudo apt-get install libgpac-dev libtesseract-dev libavcodec-dev libavdevice-dev libx11-dev libxcb1-dev libxcb-shm0-dev
57+
- uses: actions/checkout@v6
58+
- name: build
59+
run: ./build -hardsubx
60+
working-directory: ./linux
61+
- name: Display version information
62+
run: ./ccextractor --version
63+
working-directory: ./linux
64+
- name: Prepare artifacts
65+
run: mkdir ./linux/artifacts
66+
- name: Copy release artifact
67+
run: cp ./linux/ccextractor ./linux/artifacts/
68+
# NOTE: The sample-platform test runner (CCExtractor/sample-platform)
69+
# matches artifact names exactly. Update Artifact_names in
70+
# mod_ci/controllers.py there if you rename this artifact.
71+
- uses: actions/upload-artifact@v7
72+
with:
73+
name: CCExtractor Linux build (with migrations)
74+
path: ./linux/artifacts
5275
build_autoconf:
5376
runs-on: ubuntu-latest
5477
steps:

.github/workflows/build_windows.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ jobs:
113113
with:
114114
arch: ${{ matrix.arch }}
115115

116-
# Build Release-Full
117-
- name: Build Release-Full
116+
# Build Release-Full (min Rust — C paths where available)
117+
- name: Build Release-Full (min Rust)
118118
env:
119119
LIBCLANG_PATH: "C:\\Program Files\\LLVM\\lib"
120120
LLVM_CONFIG_PATH: "C:\\Program Files\\LLVM\\bin\\llvm-config"
121121
BINDGEN_EXTRA_CLANG_ARGS: -fmsc-version=0
122122
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
123123
VCPKG_DEFAULT_TRIPLET: ${{ matrix.vcpkg_triplet }}
124-
run: msbuild ccextractor.sln /p:Configuration=Release-Full /p:Platform=${{ matrix.platform }} /p:GpacDir="${{ matrix.gpac_install }}"
124+
run: msbuild ccextractor.sln /p:Configuration=Release-Full /p:Platform=${{ matrix.platform }} /p:GpacDir="${{ matrix.gpac_install }}" /p:ExtraDefines=DISABLE_RUST
125125
working-directory: ./windows
126126

127127
- name: Display Release version information
@@ -140,6 +140,25 @@ jobs:
140140
./windows/${{ matrix.outdir }}Release-Full/ccextractorwinfull.exe
141141
./windows/${{ matrix.outdir }}Release-Full/*.dll
142142
143+
# Build Release-Full (with migrations — max Rust)
144+
- name: Build Release-Full (with migrations)
145+
env:
146+
LIBCLANG_PATH: "C:\\Program Files\\LLVM\\lib"
147+
LLVM_CONFIG_PATH: "C:\\Program Files\\LLVM\\bin\\llvm-config"
148+
BINDGEN_EXTRA_CLANG_ARGS: -fmsc-version=0
149+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
150+
VCPKG_DEFAULT_TRIPLET: ${{ matrix.vcpkg_triplet }}
151+
run: msbuild ccextractor.sln /t:Rebuild /p:Configuration=Release-Full /p:Platform=${{ matrix.platform }} /p:GpacDir="${{ matrix.gpac_install }}"
152+
working-directory: ./windows
153+
154+
- name: Upload Release artifact (with migrations)
155+
uses: actions/upload-artifact@v7
156+
with:
157+
name: CCExtractor Windows ${{ matrix.arch }} Release build (with migrations)
158+
path: |
159+
./windows/${{ matrix.outdir }}Release-Full/ccextractorwinfull.exe
160+
./windows/${{ matrix.outdir }}Release-Full/*.dll
161+
143162
# Build Debug-Full (reuses cached Cargo artifacts)
144163
- name: Build Debug-Full
145164
env:

docs/CHANGES.TXT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
0.96.7 (unreleased)
22
-------------------
33
- New: Allow output \0 terminated frames via --null-terminated
4+
- New: Added ASS/SSA \pos-based positioning for CEA-608 captions when layout is simple (1–2 rows) (#1726)
45
- Fix: Remove strdup() memory leaks in WebVTT styling encoder, fix invalid CSS rgba(0,256,0) green value, fix missing free(unescaped) on write-error path (#2154)
56
- Fix: Prevent crash in Rust timing module when logging out-of-range PTS/FTS timestamps from malformed streams.
7+
- Fix: Resolve Windows MSVC debug build crash caused by cross-CRT invalid free on Rust-allocated output_filename (#2126)
8+
- Fix: Use dynamic current_fps instead of hardcoded 29.97 in CEA-708 SCC frame delay calculations (#2172)
69

710
0.96.6 (2026-02-19)
811
-------------------

linux/build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ while [[ $# -gt 0 ]]; do
2424
BLD_LINKER="$BLD_LINKER -lswscale -lavutil -pthread -lavformat -lavcodec -lavfilter -lxcb-shm -lxcb -lX11 -llzma -lswresample"
2525
shift
2626
;;
27+
-min-rust)
28+
MIN_RUST=true
29+
BLD_FLAGS="$BLD_FLAGS -DDISABLE_RUST"
30+
shift
31+
;;
2732
-system-libs)
2833
USE_SYSTEM_LIBS=true
2934
shift

src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ include (CTest)
66
option (WITH_FFMPEG "Build using FFmpeg demuxer and decoder" OFF)
77
option (WITH_OCR "Build with OCR (Optical Character Recognition) feature" OFF)
88
option (WITH_HARDSUBX "Build with support for burned-in subtitles" OFF)
9+
option (VBI_DEBUG "Enable VBI decoder debug output" OFF)
910

1011
# Version number
1112
set (CCEXTRACTOR_VERSION_MAJOR 0)
@@ -145,6 +146,11 @@ else (MSVC)
145146
endif(MSVC)
146147

147148
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
149+
150+
if (VBI_DEBUG)
151+
add_definitions(-DVBI_DEBUG)
152+
message(STATUS "VBI debug output enabled")
153+
endif (VBI_DEBUG)
148154
add_subdirectory (lib_ccx)
149155

150156
aux_source_directory(${PROJECT_SOURCE_DIR} SOURCEFILE)
@@ -202,7 +208,9 @@ if (PKG_CONFIG_FOUND AND WITH_OCR)
202208
pkg_check_modules (LEPTONICA REQUIRED lept)
203209

204210
set (EXTRA_LIBS ${EXTRA_LIBS} ${TESSERACT_LIBRARIES})
211+
link_directories(${TESSERACT_LIBRARY_DIRS})
205212
set (EXTRA_LIBS ${EXTRA_LIBS} ${LEPTONICA_LIBRARIES})
213+
link_directories(${LEPTONICA_LIBRARY_DIRS})
206214

207215
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_OCR")
208216
endif (PKG_CONFIG_FOUND AND WITH_OCR)
@@ -237,7 +245,9 @@ if (PKG_CONFIG_FOUND AND WITH_HARDSUBX)
237245
pkg_check_modules (LEPTONICA REQUIRED lept)
238246

239247
set (EXTRA_LIBS ${EXTRA_LIBS} ${TESSERACT_LIBRARIES})
248+
link_directories(${TESSERACT_LIBRARY_DIRS})
240249
set (EXTRA_LIBS ${EXTRA_LIBS} ${LEPTONICA_LIBRARIES})
250+
link_directories(${LEPTONICA_LIBRARY_DIRS})
241251

242252
set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${TESSERACT_INCLUDE_DIRS})
243253
set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${LEPTONICA_INCLUDE_DIRS})

src/lib_ccx/ccx_decoders_708_output.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,11 @@ void dtvcc_write_scc(dtvcc_writer_ctx *writer, dtvcc_service_decoder *decoder, s
550550
if (tv->old_cc_time_end > time_show.time_in_ms)
551551
{
552552
// Correct the frame delay
553-
time_show.time_in_ms -= 1000 / 29.97;
553+
time_show.time_in_ms -= 1000 / current_fps;
554554
print_scc_time(time_show, buf);
555555
buf_len = strlen(buf);
556556
SCC_SNPRINTF("\t942c 942c");
557-
time_show.time_in_ms += 1000 / 29.97;
557+
time_show.time_in_ms += 1000 / current_fps;
558558
// Clear the buffer and start pop on caption
559559
SCC_SNPRINTF("94ae 94ae 9420 9420");
560560
}
@@ -566,20 +566,20 @@ void dtvcc_write_scc(dtvcc_writer_ctx *writer, dtvcc_service_decoder *decoder, s
566566
buf_len = strlen(buf);
567567
SCC_SNPRINTF("\t942c 942c \n\n");
568568
// Correct the frame delay
569-
time_show.time_in_ms -= 1000 / 29.97;
569+
time_show.time_in_ms -= 1000 / current_fps;
570570
// Clear the buffer and start pop on caption in new time
571571
print_scc_time(time_show, buf + buf_len);
572572
buf_len = strlen(buf);
573573
SCC_SNPRINTF("\t94ae 94ae 9420 9420");
574-
time_show.time_in_ms += 1000 / 29.97;
574+
time_show.time_in_ms += 1000 / current_fps;
575575
}
576576
else
577577
{
578-
time_show.time_in_ms -= 1000 / 29.97;
578+
time_show.time_in_ms -= 1000 / current_fps;
579579
print_scc_time(time_show, buf);
580580
buf_len = strlen(buf);
581581
SCC_SNPRINTF("\t942c 942c 94ae 94ae 9420 9420");
582-
time_show.time_in_ms += 1000 / 29.97;
582+
time_show.time_in_ms += 1000 / current_fps;
583583
}
584584

585585
int total_subtitle_count = count_captions_lines_scc(tv);

src/lib_ccx/ccx_decoders_vbi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define CCX_DECODER_VBI
33

44
#include "zvbi/zvbi_decoder.h"
5-
#define VBI_DEBUG
65

76
#include "ccx_decoders_structs.h"
87
#include "ccx_decoders_common.h"
@@ -11,6 +10,8 @@ struct ccx_decoder_vbi_cfg
1110
{
1211
#ifdef VBI_DEBUG
1312
char *debug_file_name;
13+
#else
14+
int reserved; /* ensure non-empty struct in non-debug builds (MSVC C2016) */
1415
#endif
1516
};
1617

@@ -24,4 +25,4 @@ struct ccx_decoder_vbi_ctx
2425
#endif
2526
};
2627

27-
#endif
28+
#endif

src/lib_ccx/ccx_demuxer.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,19 @@ static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
136136

137137
if (ctx->auto_stream == CCX_SM_AUTODETECT)
138138
{
139+
// Temporarily disable binary_concat during stream detection.
140+
// detect_stream_type reads up to 1MB (STARTBYTESLENGTH) via
141+
// buffered_read_opt. For files smaller than 1MB, hitting EOF
142+
// causes buffered_read_opt to call switch_to_next_file (when
143+
// binary_concat is enabled), which increments current_file
144+
// past the valid range and closes the file descriptor.
145+
// This leaves current_file pointing beyond inputfile[], causing
146+
// format-specific handlers (e.g. matroska_loop) to crash when
147+
// they access inputfile[current_file].
148+
int saved_binary_concat = ccx_options.binary_concat;
149+
ccx_options.binary_concat = 0;
139150
detect_stream_type(ctx);
151+
ccx_options.binary_concat = saved_binary_concat;
140152
switch (ctx->stream_mode)
141153
{
142154
case CCX_SM_ELEMENTARY_OR_NOT_FOUND:

src/lib_ccx/ccx_encoders_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static const char *ssa_header =
4848
"[Script Info]\n\
4949
Title: Default file\n\
5050
ScriptType: v4.00+\n\
51+
PlayResX: 384\n\
52+
PlayResY: 288\n\
5153
\n\
5254
[V4+ Styles]\n\
5355
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n\

0 commit comments

Comments
 (0)