History

lavfi: add ff_parse_pixel_format() internal function, and use it

Reduce code duplication.

Stefano Sabatini committed 15 years ago

Commit e26782a1 parent 2c6348e4 files · +33 −15Browse files

Showing the changes to libavfilter/vsrc_buffer.c (1 of 4 files). Show all

Unified · Split

libavfilter/vsrc_buffer.c+4−9
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 */
2525
2626 #include "avfilter.h"
27+#include "internal.h"
2728 #include "avcodec.h"
2829 #include "vsrc_buffer.h"
2930 #include "libavutil/imgutils.h"
@@ -134,7 +135,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 104 unmodified lines
134135 {
135136 BufferSourceContext *c = ctx->priv;
136137 char pix_fmt_str[128];
137− int n = 0;
138+ int ret, n = 0;
138139 *c->sws_param = 0;
139140
140141 if (!args ||
@@ -145,14 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 4 unmodified lines
145146 return AVERROR(EINVAL);
146147 }
147148
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;
156151
157152 av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d sws_param:%s\n",
158153 c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t