Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to determine caption format and write captions #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/mcc_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,6 @@ boolean MccDecodeAddSink( Context*, LinkInfo );
uint8 MccDecodeProcNextBuffer( void*, Buffer* );
uint8 MccDecodeShutdown( void* );

Buffer* decodeMccLine( MccDecodeCtx*, Buffer* );

#endif /* mcc_decode_h */
6 changes: 6 additions & 0 deletions include/mcc_encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ boolean MccEncodeAddSink( Context*, LinkInfo );
uint8 MccEncodeProcNextBuffer( void*, Buffer* );
uint8 MccEncodeShutdown( void* );

/* Exposed for use as a shared library */
boolean generateMccHeader( Context*, CaptionTime* );
boolean sendMccText( Context*, char*, CaptionTime* );
uint16 countChars( uint8*, uint16 );
void compressData( uint8*, uint16, Buffer* );

#endif /* mcc_encode_h */
4 changes: 3 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
################################################################################

DYLIB_NAME = libci.1.0.0.dylib
SO_NAME = libci.so

UNAME := $(shell uname)

Expand Down Expand Up @@ -162,10 +163,11 @@ ci_with_gpac: with_gpac
${CI_SHARED_LIB}: $(OBJS_WITH_PATH)
@echo "\n*** Compiling Caption Inspector Dynamic Library to interface with Python. ***"
clang $(SO_FLAGS) -o ${CI_SHARED_LIB} $(OBJS_IN_OBJ_DIR)
cd ../lib; ln -s ${CI_SHARED_LIB} libci.so

clean:
@echo "*** Cleaning Target Files. ***"
rm -f ${CI_EXECUTABLE} ${CI_SHARED_LIB}
rm -f ${CI_EXECUTABLE} ${CI_SHARED_LIB} ../lib/libci.so
@echo "\n*** Cleaning Object Files. ***"
for i in $(OBJS) ; do ( rm -f ../obj/$$i ) ; done
rm -f ../obj/main.o
Expand Down
3 changes: 1 addition & 2 deletions src/xform/mcc_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
/*----------------------------------------------------------------------------*/

static Buffer* expandMccLine( Buffer* );
static Buffer* decodeMccLine( MccDecodeCtx*, Buffer* );
static uint8 mccCharCount( char );
static void addMultipleFaZeroZero( uint8, uint8*, uint16* );
static void expandMccCode( uint8, uint8*, uint16* );
Expand Down Expand Up @@ -281,7 +280,7 @@ static Buffer* expandMccLine( Buffer* buffPtr ) {
| (Specifically: SMPTE ST 334-2:2015 - Revision of SMPTE 334-2-2007)
| CEA-708-D - CEA Standard - Digital Television (DTV) Closed Captioning - August 2008
-------------------------------------------------------------------------------*/
static Buffer* decodeMccLine( MccDecodeCtx* ctxPtr, Buffer* buffPtr ) {
Buffer* decodeMccLine( MccDecodeCtx* ctxPtr, Buffer* buffPtr ) {
ASSERT(buffPtr);
ASSERT(buffPtr->dataPtr);
ASSERT(buffPtr->numElements);
Expand Down
12 changes: 4 additions & 8 deletions src/xform/mcc_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ const char* DayOfWeekStr[7] = { "Sunday", "Monday", "Tuesday", "Wednesday",
/*-- Private Member Declarations --*/
/*----------------------------------------------------------------------------*/

static boolean generateMccHeader( Context*, CaptionTime* );
static void addFillPacket( Context*, CaptionTime* );
static CaptionTime convertCaptionTime( Context*, CaptionTime* );
static boolean sendMccText( Context*, char*, CaptionTime* );
static Buffer* addBoilerplate( MccEncodeCtx*, Buffer* );
static uint16 countChars( uint8*, uint16 );
static void compressData( uint8*, uint16, Buffer* );

/*----------------------------------------------------------------------------*/
/*-- Public Member Functions --*/
Expand Down Expand Up @@ -234,7 +230,7 @@ uint8 MccEncodeShutdown( void* rootCtxPtr ) {
| This function will build the standard MCC Header and send it line by line
| to the next component in the pipeline.
-------------------------------------------------------------------------------*/
static boolean generateMccHeader( Context* ctxPtr, CaptionTime* captionTimePtr ) {
boolean generateMccHeader( Context* ctxPtr, CaptionTime* captionTimePtr ) {
uuid_t binuuid;
char uuidStr[50];
char dateStr[50];
Expand Down Expand Up @@ -463,7 +459,7 @@ static CaptionTime convertCaptionTime( Context* rootCtxPtr, CaptionTime* inCapti
| DESCRIPTION:
| This function sends a line of text to the next component in the pipeline.
-------------------------------------------------------------------------------*/
static boolean sendMccText( Context* ctxPtr, char* textStr, CaptionTime* captionTimePtr ) {
boolean sendMccText( Context* ctxPtr, char* textStr, CaptionTime* captionTimePtr ) {
Buffer* outputBuffer = NewBuffer(BUFFER_TYPE_BYTES, (strlen(textStr)+1));
strcpy((char*)outputBuffer->dataPtr, textStr);

Expand Down Expand Up @@ -553,7 +549,7 @@ static Buffer* addBoilerplate( MccEncodeCtx* ctxPtr, Buffer* inBufferPtr ) {
| U E1h 00h 00h 00h
| Z 00h
-------------------------------------------------------------------------------*/
static uint16 countChars( uint8* dataPtr, uint16 numElements ) {
uint16 countChars( uint8* dataPtr, uint16 numElements ) {
uint16 numChars = 1;

while( numElements > 0 ) {
Expand Down Expand Up @@ -663,7 +659,7 @@ static uint16 countChars( uint8* dataPtr, uint16 numElements ) {
| U E1h 00h 00h 00h
| Z 00h
-------------------------------------------------------------------------------*/
static void compressData( uint8* dataPtr, uint16 numElements, Buffer* outBufPtr ) {
void compressData( uint8* dataPtr, uint16 numElements, Buffer* outBufPtr ) {
uint8* outDataPtr = &outBufPtr->dataPtr[12];

while( numElements > 0 ) {
Expand Down