Skip to content

Commit 030c9d4

Browse files
authored
Merge branch 'master' into avc-todo
2 parents 8156845 + 81fdecd commit 030c9d4

File tree

29 files changed

+1622
-184
lines changed

29 files changed

+1622
-184
lines changed

.github/workflows/build_windows.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ on:
1414
- "**.c"
1515
- "**.h"
1616
- "windows/**"
17+
- "src/rust/**"
1718
pull_request:
1819
types: [opened, synchronize, reopened]
1920
paths:
2021
- ".github/workflows/build_windows.yml"
2122
- "**.c"
2223
- "**.h"
2324
- "windows/**"
25+
- "src/rust/**"
2426

2527
jobs:
2628
build_release:

docker/dockerfile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ FROM base as builder
44

55
RUN apk add --no-cache --update git curl gcc cmake glew glfw \
66
tesseract-ocr-dev leptonica-dev clang-dev llvm-dev make pkgconfig \
7-
zlib-dev libpng-dev libjpeg-turbo-dev openssl-dev freetype-dev libxml2-dev
8-
9-
RUN cd && git clone https://github.com/gpac/gpac
10-
WORKDIR root/gpac/
11-
RUN ./configure && make && make install-lib && cd && rm -rf /root/gpac
7+
zlib-dev libpng-dev libjpeg-turbo-dev openssl-dev freetype-dev libxml2-dev bash cargo
128

139
WORKDIR /root
10+
RUN git clone https://github.com/gpac/gpac
11+
WORKDIR /root/gpac/
12+
RUN ./configure && make -j$(nproc) && make install-lib
13+
WORKDIR /root
14+
RUN rm -rf /root/gpac
15+
1416
RUN git clone https://github.com/CCExtractor/ccextractor.git
15-
RUN apk add bash cargo
16-
RUN export LIB_CLANG_PATH=$(find / -name 'libclang*.so*' 2>/dev/null | grep -v 'No such file' | head -n 1 | xargs dirname)
17-
RUN cd /root/ccextractor/linux && ./pre-build.sh && ./build
17+
WORKDIR /root/ccextractor/linux
18+
RUN ./pre-build.sh && ./build
1819

1920
RUN cp /root/ccextractor/linux/ccextractor /ccextractor && rm -rf ~/ccextractor
2021

@@ -42,7 +43,4 @@ COPY --from=builder /usr/lib/libsharpyuv.so.0 /usr/lib/
4243

4344
COPY --from=builder /ccextractor /
4445

45-
ENTRYPOINT [ "/ccextractor" ]
46-
47-
CMD [ "/ccextractor" ]
48-
46+
ENTRYPOINT [ "/ccextractor" ]

docs/CHANGES.TXT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
1.0 (to be released)
22
-----------------
3+
- Fix: Segmentation faults on XDS files
4+
- Fix: Clippy Errors Based on Rust 1.88
5+
- IMPROVEMENT: Refactor and optimize Dockerfile
36
- Fix: Improved handling of IETF language tags in Matroska files (#1665)
47
- New: Create unit test for rust code (#1615)
58
- Breaking: Major argument flags revamp for CCExtractor (#1564 & #1619)
@@ -40,6 +43,7 @@
4043
- Fix: Resolve compile-time error about implicit declarations (#1646)
4144
- Fix: fatal out of memory error extracting from a VOB PS
4245
- Fix: Fix TODO and FIXME in `avc_functions.c`
46+
4347
0.94 (2021-12-14)
4448
-----------------
4549
- BOM is no longer enabled by default on windows platforms

docs/COMPILATION.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Dependencies can be installed via Homebrew as:
133133
```bash
134134
brew install pkg-config
135135
brew install autoconf automake libtool
136+
brew install cmake gpac
136137
# optional if you want OCR:
137138
brew install tesseract
138139
brew install leptonica

src/lib_ccx/cc_bitstream.c

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
// Hold functions to read streams on a bit or byte oriented basis
44
// plus some data related helper functions.
55

6+
#ifndef DISABLE_RUST
7+
extern uint64_t ccxr_next_bits(struct bitstream *bs, uint32_t bnum);
8+
extern uint64_t ccxr_read_bits(struct bitstream *bs, uint32_t bnum);
9+
extern int ccxr_skip_bits(struct bitstream *bs, uint32_t bnum);
10+
extern int ccxr_is_byte_aligned(struct bitstream *bs);
11+
extern void ccxr_make_byte_aligned(struct bitstream *bs);
12+
extern const uint8_t *ccxr_next_bytes(struct bitstream *bs, size_t bynum);
13+
extern const uint8_t *ccxr_read_bytes(struct bitstream *bs, size_t bynum);
14+
extern uint64_t ccxr_read_exp_golomb_unsigned(struct bitstream *bs);
15+
extern int64_t ccxr_read_exp_golomb(struct bitstream *bs);
16+
extern uint8_t ccxr_reverse8(uint8_t data);
17+
extern uint64_t ccxr_bitstream_get_num(struct bitstream *bs, unsigned bytes, int advance);
18+
extern int64_t ccxr_read_int(struct bitstream *bs, unsigned bnum);
19+
#endif
20+
621
// Guidelines for all bitsream functions:
722
// * No function shall advance the pointer past the end marker
823
// * If bitstream.bitsleft < 0 do not attempt any read access,
@@ -35,6 +50,9 @@ int init_bitstream(struct bitstream *bstr, unsigned char *start, unsigned char *
3550
// there are not enough bits left in the bitstream.
3651
uint64_t next_bits(struct bitstream *bstr, unsigned bnum)
3752
{
53+
#ifndef DISABLE_RUST
54+
return ccxr_next_bits(bstr, bnum);
55+
#else
3856
uint64_t res = 0;
3957

4058
if (bnum > 64)
@@ -99,12 +117,16 @@ uint64_t next_bits(struct bitstream *bstr, unsigned bnum)
99117
bstr->_i_pos = vpos;
100118

101119
return res;
120+
#endif
102121
}
103122

104123
// Read bnum bits from bitstream bstr with the most significant
105124
// bit read first. A 64 bit unsigned integer is returned.
106125
uint64_t read_bits(struct bitstream *bstr, unsigned bnum)
107126
{
127+
#ifndef DISABLE_RUST
128+
return ccxr_read_bits(bstr, bnum);
129+
#else
108130
uint64_t res = next_bits(bstr, bnum);
109131

110132
// Special case for reading zero bits. Also abort when not enough
@@ -117,13 +139,17 @@ uint64_t read_bits(struct bitstream *bstr, unsigned bnum)
117139
bstr->pos = bstr->_i_pos;
118140

119141
return res;
142+
#endif
120143
}
121144

122145
// This function will advance the bitstream by bnum bits, if possible.
123146
// Advancing of more than 64 bits is possible.
124147
// Return TRUE when successful, otherwise FALSE
125148
int skip_bits(struct bitstream *bstr, unsigned bnum)
126149
{
150+
#ifndef DISABLE_RUST
151+
return ccxr_skip_bits(bstr, bnum);
152+
#else
127153
// Sanity check
128154
if (bstr->end - bstr->pos < 0)
129155
fatal(CCX_COMMON_EXIT_BUG_BUG, "In skip_bits: bitstream length cannot be negative!");
@@ -140,7 +166,7 @@ int skip_bits(struct bitstream *bstr, unsigned bnum)
140166
if (bstr->bitsleft < 0)
141167
return 0;
142168

143-
// Special case for reading zero bits. Return zero
169+
// Special case for reading zero bits. Return one == success
144170
if (bnum == 0)
145171
return 1;
146172

@@ -153,13 +179,17 @@ int skip_bits(struct bitstream *bstr, unsigned bnum)
153179
bstr->pos += 1;
154180
}
155181
return 1;
182+
#endif
156183
}
157184

158185
// Return TRUE if the current position in the bitstream is on a byte
159186
// boundary, i.e., the next bit in the bitstream is the first bit in
160187
// a byte, otherwise return FALSE
161188
int is_byte_aligned(struct bitstream *bstr)
162189
{
190+
#ifndef DISABLE_RUST
191+
return ccxr_is_byte_aligned(bstr);
192+
#else
163193
// Sanity check
164194
if (bstr->end - bstr->pos < 0)
165195
fatal(CCX_COMMON_EXIT_BUG_BUG, "In is_byte_aligned: bitstream length can not be negative!");
@@ -175,11 +205,15 @@ int is_byte_aligned(struct bitstream *bstr)
175205
return 1;
176206
else
177207
return 0;
208+
#endif
178209
}
179210

180211
// Move bitstream to next byte border. Adjust bitsleft.
181212
void make_byte_aligned(struct bitstream *bstr)
182213
{
214+
#ifndef DISABLE_RUST
215+
ccxr_make_byte_aligned(bstr);
216+
#else
183217
// Sanity check
184218
if (bstr->end - bstr->pos < 0)
185219
fatal(CCX_COMMON_EXIT_BUG_BUG, "In make_byte_aligned: bitstream length can not be negative!");
@@ -208,6 +242,7 @@ void make_byte_aligned(struct bitstream *bstr)
208242
bstr->bitsleft = 0LL + 8 * (bstr->end - bstr->pos - 1) + bstr->bpos;
209243

210244
return;
245+
#endif
211246
}
212247

213248
// Return pointer to first of bynum bytes from the bitstream if the
@@ -217,6 +252,9 @@ void make_byte_aligned(struct bitstream *bstr)
217252
// This function does not advance the bitstream pointer.
218253
unsigned char *next_bytes(struct bitstream *bstr, unsigned bynum)
219254
{
255+
#ifndef DISABLE_RUST
256+
return (unsigned char *)ccxr_next_bytes(bstr, bynum);
257+
#else
220258
// Sanity check
221259
if (bstr->end - bstr->pos < 0)
222260
fatal(CCX_COMMON_EXIT_BUG_BUG, "In next_bytes: bitstream length can not be negative!");
@@ -238,6 +276,7 @@ unsigned char *next_bytes(struct bitstream *bstr, unsigned bynum)
238276
bstr->_i_pos = bstr->pos + bynum;
239277

240278
return bstr->pos;
279+
#endif
241280
}
242281

243282
// Return pointer to first of bynum bytes from the bitstream if the
@@ -247,6 +286,9 @@ unsigned char *next_bytes(struct bitstream *bstr, unsigned bynum)
247286
// This function does advance the bitstream pointer.
248287
unsigned char *read_bytes(struct bitstream *bstr, unsigned bynum)
249288
{
289+
#ifndef DISABLE_RUST
290+
return (unsigned char *)ccxr_read_bytes(bstr, bynum);
291+
#else
250292
unsigned char *res = next_bytes(bstr, bynum);
251293

252294
// Advance the bitstream when a read was possible
@@ -256,6 +298,7 @@ unsigned char *read_bytes(struct bitstream *bstr, unsigned bynum)
256298
bstr->pos = bstr->_i_pos;
257299
}
258300
return res;
301+
#endif
259302
}
260303

261304
// Return an integer number with "bytes" precision from the current
@@ -266,6 +309,9 @@ unsigned char *read_bytes(struct bitstream *bstr, unsigned bynum)
266309
// little-endian and big-endian CPUs.
267310
uint64_t bitstream_get_num(struct bitstream *bstr, unsigned bytes, int advance)
268311
{
312+
#ifndef DISABLE_RUST
313+
return ccxr_bitstream_get_num(bstr, bytes, advance);
314+
#else
269315
void *bpos;
270316
uint64_t rval = 0;
271317

@@ -296,11 +342,15 @@ uint64_t bitstream_get_num(struct bitstream *bstr, unsigned bytes, int advance)
296342
rval = (rval << 8) + uc;
297343
}
298344
return rval;
345+
#endif
299346
}
300347

301348
// Read unsigned Exp-Golomb code from bitstream
302349
uint64_t read_exp_golomb_unsigned(struct bitstream *bstr)
303350
{
351+
#ifndef DISABLE_RUST
352+
return ccxr_read_exp_golomb_unsigned(bstr);
353+
#else
304354
uint64_t res = 0;
305355
int zeros = 0;
306356

@@ -310,11 +360,15 @@ uint64_t read_exp_golomb_unsigned(struct bitstream *bstr)
310360
res = (0x01 << zeros) - 1 + read_bits(bstr, zeros);
311361

312362
return res;
363+
#endif
313364
}
314365

315366
// Read signed Exp-Golomb code from bitstream
316367
int64_t read_exp_golomb(struct bitstream *bstr)
317368
{
369+
#ifndef DISABLE_RUST
370+
return ccxr_read_exp_golomb(bstr);
371+
#else
318372
int64_t res = 0;
319373

320374
res = read_exp_golomb_unsigned(bstr);
@@ -325,6 +379,7 @@ int64_t read_exp_golomb(struct bitstream *bstr)
325379
res = (res / 2 + (res % 2 ? 1 : 0)) * (res % 2 ? 1 : -1);
326380

327381
return res;
382+
#endif
328383
}
329384

330385
// Read unsigned integer with bnum bits length. Basically an
@@ -337,18 +392,25 @@ uint64_t read_int_unsigned(struct bitstream *bstr, unsigned bnum)
337392
// Read signed integer with bnum bits length.
338393
int64_t read_int(struct bitstream *bstr, unsigned bnum)
339394
{
395+
#ifndef DISABLE_RUST
396+
return ccxr_read_int(bstr, bnum);
397+
#else
340398
uint64_t res = read_bits(bstr, bnum);
341399

342400
// Special case for reading zero bits. Return zero
343401
if (bnum == 0)
344402
return 0;
345403

346404
return (0xFFFFFFFFFFFFFFFFULL << bnum) | res;
405+
#endif
347406
}
348407

349408
// Return the value with the bit order reversed.
350409
uint8_t reverse8(uint8_t data)
351410
{
411+
#ifndef DISABLE_RUST
412+
return ccxr_reverse8(data);
413+
#else
352414
uint8_t res = 0;
353415

354416
for (int k = 0; k < 8; k++)
@@ -358,4 +420,5 @@ uint8_t reverse8(uint8_t data)
358420
}
359421

360422
return res;
423+
#endif
361424
}

src/lib_ccx/cc_bitstream.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef _BITSTREAM_
22
#define _BITSTREAM_
33

4-
54
// The structure holds the current position in the bitstream.
65
// pos points to the current byte position and bpos counts the
76
// bits left unread at the current byte pos. No bit read means

src/rust/Cargo.lock

Lines changed: 10 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ crate-type = ["staticlib"]
1313
[dependencies]
1414
log = "0.4.26"
1515
env_logger = "0.8.4"
16-
iconv = "0.1.1"
1716
palette = "0.6.1"
1817
rsmpeg = { version = "0.14.2", optional = true, features = [
1918
"link_system_ffmpeg",
@@ -28,6 +27,7 @@ cfg-if = "1.0.0"
2827
num-integer = "0.1.46"
2928
lib_ccxr = { path = "lib_ccxr" }
3029
url = "2.5.4"
30+
encoding_rs = "0.8.5"
3131

3232
[build-dependencies]
3333
bindgen = "0.64.0"

0 commit comments

Comments
 (0)