[FFmpeg-cvslog] avutil/hwcontext_cuda: query correct alignment from device
ffmpeg | branch: master | Timo Rothenpieler | Wed Nov 4 00:19:55 2020 +0100| [2f3cb5cccab51c53f7440760fbd2914edbea801b] | committer: Timo Rothenpieler avutil/hwcontext_cuda: query correct alignment from device > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f3cb5cccab51c53f7440760fbd2914edbea801b --- libavutil/hwcontext_cuda.c | 29 +++-- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index 546515ee66..7278bd2988 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -30,10 +30,9 @@ #include "pixfmt.h" #include "imgutils.h" -#define CUDA_FRAME_ALIGNMENT 512 - typedef struct CUDAFramesContext { int shift_width, shift_height; +int tex_alignment; } CUDAFramesContext; static const enum AVPixelFormat supported_formats[] = { @@ -127,8 +126,11 @@ fail: static int cuda_frames_init(AVHWFramesContext *ctx) { -CUDAFramesContext *priv = ctx->internal->priv; -int i; +AVHWDeviceContext *device_ctx = ctx->device_ctx; +AVCUDADeviceContext*hwctx = device_ctx->hwctx; +CUDAFramesContext *priv = ctx->internal->priv; +CudaFunctions *cu = hwctx->internal->cuda_dl; +int err, i; for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) { if (ctx->sw_format == supported_formats[i]) @@ -140,10 +142,24 @@ static int cuda_frames_init(AVHWFramesContext *ctx) return AVERROR(ENOSYS); } +err = CHECK_CU(cu->cuDeviceGetAttribute(>tex_alignment, +14 /* CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT */, +hwctx->internal->cuda_device)); +if (err < 0) +return err; + +av_log(ctx, AV_LOG_DEBUG, "CUDA texture alignment: %d\n", priv->tex_alignment); + +// YUV420P is a special case. +// Since nvenc expects the U/V planes to have half the linesize of the Y plane +// alignment has to be doubled to ensure the U/V planes still end up aligned. +if (ctx->sw_format == AV_PIX_FMT_YUV420P) +priv->tex_alignment *= 2; + av_pix_fmt_get_chroma_sub_sample(ctx->sw_format, >shift_width, >shift_height); if (!ctx->pool) { -int size = av_image_get_buffer_size(ctx->sw_format, ctx->width, ctx->height, CUDA_FRAME_ALIGNMENT); +int size = av_image_get_buffer_size(ctx->sw_format, ctx->width, ctx->height, priv->tex_alignment); if (size < 0) return size; @@ -157,6 +173,7 @@ static int cuda_frames_init(AVHWFramesContext *ctx) static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) { +CUDAFramesContext *priv = ctx->internal->priv; int res; frame->buf[0] = av_buffer_pool_get(ctx->pool); @@ -164,7 +181,7 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) return AVERROR(ENOMEM); res = av_image_fill_arrays(frame->data, frame->linesize, frame->buf[0]->data, - ctx->sw_format, ctx->width, ctx->height, CUDA_FRAME_ALIGNMENT); + ctx->sw_format, ctx->width, ctx->height, priv->tex_alignment); if (res < 0) return res; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/scale_cuda: add lanczos algorithm
ffmpeg | branch: master | Timo Rothenpieler | Wed Nov 4 01:43:00 2020 +0100| [cfdddec0c832a67da8a0081a32ae2c7127ce2368] | committer: Timo Rothenpieler avfilter/scale_cuda: add lanczos algorithm > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cfdddec0c832a67da8a0081a32ae2c7127ce2368 --- compat/cuda/cuda_runtime.h | 3 ++ libavfilter/version.h| 2 +- libavfilter/vf_scale_cuda.c | 8 libavfilter/vf_scale_cuda_bicubic.cu | 81 +--- 4 files changed, 77 insertions(+), 17 deletions(-) diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h index 353efcf5f9..590c2d1bb0 100644 --- a/compat/cuda/cuda_runtime.h +++ b/compat/cuda/cuda_runtime.h @@ -182,4 +182,7 @@ static inline __device__ float fabsf(float a) { return __builtin_fabsf(a); } static inline __device__ float fabs(float a) { return __builtin_fabsf(a); } static inline __device__ double fabs(double a) { return __builtin_fabs(a); } +static inline __device__ float __sinf(float a) { return __nvvm_sin_approx_f(a); } +static inline __device__ float __cosf(float a) { return __nvvm_cos_approx_f(a); } + #endif /* COMPAT_CUDA_CUDA_RUNTIME_H */ diff --git a/libavfilter/version.h b/libavfilter/version.h index 2db35f85af..44264e12cb 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 7 #define LIBAVFILTER_VERSION_MINOR 88 -#define LIBAVFILTER_VERSION_MICRO 101 +#define LIBAVFILTER_VERSION_MICRO 102 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c index dfa638dbf7..f6401b35b0 100644 --- a/libavfilter/vf_scale_cuda.c +++ b/libavfilter/vf_scale_cuda.c @@ -59,6 +59,7 @@ enum { INTERP_ALGO_NEAREST, INTERP_ALGO_BILINEAR, INTERP_ALGO_BICUBIC, +INTERP_ALGO_LANCZOS, INTERP_ALGO_COUNT }; @@ -293,6 +294,12 @@ static av_cold int cudascale_config_props(AVFilterLink *outlink) s->interp_use_linear = 0; s->interp_as_integer = 0; break; +case INTERP_ALGO_LANCZOS: +scaler_ptx = vf_scale_cuda_bicubic_ptx; +function_infix = "_Lanczos"; +s->interp_use_linear = 0; +s->interp_as_integer = 0; +break; default: av_log(ctx, AV_LOG_ERROR, "Unknown interpolation algorithm\n"); return AVERROR_BUG; @@ -601,6 +608,7 @@ static const AVOption options[] = { { "nearest", "nearest neighbour", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_NEAREST }, 0, 0, FLAGS, "interp_algo" }, { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BILINEAR }, 0, 0, FLAGS, "interp_algo" }, { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BICUBIC }, 0, 0, FLAGS, "interp_algo" }, +{ "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_LANCZOS }, 0, 0, FLAGS, "interp_algo" }, { "passthrough", "Do not process frames at all if parameters match", OFFSET(passthrough), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, { "force_original_aspect_ratio", "decrease or increase w/h if necessary to keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FLAGS, "force_oar" }, { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "force_oar" }, diff --git a/libavfilter/vf_scale_cuda_bicubic.cu b/libavfilter/vf_scale_cuda_bicubic.cu index 8a27927e60..fe451ec54b 100644 --- a/libavfilter/vf_scale_cuda_bicubic.cu +++ b/libavfilter/vf_scale_cuda_bicubic.cu @@ -22,6 +22,30 @@ #include "cuda/vector_helpers.cuh" +typedef float4 (*coeffs_function_t)(float); + +__device__ inline float4 lanczos_coeffs(float x) +{ +const float pi = 3.141592654f; + +float4 res = make_float4( +pi * (x + 1), +pi * x, +pi * (x - 1), +pi * (x - 2)); + +res.x = res.x == 0.0f ? 1.0f : +__sinf(res.x) * __sinf(res.x / 2.0f) / (res.x * res.x / 2.0f); +res.y = res.y == 0.0f ? 1.0f : +__sinf(res.y) * __sinf(res.y / 2.0f) / (res.y * res.y / 2.0f); +res.z = res.z == 0.0f ? 1.0f : +__sinf(res.z) * __sinf(res.z / 2.0f) / (res.z * res.z / 2.0f); +res.w = res.w == 0.0f ? 1.0f : +__sinf(res.w) * __sinf(res.w / 2.0f) / (res.w * res.w / 2.0f); + +return res / (res.x + res.y + res.z + res.w); +} + __device__ inline float4 bicubic_coeffs(float x) { const float A = -0.75f; @@ -35,10 +59,8 @@ __device__ inline float4 bicubic_coeffs(float x) return res; } -__device__ inline void bicubic_fast_coeffs(float x, float *h0, float *h1, float *s) +__device__ inline void derived_fast_coeffs(float4 coeffs, float x, float *h0, float *h1, float *s) { -float4 coeffs = bicubic_coeffs(x); - float g0 = coeffs.x + coeffs.y; float g1 = coeffs.z + coeffs.w; @@ -48,7 +70,7 @@ __device__ inline void
[FFmpeg-cvslog] avutil/hwcontext_cuda: fix edge case with non-even frame heights
ffmpeg | branch: master | Timo Rothenpieler | Wed Nov 4 01:36:48 2020 +0100| [98d3f2359853f1908092b6244f429ced838f493b] | committer: Timo Rothenpieler avutil/hwcontext_cuda: fix edge case with non-even frame heights > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98d3f2359853f1908092b6244f429ced838f493b --- libavutil/hwcontext_cuda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index 7278bd2988..58ffc81378 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -190,7 +190,7 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) if (ctx->sw_format == AV_PIX_FMT_YUV420P) { frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2; frame->data[2] = frame->data[1]; -frame->data[1] = frame->data[2] + frame->linesize[2] * ctx->height / 2; +frame->data[1] = frame->data[2] + frame->linesize[2] * (ctx->height / 2); } frame->format = AV_PIX_FMT_CUDA; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_mpeg2: Fix setting colour properties
ffmpeg | branch: master | Mark Thompson | Mon Nov 2 22:46:49 2020 +| [755203c2d270e1334987b462f80151eb88e30121] | committer: Mark Thompson vaapi_encode_mpeg2: Fix setting colour properties Follow the same pattern as the previous commits for H.264 and H.265. Reviewed-By: Jan Ekström Tested-By: Xu, Yefeng > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=755203c2d270e1334987b462f80151eb88e30121 --- libavcodec/vaapi_encode_mpeg2.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index b8f1c06d0f..df2c62b8e7 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -292,17 +292,16 @@ static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx) priv->sequence_display_extension.extension_start_code_identifier = MPEG2_EXTENSION_SEQUENCE_DISPLAY; +// Unspecified video format, from table 6-6. sde->video_format = 5; -if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || + +sde->colour_primaries = avctx->color_primaries; +sde->transfer_characteristics = avctx->color_trc; +sde->matrix_coefficients = avctx->colorspace; +sde->colour_description = +avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { -sde->colour_description = 1; -sde->colour_primaries = avctx->color_primaries; -sde->transfer_characteristics = avctx->color_trc; -sde->matrix_coefficients = avctx->colorspace; -} else { -sde->colour_description = 0; -} +avctx->colorspace != AVCOL_SPC_UNSPECIFIED; sde->display_horizontal_size = avctx->width; sde->display_vertical_size = avctx->height; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h265: Fix setting colour properties
ffmpeg | branch: master | Mark Thompson | Mon Nov 2 22:46:48 2020 +| [486817e1aedda759bd21287b462ee0bb6e100949] | committer: Mark Thompson vaapi_encode_h265: Fix setting colour properties Matching the previous commit for H.264. Reviewed-By: Jan Ekström Tested-By: Xu, Yefeng > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=486817e1aedda759bd21287b462ee0bb6e100949 --- libavcodec/vaapi_encode_h265.c | 34 -- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 316030914c..3e0af17ea5 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -488,30 +488,20 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) vui->aspect_ratio_info_present_flag = 1; } -if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || -avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || +// Unspecified video format, from table E-2. +vui->video_format = 5; +vui->video_full_range_flag= +avctx->color_range == AVCOL_RANGE_JPEG; +vui->colour_primaries = avctx->color_primaries; +vui->transfer_characteristics = avctx->color_trc; +vui->matrix_coefficients = avctx->colorspace; +if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { +avctx->colorspace != AVCOL_SPC_UNSPECIFIED) +vui->colour_description_present_flag = 1; +if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || +vui->colour_description_present_flag) vui->video_signal_type_present_flag = 1; -vui->video_format = 5; // Unspecified. -vui->video_full_range_flag = -avctx->color_range == AVCOL_RANGE_JPEG; - -if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || -avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { -vui->colour_description_present_flag = 1; -vui->colour_primaries = avctx->color_primaries; -vui->transfer_characteristics = avctx->color_trc; -vui->matrix_coefficients = avctx->colorspace; -} -} else { -vui->video_format = 5; -vui->video_full_range_flag= 0; -vui->colour_primaries = avctx->color_primaries; -vui->transfer_characteristics = avctx->color_trc; -vui->matrix_coefficients = avctx->colorspace; -} if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) { vui->chroma_loc_info_present_flag = 1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] vaapi_encode_h264: Fix setting colour properties
ffmpeg | branch: master | Mark Thompson | Mon Nov 2 22:46:47 2020 +| [9faf4dcf234dbc34f05cd2d973473df2eece4881] | committer: Mark Thompson vaapi_encode_h264: Fix setting colour properties The properties should always be set; only the presence flags want to be conditional. Fixes #8959. Reviewed-By: Jan Ekström Tested-By: Xu, Yefeng > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9faf4dcf234dbc34f05cd2d973473df2eece4881 --- libavcodec/vaapi_encode_h264.c | 34 -- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 5e1683e851..e52a0e37a4 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -411,30 +411,20 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->vui.aspect_ratio_info_present_flag = 1; } -if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || -avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || +// Unspecified video format, from table E-2. +sps->vui.video_format = 5; +sps->vui.video_full_range_flag= +avctx->color_range == AVCOL_RANGE_JPEG; +sps->vui.colour_primaries = avctx->color_primaries; +sps->vui.transfer_characteristics = avctx->color_trc; +sps->vui.matrix_coefficients = avctx->colorspace; +if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { +avctx->colorspace != AVCOL_SPC_UNSPECIFIED) +sps->vui.colour_description_present_flag = 1; +if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED || +sps->vui.colour_description_present_flag) sps->vui.video_signal_type_present_flag = 1; -sps->vui.video_format = 5; // Unspecified. -sps->vui.video_full_range_flag = -avctx->color_range == AVCOL_RANGE_JPEG; - -if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || -avctx->color_trc != AVCOL_TRC_UNSPECIFIED || -avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { -sps->vui.colour_description_present_flag = 1; -sps->vui.colour_primaries = avctx->color_primaries; -sps->vui.transfer_characteristics = avctx->color_trc; -sps->vui.matrix_coefficients = avctx->colorspace; -} -} else { -sps->vui.video_format = 5; -sps->vui.video_full_range_flag= 0; -sps->vui.colour_primaries = avctx->color_primaries; -sps->vui.transfer_characteristics = avctx->color_trc; -sps->vui.matrix_coefficients = avctx->colorspace; -} if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) { sps->vui.chroma_loc_info_present_flag = 1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avutil/hwcontext_cuda: increase CUDA frame alignment to 512
ffmpeg | branch: master | Timo Rothenpieler | Mon Nov 2 21:31:35 2020 +0100| [d5763edab21b08cd1388a2f41885d11d61653917] | committer: Timo Rothenpieler avutil/hwcontext_cuda: increase CUDA frame alignment to 512 At least on Turing, a frame without 512 byte alignment cannot be passed to cuTexObjectCreate. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5763edab21b08cd1388a2f41885d11d61653917 --- libavutil/hwcontext_cuda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index 718a449b6e..546515ee66 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -30,7 +30,7 @@ #include "pixfmt.h" #include "imgutils.h" -#define CUDA_FRAME_ALIGNMENT 256 +#define CUDA_FRAME_ALIGNMENT 512 typedef struct CUDAFramesContext { int shift_width, shift_height; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/scale_cuda: code cleanup
ffmpeg | branch: master | Timo Rothenpieler | Tue Nov 3 18:33:55 2020 +0100| [15c0e038ce90c3c1e13e80ea4fcf56c327b686f4] | committer: Timo Rothenpieler avfilter/scale_cuda: code cleanup > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=15c0e038ce90c3c1e13e80ea4fcf56c327b686f4 --- libavfilter/vf_scale_cuda.c | 118 +- libavfilter/vf_scale_cuda.cu | 194 +++ 2 files changed, 90 insertions(+), 222 deletions(-) diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c index b287bd8c12..dc565cda89 100644 --- a/libavfilter/vf_scale_cuda.c +++ b/libavfilter/vf_scale_cuda.c @@ -48,8 +48,6 @@ static const enum AVPixelFormat supported_formats[] = { }; #define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) -#define ALIGN_UP(a, b) (((a) + (b) - 1) & ~((b) - 1)) -#define NUM_BUFFERS 2 #define BLOCKX 32 #define BLOCKY 16 @@ -72,11 +70,6 @@ typedef struct CUDAScaleContext { enum AVPixelFormat in_fmt; enum AVPixelFormat out_fmt; -struct { -int width; -int height; -} planes_in[3], planes_out[3]; - AVBufferRef *frames_ctx; AVFrame *frame; @@ -110,6 +103,7 @@ typedef struct CUDAScaleContext { int interp_algo; int interp_use_linear; +int interp_as_integer; } CUDAScaleContext; static av_cold int cudascale_init(AVFilterContext *ctx) @@ -153,30 +147,17 @@ static int cudascale_query_formats(AVFilterContext *ctx) AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE, }; AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats); +if (!pix_fmts) +return AVERROR(ENOMEM); return ff_set_common_formats(ctx, pix_fmts); } -static av_cold int init_stage(CUDAScaleContext *s, AVBufferRef *device_ctx) +static av_cold int init_hwframe_ctx(CUDAScaleContext *s, AVBufferRef *device_ctx, int width, int height) { AVBufferRef *out_ref = NULL; AVHWFramesContext *out_ctx; -int in_sw, in_sh, out_sw, out_sh; -int ret, i; - -av_pix_fmt_get_chroma_sub_sample(s->in_fmt, _sw, _sh); -av_pix_fmt_get_chroma_sub_sample(s->out_fmt, _sw, _sh); -if (!s->planes_out[0].width) { -s->planes_out[0].width = s->planes_in[0].width; -s->planes_out[0].height = s->planes_in[0].height; -} - -for (i = 1; i < FF_ARRAY_ELEMS(s->planes_in); i++) { -s->planes_in[i].width = s->planes_in[0].width >> in_sw; -s->planes_in[i].height = s->planes_in[0].height >> in_sh; -s->planes_out[i].width = s->planes_out[0].width >> out_sw; -s->planes_out[i].height = s->planes_out[0].height >> out_sh; -} +int ret; out_ref = av_hwframe_ctx_alloc(device_ctx); if (!out_ref) @@ -185,8 +166,8 @@ static av_cold int init_stage(CUDAScaleContext *s, AVBufferRef *device_ctx) out_ctx->format= AV_PIX_FMT_CUDA; out_ctx->sw_format = s->out_fmt; -out_ctx->width = FFALIGN(s->planes_out[0].width, 32); -out_ctx->height= FFALIGN(s->planes_out[0].height, 32); +out_ctx->width = FFALIGN(width, 32); +out_ctx->height= FFALIGN(height, 32); ret = av_hwframe_ctx_init(out_ref); if (ret < 0) @@ -197,8 +178,8 @@ static av_cold int init_stage(CUDAScaleContext *s, AVBufferRef *device_ctx) if (ret < 0) goto fail; -s->frame->width = s->planes_out[0].width; -s->frame->height = s->planes_out[0].height; +s->frame->width = width; +s->frame->height = height; av_buffer_unref(>frames_ctx); s->frames_ctx = out_ref; @@ -250,20 +231,20 @@ static av_cold int init_processing_chain(AVFilterContext *ctx, int in_width, int 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; +if (s->passthrough && in_width == out_width && in_height == out_height && in_format == out_format) { +s->frames_ctx = av_buffer_ref(ctx->inputs[0]->hw_frames_ctx); +if (!s->frames_ctx) +return AVERROR(ENOMEM); +} else { +s->passthrough = 0; -ret = init_stage(s, in_frames_ctx->device_ref); -if (ret < 0) -return ret; +ret = init_hwframe_ctx(s, in_frames_ctx->device_ref, out_width, out_height); +if (ret < 0) +return ret; +} ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->frames_ctx); if (!ctx->outputs[0]->hw_frames_ctx) @@ -296,12 +277,14 @@ static av_cold int cudascale_config_props(AVFilterLink *outlink) scaler_ptx = vf_scale_cuda_ptx; function_infix = "_Bilinear"; s->interp_use_linear = 1; +s->interp_as_integer = 1; break; case INTERP_ALGO_DEFAULT: case INTERP_ALGO_BICUBIC: scaler_ptx =
[FFmpeg-cvslog] avfilter/scale_cuda: add nearest neighbour algorithm
ffmpeg | branch: master | Timo Rothenpieler | Tue Nov 3 19:28:06 2020 +0100| [4ad7af085cd3db473bf035394d7d934800461bdf] | committer: Timo Rothenpieler avfilter/scale_cuda: add nearest neighbour algorithm > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ad7af085cd3db473bf035394d7d934800461bdf --- libavfilter/vf_scale_cuda.c | 8 libavfilter/vf_scale_cuda.cu | 42 ++ 2 files changed, 50 insertions(+) diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c index dc565cda89..dfa638dbf7 100644 --- a/libavfilter/vf_scale_cuda.c +++ b/libavfilter/vf_scale_cuda.c @@ -56,6 +56,7 @@ static const enum AVPixelFormat supported_formats[] = { enum { INTERP_ALGO_DEFAULT, +INTERP_ALGO_NEAREST, INTERP_ALGO_BILINEAR, INTERP_ALGO_BICUBIC, @@ -273,6 +274,12 @@ static av_cold int cudascale_config_props(AVFilterLink *outlink) extern char vf_scale_cuda_bicubic_ptx[]; switch(s->interp_algo) { +case INTERP_ALGO_NEAREST: +scaler_ptx = vf_scale_cuda_ptx; +function_infix = "_Nearest"; +s->interp_use_linear = 0; +s->interp_as_integer = 1; +break; case INTERP_ALGO_BILINEAR: scaler_ptx = vf_scale_cuda_ptx; function_infix = "_Bilinear"; @@ -591,6 +598,7 @@ static const AVOption options[] = { { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS }, { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS }, { "interp_algo", "Interpolation algorithm used for resizing", OFFSET(interp_algo), AV_OPT_TYPE_INT, { .i64 = INTERP_ALGO_DEFAULT }, 0, INTERP_ALGO_COUNT - 1, FLAGS, "interp_algo" }, +{ "nearest", "nearest neighbour", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_NEAREST }, 0, 0, FLAGS, "interp_algo" }, { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BILINEAR }, 0, 0, FLAGS, "interp_algo" }, { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BICUBIC }, 0, 0, FLAGS, "interp_algo" }, { "passthrough", "Do not process frames at all if parameters match", OFFSET(passthrough), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, diff --git a/libavfilter/vf_scale_cuda.cu b/libavfilter/vf_scale_cuda.cu index 24b1151215..44eef535fd 100644 --- a/libavfilter/vf_scale_cuda.cu +++ b/libavfilter/vf_scale_cuda.cu @@ -22,6 +22,27 @@ #include "cuda/vector_helpers.cuh" +template +__device__ inline void Subsample_Nearest(cudaTextureObject_t tex, + T *dst, + int dst_width, int dst_height, int dst_pitch, + int src_width, int src_height, + int bit_depth) +{ +int xo = blockIdx.x * blockDim.x + threadIdx.x; +int yo = blockIdx.y * blockDim.y + threadIdx.y; + +if (yo < dst_height && xo < dst_width) +{ +float hscale = (float)src_width / (float)dst_width; +float vscale = (float)src_height / (float)dst_height; +float xi = (xo + 0.5f) * hscale; +float yi = (yo + 0.5f) * vscale; + +dst[yo*dst_pitch+xo] = tex2D(tex, xi, yi); +} +} + template __device__ inline void Subsample_Bilinear(cudaTextureObject_t tex, T *dst, @@ -57,6 +78,27 @@ __device__ inline void Subsample_Bilinear(cudaTextureObject_t tex, extern "C" { +#define NEAREST_KERNEL(T) \ +__global__ void Subsample_Nearest_ ## T(cudaTextureObject_t src_tex, \ +T *dst, \ +int dst_width, int dst_height, int dst_pitch, \ +int src_width, int src_height, \ +int bit_depth) \ +{ \ +Subsample_Nearest(src_tex, dst, \ + dst_width, dst_height, dst_pitch, \ + src_width, src_height, \ + bit_depth); \ +} + +NEAREST_KERNEL(uchar) +NEAREST_KERNEL(uchar2) +NEAREST_KERNEL(uchar4) + +NEAREST_KERNEL(ushort) +NEAREST_KERNEL(ushort2) +NEAREST_KERNEL(ushort4) + #define BILINEAR_KERNEL(T) \ __global__ void Subsample_Bilinear_ ## T(cudaTextureObject_t src_tex, \ T *dst, \ ___ ffmpeg-cvslog mailing list
[FFmpeg-cvslog] avfilter/scale_cuda: add bicubic interpolation
ffmpeg | branch: master | Timo Rothenpieler | Sat Oct 31 20:22:33 2020 +0100| [f1d0f83712470c0fef13b8215cccbdb77ba7f3bf] | committer: Timo Rothenpieler avfilter/scale_cuda: add bicubic interpolation > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f1d0f83712470c0fef13b8215cccbdb77ba7f3bf --- compat/cuda/cuda_runtime.h | 68 -- libavfilter/Makefile | 3 +- libavfilter/cuda/vector_helpers.cuh | 112 ++ libavfilter/version.h| 2 +- libavfilter/vf_scale_cuda.c | 113 --- libavfilter/vf_scale_cuda_bicubic.cu | 174 +++ 6 files changed, 429 insertions(+), 43 deletions(-) diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h index 92c55ad859..353efcf5f9 100644 --- a/compat/cuda/cuda_runtime.h +++ b/compat/cuda/cuda_runtime.h @@ -49,18 +49,23 @@ typedef struct __device_builtin__ __align__(4) ushort2 unsigned short x, y; } ushort2; -typedef struct __device_builtin__ uint3 +typedef struct __device_builtin__ __align__(8) float2 { -unsigned int x, y, z; -} uint3; - -typedef struct uint3 dim3; +float x, y; +} float2; typedef struct __device_builtin__ __align__(8) int2 { int x, y; } int2; +typedef struct __device_builtin__ uint3 +{ +unsigned int x, y, z; +} uint3; + +typedef struct uint3 dim3; + typedef struct __device_builtin__ __align__(4) uchar4 { unsigned char x, y, z, w; @@ -76,6 +81,11 @@ typedef struct __device_builtin__ __align__(16) int4 int x, y, z, w; } int4; +typedef struct __device_builtin__ __align__(16) float4 +{ +float x, y, z, w; +} float4; + // Accessors for special registers #define GETCOMP(reg, comp) \ asm("mov.u32 %0, %%" #reg "." #comp ";" : "=r"(tmp)); \ @@ -100,24 +110,31 @@ GET(getThreadIdx, tid) #define threadIdx (getThreadIdx()) // Basic initializers (simple macros rather than inline functions) +#define make_int2(a, b) ((int2){.x = a, .y = b}) #define make_uchar2(a, b) ((uchar2){.x = a, .y = b}) #define make_ushort2(a, b) ((ushort2){.x = a, .y = b}) +#define make_float2(a, b) ((float2){.x = a, .y = b}) +#define make_int4(a, b, c, d) ((int4){.x = a, .y = b, .z = c, .w = d}) #define make_uchar4(a, b, c, d) ((uchar4){.x = a, .y = b, .z = c, .w = d}) #define make_ushort4(a, b, c, d) ((ushort4){.x = a, .y = b, .z = c, .w = d}) +#define make_float4(a, b, c, d) ((float4){.x = a, .y = b, .z = c, .w = d}) // Conversions from the tex instruction's 4-register output to various types #define TEX2D(type, ret) static inline __device__ void conv(type* out, unsigned a, unsigned b, unsigned c, unsigned d) {*out = (ret);} TEX2D(unsigned char, a & 0xFF) TEX2D(unsigned short, a & 0x) +TEX2D(float, a) TEX2D(uchar2, make_uchar2(a & 0xFF, b & 0xFF)) TEX2D(ushort2, make_ushort2(a & 0x, b & 0x)) +TEX2D(float2, make_float2(a, b)) TEX2D(uchar4, make_uchar4(a & 0xFF, b & 0xFF, c & 0xFF, d & 0xFF)) TEX2D(ushort4, make_ushort4(a & 0x, b & 0x, c & 0x, d & 0x)) +TEX2D(float4, make_float4(a, b, c, d)) // Template calling tex instruction and converting the output to the selected type -template -static inline __device__ T tex2D(cudaTextureObject_t texObject, float x, float y) +template +inline __device__ T tex2D(cudaTextureObject_t texObject, float x, float y) { T ret; unsigned ret1, ret2, ret3, ret4; @@ -128,4 +145,41 @@ static inline __device__ T tex2D(cudaTextureObject_t texObject, float x, float y return ret; } +template<> +inline __device__ float4 tex2D(cudaTextureObject_t texObject, float x, float y) +{ +float4 ret; +asm("tex.2d.v4.f32.f32 {%0, %1, %2, %3}, [%4, {%5, %6}];" : +"=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : +"l"(texObject), "f"(x), "f"(y)); +return ret; +} + +template<> +inline __device__ float tex2D(cudaTextureObject_t texObject, float x, float y) +{ +return tex2D(texObject, x, y).x; +} + +template<> +inline __device__ float2 tex2D(cudaTextureObject_t texObject, float x, float y) +{ +float4 ret = tex2D(texObject, x, y); +return make_float2(ret.x, ret.y); +} + +// Math helper functions +static inline __device__ float floorf(float a) { return __builtin_floorf(a); } +static inline __device__ float floor(float a) { return __builtin_floorf(a); } +static inline __device__ double floor(double a) { return __builtin_floor(a); } +static inline __device__ float ceilf(float a) { return __builtin_ceilf(a); } +static inline __device__ float ceil(float a) { return __builtin_ceilf(a); } +static inline __device__ double ceil(double a) { return __builtin_ceil(a); } +static inline __device__ float truncf(float a) { return __builtin_truncf(a); } +static inline __device__ float trunc(float a) { return __builtin_truncf(a); } +static inline __device__ double trunc(double a) { return __builtin_trunc(a); } +static inline __device__ float fabsf(float a) { return __builtin_fabsf(a); }
[FFmpeg-cvslog] avcodec/tscc2: Don't check for errors for complete VLCs
ffmpeg | branch: master | Andreas Rheinhardt | Thu Oct 29 15:26:06 2020 +0100| [7781aa85bc7283676ba7f90988f4ed5dbcfc6a0d] | committer: Andreas Rheinhardt avcodec/tscc2: Don't check for errors for complete VLCs Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7781aa85bc7283676ba7f90988f4ed5dbcfc6a0d --- libavcodec/tscc2.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c index 6aadb51ad4..9fa28fe9fc 100644 --- a/libavcodec/tscc2.c +++ b/libavcodec/tscc2.c @@ -151,8 +151,6 @@ static int tscc2_decode_mb(TSCC2Context *c, int *q, int vlc_set, dc = get_bits(gb, 8); } else { dc = get_vlc2(gb, c->dc_vlc.table, 9, 2); -if (dc == -1) -return AVERROR_INVALIDDATA; if (dc == 0x100) dc = get_bits(gb, 8); } @@ -161,15 +159,11 @@ static int tscc2_decode_mb(TSCC2Context *c, int *q, int vlc_set, c->block[0] = dc; nc = get_vlc2(gb, c->nc_vlc[vlc_set].table, 9, 1); -if (nc == -1) -return AVERROR_INVALIDDATA; bpos = 1; memset(c->block + 1, 0, 15 * sizeof(*c->block)); for (l = 0; l < nc; l++) { ac = get_vlc2(gb, c->ac_vlc[vlc_set].table, 9, 2); -if (ac == -1) -return AVERROR_INVALIDDATA; if (ac == 0x1000) ac = get_bits(gb, 12); bpos += ac & 0xF; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mimic: Inline constants
ffmpeg | branch: master | Andreas Rheinhardt | Wed Oct 28 14:06:23 2020 +0100| [33fbc907359fb1e69a61072929a919bd5dfa8100] | committer: Andreas Rheinhardt avcodec/mimic: Inline constants Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=33fbc907359fb1e69a61072929a919bd5dfa8100 --- libavcodec/mimic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 2563a49d53..0f8103ef85 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -34,6 +34,7 @@ #include "thread.h" #define MIMIC_HEADER_SIZE 20 +#define MIMIC_VLC_BITS 11 typedef struct MimicContext { AVCodecContext *avctx; @@ -141,7 +142,7 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx) ctx->prev_index = 0; ctx->cur_index = 15; -if ((ret = init_vlc(>vlc, 11, FF_ARRAY_ELEMS(huffbits), +if ((ret = init_vlc(>vlc, MIMIC_VLC_BITS, FF_ARRAY_ELEMS(huffbits), huffbits, 1, 1, huffcodes, 4, 4, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "error initializing vlc table\n"); return ret; @@ -239,7 +240,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale) int value; int coeff; -vlc = get_vlc2(>gb, ctx->vlc.table, ctx->vlc.bits, 3); +vlc = get_vlc2(>gb, ctx->vlc.table, MIMIC_VLC_BITS, 3); if (!vlc) /* end-of-block code */ return 0; if (vlc == -1) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpc8: Unobfuscate sign-extension
ffmpeg | branch: master | Andreas Rheinhardt | Thu Oct 29 23:58:51 2020 +0100| [1c430f60454acbf6f288058d971a44d6bb3d48e7] | committer: Andreas Rheinhardt avcodec/mpc8: Unobfuscate sign-extension Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1c430f60454acbf6f288058d971a44d6bb3d48e7 --- libavcodec/mpc8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 03838a9351..631bac2753 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -384,7 +384,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data, for(j = 0; j < SAMPLES_PER_BAND; j += 2){ t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3]; c->Q[ch][off + j + 1] = t >> 4; -c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF); +c->Q[ch][off + j + 0] = sign_extend(t, 4); } break; case 5: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/apngdec: Fix size/overflow checks
ffmpeg | branch: master | Andreas Rheinhardt | Sun Jan 12 17:36:05 2020 +0100| [9c341c6c92a0fc9c5bbecbd12e8bdd904678e4d5] | committer: Andreas Rheinhardt avformat/apngdec: Fix size/overflow checks apng data consists of parts containing a small header (including a four-byte size field) and a data part; the size field does not account for everything and is actually twelve bytes short of the actual size. In order to make sure that the size fits into an int, the size field is checked for being > INT_MAX; yet this does not account for the + 12 and upon conversion to int (which happens when calling append_extradata()), the size parameter can still wrap around. In this case the currently used check would lead to undefined signed integer overflow. Furthermore, append_extradata() appends the new data to the already existing extradata and therefore needs to make sure that the combined size of new and old data as well as padding fits into an int. The check used for this is "if (old_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - new_size)". If new_size is > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE the right side becomes negative if the types are signed (as they are now); yet changing this to "if (new_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - old_size)" is better as this also works for unsigned types (where it is of course presumed that INT_MAX is replaced by the corresponding maximum for the new type). Both of these issues have been fixed. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9c341c6c92a0fc9c5bbecbd12e8bdd904678e4d5 --- libavformat/apngdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c index 23d7e15393..d8d0de190f 100644 --- a/libavformat/apngdec.c +++ b/libavformat/apngdec.c @@ -127,7 +127,7 @@ static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len) int new_size, ret; uint8_t *new_extradata; -if (previous_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - len) +if (len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - previous_size) return AVERROR_INVALIDDATA; new_size = previous_size + len; @@ -208,7 +208,7 @@ static int apng_read_header(AVFormatContext *s) goto fail; len = avio_rb32(pb); -if (len > 0x7fff) { +if (len > INT_MAX - 12) { ret = AVERROR_INVALIDDATA; goto fail; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/apngdec: Check fcTL chunk length when reading header
ffmpeg | branch: master | Andreas Rheinhardt | Sat Oct 31 14:07:27 2020 +0100| [d9363b56a6b134e90fff8098cbd46a642f9cf99d] | committer: Andreas Rheinhardt avformat/apngdec: Check fcTL chunk length when reading header Reading the header terminates when an fcTL chunk is encountered in which case read_header returned success without checking the length of said chunk. Yet when read_packet processes this chunk, it checks for the length to be 26 and errors out otherwise. So do so when reading the header, too. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d9363b56a6b134e90fff8098cbd46a642f9cf99d --- libavformat/apngdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c index d8d0de190f..6b2ce2e251 100644 --- a/libavformat/apngdec.c +++ b/libavformat/apngdec.c @@ -226,7 +226,7 @@ static int apng_read_header(AVFormatContext *s) ctx->num_frames, ctx->num_play); break; case MKTAG('f', 'c', 'T', 'L'): -if (!acTL_found) { +if (!acTL_found || len != 26) { ret = AVERROR_INVALIDDATA; goto fail; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/apngdec: Remove goto fail that does nothing
ffmpeg | branch: master | Andreas Rheinhardt | Wed Dec 11 12:15:05 2019 +0100| [158265b439083f730eb36df27b6979aff2f6f83b] | committer: Andreas Rheinhardt avformat/apngdec: Remove goto fail that does nothing Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=158265b439083f730eb36df27b6979aff2f6f83b --- libavformat/apngdec.c | 32 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c index 6b2ce2e251..bf8343faf3 100644 --- a/libavformat/apngdec.c +++ b/libavformat/apngdec.c @@ -151,17 +151,17 @@ static int apng_read_header(AVFormatContext *s) uint32_t len, tag; AVStream *st; int acTL_found = 0; -int64_t ret = AVERROR_INVALIDDATA; +int64_t ret; /* verify PNGSIG */ if (avio_rb64(pb) != PNGSIG) -return ret; +return AVERROR_INVALIDDATA; /* parse IHDR (must be first chunk) */ len = avio_rb32(pb); tag = avio_rl32(pb); if (len != 13 || tag != MKTAG('I', 'H', 'D', 'R')) -return ret; +return AVERROR_INVALIDDATA; st = avformat_new_stream(s, NULL); if (!st) @@ -193,11 +193,9 @@ static int apng_read_header(AVFormatContext *s) int64_t size = avio_size(pb); int64_t offset = avio_tell(pb); if (size < 0) { -ret = size; -goto fail; +return size; } else if (offset < 0) { -ret = offset; -goto fail; +return offset; } else if ((ret = ffio_ensure_seekback(pb, size - offset)) < 0) { av_log(s, AV_LOG_WARNING, "Could not ensure seekback, will not loop\n"); ctx->num_play = 1; @@ -205,20 +203,18 @@ static int apng_read_header(AVFormatContext *s) } if ((ctx->num_play == 1 || !acTL_found) && ((ret = ffio_ensure_seekback(pb, 4 /* len */ + 4 /* tag */)) < 0)) -goto fail; +return ret; len = avio_rb32(pb); -if (len > INT_MAX - 12) { -ret = AVERROR_INVALIDDATA; -goto fail; -} +if (len > INT_MAX - 12) +return AVERROR_INVALIDDATA; tag = avio_rl32(pb); switch (tag) { case MKTAG('a', 'c', 'T', 'L'): if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 || (ret = append_extradata(st->codecpar, pb, len + 12)) < 0) -goto fail; +return ret; acTL_found = 1; ctx->num_frames = AV_RB32(st->codecpar->extradata + ret + 8); ctx->num_play = AV_RB32(st->codecpar->extradata + ret + 12); @@ -227,21 +223,17 @@ static int apng_read_header(AVFormatContext *s) break; case MKTAG('f', 'c', 'T', 'L'): if (!acTL_found || len != 26) { - ret = AVERROR_INVALIDDATA; - goto fail; +return AVERROR_INVALIDDATA; } if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0) -goto fail; +return ret; return 0; default: if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 || (ret = append_extradata(st->codecpar, pb, len + 12)) < 0) -goto fail; +return ret; } } - -fail: -return ret; } static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, AVPacket *pkt) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avformat/apngdec: Return error for incomplete header
ffmpeg | branch: master | Andreas Rheinhardt | Tue Dec 10 11:47:57 2019 +0100| [2cf1eefae5dba7a7259156f9ff5c62f4e4e2fe0d] | committer: Andreas Rheinhardt avformat/apngdec: Return error for incomplete header If avio_read() could read anything, it returns the number of bytes read, even if it could not read as much as the caller desired. apng_read_header() only checked the return value of its avio_read() calls for being negative and this meant that it was possible for an incomplete header to not be detected. The return value of the last successfull call has been returned instead. This commit changes this. Fixes: OOM Fixes: 26608/clusterfuzz-testcase-minimized-ffmpeg_dem_APNG_fuzzer-4839491644424192 Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2cf1eefae5dba7a7259156f9ff5c62f4e4e2fe0d --- libavformat/apngdec.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c index 0f1d04a365..23d7e15393 100644 --- a/libavformat/apngdec.c +++ b/libavformat/apngdec.c @@ -138,7 +138,7 @@ static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len) par->extradata = new_extradata; par->extradata_size = new_size; -if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0) +if ((ret = ffio_read_size(pb, par->extradata + previous_size, len)) < 0) return ret; return previous_size; @@ -185,10 +185,10 @@ static int apng_read_header(AVFormatContext *s) AV_WL32(st->codecpar->extradata+4, tag); AV_WB32(st->codecpar->extradata+8, st->codecpar->width); AV_WB32(st->codecpar->extradata+12, st->codecpar->height); -if ((ret = avio_read(pb, st->codecpar->extradata+16, 9)) < 0) -goto fail; +if ((ret = ffio_read_size(pb, st->codecpar->extradata + 16, 9)) < 0) +return ret; -while (!avio_feof(pb)) { +while (1) { if (acTL_found && ctx->num_play != 1) { int64_t size = avio_size(pb); int64_t offset = avio_tell(pb); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/af_asoftclip: add asserts in default switch cases
ffmpeg | branch: master | Paul B Mahol | Tue Nov 3 12:28:02 2020 +0100| [112fe0ff194ffe7670fbc0690e6b15ba6279e11a] | committer: Paul B Mahol avfilter/af_asoftclip: add asserts in default switch cases > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=112fe0ff194ffe7670fbc0690e6b15ba6279e11a --- libavfilter/af_asoftclip.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c index b656dcfa45..ce1f7ea96a 100644 --- a/libavfilter/af_asoftclip.c +++ b/libavfilter/af_asoftclip.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/opt.h" #include "avfilter.h" @@ -162,6 +163,8 @@ static void filter_flt(ASoftClipContext *s, dst[n] = erff(src[n]); } break; +default: +av_assert0(0); } } } @@ -229,6 +232,8 @@ static void filter_dbl(ASoftClipContext *s, dst[n] = erf(src[n]); } break; +default: +av_assert0(0); } } } @@ -243,6 +248,7 @@ static int config_input(AVFilterLink *inlink) case AV_SAMPLE_FMT_FLTP: s->filter = filter_flt; break; case AV_SAMPLE_FMT_DBL: case AV_SAMPLE_FMT_DBLP: s->filter = filter_dbl; break; +default: av_assert0(0); } return 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/af_asoftclip: add erf soft clip type
ffmpeg | branch: master | Paul B Mahol | Tue Nov 3 12:05:24 2020 +0100| [ee686236cd1dcceca2ecdfe64e509a7ef977e8f0] | committer: Paul B Mahol avfilter/af_asoftclip: add erf soft clip type > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee686236cd1dcceca2ecdfe64e509a7ef977e8f0 --- doc/filters.texi | 1 + libavfilter/af_asoftclip.c | 12 2 files changed, 13 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index d98c696f60..a186f9dca1 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2323,6 +2323,7 @@ It accepts the following values: @item alg @item quintic @item sin +@item erf @end table @item param diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c index e9e3666ef6..c49ba5a49f 100644 --- a/libavfilter/af_asoftclip.c +++ b/libavfilter/af_asoftclip.c @@ -32,6 +32,7 @@ enum ASoftClipTypes { ASC_ALG, ASC_QUINTIC, ASC_SIN, +ASC_ERF, NB_TYPES, }; @@ -57,6 +58,7 @@ static const AVOption asoftclip_options[] = { { "alg", NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_ALG},0, 0, A, "types" }, { "quintic", NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_QUINTIC},0, 0, A, "types" }, { "sin", NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_SIN},0, 0, A, "types" }, +{ "erf", NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_ERF},0, 0, A, "types" }, { "param", "set softclip parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.01,3, A }, { NULL } }; @@ -148,6 +150,11 @@ static void filter_flt(ASoftClipContext *s, dst[n] = sinf(src[n]); } break; +case ASC_ERF: +for (int n = 0; n < nb_samples; n++) { +dst[n] = erff(src[n]); +} +break; } } } @@ -205,6 +212,11 @@ static void filter_dbl(ASoftClipContext *s, dst[n] = sin(src[n]); } break; +case ASC_ERF: +for (int n = 0; n < nb_samples; n++) { +dst[n] = erf(src[n]); +} +break; } } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfitler/af_asoftclip: add hard type
ffmpeg | branch: master | Paul B Mahol | Tue Nov 3 12:21:48 2020 +0100| [de63b6fb549e98f20194561a077456f03e7dcfe9] | committer: Paul B Mahol avfitler/af_asoftclip: add hard type > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de63b6fb549e98f20194561a077456f03e7dcfe9 --- doc/filters.texi | 1 + libavfilter/af_asoftclip.c | 14 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index a186f9dca1..a6de827ebf 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2316,6 +2316,7 @@ Set type of soft-clipping. It accepts the following values: @table @option +@item hard @item tanh @item atan @item cubic diff --git a/libavfilter/af_asoftclip.c b/libavfilter/af_asoftclip.c index c49ba5a49f..b656dcfa45 100644 --- a/libavfilter/af_asoftclip.c +++ b/libavfilter/af_asoftclip.c @@ -25,6 +25,7 @@ #include "formats.h" enum ASoftClipTypes { +ASC_HARD = -1, ASC_TANH, ASC_ATAN, ASC_CUBIC, @@ -50,7 +51,8 @@ typedef struct ASoftClipContext { #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM static const AVOption asoftclip_options[] = { -{ "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT,{.i64=0}, 0, NB_TYPES-1, A, "types" }, +{ "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT,{.i64=0}, -1, NB_TYPES-1, A, "types" }, +{ "hard",NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_HARD}, 0, 0, A, "types" }, { "tanh",NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" }, { "atan",NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" }, { "cubic", NULL,0, AV_OPT_TYPE_CONST, {.i64=ASC_CUBIC}, 0, 0, A, "types" }, @@ -109,6 +111,11 @@ static void filter_flt(ASoftClipContext *s, float *dst = dptr[c]; switch (s->type) { +case ASC_HARD: +for (int n = 0; n < nb_samples; n++) { +dst[n] = av_clipf(src[n], -1.f, 1.f); +} +break; case ASC_TANH: for (int n = 0; n < nb_samples; n++) { dst[n] = tanhf(src[n] * param); @@ -171,6 +178,11 @@ static void filter_dbl(ASoftClipContext *s, double *dst = dptr[c]; switch (s->type) { +case ASC_HARD: +for (int n = 0; n < nb_samples; n++) { +dst[n] = av_clipd(src[n], -1., 1.); +} +break; case ASC_TANH: for (int n = 0; n < nb_samples; n++) { dst[n] = tanh(src[n] * param); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] doc: mark "ADPCM IMA High Voltage Software ALP" as encodable
ffmpeg | branch: master | Zane van Iperen | Thu Oct 29 20:57:18 2020 +1000| [67d4ab50ec23d59f9ad6af1c34ea5727f3fcefe8] | committer: Zane van Iperen doc: mark "ADPCM IMA High Voltage Software ALP" as encodable Signed-off-by: Zane van Iperen > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=67d4ab50ec23d59f9ad6af1c34ea5727f3fcefe8 --- doc/general_contents.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/general_contents.texi b/doc/general_contents.texi index f441a75ee9..ab9a6a2a18 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -1112,7 +1112,7 @@ following image formats are supported: @item ADPCM IMA Electronic Arts EACS @tab @tab X @item ADPCM IMA Electronic Arts SEAD @tab @tab X @item ADPCM IMA Funcom @tab @tab X -@item ADPCM IMA High Voltage Software ALP @tab @tab X +@item ADPCM IMA High Voltage Software ALP @tab X @tab X @item ADPCM IMA QuickTime@tab X @tab X @item ADPCM IMA Simon & Schuster Interactive @tab X @tab X @item ADPCM IMA Ubisoft APM @tab X @tab X ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/utils: add adpcm_ima_alp to av_get_exact_bits_per_sample()
ffmpeg | branch: master | Zane van Iperen | Thu Oct 29 20:55:41 2020 +1000| [2433b62f7980b8f98d129f5b998103ad736a2b59] | committer: Zane van Iperen avcodec/utils: add adpcm_ima_alp to av_get_exact_bits_per_sample() Signed-off-by: Zane van Iperen > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2433b62f7980b8f98d129f5b998103ad736a2b59 --- libavcodec/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 110496cc44..db51512e15 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1490,6 +1490,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id) case AV_CODEC_ID_8SVX_FIB: case AV_CODEC_ID_ADPCM_ARGO: case AV_CODEC_ID_ADPCM_CT: +case AV_CODEC_ID_ADPCM_IMA_ALP: case AV_CODEC_ID_ADPCM_IMA_APC: case AV_CODEC_ID_ADPCM_IMA_APM: case AV_CODEC_ID_ADPCM_IMA_EA_SEAD: ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".