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

{

    VqfContext *c = s->priv_data;

    int ret;

    int size = (c->frame_bit_len - c->remaining_bits + 7)>>3;



    if (av_new_packet(pkt, size+2) < 0)

        return AVERROR(EIO);



    pkt->pos          = avio_tell(s->pb);

    pkt->stream_index = 0;

    pkt->duration     = 1;



    pkt->data[0] = 8 - c->remaining_bits; // Number of bits to skip

    pkt->data[1] = c->last_frame_bits;

    ret = avio_read(s->pb, pkt->data+2, size);



    if (ret<=0) {

        av_free_packet(pkt);

        return AVERROR(EIO);

    }



    c->last_frame_bits = pkt->data[size+1];

    c->remaining_bits  = (size << 3) - c->frame_bit_len + c->remaining_bits;



    return size+2;

}

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

{

    VqfContext *c = s->priv_data;

    int ret;

    int size = (c->frame_bit_len - c->remaining_bits + 7)>>3;



    if (av_new_packet(pkt, size+2) < 0)

        return AVERROR(EIO);



    pkt->pos          = avio_tell(s->pb);

    pkt->stream_index = 0;

    pkt->duration     = 1;



    pkt->data[0] = 8 - c->remaining_bits; 

    pkt->data[1] = c->last_frame_bits;

    ret = avio_read(s->pb, pkt->data+2, size);



    if (ret<=0) {

        av_free_packet(pkt);

        return AVERROR(EIO);

    }



    c->last_frame_bits = pkt->data[size+1];

    c->remaining_bits  = (size << 3) - c->frame_bit_len + c->remaining_bits;



    return size+2;

}

    if (ret<=0) {
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)

{

    VqfContext *c = VAR_0->priv_data;

    int VAR_2;

    int VAR_3 = (c->frame_bit_len - c->remaining_bits + 7)>>3;



    if (av_new_packet(VAR_1, VAR_3+2) < 0)

        return AVERROR(EIO);



    VAR_1->pos          = avio_tell(VAR_0->pb);

    VAR_1->stream_index = 0;

    VAR_1->duration     = 1;



    VAR_1->data[0] = 8 - c->remaining_bits; 

    VAR_1->data[1] = c->last_frame_bits;

    VAR_2 = avio_read(VAR_0->pb, VAR_1->data+2, VAR_3);



    if (VAR_2<=0) {

        av_free_packet(VAR_1);

        return AVERROR(EIO);

    }



    c->last_frame_bits = VAR_1->data[VAR_3+1];

    c->remaining_bits  = (VAR_3 << 3) - c->frame_bit_len + c->remaining_bits;



    return VAR_3+2;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ VqfContext *c = VAR_0->priv_data; int VAR_2; int VAR_3 = (c->frame_bit_len - c->remaining_bits + 7)>>3; if (av_new_packet(VAR_1, VAR_3+2) < 0)
return AVERROR(EIO); VAR_1->pos          = avio_tell(VAR_0->pb); VAR_1->stream_index = 0; VAR_1->duration     = 1; VAR_1->data[0] = 8 - c->remaining_bits; VAR_1->data[1] = c->last_frame_bits; VAR_2 = avio_read(VAR_0->pb, VAR_1->data+2, VAR_3); if (VAR_2<=0) { av_free_packet(VAR_1); return AVERROR(EIO); } c->last_frame_bits = VAR_1->data[VAR_3+1]; c->remaining_bits  = (VAR_3 << 3) - c->frame_bit_len + c->remaining_bits; return VAR_3+2; }