static int read_packet(ByteIOContext *pb, uint8_t *buf, int raw_packet_size)

{

    int skip, len;



    for(;;) {

        len = get_buffer(pb, buf, TS_PACKET_SIZE);

        if (len != TS_PACKET_SIZE)

            return AVERROR(EIO);

        /* check paquet sync byte */

        if (buf[0] != 0x47) {

            /* find a new packet start */

            url_fseek(pb, -TS_PACKET_SIZE, SEEK_CUR);

            if (mpegts_resync(pb) < 0)

                return AVERROR_INVALIDDATA;

            else

                continue;

        } else {

            skip = raw_packet_size - TS_PACKET_SIZE;

            if (skip > 0)

                url_fskip(pb, skip);

            break;

        }

    }

    return 0;

}

static int read_packet(ByteIOContext *pb, uint8_t *buf, int raw_packet_size)

{

    int skip, len;



    for(;;) {

        len = get_buffer(pb, buf, TS_PACKET_SIZE);

        if (len != TS_PACKET_SIZE)

            return AVERROR(EIO);

        

        if (buf[0] != 0x47) {

            

            url_fseek(pb, -TS_PACKET_SIZE, SEEK_CUR);

            if (mpegts_resync(pb) < 0)

                return AVERROR_INVALIDDATA;

            else

                continue;

        } else {

            skip = raw_packet_size - TS_PACKET_SIZE;

            if (skip > 0)

                url_fskip(pb, skip);

            break;

        }

    }

    return 0;

}

static int FUNC_0(ByteIOContext *VAR_0, uint8_t *VAR_1, int VAR_2)

{

    int VAR_3, VAR_4;



    for(;;) {

        VAR_4 = get_buffer(VAR_0, VAR_1, TS_PACKET_SIZE);

        if (VAR_4 != TS_PACKET_SIZE)

            return AVERROR(EIO);

        

        if (VAR_1[0] != 0x47) {

            

            url_fseek(VAR_0, -TS_PACKET_SIZE, SEEK_CUR);

            if (mpegts_resync(VAR_0) < 0)

                return AVERROR_INVALIDDATA;

            else

                continue;

        } else {

            VAR_3 = VAR_2 - TS_PACKET_SIZE;

            if (VAR_3 > 0)

                url_fskip(VAR_0, VAR_3);

            break;

        }

    }

    return 0;

}

static int FUNC_0(ByteIOContext *VAR_0, uint8_t *VAR_1, int VAR_2)
{ int VAR_3, VAR_4; for(;;) { VAR_4 = get_buffer(VAR_0, VAR_1, TS_PACKET_SIZE); if (VAR_4 != TS_PACKET_SIZE)
return AVERROR(EIO); if (VAR_1[0] != 0x47) { url_fseek(VAR_0, -TS_PACKET_SIZE, SEEK_CUR); if (mpegts_resync(VAR_0) < 0)
return AVERROR_INVALIDDATA; else
continue; } else { VAR_3 = VAR_2 - TS_PACKET_SIZE; if (VAR_3 > 0)
url_fskip(VAR_0, VAR_3); break; } } return 0; }