Re: [FFmpeg-devel] [PATCH] Add GPU accelerated video crop filter
Done it. Thanks Steven and Timo Timo Rothenpieler 于2019年3月23日周六 下午10:52写道: > On 23.03.2019 14:46, Steven Liu wrote: > > Documentation of the crop_cuda should be submitted together. > > > > > > Thanks > > Steven > > > > True, forgot about that. Should be almost identical to that of the > regular crop filter. > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Add GPU accelerated video crop filter
On 23.03.2019 14:46, Steven Liu wrote: Documentation of the crop_cuda should be submitted together. Thanks Steven True, forgot about that. Should be almost identical to that of the regular crop filter. smime.p7s Description: S/MIME Cryptographic Signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Add GPU accelerated video crop filter
> 在 2019年3月23日,19:31,UsingtcNower 写道: > > Signed-off-by: UsingtcNower > --- > Changelog | 1 + > configure | 1 + > libavfilter/Makefile| 1 + > libavfilter/allfilters.c| 1 + > libavfilter/vf_crop_cuda.c | 638 > libavfilter/vf_crop_cuda.cu | 109 > 6 files changed, 751 insertions(+) > create mode 100644 libavfilter/vf_crop_cuda.c > create mode 100644 libavfilter/vf_crop_cuda.cu > > diff --git a/Changelog b/Changelog > index ad7e82f..f224fc8 100644 > --- a/Changelog > +++ b/Changelog > @@ -20,6 +20,7 @@ version : > - libaribb24 based ARIB STD-B24 caption support (profiles A and C) > - Support decoding of HEVC 4:4:4 content in nvdec and cuviddec > - removed libndi-newtek > +- crop_cuda GPU accelerated video crop filter > > > version 4.1: > diff --git a/configure b/configure > index 331393f..88f1e91 100755 > --- a/configure > +++ b/configure > @@ -2978,6 +2978,7 @@ scale_npp_filter_deps="ffnvcodec libnpp" > scale_cuda_filter_deps="ffnvcodec cuda_nvcc" > thumbnail_cuda_filter_deps="ffnvcodec cuda_nvcc" > transpose_npp_filter_deps="ffnvcodec libnpp" > +crop_cuda_filter_deps="ffnvcodec cuda_nvcc" > > amf_deps_any="libdl LoadLibrary" > nvenc_deps="ffnvcodec" > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index fef6ec5..84df037 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -187,6 +187,7 @@ OBJS-$(CONFIG_COPY_FILTER) += vf_copy.o > OBJS-$(CONFIG_COREIMAGE_FILTER) += vf_coreimage.o > OBJS-$(CONFIG_COVER_RECT_FILTER) += vf_cover_rect.o lavfutils.o > OBJS-$(CONFIG_CROP_FILTER) += vf_crop.o > +OBJS-$(CONFIG_CROP_CUDA_FILTER) += vf_crop_cuda.o > vf_crop_cuda.ptx.o > OBJS-$(CONFIG_CROPDETECT_FILTER) += vf_cropdetect.o > OBJS-$(CONFIG_CUE_FILTER)+= f_cue.o > OBJS-$(CONFIG_CURVES_FILTER) += vf_curves.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index c51ae0f..550e545 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -175,6 +175,7 @@ extern AVFilter ff_vf_copy; > extern AVFilter ff_vf_coreimage; > extern AVFilter ff_vf_cover_rect; > extern AVFilter ff_vf_crop; > +extern AVFilter ff_vf_crop_cuda; > extern AVFilter ff_vf_cropdetect; > extern AVFilter ff_vf_cue; > extern AVFilter ff_vf_curves; > diff --git a/libavfilter/vf_crop_cuda.c b/libavfilter/vf_crop_cuda.c > new file mode 100644 > index 000..5a97863 > --- /dev/null > +++ b/libavfilter/vf_crop_cuda.c > @@ -0,0 +1,638 @@ > +/* > +* Copyright (c) 2019, iQIYI CORPORATION. All rights reserved. > +* > +* Permission is hereby granted, free of charge, to any person obtaining a > +* copy of this software and associated documentation files (the "Software"), > +* to deal in the Software without restriction, including without limitation > +* the rights to use, copy, modify, merge, publish, distribute, sublicense, > +* and/or sell copies of the Software, and to permit persons to whom the > +* Software is furnished to do so, subject to the following conditions: > +* > +* The above copyright notice and this permission notice shall be included in > +* all copies or substantial portions of the Software. > +* > +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > +* DEALINGS IN THE SOFTWARE. > +*/ > + > +#include > +#include > + > +#include "libavutil/avstring.h" > +#include "libavutil/common.h" > +#include "libavutil/hwcontext.h" > +#include "libavutil/hwcontext_cuda_internal.h" > +#include "libavutil/cuda_check.h" > +#include "libavutil/internal.h" > +#include "libavutil/opt.h" > +#include "libavutil/pixdesc.h" > +#include "libavutil/eval.h" > + > +#include "avfilter.h" > +#include "formats.h" > +#include "internal.h" > +#include "video.h" > + > +static const char *const var_names[] = { > +"in_w", "iw", ///< width of the input video > +"in_h", "ih", ///< height of the input video > +"out_w", "ow", ///< width of the cropped video > +"out_h", "oh", ///< height of the cropped video > +"x", > +"y", > +NULL > +}; > + > +enum var_name { > +VAR_IN_W, VAR_IW, > +VAR_IN_H, VAR_IH, > +VAR_OUT_W, VAR_OW, > +VAR_OUT_H, VAR_OH, > +VAR_X, > +VAR_Y, > +VAR_VARS_NB > +}; > + > +static const enum AVPixelFormat supported_formats[] = { > +AV_PIX_FMT_YUV420P, > +AV_PIX_FMT_NV12, > +AV_PIX_FMT_YUV444P, > +AV_PIX_FMT_P010, > +AV_PIX_FMT_P016 > +}; > + > +#define DIV_UP(a, b) ( ((a) +
Re: [FFmpeg-devel] [PATCH] Add GPU accelerated video crop filter
Got it and corrected. Thanks Timo Timo Rothenpieler 于2019年3月23日周六 下午7:53写道: > On 23.03.2019 12:31, UsingtcNower wrote: > > diff --git a/configure b/configure > > index 331393f..88f1e91 100755 > > --- a/configure > > +++ b/configure > > @@ -2978,6 +2978,7 @@ scale_npp_filter_deps="ffnvcodec libnpp" > > scale_cuda_filter_deps="ffnvcodec cuda_nvcc" > > thumbnail_cuda_filter_deps="ffnvcodec cuda_nvcc" > > transpose_npp_filter_deps="ffnvcodec libnpp" > > +crop_cuda_filter_deps="ffnvcodec cuda_nvcc" > > These are generally kept in alphabetical order. > > > +static av_cold int init_processing_chain(AVFilterContext *ctx, int > in_width, int in_height, > > + int out_width, int out_height, > > + int left, int top) > > +{ > > +CUDACropContext *s = ctx->priv; > > + > > +AVHWFramesContext *in_frames_ctx; > > + > > +enum AVPixelFormat in_format; > > +enum AVPixelFormat out_format; > > +int ret; > > + > > +/* check that we have a hw context */ > > +if (!ctx->inputs[0]->hw_frames_ctx) { > > +av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n"); > > +return AVERROR(EINVAL); > > +} > > +in_frames_ctx = > (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data; > > +in_format = in_frames_ctx->sw_format; > > +out_format= (s->format == AV_PIX_FMT_NONE) ? in_format : > s->format; > > + > > +if (!format_is_supported(in_format)) { > > +av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n", > > + av_get_pix_fmt_name(in_format)); > > +return AVERROR(ENOSYS); > > +} > > +if (!format_is_supported(out_format)) { > > +av_log(ctx, AV_LOG_ERROR, "Unsupported output format: %s\n", > > + av_get_pix_fmt_name(out_format)); > > +return AVERROR(ENOSYS); > > +} > > + > > +if (in_width == out_width && in_height == out_height) > > +s->passthrough = 1; > > + > > +s->in_fmt = in_format; > > +s->out_fmt = out_format; > > + > > +s->planes_in[0].width = in_width; > > +s->planes_in[0].height = in_height; > > +s->planes_out[0].width = out_width; > > +s->planes_out[0].height = out_height; > > +s->planes_in[0].left = left; > > +s->planes_in[0].top = top; > > +s->planes_out[0].left = 0; > > +s->planes_out[0].top = 0; > > This is a nit, but why not align all of them? > > Also missing a version bump. I'd say bumping lavf micro version is enough. > > > Otherwise this looks good to me. Will give it a test later, and I don't > really see any reason not to merge this. > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Add GPU accelerated video crop filter
On 23.03.2019 12:31, UsingtcNower wrote: > diff --git a/configure b/configure > index 331393f..88f1e91 100755 > --- a/configure > +++ b/configure > @@ -2978,6 +2978,7 @@ scale_npp_filter_deps="ffnvcodec libnpp" > scale_cuda_filter_deps="ffnvcodec cuda_nvcc" > thumbnail_cuda_filter_deps="ffnvcodec cuda_nvcc" > transpose_npp_filter_deps="ffnvcodec libnpp" > +crop_cuda_filter_deps="ffnvcodec cuda_nvcc" These are generally kept in alphabetical order. +static av_cold int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height, + int out_width, int out_height, + int left, int top) +{ +CUDACropContext *s = ctx->priv; + +AVHWFramesContext *in_frames_ctx; + +enum AVPixelFormat in_format; +enum AVPixelFormat out_format; +int ret; + +/* check that we have a hw context */ +if (!ctx->inputs[0]->hw_frames_ctx) { +av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n"); +return AVERROR(EINVAL); +} +in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data; +in_format = in_frames_ctx->sw_format; +out_format= (s->format == AV_PIX_FMT_NONE) ? in_format : s->format; + +if (!format_is_supported(in_format)) { +av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n", + av_get_pix_fmt_name(in_format)); +return AVERROR(ENOSYS); +} +if (!format_is_supported(out_format)) { +av_log(ctx, AV_LOG_ERROR, "Unsupported output format: %s\n", + av_get_pix_fmt_name(out_format)); +return AVERROR(ENOSYS); +} + +if (in_width == out_width && in_height == out_height) +s->passthrough = 1; + +s->in_fmt = in_format; +s->out_fmt = out_format; + +s->planes_in[0].width = in_width; +s->planes_in[0].height = in_height; +s->planes_out[0].width = out_width; +s->planes_out[0].height = out_height; +s->planes_in[0].left = left; +s->planes_in[0].top = top; +s->planes_out[0].left = 0; +s->planes_out[0].top = 0; This is a nit, but why not align all of them? Also missing a version bump. I'd say bumping lavf micro version is enough. Otherwise this looks good to me. Will give it a test later, and I don't really see any reason not to merge this. smime.p7s Description: S/MIME Cryptographic Signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".