diff options
author | Mark Thompson <sw@jkqxz.net> | 2016-10-31 22:14:04 +0000 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2016-11-02 20:07:15 +0000 |
commit | 7433feb82f75827884d909de34d341a1c4401d4a (patch) | |
tree | 19f866cb05f617b2d8efeb94bc59311872f7a2fa | |
parent | 2025d3787158ba272a1b8fbc0493fa20dd7a8484 (diff) | |
download | ffmpeg-7433feb82f75827884d909de34d341a1c4401d4a.tar.gz |
lavfi: Make default get_video_buffer work with hardware frames
-rw-r--r-- | libavfilter/video.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libavfilter/video.c b/libavfilter/video.c index cadac50da8..533946a74c 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -20,6 +20,7 @@ #include <stdio.h> #include "libavutil/buffer.h" +#include "libavutil/hwcontext.h" #include "libavutil/imgutils.h" #include "libavutil/mem.h" @@ -43,11 +44,16 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h) if (!frame) return NULL; - frame->width = w; - frame->height = h; - frame->format = link->format; + if (link->hw_frames_ctx && + ((AVHWFramesContext*)link->hw_frames_ctx->data)->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) av_frame_free(&frame); |