summaryrefslogtreecommitdiff
path: root/avconv_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-02-12 09:22:15 +0100
committerAnton Khirnov <anton@khirnov.net>2016-02-14 22:22:41 +0100
commit1bf34134612e509fa68c70dfff418c6022459259 (patch)
tree72a330a3735f48a38f2145a75d2f02853fe028fd /avconv_filter.c
parentb3dd30db0b2d857147fc0e1461a00bd6172a26a3 (diff)
avconv: use the new buffersrc parameters API
The timebase change in the zmbv-8bit test is due to the fact that previously the timebase string was evaluated as floating point, then converted to a rational. After this commit, the timebase is passed directly as is.
Diffstat (limited to 'avconv_filter.c')
-rw-r--r--avconv_filter.c70
1 files changed, 49 insertions, 21 deletions
diff --git a/avconv_filter.c b/avconv_filter.c
index 0127580023..aaf5851017 100644
--- a/avconv_filter.c
+++ b/avconv_filter.c
@@ -23,6 +23,7 @@
#include "avconv.h"
#include "libavfilter/avfilter.h"
+#include "libavfilter/buffersrc.h"
#include "libavresample/avresample.h"
@@ -489,24 +490,39 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
InputFile *f = input_files[ist->file_index];
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
ist->st->time_base;
- AVRational sar;
- char args[255], name[255];
+ AVBufferSrcParameters *par;
+ char name[255];
int ret, pad_idx = 0;
- sar = ist->st->sample_aspect_ratio.num ?
- ist->st->sample_aspect_ratio :
- ist->dec_ctx->sample_aspect_ratio;
- snprintf(args, sizeof(args),
- "width=%d:height=%d:pix_fmt=%d:time_base=%d/%d:sar=%d/%d",
- ist->dec_ctx->width, ist->dec_ctx->height,
- ist->hwaccel_retrieve_data ? ist->hwaccel_retrieved_pix_fmt : ist->dec_ctx->pix_fmt,
- tb.num, tb.den, sar.num, sar.den);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
ist->file_index, ist->st->index);
- if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
- args, NULL, fg->graph)) < 0)
+ ifilter->filter = avfilter_graph_alloc_filter(fg->graph, buffer_filt, name);
+ if (!ifilter->filter)
+ return AVERROR(ENOMEM);
+
+ par = av_buffersrc_parameters_alloc();
+ if (!par)
+ return AVERROR(ENOMEM);
+
+ par->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ?
+ ist->st->sample_aspect_ratio :
+ ist->dec_ctx->sample_aspect_ratio;
+ par->width = ist->dec_ctx->width;
+ par->height = ist->dec_ctx->height;
+ par->format = ist->hwaccel_retrieve_data ?
+ ist->hwaccel_retrieved_pix_fmt : ist->dec_ctx->pix_fmt;
+ par->time_base = tb;
+
+ ret = av_buffersrc_parameters_set(ifilter->filter, par);
+ av_freep(&par);
+ if (ret < 0)
+ return ret;
+
+ ret = avfilter_init_str(ifilter->filter, NULL);
+ if (ret < 0)
return ret;
+
last_filter = ifilter->filter;
if (ist->autorotate) {
@@ -565,21 +581,33 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
InputStream *ist = ifilter->ist;
InputFile *f = input_files[ist->file_index];
+ AVBufferSrcParameters *par;
char args[255], name[255];
int ret, pad_idx = 0;
- snprintf(args, sizeof(args), "time_base=%d/%d:sample_rate=%d:sample_fmt=%s"
- ":channel_layout=0x%"PRIx64,
- 1, ist->dec_ctx->sample_rate,
- ist->dec_ctx->sample_rate,
- av_get_sample_fmt_name(ist->dec_ctx->sample_fmt),
- ist->dec_ctx->channel_layout);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
ist->file_index, ist->st->index);
- if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
- name, args, NULL,
- fg->graph)) < 0)
+ ifilter->filter = avfilter_graph_alloc_filter(fg->graph, abuffer_filt, name);
+ if (!ifilter->filter)
+ return AVERROR(ENOMEM);
+
+ par = av_buffersrc_parameters_alloc();
+ if (!par)
+ return AVERROR(ENOMEM);
+
+ par->time_base = (AVRational){ 1, ist->dec_ctx->sample_rate };
+ par->sample_rate = ist->dec_ctx->sample_rate;
+ par->format = ist->dec_ctx->sample_fmt;
+ par->channel_layout = ist->dec_ctx->channel_layout;
+
+ ret = av_buffersrc_parameters_set(ifilter->filter, par);
+ av_freep(&par);
+ if (ret < 0)
+ return ret;
+
+ ret = avfilter_init_str(ifilter->filter, NULL);
+ if (ret < 0)
return ret;
last_filter = ifilter->filter;