#define AUDIO_INBUF_SIZE 0x10000
#define VIDEO_REFILL_THRESH 0
#define AUDIO_REFILL_THRESH 0x1000
+#define AUDIO_MIN_FRAME_SZ 128
Mutex FFMPEG::fflock("FFMPEG::fflock");
if( decoder->capabilities & AV_CODEC_CAP_DR1 )
avctx->flags |= CODEC_FLAG_EMU_EDGE;
avcodec_parameters_to_context(avctx, st->codecpar);
+ if( !av_dict_get(copts, "threads", NULL, 0) )
+ avctx->thread_count = ffmpeg->ff_cpus();
ret = avcodec_open2(avctx, decoder, &copts);
}
if( ret >= 0 ) {
int FFStream::load_filter(AVFrame *frame)
{
- av_frame_unref(frame);
- int ret = av_buffersrc_add_frame_flags(buffersrc_ctx,
- frame, AV_BUFFERSRC_FLAG_KEEP_REF);
+ int ret = av_buffersrc_add_frame_flags(buffersrc_ctx, frame, 0);
if( ret < 0 )
eprintf(_("av_buffersrc_add_frame_flags failed\n"));
return ret;
channel0 = channels = 0;
sample_rate = 0;
mbsz = 0;
+ frame_sz = AUDIO_MIN_FRAME_SZ;
length = 0;
resample_context = 0;
swr_ichs = swr_ifmt = swr_irate = 0;
int FFAudioStream::encode_activate()
{
if( writing >= 0 ) return writing;
+ if( !avctx->codec ) return writing = 0;
frame_sz = avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE ?
10000 : avctx->frame_size;
return FFStream::encode_activate();
av_dict_set(&sopts, "cin_bitrate", 0, 0);
av_dict_set(&sopts, "cin_quality", 0, 0);
+ if( !av_dict_get(sopts, "threads", NULL, 0) )
+ ctx->thread_count = ff_cpus();
ret = avcodec_open2(ctx, codec, &sopts);
if( ret >= 0 ) {
ret = avcodec_parameters_from_context(st->codecpar, ctx);
if( st->start_time == AV_NOPTS_VALUE ) continue;
int vidx = ffvideo.size();
while( --vidx >= 0 && ffvideo[vidx]->fidx != i );
- if( vidx >= 0 && ffvideo[vidx]->nudge != AV_NOPTS_VALUE ) continue;
+ if( vidx < 0 ) continue;
+ if( ffvideo[vidx]->nudge != AV_NOPTS_VALUE ) continue;
if( vstart_time < st->start_time )
vstart_time = st->start_time;
break; }
if( st->start_time == AV_NOPTS_VALUE ) continue;
int aidx = ffaudio.size();
while( --aidx >= 0 && ffaudio[aidx]->fidx != i );
- if( aidx >= 0 && ffaudio[aidx]->nudge != AV_NOPTS_VALUE ) continue;
+ if( aidx < 0 ) continue;
+ if( ffaudio[aidx]->frame_sz < avpar->frame_size )
+ ffaudio[aidx]->frame_sz = avpar->frame_size;
+ if( ffaudio[aidx]->nudge != AV_NOPTS_VALUE ) continue;
if( astart_time < st->start_time )
astart_time = st->start_time;
- ffaudio[aidx]->frame_sz =
- avpar->frame_size < 128 ? 128 : avpar->frame_size;
break; }
default: break;
}
}
if( ret >= 0 ) {
avcodec_parameters_to_context(avctx, st->codecpar);
+ if( !av_dict_get(copts, "threads", NULL, 0) )
+ avctx->thread_count = ff_cpus();
ret = avcodec_open2(avctx, decoder, &copts);
}
av_dict_free(&copts);