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

{

    ASFContext *asf = s->priv_data;

    AVIOContext *pb = s->pb;

    ASFStream *stream;

    AVCodecContext *codec;

    uint32_t packet_number;

    int64_t pts;

    int start_sec;

    int flags = pkt->flags;

    int ret;

    uint64_t offset = avio_tell(pb);



    codec  = s->streams[pkt->stream_index]->codec;

    stream = &asf->streams[pkt->stream_index];



    if (codec->codec_type == AVMEDIA_TYPE_AUDIO)

        flags &= ~AV_PKT_FLAG_KEY;



    pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;

    av_assert0(pts != AV_NOPTS_VALUE);






    pts *= 10000;

    asf->duration = FFMAX(asf->duration, pts + pkt->duration * 10000);



    packet_number = asf->nb_packets;

    put_frame(s, stream, s->streams[pkt->stream_index],

              pkt->dts, pkt->data, pkt->size, flags);



    start_sec = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)

              / ASF_INDEXED_INTERVAL);



    /* check index */

    if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {

        uint16_t packet_count = asf->nb_packets - packet_number;

        ret = update_index(s, start_sec, packet_number, packet_count, offset);

        if (ret < 0)

            return ret;


    asf->end_sec = start_sec;



    return 0;

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

{

    ASFContext *asf = s->priv_data;

    AVIOContext *pb = s->pb;

    ASFStream *stream;

    AVCodecContext *codec;

    uint32_t packet_number;

    int64_t pts;

    int start_sec;

    int flags = pkt->flags;

    int ret;

    uint64_t offset = avio_tell(pb);



    codec  = s->streams[pkt->stream_index]->codec;

    stream = &asf->streams[pkt->stream_index];



    if (codec->codec_type == AVMEDIA_TYPE_AUDIO)

        flags &= ~AV_PKT_FLAG_KEY;



    pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;

    av_assert0(pts != AV_NOPTS_VALUE);






    pts *= 10000;

    asf->duration = FFMAX(asf->duration, pts + pkt->duration * 10000);



    packet_number = asf->nb_packets;

    put_frame(s, stream, s->streams[pkt->stream_index],

              pkt->dts, pkt->data, pkt->size, flags);



    start_sec = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)

              / ASF_INDEXED_INTERVAL);



    

    if ((!asf->is_streamed) && (flags & AV_PKT_FLAG_KEY)) {

        uint16_t packet_count = asf->nb_packets - packet_number;

        ret = update_index(s, start_sec, packet_number, packet_count, offset);

        if (ret < 0)

            return ret;


    asf->end_sec = start_sec;



    return 0;

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

{

    ASFContext *asf = VAR_0->priv_data;

    AVIOContext *pb = VAR_0->pb;

    ASFStream *stream;

    AVCodecContext *codec;

    uint32_t packet_number;

    int64_t pts;

    int VAR_2;

    int VAR_3 = VAR_1->VAR_3;

    int VAR_4;

    uint64_t offset = avio_tell(pb);



    codec  = VAR_0->streams[VAR_1->stream_index]->codec;

    stream = &asf->streams[VAR_1->stream_index];



    if (codec->codec_type == AVMEDIA_TYPE_AUDIO)

        VAR_3 &= ~AV_PKT_FLAG_KEY;



    pts = (VAR_1->pts != AV_NOPTS_VALUE) ? VAR_1->pts : VAR_1->dts;

    av_assert0(pts != AV_NOPTS_VALUE);






    pts *= 10000;

    asf->duration = FFMAX(asf->duration, pts + VAR_1->duration * 10000);



    packet_number = asf->nb_packets;

    put_frame(VAR_0, stream, VAR_0->streams[VAR_1->stream_index],

              VAR_1->dts, VAR_1->data, VAR_1->size, VAR_3);



    VAR_2 = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)

              / ASF_INDEXED_INTERVAL);



    

    if ((!asf->is_streamed) && (VAR_3 & AV_PKT_FLAG_KEY)) {

        uint16_t packet_count = asf->nb_packets - packet_number;

        VAR_4 = update_index(VAR_0, VAR_2, packet_number, packet_count, offset);

        if (VAR_4 < 0)

            return VAR_4;


    asf->end_sec = VAR_2;



    return 0;

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ ASFContext *asf = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; ASFStream *stream; AVCodecContext *codec; uint32_t packet_number; int64_t pts; int VAR_2; int VAR_3 = VAR_1->VAR_3; int VAR_4; uint64_t offset = avio_tell(pb); codec  = VAR_0->streams[VAR_1->stream_index]->codec; stream = &asf->streams[VAR_1->stream_index]; if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
VAR_3 &= ~AV_PKT_FLAG_KEY; pts = (VAR_1->pts != AV_NOPTS_VALUE) ? VAR_1->pts : VAR_1->dts; av_assert0(pts != AV_NOPTS_VALUE); pts *= 10000; asf->duration = FFMAX(asf->duration, pts + VAR_1->duration * 10000); packet_number = asf->nb_packets; put_frame(VAR_0, stream, VAR_0->streams[VAR_1->stream_index],
VAR_1->dts, VAR_1->data, VAR_1->size, VAR_3); VAR_2 = (int)((PREROLL_TIME * 10000 + pts + ASF_INDEXED_INTERVAL - 1)
/ ASF_INDEXED_INTERVAL); if ((!asf->is_streamed) && (VAR_3 & AV_PKT_FLAG_KEY)) { uint16_t packet_count = asf->nb_packets - packet_number; VAR_4 = update_index(VAR_0, VAR_2, packet_number, packet_count, offset); if (VAR_4 < 0)
return VAR_4; asf->end_sec = VAR_2; return 0;