+ if( ret >= 0 ) {
+ AVCodecParameters *avpar = st->codecpar;
+ switch( avpar->codec_type ) {
+ case AVMEDIA_TYPE_VIDEO: {
+ int vidx = ffvideo.size();
+ while( --vidx>=0 && ffvideo[vidx]->fidx != i );
+ if( vidx < 0 ) break;
+ ffvideo[vidx]->avctx = avctx;
+ continue; }
+ case AVMEDIA_TYPE_AUDIO: {
+ int aidx = ffaudio.size();
+ while( --aidx>=0 && ffaudio[aidx]->fidx != i );
+ if( aidx < 0 ) break;
+ ffaudio[aidx]->avctx = avctx;
+ continue; }
+ default: break;
+ }
+ }
+ fprintf(stderr,"FFMPEG::scan: ");
+ fprintf(stderr,_("codec open failed\n"));
+ avcodec_free_context(&avctx);
+ }
+
+ decode_activate();
+ for( int i=0; i<(int)fmt_ctx->nb_streams; ++i ) {
+ AVStream *st = fmt_ctx->streams[i];
+ AVCodecParameters *avpar = st->codecpar;
+ if( avpar->codec_type != AVMEDIA_TYPE_AUDIO ) continue;
+ int64_t tstmp = st->start_time;
+ if( tstmp == AV_NOPTS_VALUE ) continue;
+ int aidx = ffaudio.size();
+ while( --aidx>=0 && ffaudio[aidx]->fidx != i );
+ if( aidx < 0 ) continue;
+ FFAudioStream *aud = ffaudio[aidx];
+ tstmp -= aud->nudge;
+ double secs = to_secs(tstmp, st->time_base);
+ aud->curr_pos = secs * aud->sample_rate + 0.5;