/*************************************************************************** * Copyright (c) 2002, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: bcmDccTransportParse.c $ * $brcm_Revision: SanJose_MSTV_Devel/3 $ * $brcm_Date: 10/11/02 12:13p $ * * Module Description: * * Revision History: * * $brcm_Log: /SetTop/applications/vbi/MPEGCCTransportLib/source/bcmDccTransportParse.c $ * * SanJose_MSTV_Devel/3 10/11/02 12:13p erikg * Various Changes: 1. Fixed NTSC Caption Parsing from A53 2. Supports * pkt seq discontinuity reset 3. Support shortened pkts 4. Fixed * underline during monospaced simulation 5. Added parity checking to * chars in 608 transcoder 6. Correctly skips XDS and Text modes in * transcoder 7. Supports transparent space 8. Fixed Flashing * (FLASH_BY_2SURFACES) 9. DLY and DLC imply ETX 10.Force all combos of * PDir/SDir to L2R/B2T 11. Packet interface has changed Merge from * SanJose_MSTV_Devel_erikg_week_oct7_2002_10_07_0927_44 10-Oct- * 02.11:30:39 \SetTop\applications\vbi\public_inc\bcmDcc.h various * improvements: * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 08- * Oct-02.16:00:59 * \SetTop\applications\vbi\MPEGCCTransportLib\source\bcmDccTransportPars * e.c diff treatment for cc_type --- 11-Oct-02.11:49:16 * \SetTop\applications\vbi\MPEGCCTransportLib\source\bcmDccTransportPars * e.c cleaned up in prep for release --- 10-Oct-02.11:26:59 * \SetTop\applications\vbi\Common\bcmDccCBuf.c added cbUnPeek --- 11- * Oct-02.11:49:21 \SetTop\applications\vbi\Common\bcmDccCBuf.c cleaned * up in prep for release --- 10-Oct-02.11:27:05 * \SetTop\applications\vbi\Common\bcmDccCBuf.h added cbUnPeek --- 11- * Oct-02.11:49:24 \SetTop\applications\vbi\Common\bcmDccCBuf.h cleaned * up in prep for release --- 10-Oct-02.11:30:44 * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 10- * Oct-02.11:30:47 * \SetTop\applications\vbi\DTVCCLib\source\bcmDccPacket.c various * improvements: * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 08- * Oct-02.16:01:23 * \SetTop\applications\vbi\DTVCCLib\source\bcmDccIntGfx.c force l2r pdir * --- 10-Oct-02.11:30:51 * \SetTop\applications\vbi\DTVCCLib\source\bcmDccIntGfx.c various * improvements: * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 10- * Oct-02.12:38:10 * \SetTop\applications\vbi\DTVCCLib\source\bcmDccCoding.c DLY and DLC * imply ETX --- 10-Oct-02.14:09:02 * \SetTop\applications\vbi\DTVCCLib\source\bcmDccCoding.c support * transparent space * and fix RemapMultiByteTextToC1 --- 11-Oct-02.12:00:25 * \SetTop\applications\vbi\DTVCCLib\CCGfx\7030 Added file element * "arial_20.c". Added file element "arial_20_italic.c". --- 08-Oct- * 02.16:03:24 \SetTop\applications\vbi\DTVCCLib\CCGfx\7030\bcmDccGfx.c * split ccgfxRenderChar into two DoRenderChar calls --- 10-Oct- * 02.11:30:54 \SetTop\applications\vbi\DTVCCLib\CCGfx\7030\bcmDccGfx.c * various improvements: * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 10- * Oct-02.14:09:08 * \SetTop\applications\vbi\DTVCCLib\CCGfx\7030\bcmDccGfx.c support * transparent space * and fix RemapMultiByteTextToC1 --- 10-Oct-02.17:04:05 * \SetTop\applications\vbi\DTVCCLib\CCGfx\7030\bcmDccGfx.c fixed * flashing by 2 surfaces * this was broken when render incremental was added --- 11-Oct- * 02.11:49:27 \SetTop\applications\vbi\DTVCCLib\CCGfx\7030\bcmDccGfx.c * cleaned up in prep for release --- 11-Oct-02.12:01:00 * \SetTop\applications\vbi\DTVCCLib\CCGfx\7030\bcmDccGfx.c added a * comment for the font files --- 10-Oct-02.11:30:59 * \SetTop\applications\vbi\Common\bcmDccEngine.h various improvements: * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 10- * Oct-02.11:31:03 \SetTop\applications\vbi\Common\bcmDccEngine.c various * improvements: * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 08- * Oct-02.16:02:32 * \SetTop\applications\vbi\DTVCCLib\source\bcmDcc608Transcoder.c add * support for XDS and fix Text mode --- 10-Oct-02.11:31:07 * \SetTop\applications\vbi\DTVCCLib\source\bcmDcc608Transcoder.c various * improvements: * 1. correctly skip over XDS and Text in transcoder * 2. force pdir/sdir to l2r and b2t * 3. fixed underline during monospace * 4. fixed packet processing: short pkts and discontinuous pkts --- 10- * Oct-02.15:25:03 * \SetTop\applications\vbi\DTVCCLib\source\bcmDcc608Transcoder.c fixed * bug with XDS detection --- 11-Oct-02.11:49:31 * \SetTop\applications\vbi\DTVCCLib\source\bcmDcc608Transcoder.c cleaned * up in prep for release --- 08-Oct-02.16:02:36 * \SetTop\applications\vbi\DTVCCLib\public_inc\bcmDcc608Transcoder.h add * support for XDS and fix Text mode --- 08-Oct-02.16:03:39 * \SetTop\applications\vbi\Docs\SarnoffTesting.xls added set 1 * placeholder --- 11-Oct-02.12:01:30 * \SetTop\applications\vbi\Docs\SarnoffTesting.xls updated for oct 11 * release --- 11-Oct-02.12:00:12 * * SanJose_MSTV_Devel/SanJose_MSTV_Devel_erikg_week_oct7_2002_10_07_0927_44/2 10/11/02 11:49a erikg * cleaned up in prep for release * * SanJose_MSTV_Devel/SanJose_MSTV_Devel_erikg_week_oct7_2002_10_07_0927_44/1 10/8/02 4:1p erikg * diff treatment for cc_type * * SanJose_MSTV_Devel\2 5/13/02 1:13p erikg * snapshot of dtvcc code Merge from * SanJose_MSTV_Devel_erikg_DTVCC_Int_2002_05_02_1128_00 13-May- * 02.11:55:52 \SetTop\applications\vbi Added directory element * "DTVCCLib". --- 13-May-02.13:08:38 \SetTop\applications\vbi\Common * First version of the Dcc 708 Rendering Libraries --- 13-May- * 02.13:08:10 \SetTop\applications\vbi\Common\bcmDccBits.h Added ifdef * to ensure included only once. * Added extern "C" for __cplusplus --- 13-May-02.13:07:04 * \SetTop\applications\vbi\MPEGCCTransportLib\source\bcmDccTransportPars * e.c NextStartCode() now specifically scans for start codes until it * finds * 00 00 01 B2. --- 13-May-02.13:08:40 * \SetTop\applications\vbi\Common@@\main\SanJose_MSTV_Devel\SanJose_MSTV * _Devel_erikg_DTVCC_Int_2002_05_02_1128_00\1\bcmDccCBuf.c First version * of the Dcc 708 Rendering Libraries --- 13-May-02.13:08:43 * \SetTop\applications\vbi\Common@@\main\SanJose_MSTV_Devel\SanJose_MSTV * _Devel_erikg_DTVCC_Int_2002_05_02_1128_00\1\bcmDccCBuf.h First version * of the Dcc 708 Rendering Libraries --- 13-May-02.11:55:59 * \SetTop\applications\vbi@@\main\SanJose_MSTV_Devel\SanJose_MSTV_Devel_ * erikg_DTVCC_Int_2002_05_02_1128_00\1\DTVCCLib Added directory element * "source". Added directory element "public_inc". --- * * SanJose_MSTV_Devel\SanJose_MSTV_Devel_erikg_DTVCC_Int_2002_05_02_1128_00\1 5/13/02 1:6p erikg * NextStartCode() now specifically scans for start codes until it finds * 00 00 01 B2. * * \main\SanJose_MSTV_Devel\1 3/12/02 4:45p erikg * Merge from SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38 * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\5 3/12/02 2:57p erikg * debugged using base platform * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\4 3/11/02 2:21p erikg * added comments * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\3 3/11/02 8:12a erikg * fixed some build problems * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\2 3/7/02 4:21p erikg * more fleshing out * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\1 3/6/02 2:20p erikg * Added file element "bcmDccTransportParse.c". * ***************************************************************************/ /********************** * * INCLUDES * **********************/ #include "bcmDccTransport.h" #include "bcmDccTransportMux.h" #include "bcmDccPriv.h" #include "bcmDccBits.h" #include "bcmDccTransportParse.h" /********************** * * ProtoTypes * **********************/ unsigned int ParsePUD_053( unsigned char * pInputBuf, // unsigned int InputBufSize, // unsigned long ulPicInfo, // DCC_OUTBUF_INFO * p608BufInfo, DCC_OUTBUF_INFO * pDTVCCBufInfo) ; unsigned int ParsePUD_157( unsigned char * pInputBuf, unsigned int InputBufSize, unsigned long ulPicInfo, DCC_OUTBUF_INFO * p608BufInfo) ; unsigned int FieldFromPicInfo( unsigned long ulMainPicInfo, unsigned long index, unsigned long numPairs) ; #define DETECTED_608 1 #define DETECTED_DTVCC 2 /************************************************************************** * * Function: find_next_start_code * * Inputs: * pInputCur - input buffer w/ User Data * InputCurSize - num bytes of input buffer * * Outputs: * pStartCodeIndex - index of start code returned here * * Returns: 1 iff the next start code was found, 0 otherwise * * Description: * * This function finds the next start code in a buffer. * **************************************************************************/ int NextStartCode( unsigned char * pInputCur, unsigned int InputCurSize, unsigned int * pStartCodeIndex) { int ByteOff = 0 ; int BitOff = 0 ; int err ; if ( NULL == pInputCur || NULL == pStartCodeIndex ) { return(0) ; } do { if ( (err = next_start_code(pInputCur, &ByteOff, &BitOff, InputCurSize)) ) { return(0) ; } *pStartCodeIndex = ByteOff ; /* consume the 3 bytes */ ByteOff += 3 ; } while ( nextbits(pInputCur, ByteOff, BitOff, 8) != 0xB2 ) ; return(1) ; } /* find_next_start_code */ /************************************************************************** * * Function: ParseOnePicUserDataForCC * * Inputs: * pObj - transport object * pInputBuf - input buffer w/ User Data * InputBufSize - num bytes of input buffer * ulPicInfo - PicInfo from bcmMPIReadCCStatus * * Outputs: * p608BufInfo - 608 output * pDTVCCBufInfo - DTVCC output * * Returns: dccSuccess or a standard DCCERR error code * * Description: * * This function parses a buffer containing one MPEG picture user data. * **************************************************************************/ DCCERR ParseOnePicUserDataForCC( DCC_TRANSPORT_OBJECT * pObj, /* transport session object */ unsigned char * pInputBuf, /* input buffer, remaining */ unsigned int InputBufSize, /* input buffer size, remaining */ // unsigned long ulPicInfo, /* picture info */ DCC_OUTBUF_INFO * p608BufInfo, /* output buffer info for 608 type */ DCC_OUTBUF_INFO * pDTVCCBufInfo) /* output buffer info for DTVCC type */ { DCC_OUTBUF_INFO * p608Output ; int f608Output_A53 = 0 ; int f608Output_DVS157 = 0 ; unsigned int ret ; /* * Decide up front which 608 type * we'll output. */ switch ( pObj->CC608Type ) { case CC608_A53 : f608Output_A53 = 1 ; break ; case CC608_DVS157 : f608Output_DVS157 = 1 ; break ; case CC608_A53Preferred : if ( CC608Mux_IsDetected(&pObj->CC608MuxState, cctA053_608) ) f608Output_A53 = 1 ; else if ( CC608Mux_IsDetected(&pObj->CC608MuxState, cctDVS157) ) f608Output_DVS157 = 1 ; break ; } /*********************************** * check for DVS 157, DIGICIPHER II ***********************************/ if ( pInputBuf[0] == 0x03 ) { if ( f608Output_DVS157 ) { ;//ParsePUD_157(pInputBuf, InputBufSize, ulPicInfo, p608BufInfo) ; } ;///CC608Mux_Accumulate(&pObj->CC608MuxState, cctDVS157) ; } /*********************************** * check for ATSC A53, EIA-708 ***********************************/ else if ( pInputBuf[0] == 0x47 /* first 4 bytes are 47 41 39 34 */ && pInputBuf[1] == 0x41 && pInputBuf[2] == 0x39 && pInputBuf[3] == 0x34 && pInputBuf[4] == 0x03 ) /* Type == 03 */ { if ( f608Output_A53 ) p608Output = p608BufInfo ; else { /* * Even if we're not outputting this * type of 608 CC data, we still need * to parse the A53 data because it may * contain DTVCC data. */ p608Output = NULL ; /* this means ignore 608 CC data when parsing */ } /* parse, ret indicates what the A53 data actually contained */ //ret = ParsePUD_053(pInputBuf, InputBufSize, ulPicInfo, p608Output, pDTVCCBufInfo) ; ret = ParsePUD_053(pInputBuf,pDTVCCBufInfo) ; /* accumulate */ if ( ret & DETECTED_608 ) CC608Mux_Accumulate(&pObj->CC608MuxState, cctA053_608) ; if ( ret & DETECTED_DTVCC ) CC608Mux_Accumulate(&pObj->CC608MuxState, cctA053_DTVCC) ; } /*********************************** * check for unknown type ***********************************/ else { CC608Mux_Accumulate(&pObj->CC608MuxState, cctUnknown) ; } return(dccSuccess) ; } /* ParseOnePicUserDataForCC */ /************************************************************************** * * Function: ParsePUD_053 * * Inputs: * pInputBuf - user data to parse * InputBufSize - num bytes of user data * ulPicInfo - pic info from MPEG library * * Outputs: * p608BufInfo - 608 bytes go here if not NULL * pDTVCCBufInfo - DTVCC bytes go here if not NULL * * Returns: bitmask of DETECTED_608 and/or DETECTED_DTVCC * * Description: * * This function parses a buffer of MPEG picture user data, looking for * valid CC bytes. It assumes that the user data is in the ATSC 053 * format. * **************************************************************************/ #if 0 unsigned int ParsePUD_053( unsigned char * pInputBuf, unsigned int InputBufSize, unsigned long ulPicInfo, DCC_OUTBUF_INFO * p608BufInfo, DCC_OUTBUF_INFO * pDTVCCBufInfo) { unsigned int retCode = 0 ; /* * This code is adapted from DVS053GetXDSData() */ int i; /* index into pInputBuf */ int numCCPairs; /* pairs in user data, not all nec. valid */ unsigned char cc_type ; unsigned char dtvcc_type ; i = 4; /* process user_data_type 0x03 */ if (pInputBuf[i] == 0x03) { int j; i++; /* if process_cc_data_flag != 1, return */ if ( !(pInputBuf[i] & 0x40) ) return(retCode) ; numCCPairs = pInputBuf[i] & 0x1f; i += 2; /* skip em_data */ for (j = 0; j < numCCPairs; j++) { if ( (pInputBuf[i] & 0xF8) != 0xF8 ) { /* marker bits not correct */ } if ( !(pInputBuf[i] & 0x04) ) { /* if cc_valid != 1, continue to next pair */ i += 3; continue; } cc_type = pInputBuf[i] & 0x03 ; dtvcc_type = pInputBuf[i] & 0x02 ; i++ ; if ( dtvcc_type ) { /* * For DTVCC, output 3 bytes * [0] : cc_type * [1] : DTVCC Byte[0] * [2] : DTVCC Byte[1] */ retCode |= DETECTED_DTVCC ; if ( pDTVCCBufInfo ) { /* make sure we have enough room */ if ( (pDTVCCBufInfo->OutputBytesProduced + 3) > pDTVCCBufInfo->OutputBufSize ) { /* not enough room, error */ pDTVCCBufInfo->DccError = dccErrOutputBufTooSmall ; } else { pDTVCCBufInfo->pOutputBuf[ (pDTVCCBufInfo->OutputBytesProduced) + 0 ] = cc_type ; pDTVCCBufInfo->pOutputBuf[ (pDTVCCBufInfo->OutputBytesProduced) + 1 ] = pInputBuf[i+0] ; pDTVCCBufInfo->pOutputBuf[ (pDTVCCBufInfo->OutputBytesProduced) + 2 ] = pInputBuf[i+1] ; pDTVCCBufInfo->OutputBytesProduced += 3 ; } } } else { /* * For 608, output 3 bytes * [0] : field * [1] : CC Byte[0] * [2] : CC Byte[1] */ retCode |= DETECTED_608 ; if ( p608BufInfo ) { /* make sure we have enough room */ if ( (p608BufInfo->OutputBytesProduced + 3) > p608BufInfo->OutputBufSize ) { /* not enough room, error */ p608BufInfo->DccError = dccErrOutputBufTooSmall ; } else { #if 1 p608BufInfo->pOutputBuf[ (p608BufInfo->OutputBytesProduced) + 0 ] = ((cc_type == 0) ? DCC_608_FIELD_TOP : DCC_608_FIELD_BOTTOM) ; #else p608BufInfo->pOutputBuf[ (p608BufInfo->OutputBytesProduced) + 0 ] = FieldFromPicInfo(ulPicInfo,j,numCCPairs) ; #endif p608BufInfo->pOutputBuf[ (p608BufInfo->OutputBytesProduced) + 1 ] = pInputBuf[i+0] ; p608BufInfo->pOutputBuf[ (p608BufInfo->OutputBytesProduced) + 2 ] = pInputBuf[i+1] ; p608BufInfo->OutputBytesProduced += 3 ; } } } i += 2 ; } } return(retCode) ; } /* ParsePUD_053 */ #endif unsigned int ParsePUD_053(unsigned char * pInputBuf, DCC_OUTBUF_INFO * pDTVCCBufInfo) { unsigned int retCode = 0 ; /* * This code is adapted from DVS053GetXDSData() */ int i,j; /* index into pInputBuf */ int numCCPairs; /* pairs in user data, not all nec. valid */ unsigned char cc_type ; unsigned char dtvcc_type ; i = 4; /* process user_data_type 0x03 */ if (pInputBuf[i] == 0x03) { i++; /* if process_cc_data_flag != 1, return */ if ( !(pInputBuf[i] & 0x40) ) return(retCode) ; numCCPairs = pInputBuf[i] & 0x1f; i += 2; /* skip em_data */ for (j = 0; j < numCCPairs; j++) { if ( (pInputBuf[i] & 0xF8) != 0xF8 ) { /* marker bits not correct */ } #if 0 /* JPF Need to pass invalid data */ if ( !(pInputBuf[i] & 0x04) ) { /* if cc_valid != 1, continue to next pair */ i += 3; continue; } #endif //cc_type = pInputBuf[i] & 0x03 ; cc_type = pInputBuf[i] & 0x03 ; dtvcc_type = pInputBuf[i] & 0x02 ; i++ ; #if 1 /* JPF Need to pass invalid data */ if ( dtvcc_type ) #endif { /* * For DTVCC, output 3 bytes * [0] : cc_type * [1] : DTVCC Byte[0] * [2] : DTVCC Byte[1] */ retCode |= DETECTED_DTVCC ; if ( pDTVCCBufInfo ) { /* make sure we have enough room */ if ( (pDTVCCBufInfo->OutputBytesProduced + 2) >= pDTVCCBufInfo->OutputBufSize ) { /* not enough room, error */ pDTVCCBufInfo->DccError = dccErrOutputBufTooSmall ; } else { pDTVCCBufInfo->pOutputBuf[ (pDTVCCBufInfo->OutputBytesProduced) + 0 ] = cc_type ; pDTVCCBufInfo->pOutputBuf[ (pDTVCCBufInfo->OutputBytesProduced) + 1 ] = pInputBuf[i+0] ; pDTVCCBufInfo->pOutputBuf[ (pDTVCCBufInfo->OutputBytesProduced) + 2 ] = pInputBuf[i+1] ; pDTVCCBufInfo->OutputBytesProduced += 3 ; } } } i += 2 ; } } return(retCode) ; } /* ParsePUD_053 */ /************************************************************************** * * Function: ParsePUD_157 * * Inputs: * pInputBuf - user data to parse * InputBufSize - num bytes of user data * ulPicInfo - pic info from MPEG library * * Outputs: * p608BufInfo - 608 bytes go here if not NULL * * Returns: bitmask of DETECTED_608 * * Description: * * This function parses a buffer of MPEG picture user data, looking for * valid CC bytes. It assumes that the user data is in the DVS 157 * format. * **************************************************************************/ unsigned int ParsePUD_157( unsigned char * pInputBuf, unsigned int InputBufSize, unsigned long ulPicInfo, DCC_OUTBUF_INFO * p608BufInfo) { unsigned int retCode = 0 ; /* * This code is adapted from DVS053GetXDSData() */ int byteoff = 0 ; int bitoff = 0 ; unsigned int field_num ; unsigned int line_offset ; unsigned int priority, marker ; unsigned char cc_data[2] ; int i; /* index into pInputBuf */ unsigned int numCCPairs; /* pairs in user data, not all nec. valid */ i = 0 ; /* process user_data_type 0x03 */ if ( getnextbits(pInputBuf,&byteoff,&bitoff,8) == 0x03 ) { unsigned int j; /* ignore the next 7 bits */ getnextbits(pInputBuf,&byteoff,&bitoff,7) ; /* check vbi_data_flag */ if ( getnextbits(pInputBuf,&byteoff,&bitoff,1) != 1 ) { /* vbi_data_flag not set, get out */ return(retCode) ; } /* the next 5 bits are the cc_count */ numCCPairs = getnextbits(pInputBuf,&byteoff,&bitoff,5) ; for ( j=0 ; j < numCCPairs ; j++ ) { /* cc_priority: 2 bits */ priority = getnextbits(pInputBuf,&byteoff,&bitoff,2) ; /* field_number: 2 bits */ field_num = getnextbits(pInputBuf,&byteoff,&bitoff,2) ; /* line_offset: 5 bits */ line_offset = getnextbits(pInputBuf,&byteoff,&bitoff,5) ; /* cc_data_1[1:8] 8 bits (bit reversed) */ cc_data[0] = (unsigned char)getnextbits_rev(pInputBuf,&byteoff,&bitoff,8) ; /* cc_data_2[1:8] 8 bits (bit reversed) */ cc_data[1] = (unsigned char)getnextbits_rev(pInputBuf,&byteoff,&bitoff,8) ; /* marker_bit: 1 bits */ marker = getnextbits(pInputBuf,&byteoff,&bitoff,1) ; if ( field_num != 0 && line_offset == 11 ) { retCode |= DETECTED_608 ; if ( p608BufInfo ) { /* make sure we have enough room */ if ( (p608BufInfo->OutputBytesProduced + 2) >= p608BufInfo->OutputBufSize ) { /* not enough room, error */ p608BufInfo->DccError = dccErrOutputBufTooSmall ; } else { p608BufInfo->pOutputBuf[ (p608BufInfo->OutputBytesProduced) + 0 ] = FieldFromPicInfo(ulPicInfo,j,numCCPairs) ; p608BufInfo->pOutputBuf[ (p608BufInfo->OutputBytesProduced) + 1 ] = cc_data[0] ; p608BufInfo->pOutputBuf[ (p608BufInfo->OutputBytesProduced) + 2 ] = cc_data[1] ; p608BufInfo->OutputBytesProduced += 3 ; } } } } /* for each pair */ } /* if type == 03 */ return(retCode) ; } /* Parse_157 */ /************************************************************************** * * Function: FieldFromPicInfo * * Inputs: * * Outputs: * * Returns: * * Description: * * **************************************************************************/ unsigned int FieldFromPicInfo( unsigned long ulMainPicInfo, unsigned long index, unsigned long numPairs) { if ( (ulMainPicInfo & 3) == 1 ) { return(DCC_608_FIELD_TOP) ; } else if ( (ulMainPicInfo & 3) == 2 ) { return(DCC_608_FIELD_BOTTOM) ; } else if ( (ulMainPicInfo & 3) == 3 ) { /* frame */ if ( 1 ) //(ulMainPicInfo & 0x100) ) { /* progressive frame */ if ( numPairs == 1 || (numPairs==2 && (ulMainPicInfo & 0x10)) ) /* 0x10 means repeat first field */ { /* this is very strange */ return(DCC_608_FIELD_TOP) ; } else { switch ( ulMainPicInfo & 0x30 ) { case 0x00 : /* bottom field first, repeat first field = 0 */ return( index ? DCC_608_FIELD_TOP : DCC_608_FIELD_BOTTOM ) ; case 0x10 : /* bottom field first, repeat first field = 1 */ return( (index==1) ? DCC_608_FIELD_TOP : DCC_608_FIELD_BOTTOM ) ; case 0x20 : /* top field first, repeat first field = 0 */ return( index ? DCC_608_FIELD_BOTTOM : DCC_608_FIELD_TOP ) ; case 0x30 : /* top field first, repeat first field = 1 */ return( (index==1) ? DCC_608_FIELD_BOTTOM : DCC_608_FIELD_TOP ) ; } } } else { if ( (ulMainPicInfo & 0x20) ) { /* top field first */ return(DCC_608_FIELD_TOP) ; } else { return(DCC_608_FIELD_BOTTOM) ; } } } return(DCC_608_FIELD_BOTTOM) ; //??? } /* FieldFromPicInfo */