[FFmpeg-devel] [PATCH][WIP][RFC] avfilter: add opencl v360 filter
Signed-off-by: Paul B Mahol --- For now just equirectangular to flat conversion, but could be with some effort extended with all formats supported by v360 filter, minus non-padded stuff, but that is not present in normal usecases. --- libavfilter/Makefile | 2 + libavfilter/allfilters.c | 1 + libavfilter/opencl/v360.cl | 158 +++ libavfilter/opencl_source.h | 1 + libavfilter/vf_v360_opencl.c | 505 +++ 5 files changed, 667 insertions(+) create mode 100644 libavfilter/opencl/v360.cl create mode 100644 libavfilter/vf_v360_opencl.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 358f121cb4..eb5365a739 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -485,6 +485,8 @@ OBJS-$(CONFIG_UNSHARP_OPENCL_FILTER) += vf_unsharp_opencl.o opencl.o \ OBJS-$(CONFIG_UNTILE_FILTER) += vf_untile.o OBJS-$(CONFIG_USPP_FILTER) += vf_uspp.o qp_table.o OBJS-$(CONFIG_V360_FILTER) += vf_v360.o +OBJS-$(CONFIG_V360_OPENCL_FILTER)+= vf_v360_opencl.o opencl.o \ +opencl/v360.o OBJS-$(CONFIG_VAGUEDENOISER_FILTER) += vf_vaguedenoiser.o OBJS-$(CONFIG_VARBLUR_FILTER)+= vf_varblur.o framesync.o OBJS-$(CONFIG_VECTORSCOPE_FILTER)+= vf_vectorscope.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 409ab5d3c4..04f1925c14 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -462,6 +462,7 @@ extern const AVFilter ff_vf_unsharp_opencl; extern const AVFilter ff_vf_untile; extern const AVFilter ff_vf_uspp; extern const AVFilter ff_vf_v360; +extern const AVFilter ff_vf_v360_opencl; extern const AVFilter ff_vf_vaguedenoiser; extern const AVFilter ff_vf_varblur; extern const AVFilter ff_vf_vectorscope; diff --git a/libavfilter/opencl/v360.cl b/libavfilter/opencl/v360.cl new file mode 100644 index 00..003c188249 --- /dev/null +++ b/libavfilter/opencl/v360.cl @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2021 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_LINEAR); + +static float scale(float x, float s) +{ +return (0.5 * x + 0.5) * (s - 1.); +} + +static float rescale(int x, float s) +{ +return (2. * x + 1.) / s - 1.; +} + +__kernel void equirect_to_xyz(__write_only image2d_t dst) +{ +int2 p = (int2)(get_global_id(0), get_global_id(1)); +int2 size = (int2)(get_global_size(0), get_global_size(1)); +float2 f; + +f.x = rescale(p.x, size.x); +f.y = rescale(p.y, size.y); + +float sin_phi = sin(f.x); +float cos_phi = cos(f.x); +float sin_theta = sin(f.y); +float cos_theta = cos(f.y); + +float4 vec; + +vec.x = cos_theta * sin_phi; +vec.y = sin_theta; +vec.z = cos_theta * cos_phi; + +write_imagef(dst, p, vec); +} + +__kernel void flat_to_xyz(global float3 *dst, + float2 flat_range) +{ +int2 p = (int2)(get_global_id(0), get_global_id(1)); +int2 size = (int2)(get_global_size(0), get_global_size(1)); +float2 f; + +f.x = flat_range.x * rescale(p.x, size.x); +f.y = flat_range.y * rescale(p.y, size.y); + +float3 vec; + +vec.x = f.x; +vec.y = f.y; +vec.z = 1.0; + +vec = normalize(vec); + +dst[p.y * size.x + p.x] = vec; +} + +__kernel void xyz_to_equirect(global float2 *dst, + float2 iflat_range, + global float3 *m, + __read_only image2d_t src) +{ +int2 p = (int2)(get_global_id(0), get_global_id(1)); +int2 size = (int2)(get_global_size(0), get_global_size(1)); + +float3 vec = m[p.x + size.x * p.y]; + +const float phi = atan2(vec.x, vec.z) / iflat_range.x; +const float theta = asin(vec.y) / iflat_range.y; + +float2 uv; + +uv.x = scale(phi, size.x); +uv.y = scale(theta, size.y); + +dst[p.x + p.y * size.x] = uv; +} + +__kernel void remap(__write_only image2d_t dst, +__read_only image2d_t src, +global float2 *remap) +{ +int2 p = (int2)(get_global_id(0), get_global_id(1)
Re: [FFmpeg-devel] [PATCH 1/8] avfilter/af_replaygain: use fabsf() instead of fabs()
On 10/14/2021 10:08 AM, lance.lmw...@gmail.com wrote: From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/af_replaygain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c index 4bf2763..da5c196 100644 --- a/libavfilter/af_replaygain.c +++ b/libavfilter/af_replaygain.c @@ -428,7 +428,7 @@ static void butter_filter_stereo_samples(ReplayGainContext *s, // (slowing us down). for (j = -4; j < 0; ++j) -if (fabs(hist_a[i + j]) > 1e-10 || fabs(hist_b[i + j]) > 1e-10) +if (fabsf(hist_a[i + j]) > 1e-10 || fabsf(hist_b[i + j]) > 1e-10) Shouldn't the constants also be made into floats? Otherwise the compiler will probably do a conversion to double. break; if (!j) { @@ -477,7 +477,7 @@ static void yule_filter_stereo_samples(ReplayGainContext *s, const float *src, // (slowing us down). for (j = -20; j < 0; ++j) -if (fabs(hist_a[i + j]) > 1e-10 || fabs(hist_b[i + j]) > 1e-10) +if (fabsf(hist_a[i + j]) > 1e-10 || fabsf(hist_b[i + j]) > 1e-10) break; if (!j) { ___ 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] [PATCH 2/2] Revert "arm: hevc_qpel: Fix the assembly to work with non-multiple of 8 widths"
This reverts commit 2589060b92eeeb944c6e2b50e38412c0c5fabcf4. Signed-off-by: J. Dekker --- libavcodec/arm/hevcdsp_qpel_neon.S | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/arm/hevcdsp_qpel_neon.S b/libavcodec/arm/hevcdsp_qpel_neon.S index f71bec05ed..caa6efa766 100644 --- a/libavcodec/arm/hevcdsp_qpel_neon.S +++ b/libavcodec/arm/hevcdsp_qpel_neon.S @@ -237,7 +237,7 @@ vld1.8{d23}, [r2], r3 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #16 mov r0, r6 @@ -280,7 +280,7 @@ vld1.8{d23}, [r2], r3 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #8 mov r0, r6 @@ -310,7 +310,7 @@ vld1.8{d23}, [r2], r3 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #8 mov r0, r6 @@ -377,7 +377,7 @@ endfunc vst1.16 {q7}, [r0], r1 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #16 mov r0, r6 @@ -417,7 +417,7 @@ endfunc vst1.8d0, [r0], r1 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #8 mov r0, r6 @@ -446,7 +446,7 @@ endfunc vst1.8 d0, [r0], r1 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #8 add r10, #16 @@ -533,7 +533,7 @@ endfunc \filterh q7 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #16 mov r0, r6 @@ -594,7 +594,7 @@ endfunc \filterh q7 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #8 mov r0, r6 @@ -641,7 +641,7 @@ endfunc \filterh q7 bne 8b subs r5, #8 -ble 99f +beq 99f mov r4, r12 add r6, #8 mov r0, r6 -- 2.30.1 (Apple Git-130) ___ 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] [PATCH 1/2] lavc/arm: dont assign hevc_qpel non-multiple of 8 width stubs
Signed-off-by: J. Dekker --- libavcodec/arm/hevcdsp_init_neon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/arm/hevcdsp_init_neon.c b/libavcodec/arm/hevcdsp_init_neon.c index 201a088dac..112edb5edd 100644 --- a/libavcodec/arm/hevcdsp_init_neon.c +++ b/libavcodec/arm/hevcdsp_init_neon.c @@ -270,7 +270,8 @@ av_cold void ff_hevc_dsp_init_neon(HEVCDSPContext *c, const int bit_depth) put_hevc_qpel_uw_neon[3][1] = ff_hevc_put_qpel_uw_h1v3_neon_8; put_hevc_qpel_uw_neon[3][2] = ff_hevc_put_qpel_uw_h2v3_neon_8; put_hevc_qpel_uw_neon[3][3] = ff_hevc_put_qpel_uw_h3v3_neon_8; -for (x = 0; x < 10; x++) { +for (x = 3; x < 10; x++) { +if (x == 4) continue; c->put_hevc_qpel[x][1][0] = ff_hevc_put_qpel_neon_wrapper; c->put_hevc_qpel[x][0][1] = ff_hevc_put_qpel_neon_wrapper; c->put_hevc_qpel[x][1][1] = ff_hevc_put_qpel_neon_wrapper; -- 2.30.1 (Apple Git-130) ___ 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] [PATCH][WIP] avfilter: add opencl v360 filter
Signed-off-by: Paul B Mahol --- libavfilter/Makefile | 2 + libavfilter/allfilters.c | 1 + libavfilter/opencl/v360.cl | 419 libavfilter/opencl_source.h | 1 + libavfilter/vf_v360_opencl.c | 719 +++ 5 files changed, 1142 insertions(+) create mode 100644 libavfilter/opencl/v360.cl create mode 100644 libavfilter/vf_v360_opencl.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 358f121cb4..eb5365a739 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -485,6 +485,8 @@ OBJS-$(CONFIG_UNSHARP_OPENCL_FILTER) += vf_unsharp_opencl.o opencl.o \ OBJS-$(CONFIG_UNTILE_FILTER) += vf_untile.o OBJS-$(CONFIG_USPP_FILTER) += vf_uspp.o qp_table.o OBJS-$(CONFIG_V360_FILTER) += vf_v360.o +OBJS-$(CONFIG_V360_OPENCL_FILTER)+= vf_v360_opencl.o opencl.o \ +opencl/v360.o OBJS-$(CONFIG_VAGUEDENOISER_FILTER) += vf_vaguedenoiser.o OBJS-$(CONFIG_VARBLUR_FILTER)+= vf_varblur.o framesync.o OBJS-$(CONFIG_VECTORSCOPE_FILTER)+= vf_vectorscope.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 409ab5d3c4..04f1925c14 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -462,6 +462,7 @@ extern const AVFilter ff_vf_unsharp_opencl; extern const AVFilter ff_vf_untile; extern const AVFilter ff_vf_uspp; extern const AVFilter ff_vf_v360; +extern const AVFilter ff_vf_v360_opencl; extern const AVFilter ff_vf_vaguedenoiser; extern const AVFilter ff_vf_varblur; extern const AVFilter ff_vf_vectorscope; diff --git a/libavfilter/opencl/v360.cl b/libavfilter/opencl/v360.cl new file mode 100644 index 00..4acb5a025a --- /dev/null +++ b/libavfilter/opencl/v360.cl @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2021 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_LINEAR); + +static float scale(float x, float s) +{ +return (0.5 * x + 0.5) * (s - 1.); +} + +static float rescale(int x, float s) +{ +return (2. * x + 1.) / s - 1.; +} + +__kernel void equirect_to_xyz(global float3 *dst, + float2 flat_range) +{ +int2 p = (int2)(get_global_id(0), get_global_id(1)); +int2 size = (int2)(get_global_size(0), get_global_size(1)); +float2 f; + +f.x = flat_range.x * rescale(p.x, size.x); +f.y = flat_range.y * rescale(p.y, size.y); + +float sin_phi = sin(f.x); +float cos_phi = cos(f.x); +float sin_theta = sin(f.y); +float cos_theta = cos(f.y); + +float3 vec; + +vec.x = cos_theta * sin_phi; +vec.y = sin_theta; +vec.z = cos_theta * cos_phi; + +dst[p.y * size.x + p.x] = vec; +} + +__kernel void flat_to_xyz(global float3 *dst, + float2 flat_range) +{ +int2 p = (int2)(get_global_id(0), get_global_id(1)); +int2 size = (int2)(get_global_size(0), get_global_size(1)); +float2 f; + +f.x = flat_range.x * rescale(p.x, size.x); +f.y = flat_range.y * rescale(p.y, size.y); + +float3 vec; + +vec.x = f.x; +vec.y = f.y; +vec.z = 1.0; + +vec = normalize(vec); + +dst[p.y * size.x + p.x] = vec; +} + +__kernel void fisheye_to_xyz(global float3 *dst, + float2 flat_range) +{ +int2 p = (int2)(get_global_id(0), get_global_id(1)); +int2 size = (int2)(get_global_size(0), get_global_size(1)); +float2 uv; + +uv.x = flat_range.x * rescale(p.x, size.x); +uv.y = flat_range.y * rescale(p.y, size.y); + +float phi = atan2(uv.y, uv.x); +float theta = M_PI_2 * (1.f - hypot(uv.x, uv.y)); + +float sin_phi = sin(phi); +float cos_phi = cos(phi); +float sin_theta = sin(theta); +float cos_theta = cos(theta); + +float3 vec; + +vec.x = cos_theta * cos_phi; +vec.y = cos_theta * sin_phi; +vec.z = sin_theta; + +vec = normalize(vec); + +dst[p.y * size.x + p.x] = vec; +} + +__kernel void xyz_to_flat(global float2 *dst, + float2 iflat_range, + global float3 *m, + __read_only imag
[FFmpeg-devel] [PATCH 1/1] swscale/swscale: check SWS_PRINT_INFO flag for printing alignment warnings
This makes output consistent with a similar warning just few lines above where this flag is checked in the same way. Signed-off-by: softworkz --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 75cde31f4f..feef3482d2 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -329,7 +329,7 @@ static int swscale(SwsContext *c, const uint8_t *src[], ) { SwsContext *const ctx = c->parent ? c->parent : c; int cpu_flags = av_get_cpu_flags(); -if (HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) && +if (flags & SWS_PRINT_INFO && HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) && !atomic_exchange_explicit(&ctx->stride_unaligned_warned,1, memory_order_relaxed)) { av_log(c, AV_LOG_WARNING, "Warning: data is not aligned! This can lead to a speed loss\n"); } -- 2.30.2.windows.1 ___ 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 v5 1/9] cbs_av1: fix incorrect data type
On 10/14/2021 11:04 PM, Wang, Fei W wrote: On Tue, 2021-10-12 at 16:23 +0800, Fei Wang wrote: Since order_hint_bits_minus_1 range is 0~7, cur_frame_hint can be most 128. And similar return value for cbs_av1_get_relative_dist. So if plus them and use int8_t for the result may lose its precision. Signed-off-by: Fei Wang --- update: 1. move additional film grain frame from av1dec.c to vaapi_av1.c 2. patch 3~5 can fix clip: https://drive.google.com/file/d/1Qdx_18_BFcFf_5_XXSZOVohLpaAb-yIw/view?usp=sharing libavcodec/cbs_av1_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 6fe6e9a4f3..d98d3d42de 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -355,7 +355,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw, AV1_REF_FRAME_ALTREF2, AV1_REF_FRAME_ALTREF }; int8_t ref_frame_idx[AV1_REFS_PER_FRAME], used_frame[AV1_NUM_REF_FRAMES]; -int8_t shifted_order_hints[AV1_NUM_REF_FRAMES]; +int16_t shifted_order_hints[AV1_NUM_REF_FRAMES]; int cur_frame_hint, latest_order_hint, earliest_order_hint, ref; int i, j; Hi James, Could you help to review this version? This fixed your comments in V4. And we tested the 3th patch with DXVA, which can also fix the clip I shared. Fei Thanks Set applied. ___ 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".