Skip to content

Commit

Permalink
[FEATURE] Added support for encoding into an MCC File. (#733) (#1097)
Browse files Browse the repository at this point in the history
* [FEATURE] Added support for encoding into an MCC File. (#733)

* Missed deleting an unused variable declaration as part of a refactor.
  • Loading branch information
robdt authored and cfsmp3 committed Sep 21, 2019
1 parent 7598225 commit 8fec59e
Show file tree
Hide file tree
Showing 28 changed files with 1,056 additions and 280 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGES.TXT
@@ -1,5 +1,5 @@
0.89 (TBD) 0.89 (TBD)
----------------- - New: Added support to output captions to MCC file (#733).
- Fix: ccx_demuxer_mxf.c: Parse framerate from MXF captions to fix caption timings. - Fix: ccx_demuxer_mxf.c: Parse framerate from MXF captions to fix caption timings.
- Fix: hardsubx_decoder.c: Fix memory leaks using Leptonica API. - Fix: hardsubx_decoder.c: Fix memory leaks using Leptonica API.
- Fix: linux/Makefile.am: added some sources to enable rpms to be created. - Fix: linux/Makefile.am: added some sources to enable rpms to be created.
Expand Down
2 changes: 2 additions & 0 deletions linux/Makefile.am
Expand Up @@ -156,6 +156,8 @@ ccextractor_SOURCES = \
../src/lib_ccx/ccx_encoders_g608.c \ ../src/lib_ccx/ccx_encoders_g608.c \
../src/lib_ccx/ccx_encoders_helpers.c \ ../src/lib_ccx/ccx_encoders_helpers.c \
../src/lib_ccx/ccx_encoders_helpers.h \ ../src/lib_ccx/ccx_encoders_helpers.h \
../src/lib_ccx/ccx_encoders_mcc.c \
../src/lib_ccx/ccx_encoders_mcc.h \
../src/lib_ccx/ccx_encoders_python.c \ ../src/lib_ccx/ccx_encoders_python.c \
../src/lib_ccx/ccx_encoders_sami.c \ ../src/lib_ccx/ccx_encoders_sami.c \
../src/lib_ccx/ccx_encoders_smptett.c \ ../src/lib_ccx/ccx_encoders_smptett.c \
Expand Down
2 changes: 2 additions & 0 deletions mac/Makefile.am
Expand Up @@ -155,6 +155,8 @@ ccextractor_SOURCES = \
../src/lib_ccx/ccx_encoders_g608.c \ ../src/lib_ccx/ccx_encoders_g608.c \
../src/lib_ccx/ccx_encoders_helpers.c \ ../src/lib_ccx/ccx_encoders_helpers.c \
../src/lib_ccx/ccx_encoders_helpers.h \ ../src/lib_ccx/ccx_encoders_helpers.h \
../src/lib_ccx/ccx_encoders_mcc.c \
../src/lib_ccx/ccx_encoders_mcc.h \
../src/lib_ccx/ccx_encoders_python.c \ ../src/lib_ccx/ccx_encoders_python.c \
../src/lib_ccx/ccx_encoders_sami.c \ ../src/lib_ccx/ccx_encoders_sami.c \
../src/lib_ccx/ccx_encoders_smptett.c \ ../src/lib_ccx/ccx_encoders_smptett.c \
Expand Down
18 changes: 15 additions & 3 deletions src/gpacmp4/mp4.c
Expand Up @@ -6,6 +6,7 @@
#include "lib_ccx.h" #include "lib_ccx.h"
#include "utility.h" #include "utility.h"
#include "ccx_encoders_common.h" #include "ccx_encoders_common.h"
#include "ccx_encoders_mcc.h"
#include "ccx_common_option.h" #include "ccx_common_option.h"
#include "ccx_mp4.h" #include "ccx_mp4.h"
#include "activity.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; u32 i;
s32 signed_cts=(s32) s->CTS_Offset; // Convert from unsigned to signed. GPAC uses u32 but unsigned values are legal. 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 lib_cc_decode *dec_ctx = NULL;
struct encoder_ctx *enc_ctx = NULL;


dec_ctx = update_decoder_list(ctx); 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_current_pts(dec_ctx->timing, (s->DTS + signed_cts)*MPEG_CLOCK_FREQ/timescale);
set_fts(dec_ctx->timing); 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; temp_debug=0;


if (nal_length>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; i += nal_length;
} // outer for } // outer for
assert(i == s->dataLength); 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; int status;


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


dec_ctx = update_decoder_list(ctx); dec_ctx = update_decoder_list(ctx);
enc_ctx = update_encoder_list(ctx);
if((sample_count = gf_isom_get_sample_count(f, track)) < 1) if((sample_count = gf_isom_get_sample_count(f, track)) < 1)
{ {
return 0; 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_current_pts(dec_ctx->timing, (s->DTS + signed_cts)*MPEG_CLOCK_FREQ/timescale);
set_fts(dec_ctx->timing); 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); 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); ccx_dtvcc_process_data(dec_ctx, (unsigned char *)temp, 4);
cb_708++; 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 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) { if (cnf != NULL) {
for (j = 0; j < gf_list_count(cnf->sequenceParameterSets); j++) { for (j = 0; j < gf_list_count(cnf->sequenceParameterSets); j++) {
GF_AVCConfigSlot* seqcnf = (GF_AVCConfigSlot*)gf_list_get(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) { 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; 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; return mp4_ret;
} }


Expand Down
2 changes: 1 addition & 1 deletion src/lib_ccx/CMakeLists.txt
Expand Up @@ -57,7 +57,7 @@ endif (WITH_SHARING)
aux_source_directory ("${PROJECT_SOURCE_DIR}/lib_ccx/" SOURCEFILE) aux_source_directory ("${PROJECT_SOURCE_DIR}/lib_ccx/" SOURCEFILE)
aux_source_directory ("${PROJECT_SOURCE_DIR}/gpacmp4/" 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_link_libraries (ccx ${EXTRA_LIBS})
target_include_directories (ccx PUBLIC ${EXTRA_INCLUDES}) target_include_directories (ccx PUBLIC ${EXTRA_INCLUDES})


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

0 comments on commit 8fec59e

Please sign in to comment.