History

lavfi/buffersrc: validate hw context presence in video_init()

That is the more appropriate place for it than query_formats().

Anton Khirnov committed 2 years ago

Commit a7fe27f1 parent 2fa142f1 file · +8 −7Browse files

Unified · Split

libavfilter/buffersrc.c+8−7
@@ -291,6 +291,13 @@ static av_cold int init_video(AVFilterContext *ctx) · 290 unmodified lines
291291 av_log(ctx, AV_LOG_ERROR, "Unspecified pixel format\n");
292292 return AVERROR(EINVAL);
293293 }
294+ if (av_pix_fmt_desc_get(c->pix_fmt)->flags & AV_PIX_FMT_FLAG_HWACCEL) {
295+ if (!c->hw_frames_ctx) {
296+ av_log(ctx, AV_LOG_ERROR, "Setting BufferSourceContext.pix_fmt "
297+ "to a HW format requires hw_frames_ctx to be non-NULL!\n");
298+ return AVERROR(EINVAL);
299+ }
300+ }
294301 if (c->w <= 0 || c->h <= 0) {
295302 av_log(ctx, AV_LOG_ERROR, "Invalid size %dx%d\n", c->w, c->h);
296303 return AVERROR(EINVAL);
@@ -445,14 +452,8 @@ static int query_formats(AVFilterContext *ctx) · 148 unmodified lines
445452 switch (ctx->outputs[0]->type) {
446453 case AVMEDIA_TYPE_VIDEO: {
447454 enum AVPixelFormat swfmt = c->pix_fmt;
448− if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_HWACCEL) {
449− if (!c->hw_frames_ctx) {
450− av_log(ctx, AV_LOG_ERROR, "Setting BufferSourceContext.pix_fmt "
451− "to a HW format requires hw_frames_ctx to be non-NULL!\n");
452− return AVERROR(EINVAL);
453− }
455+ if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_HWACCEL)
454456 swfmt = ((AVHWFramesContext *) c->hw_frames_ctx->data)->sw_format;
455− }
456457 if ((ret = ff_add_format (&formats, c->pix_fmt)) < 0 ||
457458 (ret = ff_set_common_formats (ctx , formats )) < 0)
458459 return ret;

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