static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    MTVDemuxContext *mtv = s->priv_data;

    ByteIOContext *pb = s->pb;

    int ret;

#if !HAVE_BIGENDIAN

    int i;

#endif



    if((url_ftell(pb) - s->data_offset + mtv->img_segment_size) % mtv->full_segment_size)

    {

        url_fskip(pb, MTV_AUDIO_PADDING_SIZE);



        ret = av_get_packet(pb, pkt, MTV_ASUBCHUNK_DATA_SIZE);

        if(ret != MTV_ASUBCHUNK_DATA_SIZE)

            return AVERROR(EIO);



        pkt->pos -= MTV_AUDIO_PADDING_SIZE;

        pkt->stream_index = AUDIO_SID;



    }else

    {

        ret = av_get_packet(pb, pkt, mtv->img_segment_size);

        if(ret != mtv->img_segment_size)

            return AVERROR(EIO);



#if !HAVE_BIGENDIAN



        /* pkt->data is GGGRRRR BBBBBGGG

         * and we need RRRRRGGG GGGBBBBB

         * for PIX_FMT_RGB565 so here we

         * just swap bytes as they come

         */



        for(i=0;i<mtv->img_segment_size/2;i++)

            *((uint16_t *)pkt->data+i) = bswap_16(*((uint16_t *)pkt->data+i));

#endif

        pkt->stream_index = VIDEO_SID;

    }



    return ret;

}

static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    MTVDemuxContext *mtv = s->priv_data;

    ByteIOContext *pb = s->pb;

    int ret;

#if !HAVE_BIGENDIAN

    int i;

#endif



    if((url_ftell(pb) - s->data_offset + mtv->img_segment_size) % mtv->full_segment_size)

    {

        url_fskip(pb, MTV_AUDIO_PADDING_SIZE);



        ret = av_get_packet(pb, pkt, MTV_ASUBCHUNK_DATA_SIZE);

        if(ret != MTV_ASUBCHUNK_DATA_SIZE)

            return AVERROR(EIO);



        pkt->pos -= MTV_AUDIO_PADDING_SIZE;

        pkt->stream_index = AUDIO_SID;



    }else

    {

        ret = av_get_packet(pb, pkt, mtv->img_segment_size);

        if(ret != mtv->img_segment_size)

            return AVERROR(EIO);



#if !HAVE_BIGENDIAN



        











        for(i=0;i<mtv->img_segment_size/2;i++)

            *((uint16_t *)pkt->data+i) = bswap_16(*((uint16_t *)pkt->data+i));

#endif

        pkt->stream_index = VIDEO_SID;

    }



    return ret;

}

        if(ret != MTV_ASUBCHUNK_DATA_SIZE)             return AVERROR(EIO);         if(ret != mtv->img_segment_size)             return AVERROR(EIO);
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)

{

    MTVDemuxContext *mtv = VAR_0->priv_data;

    ByteIOContext *pb = VAR_0->pb;

    int VAR_2;

#if !HAVE_BIGENDIAN

    int VAR_3;

#endif



    if((url_ftell(pb) - VAR_0->data_offset + mtv->img_segment_size) % mtv->full_segment_size)

    {

        url_fskip(pb, MTV_AUDIO_PADDING_SIZE);



        VAR_2 = av_get_packet(pb, VAR_1, MTV_ASUBCHUNK_DATA_SIZE);

        if(VAR_2 != MTV_ASUBCHUNK_DATA_SIZE)

            return AVERROR(EIO);



        VAR_1->pos -= MTV_AUDIO_PADDING_SIZE;

        VAR_1->stream_index = AUDIO_SID;



    }else

    {

        VAR_2 = av_get_packet(pb, VAR_1, mtv->img_segment_size);

        if(VAR_2 != mtv->img_segment_size)

            return AVERROR(EIO);



#if !HAVE_BIGENDIAN



        











        for(VAR_3=0;VAR_3<mtv->img_segment_size/2;VAR_3++)

            *((uint16_t *)VAR_1->data+VAR_3) = bswap_16(*((uint16_t *)VAR_1->data+VAR_3));

#endif

        VAR_1->stream_index = VIDEO_SID;

    }



    return VAR_2;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ MTVDemuxContext *mtv = VAR_0->priv_data; ByteIOContext *pb = VAR_0->pb; int VAR_2; #if !HAVE_BIGENDIAN
int VAR_3; #endif
if((url_ftell(pb) - VAR_0->data_offset + mtv->img_segment_size) % mtv->full_segment_size)
{ url_fskip(pb, MTV_AUDIO_PADDING_SIZE); VAR_2 = av_get_packet(pb, VAR_1, MTV_ASUBCHUNK_DATA_SIZE); if(VAR_2 != MTV_ASUBCHUNK_DATA_SIZE)
return AVERROR(EIO); VAR_1->pos -= MTV_AUDIO_PADDING_SIZE; VAR_1->stream_index = AUDIO_SID; }else { VAR_2 = av_get_packet(pb, VAR_1, mtv->img_segment_size); if(VAR_2 != mtv->img_segment_size)
return AVERROR(EIO); #if !HAVE_BIGENDIAN
for(VAR_3=0;VAR_3<mtv->img_segment_size/2;VAR_3++) *((uint16_t *)VAR_1->data+VAR_3) = bswap_16(*((uint16_t *)VAR_1->data+VAR_3)); #endif
VAR_1->stream_index = VIDEO_SID; } return VAR_2; }