mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-24 11:53:25 +00:00
Merge branch 'pr/n98_rkuchumov'
This commit is contained in:
commit
bd8e3ad137
@ -1,3 +1,7 @@
|
||||
0.73 - GSOC
|
||||
-----------
|
||||
- Added support of BIN format for Teletext
|
||||
|
||||
0.72 - GSOC
|
||||
-----------
|
||||
- Fix for WTV files with incorrect timing
|
||||
|
@ -76,6 +76,9 @@ void write_subtitle_file_header(struct encoder_ctx *ctx,struct ccx_s_write *out)
|
||||
write(out->fh, ctx->buffer, used);
|
||||
break;
|
||||
case CCX_OF_RCWT: // Write header
|
||||
if (ccx_options.teletext_mode == CCX_TXT_IN_USE)
|
||||
rcwt_header[7] = 2; // sets file format version
|
||||
|
||||
write(out->fh, rcwt_header, sizeof(rcwt_header));
|
||||
|
||||
if (ccx_options.send_to_srv)
|
||||
|
@ -398,6 +398,7 @@ extern void build_parity_table(void);
|
||||
void tlt_process_pes_packet(uint8_t *buffer, uint16_t size) ;
|
||||
void telxcc_init(void);
|
||||
void telxcc_close(void);
|
||||
void tlt_read_rcwt();
|
||||
void mstotime(LLONG milli, unsigned *hours, unsigned *minutes,
|
||||
unsigned *seconds, unsigned *ms);
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
//4-5 0050 Program version number
|
||||
//6-7 0001 File format version
|
||||
//8-10 000000 Padding, required :-)
|
||||
const unsigned char rcwt_header[11]={0xCC, 0xCC, 0xED, 0xCC, 0x00, 0x50, 0, 1, 0, 0, 0};
|
||||
unsigned char rcwt_header[11]={0xCC, 0xCC, 0xED, 0xCC, 0x00, 0x50, 0, 1, 0, 0, 0};
|
||||
|
||||
const unsigned char BROADCAST_HEADER[]={0xff, 0xff, 0xff, 0xff};
|
||||
const unsigned char LITTLE_ENDIAN_BOM[]={0xff, 0xfe};
|
||||
|
@ -20,7 +20,7 @@ extern const unsigned char lc4[2];
|
||||
extern const unsigned char lc5[1];
|
||||
extern const unsigned char lc6[1];
|
||||
|
||||
extern const unsigned char rcwt_header[11];
|
||||
extern unsigned char rcwt_header[11];
|
||||
|
||||
#define ONEPASS 120 /* Bytes we can always look ahead without going out of limits */
|
||||
#define BUFSIZE (2048*1024+ONEPASS) /* 2 Mb plus the safety pass */
|
||||
|
@ -772,6 +772,12 @@ void rcwt_loop(void *enc_ctx)
|
||||
fatal(EXIT_MISSING_RCWT_HEADER, "Missing RCWT header. Abort.\n");
|
||||
}
|
||||
|
||||
if (parsebuf[6] == 0 && parsebuf[7] == 2)
|
||||
{
|
||||
tlt_read_rcwt();
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize first time. As RCWT files come with the correct FTS the
|
||||
// initial (minimal) time needs to be set to 0.
|
||||
current_pts = 0;
|
||||
|
54
src/telxcc.c
54
src/telxcc.c
@ -366,9 +366,9 @@ void telxcc_dump_prev_page (void)
|
||||
fdprintf(wbout1.fh, "%s|", c_temp1);
|
||||
}
|
||||
if (ccx_options.transcript_settings.showEndTime)
|
||||
{
|
||||
{
|
||||
millis_to_date (prev_hide_timestamp, c_temp2);
|
||||
fdprintf(wbout1.fh,"%s|",c_temp2);
|
||||
fdprintf(wbout1.fh,"%s|",c_temp2);
|
||||
}
|
||||
if (ccx_options.transcript_settings.showMode){
|
||||
fdprintf(wbout1.fh, "TLT|");
|
||||
@ -588,7 +588,7 @@ void process_page(teletext_page_t *page) {
|
||||
}
|
||||
}
|
||||
time_reported=0;
|
||||
|
||||
|
||||
switch (ccx_options.write_format)
|
||||
{
|
||||
case CCX_OF_TRANSCRIPT:
|
||||
@ -712,6 +712,7 @@ void process_telx_packet(data_unit_t data_unit_id, teletext_packet_payload_t *pa
|
||||
// it would be nice, if subtitle hides on previous video frame, so we contract 40 ms (1 frame @25 fps)
|
||||
page_buffer.hide_timestamp = timestamp - 40;
|
||||
process_page(&page_buffer);
|
||||
|
||||
}
|
||||
|
||||
page_buffer.show_timestamp = timestamp;
|
||||
@ -898,6 +899,39 @@ void process_telx_packet(data_unit_t data_unit_id, teletext_packet_payload_t *pa
|
||||
}
|
||||
}
|
||||
|
||||
void tlt_write_rcwt(uint8_t data_unit_id, uint8_t *packet, uint64_t timestamp) {
|
||||
writeraw((unsigned char *) &data_unit_id, sizeof(uint8_t), &wbout1);
|
||||
writeraw((unsigned char *) ×tamp, sizeof(uint64_t), &wbout1);
|
||||
writeraw((unsigned char *) packet, 44, &wbout1);
|
||||
}
|
||||
|
||||
void tlt_read_rcwt() {
|
||||
int len = 1 + 8 + 44;
|
||||
char *buf = (char *) malloc(len);
|
||||
if (buf == NULL)
|
||||
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory");
|
||||
|
||||
while(1) {
|
||||
buffered_read(buf, len);
|
||||
past += result;
|
||||
|
||||
if (result != len) {
|
||||
end_of_file = 1;
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
data_unit_t id = buf[0];
|
||||
uint64_t t;
|
||||
memcpy(&t, &buf[1], sizeof(uint64_t));
|
||||
teletext_packet_payload_t *pl = (teletext_packet_payload_t *)&buf[9];
|
||||
|
||||
last_timestamp = t;
|
||||
|
||||
process_telx_packet(id, pl, t);
|
||||
}
|
||||
}
|
||||
|
||||
void tlt_process_pes_packet(uint8_t *buffer, uint16_t size) {
|
||||
uint64_t pes_prefix;
|
||||
uint8_t pes_stream_id;
|
||||
@ -1000,8 +1034,11 @@ void tlt_process_pes_packet(uint8_t *buffer, uint16_t size) {
|
||||
// reverse endianess (via lookup table), ETS 300 706, chapter 7.1
|
||||
for (uint8_t j = 0; j < data_unit_len; j++) buffer[i + j] = REVERSE_8[buffer[i + j]];
|
||||
|
||||
// FIXME: This explicit type conversion could be a problem some day -- do not need to be platform independant
|
||||
process_telx_packet((data_unit_t) data_unit_id, (teletext_packet_payload_t *)&buffer[i], last_timestamp);
|
||||
if (ccx_options.write_format == CCX_OF_RCWT)
|
||||
tlt_write_rcwt(data_unit_id, &buffer[i], last_timestamp);
|
||||
else
|
||||
// FIXME: This explicit type conversion could be a problem some day -- do not need to be platform independant
|
||||
process_telx_packet((data_unit_t) data_unit_id, (teletext_packet_payload_t *)&buffer[i], last_timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1110,14 +1147,15 @@ void telxcc_init(void)
|
||||
// Close output
|
||||
void telxcc_close(void)
|
||||
{
|
||||
if (telxcc_inited)
|
||||
{
|
||||
if (telxcc_inited && ccx_options.write_format != CCX_OF_RCWT)
|
||||
{
|
||||
// output any pending close caption
|
||||
if (page_buffer.tainted == YES) {
|
||||
// this time we do not subtract any frames, there will be no more frames
|
||||
page_buffer.hide_timestamp = last_timestamp;
|
||||
process_page(&page_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
telxcc_dump_prev_page();
|
||||
|
||||
if ((tlt_frames_produced == 0) && (tlt_config.nonempty == YES)) {
|
||||
|
Loading…
Reference in New Issue
Block a user