int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
{
    int ret, flush = 0;
    if (pkt) {
        AVStream *st = s->streams[pkt->stream_index];
        //FIXME/XXX/HACK drop zero sized packets
        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size == 0)
            return 0;
        av_dlog(s, "av_interleaved_write_frame size:%d dts:%" PRId64 " pts:%" PRId64 "\n",
                pkt->size, pkt->dts, pkt->pts);
        if ((ret = compute_pkt_fields2(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
        if (pkt->dts == AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
            return AVERROR(EINVAL);
    } else {
        av_dlog(s, "av_interleaved_write_frame FLUSH\n");
        flush = 1;
    }
    for (;; ) {
        AVPacket opkt;
        int ret = interleave_packet(s, &opkt, pkt, flush);
        if (ret <= 0) //FIXME cleanup needed for ret<0 ?
        ret = write_packet(s, &opkt);
        if (ret >= 0)
            s->streams[opkt.stream_index]->nb_frames++;
        av_free_packet(&opkt);
        pkt = NULL;
    }
}
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
{
    int ret, flush = 0;
    if (pkt) {
        AVStream *st = s->streams[pkt->stream_index];
        
        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->size == 0)
            return 0;
        av_dlog(s, "av_interleaved_write_frame size:%d dts:%" PRId64 " pts:%" PRId64 "\n",
                pkt->size, pkt->dts, pkt->pts);
        if ((ret = compute_pkt_fields2(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
        if (pkt->dts == AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
            return AVERROR(EINVAL);
    } else {
        av_dlog(s, "av_interleaved_write_frame FLUSH\n");
        flush = 1;
    }
    for (;; ) {
        AVPacket opkt;
        int ret = interleave_packet(s, &opkt, pkt, flush);
        if (ret <= 0) 
        ret = write_packet(s, &opkt);
        if (ret >= 0)
            s->streams[opkt.stream_index]->nb_frames++;
        av_free_packet(&opkt);
        pkt = NULL;
    }
}
int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{
    int VAR_4, VAR_3 = 0;
    if (VAR_1) {
        AVStream *st = VAR_0->streams[VAR_1->stream_index];
        
        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && VAR_1->size == 0)
            return 0;
        av_dlog(VAR_0, "FUNC_0 size:%d dts:%" PRId64 " pts:%" PRId64 "\n",
                VAR_1->size, VAR_1->dts, VAR_1->pts);
        if ((VAR_4 = compute_pkt_fields2(VAR_0, st, VAR_1)) < 0 && !(VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS))
        if (VAR_1->dts == AV_NOPTS_VALUE && !(VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS))
            return AVERROR(EINVAL);
    } else {
        av_dlog(VAR_0, "FUNC_0 FLUSH\n");
        VAR_3 = 1;
    }
    for (;; ) {
        AVPacket opkt;
        int VAR_4 = interleave_packet(VAR_0, &opkt, VAR_1, VAR_3);
        if (VAR_4 <= 0) 
        VAR_4 = write_packet(VAR_0, &opkt);
        if (VAR_4 >= 0)
            VAR_0->streams[opkt.stream_index]->nb_frames++;
        av_free_packet(&opkt);
        VAR_1 = NULL;
    }
}
int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ int VAR_4, VAR_3 = 0; if (VAR_1) { AVStream *st = VAR_0->streams[VAR_1->stream_index]; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && VAR_1->size == 0)
return 0; av_dlog(VAR_0, "FUNC_0 size:%d dts:%" PRId64 " pts:%" PRId64 "\n",
VAR_1->size, VAR_1->dts, VAR_1->pts); if ((VAR_4 = compute_pkt_fields2(VAR_0, st, VAR_1)) < 0 && !(VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS))
if (VAR_1->dts == AV_NOPTS_VALUE && !(VAR_0->oformat->flags & AVFMT_NOTIMESTAMPS))
return AVERROR(EINVAL); } else { av_dlog(VAR_0, "FUNC_0 FLUSH\n"); VAR_3 = 1; } for (;; ) { AVPacket opkt; int VAR_4 = interleave_packet(VAR_0, &opkt, VAR_1, VAR_3); if (VAR_4 <= 0)
VAR_4 = write_packet(VAR_0, &opkt); if (VAR_4 >= 0)
VAR_0->streams[opkt.stream_index]->nb_frames++; av_free_packet(&opkt); VAR_1 = NULL; } }