Skip to content

Commit

Permalink
Added support for encoding into an MCC File. (CCExtractor#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
robdt committed Jun 25, 2019
1 parent 6cb70be commit d7e2b52
Show file tree
Hide file tree
Showing 25 changed files with 1,021 additions and 279 deletions.
2 changes: 1 addition & 1 deletion linux/build
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SRC_FREETYPE="../src/freetype/autofit/autofit.c
../src/freetype/winfonts/winfnt.c"
API_WRAPPERS="$(find ../src/wrappers/ -name '*.c')"
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_ZVBI $SRC_LIBPNG $SRC_HASH $SRC_PROTOBUF $SRC_UTF8PROC $API_WRAPPERS $SRC_FREETYPE"
BLD_LINKER="-lm -zmuldefs -l tesseract -l lept"
BLD_LINKER="-lm -zmuldefs -l tesseract -l lept -luuid"

echo "Running pre-build script..."
./pre-build.sh
Expand Down
18 changes: 15 additions & 3 deletions src/gpacmp4/mp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "lib_ccx.h"
#include "utility.h"
#include "ccx_encoders_common.h"
#include "ccx_encoders_mcc.h"
#include "ccx_common_option.h"
#include "ccx_mp4.h"
#include "activity.h"
Expand Down Expand Up @@ -35,8 +36,10 @@ static int process_avc_sample(struct lib_ccx_ctx *ctx, u32 timescale, GF_AVCConf
u32 i;
s32 signed_cts=(s32) s->CTS_Offset; // Convert from unsigned to signed. GPAC uses u32 but unsigned values are legal.
struct lib_cc_decode *dec_ctx = NULL;
struct encoder_ctx *enc_ctx = NULL;

dec_ctx = update_decoder_list(ctx);
enc_ctx = update_encoder_list(ctx);

set_current_pts(dec_ctx->timing, (s->DTS + signed_cts)*MPEG_CLOCK_FREQ/timescale);
set_fts(dec_ctx->timing);
Expand Down Expand Up @@ -65,7 +68,7 @@ static int process_avc_sample(struct lib_ccx_ctx *ctx, u32 timescale, GF_AVCConf
temp_debug=0;

if (nal_length>0)
do_NAL (dec_ctx, (unsigned char *) &(s->data[i]) ,nal_length, sub);
do_NAL (enc_ctx, dec_ctx, (unsigned char *) &(s->data[i]) ,nal_length, sub);
i += nal_length;
} // outer for
assert(i == s->dataLength);
Expand All @@ -78,8 +81,10 @@ static int process_xdvb_track(struct lib_ccx_ctx *ctx, const char* basename, GF_
int status;

struct lib_cc_decode *dec_ctx = NULL;
struct encoder_ctx *enc_ctx = NULL;

dec_ctx = update_decoder_list(ctx);
enc_ctx = update_encoder_list(ctx);
if((sample_count = gf_isom_get_sample_count(f, track)) < 1)
{
return 0;
Expand All @@ -100,7 +105,7 @@ static int process_xdvb_track(struct lib_ccx_ctx *ctx, const char* basename, GF_
set_current_pts(dec_ctx->timing, (s->DTS + signed_cts)*MPEG_CLOCK_FREQ/timescale);
set_fts(dec_ctx->timing);

process_m2v (dec_ctx, (unsigned char *) s->data,s->dataLength, sub);
process_m2v (enc_ctx, dec_ctx, (unsigned char *) s->data,s->dataLength, sub);
gf_isom_sample_del(&s);
}

Expand Down Expand Up @@ -374,6 +379,9 @@ static int process_clcp(struct lib_ccx_ctx *ctx, struct encoder_ctx *enc_ctx,
ccx_dtvcc_process_data(dec_ctx, (unsigned char *)temp, 4);
cb_708++;
}
if( ctx->write_format == CCX_OF_MCC ) {
mcc_encode_cc_data(enc_ctx, dec_ctx, cc_data, cc_count);
}
}
else //subtype == GF_ISOM_SUBTYPE_C608
{
Expand Down Expand Up @@ -570,7 +578,7 @@ int processmp4 (struct lib_ccx_ctx *ctx, struct ccx_s_mp4Cfg *cfg, char *file)
if (cnf != NULL) {
for (j = 0; j < gf_list_count(cnf->sequenceParameterSets); j++) {
GF_AVCConfigSlot* seqcnf = (GF_AVCConfigSlot*)gf_list_get(cnf->sequenceParameterSets, j);
do_NAL(dec_ctx, (unsigned char *)seqcnf->data, seqcnf->size, &dec_sub);
do_NAL(enc_ctx, dec_ctx, (unsigned char *)seqcnf->data, seqcnf->size, &dec_sub);
}
}
if (process_avc_track(ctx, file, f, i + 1, &dec_sub) != 0) {
Expand Down Expand Up @@ -699,6 +707,10 @@ int processmp4 (struct lib_ccx_ctx *ctx, struct ccx_s_mp4Cfg *cfg, char *file)

ctx->freport.mp4_cc_track_cnt = cc_track_count;

if( (dec_ctx->write_format == CCX_OF_MCC) && (dec_ctx->saw_caption_block == CCX_TRUE) ) {
mp4_ret = 1;
}

return mp4_ret;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib_ccx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ endif (WITH_SHARING)
aux_source_directory ("${PROJECT_SOURCE_DIR}/lib_ccx/" SOURCEFILE)
aux_source_directory ("${PROJECT_SOURCE_DIR}/gpacmp4/" SOURCEFILE)

add_library (ccx ${SOURCEFILE} ccx_dtvcc.h ccx_dtvcc.c)
add_library (ccx ${SOURCEFILE} ccx_dtvcc.h ccx_dtvcc.c ccx_encoders_mcc.c ccx_encoders_mcc.h)
target_link_libraries (ccx ${EXTRA_LIBS})
target_include_directories (ccx PUBLIC ${EXTRA_INCLUDES})

Expand Down
4 changes: 2 additions & 2 deletions src/lib_ccx/activity.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ void activity_progress (int percentage, int cur_min, int cur_sec)
if (!ccx_options.no_progress_bar)
{
if (percentage==-1)
mprint ("\rStreaming | %02d:%02d", cur_min, cur_sec);
mprint ("Streaming | %02d:%02d\r", cur_min, cur_sec);
else
mprint ("\r%3d%% | %02d:%02d",percentage, cur_min, cur_sec);
mprint ("%3d%% | %02d:%02d\r",percentage, cur_min, cur_sec);
if (ccx_options.pes_header_to_stdout || ccx_options.debug_mask&CCX_DMT_DVB) //For PES Header dumping and DVB debug traces
{
mprint("\n");
Expand Down
Loading

0 comments on commit d7e2b52

Please sign in to comment.