if(enc->codec_id == CODEC_ID_MPEG4 && trk->vosLen == 0) { assert(enc->extradata_size);
else if(enc->codec_type == CODEC_TYPE_VIDEO) { if(enc->codec_id == CODEC_ID_MPEG4 && trk->vosLen == 0) { assert(enc->extradata_size);
static int mov_write_packet(AVFormatContext *s, int stream_index,                            const uint8_t *buf, int size, int64_t pts){    MOVContext *mov = s->priv_data;    ByteIOContext *pb = &s->pb;    AVCodecContext *enc;    int cl, id;    enc = &s->streams[stream_index]->codec;    if (!url_is_streamed(&s->pb)) {        MOVTrack* trk = &mov->tracks[stream_index];        int sampleCount = 0;        /* We must find out how many AMR blocks there are in one packet */        if(enc->codec_id == CODEC_ID_AMR_NB) {            static uint16_t packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0};                         int len = 0;            while(len < size && sampleCount < 100) {                len += packed_size[(buf[len] >> 3) & 0x0F];                sampleCount++;            }        }                if(enc->codec_id == CODEC_ID_MPEG4 &&           trk->vosLen == 0)        {            assert(enc->extradata_size);            trk->vosLen = enc->extradata_size;            trk->vosData = av_malloc(trk->vosLen);            memcpy(trk->vosData, enc->extradata, trk->vosLen);        }        cl = trk->entry / MOV_INDEX_CLUSTER_SIZE;        id = trk->entry % MOV_INDEX_CLUSTER_SIZE;        if (trk->ents_allocated <= trk->entry) {            trk->cluster = av_realloc(trk->cluster, (cl+1)*sizeof(void*));             if (!trk->cluster)                return -1;            trk->cluster[cl] = av_malloc(MOV_INDEX_CLUSTER_SIZE*sizeof(MOVIentry));            if (!trk->cluster[cl])                return -1;            trk->ents_allocated += MOV_INDEX_CLUSTER_SIZE;        }        if(stream_index == 0 && trk->entry == 0) {            mov_write_mdat_tag(pb, trk);            mov->time = Timestamp();        }                trk->cluster[cl][id].pos = url_ftell(pb) - mov->movi_list;        trk->cluster[cl][id].len = size;        trk->cluster[cl][id].entries = sampleCount;        trk->enc = enc;        trk->entry++;        if(sampleCount == 0)            trk->samples++;        else            trk->samples += sampleCount;        trk->mdat_size += size;    }    put_buffer(pb, buf, size);    put_flush_packet(pb);    return 0;}