Reduce code duplication.
Showing the changes to libavfilter/vsrc_buffer.c (1 of 4 files). Show all
Unified · Split
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | #include "avfilter.h" |
| 27 | +#include "internal.h" | |
| 27 | 28 | #include "avcodec.h" |
| 28 | 29 | #include "vsrc_buffer.h" |
| 29 | 30 | #include "libavutil/imgutils.h" |
| @@ -134,7 +135,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 104 unmodified lines | ||
| 134 | 135 | { |
| 135 | 136 | BufferSourceContext *c = ctx->priv; |
| 136 | 137 | char pix_fmt_str[128]; |
| 137 | − int n = 0; | |
| 138 | + int ret, n = 0; | |
| 138 | 139 | *c->sws_param = 0; |
| 139 | 140 | |
| 140 | 141 | if (!args || |
| @@ -145,14 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 4 unmodified lines | ||
| 145 | 146 | return AVERROR(EINVAL); |
| 146 | 147 | } |
| 147 | 148 | |
| 148 | − if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) { | |
| 149 | − char *tail; | |
| 150 | − c->pix_fmt = strtol(pix_fmt_str, &tail, 10); | |
| 151 | − if (*tail || c->pix_fmt < 0 || c->pix_fmt >= PIX_FMT_NB) { | |
| 152 | − av_log(ctx, AV_LOG_ERROR, "Invalid pixel format string '%s'\n", pix_fmt_str); | |
| 153 | − return AVERROR(EINVAL); | |
| 154 | − } | |
| 155 | − } | |
| 149 | + if ((ret = ff_parse_pixel_format(&c->pix_fmt, pix_fmt_str, ctx)) < 0) | |
| 150 | + return ret; | |
| 156 | 151 | |
| 157 | 152 | av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d sws_param:%s\n", |
| 158 | 153 | c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name, |