Commit 7433feb8 authored by Mark Thompson's avatar Mark Thompson

lavfi: Make default get_video_buffer work with hardware frames

parent 2025d378
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <stdio.h> #include <stdio.h>
#include "libavutil/buffer.h" #include "libavutil/buffer.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/mem.h" #include "libavutil/mem.h"
...@@ -43,11 +44,16 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) ...@@ -43,11 +44,16 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
if (!frame) if (!frame)
return NULL; return NULL;
frame->width = w; if (link->hw_frames_ctx &&
frame->height = h; ((AVHWFramesContext*)link->hw_frames_ctx->data)->format == link->format) {
frame->format = link->format; ret = av_hwframe_get_buffer(link->hw_frames_ctx, frame, 0);
} else {
frame->width = w;
frame->height = h;
frame->format = link->format;
ret = av_frame_get_buffer(frame, 32); ret = av_frame_get_buffer(frame, 32);
}
if (ret < 0) if (ret < 0)
av_frame_free(&frame); av_frame_free(&frame);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment