⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user_data_task.c

📁 pnx1500 mpeg2 ts stream demo
💻 C
📖 第 1 页 / 共 2 页
字号:
                            "parseUserDataPacket: Warning: additional_data_flag "                            "is set - this feature is not yet supported") )        }        if ( pktLength > (i + 1) )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                            "parseUserDataPacket: User data packet is larger "                            "than necessary for CC data, discarding %d bytes",                            (pktLength - (i + 1))) )        }        }        break;    case EIA_608_ADDITIONAL_DATA:        {        UInt8  additionalCcCount = 0;        DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                        "parseUserDataPacket: User data type code=0x%x: "                        "EIA 608 Additional Data", userDataType) )        // Set index to position of marker bits/additional CC count byte        i++;        if ( pktLength < (i + 1) )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: User data packet is too small "                            "to check for marker bits/additional CC count, "                            "discarding packet") )            goto _return;        }        markerBits = (pPacket[i] >> 5) & 0x07;        if ( markerBits != 0x07 )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: Error: Invalid marker bits "                            "found before additional CC data, discarding packet") )            goto _return;        }        additionalCcCount = pPacket[i] & 0x1F;  // Number of additional CC bytes        // Set index to start of first set of additional Closed Captioning data bytes        i++;        if ( (additionalCcCount > 0) &&             (pktLength < (i + (additionalCcCount * 3))) )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: User data packet is too small "                            "to check for additional CC data, discarding packet") )            goto _return;        }        for ( j = 0; j < additionalCcCount; j++ )        {            UInt8  additionalCcValid       = 0;            UInt8  additionalCcLineOffset  = 0;            UInt8  additionalCcFieldNumber = 0;            additionalCcValid       = (pPacket[i] >> 7) & 0x01;  // Additional CC valid flag            additionalCcLineOffset  = (pPacket[i] >> 2) & 0x1F;  // Additional CC line offset            additionalCcFieldNumber =  pPacket[i] & 0x03;        // Additional CC field number            if ( additionalCcValid )            {                /* Put user data type code, CC line offset, CC field number and                   CC data bytes into output buffer */                // :TODO: verify how we want to send these bytes                outputBuffer[numOutputBytes++] = userDataType;                outputBuffer[numOutputBytes++] = additionalCcLineOffset;                outputBuffer[numOutputBytes++] = additionalCcFieldNumber;                outputBuffer[numOutputBytes++] = pPacket[i+1];                outputBuffer[numOutputBytes++] = pPacket[i+2];                DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                                "parseUserDataPacket: Found additional "                                "CC data bytes=0x%x, 0x%x for line offset=%d, "                                "field number=%d", pPacket[i+1], pPacket[i+2],                                additionalCcLineOffset, additionalCcFieldNumber) )            }            // Set index to start of next set of additional Closed Captioning data bytes            i += 3;        }  // end for loop        if ( pktLength > (i + 1) )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                            "parseUserDataPacket: User data packet is larger "                            "than necessary for additional CC data, discarding "                            "%d bytes", (pktLength - (i + 1))) )            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: Warning: User data packet may "                            "contain additional Type 4 data.  This is not yet "                            "supported") )        }        }        break;    case LUMINANCE_PAM_DATA:#if 0  // :TODO: This code is unused for now        {        UInt8  lumaPamCount = 0;        DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                        "parseUserDataPacket: User data type code=0x%x: "                        "Luminance PAM Data", userDataType) )        // Set index to position of marker bits/luma-PAM count byte        i++;        if ( pktLength < (i + 1) )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: User data packet is too small "                            "to check for marker bits/luma-PAM count, discarding"                            " packet") )            goto _return;        }        markerBits = (pPacket[i] >> 5) & 0x07;        if ( markerBits != 0x07 )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: Error: Invalid marker bits "                            "found before Luminance PAM data, discarding packet") )            goto _return;        }        lumaPamCount = pPacket[i] & 0x1F;  // Number of Luminance PAM bytes        // Set index to start of first set of Luminance PAM data bytes        i++;        if ( (lumaPamCount > 0) && (pktLength < (i + (lumaPamCount * 10))) )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: User data packet is too small "                            "to check for Luminance PAM data, discarding packet") )            goto _return;        }        for ( j = 0; j < lumaPamCount; j++ )        {            UInt8   lumaPamPriority         = 0;  // Luminance PAM reconstruction priority            UInt8   fieldNumber             = 0;  // Number of field from which VBI data originated            UInt16  startSample             = 0;  // Starting sample number in luminance line            UInt8   bitsPerSymbol           = 0;  // Number of bits per symbol            UInt8   pamIncrement            = 0;  // Luminance PAM symbol clock increment            UInt16  pamModulus              = 0;  // Luminance PAM symbol clock modulus number            UInt8   lowAmplitudeLevel       = 0;  // Low amplitude symbol reconstruction level            UInt8   highAmplitudeLevel      = 0;  // High amplitude symbol reconstruction level            UInt8   lineOffset              = 0;  /* Offset of Luminance PAM data relative to base                                                       VBI frame line */            UInt8   pulseShape              = 0;  /* Shape of pulses used to reconstruct line of                                                       Luminance PAM */            UInt8   symbolToTransitionRatio = 0;  /* Ratio of each Luminance PAM symbol duration                                                     to each symbol transition duration */            UInt8   reserved                = 0;  // Reserved for future use            UInt8   pamAlpha                = 0;  // Value of Alpha for Raised Cosine filter            UInt8   wordCount               = 0;  // Number of Luminance PAM words            UInt8   remainderCount          = 0;  // Number of symbol bits remaining            UInt8   symbolBit               = 0;  // Single bit of the symbol list            Int8    rightBitShift           = 0;  // Number of bit positions to right shift            UInt8   leftBitShift            = 0;  // Number of bit positions to left shift            UInt8   numExpectedMarkerBits   = 0;  // Number of expected marker bits after symbol bits            Int     k                       = 0;            lumaPamPriority    = (pPacket[i] >> 6) & 0x03;            fieldNumber        = (pPacket[i] >> 4) & 0x03;            startSample        = (((UInt16)pPacket[i] & 0x0F) << 5) |                                 ((pPacket[i+1] >> 3) & 0x1F);            bitsPerSymbol      = pPacket[i+1] & 0x07;            pamIncrement       = (pPacket[i+2] >> 2) & 0x3F;            pamModulus         = (((UInt16)pPacket[i+2] & 0x03) << 8) |                                 pPacket[i+3];            lowAmplitudeLevel  = pPacket[i+4];            highAmplitudeLevel = pPacket[i+5];            lineOffset         = (pPacket[i+6] >> 3) & 0x1F;            pulseShape         = pPacket[i+6] & 0x07;            switch( pulseShape )            {            case RECTANGULAR_PULSE_SHAPE:                symbolToTransitionRatio = pPacket[i+7];                break;            case RAISED_COSINE_PULSE_SHAPE:                reserved = (pPacket[i+7] >> 5) & 0x07;                pamAlpha =  pPacket[i+7] & 0x1F;                break;            case PARTIAL_RESPONSE_CODING_PULSE_SHAPE:                reserved = pPacket[i+7];                break;            default:                reserved = pPacket[i+7];                break;            }  // end switch            markerBits = (pPacket[i+8] >> 5) & 0x07;            if ( markerBits != 0x07 )            {                DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                                "parseUserDataPacket: Error: Invalid marker bits "                                "found after Luminance PAM data, discarding packet") )                goto _return;            }            wordCount = pPacket[i+8] & 0x1F;            // Set index to start of first set of Luminance PAM data words            i += 9;            if ( (wordCount > 0) && (pktLength < (i + (wordCount * 3) + 1)) )            {                DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                                "parseUserDataPacket: User data packet is too "                                "small to check for Luminance PAM words, "                                "discarding packet") )                goto _return;            }            for ( k = 0; k < wordCount; k++ )            {                markerBits = (pPacket[i] >> 6) & 0x03;                if ( markerBits != 0x03 )                {                    DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                                    "parseUserDataPacket: Error: Invalid marker "                                    "bits found before Luminance PAM word, "                                    "discarding packet") )                    goto _return;                }                // Put user data type code and Luminance PAM data into output buffer                // :TODO: if we ever use this then verify what goes here                outputBuffer[numOutputBytes++] = userDataType;                outputBuffer[numOutputBytes++] = lumaPamPriority;                outputBuffer[numOutputBytes++] = fieldNumber;                outputBuffer[numOutputBytes++] = startSample;                outputBuffer[numOutputBytes++] = bitsPerSymbol;                outputBuffer[numOutputBytes++] = pamIncrement;                outputBuffer[numOutputBytes++] = pamModulus;                outputBuffer[numOutputBytes++] = lowAmplitudeLevel;                outputBuffer[numOutputBytes++] = highAmplitudeLevel;                outputBuffer[numOutputBytes++] = lineOffset;                outputBuffer[numOutputBytes++] = pulseShape;                outputBuffer[numOutputBytes++] = pPacket[i] & 0x3F;                outputBuffer[numOutputBytes++] = pPacket[i+1];                outputBuffer[numOutputBytes++] = pPacket[i+2];                DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                                "parseUserDataPacket: Found Luminance PAM word="                                "0x%x, 0x%x, 0x%x", (pPacket[i] & 0x3F),                                pPacket[i+1], pPacket[i+2]) )                // Set index to start of next set of Luminance PAM words                i += 3;            }  // end for k loop            markerBits = (pPacket[i] >> 7) & 0x01;            if ( markerBits != 0x01 )            {                DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                                "parseUserDataPacket: Error: Invalid marker bit "                                "found before Luminance PAM remainder count, "                                "discarding packet") )                goto _return;            }            remainderCount = (pPacket[i] >> 2) & 0x1F;            /* NOTE: 2 of the remaining symbols will fit in the current byte,                     after that we need another byte for every 8 symbols */            if ( (remainderCount > 2) &&                 (pktLength < (i + ((remainderCount - 2) / 8) + 1)) )            {                DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                                "parseUserDataPacket: User data packet is too "                                "small to check for remaining symbol bits, "                                "discarding packet") )                goto _return;            }            rightBitShift = 1;            leftBitShift  = 0;            for ( k = 0; k < remainderCount; k++ )            {                symbolBit = (symbolBit   << 1) |                            ((pPacket[i] >> rightBitShift) & 0x01);                rightBitShift--;                leftBitShift++;                if ( rightBitShift < 0 )                {                    rightBitShift = 7;                    i++;                }                if ( leftBitShift == 7 )                {                    // Put remaining symbol bits into output buffer                    outputBuffer[numOutputBytes++] = symbolBit;                    symbolBit    = 0;                    leftBitShift = 0;                    DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                                    "parseUserDataPacket: Found remaining symbol"                                    " bits=0x%x", symbolBit) )                }            }  // end for loop            /* NOTE: The first 6 bits of the first byte are taken up by a marker                     bit and the 5-bit remainder count */            if ( remainderCount > 2 )            {                numExpectedMarkerBits = (remainderCount + 6) % 8;            }            else            {                numExpectedMarkerBits = 8 - (remainderCount + 6);            }            // Check the remaining bits in the current byte for marker bits            for ( k = 0; k < numExpectedMarkerBits; k++ )            {                markerBits = (pPacket[i] >> (k - 1)) & 0x01;                if ( markerBits != 0x01 )                {                    DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                                    "parseUserDataPacket: Error: Invalid marker "                                    "bit found after remaining symbol bits, "                                    "discarding packet") )                    goto _return;                }            }  // end for loop            // Set index to start of next set of Luminance PAM data bytes            i++;        }  // end for j loop        if ( pktLength > (i + 1) )        {            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_4,                            "parseUserDataPacket: User data packet is larger "                            "than necessary for Luminance PAM data, discarding "                            "%d bytes", (pktLength - (i + 1))) )            DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                            "parseUserDataPacket: Warning: User data packet may "                            "contain additional Type 5 data.  This is not yet "                            "supported") )        }        }#endif        break;    default:        DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,                        "parseUserDataPacket: Error: Unknown/Reserved user data "                        "type code detected, discarding packet") )        goto _return;//      break;    }  // end switch_return:    tmmlCacheInvalidate( (void *)pPacket, pktLength );    DBG_ISR_PRINT( (dbgTsDemux, DBG_INTERNAL_LEAVE, "parseUserDataPacket") )    return( TM_OK );}//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -