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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/buffersrc.c+8−7
@@ -291,6 +291,13 @@ static av_cold int init_video(AVFilterContext *ctx) · 290 unmodified lines
291 av_log(ctx, AV_LOG_ERROR, "Unspecified pixel format\n");291 av_log(ctx, AV_LOG_ERROR, "Unspecified pixel format\n");
292 return AVERROR(EINVAL);292 return AVERROR(EINVAL);
293 }293 }
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 }
294 if (c->w <= 0 || c->h <= 0) {301 if (c->w <= 0 || c->h <= 0) {
295 av_log(ctx, AV_LOG_ERROR, "Invalid size %dx%d\n", c->w, c->h);302 av_log(ctx, AV_LOG_ERROR, "Invalid size %dx%d\n", c->w, c->h);
296 return AVERROR(EINVAL);303 return AVERROR(EINVAL);
@@ -445,14 +452,8 @@ static int query_formats(AVFilterContext *ctx) · 148 unmodified lines
445 switch (ctx->outputs[0]->type) {452 switch (ctx->outputs[0]->type) {
446 case AVMEDIA_TYPE_VIDEO: {453 case AVMEDIA_TYPE_VIDEO: {
447 enum AVPixelFormat swfmt = c->pix_fmt;454 enum AVPixelFormat swfmt = c->pix_fmt;
448 if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_HWACCEL) {455 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 }
454 swfmt = ((AVHWFramesContext *) c->hw_frames_ctx->data)->sw_format;456 swfmt = ((AVHWFramesContext *) c->hw_frames_ctx->data)->sw_format;
455 }
456 if ((ret = ff_add_format (&formats, c->pix_fmt)) < 0 ||457 if ((ret = ff_add_format (&formats, c->pix_fmt)) < 0 ||
457 (ret = ff_set_common_formats (ctx , formats )) < 0)458 (ret = ff_set_common_formats (ctx , formats )) < 0)
458 return ret;459 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