That is the more appropriate place for it than query_formats().
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -291,6 +291,13 @@ static av_cold int init_video(AVFilterContext *ctx) · 290 unmodified lines | ||
| 291 | 291 | av_log(ctx, AV_LOG_ERROR, "Unspecified pixel format\n"); |
| 292 | 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 | 301 | if (c->w <= 0 || c->h <= 0) { |
| 295 | 302 | av_log(ctx, AV_LOG_ERROR, "Invalid size %dx%d\n", c->w, c->h); |
| 296 | 303 | return AVERROR(EINVAL); |
| @@ -445,14 +452,8 @@ static int query_formats(AVFilterContext *ctx) · 148 unmodified lines | ||
| 445 | 452 | switch (ctx->outputs[0]->type) { |
| 446 | 453 | case AVMEDIA_TYPE_VIDEO: { |
| 447 | 454 | 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) | |
| 454 | 456 | swfmt = ((AVHWFramesContext *) c->hw_frames_ctx->data)->sw_format; |
| 455 | − } | |
| 456 | 457 | if ((ret = ff_add_format (&formats, c->pix_fmt)) < 0 || |
| 457 | 458 | (ret = ff_set_common_formats (ctx , formats )) < 0) |
| 458 | 459 | return ret; |