mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avconv: insert extra filters in the same way for both graph inputs and outputs
This will allow using the same code when one filter can be inserted both on input and output.
This commit is contained in:
parent
3799376dd3
commit
2e661f26f8
@ -412,14 +412,13 @@ int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOu
|
|||||||
static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||||
AVFilterInOut *in)
|
AVFilterInOut *in)
|
||||||
{
|
{
|
||||||
AVFilterContext *first_filter = in->filter_ctx;
|
AVFilterContext *last_filter;
|
||||||
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
||||||
InputStream *ist = ifilter->ist;
|
InputStream *ist = ifilter->ist;
|
||||||
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
|
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
|
||||||
ist->st->time_base;
|
ist->st->time_base;
|
||||||
AVRational sar;
|
AVRational sar;
|
||||||
char args[255], name[255];
|
char args[255], name[255];
|
||||||
int pad_idx = in->pad_idx;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sar = ist->st->sample_aspect_ratio.num ?
|
sar = ist->st->sample_aspect_ratio.num ?
|
||||||
@ -434,6 +433,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
|
if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
|
||||||
args, NULL, fg->graph)) < 0)
|
args, NULL, fg->graph)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
last_filter = ifilter->filter;
|
||||||
|
|
||||||
if (ist->framerate.num) {
|
if (ist->framerate.num) {
|
||||||
AVFilterContext *setpts;
|
AVFilterContext *setpts;
|
||||||
@ -446,14 +446,13 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
fg->graph)) < 0)
|
fg->graph)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((ret = avfilter_link(setpts, 0, first_filter, pad_idx)) < 0)
|
if ((ret = avfilter_link(last_filter, 0, setpts, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
first_filter = setpts;
|
last_filter = setpts;
|
||||||
pad_idx = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = avfilter_link(ifilter->filter, 0, first_filter, pad_idx)) < 0)
|
if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -461,10 +460,9 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||||
AVFilterInOut *in)
|
AVFilterInOut *in)
|
||||||
{
|
{
|
||||||
AVFilterContext *first_filter = in->filter_ctx;
|
AVFilterContext *last_filter;
|
||||||
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
|
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
|
||||||
InputStream *ist = ifilter->ist;
|
InputStream *ist = ifilter->ist;
|
||||||
int pad_idx = in->pad_idx;
|
|
||||||
char args[255], name[255];
|
char args[255], name[255];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -481,6 +479,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
name, args, NULL,
|
name, args, NULL,
|
||||||
fg->graph)) < 0)
|
fg->graph)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
last_filter = ifilter->filter;
|
||||||
|
|
||||||
if (audio_sync_method > 0) {
|
if (audio_sync_method > 0) {
|
||||||
AVFilterContext *async;
|
AVFilterContext *async;
|
||||||
@ -503,12 +502,11 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = avfilter_link(async, 0, first_filter, pad_idx);
|
ret = avfilter_link(last_filter, 0, async, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
first_filter = async;
|
last_filter = async;
|
||||||
pad_idx = 0;
|
|
||||||
}
|
}
|
||||||
if (audio_volume != 256) {
|
if (audio_volume != 256) {
|
||||||
AVFilterContext *volume;
|
AVFilterContext *volume;
|
||||||
@ -526,14 +524,13 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = avfilter_link(volume, 0, first_filter, pad_idx);
|
ret = avfilter_link(last_filter, 0, volume, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
first_filter = volume;
|
last_filter = volume;
|
||||||
pad_idx = 0;
|
|
||||||
}
|
}
|
||||||
if ((ret = avfilter_link(ifilter->filter, 0, first_filter, pad_idx)) < 0)
|
if ((ret = avfilter_link(last_filter, 0, in->filter_ctx, in->pad_idx)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user