-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Port 708 decoder encoding module to RUST (#1607)
* feat: Add `decoder/encoding` new module This `decoder/encoding.rs` file will contain the content of `lib_ccx/ccx_708_decoder_encoding.c` file * feat: Add encoding functions * feat: Add conditional compilation to include Rust functions * fix: conditional compilation logic * refactor: Use of match statement instead of if-else * fix: Calling C function for rust * feat: Enable `derive_default` feature
- Loading branch information
1 parent
8e3b145
commit d6ccf1b
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
#ifndef _CCX_DECODERS_708_ENCODING_H_ | ||
#define _CCX_DECODERS_708_ENCODING_H_ | ||
|
||
#define CCX_DTVCC_MUSICAL_NOTE_CHAR 9836 // Unicode Character 'BEAMED SIXTEENTH NOTES' | ||
#define CCX_DTVCC_MUSICAL_NOTE_CHAR 9836 // Unicode Character 'BEAMED SIXTEENTH NOTES' | ||
|
||
#ifndef DISABLE_RUST | ||
extern unsigned char dtvcc_get_internal_from_G0(unsigned char g0_char); | ||
extern unsigned char dtvcc_get_internal_from_G1(unsigned char g1_char); | ||
extern unsigned char dtvcc_get_internal_from_G2(unsigned char g2_char); | ||
extern unsigned char dtvcc_get_internal_from_G3(unsigned char g3_char); | ||
#else | ||
unsigned char dtvcc_get_internal_from_G0(unsigned char g0_char); | ||
unsigned char dtvcc_get_internal_from_G1(unsigned char g1_char); | ||
unsigned char dtvcc_get_internal_from_G2(unsigned char g2_char); | ||
unsigned char dtvcc_get_internal_from_G3(unsigned char g3_char); | ||
#endif | ||
|
||
#endif /*_CCX_DECODERS_708_ENCODING_H_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/// 256 BYTES IS ENOUGH FOR ALL THE SUPPORTED CHARACTERS IN | ||
/// EIA-708, SO INTERNALLY WE USE THIS TABLE (FOR CONVENIENCE) | ||
/// | ||
/// 00-1F -> Characters that are in the G2 group in 20-3F, | ||
/// except for 06, which is used for the closed captions | ||
/// sign "CC" which is defined in group G3 as 00. (this | ||
/// is by the article 33). | ||
/// 20-7F -> Group G0 as is - corresponds to the ASCII code | ||
/// 80-9F -> Characters that are in the G2 group in 60-7F | ||
/// (there are several blank characters here, that's OK) | ||
/// A0-FF -> Group G1 as is - non-English characters and symbols | ||
// NOTE: Same as `lib_ccx/ccx_decoder_708_encoding.c` file | ||
|
||
#[no_mangle] | ||
pub extern "C" fn dtvcc_get_internal_from_G0(g0_char: u8) -> u8 { | ||
g0_char | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn dtvcc_get_internal_from_G1(g1_char: u8) -> u8 { | ||
g1_char | ||
} | ||
|
||
/// G2: Extended Control Code Set 1 | ||
#[no_mangle] | ||
pub extern "C" fn dtvcc_get_internal_from_G2(g2_char: u8) -> u8 { | ||
match g2_char { | ||
0x20..=0x3F => g2_char - 0x20, | ||
0x60..=0x7F => g2_char + 0x20, | ||
_ => 0x20, | ||
} | ||
} | ||
|
||
/// G3: Future Characters and Icon Expansion | ||
#[no_mangle] | ||
pub extern "C" fn dtvcc_get_internal_from_G3(g3_char: u8) -> u8 { | ||
if g3_char == 0xa0 { | ||
// The "CC" (closed captions) sign | ||
0x06 | ||
} else { | ||
// Rest unmapped, so we return a blank space | ||
0x20 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters