static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)

{

    unsigned int crc;

    unsigned char packet[TS_PACKET_SIZE];

    const unsigned char *buf_ptr;

    unsigned char *q;

    int first, b, len1, left;



    crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),

                            -1, buf, len - 4));



    buf[len - 4] = (crc >> 24) & 0xff;

    buf[len - 3] = (crc >> 16) & 0xff;

    buf[len - 2] = (crc >>  8) & 0xff;

    buf[len - 1] =  crc        & 0xff;



    /* send each packet */

    buf_ptr = buf;

    while (len > 0) {

        first = buf == buf_ptr;

        q     = packet;

        *q++  = 0x47;

        b     = s->pid >> 8;

        if (first)

            b |= 0x40;

        *q++  = b;

        *q++  = s->pid;

        s->cc = s->cc + 1 & 0xf;

        *q++  = 0x10 | s->cc;







        if (first)

            *q++ = 0; /* 0 offset */

        len1 = TS_PACKET_SIZE - (q - packet);

        if (len1 > len)

            len1 = len;

        memcpy(q, buf_ptr, len1);

        q += len1;

        /* add known padding data */

        left = TS_PACKET_SIZE - (q - packet);

        if (left > 0)

            memset(q, 0xff, left);



        s->write_packet(s, packet);



        buf_ptr += len1;

        len     -= len1;


static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)

{

    unsigned int crc;

    unsigned char packet[TS_PACKET_SIZE];

    const unsigned char *buf_ptr;

    unsigned char *q;

    int first, b, len1, left;



    crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),

                            -1, buf, len - 4));



    buf[len - 4] = (crc >> 24) & 0xff;

    buf[len - 3] = (crc >> 16) & 0xff;

    buf[len - 2] = (crc >>  8) & 0xff;

    buf[len - 1] =  crc        & 0xff;



    

    buf_ptr = buf;

    while (len > 0) {

        first = buf == buf_ptr;

        q     = packet;

        *q++  = 0x47;

        b     = s->pid >> 8;

        if (first)

            b |= 0x40;

        *q++  = b;

        *q++  = s->pid;

        s->cc = s->cc + 1 & 0xf;

        *q++  = 0x10 | s->cc;







        if (first)

            *q++ = 0; 

        len1 = TS_PACKET_SIZE - (q - packet);

        if (len1 > len)

            len1 = len;

        memcpy(q, buf_ptr, len1);

        q += len1;

        

        left = TS_PACKET_SIZE - (q - packet);

        if (left > 0)

            memset(q, 0xff, left);



        s->write_packet(s, packet);



        buf_ptr += len1;

        len     -= len1;


static void FUNC_0(MpegTSSection *VAR_0, uint8_t *VAR_1, int VAR_2)

{

    unsigned int VAR_3;

    unsigned char VAR_4[TS_PACKET_SIZE];

    const unsigned char *VAR_5;

    unsigned char *VAR_6;

    int VAR_7, VAR_8, VAR_9, VAR_10;



    VAR_3 = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),

                            -1, VAR_1, VAR_2 - 4));



    VAR_1[VAR_2 - 4] = (VAR_3 >> 24) & 0xff;

    VAR_1[VAR_2 - 3] = (VAR_3 >> 16) & 0xff;

    VAR_1[VAR_2 - 2] = (VAR_3 >>  8) & 0xff;

    VAR_1[VAR_2 - 1] =  VAR_3        & 0xff;



    

    VAR_5 = VAR_1;

    while (VAR_2 > 0) {

        VAR_7 = VAR_1 == VAR_5;

        VAR_6     = VAR_4;

        *VAR_6++  = 0x47;

        VAR_8     = VAR_0->pid >> 8;

        if (VAR_7)

            VAR_8 |= 0x40;

        *VAR_6++  = VAR_8;

        *VAR_6++  = VAR_0->pid;

        VAR_0->cc = VAR_0->cc + 1 & 0xf;

        *VAR_6++  = 0x10 | VAR_0->cc;







        if (VAR_7)

            *VAR_6++ = 0; 

        VAR_9 = TS_PACKET_SIZE - (VAR_6 - VAR_4);

        if (VAR_9 > VAR_2)

            VAR_9 = VAR_2;

        memcpy(VAR_6, VAR_5, VAR_9);

        VAR_6 += VAR_9;

        

        VAR_10 = TS_PACKET_SIZE - (VAR_6 - VAR_4);

        if (VAR_10 > 0)

            memset(VAR_6, 0xff, VAR_10);



        VAR_0->write_packet(VAR_0, VAR_4);



        VAR_5 += VAR_9;

        VAR_2     -= VAR_9;


static void FUNC_0(MpegTSSection *VAR_0, uint8_t *VAR_1, int VAR_2)
{ unsigned int VAR_3; unsigned char VAR_4[TS_PACKET_SIZE]; const unsigned char *VAR_5; unsigned char *VAR_6; int VAR_7, VAR_8, VAR_9, VAR_10; VAR_3 = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE),
-1, VAR_1, VAR_2 - 4)); VAR_1[VAR_2 - 4] = (VAR_3 >> 24) & 0xff; VAR_1[VAR_2 - 3] = (VAR_3 >> 16) & 0xff; VAR_1[VAR_2 - 2] = (VAR_3 >>  8) & 0xff; VAR_1[VAR_2 - 1] =  VAR_3        & 0xff; VAR_5 = VAR_1; while (VAR_2 > 0) { VAR_7 = VAR_1 == VAR_5; VAR_6     = VAR_4; *VAR_6++  = 0x47; VAR_8     = VAR_0->pid >> 8; if (VAR_7)
VAR_8 |= 0x40; *VAR_6++  = VAR_8; *VAR_6++  = VAR_0->pid; VAR_0->cc = VAR_0->cc + 1 & 0xf; *VAR_6++  = 0x10 | VAR_0->cc; if (VAR_7)
*VAR_6++ = 0; VAR_9 = TS_PACKET_SIZE - (VAR_6 - VAR_4); if (VAR_9 > VAR_2)
VAR_9 = VAR_2; memcpy(VAR_6, VAR_5, VAR_9); VAR_6 += VAR_9; VAR_10 = TS_PACKET_SIZE - (VAR_6 - VAR_4); if (VAR_10 > 0)
memset(VAR_6, 0xff, VAR_10); VAR_0->write_packet(VAR_0, VAR_4); VAR_5 += VAR_9; VAR_2     -= VAR_9;