| 1 | /****************************************************************************** |
|---|
| 2 | * (c)2008-2012 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: cmdline_args.c $ |
|---|
| 39 | * $brcm_Revision: 109 $ |
|---|
| 40 | * $brcm_Date: 2/22/12 1:52p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/utils/cmdline_args.c $ |
|---|
| 47 | * |
|---|
| 48 | * 109 2/22/12 1:52p vsilyaev |
|---|
| 49 | * SW7425-2258: Improved handling of MJPEG decoders |
|---|
| 50 | * |
|---|
| 51 | * 108 2/15/12 11:34a erickson |
|---|
| 52 | * SW7405-5610: use endptr instead of strtol to verify output |
|---|
| 53 | * |
|---|
| 54 | * 107 2/14/12 12:46p vsilyaev |
|---|
| 55 | * SW7425-2258: Added Motion Jpeg codec type |
|---|
| 56 | * |
|---|
| 57 | * 106 2/7/12 7:34p jgarrett |
|---|
| 58 | * SW7425-2136: Adding FLAC support |
|---|
| 59 | * |
|---|
| 60 | * 105 2/2/12 4:47p jgarrett |
|---|
| 61 | * SW7425-2268: Adding voice conferencing codecs |
|---|
| 62 | * |
|---|
| 63 | * 104 1/31/12 5:07p rjlewis |
|---|
| 64 | * SW7425-1136: Added HDMI support (and some cleanup). |
|---|
| 65 | * |
|---|
| 66 | * 103 1/26/12 1:32p erickson |
|---|
| 67 | * SW7425-2250: default to NEXUS_StcChannelAutoModeBehavior_eVideoMaster |
|---|
| 68 | * |
|---|
| 69 | * 102 1/19/12 11:51a erickson |
|---|
| 70 | * SW7346-629: add -cmp_crc and -avd_crc options |
|---|
| 71 | * |
|---|
| 72 | * 101 1/11/12 6:13p vsilyaev |
|---|
| 73 | * SW7425-2112: Added option to limit playback rate |
|---|
| 74 | * |
|---|
| 75 | * 100 1/4/12 3:18p jgarrett |
|---|
| 76 | * SW7231-500: Merge to main branch |
|---|
| 77 | * |
|---|
| 78 | * SW7231-500/1 12/29/11 3:00p jgarrett |
|---|
| 79 | * SW7231-500: Enabling probe for IEEE-1394 LPCM audio |
|---|
| 80 | * |
|---|
| 81 | * 99 12/29/11 2:11p jgarrett |
|---|
| 82 | * SW7231-500: Removing branched argument |
|---|
| 83 | * |
|---|
| 84 | * 98 12/29/11 1:14p jgarrett |
|---|
| 85 | * SW7231-500: Adding IEEE-1394 LPCM |
|---|
| 86 | * |
|---|
| 87 | * 97 12/12/11 11:56a jgarrett |
|---|
| 88 | * SW7425-1406: Adding vorbis support |
|---|
| 89 | * |
|---|
| 90 | * 96 11/18/11 11:16a jgarrett |
|---|
| 91 | * SW7405-5071: Adding support for WMATS playback |
|---|
| 92 | * |
|---|
| 93 | * 95 10/25/11 11:36a vsilyaev |
|---|
| 94 | * SWDTV-8388: Added NEXUS_TransportType_eOgg type |
|---|
| 95 | * |
|---|
| 96 | * 94 10/7/11 4:17p vsilyaev |
|---|
| 97 | * SW7420-2086: Added MPEG1 Program Stream type |
|---|
| 98 | * |
|---|
| 99 | * 93 9/15/11 3:56p jgarrett |
|---|
| 100 | * SWDTV-4772: Adding support for dvi_adpcm type |
|---|
| 101 | * |
|---|
| 102 | * 92 9/9/11 3:52p jgarrett |
|---|
| 103 | * SW7422-408: Adding ADPCM support |
|---|
| 104 | * |
|---|
| 105 | * 91 8/31/11 1:36p vsilyaev |
|---|
| 106 | * SW7422-406: Removed dereference of relocated fields |
|---|
| 107 | * |
|---|
| 108 | * 90 8/26/11 5:57p jgarrett |
|---|
| 109 | * SW7344-160: Adding DTS-Legacy support |
|---|
| 110 | * |
|---|
| 111 | * 89 8/18/11 6:21p vsilyaev |
|---|
| 112 | * SW7425-1086, SW7425-966: added support for LeftRightEnhancedResolution |
|---|
| 113 | * |
|---|
| 114 | * 88 8/18/11 5:23p vsilyaev |
|---|
| 115 | * SW7425-651: Removed deprecated control over the encoder delay |
|---|
| 116 | * |
|---|
| 117 | * 87 8/15/11 3:11p vsilyaev |
|---|
| 118 | * SW7425-938: Added mapping for SH263 and VP8 video codecs |
|---|
| 119 | * |
|---|
| 120 | * 86 7/13/11 8:39p vsilyaev |
|---|
| 121 | * SWDTV-7897: Added code to wrap PCM file with the WAV header |
|---|
| 122 | * |
|---|
| 123 | * 85 7/7/11 5:52p jtna |
|---|
| 124 | * SW7425-869: added runtime option to override |
|---|
| 125 | * NEXUS_VideoDecoderSourceOrientation |
|---|
| 126 | * |
|---|
| 127 | * 84 4/22/11 5:49p vsilyaev |
|---|
| 128 | * SW7425-416: Added option to override display orientation |
|---|
| 129 | * |
|---|
| 130 | * 83 4/20/11 10:58a jgarrett |
|---|
| 131 | * SW7422-408: Adding AMR |
|---|
| 132 | * |
|---|
| 133 | * 82 4/8/11 5:19p vsilyaev |
|---|
| 134 | * SW7425-14: Fixed online help |
|---|
| 135 | * |
|---|
| 136 | * 81 3/24/11 8:06p vsilyaev |
|---|
| 137 | * SW7422-406: Fixed parsing of record parameters |
|---|
| 138 | * |
|---|
| 139 | * 80 3/23/11 5:41p vsilyaev |
|---|
| 140 | * SW7422-406: Unified parsing of command line parameters |
|---|
| 141 | * |
|---|
| 142 | * 79 3/15/11 2:15p erickson |
|---|
| 143 | * SW7346-101: fix dss playback |
|---|
| 144 | * |
|---|
| 145 | * 78 3/11/11 3:49p vsilyaev |
|---|
| 146 | * SW7425-159: add encode profile/level etc settings; add clean shutdown |
|---|
| 147 | * sequence for transcoder; add sample usage for transcoder; |
|---|
| 148 | * |
|---|
| 149 | * SW7425-159/1 3/9/11 8:05p hongtaoz |
|---|
| 150 | * SW7425-159: add encode profile/level etc settings; add clean shutdown |
|---|
| 151 | * sequence for transcoder; add sample usage for transcoder; |
|---|
| 152 | * |
|---|
| 153 | * 77 3/11/11 3:35p vsilyaev |
|---|
| 154 | * SW7422-14: Added support for decoding SVC/MVC streams |
|---|
| 155 | * |
|---|
| 156 | * 76 3/4/11 3:18p jgarrett |
|---|
| 157 | * SW7422-146: Adding multichannel audio support |
|---|
| 158 | * |
|---|
| 159 | * 75 3/4/11 1:22p erickson |
|---|
| 160 | * SW7125-833: add NEXUS_VideoWindowContentMode_ePanScanWithoutCorrection |
|---|
| 161 | * |
|---|
| 162 | * 74 2/22/11 7:53p vsilyaev |
|---|
| 163 | * SW7422-107: Added FLV mapping |
|---|
| 164 | * |
|---|
| 165 | * 73 2/16/11 2:32p vsilyaev |
|---|
| 166 | * SW7425-39, SW7425-40: updated to match new API |
|---|
| 167 | * |
|---|
| 168 | * SW7425_bringup/2 2/15/11 9:52p hongtaoz |
|---|
| 169 | * SW7425-40: adapted to new API; |
|---|
| 170 | * |
|---|
| 171 | * 72 1/20/11 5:51p vsilyaev |
|---|
| 172 | * SW7425-69: Can't use nexus API in cmdline_args |
|---|
| 173 | * |
|---|
| 174 | * 71 1/20/11 11:09a vsilyaev |
|---|
| 175 | * SW7422-216: Added vp6 video coded |
|---|
| 176 | * |
|---|
| 177 | * 70 12/22/10 1:15p vsilyaev |
|---|
| 178 | * SW7425-39, SW7425-40: merged hdmi_input source and transcoder util |
|---|
| 179 | * test; |
|---|
| 180 | * |
|---|
| 181 | * SW7425_bringup/1 12/22/10 12:42a hongtaoz |
|---|
| 182 | * SW7425-39, SW7425-40: add hdmi_input source and transcoder util test; |
|---|
| 183 | * |
|---|
| 184 | * 69 11/30/10 2:47p vsilyaev |
|---|
| 185 | * SW7422-65: Fixed mapping of SVC/MVC video codecs |
|---|
| 186 | * |
|---|
| 187 | * 68 11/24/10 1:49p vsilyaev |
|---|
| 188 | * SW3548-3106: Fixed position of usage for 'start_paused' |
|---|
| 189 | * |
|---|
| 190 | * 67 11/17/10 3:34p jgarrett |
|---|
| 191 | * SW7408-137: Adding HDMI output options |
|---|
| 192 | * |
|---|
| 193 | * 66 11/12/10 11:31a vsilyaev |
|---|
| 194 | * SW7422-64: Added basic 3D display format types |
|---|
| 195 | * |
|---|
| 196 | * 65 11/3/10 7:10p jgarrett |
|---|
| 197 | * SW35230-91: Renamed NEXUS_AudioCodec_eRealAudioLbr to _eCook |
|---|
| 198 | * |
|---|
| 199 | * 64 10/27/10 1:50p vsilyaev |
|---|
| 200 | * SW7468-69: Added mapping for cook audio streams |
|---|
| 201 | * |
|---|
| 202 | * 63 10/22/10 12:17p vsilyaev |
|---|
| 203 | * SW3548-3106: Added option to start playback in a paused state |
|---|
| 204 | * |
|---|
| 205 | * 62 9/28/10 6:44p vsilyaev |
|---|
| 206 | * SW7422-65: Added SVC types |
|---|
| 207 | * |
|---|
| 208 | * 61 9/8/10 3:22p vsilyaev |
|---|
| 209 | * SW7468-129: Split help message |
|---|
| 210 | * |
|---|
| 211 | * 60 9/8/10 12:09p vsilyaev |
|---|
| 212 | * SW7468-129: Added video decoder on ZSP |
|---|
| 213 | * |
|---|
| 214 | * 59 8/31/10 2:44p erickson |
|---|
| 215 | * SWGIGGSVIZIO-57: add -fixed_bitrate option to set |
|---|
| 216 | * NEXUS_PlaybackMode_eFixedBitrate |
|---|
| 217 | * |
|---|
| 218 | * 58 8/10/10 12:14p erickson |
|---|
| 219 | * SW7405-4735: merge |
|---|
| 220 | * |
|---|
| 221 | * SW7405-4735/1 8/9/10 3:21p jtna |
|---|
| 222 | * SW7405-4735: rename opts.pids to opts.otherPids. allow pid 0 in |
|---|
| 223 | * opts.otherPids. start only one playback during allpass record. |
|---|
| 224 | * |
|---|
| 225 | * 57 8/9/10 8:17a erickson |
|---|
| 226 | * SW3548-3045: bound array that is being dereferenced with an enum |
|---|
| 227 | * |
|---|
| 228 | * 56 8/9/10 6:32a erickson |
|---|
| 229 | * SW3548-3042: add more help for record, add default -video_type for |
|---|
| 230 | * record |
|---|
| 231 | * |
|---|
| 232 | * 55 8/3/10 1:30p jhaberf |
|---|
| 233 | * SW35230-844: Added 1080p support |
|---|
| 234 | * |
|---|
| 235 | * 54 7/14/10 6:12p vsilyaev |
|---|
| 236 | * SW3556-1131: Added basic support for CDXA format |
|---|
| 237 | * |
|---|
| 238 | * 53 5/7/10 4:18p erickson |
|---|
| 239 | * SWDEPRECATED-3783: default -probe for playback w/ no -video and no - |
|---|
| 240 | * audio |
|---|
| 241 | * |
|---|
| 242 | * 52 5/6/10 3:45p vsilyaev |
|---|
| 243 | * SW7405-3773: Added support for demuxing fragments from fragmented MP4 |
|---|
| 244 | * container |
|---|
| 245 | * |
|---|
| 246 | * 51 5/5/10 10:43a vsilyaev |
|---|
| 247 | * SW7405-1260: Added settings for size of the audio decoder buffer |
|---|
| 248 | * |
|---|
| 249 | * 50 3/10/10 6:59p jtna |
|---|
| 250 | * SW3556-1051: default back to timestamp reordering at host, until |
|---|
| 251 | * decoder reordering contract is re-established |
|---|
| 252 | * |
|---|
| 253 | * 49 2/23/10 4:50p vsilyaev |
|---|
| 254 | * SW3556-913: Added code that monitors state of the playback file and |
|---|
| 255 | * restarts playback (from last good position) in case of error |
|---|
| 256 | * |
|---|
| 257 | * 48 2/22/10 5:33p vsilyaev |
|---|
| 258 | * SW3556-913: Added option to plug Custom File I/O routines to inject |
|---|
| 259 | * errors |
|---|
| 260 | * |
|---|
| 261 | * 47 2/16/10 11:58a jtna |
|---|
| 262 | * SW3556-1051: make decoder reordering the default mode |
|---|
| 263 | * |
|---|
| 264 | * 46 2/12/10 5:56p jtna |
|---|
| 265 | * SW3556-1051: added option to control playback timestamp reordering |
|---|
| 266 | * |
|---|
| 267 | * 45 1/28/10 11:58a jtna |
|---|
| 268 | * SW7405-3260: -astm option is only used in decode app, not playback app |
|---|
| 269 | * |
|---|
| 270 | * 44 1/20/10 5:11p erickson |
|---|
| 271 | * SW7550-159: update record util for threshold and buffer control |
|---|
| 272 | * |
|---|
| 273 | * 43 1/12/10 3:52p jtna |
|---|
| 274 | * SW3548-2715: propagate video frame rate for AVI streams |
|---|
| 275 | * |
|---|
| 276 | * 42 1/11/10 6:54p jtna |
|---|
| 277 | * SW3556-982: propagate pcr pid to playback util |
|---|
| 278 | * |
|---|
| 279 | * 41 1/6/10 11:27a erickson |
|---|
| 280 | * SW3556-958: select correct NEXUS_TransportTimestampType for MPEG2TS |
|---|
| 281 | * |
|---|
| 282 | * 40 12/30/09 3:19p vsilyaev |
|---|
| 283 | * SW7408-17: Added options to select PCM and compressed audio outputs |
|---|
| 284 | * |
|---|
| 285 | * 39 12/30/09 2:13p erickson |
|---|
| 286 | * SW7550-128: add closed caption feature (-cc on) |
|---|
| 287 | * |
|---|
| 288 | * 38 12/9/09 1:42p vsilyaev |
|---|
| 289 | * SW7408-1: Added option to pass codec/stream types as a number |
|---|
| 290 | * |
|---|
| 291 | * 37 12/8/09 2:31p gmohile |
|---|
| 292 | * SW7408-1 : Add defines for nexus had frontend |
|---|
| 293 | * |
|---|
| 294 | * 36 11/25/09 6:39p vsilyaev |
|---|
| 295 | * SWDEPRECATED-3586: Fixed handling of ES streams (bogus start of both |
|---|
| 296 | * audio and video decoders for ES streams) |
|---|
| 297 | * |
|---|
| 298 | * 35 11/25/09 5:24p katrep |
|---|
| 299 | * SW7405-2740: Add support for WMA pro drc |
|---|
| 300 | * |
|---|
| 301 | * 34 10/8/09 6:03p jgarrett |
|---|
| 302 | * SW7405-3064: Adding DRA |
|---|
| 303 | * |
|---|
| 304 | * 33 10/8/09 5:45p jgarrett |
|---|
| 305 | * SW3548-2188: Adding AMR |
|---|
| 306 | * |
|---|
| 307 | * 32 10/8/09 10:43a jtna |
|---|
| 308 | * SWDEPRECATED-3793: clarify -acceptnull option for record |
|---|
| 309 | * |
|---|
| 310 | * 31 8/18/09 4:36p vsilyaev |
|---|
| 311 | * PR 56809: Added option to control handling of video errors |
|---|
| 312 | * |
|---|
| 313 | * 30 7/15/09 7:27p vsilyaev |
|---|
| 314 | * PR 55653: Added WAV format |
|---|
| 315 | * |
|---|
| 316 | * 29 7/13/09 4:11p vsilyaev |
|---|
| 317 | * PR 46190: Fixed mapping for PCM audio |
|---|
| 318 | * |
|---|
| 319 | * 28 6/25/09 11:33a erickson |
|---|
| 320 | * PR54342: use media probe to determine if there's an index to use |
|---|
| 321 | * |
|---|
| 322 | * 27 6/19/09 5:20p vsilyaev |
|---|
| 323 | * PR 56169: Added option to set max decode rate |
|---|
| 324 | * |
|---|
| 325 | * 26 6/18/09 4:30p jtna |
|---|
| 326 | * PR54802: add frontend support to record |
|---|
| 327 | * |
|---|
| 328 | * 25 6/16/09 5:13p jtna |
|---|
| 329 | * PR54802: added record |
|---|
| 330 | * |
|---|
| 331 | * 24 6/8/09 7:06a erickson |
|---|
| 332 | * PR55617: add user-specific aspectRatio |
|---|
| 333 | * |
|---|
| 334 | * 23 6/1/09 3:39p erickson |
|---|
| 335 | * PR48944: if scart1composite is on, revert from panel defaults |
|---|
| 336 | * |
|---|
| 337 | * 22 5/22/09 5:21p vsilyaev |
|---|
| 338 | * PR 55376 PR 52344: Added option to enable processing of AVC(H.264) |
|---|
| 339 | * Level 5.1 video |
|---|
| 340 | * |
|---|
| 341 | * 21 3/24/09 10:38a erickson |
|---|
| 342 | * PR48944: default ES to video or audio if audio_type is set or not set |
|---|
| 343 | * |
|---|
| 344 | * 20 3/18/09 10:30a erickson |
|---|
| 345 | * PR52350: add wxga/fha support with 50/60 hz option |
|---|
| 346 | * |
|---|
| 347 | * 19 3/17/09 5:41p vsilyaev |
|---|
| 348 | * PR 46190: Adding mappings to the PCM audio codec |
|---|
| 349 | * |
|---|
| 350 | * 18 3/10/09 10:55a erickson |
|---|
| 351 | * PR52946: reconcile ts_timestamp help and actual cmdline param |
|---|
| 352 | * |
|---|
| 353 | * 17 3/6/09 9:33a erickson |
|---|
| 354 | * PR51743: added -ar and -graphics options, default DTV apps to panel |
|---|
| 355 | * output |
|---|
| 356 | * |
|---|
| 357 | * 16 2/27/09 5:05p vsilyaev |
|---|
| 358 | * PR 52634: Added code to handle MPEG-2 TS streams with timesampts (e.g. |
|---|
| 359 | * 192 byte packets) |
|---|
| 360 | * |
|---|
| 361 | * 15 2/20/09 2:06p vsilyaev |
|---|
| 362 | * PR 51467: Added option to set size of the video decoder buffer |
|---|
| 363 | * |
|---|
| 364 | * 14 2/5/09 2:08p erickson |
|---|
| 365 | * PR51151: update |
|---|
| 366 | * |
|---|
| 367 | * 13 2/5/09 1:49p erickson |
|---|
| 368 | * PR51151: added media probe option for playback |
|---|
| 369 | * |
|---|
| 370 | * 12 1/26/09 11:26a vsilyaev |
|---|
| 371 | * PR 51579: Added stream_processing and auto_bitrate options |
|---|
| 372 | * |
|---|
| 373 | * 11 1/22/09 7:48p vsilyaev |
|---|
| 374 | * PR 50848: Don't use globals for the command line options |
|---|
| 375 | * |
|---|
| 376 | * 10 1/20/09 4:28p erickson |
|---|
| 377 | * PR48944: add -mad and -display_format options |
|---|
| 378 | * |
|---|
| 379 | * 9 1/8/09 10:34p erickson |
|---|
| 380 | * PR48944: add more options |
|---|
| 381 | * |
|---|
| 382 | * 8 1/8/09 9:36p erickson |
|---|
| 383 | * PR50757: added NEXUS_VideoFrameRate support, both as a start setting |
|---|
| 384 | * and status |
|---|
| 385 | * |
|---|
| 386 | * 7 1/6/09 12:45a erickson |
|---|
| 387 | * PR50763: added -bof, -eof options. added playback position to status. |
|---|
| 388 | * fix mkv, mp4. |
|---|
| 389 | * |
|---|
| 390 | * 6 1/5/09 12:49p erickson |
|---|
| 391 | * PR50763: update for mkv testing |
|---|
| 392 | * |
|---|
| 393 | * 5 12/3/08 3:55p erickson |
|---|
| 394 | * PR48944: update |
|---|
| 395 | * |
|---|
| 396 | * 4 11/20/08 12:50p erickson |
|---|
| 397 | * PR48944: update |
|---|
| 398 | * |
|---|
| 399 | * 3 11/19/08 1:30p erickson |
|---|
| 400 | * PR48944: update |
|---|
| 401 | * |
|---|
| 402 | * 2 11/17/08 2:19p erickson |
|---|
| 403 | * PR48944: update |
|---|
| 404 | * |
|---|
| 405 | * 1 11/17/08 12:34p erickson |
|---|
| 406 | * PR48944: add utils |
|---|
| 407 | * |
|---|
| 408 | *****************************************************************************/ |
|---|
| 409 | #include "nexus_platform.h" |
|---|
| 410 | #include "nexus_core_utils.h" |
|---|
| 411 | #include "cmdline_args.h" |
|---|
| 412 | #include "bmedia_probe.h" |
|---|
| 413 | #include "bmpeg2ts_probe.h" |
|---|
| 414 | #include "bmedia_cdxa.h" |
|---|
| 415 | #if B_HAS_ASF |
|---|
| 416 | #include "basf_probe.h" |
|---|
| 417 | #endif |
|---|
| 418 | #if B_HAS_AVI |
|---|
| 419 | #include "bavi_probe.h" |
|---|
| 420 | #endif |
|---|
| 421 | #if NEXUS_HAS_VIDEO_ENCODER |
|---|
| 422 | #include "nexus_video_encoder_types.h" |
|---|
| 423 | #include "nexus_stream_mux.h" |
|---|
| 424 | #endif |
|---|
| 425 | #include "bfile_stdio.h" |
|---|
| 426 | #include <string.h> |
|---|
| 427 | #include <stdio.h> |
|---|
| 428 | #include <stdlib.h> |
|---|
| 429 | |
|---|
| 430 | NEXUS_VideoCodec b_videocodec2nexus(bvideo_codec settop_value); |
|---|
| 431 | NEXUS_AudioCodec b_audiocodec2nexus(baudio_format settop_value); |
|---|
| 432 | NEXUS_TransportType b_mpegtype2nexus(bstream_mpeg_type settop_value); |
|---|
| 433 | |
|---|
| 434 | const namevalue_t g_videoFormatStrs[] = { |
|---|
| 435 | {"ntsc", NEXUS_VideoFormat_eNtsc}, |
|---|
| 436 | {"480i", NEXUS_VideoFormat_eNtsc}, |
|---|
| 437 | {"pal", NEXUS_VideoFormat_ePal}, |
|---|
| 438 | {"576i", NEXUS_VideoFormat_ePal}, |
|---|
| 439 | {"1080i", NEXUS_VideoFormat_e1080i}, |
|---|
| 440 | {"720p", NEXUS_VideoFormat_e720p}, |
|---|
| 441 | {"480p", NEXUS_VideoFormat_e480p}, |
|---|
| 442 | {"576p", NEXUS_VideoFormat_e576p}, |
|---|
| 443 | {"1080p", NEXUS_VideoFormat_e1080p}, |
|---|
| 444 | {"720p3D", NEXUS_VideoFormat_e3D_720p}, |
|---|
| 445 | {"1080p3D", NEXUS_VideoFormat_e3D_1080p_24Hz}, |
|---|
| 446 | {NULL, 0} |
|---|
| 447 | }; |
|---|
| 448 | |
|---|
| 449 | const namevalue_t g_videoFrameRateStrs[NEXUS_VideoFrameRate_eMax+1] = { |
|---|
| 450 | {"0", NEXUS_VideoFrameRate_eUnknown}, |
|---|
| 451 | {"23.976", NEXUS_VideoFrameRate_e23_976}, |
|---|
| 452 | {"24", NEXUS_VideoFrameRate_e24}, |
|---|
| 453 | {"25", NEXUS_VideoFrameRate_e25}, |
|---|
| 454 | {"29.97", NEXUS_VideoFrameRate_e29_97}, |
|---|
| 455 | {"30", NEXUS_VideoFrameRate_e30}, |
|---|
| 456 | {"50", NEXUS_VideoFrameRate_e50}, |
|---|
| 457 | {"59.94", NEXUS_VideoFrameRate_e59_94}, |
|---|
| 458 | {"60", NEXUS_VideoFrameRate_e60}, |
|---|
| 459 | {NULL, 0} |
|---|
| 460 | }; |
|---|
| 461 | |
|---|
| 462 | static const namevalue_t g_transportTypeStrs[] = { |
|---|
| 463 | {"ts", NEXUS_TransportType_eTs}, |
|---|
| 464 | {"pes", NEXUS_TransportType_eMpeg2Pes}, |
|---|
| 465 | {"es", NEXUS_TransportType_eEs}, |
|---|
| 466 | {"vob", NEXUS_TransportType_eVob}, |
|---|
| 467 | {"mp4", NEXUS_TransportType_eMp4}, |
|---|
| 468 | {"mkv", NEXUS_TransportType_eMkv}, |
|---|
| 469 | {"avi", NEXUS_TransportType_eAvi}, |
|---|
| 470 | {"asf", NEXUS_TransportType_eAsf}, |
|---|
| 471 | {"wav", NEXUS_TransportType_eWav}, |
|---|
| 472 | {"mp4f", NEXUS_TransportType_eMp4Fragment}, |
|---|
| 473 | {"rmff", NEXUS_TransportType_eRmff}, |
|---|
| 474 | {"flv", NEXUS_TransportType_eFlv}, |
|---|
| 475 | {"ogg", NEXUS_TransportType_eOgg}, |
|---|
| 476 | {"dss", NEXUS_TransportType_eDssEs}, |
|---|
| 477 | {"dss_es", NEXUS_TransportType_eDssEs}, /* alias. used for SD. */ |
|---|
| 478 | {"dss_pes", NEXUS_TransportType_eDssPes}, /* used for HD */ |
|---|
| 479 | {"mp1", NEXUS_TransportType_eMpeg1Ps}, |
|---|
| 480 | {NULL, 0} |
|---|
| 481 | }; |
|---|
| 482 | |
|---|
| 483 | static const namevalue_t g_videoCodecStrs[] = { |
|---|
| 484 | {"mpeg2", NEXUS_VideoCodec_eMpeg2}, |
|---|
| 485 | {"mpeg", NEXUS_VideoCodec_eMpeg2}, |
|---|
| 486 | {"mpeg1", NEXUS_VideoCodec_eMpeg1}, |
|---|
| 487 | {"avc", NEXUS_VideoCodec_eH264}, |
|---|
| 488 | {"h264", NEXUS_VideoCodec_eH264}, |
|---|
| 489 | {"svc", NEXUS_VideoCodec_eH264_Svc}, |
|---|
| 490 | {"mvc", NEXUS_VideoCodec_eH264_Mvc}, |
|---|
| 491 | {"h263", NEXUS_VideoCodec_eH263}, |
|---|
| 492 | {"h263", NEXUS_VideoCodec_eH263}, |
|---|
| 493 | {"avs", NEXUS_VideoCodec_eAvs}, |
|---|
| 494 | {"vc1", NEXUS_VideoCodec_eVc1}, |
|---|
| 495 | {"vc1sm", NEXUS_VideoCodec_eVc1SimpleMain}, |
|---|
| 496 | {"divx", NEXUS_VideoCodec_eMpeg4Part2}, |
|---|
| 497 | {"mpeg4", NEXUS_VideoCodec_eMpeg4Part2}, |
|---|
| 498 | {"divx311", NEXUS_VideoCodec_eDivx311}, |
|---|
| 499 | {"divx3", NEXUS_VideoCodec_eDivx311}, |
|---|
| 500 | {"rv40", NEXUS_VideoCodec_eRv40}, |
|---|
| 501 | {"vp6", NEXUS_VideoCodec_eVp6}, |
|---|
| 502 | {"vp7", NEXUS_VideoCodec_eVp7}, |
|---|
| 503 | {"vp8", NEXUS_VideoCodec_eVp8}, |
|---|
| 504 | {"spark", NEXUS_VideoCodec_eSpark}, |
|---|
| 505 | {"mjpeg", NEXUS_VideoCodec_eMotionJpeg}, |
|---|
| 506 | {NULL, 0} |
|---|
| 507 | }; |
|---|
| 508 | |
|---|
| 509 | #if NEXUS_HAS_VIDEO_ENCODER |
|---|
| 510 | static const namevalue_t g_videoCodecProfileStrs[] = { |
|---|
| 511 | {"simple", NEXUS_VideoCodecProfile_eSimple}, |
|---|
| 512 | {"main", NEXUS_VideoCodecProfile_eMain}, |
|---|
| 513 | {"high", NEXUS_VideoCodecProfile_eHigh}, |
|---|
| 514 | {"advanced", NEXUS_VideoCodecProfile_eAdvanced}, |
|---|
| 515 | {"jizhun", NEXUS_VideoCodecProfile_eJizhun}, |
|---|
| 516 | {"snrscl", NEXUS_VideoCodecProfile_eSnrScalable}, |
|---|
| 517 | {"spatialscl", NEXUS_VideoCodecProfile_eSpatiallyScalable}, |
|---|
| 518 | {"advsimple", NEXUS_VideoCodecProfile_eAdvancedSimple}, |
|---|
| 519 | {"baseline", NEXUS_VideoCodecProfile_eBaseline}, |
|---|
| 520 | |
|---|
| 521 | {NULL, 0} |
|---|
| 522 | }; |
|---|
| 523 | |
|---|
| 524 | static const namevalue_t g_videoCodecLevelStrs[] = { |
|---|
| 525 | {"0.0", NEXUS_VideoCodecLevel_e00}, |
|---|
| 526 | {"1.0", NEXUS_VideoCodecLevel_e10}, |
|---|
| 527 | {"1.b", NEXUS_VideoCodecLevel_e1B}, |
|---|
| 528 | {"1.1", NEXUS_VideoCodecLevel_e11}, |
|---|
| 529 | {"1.2", NEXUS_VideoCodecLevel_e12}, |
|---|
| 530 | {"1.3", NEXUS_VideoCodecLevel_e13}, |
|---|
| 531 | {"2.0", NEXUS_VideoCodecLevel_e20}, |
|---|
| 532 | {"2.1", NEXUS_VideoCodecLevel_e21}, |
|---|
| 533 | {"2.2", NEXUS_VideoCodecLevel_e22}, |
|---|
| 534 | {"3.0", NEXUS_VideoCodecLevel_e30}, |
|---|
| 535 | {"3.1", NEXUS_VideoCodecLevel_e31}, |
|---|
| 536 | {"3.2", NEXUS_VideoCodecLevel_e32}, |
|---|
| 537 | {"4.0", NEXUS_VideoCodecLevel_e40}, |
|---|
| 538 | {"4.1", NEXUS_VideoCodecLevel_e41}, |
|---|
| 539 | {"4.2", NEXUS_VideoCodecLevel_e42}, |
|---|
| 540 | {"5.0", NEXUS_VideoCodecLevel_e50}, |
|---|
| 541 | {"5.1", NEXUS_VideoCodecLevel_e51}, |
|---|
| 542 | {"6.0", NEXUS_VideoCodecLevel_e60}, |
|---|
| 543 | {"6.2", NEXUS_VideoCodecLevel_e62}, |
|---|
| 544 | {"low", NEXUS_VideoCodecLevel_eLow}, |
|---|
| 545 | {"main", NEXUS_VideoCodecLevel_eMain}, |
|---|
| 546 | {"high", NEXUS_VideoCodecLevel_eHigh}, |
|---|
| 547 | {"high1440", NEXUS_VideoCodecLevel_eHigh1440}, |
|---|
| 548 | {NULL, 0} |
|---|
| 549 | }; |
|---|
| 550 | #endif |
|---|
| 551 | |
|---|
| 552 | static const namevalue_t g_audioCodecStrs[] = { |
|---|
| 553 | {"mpeg", NEXUS_AudioCodec_eMpeg}, |
|---|
| 554 | {"mp3", NEXUS_AudioCodec_eMp3}, |
|---|
| 555 | {"ac3", NEXUS_AudioCodec_eAc3}, |
|---|
| 556 | {"ac3plus", NEXUS_AudioCodec_eAc3Plus}, |
|---|
| 557 | {"aac", NEXUS_AudioCodec_eAac}, |
|---|
| 558 | {"aacplus", NEXUS_AudioCodec_eAacPlus}, |
|---|
| 559 | {"wma", NEXUS_AudioCodec_eWmaStd}, |
|---|
| 560 | {"wmastd", NEXUS_AudioCodec_eWmaStd}, |
|---|
| 561 | {"wmats", NEXUS_AudioCodec_eWmaStdTs}, |
|---|
| 562 | {"wmapro", NEXUS_AudioCodec_eWmaPro}, |
|---|
| 563 | {"pcm", NEXUS_AudioCodec_ePcmWav}, |
|---|
| 564 | {"dra", NEXUS_AudioCodec_eDra}, |
|---|
| 565 | {"dts_legacy", NEXUS_AudioCodec_eDtsLegacy}, |
|---|
| 566 | {"dts", NEXUS_AudioCodec_eDts}, |
|---|
| 567 | {"dtshd", NEXUS_AudioCodec_eDtsHd}, |
|---|
| 568 | {"cook", NEXUS_AudioCodec_eCook}, |
|---|
| 569 | {"amr", NEXUS_AudioCodec_eAmr}, |
|---|
| 570 | {"adpcm", NEXUS_AudioCodec_eAdpcm}, |
|---|
| 571 | {"vorbis", NEXUS_AudioCodec_eVorbis}, |
|---|
| 572 | {"lpcm_1394", NEXUS_AudioCodec_eLpcm1394}, |
|---|
| 573 | {"g711", NEXUS_AudioCodec_eG711}, |
|---|
| 574 | {"g726", NEXUS_AudioCodec_eG726}, |
|---|
| 575 | {"g729", NEXUS_AudioCodec_eG729}, |
|---|
| 576 | {"g723.1", NEXUS_AudioCodec_eG723_1}, |
|---|
| 577 | {"flac", NEXUS_AudioCodec_eFlac}, |
|---|
| 578 | {NULL, 0} |
|---|
| 579 | }; |
|---|
| 580 | |
|---|
| 581 | static const namevalue_t g_stcChannelMasterStrs[] = { |
|---|
| 582 | {"first", NEXUS_StcChannelAutoModeBehavior_eFirstAvailable}, |
|---|
| 583 | {"video", NEXUS_StcChannelAutoModeBehavior_eVideoMaster}, |
|---|
| 584 | {"audio", NEXUS_StcChannelAutoModeBehavior_eAudioMaster}, |
|---|
| 585 | {NULL, 0} |
|---|
| 586 | }; |
|---|
| 587 | |
|---|
| 588 | static const namevalue_t g_endOfStreamActionStrs[] = { |
|---|
| 589 | {"loop", NEXUS_PlaybackLoopMode_eLoop}, |
|---|
| 590 | {"pause", NEXUS_PlaybackLoopMode_ePause}, |
|---|
| 591 | {"play", NEXUS_PlaybackLoopMode_ePlay}, |
|---|
| 592 | {NULL, 0} |
|---|
| 593 | }; |
|---|
| 594 | |
|---|
| 595 | static const namevalue_t g_tsTimestampType[] = { |
|---|
| 596 | {"none", NEXUS_TransportTimestampType_eNone}, |
|---|
| 597 | {"mod300", NEXUS_TransportTimestampType_eMod300}, |
|---|
| 598 | {"binary", NEXUS_TransportTimestampType_eBinary}, |
|---|
| 599 | {NULL, 0} |
|---|
| 600 | }; |
|---|
| 601 | |
|---|
| 602 | static const namevalue_t g_contentModeStrs[] = { |
|---|
| 603 | {"zoom", NEXUS_VideoWindowContentMode_eZoom}, |
|---|
| 604 | {"box", NEXUS_VideoWindowContentMode_eBox}, |
|---|
| 605 | {"panscan", NEXUS_VideoWindowContentMode_ePanScan}, |
|---|
| 606 | {"full", NEXUS_VideoWindowContentMode_eFull}, |
|---|
| 607 | {"nonlinear", NEXUS_VideoWindowContentMode_eFullNonLinear}, |
|---|
| 608 | /* {"panscan_no_cor", NEXUS_VideoWindowContentMode_ePanScanWithoutCorrection}, */ |
|---|
| 609 | {NULL, 0} |
|---|
| 610 | }; |
|---|
| 611 | |
|---|
| 612 | static const namevalue_t g_panelStrs[] = { |
|---|
| 613 | {"wxga", 0}, |
|---|
| 614 | {"wxga50", 1}, |
|---|
| 615 | {"fhd", 2}, |
|---|
| 616 | {"fhd50", 3}, |
|---|
| 617 | {"off", 0xff}, |
|---|
| 618 | {NULL, 0} |
|---|
| 619 | }; |
|---|
| 620 | |
|---|
| 621 | #if NEXUS_HAS_FRONTEND |
|---|
| 622 | static const namevalue_t g_vsbModeStrs[] = { |
|---|
| 623 | {"8", NEXUS_FrontendVsbMode_e8}, |
|---|
| 624 | {"16", NEXUS_FrontendVsbMode_e16}, |
|---|
| 625 | {NULL, 0} |
|---|
| 626 | }; |
|---|
| 627 | |
|---|
| 628 | static const namevalue_t g_qamModeStrs[] = { |
|---|
| 629 | {"16", NEXUS_FrontendQamMode_e16}, |
|---|
| 630 | {"32", NEXUS_FrontendQamMode_e32}, |
|---|
| 631 | {"64", NEXUS_FrontendQamMode_e64}, |
|---|
| 632 | {"128", NEXUS_FrontendQamMode_e128}, |
|---|
| 633 | {"256", NEXUS_FrontendQamMode_e256}, |
|---|
| 634 | {"512", NEXUS_FrontendQamMode_e512}, |
|---|
| 635 | {"1024", NEXUS_FrontendQamMode_e1024}, |
|---|
| 636 | {"2048", NEXUS_FrontendQamMode_e2048}, |
|---|
| 637 | {"4096", NEXUS_FrontendQamMode_e4096}, |
|---|
| 638 | {"Auto_64_256", NEXUS_FrontendQamMode_eAuto_64_256}, |
|---|
| 639 | {NULL, 0} |
|---|
| 640 | }; |
|---|
| 641 | |
|---|
| 642 | static const namevalue_t g_satModeStrs[] = { |
|---|
| 643 | {"dvb", NEXUS_FrontendSatelliteMode_eDvb}, |
|---|
| 644 | {"dss", NEXUS_FrontendSatelliteMode_eDss}, |
|---|
| 645 | {NULL, 0} |
|---|
| 646 | }; |
|---|
| 647 | #endif |
|---|
| 648 | |
|---|
| 649 | static const namevalue_t g_videoErrorHandling[] = { |
|---|
| 650 | {"none", NEXUS_VideoDecoderErrorHandling_eNone}, |
|---|
| 651 | {"picture", NEXUS_VideoDecoderErrorHandling_ePicture}, |
|---|
| 652 | {"prognostic", NEXUS_VideoDecoderErrorHandling_ePrognostic}, |
|---|
| 653 | {NULL, 0} |
|---|
| 654 | }; |
|---|
| 655 | |
|---|
| 656 | static const namevalue_t g_videoOrientation[] = { |
|---|
| 657 | {"2D", NEXUS_VideoOrientation_e2D}, |
|---|
| 658 | {"LeftRight", NEXUS_VideoOrientation_e3D_LeftRight}, |
|---|
| 659 | {"3D", NEXUS_VideoOrientation_e3D_LeftRight}, |
|---|
| 660 | {"OverUnder", NEXUS_VideoOrientation_e3D_OverUnder}, |
|---|
| 661 | {NULL, 0} |
|---|
| 662 | }; |
|---|
| 663 | |
|---|
| 664 | static const namevalue_t g_sourceOrientation[] = { |
|---|
| 665 | {"2D", NEXUS_VideoDecoderSourceOrientation_e2D}, |
|---|
| 666 | {"LeftRight", NEXUS_VideoDecoderSourceOrientation_e3D_LeftRight}, |
|---|
| 667 | {"OverUnder", NEXUS_VideoDecoderSourceOrientation_e3D_OverUnder}, |
|---|
| 668 | {"LeftRightFull", NEXUS_VideoDecoderSourceOrientation_e3D_LeftRightFullFrame}, |
|---|
| 669 | {"RightLeftFull", NEXUS_VideoDecoderSourceOrientation_e3D_RightLeftFullFrame}, |
|---|
| 670 | {"LeftRightEnhanced", NEXUS_VideoDecoderSourceOrientation_e3D_LeftRightFullFrame}, |
|---|
| 671 | {NULL, 0} |
|---|
| 672 | }; |
|---|
| 673 | |
|---|
| 674 | static unsigned lookup(const namevalue_t *table, const char *name) |
|---|
| 675 | { |
|---|
| 676 | unsigned i; |
|---|
| 677 | unsigned value; |
|---|
| 678 | char *endptr; |
|---|
| 679 | for (i=0;table[i].name;i++) { |
|---|
| 680 | if (!strcasecmp(table[i].name, name)) { |
|---|
| 681 | return table[i].value; |
|---|
| 682 | } |
|---|
| 683 | } |
|---|
| 684 | value = strtol(name, &endptr, 0); |
|---|
| 685 | if(!endptr || *endptr) { /* if valid, *endptr = '\0' */ |
|---|
| 686 | value = table[0].value; |
|---|
| 687 | } |
|---|
| 688 | printf("Unknown cmdline param '%s', using %u as value\n", name, value); |
|---|
| 689 | return value; |
|---|
| 690 | } |
|---|
| 691 | |
|---|
| 692 | static void print_list(const namevalue_t *table) |
|---|
| 693 | { |
|---|
| 694 | unsigned i; |
|---|
| 695 | const char *sep=" {"; |
|---|
| 696 | for (i=0;table[i].name;i++) { |
|---|
| 697 | /* skip aliases */ |
|---|
| 698 | if (i > 0 && table[i].value == table[i-1].value) continue; |
|---|
| 699 | printf("%s%s",sep,table[i].name); |
|---|
| 700 | sep = ","; |
|---|
| 701 | } |
|---|
| 702 | printf("}"); |
|---|
| 703 | } |
|---|
| 704 | |
|---|
| 705 | static void print_list_option(const char *name, const namevalue_t *list) |
|---|
| 706 | { |
|---|
| 707 | printf(" -%s ", name); |
|---|
| 708 | print_list(list); |
|---|
| 709 | printf("\n"); |
|---|
| 710 | } |
|---|
| 711 | |
|---|
| 712 | static void print_usage_common(void) |
|---|
| 713 | { |
|---|
| 714 | printf( |
|---|
| 715 | " -h|--help - this usage information\n" |
|---|
| 716 | " -pcr PID - defaults to video PID\n" |
|---|
| 717 | " -mpeg_type"); |
|---|
| 718 | print_list(g_transportTypeStrs); |
|---|
| 719 | printf("\n -video PID\n"); |
|---|
| 720 | print_list_option("video_type",g_videoCodecStrs); |
|---|
| 721 | print_list_option("audio_type",g_audioCodecStrs); |
|---|
| 722 | printf(" -audio PID\n"); |
|---|
| 723 | print_list_option("frame_rate",g_videoFrameRateStrs); |
|---|
| 724 | print_list_option("display_format",g_videoFormatStrs); |
|---|
| 725 | print_list_option("ar",g_contentModeStrs); |
|---|
| 726 | print_list_option("panel",g_panelStrs); |
|---|
| 727 | printf( |
|---|
| 728 | #if NEXUS_NUM_COMPOSITE_OUTPUTS |
|---|
| 729 | " -composite {on|off}\n" |
|---|
| 730 | #endif |
|---|
| 731 | #if NEXUS_NUM_COMPONENT_OUTPUTS |
|---|
| 732 | " -component {on|off}\n" |
|---|
| 733 | #endif |
|---|
| 734 | #if NEXUS_NUM_HDMI_OUTPUTS |
|---|
| 735 | " -hdmi {on|off}\n" |
|---|
| 736 | #endif |
|---|
| 737 | #if NEXUS_NUM_SCART_INPUTS |
|---|
| 738 | " -scart1composite {on|off}\n" |
|---|
| 739 | #endif |
|---|
| 740 | " -cc {on|off} - enable closed caption routing and output\n" |
|---|
| 741 | " -probe - use media probe to discover stream format for playback (defaults on if no video or audio pid)\n" |
|---|
| 742 | ); |
|---|
| 743 | printf( |
|---|
| 744 | " -video_cdb KBytes - size of compressed video buffer, in KBytes\n" |
|---|
| 745 | " -audio_cdb KBytes - size of compressed audio buffer, in KBytes\n" |
|---|
| 746 | " -avc51 - Enable AVC (H.264) Level 5.1 decoding\n" |
|---|
| 747 | " -max_decoder_rate rate - Set decoder max decoder rate\n" |
|---|
| 748 | " -compressed_audio - Also output compressed audio\n" |
|---|
| 749 | " -multichannel_audio - Also output multichannel audio on hdmi\n" |
|---|
| 750 | " -no_decoded_audio - Don't output decoded (PCM) audio\n" |
|---|
| 751 | " -video_decoder index - Selects video decoder index\n" |
|---|
| 752 | " -pcm sr,channels,bits - Play LPCM file\n" |
|---|
| 753 | ); |
|---|
| 754 | print_list_option("ts_timestamp",g_tsTimestampType); |
|---|
| 755 | print_list_option("video_error_handling", g_videoErrorHandling); |
|---|
| 756 | printf( |
|---|
| 757 | " -detect_avc_extension - Detect SVC/MVC extensions\n" |
|---|
| 758 | " -ext_video PID\n" |
|---|
| 759 | " -max_playback_data_rate - Set limit for playback data rate (Kbps)\n" |
|---|
| 760 | ); |
|---|
| 761 | print_list_option("ext_video_type", g_videoCodecStrs); |
|---|
| 762 | print_list_option("display_3d", g_videoOrientation); |
|---|
| 763 | print_list_option("source_3d", g_sourceOrientation); |
|---|
| 764 | return; |
|---|
| 765 | } |
|---|
| 766 | |
|---|
| 767 | void print_usage(const char *app) |
|---|
| 768 | { |
|---|
| 769 | printf("%s usage:\n", app); |
|---|
| 770 | print_usage_common(); |
|---|
| 771 | printf( |
|---|
| 772 | " -stream_processing - enable extra stream processing for playback\n" |
|---|
| 773 | " -auto_bitrate - enable bitrate detection for playback\n" |
|---|
| 774 | " -fixed_bitrate X - provide fixed bitrate to playback (units bits per second)\n" |
|---|
| 775 | " -graphics - add a graphics plane\n" |
|---|
| 776 | ); |
|---|
| 777 | printf( |
|---|
| 778 | " -astm - enable Astm (adaptive system time management). used only for decode app\n" |
|---|
| 779 | " -sync - enable SyncChannel (high-precision lipsync)\n" |
|---|
| 780 | #if HOST_REORDER /* disabled for now */ |
|---|
| 781 | " -host_reorder - handle timestamp reordering at host and disable at decoder\n" |
|---|
| 782 | #endif |
|---|
| 783 | " -stctrick - use STC trick modes instead of decoder trick modes\n" |
|---|
| 784 | " -start_paused - Start playback in a paused state\n" |
|---|
| 785 | ); |
|---|
| 786 | print_list_option("master", g_stcChannelMasterStrs); |
|---|
| 787 | print_list_option("bof", g_endOfStreamActionStrs); |
|---|
| 788 | print_list_option("eof", g_endOfStreamActionStrs); |
|---|
| 789 | return; |
|---|
| 790 | } |
|---|
| 791 | |
|---|
| 792 | struct cmdline_parse_common_state { |
|---|
| 793 | bool isVideoEs; |
|---|
| 794 | }; |
|---|
| 795 | |
|---|
| 796 | static int cmdline_parse_common(int offset, int argc, const char *argv[], struct common_opts_t *opts, struct cmdline_parse_common_state *state, void (*usage)(const char *) ) |
|---|
| 797 | { |
|---|
| 798 | int i; |
|---|
| 799 | |
|---|
| 800 | if (offset==0) { |
|---|
| 801 | memset(state,0,sizeof(*state)); |
|---|
| 802 | offset = 1; |
|---|
| 803 | state->isVideoEs = true; |
|---|
| 804 | memset(opts,0,sizeof(*opts)); |
|---|
| 805 | opts->transportType = NEXUS_TransportType_eTs; |
|---|
| 806 | opts->extVideoCodec = NEXUS_VideoCodec_eNone; |
|---|
| 807 | opts->videoCodec = NEXUS_VideoCodec_eMpeg2; |
|---|
| 808 | opts->audioCodec = NEXUS_AudioCodec_eMpeg; |
|---|
| 809 | opts->contentMode = NEXUS_VideoWindowContentMode_eFull; |
|---|
| 810 | opts->compressedAudio = false; |
|---|
| 811 | opts->multichannelAudio = false; |
|---|
| 812 | opts->detectAvcExtension = false; |
|---|
| 813 | opts->decodedAudio = true; |
|---|
| 814 | opts->playpumpTimestampReordering = true; |
|---|
| 815 | opts->videoDecoder = 0; |
|---|
| 816 | opts->tsTimestampType = NEXUS_TransportTimestampType_eNone; |
|---|
| 817 | opts->videoFrameRate = NEXUS_VideoFrameRate_eUnknown; |
|---|
| 818 | opts->displayOrientation = NEXUS_VideoOrientation_e2D; |
|---|
| 819 | opts->sourceOrientation = NEXUS_VideoDecoderSourceOrientation_e2D; |
|---|
| 820 | opts->pcm = false; |
|---|
| 821 | bpcm_file_config_init(&opts->pcm_config); |
|---|
| 822 | opts->useCompositeOutput = true; |
|---|
| 823 | opts->useComponentOutput = true; |
|---|
| 824 | opts->useHdmiOutput = true; |
|---|
| 825 | opts->displayFormat = NEXUS_VideoFormat_eNtsc; |
|---|
| 826 | opts->displayType = NEXUS_DisplayType_eAuto; |
|---|
| 827 | } |
|---|
| 828 | |
|---|
| 829 | for (i=offset;i<argc;i++) { |
|---|
| 830 | if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { |
|---|
| 831 | usage(argv[0]); |
|---|
| 832 | return -1; |
|---|
| 833 | } |
|---|
| 834 | else if (!strcmp(argv[i], "-pcr") && i+1<argc) { |
|---|
| 835 | opts->pcrPid = strtoul(argv[++i], NULL, 0); |
|---|
| 836 | } |
|---|
| 837 | else if (!strcmp(argv[i], "-mpeg_type") && i+1<argc) { |
|---|
| 838 | opts->transportType=lookup(g_transportTypeStrs, argv[++i]); |
|---|
| 839 | } |
|---|
| 840 | else if (!strcmp(argv[i], "-display_format") && i+1<argc) { |
|---|
| 841 | opts->displayFormat=lookup(g_videoFormatStrs, argv[++i]); |
|---|
| 842 | if (opts->displayFormat >= NEXUS_VideoFormat_e480p) { |
|---|
| 843 | opts->useCompositeOutput = false; |
|---|
| 844 | } |
|---|
| 845 | } |
|---|
| 846 | else if (!strcmp(argv[i], "-ar") && i+1<argc) { |
|---|
| 847 | opts->contentMode = lookup(g_contentModeStrs, argv[++i]); |
|---|
| 848 | } |
|---|
| 849 | else if (!strcmp(argv[i], "-video") && i+1<argc) { |
|---|
| 850 | opts->videoPid = strtoul(argv[++i], NULL, 0); |
|---|
| 851 | } |
|---|
| 852 | else if (!strcmp(argv[i], "-ext_video") && i+1<argc) { |
|---|
| 853 | opts->extVideoPid = strtoul(argv[++i], NULL, 0); |
|---|
| 854 | } |
|---|
| 855 | else if (!strcmp(argv[i], "-audio") && i+1<argc) { |
|---|
| 856 | opts->audioPid = strtoul(argv[++i], NULL, 0); |
|---|
| 857 | state->isVideoEs = false; |
|---|
| 858 | } |
|---|
| 859 | else if (!strcmp(argv[i], "-video_type") && i+1<argc) { |
|---|
| 860 | opts->videoCodec=lookup(g_videoCodecStrs, argv[++i]); |
|---|
| 861 | } |
|---|
| 862 | else if (!strcmp(argv[i], "-ext_video_type") && i+1<argc) { |
|---|
| 863 | opts->extVideoCodec=lookup(g_videoCodecStrs, argv[++i]); |
|---|
| 864 | } |
|---|
| 865 | else if (!strcmp(argv[i], "-audio_type") && i+1<argc) { |
|---|
| 866 | opts->audioCodec=lookup(g_audioCodecStrs, argv[++i]); |
|---|
| 867 | state->isVideoEs = false; |
|---|
| 868 | } |
|---|
| 869 | /* Note: leave in these options even if the hardware doesn't exist so we don't break any scripts that don't know what is available */ |
|---|
| 870 | else if (!strcmp(argv[i], "-composite") && i+1<argc) { |
|---|
| 871 | opts->useCompositeOutput = strcasecmp(argv[++i], "off"); |
|---|
| 872 | } |
|---|
| 873 | else if (!strcmp(argv[i], "-component") && i+1<argc) { |
|---|
| 874 | opts->useComponentOutput = strcasecmp(argv[++i], "off"); |
|---|
| 875 | } |
|---|
| 876 | else if (!strcmp(argv[i], "-hdmi") && i+1<argc) { |
|---|
| 877 | opts->useHdmiOutput = strcasecmp(argv[++i], "off"); |
|---|
| 878 | } |
|---|
| 879 | else if (!strcmp(argv[i], "-scart1composite") && i+1<argc) { |
|---|
| 880 | opts->useScart1CompositeOutput = strcasecmp(argv[++i], "off"); |
|---|
| 881 | opts->usePanelOutput = false; |
|---|
| 882 | opts->displayFormat = NEXUS_VideoFormat_ePal; |
|---|
| 883 | } |
|---|
| 884 | else if (!strcmp(argv[i], "-video_cdb") && i+1<argc) { |
|---|
| 885 | opts->videoCdb = strtoul(argv[++i], NULL, 0); |
|---|
| 886 | } |
|---|
| 887 | else if (!strcmp(argv[i], "-audio_cdb") && i+1<argc) { |
|---|
| 888 | opts->audioCdb = strtoul(argv[++i], NULL, 0); |
|---|
| 889 | } |
|---|
| 890 | else if (!strcmp(argv[i], "-probe")) { |
|---|
| 891 | opts->probe = true; |
|---|
| 892 | } |
|---|
| 893 | else if (!strcmp(argv[i], "-panel") && i+1<argc) { |
|---|
| 894 | unsigned paneltype = lookup(g_panelStrs, argv[++i]); |
|---|
| 895 | |
|---|
| 896 | /* for now, use output_resolution env to get into platform */ |
|---|
| 897 | switch (paneltype) { |
|---|
| 898 | case 0: |
|---|
| 899 | opts->usePanelOutput = true; |
|---|
| 900 | opts->displayFormat = NEXUS_VideoFormat_eCustom0; |
|---|
| 901 | setenv("output_resolution", "wxga", true); |
|---|
| 902 | setenv("bvn_usage", "config1", true); |
|---|
| 903 | break; |
|---|
| 904 | case 1: |
|---|
| 905 | opts->usePanelOutput = true; |
|---|
| 906 | opts->displayFormat = NEXUS_VideoFormat_eCustom1; |
|---|
| 907 | setenv("output_resolution", "wxga", true); |
|---|
| 908 | setenv("bvn_usage", "config1", true); |
|---|
| 909 | break; |
|---|
| 910 | case 2: |
|---|
| 911 | opts->usePanelOutput = true; |
|---|
| 912 | opts->displayFormat = NEXUS_VideoFormat_eCustom0; |
|---|
| 913 | setenv("output_resolution", "fhd", true); |
|---|
| 914 | setenv("bvn_usage", "config2", true); |
|---|
| 915 | break; |
|---|
| 916 | case 3: |
|---|
| 917 | opts->usePanelOutput = true; |
|---|
| 918 | opts->displayFormat = NEXUS_VideoFormat_eCustom1; |
|---|
| 919 | setenv("output_resolution", "fhd", true); |
|---|
| 920 | setenv("bvn_usage", "config2", true); |
|---|
| 921 | break; |
|---|
| 922 | /* TODO: XGA 60 & 50 */ |
|---|
| 923 | default: |
|---|
| 924 | case 4: |
|---|
| 925 | opts->usePanelOutput = false; /* off */ |
|---|
| 926 | break; |
|---|
| 927 | } |
|---|
| 928 | } |
|---|
| 929 | else if (!strcmp(argv[i], "-mad")) { |
|---|
| 930 | opts->mad = true; |
|---|
| 931 | } |
|---|
| 932 | else if (!strcmp(argv[i], "-compressed_audio")) { |
|---|
| 933 | opts->compressedAudio = true; |
|---|
| 934 | } |
|---|
| 935 | else if (!strcmp(argv[i], "-multichannel_audio")) { |
|---|
| 936 | opts->multichannelAudio = true; |
|---|
| 937 | } |
|---|
| 938 | else if (!strcmp(argv[i], "-video_decoder") && i+1<argc) { |
|---|
| 939 | opts->videoDecoder= strtoul(argv[++i], NULL, 0); |
|---|
| 940 | } |
|---|
| 941 | else if (!strcmp(argv[i], "-frame_rate") && i+1<argc) { |
|---|
| 942 | opts->videoFrameRate=lookup(g_videoFrameRateStrs, argv[++i]); |
|---|
| 943 | } |
|---|
| 944 | else if (!strcmp(argv[i], "-ts_timestamp") && i+1<argc) { |
|---|
| 945 | opts->tsTimestampType=lookup(g_tsTimestampType, argv[++i]); |
|---|
| 946 | } |
|---|
| 947 | else if (!strcmp(argv[i], "-detect_avc_extension")) { |
|---|
| 948 | opts->detectAvcExtension = true; |
|---|
| 949 | } |
|---|
| 950 | else if (!strcmp(argv[i], "-host_reorder")) { |
|---|
| 951 | opts->playpumpTimestampReordering = true; |
|---|
| 952 | } |
|---|
| 953 | else if (!strcmp(argv[i], "-no_decoded_audio")) { |
|---|
| 954 | opts->decodedAudio = false; |
|---|
| 955 | } |
|---|
| 956 | else if (!strcmp(argv[i], "-display_3d") && i+1<argc) { |
|---|
| 957 | opts->displayOrientation=lookup(g_videoOrientation, argv[++i]); |
|---|
| 958 | } |
|---|
| 959 | else if (!strcmp(argv[i], "-source_3d") && i+1<argc) { |
|---|
| 960 | opts->sourceOrientation=lookup(g_sourceOrientation, argv[++i]); |
|---|
| 961 | } |
|---|
| 962 | else if (!strcmp(argv[i], "-pcm") && i+1<argc) { |
|---|
| 963 | unsigned channel_count = opts->pcm_config.channel_count; |
|---|
| 964 | unsigned sample_size = opts->pcm_config.sample_size; |
|---|
| 965 | unsigned sample_rate = opts->pcm_config.sample_rate; |
|---|
| 966 | |
|---|
| 967 | sscanf(argv[++i], "%u,%u,%u", &sample_rate, &channel_count, &sample_size); |
|---|
| 968 | opts->pcm_config.channel_count = channel_count; |
|---|
| 969 | opts->pcm_config.sample_size = sample_size; |
|---|
| 970 | opts->pcm_config.sample_rate = sample_rate; |
|---|
| 971 | opts->pcm = true; |
|---|
| 972 | } |
|---|
| 973 | else { |
|---|
| 974 | return i; |
|---|
| 975 | } |
|---|
| 976 | } |
|---|
| 977 | |
|---|
| 978 | if (opts->usePanelOutput) { |
|---|
| 979 | opts->displayType = NEXUS_DisplayType_eLvds; |
|---|
| 980 | opts->useComponentOutput = false; |
|---|
| 981 | opts->useCompositeOutput = false; |
|---|
| 982 | } |
|---|
| 983 | else { |
|---|
| 984 | opts->displayType = NEXUS_DisplayType_eAuto; |
|---|
| 985 | } |
|---|
| 986 | |
|---|
| 987 | /* this allows the user to set: "-mpeg_type es -video_type mpeg" and forget the "-video 1" option */ |
|---|
| 988 | if (opts->transportType == NEXUS_TransportType_eEs && !opts->videoPid && !opts->audioPid) { |
|---|
| 989 | if (state->isVideoEs) { |
|---|
| 990 | opts->videoPid = 1; |
|---|
| 991 | } |
|---|
| 992 | else { |
|---|
| 993 | opts->audioPid = 1; |
|---|
| 994 | } |
|---|
| 995 | } |
|---|
| 996 | |
|---|
| 997 | return 0; |
|---|
| 998 | } |
|---|
| 999 | |
|---|
| 1000 | int cmdline_parse(int argc, const char *argv[], struct util_opts_t *opts) |
|---|
| 1001 | { |
|---|
| 1002 | struct cmdline_parse_common_state state; |
|---|
| 1003 | int i; |
|---|
| 1004 | int rc=-1; |
|---|
| 1005 | BSTD_UNUSED(argc); |
|---|
| 1006 | BSTD_UNUSED(argv); |
|---|
| 1007 | |
|---|
| 1008 | memset(opts,0,sizeof(*opts)); |
|---|
| 1009 | opts->stcChannelMaster = NEXUS_StcChannelAutoModeBehavior_eVideoMaster; |
|---|
| 1010 | opts->beginningOfStreamAction = NEXUS_PlaybackLoopMode_eLoop; |
|---|
| 1011 | opts->endOfStreamAction = NEXUS_PlaybackLoopMode_eLoop; |
|---|
| 1012 | opts->videoErrorHandling = NEXUS_VideoDecoderErrorHandling_eNone; |
|---|
| 1013 | opts->customFileIo = false; |
|---|
| 1014 | opts->playbackMonitor = false; |
|---|
| 1015 | opts->startPaused = false; |
|---|
| 1016 | opts->maxPlaybackDataRate = 0; |
|---|
| 1017 | |
|---|
| 1018 | for (i=0;i<argc;i++) |
|---|
| 1019 | { |
|---|
| 1020 | rc = cmdline_parse_common(i, argc, argv, &opts->common, &state, print_usage); |
|---|
| 1021 | if(rc==0) break; |
|---|
| 1022 | if(rc<0) return rc; |
|---|
| 1023 | |
|---|
| 1024 | /* unknown option */ |
|---|
| 1025 | i = rc; |
|---|
| 1026 | if (!strcmp(argv[i], "-bof") && i+1<argc) { |
|---|
| 1027 | opts->beginningOfStreamAction=lookup(g_endOfStreamActionStrs, argv[++i]); |
|---|
| 1028 | } |
|---|
| 1029 | else if (!strcmp(argv[i], "-eof") && i+1<argc) { |
|---|
| 1030 | opts->endOfStreamAction=lookup(g_endOfStreamActionStrs, argv[++i]); |
|---|
| 1031 | } |
|---|
| 1032 | else if (!strcmp(argv[i], "-master") && i+1<argc) { |
|---|
| 1033 | opts->stcChannelMaster=lookup(g_stcChannelMasterStrs, argv[++i]); |
|---|
| 1034 | } |
|---|
| 1035 | else if (!strcmp(argv[i], "-cc") && i+1<argc) { |
|---|
| 1036 | opts->closedCaptionEnabled = strcasecmp(argv[++i], "off"); |
|---|
| 1037 | } |
|---|
| 1038 | else if (!strcmp(argv[i], "-stctrick")) { |
|---|
| 1039 | opts->stcTrick = true; |
|---|
| 1040 | } |
|---|
| 1041 | else if (!strcmp(argv[i], "-astm")) { |
|---|
| 1042 | opts->astm = true; |
|---|
| 1043 | } |
|---|
| 1044 | else if (!strcmp(argv[i], "-sync")) { |
|---|
| 1045 | opts->sync = true; |
|---|
| 1046 | } |
|---|
| 1047 | else if (!strcmp(argv[i], "-custom_file_io")) { |
|---|
| 1048 | opts->customFileIo=true; |
|---|
| 1049 | } |
|---|
| 1050 | else if (!strcmp(argv[i], "-playback_monitor")) { |
|---|
| 1051 | opts->playbackMonitor=true; |
|---|
| 1052 | } |
|---|
| 1053 | else if (!strcmp(argv[i], "-stream_processing")) { |
|---|
| 1054 | opts->streamProcessing = true; |
|---|
| 1055 | } |
|---|
| 1056 | else if (!strcmp(argv[i], "-auto_bitrate")) { |
|---|
| 1057 | opts->autoBitrate = true; |
|---|
| 1058 | } |
|---|
| 1059 | else if (!strcmp(argv[i], "-fixed_bitrate") && i+1<argc) { |
|---|
| 1060 | opts->fixedBitrate = strtoul(argv[++i], NULL, 0); |
|---|
| 1061 | } |
|---|
| 1062 | else if (!strcmp(argv[i], "-graphics")) { |
|---|
| 1063 | opts->graphics = true; |
|---|
| 1064 | } |
|---|
| 1065 | else if (!strcmp(argv[i], "-avc51")) { |
|---|
| 1066 | opts->avc51= true; |
|---|
| 1067 | } |
|---|
| 1068 | else if (!strcmp(argv[i], "-max_decoder_rate") && i+1<argc) { |
|---|
| 1069 | opts->maxDecoderRate=atof(argv[++i])*NEXUS_NORMAL_PLAY_SPEED; |
|---|
| 1070 | } |
|---|
| 1071 | else if (!strcmp(argv[i], "-video_error_handling") && i+1<argc) { |
|---|
| 1072 | opts->videoErrorHandling=lookup(g_videoErrorHandling, argv[++i]); |
|---|
| 1073 | } |
|---|
| 1074 | else if (!strcmp(argv[i], "-start_paused")) { |
|---|
| 1075 | opts->startPaused = true; |
|---|
| 1076 | } |
|---|
| 1077 | else if (!strcmp(argv[i], "-max_playback_data_rate") && i+1<argc) { |
|---|
| 1078 | opts->maxPlaybackDataRate=atof(argv[++i])*1000; |
|---|
| 1079 | } |
|---|
| 1080 | else if (!strcmp(argv[i], "-cmp_crc")) { |
|---|
| 1081 | opts->cmp_crc = true; |
|---|
| 1082 | } |
|---|
| 1083 | else if (!strcmp(argv[i], "-avd_crc")) { |
|---|
| 1084 | opts->avd_crc = true; |
|---|
| 1085 | } |
|---|
| 1086 | else if (!opts->filename) { |
|---|
| 1087 | opts->filename = argv[i]; |
|---|
| 1088 | } |
|---|
| 1089 | else if (!opts->indexname) { |
|---|
| 1090 | opts->indexname = argv[i]; |
|---|
| 1091 | } |
|---|
| 1092 | else { |
|---|
| 1093 | printf("unknown parameter: '%s'\n", argv[i]); |
|---|
| 1094 | return -1; |
|---|
| 1095 | } |
|---|
| 1096 | } |
|---|
| 1097 | if(rc!=0) { |
|---|
| 1098 | cmdline_parse_common(i, argc, argv, &opts->common, &state, print_usage); /* allow common parser to execute finishing touches */ |
|---|
| 1099 | } |
|---|
| 1100 | |
|---|
| 1101 | /* default -probe for playback if no -video or -audio option */ |
|---|
| 1102 | if (opts->filename && !opts->common.videoPid && !opts->common.audioPid) { |
|---|
| 1103 | opts->common.probe = true; |
|---|
| 1104 | } |
|---|
| 1105 | return 0; |
|---|
| 1106 | } |
|---|
| 1107 | |
|---|
| 1108 | void print_usage_record(const char *app) |
|---|
| 1109 | { |
|---|
| 1110 | printf("%s usage: nexus %s [-options] datafile [indexfile]", app, app); |
|---|
| 1111 | print_usage_common(); |
|---|
| 1112 | printf( |
|---|
| 1113 | " -decode{on|off} - A/V decode of source during record"); |
|---|
| 1114 | printf( |
|---|
| 1115 | "\n -streamer - (default)" |
|---|
| 1116 | "\n -playfile - playback file to be used as source"); |
|---|
| 1117 | #if NEXUS_HAS_FRONTEND |
|---|
| 1118 | printf("\n -vsb"); |
|---|
| 1119 | print_list(g_vsbModeStrs); |
|---|
| 1120 | printf("\n -qam"); |
|---|
| 1121 | print_list(g_qamModeStrs); |
|---|
| 1122 | printf("\n -sat"); |
|---|
| 1123 | print_list(g_satModeStrs); |
|---|
| 1124 | #endif |
|---|
| 1125 | #if NEXUS_HAS_HDMI_INPUT |
|---|
| 1126 | printf("\n -hdmi_input"); |
|---|
| 1127 | #endif |
|---|
| 1128 | #if NEXUS_HAS_VIDEO_ENCODER |
|---|
| 1129 | printf("\n -encode - enable video encoder"); |
|---|
| 1130 | printf("\n -encode_video_type"); |
|---|
| 1131 | print_list(g_videoCodecStrs); |
|---|
| 1132 | printf("\n -video_codec_profile"); |
|---|
| 1133 | print_list(g_videoCodecProfileStrs); |
|---|
| 1134 | printf("\n -video_codec_level"); |
|---|
| 1135 | print_list(g_videoCodecLevelStrs); |
|---|
| 1136 | printf("\n -encode_format"); |
|---|
| 1137 | print_list(g_videoFormatStrs); |
|---|
| 1138 | printf("\n -encode_frame_rate"); |
|---|
| 1139 | print_list(g_videoFrameRateStrs); |
|---|
| 1140 | printf("\n -video_bit_rate MAX - video encoder max bit rate"); |
|---|
| 1141 | printf("\n -gop_frameP num_of_P_between_Is"); |
|---|
| 1142 | printf("\n -gop_frameB num_of_B_between_IPs "); |
|---|
| 1143 | printf("\n -mux_latency_tolerance MSEC - Stream MUX latency tolerance in number of msecs"); |
|---|
| 1144 | printf("\n -encode_audio"); |
|---|
| 1145 | printf("\n -audio_bit_rate"); |
|---|
| 1146 | printf("\n -encode_audio_type"); |
|---|
| 1147 | print_list(g_audioCodecStrs); |
|---|
| 1148 | #endif |
|---|
| 1149 | printf( |
|---|
| 1150 | "\n -freq - tuner frequency in MHz" |
|---|
| 1151 | "\n -probe - use media probe to discover stream format for playback" |
|---|
| 1152 | "\n -allpass - allpass record" |
|---|
| 1153 | "\n -acceptnull - record null packets in source stream (applies only to allpass record)" |
|---|
| 1154 | "\n -data_buffer_size - CDB size in bytes" |
|---|
| 1155 | "\n -data_data_ready_threshold - CDB interrupt threshold in bytes"); |
|---|
| 1156 | printf( |
|---|
| 1157 | "\n -index_buffer_size - ITB size in bytes" |
|---|
| 1158 | "\n -index_data_ready_threshold - ITB interrupt threshold in bytes" |
|---|
| 1159 | "\n -video_decoder index - Selects video decoder index" |
|---|
| 1160 | "\n"); |
|---|
| 1161 | return; |
|---|
| 1162 | } |
|---|
| 1163 | |
|---|
| 1164 | int cmdline_parse_record(int argc, const char *argv[], struct util_opts_record_t *opts) |
|---|
| 1165 | { |
|---|
| 1166 | int i; |
|---|
| 1167 | int rc=-1; |
|---|
| 1168 | struct cmdline_parse_common_state state; |
|---|
| 1169 | |
|---|
| 1170 | memset(opts,0,sizeof(*opts)); |
|---|
| 1171 | #if NEXUS_HAS_FRONTEND |
|---|
| 1172 | opts->vsbMode = NEXUS_FrontendVsbMode_eMax; |
|---|
| 1173 | opts->qamMode = NEXUS_FrontendQamMode_eMax; |
|---|
| 1174 | opts->satMode = NEXUS_FrontendSatelliteMode_eMax; |
|---|
| 1175 | #endif |
|---|
| 1176 | #if NEXUS_HAS_HDMI_INPUT |
|---|
| 1177 | opts->hdmiInput = false; |
|---|
| 1178 | #endif |
|---|
| 1179 | #if NEXUS_HAS_VIDEO_ENCODER |
|---|
| 1180 | opts->encoder = false; |
|---|
| 1181 | opts->encodeFormat = NEXUS_VideoFormat_e480p; |
|---|
| 1182 | opts->videoTranscodec = NEXUS_VideoCodec_eH264; |
|---|
| 1183 | opts->videoProfile = NEXUS_VideoCodecProfile_eBaseline; |
|---|
| 1184 | opts->videoLevel = NEXUS_VideoCodecLevel_e31; |
|---|
| 1185 | opts->encodeFrameRate = NEXUS_VideoFrameRate_e29_97; |
|---|
| 1186 | opts->variableFrameRate = true; |
|---|
| 1187 | opts->maxVideoBitRate = 8*1000*1000; |
|---|
| 1188 | opts->gopFrameP = 0; |
|---|
| 1189 | opts->gopFrameB = 0; |
|---|
| 1190 | opts->muxLatencyTolerance = 20; /* 20 msec */ |
|---|
| 1191 | opts->audioEncode = false; |
|---|
| 1192 | opts->audioBitRate = 48000; |
|---|
| 1193 | opts->audioTranscodec = NEXUS_AudioCodec_eAac; |
|---|
| 1194 | #endif |
|---|
| 1195 | opts->decode = true; |
|---|
| 1196 | |
|---|
| 1197 | for (i=0;i<argc;i++) |
|---|
| 1198 | { |
|---|
| 1199 | rc = cmdline_parse_common(i, argc, argv, &opts->common, &state, print_usage); |
|---|
| 1200 | if(rc==0) break; |
|---|
| 1201 | if(rc<0) return rc; |
|---|
| 1202 | |
|---|
| 1203 | /* unknown option */ |
|---|
| 1204 | i = rc; |
|---|
| 1205 | if (!strcmp(argv[i], "-pids") && i+1<argc) { |
|---|
| 1206 | unsigned j; |
|---|
| 1207 | char *cur, pid[16+1]; |
|---|
| 1208 | const char *prev; |
|---|
| 1209 | |
|---|
| 1210 | /* parse the comma-separated list of pids */ |
|---|
| 1211 | j=0; |
|---|
| 1212 | prev=argv[i+1]; |
|---|
| 1213 | while (j<MAX_RECORD_PIDS) { |
|---|
| 1214 | if ((cur=strchr(prev,','))) { |
|---|
| 1215 | if ((cur-prev)/sizeof(*cur)>16) { continue; } |
|---|
| 1216 | strncpy(pid,prev,(cur-prev)/sizeof(*cur)); |
|---|
| 1217 | opts->otherPids[j] = strtoul(pid, NULL, 0); |
|---|
| 1218 | j++; |
|---|
| 1219 | prev = cur+1; |
|---|
| 1220 | } |
|---|
| 1221 | else { |
|---|
| 1222 | strncpy(pid,prev,sizeof(pid)); |
|---|
| 1223 | opts->otherPids[j] = strtoul(pid, NULL, 0); |
|---|
| 1224 | j++; |
|---|
| 1225 | break; |
|---|
| 1226 | } |
|---|
| 1227 | pid[0]='\0'; |
|---|
| 1228 | } |
|---|
| 1229 | opts->numOtherPids = j; |
|---|
| 1230 | i++; |
|---|
| 1231 | } |
|---|
| 1232 | else if (!strcmp(argv[i], "-decode") && i+1<argc) { |
|---|
| 1233 | opts->decode = strcasecmp(argv[++i], "off"); |
|---|
| 1234 | } |
|---|
| 1235 | else if (!strcmp(argv[i], "-streamer")) { |
|---|
| 1236 | opts->streamer = true; |
|---|
| 1237 | } |
|---|
| 1238 | else if (!strcmp(argv[i], "-playfile")) { |
|---|
| 1239 | opts->playfname = argv[++i]; |
|---|
| 1240 | printf("-playfile %s\n", opts->playfname); |
|---|
| 1241 | } |
|---|
| 1242 | #if NEXUS_HAS_FRONTEND |
|---|
| 1243 | else if (!strcmp(argv[i], "-vsb")) { |
|---|
| 1244 | opts->vsbMode = lookup(g_vsbModeStrs, argv[++i]); |
|---|
| 1245 | } |
|---|
| 1246 | else if (!strcmp(argv[i], "-qam")) { |
|---|
| 1247 | opts->qamMode = lookup(g_qamModeStrs, argv[++i]); |
|---|
| 1248 | } |
|---|
| 1249 | else if (!strcmp(argv[i], "-sat")) { |
|---|
| 1250 | opts->satMode = lookup(g_satModeStrs, argv[++i]); |
|---|
| 1251 | } |
|---|
| 1252 | else if (!strcmp(argv[i], "-freq")) { |
|---|
| 1253 | opts->freq = strtoul(argv[++i], NULL, 0); |
|---|
| 1254 | } |
|---|
| 1255 | #endif |
|---|
| 1256 | #if NEXUS_HAS_HDMI_INPUT |
|---|
| 1257 | else if (!strcmp(argv[i], "-hdmi_input")) { |
|---|
| 1258 | opts->hdmiInput = true; |
|---|
| 1259 | } |
|---|
| 1260 | #endif |
|---|
| 1261 | #if NEXUS_HAS_VIDEO_ENCODER |
|---|
| 1262 | else if (!strcmp(argv[i], "-encode")) { |
|---|
| 1263 | opts->encoder = true; |
|---|
| 1264 | } |
|---|
| 1265 | else if (!strcmp(argv[i], "-encode_audio")) { |
|---|
| 1266 | opts->audioEncode = true; |
|---|
| 1267 | } |
|---|
| 1268 | else if (!strcmp(argv[i], "-audio_bit_rate")) { |
|---|
| 1269 | opts->audioBitRate = strtoul(argv[++i], NULL, 0); |
|---|
| 1270 | } |
|---|
| 1271 | else if (!strcmp(argv[i], "-encode_audio_type")) { |
|---|
| 1272 | opts->audioTranscodec = lookup(g_audioCodecStrs, argv[++i]); |
|---|
| 1273 | } |
|---|
| 1274 | else if (!strcmp(argv[i], "-encode_format")) { |
|---|
| 1275 | opts->encodeFormat = lookup(g_videoFormatStrs, argv[++i]); |
|---|
| 1276 | } |
|---|
| 1277 | else if (!strcmp(argv[i], "-encode_video_type")) { |
|---|
| 1278 | opts->videoTranscodec = lookup(g_videoCodecStrs, argv[++i]); |
|---|
| 1279 | } |
|---|
| 1280 | else if (!strcmp(argv[i], "-video_codec_profile")) { |
|---|
| 1281 | opts->videoProfile = lookup(g_videoCodecProfileStrs, argv[++i]); |
|---|
| 1282 | } |
|---|
| 1283 | else if (!strcmp(argv[i], "-video_codec_level")) { |
|---|
| 1284 | opts->videoLevel = lookup(g_videoCodecLevelStrs, argv[++i]); |
|---|
| 1285 | } |
|---|
| 1286 | else if (!strcmp(argv[i], "-encode_frame_rate")) { |
|---|
| 1287 | opts->encodeFrameRate = lookup(g_videoFrameRateStrs, argv[++i]); |
|---|
| 1288 | } |
|---|
| 1289 | else if (!strcmp(argv[i], "-video_bit_rate")) { |
|---|
| 1290 | opts->maxVideoBitRate = strtoul(argv[++i], NULL, 0); |
|---|
| 1291 | } |
|---|
| 1292 | else if (!strcmp(argv[i], "-gop_frameP")) { |
|---|
| 1293 | opts->gopFrameP = strtoul(argv[++i], NULL, 0); |
|---|
| 1294 | } |
|---|
| 1295 | else if (!strcmp(argv[i], "-gop_frameB")) { |
|---|
| 1296 | opts->gopFrameB = strtoul(argv[++i], NULL, 0); |
|---|
| 1297 | } |
|---|
| 1298 | else if (!strcmp(argv[i], "-mux_latency_tolerance")) { |
|---|
| 1299 | opts->muxLatencyTolerance = strtoul(argv[++i], NULL, 0); |
|---|
| 1300 | } |
|---|
| 1301 | #endif |
|---|
| 1302 | else if (!strcmp(argv[i], "-allpass")) { |
|---|
| 1303 | opts->allpass = true; |
|---|
| 1304 | } |
|---|
| 1305 | else if (!strcmp(argv[i], "-acceptnull")) { |
|---|
| 1306 | opts->acceptNullPackets = true; |
|---|
| 1307 | } |
|---|
| 1308 | else if (!strcmp(argv[i], "-data_buffer_size") && i+1<argc) { |
|---|
| 1309 | opts->data.bufferSize = strtoul(argv[++i], NULL, 0); |
|---|
| 1310 | } |
|---|
| 1311 | else if (!strcmp(argv[i], "-data_data_ready_threshold") && i+1<argc) { |
|---|
| 1312 | opts->data.dataReadyThreshold = strtoul(argv[++i], NULL, 0); |
|---|
| 1313 | } |
|---|
| 1314 | else if (!strcmp(argv[i], "-index_buffer_size") && i+1<argc) { |
|---|
| 1315 | opts->index.bufferSize = strtoul(argv[++i], NULL, 0); |
|---|
| 1316 | } |
|---|
| 1317 | else if (!strcmp(argv[i], "-index_data_ready_threshold") && i+1<argc) { |
|---|
| 1318 | opts->index.dataReadyThreshold = strtoul(argv[++i], NULL, 0); |
|---|
| 1319 | } |
|---|
| 1320 | else if (!opts->recfname) { |
|---|
| 1321 | opts->recfname = argv[i]; |
|---|
| 1322 | } |
|---|
| 1323 | else if (!opts->recidxname) { |
|---|
| 1324 | opts->recidxname = argv[i]; |
|---|
| 1325 | } |
|---|
| 1326 | else { |
|---|
| 1327 | printf("unknown param %s\n", argv[i]); |
|---|
| 1328 | return -1; |
|---|
| 1329 | } |
|---|
| 1330 | } |
|---|
| 1331 | |
|---|
| 1332 | if(rc!=0) { |
|---|
| 1333 | cmdline_parse_common(i, argc, argv, &opts->common, &state, print_usage); /* allow common parser to execute finishing touches */ |
|---|
| 1334 | } |
|---|
| 1335 | |
|---|
| 1336 | if (!opts->recidxname) { /* if index is specified, require video codec to be explicit. otherwise, default to MPEG2 */ |
|---|
| 1337 | opts->common.videoCodec = NEXUS_VideoCodec_eMpeg2; |
|---|
| 1338 | } |
|---|
| 1339 | return 0; |
|---|
| 1340 | } |
|---|
| 1341 | |
|---|
| 1342 | int cmdline_probe(struct common_opts_t *opts, const char *filename, const char **indexname) |
|---|
| 1343 | { |
|---|
| 1344 | int rc = 0; |
|---|
| 1345 | |
|---|
| 1346 | if (opts->probe) { |
|---|
| 1347 | /* use media probe to set values */ |
|---|
| 1348 | bmedia_probe_t probe = NULL; |
|---|
| 1349 | bmedia_probe_config probe_config; |
|---|
| 1350 | const bmedia_probe_stream *stream = NULL; |
|---|
| 1351 | const bmedia_probe_track *track = NULL; |
|---|
| 1352 | bfile_io_read_t fd = NULL; |
|---|
| 1353 | bpcm_file_t pcm_file = NULL; |
|---|
| 1354 | bool foundAudio = false, foundVideo = false; |
|---|
| 1355 | FILE *fin; |
|---|
| 1356 | char stream_info[512]; |
|---|
| 1357 | |
|---|
| 1358 | probe = bmedia_probe_create(); |
|---|
| 1359 | |
|---|
| 1360 | opts->videoCodec = NEXUS_VideoCodec_eUnknown; |
|---|
| 1361 | opts->audioCodec = NEXUS_AudioCodec_eUnknown; |
|---|
| 1362 | |
|---|
| 1363 | fin = fopen64(filename,"rb"); |
|---|
| 1364 | if (!fin) { |
|---|
| 1365 | printf("can't open media file '%s' for probing\n", filename); |
|---|
| 1366 | rc = -1; |
|---|
| 1367 | goto done; |
|---|
| 1368 | } |
|---|
| 1369 | |
|---|
| 1370 | fd = bfile_stdio_read_attach(fin); |
|---|
| 1371 | if(opts->pcm) { |
|---|
| 1372 | pcm_file = bpcm_file_create(fd, &opts->pcm_config); |
|---|
| 1373 | BDBG_ASSERT(pcm_file); |
|---|
| 1374 | } |
|---|
| 1375 | |
|---|
| 1376 | bmedia_probe_default_cfg(&probe_config); |
|---|
| 1377 | probe_config.file_name = filename; |
|---|
| 1378 | probe_config.type = bstream_mpeg_type_unknown; |
|---|
| 1379 | stream = bmedia_probe_parse(probe, pcm_file?bpcm_file_get_file_interface(pcm_file):fd, &probe_config); |
|---|
| 1380 | |
|---|
| 1381 | if(stream && stream->type == bstream_mpeg_type_cdxa) { |
|---|
| 1382 | bcdxa_file_t cdxa_file; |
|---|
| 1383 | bmedia_stream_to_string(stream, stream_info, sizeof(stream_info)); |
|---|
| 1384 | printf( "Media Probe:\n" "%s\n\n", stream_info); |
|---|
| 1385 | cdxa_file = bcdxa_file_create(fd); |
|---|
| 1386 | if(cdxa_file) { |
|---|
| 1387 | const bmedia_probe_stream *cdxa_stream; |
|---|
| 1388 | cdxa_stream = bmedia_probe_parse(probe, bcdxa_file_get_file_interface(cdxa_file), &probe_config); |
|---|
| 1389 | bcdxa_file_destroy(cdxa_file); |
|---|
| 1390 | if(cdxa_stream) { |
|---|
| 1391 | bmedia_probe_stream_free(probe, stream); |
|---|
| 1392 | stream = cdxa_stream; |
|---|
| 1393 | opts->cdxaFile = true; |
|---|
| 1394 | } |
|---|
| 1395 | } |
|---|
| 1396 | } |
|---|
| 1397 | if (pcm_file) { |
|---|
| 1398 | bpcm_file_destroy(pcm_file); |
|---|
| 1399 | } |
|---|
| 1400 | |
|---|
| 1401 | /* now stream is either NULL, or stream descriptor with linked list of audio/video tracks */ |
|---|
| 1402 | bfile_stdio_read_detach(fd); |
|---|
| 1403 | |
|---|
| 1404 | fclose(fin); |
|---|
| 1405 | if(!stream) { |
|---|
| 1406 | printf("media probe can't parse stream '%s'\n", filename); |
|---|
| 1407 | rc = -1; |
|---|
| 1408 | goto done; |
|---|
| 1409 | } |
|---|
| 1410 | |
|---|
| 1411 | /* if the user has specified the index, don't override */ |
|---|
| 1412 | if (indexname && !*indexname) { |
|---|
| 1413 | if (stream->index == bmedia_probe_index_available || stream->index == bmedia_probe_index_required) { |
|---|
| 1414 | *indexname = filename; |
|---|
| 1415 | } |
|---|
| 1416 | } |
|---|
| 1417 | |
|---|
| 1418 | bmedia_stream_to_string(stream, stream_info, sizeof(stream_info)); |
|---|
| 1419 | printf( |
|---|
| 1420 | "Media Probe:\n" |
|---|
| 1421 | "%s\n\n", |
|---|
| 1422 | stream_info); |
|---|
| 1423 | |
|---|
| 1424 | opts->transportType = b_mpegtype2nexus(stream->type); |
|---|
| 1425 | |
|---|
| 1426 | if (stream->type == bstream_mpeg_type_ts) { |
|---|
| 1427 | if ((((bmpeg2ts_probe_stream*)stream)->pkt_len) == 192) { |
|---|
| 1428 | if(opts->tsTimestampType == NEXUS_TransportTimestampType_eNone) { |
|---|
| 1429 | opts->tsTimestampType = NEXUS_TransportTimestampType_eMod300; |
|---|
| 1430 | } |
|---|
| 1431 | } |
|---|
| 1432 | } |
|---|
| 1433 | |
|---|
| 1434 | for(track=BLST_SQ_FIRST(&stream->tracks);track;track=BLST_SQ_NEXT(track, link)) { |
|---|
| 1435 | switch(track->type) { |
|---|
| 1436 | case bmedia_track_type_audio: |
|---|
| 1437 | if(track->info.audio.codec != baudio_format_unknown && !foundAudio) { |
|---|
| 1438 | opts->audioPid = track->number; |
|---|
| 1439 | opts->audioCodec = b_audiocodec2nexus(track->info.audio.codec); |
|---|
| 1440 | foundAudio = true; |
|---|
| 1441 | } |
|---|
| 1442 | break; |
|---|
| 1443 | case bmedia_track_type_video: |
|---|
| 1444 | if(track->info.video.codec == bvideo_codec_h264_svc || track->info.video.codec == bvideo_codec_h264_mvc) { |
|---|
| 1445 | if(opts->detectAvcExtension) { |
|---|
| 1446 | opts->extVideoPid = track->number; |
|---|
| 1447 | opts->extVideoCodec = b_videocodec2nexus(track->info.video.codec); |
|---|
| 1448 | } |
|---|
| 1449 | break; |
|---|
| 1450 | } else if (track->info.video.codec != bvideo_codec_unknown && !foundVideo) { |
|---|
| 1451 | opts->videoPid = track->number; |
|---|
| 1452 | opts->videoCodec = b_videocodec2nexus(track->info.video.codec); |
|---|
| 1453 | foundVideo = true; |
|---|
| 1454 | /* timestamp reordering can be done at the host or decoder. |
|---|
| 1455 | to do it at the decoder, disable it at the host and use media_probe to |
|---|
| 1456 | determine the correct decoder timestamp mode */ |
|---|
| 1457 | if (opts->playpumpTimestampReordering == false) { |
|---|
| 1458 | opts->decoderTimestampMode = track->info.video.timestamp_order; |
|---|
| 1459 | } |
|---|
| 1460 | |
|---|
| 1461 | #if B_HAS_ASF |
|---|
| 1462 | if (stream->type == bstream_mpeg_type_asf) { |
|---|
| 1463 | basf_probe_track *asf_track = (basf_probe_track *)track; |
|---|
| 1464 | if (asf_track->aspectRatioValid) { |
|---|
| 1465 | opts->aspectRatio = NEXUS_AspectRatio_eSar; |
|---|
| 1466 | opts->sampleAspectRatio.x = asf_track->aspectRatio.x; |
|---|
| 1467 | opts->sampleAspectRatio.y = asf_track->aspectRatio.y; |
|---|
| 1468 | } |
|---|
| 1469 | if(asf_track->dynamicRangeControlValid) { |
|---|
| 1470 | opts->dynamicRangeControlValid = true; |
|---|
| 1471 | opts->dynamicRangeControl.peakReference = asf_track->dynamicRangeControl.peakReference; |
|---|
| 1472 | opts->dynamicRangeControl.peakTarget = asf_track->dynamicRangeControl.peakTarget; |
|---|
| 1473 | opts->dynamicRangeControl.averageReference = asf_track->dynamicRangeControl.averageReference; |
|---|
| 1474 | opts->dynamicRangeControl.averageTarget = asf_track->dynamicRangeControl.averageTarget; |
|---|
| 1475 | } |
|---|
| 1476 | } |
|---|
| 1477 | #endif |
|---|
| 1478 | } |
|---|
| 1479 | break; |
|---|
| 1480 | case bmedia_track_type_pcr: |
|---|
| 1481 | opts->pcrPid = track->number; |
|---|
| 1482 | break; |
|---|
| 1483 | default: |
|---|
| 1484 | break; |
|---|
| 1485 | } |
|---|
| 1486 | } |
|---|
| 1487 | |
|---|
| 1488 | #if B_HAS_AVI |
|---|
| 1489 | if (stream->type == bstream_mpeg_type_avi && ((bavi_probe_stream *)stream)->video_framerate && opts->videoFrameRate==0) { |
|---|
| 1490 | NEXUS_LookupFrameRate(((bavi_probe_stream *)stream)->video_framerate, &opts->videoFrameRate); |
|---|
| 1491 | } |
|---|
| 1492 | #endif |
|---|
| 1493 | |
|---|
| 1494 | done: |
|---|
| 1495 | if (probe) { |
|---|
| 1496 | if (stream) { |
|---|
| 1497 | bmedia_probe_stream_free(probe, stream); |
|---|
| 1498 | } |
|---|
| 1499 | bmedia_probe_destroy(probe); |
|---|
| 1500 | } |
|---|
| 1501 | } |
|---|
| 1502 | |
|---|
| 1503 | return rc; |
|---|
| 1504 | } |
|---|
| 1505 | |
|---|
| 1506 | struct { |
|---|
| 1507 | NEXUS_VideoCodec nexus; |
|---|
| 1508 | bvideo_codec settop; |
|---|
| 1509 | } g_videoCodec[] = { |
|---|
| 1510 | {NEXUS_VideoCodec_eUnknown, bvideo_codec_none}, |
|---|
| 1511 | {NEXUS_VideoCodec_eUnknown, bvideo_codec_unknown}, |
|---|
| 1512 | {NEXUS_VideoCodec_eMpeg1, bvideo_codec_mpeg1}, |
|---|
| 1513 | {NEXUS_VideoCodec_eMpeg2, bvideo_codec_mpeg2}, |
|---|
| 1514 | {NEXUS_VideoCodec_eMpeg4Part2, bvideo_codec_mpeg4_part2}, |
|---|
| 1515 | {NEXUS_VideoCodec_eH263, bvideo_codec_h263}, |
|---|
| 1516 | {NEXUS_VideoCodec_eH264, bvideo_codec_h264}, |
|---|
| 1517 | {NEXUS_VideoCodec_eH264_Svc, bvideo_codec_h264_svc}, |
|---|
| 1518 | {NEXUS_VideoCodec_eH264_Mvc, bvideo_codec_h264_mvc}, |
|---|
| 1519 | {NEXUS_VideoCodec_eVc1, bvideo_codec_vc1}, |
|---|
| 1520 | {NEXUS_VideoCodec_eVc1SimpleMain, bvideo_codec_vc1_sm}, |
|---|
| 1521 | {NEXUS_VideoCodec_eDivx311, bvideo_codec_divx_311}, |
|---|
| 1522 | {NEXUS_VideoCodec_eRv40, bvideo_codec_rv40}, |
|---|
| 1523 | {NEXUS_VideoCodec_eVp6, bvideo_codec_vp6}, |
|---|
| 1524 | {NEXUS_VideoCodec_eVp8, bvideo_codec_vp8}, |
|---|
| 1525 | {NEXUS_VideoCodec_eSpark, bvideo_codec_spark}, |
|---|
| 1526 | {NEXUS_VideoCodec_eMotionJpeg, bvideo_codec_mjpeg}, |
|---|
| 1527 | {NEXUS_VideoCodec_eAvs, bvideo_codec_avs} |
|---|
| 1528 | }; |
|---|
| 1529 | |
|---|
| 1530 | struct { |
|---|
| 1531 | NEXUS_AudioCodec nexus; |
|---|
| 1532 | baudio_format settop; |
|---|
| 1533 | } g_audioCodec[] = { |
|---|
| 1534 | {NEXUS_AudioCodec_eUnknown, baudio_format_unknown}, |
|---|
| 1535 | {NEXUS_AudioCodec_eMpeg, baudio_format_mpeg}, |
|---|
| 1536 | {NEXUS_AudioCodec_eMp3, baudio_format_mp3}, |
|---|
| 1537 | {NEXUS_AudioCodec_eAac, baudio_format_aac}, |
|---|
| 1538 | {NEXUS_AudioCodec_eAacPlus, baudio_format_aac_plus}, |
|---|
| 1539 | {NEXUS_AudioCodec_eAacPlusAdts, baudio_format_aac_plus_adts}, |
|---|
| 1540 | {NEXUS_AudioCodec_eAacPlusLoas, baudio_format_aac_plus_loas}, |
|---|
| 1541 | {NEXUS_AudioCodec_eAc3, baudio_format_ac3}, |
|---|
| 1542 | {NEXUS_AudioCodec_eAc3Plus, baudio_format_ac3_plus}, |
|---|
| 1543 | {NEXUS_AudioCodec_eDts, baudio_format_dts}, |
|---|
| 1544 | {NEXUS_AudioCodec_eLpcmHdDvd, baudio_format_lpcm_hddvd}, |
|---|
| 1545 | {NEXUS_AudioCodec_eLpcmBluRay, baudio_format_lpcm_bluray}, |
|---|
| 1546 | {NEXUS_AudioCodec_eDtsHd, baudio_format_dts_hd}, |
|---|
| 1547 | {NEXUS_AudioCodec_eWmaStd, baudio_format_wma_std}, |
|---|
| 1548 | {NEXUS_AudioCodec_eWmaPro, baudio_format_wma_pro}, |
|---|
| 1549 | {NEXUS_AudioCodec_eLpcmDvd, baudio_format_lpcm_dvd}, |
|---|
| 1550 | {NEXUS_AudioCodec_eAvs, baudio_format_avs}, |
|---|
| 1551 | {NEXUS_AudioCodec_eAmr, baudio_format_amr}, |
|---|
| 1552 | {NEXUS_AudioCodec_eDra, baudio_format_dra}, |
|---|
| 1553 | {NEXUS_AudioCodec_eCook, baudio_format_cook}, |
|---|
| 1554 | {NEXUS_AudioCodec_ePcmWav, baudio_format_pcm}, |
|---|
| 1555 | {NEXUS_AudioCodec_eAdpcm, baudio_format_adpcm}, |
|---|
| 1556 | {NEXUS_AudioCodec_eAdpcm, baudio_format_dvi_adpcm}, |
|---|
| 1557 | {NEXUS_AudioCodec_eVorbis, baudio_format_vorbis}, |
|---|
| 1558 | {NEXUS_AudioCodec_eLpcm1394, baudio_format_lpcm_1394}, |
|---|
| 1559 | {NEXUS_AudioCodec_eFlac, baudio_format_flac}, |
|---|
| 1560 | }; |
|---|
| 1561 | |
|---|
| 1562 | struct { |
|---|
| 1563 | NEXUS_TransportType nexus; |
|---|
| 1564 | unsigned settop; |
|---|
| 1565 | } g_mpegType[] = { |
|---|
| 1566 | {NEXUS_TransportType_eTs, bstream_mpeg_type_unknown}, |
|---|
| 1567 | {NEXUS_TransportType_eEs, bstream_mpeg_type_es}, |
|---|
| 1568 | {NEXUS_TransportType_eTs, bstream_mpeg_type_bes}, |
|---|
| 1569 | {NEXUS_TransportType_eMpeg2Pes, bstream_mpeg_type_pes}, |
|---|
| 1570 | {NEXUS_TransportType_eTs, bstream_mpeg_type_ts}, |
|---|
| 1571 | {NEXUS_TransportType_eDssEs, bstream_mpeg_type_dss_es}, |
|---|
| 1572 | {NEXUS_TransportType_eDssPes, bstream_mpeg_type_dss_pes}, |
|---|
| 1573 | {NEXUS_TransportType_eVob, bstream_mpeg_type_vob}, |
|---|
| 1574 | {NEXUS_TransportType_eAsf, bstream_mpeg_type_asf}, |
|---|
| 1575 | {NEXUS_TransportType_eAvi, bstream_mpeg_type_avi}, |
|---|
| 1576 | {NEXUS_TransportType_eMpeg1Ps, bstream_mpeg_type_mpeg1}, |
|---|
| 1577 | {NEXUS_TransportType_eMp4, bstream_mpeg_type_mp4}, |
|---|
| 1578 | {NEXUS_TransportType_eMkv, bstream_mpeg_type_mkv}, |
|---|
| 1579 | {NEXUS_TransportType_eWav, bstream_mpeg_type_wav}, |
|---|
| 1580 | {NEXUS_TransportType_eMp4Fragment, bstream_mpeg_type_mp4_fragment}, |
|---|
| 1581 | {NEXUS_TransportType_eRmff, bstream_mpeg_type_rmff}, |
|---|
| 1582 | {NEXUS_TransportType_eFlv, bstream_mpeg_type_flv}, |
|---|
| 1583 | {NEXUS_TransportType_eOgg, bstream_mpeg_type_ogg}, |
|---|
| 1584 | {NEXUS_TransportType_eFlac, bstream_mpeg_type_flac} |
|---|
| 1585 | }; |
|---|
| 1586 | |
|---|
| 1587 | #define CONVERT(g_struct) \ |
|---|
| 1588 | unsigned i; \ |
|---|
| 1589 | for (i=0;i<sizeof(g_struct)/sizeof(g_struct[0]);i++) { \ |
|---|
| 1590 | if (g_struct[i].settop == settop_value) { \ |
|---|
| 1591 | return g_struct[i].nexus; \ |
|---|
| 1592 | } \ |
|---|
| 1593 | } \ |
|---|
| 1594 | printf("unable to find value %d in %s\n", settop_value, #g_struct); \ |
|---|
| 1595 | return g_struct[0].nexus |
|---|
| 1596 | |
|---|
| 1597 | NEXUS_VideoCodec b_videocodec2nexus(bvideo_codec settop_value) |
|---|
| 1598 | { |
|---|
| 1599 | CONVERT(g_videoCodec); |
|---|
| 1600 | } |
|---|
| 1601 | |
|---|
| 1602 | NEXUS_AudioCodec b_audiocodec2nexus(baudio_format settop_value) |
|---|
| 1603 | { |
|---|
| 1604 | CONVERT(g_audioCodec); |
|---|
| 1605 | } |
|---|
| 1606 | |
|---|
| 1607 | NEXUS_TransportType b_mpegtype2nexus(bstream_mpeg_type settop_value) |
|---|
| 1608 | { |
|---|
| 1609 | CONVERT(g_mpegType); |
|---|
| 1610 | } |
|---|
| 1611 | |
|---|