Merge commit '722ec3eb35bc152ce91d0a4502eca0df1c0086d0'

* commit '722ec3eb35bc152ce91d0a4502eca0df1c0086d0':
  avconv: decouple configuring filtergraphs and setting input parameters

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
Hendrik Leppkes
2016-11-03 14:53:58 +01:00
4 changed files with 136 additions and 22 deletions

View File

@ -471,6 +471,7 @@ static void ffmpeg_cleanup(int ret)
FilterGraph *fg = filtergraphs[i];
avfilter_graph_free(&fg->graph);
for (j = 0; j < fg->nb_inputs; j++) {
av_buffer_unref(&fg->inputs[j]->hw_frames_ctx);
av_freep(&fg->inputs[j]->name);
av_freep(&fg->inputs[j]);
}
@ -2128,6 +2129,16 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
ist->resample_channel_layout = decoded_frame->channel_layout;
ist->resample_channels = avctx->channels;
for (i = 0; i < ist->nb_filters; i++) {
err = ifilter_parameters_from_frame(ist->filters[i], decoded_frame);
if (err < 0) {
av_log(NULL, AV_LOG_ERROR,
"Error reconfiguring input stream %d:%d filter %d\n",
ist->file_index, ist->st->index, i);
goto fail;
}
}
for (i = 0; i < nb_filtergraphs; i++)
if (ist_in_filtergraph(filtergraphs[i], ist)) {
FilterGraph *fg = filtergraphs[i];
@ -2169,6 +2180,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
}
decoded_frame->pts = AV_NOPTS_VALUE;
fail:
av_frame_unref(ist->filter_frame);
av_frame_unref(decoded_frame);
return err < 0 ? err : ret;
@ -2307,6 +2319,16 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eo
ist->resample_height = decoded_frame->height;
ist->resample_pix_fmt = decoded_frame->format;
for (i = 0; i < ist->nb_filters; i++) {
err = ifilter_parameters_from_frame(ist->filters[i], decoded_frame);
if (err < 0) {
av_log(NULL, AV_LOG_ERROR,
"Error reconfiguring input stream %d:%d filter %d\n",
ist->file_index, ist->st->index, i);
goto fail;
}
}
for (i = 0; i < nb_filtergraphs; i++) {
if (ist_in_filtergraph(filtergraphs[i], ist) && ist->reinit_filters &&
configure_filtergraph(filtergraphs[i]) < 0) {
@ -3305,6 +3327,16 @@ static int transcode_init(void)
enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
filtergraph_is_simple(ost->filter->graph)) {
FilterGraph *fg = ost->filter->graph;
if (dec_ctx) {
ret = ifilter_parameters_from_decoder(fg->inputs[0],
dec_ctx);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error initializing filter input\n");
exit_program(1);
}
}
if (configure_filtergraph(fg)) {
av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
exit_program(1);