| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 1998-2010, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: createindex.c $ |
|---|
| 11 | * $brcm_Revision: 3 $ |
|---|
| 12 | * $brcm_Date: 6/22/10 11:13a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/lib/bcmplayer/utils/createindex.c $ |
|---|
| 19 | * |
|---|
| 20 | * 3 6/22/10 11:13a erickson |
|---|
| 21 | * SW7405-4465: add BNAV_Indexer_Settings.ptsBasedFrameRate for PTS-based |
|---|
| 22 | * offline indexing |
|---|
| 23 | * |
|---|
| 24 | * 2 2/26/10 12:13p erickson |
|---|
| 25 | * CDSTRMANA-294: SCT6 is a required intermediate format for field-encoded |
|---|
| 26 | * MPEG |
|---|
| 27 | * |
|---|
| 28 | * Irvine_BSEAVSW_Devel/21 3/6/06 1:21p erickson |
|---|
| 29 | * PR19853: added VC1 PES support |
|---|
| 30 | * |
|---|
| 31 | * Irvine_BSEAVSW_Devel/20 2/6/06 1:04p ahulse |
|---|
| 32 | * PR17108: Call to BDBG_Init is now needed after 64bit cpu support rework |
|---|
| 33 | * |
|---|
| 34 | * Irvine_BSEAVSW_Devel/19 1/6/06 10:16a erickson |
|---|
| 35 | * PR17108: updated for magnum basemodules and 64 bit cpus |
|---|
| 36 | * |
|---|
| 37 | * Irvine_BSEAVSW_Devel/18 7/13/05 2:12p erickson |
|---|
| 38 | * PR16138: added AVC nav support |
|---|
| 39 | * |
|---|
| 40 | * Irvine_BSEAVSW_Devel/17 7/7/05 1:18p erickson |
|---|
| 41 | * PR16138: added help |
|---|
| 42 | * |
|---|
| 43 | * Irvine_BSEAVSW_Devel/16 4/21/05 4:51p erickson |
|---|
| 44 | * PR14451: added quiet mode for debug |
|---|
| 45 | * |
|---|
| 46 | * Irvine_BSEAVSW_Devel/15 3/18/05 10:00a erickson |
|---|
| 47 | * PR14451: added support for more inputs and outputs, changed command |
|---|
| 48 | * line params to accomodate |
|---|
| 49 | * |
|---|
| 50 | * Irvine_BSEAVSW_Devel/14 3/14/05 5:00p erickson |
|---|
| 51 | * PR14451: added 6 word SCT support |
|---|
| 52 | * |
|---|
| 53 | ****************************************************************/ |
|---|
| 54 | #include "bstd.h" |
|---|
| 55 | #include <stdio.h> |
|---|
| 56 | #include <stdlib.h> |
|---|
| 57 | #include <string.h> /* strcmp() */ |
|---|
| 58 | #include <sys/stat.h> |
|---|
| 59 | #if !defined(__vxworks) |
|---|
| 60 | #include <sys/timeb.h> /* ftime() */ |
|---|
| 61 | #endif |
|---|
| 62 | #include "tsindexer.h" |
|---|
| 63 | #include "bcmindexer.h" |
|---|
| 64 | |
|---|
| 65 | #define NUM_STREAM_BYTES_TO_READ (188*1024) |
|---|
| 66 | #define NUM_SC4_BYTES_TO_READ (sizeof(BSCT_Entry)*1024) |
|---|
| 67 | #define NUM_SC6_BYTES_TO_READ (sizeof(BSCT_SixWord_Entry)*1024) |
|---|
| 68 | |
|---|
| 69 | int g_quiet = 0; |
|---|
| 70 | |
|---|
| 71 | void TimetoString( long ctime, char *outStr ) |
|---|
| 72 | { |
|---|
| 73 | long hh,mm,ss; |
|---|
| 74 | char *p; |
|---|
| 75 | |
|---|
| 76 | ss = ctime % 60; |
|---|
| 77 | mm = (ctime/60) % 60; |
|---|
| 78 | hh = (ctime/3600) % 24; |
|---|
| 79 | |
|---|
| 80 | p = outStr; |
|---|
| 81 | *p++ = (hh/10) + 0x30; |
|---|
| 82 | *p++ = (hh%10) + 0x30; |
|---|
| 83 | *p++ = ':'; |
|---|
| 84 | *p++ = (mm/10) + 0x30; |
|---|
| 85 | *p++ = (mm%10) + 0x30; |
|---|
| 86 | *p++ = ':'; |
|---|
| 87 | *p++ = (ss/10) + 0x30; |
|---|
| 88 | *p++ = (ss%10) + 0x30; |
|---|
| 89 | *p++ = 0; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | double getms( void ) |
|---|
| 93 | { |
|---|
| 94 | #if defined(__vxworks) |
|---|
| 95 | return 0; |
|---|
| 96 | #else |
|---|
| 97 | double usec1; |
|---|
| 98 | struct timeb t; |
|---|
| 99 | |
|---|
| 100 | ftime( &t ); |
|---|
| 101 | |
|---|
| 102 | usec1 = t.time + t.millitm/1000.0; |
|---|
| 103 | return usec1; |
|---|
| 104 | #endif |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | void OffsetToString( long offset, char *outStr ) |
|---|
| 108 | { |
|---|
| 109 | long mb, kb, b; |
|---|
| 110 | |
|---|
| 111 | b = offset % 1000; |
|---|
| 112 | kb = (offset/1000)%1000; |
|---|
| 113 | mb = (offset/(1000*1000)) % (1000*1000); |
|---|
| 114 | |
|---|
| 115 | sprintf( outStr, "%ld,%03ld,%03ld", mb, kb, b ); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | * Feed from tsindexer to bcmindexer. |
|---|
| 120 | **/ |
|---|
| 121 | static unsigned long write_to_bcmindexer( const void *p_bfr, |
|---|
| 122 | unsigned long numEntries, |
|---|
| 123 | unsigned long entrySize, |
|---|
| 124 | void *fp ) |
|---|
| 125 | { |
|---|
| 126 | BSTD_UNUSED(entrySize); |
|---|
| 127 | return BNAV_Indexer_Feed((BNAV_Indexer_Handle)fp, (void*)p_bfr, numEntries); |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | void printHeader() |
|---|
| 131 | { |
|---|
| 132 | printf("\ncreateindex, built on %s\n\n", __DATE__); |
|---|
| 133 | printf("Broadcom Corp. Confidential\n"); |
|---|
| 134 | printf("Copyright 1998-2005 Broadcom Corp. All Rights Reserved.\n\n"); |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | static FILE *g_mpegFile = NULL; /* global hack */ |
|---|
| 138 | int mpegSizeCallback(BNAV_Indexer_Handle handle, unsigned long *hi, unsigned long *lo) |
|---|
| 139 | { |
|---|
| 140 | #ifdef LINUX |
|---|
| 141 | off_t o = ftello(g_mpegFile); |
|---|
| 142 | #else |
|---|
| 143 | off_t o = ftell(g_mpegFile); |
|---|
| 144 | #endif |
|---|
| 145 | BSTD_UNUSED(handle); |
|---|
| 146 | if (o == -1) |
|---|
| 147 | return -1; |
|---|
| 148 | *hi = o >> 32; |
|---|
| 149 | *lo = o & 0xFFFFFFFF; |
|---|
| 150 | return 0; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | typedef enum b_input { |
|---|
| 154 | b_input_4word_sct = 0, |
|---|
| 155 | b_input_6word_sct, |
|---|
| 156 | b_input_mpeg_ts, |
|---|
| 157 | b_input_mpeg_pes, |
|---|
| 158 | b_input_avc_ts, |
|---|
| 159 | b_input_vc1_pes, |
|---|
| 160 | b_input_unknown |
|---|
| 161 | } b_input; |
|---|
| 162 | |
|---|
| 163 | const char *b_input_str[] = { |
|---|
| 164 | "4word_sct", |
|---|
| 165 | "6word_sct", |
|---|
| 166 | "mpeg_ts", |
|---|
| 167 | "mpeg_pes", |
|---|
| 168 | "avc_ts", |
|---|
| 169 | "vc1_pes" |
|---|
| 170 | }; |
|---|
| 171 | |
|---|
| 172 | typedef enum b_output { |
|---|
| 173 | b_output_4word_sct = 0, |
|---|
| 174 | b_output_6word_sct, |
|---|
| 175 | b_output_bcm, |
|---|
| 176 | b_output_unknown |
|---|
| 177 | } b_output; |
|---|
| 178 | |
|---|
| 179 | const char *b_output_str[] = { |
|---|
| 180 | "4word_sct", |
|---|
| 181 | "6word_sct", |
|---|
| 182 | "bcm" |
|---|
| 183 | }; |
|---|
| 184 | |
|---|
| 185 | /** |
|---|
| 186 | * This is the entry point for VxWorks. You'll need to look at the enum values. |
|---|
| 187 | **/ |
|---|
| 188 | int createindex(const char *inputfile, const char *outputfile, int pid, |
|---|
| 189 | b_input input, b_output output, |
|---|
| 190 | int timestamp_enabled, BNAV_Version navVersion, int simulatedFrameRate ) |
|---|
| 191 | { |
|---|
| 192 | unsigned char *bfr; |
|---|
| 193 | FILE *fin, *fout; |
|---|
| 194 | sTsIndexer *indexer = NULL; |
|---|
| 195 | BNAV_Indexer_Handle bcmindexer = NULL; |
|---|
| 196 | unsigned long readBytes; |
|---|
| 197 | unsigned long totalBytes = 0; |
|---|
| 198 | double time1, time2; |
|---|
| 199 | unsigned long numBytesToRead; |
|---|
| 200 | int index_input = (input == b_input_4word_sct) || (input == b_input_6word_sct); |
|---|
| 201 | bool sct6; |
|---|
| 202 | |
|---|
| 203 | BDBG_Init(); |
|---|
| 204 | |
|---|
| 205 | printHeader(); |
|---|
| 206 | |
|---|
| 207 | time1 = getms(); |
|---|
| 208 | |
|---|
| 209 | switch (input) { |
|---|
| 210 | case b_input_4word_sct: |
|---|
| 211 | numBytesToRead = NUM_SC4_BYTES_TO_READ; |
|---|
| 212 | break; |
|---|
| 213 | case b_input_6word_sct: |
|---|
| 214 | numBytesToRead = NUM_SC6_BYTES_TO_READ; |
|---|
| 215 | break; |
|---|
| 216 | default: |
|---|
| 217 | /* reading mpeg */ |
|---|
| 218 | numBytesToRead = NUM_STREAM_BYTES_TO_READ; |
|---|
| 219 | break; |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | if (pid == 0 && !index_input) |
|---|
| 223 | printf( |
|---|
| 224 | "WARNING\n" |
|---|
| 225 | "WARNING\n" |
|---|
| 226 | "WARNING: Are you sure you want PID == 0 ??????????????\n" |
|---|
| 227 | "WARNING\n" |
|---|
| 228 | "WARNING\n" |
|---|
| 229 | "\n" |
|---|
| 230 | ); |
|---|
| 231 | if (index_input && output != b_output_bcm) { |
|---|
| 232 | printf("If your input is a start code index, then -bcm is required.\n"); |
|---|
| 233 | exit(1); |
|---|
| 234 | } |
|---|
| 235 | |
|---|
| 236 | bfr = malloc( numBytesToRead ); |
|---|
| 237 | |
|---|
| 238 | if (!strcmp(inputfile, "-")) { |
|---|
| 239 | fin = stdin; |
|---|
| 240 | inputfile = "stdin"; |
|---|
| 241 | } |
|---|
| 242 | else if( (fin = fopen(inputfile, "rb" )) == NULL ) |
|---|
| 243 | { |
|---|
| 244 | printf("Unable to open input file %s\n", inputfile); |
|---|
| 245 | exit(255); |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | if (!strcmp(outputfile, "-")) { |
|---|
| 249 | fout = stdout; |
|---|
| 250 | outputfile = "stdout"; |
|---|
| 251 | } |
|---|
| 252 | else if( (fout = fopen(outputfile, "wb" )) == NULL ) |
|---|
| 253 | { |
|---|
| 254 | printf("Unable to open output file %s\n", outputfile); |
|---|
| 255 | fclose(fin); |
|---|
| 256 | exit(255); |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | printf("Processing %s 0x%X from %s input file '%s'.\n", |
|---|
| 260 | (input == b_input_mpeg_pes || input == b_input_vc1_pes)?"StreamID":"PID", pid, |
|---|
| 261 | b_input_str[input], inputfile); |
|---|
| 262 | printf("Writing %s index to '%s'.\n", b_output_str[output], outputfile); |
|---|
| 263 | |
|---|
| 264 | /* only use sct4 if we must. sct6 is a required intermediate format for AVC, field-encoded MPEG, etc. */ |
|---|
| 265 | sct6 = (input != b_input_4word_sct) && (output != b_output_4word_sct); |
|---|
| 266 | |
|---|
| 267 | if (output == b_output_bcm) |
|---|
| 268 | { |
|---|
| 269 | BNAV_Indexer_Settings settings; |
|---|
| 270 | BNAV_Indexer_GetDefaultSettings(&settings); |
|---|
| 271 | settings.writeCallback = (INDEX_WRITE_CB)fwrite; |
|---|
| 272 | settings.filePointer = (void *)fout; |
|---|
| 273 | settings.navVersion = navVersion; |
|---|
| 274 | settings.transportTimestampEnabled = timestamp_enabled; |
|---|
| 275 | /* createindex must generate a timestamp somehow. it is either PTS or simulated framerate. |
|---|
| 276 | if framerate not specified, we use PTS. */ |
|---|
| 277 | settings.ptsBasedFrameRate = (simulatedFrameRate == 0); |
|---|
| 278 | settings.simulatedFrameRate = simulatedFrameRate; |
|---|
| 279 | settings.sctVersion = sct6?BSCT_Version6wordEntry:BSCT_Version40bitOffset; |
|---|
| 280 | if (input == b_input_avc_ts) { |
|---|
| 281 | settings.videoFormat = BNAV_Indexer_VideoFormat_AVC; |
|---|
| 282 | settings.navVersion = BNAV_Version_AVC; |
|---|
| 283 | } |
|---|
| 284 | else if (input == b_input_vc1_pes) { |
|---|
| 285 | settings.videoFormat = BNAV_Indexer_VideoFormat_VC1; |
|---|
| 286 | settings.navVersion = BNAV_Version_VC1_PES; |
|---|
| 287 | } |
|---|
| 288 | else { |
|---|
| 289 | settings.videoFormat = BNAV_Indexer_VideoFormat_MPEG2; |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | if (!index_input) { |
|---|
| 293 | settings.mpegSizeCallback = mpegSizeCallback; |
|---|
| 294 | g_mpegFile = fin; |
|---|
| 295 | } |
|---|
| 296 | if (BNAV_Indexer_Open(&bcmindexer, &settings)) { |
|---|
| 297 | exit(1); |
|---|
| 298 | } |
|---|
| 299 | } |
|---|
| 300 | if (!index_input) |
|---|
| 301 | { |
|---|
| 302 | tsindex_settings settings; |
|---|
| 303 | tsindex_settings_init(&settings); |
|---|
| 304 | settings.pid = pid; |
|---|
| 305 | settings.entry_size = sct6?6:4; |
|---|
| 306 | if (output == b_output_bcm) { |
|---|
| 307 | settings.cb = (INDEX_WRITE_CB)write_to_bcmindexer; |
|---|
| 308 | settings.fp = (void*)bcmindexer; |
|---|
| 309 | } |
|---|
| 310 | else { |
|---|
| 311 | settings.cb = (INDEX_WRITE_CB)fwrite; |
|---|
| 312 | settings.fp = (void*)fout; |
|---|
| 313 | } |
|---|
| 314 | if (input == b_input_avc_ts) { |
|---|
| 315 | /* This is AVC */ |
|---|
| 316 | settings.start_code_lo = 0x00; |
|---|
| 317 | settings.start_code_hi = 0xFF; |
|---|
| 318 | settings.is_avc = 1; |
|---|
| 319 | } |
|---|
| 320 | indexer = tsindex_allocate_ex(&settings); |
|---|
| 321 | if (input == b_input_mpeg_pes) |
|---|
| 322 | tsindex_setPesId( indexer, pid); |
|---|
| 323 | } |
|---|
| 324 | |
|---|
| 325 | while( (readBytes = fread( bfr, 1, numBytesToRead, fin )) != 0 ) |
|---|
| 326 | { |
|---|
| 327 | totalBytes += readBytes; |
|---|
| 328 | |
|---|
| 329 | if ( totalBytes%(1*numBytesToRead) == 0 ) |
|---|
| 330 | { |
|---|
| 331 | double rate1; char timeStr[32], offsetStr[32]; |
|---|
| 332 | time2 = getms() - time1; |
|---|
| 333 | rate1 = (totalBytes/1024)/time2; |
|---|
| 334 | TimetoString( (long)time2, timeStr ); |
|---|
| 335 | OffsetToString( totalBytes, offsetStr ); |
|---|
| 336 | if (!g_quiet) |
|---|
| 337 | printf( "Byte Offset: %s Rate: %0.1fK/s, Elapsed Time: %s \r", offsetStr, rate1, timeStr ); |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | switch (input) { |
|---|
| 341 | case b_input_vc1_pes: |
|---|
| 342 | BNAV_Indexer_FeedPES(bcmindexer, bfr, readBytes); |
|---|
| 343 | break; |
|---|
| 344 | case b_input_4word_sct: |
|---|
| 345 | BNAV_Indexer_Feed(bcmindexer, bfr, readBytes/sizeof(BSCT_Entry) ); |
|---|
| 346 | break; |
|---|
| 347 | case b_input_6word_sct: |
|---|
| 348 | BNAV_Indexer_Feed(bcmindexer, bfr, readBytes/sizeof(BSCT_SixWord_Entry)); |
|---|
| 349 | break; |
|---|
| 350 | case b_input_mpeg_pes: |
|---|
| 351 | tsindex_feedPes( indexer, bfr, readBytes ); |
|---|
| 352 | break; |
|---|
| 353 | default: |
|---|
| 354 | tsindex_feed( indexer, bfr, readBytes ); |
|---|
| 355 | break; |
|---|
| 356 | } |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | if (bcmindexer) |
|---|
| 360 | BNAV_Indexer_Close( bcmindexer ); |
|---|
| 361 | if (indexer) |
|---|
| 362 | tsindex_free( indexer ); |
|---|
| 363 | |
|---|
| 364 | fclose( fin ); |
|---|
| 365 | fclose( fout ); |
|---|
| 366 | free( bfr ); |
|---|
| 367 | if (!g_quiet) { |
|---|
| 368 | printf("\n"); |
|---|
| 369 | } |
|---|
| 370 | exit(0); |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | #if !defined(__vxworks) |
|---|
| 374 | void printUsage() |
|---|
| 375 | { |
|---|
| 376 | printf( |
|---|
| 377 | "Parses an MPEG stream or SCT index and creates either a SCT index\n" |
|---|
| 378 | " or Broadcom index.\n" |
|---|
| 379 | "\n" |
|---|
| 380 | "Usage: createindex inputfile outputfile [pid] [-in=XXX] [-out=XXX] [others, see below]\n" |
|---|
| 381 | "\n" |
|---|
| 382 | ); |
|---|
| 383 | printf( |
|---|
| 384 | " inputfile Defaults to MPEG2 TS stream, unless specified with -in param.\n" |
|---|
| 385 | " outputfile Defaults to SCT index if .sct or .idx suffix, or BCM index if\n" |
|---|
| 386 | " .bcm or .nav suffix, unless specified with -out param.\n" |
|---|
| 387 | " pid PID (or stream id in PES mode). Not needed if inputfile is\n" |
|---|
| 388 | " a startcode index. Prefix with 0x for hex, otherwise decimal.\n" |
|---|
| 389 | "\n" |
|---|
| 390 | ); |
|---|
| 391 | printf( |
|---|
| 392 | "Optional Parameters:\n" |
|---|
| 393 | " -in=ts inputfile is a MPEG2 TS stream\n" |
|---|
| 394 | " -in=avc_ts inputfile is a AVC TS stream\n" |
|---|
| 395 | " -in=vc1_pes inputfile is a VC1 PES stream\n" |
|---|
| 396 | " -in=pes inputfile is a MPEG2 PES stream\n" |
|---|
| 397 | " -in=sct inputfile is a 4 word startcode index\n" |
|---|
| 398 | " -in=sct6 inputfile is a 6 word startcode index\n" |
|---|
| 399 | ); |
|---|
| 400 | printf( |
|---|
| 401 | " -out=sct outputfile will be a 4 word startcode index\n" |
|---|
| 402 | " -out=sct6 outputfile will be a 6 word startcode index\n" |
|---|
| 403 | " -out=bcm outputfile will be a BCM index file\n" |
|---|
| 404 | " -timestamp transport timestamping present in the MPEG stream.\n" |
|---|
| 405 | " -bcmver VERSION specify the BCM index format. See eBcmNavVersion.\n" |
|---|
| 406 | " -framerate RATE specify the frame rate for timestamp emulation (default=30).\n" |
|---|
| 407 | " -q quiet. do not print status line.\n" |
|---|
| 408 | ); |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | int main( int argc, char **argv ) |
|---|
| 412 | { |
|---|
| 413 | int pid = 0; |
|---|
| 414 | int nextparam = 3; |
|---|
| 415 | b_input input = b_input_unknown; |
|---|
| 416 | b_output output = b_output_unknown; |
|---|
| 417 | int timestamp_enabled = 0; |
|---|
| 418 | int simulatedFrameRate = 0; |
|---|
| 419 | const char *source; |
|---|
| 420 | const char *dest; |
|---|
| 421 | BNAV_Version navVersion = BNAV_VersionLatest; |
|---|
| 422 | |
|---|
| 423 | if (argc < 3) { |
|---|
| 424 | printHeader(); |
|---|
| 425 | printUsage(); |
|---|
| 426 | return 1; |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | source = argv[1]; |
|---|
| 430 | dest = argv[2]; |
|---|
| 431 | |
|---|
| 432 | if (argc>3 && argv[3][0] != '-') { |
|---|
| 433 | pid = strtoul(argv[3], NULL, 0); |
|---|
| 434 | ++nextparam; |
|---|
| 435 | } |
|---|
| 436 | |
|---|
| 437 | while (nextparam < argc) { |
|---|
| 438 | if (!strcmp(argv[nextparam], "-in=ts")) |
|---|
| 439 | input = b_input_mpeg_ts; |
|---|
| 440 | else if (!strcmp(argv[nextparam], "-in=pes")) |
|---|
| 441 | input = b_input_mpeg_pes; |
|---|
| 442 | else if (!strcmp(argv[nextparam], "-in=sct")) |
|---|
| 443 | input = b_input_4word_sct; |
|---|
| 444 | else if (!strcmp(argv[nextparam], "-in=sct6")) |
|---|
| 445 | input = b_input_6word_sct; |
|---|
| 446 | else if (!strcmp(argv[nextparam], "-in=avc_ts")) |
|---|
| 447 | input = b_input_avc_ts; |
|---|
| 448 | else if (!strcmp(argv[nextparam], "-in=vc1_pes")) |
|---|
| 449 | input = b_input_vc1_pes; |
|---|
| 450 | else if (!strcmp(argv[nextparam], "-out=bcm")) |
|---|
| 451 | output = b_output_bcm; |
|---|
| 452 | else if (!strcmp(argv[nextparam], "-out=sct6")) |
|---|
| 453 | output = b_output_6word_sct; |
|---|
| 454 | else if (!strcmp(argv[nextparam], "-out=sct")) |
|---|
| 455 | output = b_output_4word_sct; |
|---|
| 456 | else if (!strcmp(argv[nextparam], "-timestamp")) |
|---|
| 457 | timestamp_enabled = 1; |
|---|
| 458 | else if (!strcmp(argv[nextparam], "-q")) |
|---|
| 459 | g_quiet = 1; |
|---|
| 460 | else if (!strcmp(argv[nextparam], "-bcmver") && nextparam+1 < argc) |
|---|
| 461 | navVersion = atoi(argv[++nextparam]); |
|---|
| 462 | else if (!strcmp(argv[nextparam], "-framerate") && nextparam+1 < argc) { |
|---|
| 463 | simulatedFrameRate = atoi(argv[++nextparam]); |
|---|
| 464 | } |
|---|
| 465 | else { |
|---|
| 466 | printf("Invalid param: %s\n\n", argv[nextparam]); |
|---|
| 467 | printUsage(); |
|---|
| 468 | return -1; |
|---|
| 469 | } |
|---|
| 470 | nextparam++; |
|---|
| 471 | } |
|---|
| 472 | |
|---|
| 473 | if (input == b_input_unknown) { |
|---|
| 474 | char *s; |
|---|
| 475 | /* check the suffix of the inputfile */ |
|---|
| 476 | if (((s = strstr(source, ".sct")) && !s[4]) || |
|---|
| 477 | ((s = strstr(source, ".idx")) && !s[4])) |
|---|
| 478 | { |
|---|
| 479 | input = b_input_4word_sct; |
|---|
| 480 | } |
|---|
| 481 | else if ((s = strstr(source, ".pes")) && !s[4]) |
|---|
| 482 | { |
|---|
| 483 | input = b_input_mpeg_pes; |
|---|
| 484 | } |
|---|
| 485 | else |
|---|
| 486 | input = b_input_mpeg_ts; |
|---|
| 487 | } |
|---|
| 488 | if (output == b_output_unknown) { |
|---|
| 489 | char *s; |
|---|
| 490 | if (((s = strstr(dest, ".nav")) && !s[4]) || |
|---|
| 491 | ((s = strstr(dest, ".bcm")) && !s[4])) |
|---|
| 492 | output = b_output_bcm; |
|---|
| 493 | else |
|---|
| 494 | output = b_output_4word_sct; |
|---|
| 495 | } |
|---|
| 496 | |
|---|
| 497 | return createindex(source,dest,pid,input,output,timestamp_enabled,navVersion,simulatedFrameRate); |
|---|
| 498 | } |
|---|
| 499 | #endif |
|---|
| 500 | |
|---|