aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-11-03 14:53:58 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2016-11-03 14:53:58 +0100
commitb6422902d84ec8df6f5a64ffd8743e93307bd8e9 (patch)
tree72f9c0209b0f26cf4c1b93f4238b5861005294ed /ffmpeg.c
parent3932ccc472ad4f4d370dcfc1c2f574b0f3acb88c (diff)
parent722ec3eb35bc152ce91d0a4502eca0df1c0086d0 (diff)
downloadffmpeg-b6422902d84ec8df6f5a64ffd8743e93307bd8e9.tar.gz
Merge commit '722ec3eb35bc152ce91d0a4502eca0df1c0086d0'
* commit '722ec3eb35bc152ce91d0a4502eca0df1c0086d0': avconv: decouple configuring filtergraphs and setting input parameters Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 3b9171090f..52c655f2d1 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -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);