static int nut_read_packet(AVFormatContext * avf, AVPacket * pkt) {

    NUTContext * priv = avf->priv_data;

    nut_packet_t pd;

    int ret;



    while ((ret = nut_read_next_packet(priv->nut, &pd)) < 0)

        av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret));



    if (ret || av_new_packet(pkt, pd.len) < 0) return -1;



    if (pd.flags & NUT_FLAG_KEY) pkt->flags |= PKT_FLAG_KEY;

    pkt->pts = pd.pts;

    pkt->stream_index = pd.stream;

    pkt->pos = url_ftell(&avf->pb);



    ret = nut_read_frame(priv->nut, &pd.len, pkt->data);



    return ret;

}

static int nut_read_packet(AVFormatContext * avf, AVPacket * pkt) {

    NUTContext * priv = avf->priv_data;

    nut_packet_t pd;

    int ret;



    while ((ret = nut_read_next_packet(priv->nut, &pd)) < 0)

        av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret));



    if (ret || av_new_packet(pkt, pd.len) < 0) return -1;



    if (pd.flags & NUT_FLAG_KEY) pkt->flags |= PKT_FLAG_KEY;

    pkt->pts = pd.pts;

    pkt->stream_index = pd.stream;

    pkt->pos = url_ftell(&avf->pb);



    ret = nut_read_frame(priv->nut, &pd.len, pkt->data);



    return ret;

}

static int FUNC_0(AVFormatContext * VAR_0, AVPacket * VAR_1) {

    NUTContext * priv = VAR_0->priv_data;

    nut_packet_t pd;

    int VAR_2;



    while ((VAR_2 = nut_read_next_packet(priv->nut, &pd)) < 0)

        av_log(VAR_0, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-VAR_2));



    if (VAR_2 || av_new_packet(VAR_1, pd.len) < 0) return -1;



    if (pd.flags & NUT_FLAG_KEY) VAR_1->flags |= PKT_FLAG_KEY;

    VAR_1->pts = pd.pts;

    VAR_1->stream_index = pd.stream;

    VAR_1->pos = url_ftell(&VAR_0->pb);



    VAR_2 = nut_read_frame(priv->nut, &pd.len, VAR_1->data);



    return VAR_2;

}

static int FUNC_0(AVFormatContext * VAR_0, AVPacket * VAR_1) { NUTContext * priv = VAR_0->priv_data; nut_packet_t pd; int VAR_2; while ((VAR_2 = nut_read_next_packet(priv->nut, &pd)) < 0)
av_log(VAR_0, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-VAR_2)); if (VAR_2 || av_new_packet(VAR_1, pd.len) < 0) return -1; if (pd.flags & NUT_FLAG_KEY) VAR_1->flags |= PKT_FLAG_KEY; VAR_1->pts = pd.pts; VAR_1->stream_index = pd.stream; VAR_1->pos = url_ftell(&VAR_0->pb); VAR_2 = nut_read_frame(priv->nut, &pd.len, VAR_1->data); return VAR_2; }