Compare commits

...

12 Commits
v0.73 ... v0.74

Author SHA1 Message Date
cfsmp3
18f781d099 0.74 2014-09-24 13:04:26 +02:00
Ruslan Kuchumov
84db812769 windows support 2014-09-08 18:49:37 +00:00
Ruslan Kuchumov
7763f8aeab pointer bugfix 2014-09-08 18:02:49 +00:00
Ruslan Kuchumov
faa879801e printing output on SIGINT 2014-09-08 09:02:10 +00:00
wforums
4635329a5b Changes.txt updated
-
2014-09-06 13:17:04 +02:00
wforums
b89cc3b6df UCLA TT format change
Switched around TEL & TT page number in ttxt format.
2014-09-06 13:16:51 +02:00
wforums
e9f8313f7c BOM parameter
BOM can be not written now if -nobom is passed as parameter.
2014-09-06 13:16:25 +02:00
wforums
324cd84ffe UCLA parameter fix
Added a new option to ensure that UCLA parameter doesn't get overriden
anymore.
2014-09-06 12:13:50 +02:00
wforums
9d7518c9ec -o1 -o2 -12 fix
Fixes the issue where when using multiple output files, everyting is
written to the -o2 output file.
2014-09-06 00:07:28 +02:00
Ruslan Kuchumov
32e0d6023d sending teletext to the server 2014-09-04 16:07:06 +00:00
Ruslan Kuchumov
c9465e476b segfault when no input files bugfix 2014-09-04 16:02:51 +00:00
Ruslan Kuchumov
45d237da40 removed bin output when sending to server 2014-09-04 15:33:02 +00:00
12 changed files with 175 additions and 82 deletions

View File

@@ -1,3 +1,13 @@
0.74
-----------
- Fixed issue with -o1 -o2 and -12 parameters (where it would write output only in the o2 file)
- Fixed UCLA parameter issue. Now the UCLA parameter settings can't be overwritten anymore by later parameters that affect the custom transcript
- Switched order around for TLT and TT page number in custom transcript to match UCLA settings
- Added nobom parameter, for when files are processed by tools that can't handle the BOM. If using this, files might be not readable under windows.
- Segfault fix when no input files were given
- No more bin output when sending to server + possibility to send TT to server for processing
- Windows: Added the Microsoft redistributable MSVCR120.DLL to both the installation package and the application zip.
0.73 - GSOC
-----------
- Added support of BIN format for Teletext

View File

@@ -7,6 +7,7 @@ License: GPL 2.0
#include "configuration.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include "ffmpeg_intgr.h"
void xds_cea608_test();
@@ -79,6 +80,8 @@ void init_options (struct ccx_s_options *options)
options->nofontcolor=0; // 1 = don't put <font color> tags
options->notypesetting=0; // 1 = Don't put <i>, <u>, etc typesetting tags
options->no_bom = 0; // Use BOM by default.
options->settings_608.direct_rollup = 0;
options->settings_608.no_rollup = 0;
options->settings_608.force_rollup = 0;
@@ -198,6 +201,13 @@ int main_telxcc (int argc, char *argv[]);
#endif
LLONG process_raw_with_field (void);
void sigint_handler()
{
if (ccx_options.print_file_reports)
print_file_report();
exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
@@ -208,9 +218,9 @@ int main(int argc, char *argv[])
void *ffmpeg_ctx = NULL;
// Need to set the 608 data for the report to the correct variable.
file_report.data_from_608 = ccx_decoder_608_report;
file_report.data_from_608 = &ccx_decoder_608_report;
// Same applies for 708 data
file_report.data_from_708 = ccx_decoder_708_report;
file_report.data_from_708 = &ccx_decoder_708_report;
// Initialize some constants
init_ts();
@@ -265,10 +275,13 @@ int main(int argc, char *argv[])
fatal(EXIT_TOO_MANY_INPUT_FILES, "TCP mode is not compatible with input files.\n");
}
wbout1.multiple_files = num_input_files > 0;
wbout1.first_input_file = inputfile[0];
wbout2.multiple_files = num_input_files > 0;
wbout2.first_input_file = inputfile[0];
if (num_input_files > 0)
{
wbout1.multiple_files = 1;
wbout1.first_input_file = inputfile[0];
wbout2.multiple_files = 1;
wbout2.first_input_file = inputfile[0];
}
// teletext page number out of range
if ((tlt_config.page != 0) && ((tlt_config.page < 100) || (tlt_config.page > 899))) {
@@ -435,7 +448,7 @@ int main(int argc, char *argv[])
wbout1.fh=STDOUT_FILENO;
mprint ("Sending captions to stdout.\n");
}
else
else if (!ccx_options.send_to_srv)
{
if (wbout1.filename[0]==0)
{
@@ -453,22 +466,27 @@ int main(int argc, char *argv[])
}
switch (ccx_options.write_format)
{
case CCX_OF_RAW:
writeraw (BROADCAST_HEADER,sizeof (BROADCAST_HEADER),&wbout1);
break;
case CCX_OF_DVDRAW:
break;
case CCX_OF_RCWT:
if( init_encoder(enc_ctx,&wbout1) )
fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
break;
default:
if (ccx_options.encoding==CCX_ENC_UTF_8) // Write BOM
writeraw (UTF8_BOM, sizeof (UTF8_BOM), &wbout1);
if (ccx_options.encoding==CCX_ENC_UNICODE) // Write BOM
writeraw (LITTLE_ENDIAN_BOM, sizeof (LITTLE_ENDIAN_BOM), &wbout1);
if( init_encoder(enc_ctx,&wbout1) )
fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
case CCX_OF_RAW:
writeraw(BROADCAST_HEADER, sizeof(BROADCAST_HEADER), &wbout1);
break;
case CCX_OF_DVDRAW:
break;
case CCX_OF_RCWT:
if (init_encoder(enc_ctx, &wbout1))
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
break;
default:
if (!ccx_options.no_bom){
if (ccx_options.encoding == CCX_ENC_UTF_8){ // Write BOM
writeraw(UTF8_BOM, sizeof(UTF8_BOM), &wbout1);
}
if (ccx_options.encoding == CCX_ENC_UNICODE){ // Write BOM
writeraw(LITTLE_ENDIAN_BOM, sizeof(LITTLE_ENDIAN_BOM), &wbout1);
}
}
if (init_encoder(enc_ctx, &wbout1)){
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
}
}
}
if (ccx_options.extract == 12 && ccx_options.write_format != CCX_OF_RAW)
@@ -485,7 +503,7 @@ int main(int argc, char *argv[])
{
memcpy(&wbout2, &wbout1,sizeof(wbout1));
}
else
else if (!ccx_options.send_to_srv)
{
if (wbout2.filename[0]==0)
{
@@ -514,12 +532,17 @@ int main(int argc, char *argv[])
fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
break;
default:
if (ccx_options.encoding==CCX_ENC_UTF_8) // Write BOM
writeraw (UTF8_BOM, sizeof (UTF8_BOM), &wbout2);
if (ccx_options.encoding==CCX_ENC_UNICODE) // Write BOM
writeraw (LITTLE_ENDIAN_BOM, sizeof (LITTLE_ENDIAN_BOM), &wbout2);
if( init_encoder(enc_ctx+1,&wbout2) )
fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
if (!ccx_options.no_bom){
if (ccx_options.encoding == CCX_ENC_UTF_8){ // Write BOM
writeraw(UTF8_BOM, sizeof(UTF8_BOM), &wbout2);
}
if (ccx_options.encoding == CCX_ENC_UNICODE){ // Write BOM
writeraw(LITTLE_ENDIAN_BOM, sizeof(LITTLE_ENDIAN_BOM), &wbout2);
}
}
if (init_encoder(enc_ctx + 1, &wbout2)){
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
}
}
}
}
@@ -573,6 +596,10 @@ int main(int argc, char *argv[])
fatal (EXIT_UNABLE_TO_DETERMINE_FILE_SIZE, "Failed to determine total file size.\n");
}
#ifndef _WIN32
m_signal(SIGINT, sigint_handler);
#endif
while (switch_to_next_file(0) && !processed_enough)
{
prepare_for_new_file();

View File

@@ -1,7 +1,7 @@
#ifndef CCX_CCEXTRACTOR_H
#define CCX_CCEXTRACTOR_H
#define VERSION "0.73"
#define VERSION "0.74"
// Load common includes and constants for library usage
#include "ccx_common_platform.h"
@@ -42,6 +42,8 @@ struct ccx_s_options // Options from user parameters
struct ccx_boundary_time extraction_start, extraction_end; // Segment we actually process
int print_file_reports;
int no_bom; // Set to 1 when no BOM (Byte Order Mark) should be used for files. Note, this might make files unreadable in windows!
ccx_decoder_608_settings settings_608; // Contains the settings for the 608 decoder.
/* subtitle codec type */
@@ -107,8 +109,7 @@ struct ccx_s_options // Options from user parameters
char *srv_port;
int line_terminator_lf; // 0 = CRLF, 1=LF
int noautotimeref; // Do NOT set time automatically?
enum ccx_datasource input_source; // Files, stdin or network
enum ccx_datasource input_source; // Files, stdin or network
};
struct ts_payload
@@ -150,8 +151,8 @@ struct file_report_t
unsigned height;
unsigned aspect_ratio;
unsigned frame_rate;
struct ccx_decoder_608_report_t data_from_608;
struct ccx_decoder_708_report_t data_from_708;
struct ccx_decoder_608_report_t *data_from_608;
struct ccx_decoder_708_report_t *data_from_708;
unsigned dvb_sub_pid[SUB_STREAMS_CNT];
unsigned tlt_sub_pid[SUB_STREAMS_CNT];
unsigned mp4_cc_track_cnt;
@@ -316,6 +317,9 @@ int hex2int (char high, char low);
void timestamp_to_srttime(uint64_t timestamp, char *buffer);
void millis_to_date (uint64_t timestamp, char *buffer) ;
int levenshtein_dist (const uint64_t *s1, const uint64_t *s2, unsigned s1len, unsigned s2len);
#ifndef _WIN32
void m_signal(int sig, void (*func)(int));
#endif
unsigned encode_line (unsigned char *buffer, unsigned char *text);

View File

@@ -17,7 +17,8 @@ ccx_encoders_transcript_format ccx_encoders_default_transcript_settings =
.showCC = 0,
.relativeTimestamp = 1,
.xds = 0,
.useColors = 1
.useColors = 1,
.isFinal = 0
};
static const char *sami_header= // TODO: Revise the <!-- comments
@@ -92,10 +93,10 @@ void write_subtitle_file_header(struct encoder_ctx *ctx,struct ccx_s_write *out)
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)
net_send_header(rcwt_header, sizeof(rcwt_header));
else
write(out->fh, rcwt_header, sizeof(rcwt_header));
break;
case CCX_OF_SPUPNG:
@@ -523,14 +524,17 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
{
int wrote_something = 0 ;
if (ccx_options.extract!=1)
context++;
if (sub->type == CC_608)
{
struct eia608_screen *data = NULL;
for(data = sub->data; sub->nb_data ; sub->nb_data--,data++)
{
// Determine context based on channel. This replaces the code that was above, as this was incomplete (for cases where -12 was used for example)
//if (ccx_options.extract!=1)
//context++;
if (data->my_field == 2)
context++;
new_sentence=1;
if(data->format == SFORMAT_XDS)

View File

@@ -8,6 +8,7 @@ typedef struct {
int relativeTimestamp; // Timestamps relative to start of sample or in UTC?
int xds; // Show XDS or not
int useColors; // Add colors or no colors
int isFinal; // Used to determine if these parameters should be changed afterwards.
} ccx_encoders_transcript_format;

View File

@@ -661,7 +661,7 @@ void general_loop(void *enc_ctx)
else if (ccx_bufferdatatype == CCX_H264) // H.264 data from TS file
{
got = process_avc(buffer, inbuf,&dec_sub);
}
}
else
fatal(CCX_COMMON_EXIT_BUG_BUG, "Unknown data type!");

View File

@@ -581,7 +581,7 @@ int tcp_bind(const char *port, int *family)
if (bind(sockfd, p->ai_addr, p->ai_addrlen) < 0)
{
#if _WIN32
wprintf(L"bind() eror: %ld\n", WSAGetLastError());
wprintf(L"bind() error: %ld\n", WSAGetLastError());
closesocket(sockfd);
#else
mprint("bind() error: %s\n", strerror(errno));

View File

@@ -178,14 +178,16 @@ void writercwtdata (const unsigned char *data)
if (cbcount > 0)
{
writeraw(cbheader,10,&wbout1);
writeraw(cbbuffer,3*cbcount, &wbout1);
if (ccx_options.send_to_srv)
{
net_send_cc(cbheader, 10);
net_send_cc(cbbuffer, 3*cbcount);
}
else
{
writeraw(cbheader,10,&wbout1);
writeraw(cbbuffer,3*cbcount, &wbout1);
}
}
cbcount = 0;
cbempty = 0;
@@ -228,14 +230,16 @@ void writercwtdata (const unsigned char *data)
memcpy(cbbuffer, "\x04\x80\x80", 3); // Field 1 padding
memcpy(cbbuffer+3, "\x05\x80\x80", 3); // Field 2 padding
writeraw(cbheader,10,&wbout1);
writeraw(cbbuffer,3*cbcount, &wbout1);
if (ccx_options.send_to_srv)
{
net_send_cc(cbheader, 10);
net_send_cc(cbbuffer, 3*cbcount);
}
else
{
writeraw(cbheader,10,&wbout1);
writeraw(cbbuffer,3*cbcount, &wbout1);
}
cbcount = 0;
cbempty = 0;

View File

@@ -230,10 +230,12 @@ void set_output_format (const char *format)
if (ccx_options.date_format==ODF_NONE)
ccx_options.date_format=ODF_HHMMSSMS;
// Sets the right things so that timestamps and the mode are printed.
ccx_options.transcript_settings.showStartTime = 1;
ccx_options.transcript_settings.showEndTime = 1;
ccx_options.transcript_settings.showCC = 0;
ccx_options.transcript_settings.showMode = 1;
if (!ccx_options.transcript_settings.isFinal){
ccx_options.transcript_settings.showStartTime = 1;
ccx_options.transcript_settings.showEndTime = 1;
ccx_options.transcript_settings.showCC = 0;
ccx_options.transcript_settings.showMode = 1;
}
}
else if (strcmp (format,"report")==0)
{
@@ -346,7 +348,7 @@ void usage (void)
mprint (" -1, -2, -12: Output Field 1 data, Field 2 data, or both\n");
mprint (" (DEFAULT is -1)\n");
mprint (" -cc2: When in srt/sami mode, process captions in channel 2\n");
mprint (" instead channel 1.\n");
mprint (" instead of channel 1.\n");
mprint ("-svc --service N,N...: Enabled CEA-708 captions processing for the listed\n");
mprint (" services. The parameter is a command delimited list\n");
mprint (" of services numbers, such as \"1,2\" to process the\n");
@@ -475,6 +477,8 @@ void usage (void)
mprint (" affects Teletext in timed transcript with -datets.\n");
mprint ("\n");
mprint ("Options that affect what kind of output will be produced:\n");
mprint(" -nobom: Do not append a BOM (Byte Order Mark) to output files.");
mprint(" Note that this may break files when using Windows.");
mprint (" -unicode: Encode subtitles in Unicode instead of Latin-1.\n");
mprint (" -utf8: Encode subtitles in UTF-8 (no longer needed.\n");
mprint (" because UTF-8 is now the default).\n");
@@ -861,6 +865,9 @@ void parse_parameters (int argc, char *argv[])
ccx_options.nofontcolor=1;
continue;
}
if (strcmp(argv[i], "-nobom") == 0){
ccx_options.no_bom = 1;
}
if (strcmp (argv[i],"-nots")==0 ||
strcmp (argv[i],"--notypesetting")==0)
{
@@ -1259,7 +1266,9 @@ void parse_parameters (int argc, char *argv[])
}
if (strcmp (argv[i],"-xds")==0)
{
ccx_options.transcript_settings.xds = 1;
if (!ccx_options.transcript_settings.isFinal){
ccx_options.transcript_settings.xds = 1;
}
continue;
}
if (strcmp (argv[i],"-xdsdebug")==0)
@@ -1421,11 +1430,15 @@ void parse_parameters (int argc, char *argv[])
if (strcmp (argv[i],"-UCLA")==0 || strcmp (argv[i],"-ucla")==0)
{
ccx_options.millis_separator='.';
ccx_options.transcript_settings.showStartTime = 1;
ccx_options.transcript_settings.showEndTime = 1;
ccx_options.transcript_settings.showCC = 1;
ccx_options.transcript_settings.showMode = 1;
ccx_options.transcript_settings.relativeTimestamp = 0;
ccx_options.no_bom = 1;
if (!ccx_options.transcript_settings.isFinal){
ccx_options.transcript_settings.showStartTime = 1;
ccx_options.transcript_settings.showEndTime = 1;
ccx_options.transcript_settings.showCC = 1;
ccx_options.transcript_settings.showMode = 1;
ccx_options.transcript_settings.relativeTimestamp = 0;
ccx_options.transcript_settings.isFinal = 1;
}
continue;
}
if (strcmp (argv[i],"-lf")==0 || strcmp (argv[i],"-LF")==0)
@@ -1485,13 +1498,15 @@ void parse_parameters (int argc, char *argv[])
if (strlen(format) == 7){
if (ccx_options.date_format == ODF_NONE)
ccx_options.date_format = ODF_HHMMSSMS; // Necessary for displaying times, if any would be used.
ccx_options.transcript_settings.showStartTime = format[0]-'0';
ccx_options.transcript_settings.showEndTime = format[1] - '0';
ccx_options.transcript_settings.showMode = format[2] - '0';
ccx_options.transcript_settings.showCC = format[3] - '0';
ccx_options.transcript_settings.relativeTimestamp = format[4] - '0';
ccx_options.transcript_settings.xds = format[5] - '0';
ccx_options.transcript_settings.useColors = format[6] - '0';
if (!ccx_options.transcript_settings.isFinal){
ccx_options.transcript_settings.showStartTime = format[0] - '0';
ccx_options.transcript_settings.showEndTime = format[1] - '0';
ccx_options.transcript_settings.showMode = format[2] - '0';
ccx_options.transcript_settings.showCC = format[3] - '0';
ccx_options.transcript_settings.relativeTimestamp = format[4] - '0';
ccx_options.transcript_settings.xds = format[5] - '0';
ccx_options.transcript_settings.useColors = format[6] - '0';
}
i++;
}
else {

View File

@@ -204,7 +204,7 @@ void params_dump(void)
}
void print_file_report(void)
void print_file_report(void)
{
#define Y_N(cond) ((cond) ? "Yes" : "No")
@@ -212,6 +212,12 @@ void print_file_report(void)
switch (ccx_options.input_source)
{
case CCX_DS_FILE:
if (current_file < 0)
{
printf("file is not openened yet\n");
return;
}
printf("%s\n", inputfile[current_file]);
break;
case CCX_DS_STDIN:
@@ -356,12 +362,12 @@ void print_file_report(void)
if (cc_stats[0] > 0 || cc_stats[1] > 0)
{
printf("XDS: %s\n", Y_N(file_report.data_from_608.xds));
printf("XDS: %s\n", Y_N(file_report.data_from_608->xds));
printf("CC1: %s\n", Y_N(file_report.data_from_608.cc_channels[0]));
printf("CC2: %s\n", Y_N(file_report.data_from_608.cc_channels[1]));
printf("CC3: %s\n", Y_N(file_report.data_from_608.cc_channels[2]));
printf("CC4: %s\n", Y_N(file_report.data_from_608.cc_channels[3]));
printf("CC1: %s\n", Y_N(file_report.data_from_608->cc_channels[0]));
printf("CC2: %s\n", Y_N(file_report.data_from_608->cc_channels[1]));
printf("CC3: %s\n", Y_N(file_report.data_from_608->cc_channels[2]));
printf("CC4: %s\n", Y_N(file_report.data_from_608->cc_channels[3]));
}
printf("CEA-708: %s\n", Y_N(cc_stats[2] > 0 || cc_stats[3] > 0));
@@ -371,15 +377,15 @@ void print_file_report(void)
printf("Services: ");
for (int i = 0; i < CCX_DECODERS_708_MAX_SERVICES; i++)
{
if (file_report.data_from_708.services[i] == 0)
if (file_report.data_from_708->services[i] == 0)
continue;
printf("%d ", i);
}
printf("\n");
printf("Primary Language Present: %s\n", Y_N(file_report.data_from_708.services[1]));
printf("Primary Language Present: %s\n", Y_N(file_report.data_from_708->services[1]));
printf("Secondary Language Present: %s\n", Y_N(file_report.data_from_708.services[2]));
printf("Secondary Language Present: %s\n", Y_N(file_report.data_from_708->services[2]));
}
printf("MPEG-4 Timed Text: %s\n", Y_N(file_report.mp4_cc_track_cnt));

View File

@@ -370,12 +370,12 @@ void telxcc_dump_prev_page (void)
millis_to_date (prev_hide_timestamp, c_temp2);
fdprintf(wbout1.fh,"%s|",c_temp2);
}
if (ccx_options.transcript_settings.showMode){
fdprintf(wbout1.fh, "TLT|");
}
if (ccx_options.transcript_settings.showCC){
fdprintf(wbout1.fh, "%.3u|", bcd_page_to_int(tlt_config.page));
}
if (ccx_options.transcript_settings.showMode){
fdprintf(wbout1.fh, "TLT|");
}
if (wbout1.fh!=-1) fdprintf(wbout1.fh, "%s",page_buffer_prev);
fdprintf(wbout1.fh,"%s",encoded_crlf);
@@ -900,9 +900,15 @@ 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 *) &timestamp, sizeof(uint64_t), &wbout1);
writeraw((unsigned char *) packet, 44, &wbout1);
if (ccx_options.send_to_srv) {
net_send_cc((unsigned char *) &data_unit_id, sizeof(uint8_t));
net_send_cc((unsigned char *) &timestamp, sizeof(uint64_t));
net_send_cc((unsigned char *) packet, 44);
} else {
writeraw((unsigned char *) &data_unit_id, sizeof(uint8_t), &wbout1);
writeraw((unsigned char *) &timestamp, sizeof(uint64_t), &wbout1);
writeraw((unsigned char *) packet, 44, &wbout1);
}
}
void tlt_read_rcwt() {

View File

@@ -1,3 +1,4 @@
#include <signal.h>
#include "ccextractor.h"
static char *text;
@@ -244,3 +245,18 @@ int hex2int (char high, char low)
return -1;
return h*16+l;
}
#ifndef _WIN32
void m_signal(int sig, void (*func)(int))
{
struct sigaction act;
act.sa_handler = func;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if (sigaction(sig, &act, NULL))
perror("sigaction() error");
return;
}
#endif