diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-05-23 14:09:08 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-06-25 11:20:50 +0200 |
commit | 722ec3eb35bc152ce91d0a4502eca0df1c0086d0 (patch) | |
tree | d353507a68b0f209244ebe44f8ee72d7e7305e9e /avconv.c | |
parent | 398f015f077c6a2406deffd9e37ff34b9c7bb3bc (diff) |
avconv: decouple configuring filtergraphs and setting input parameters
Currently, calling configure_filtergraph() will pull in the input
parameters from the corresponding decoder context. This has the
following disadvantages:
- the decoded frame is a more proper source for this information
- a filter accessing decoder data breaks proper layering
Add functions for explicitly sending the input stream parameters to a
filtergraph input - currently from a frame and a decoder. The decoder
one will be dropped in future commits after some more restructuring.
Diffstat (limited to 'avconv.c')
-rw-r--r-- | avconv.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -147,6 +147,7 @@ static void avconv_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]); } @@ -1252,6 +1253,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) && configure_filtergraph(filtergraphs[i]) < 0) { @@ -1279,6 +1290,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) break; } +fail: av_frame_unref(ist->filter_frame); av_frame_unref(decoded_frame); return err < 0 ? err : ret; @@ -1336,6 +1348,16 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) 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) && configure_filtergraph(filtergraphs[i]) < 0) { @@ -2061,6 +2083,14 @@ static int transcode_init(void) enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO) && filtergraph_is_simple(ost->filter->graph)) { FilterGraph *fg = ost->filter->graph; + + 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); |