lavfi: add ff_parse_pixel_format() internal function, and use it
Reduce code duplication.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include "avfilter.h"
|
||||
#include "internal.h"
|
||||
#include "avcodec.h"
|
||||
#include "vsrc_buffer.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
@@ -134,7 +135,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
|
||||
{
|
||||
BufferSourceContext *c = ctx->priv;
|
||||
char pix_fmt_str[128];
|
||||
int n = 0;
|
||||
int ret, n = 0;
|
||||
*c->sws_param = 0;
|
||||
|
||||
if (!args ||
|
||||
@@ -145,14 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if ((c->pix_fmt = av_get_pix_fmt(pix_fmt_str)) == PIX_FMT_NONE) {
|
||||
char *tail;
|
||||
c->pix_fmt = strtol(pix_fmt_str, &tail, 10);
|
||||
if (*tail || c->pix_fmt < 0 || c->pix_fmt >= PIX_FMT_NB) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Invalid pixel format string '%s'\n", pix_fmt_str);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
if ((ret = ff_parse_pixel_format(&c->pix_fmt, pix_fmt_str, ctx)) < 0)
|
||||
return ret;
|
||||
|
||||
av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d sws_param:%s\n",
|
||||
c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
|
||||
|
Reference in New Issue
Block a user