--- libavcodec/Makefile | 4 +-- libavcodec/dwt.c | 53 +-------------------------------- libavcodec/dwt.h | 12 -------- libavcodec/snow.c | 3 +- libavcodec/snow_dwt.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ libavcodec/snow_dwt.h | 36 +++++++++++++++++++++++ libavcodec/x86/Makefile | 2 +- libavcodec/x86/snowdsp.c | 5 ++-- 8 files changed, 118 insertions(+), 70 deletions(-) create mode 100644 libavcodec/snow_dwt.c create mode 100644 libavcodec/snow_dwt.h
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 45c6d66..7e06945 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -339,8 +339,8 @@ OBJS-$(CONFIG_SIPR_DECODER) += sipr.o acelp_pitch_delay.o \ OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o OBJS-$(CONFIG_SMC_DECODER) += smc.o -OBJS-$(CONFIG_SNOW_DECODER) += snowdec.o snow.o -OBJS-$(CONFIG_SNOW_ENCODER) += snowenc.o snow.o \ +OBJS-$(CONFIG_SNOW_DECODER) += snowdec.o snow.o snow_dwt.o +OBJS-$(CONFIG_SNOW_ENCODER) += snowenc.o snow.o snow_dwt.o \ h263.o ituh263enc.o OBJS-$(CONFIG_SOL_DPCM_DECODER) += dpcm.o OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o diff --git a/libavcodec/dwt.c b/libavcodec/dwt.c index 93cf2c6..0796a3e 100644 --- a/libavcodec/dwt.c +++ b/libavcodec/dwt.c @@ -22,6 +22,7 @@ #include "libavutil/common.h" #include "dsputil.h" #include "dwt.h" +#include "snow_dwt.h" int ff_slice_buffer_init(slice_buffer *buf, int line_count, int max_allocated_lines, int line_width, @@ -465,34 +466,6 @@ static void spatial_compose53i_dy(DWTCompose *cs, IDWTELEM *buffer, cs->y += 2; } -void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width) -{ - const int w2 = (width + 1) >> 1; - int x; - - temp[0] = b[0] - ((3 * b[w2] + 2) >> 2); - for (x = 1; x < (width >> 1); x++) { - temp[2 * x] = b[x] - ((3 * (b[x + w2 - 1] + b[x + w2]) + 4) >> 3); - temp[2 * x - 1] = b[x + w2 - 1] - temp[2 * x - 2] - temp[2 * x]; - } - if (width & 1) { - temp[2 * x] = b[x] - ((3 * b[x + w2 - 1] + 2) >> 2); - temp[2 * x - 1] = b[x + w2 - 1] - temp[2 * x - 2] - temp[2 * x]; - } else - temp[2 * x - 1] = b[x + w2 - 1] - 2 * temp[2 * x - 2]; - - b[0] = temp[0] + ((2 * temp[0] + temp[1] + 4) >> 3); - for (x = 2; x < width - 1; x += 2) { - b[x] = temp[x] + ((4 * temp[x] + temp[x - 1] + temp[x + 1] + 8) >> 4); - b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1); - } - if (width & 1) { - b[x] = temp[x] + ((2 * temp[x] + temp[x - 1] + 4) >> 3); - b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1); - } else - b[x - 1] = temp[x - 1] + 3 * b[x - 2]; -} - static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width) { @@ -529,20 +502,6 @@ static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, b1[i] -= (W_DM * (b0[i] + b2[i]) + W_DO) >> W_DS; } -void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, - IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, - int width) -{ - int i; - - for (i = 0; i < width; i++) { - b4[i] -= (W_DM * (b3[i] + b5[i]) + W_DO) >> W_DS; - b3[i] -= (W_CM * (b2[i] + b4[i]) + W_CO) >> W_CS; - b2[i] += (W_BM * (b1[i] + b3[i]) + 4 * b2[i] + W_BO) >> W_BS; - b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS; - } -} - static void spatial_compose97i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line) { @@ -849,13 +808,3 @@ void ff_dsputil_init_dwt(DSPContext *c) c->w97[0] = w97_16_c; c->w97[1] = w97_8_c; } - -void ff_dwt_init(DWTContext *c) -{ - c->vertical_compose97i = ff_snow_vertical_compose97i; - c->horizontal_compose97i = ff_snow_horizontal_compose97i; - c->inner_add_yblock = ff_snow_inner_add_yblock; - - if (HAVE_MMX) - ff_dwt_init_x86(c); -} diff --git a/libavcodec/dwt.h b/libavcodec/dwt.h index f2d7864..6cf73ba 100644 --- a/libavcodec/dwt.h +++ b/libavcodec/dwt.h @@ -93,15 +93,6 @@ void ff_slice_buffer_flush(slice_buffer *buf); void ff_slice_buffer_destroy(slice_buffer *buf); IDWTELEM *ff_slice_buffer_load_line(slice_buffer *buf, int line); -void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, - IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, - int width); -void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width); -void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, - uint8_t **block, int b_w, int b_h, int src_x, - int src_y, int src_stride, slice_buffer *sb, - int add, uint8_t *dst8); - int ff_w53_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h); int ff_w97_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h); @@ -118,7 +109,4 @@ void ff_spatial_idwt_buffered_slice(DWTContext *dsp, DWTCompose *cs, void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride, int type, int decomposition_count); -void ff_dwt_init(DWTContext *c); -void ff_dwt_init_x86(DWTContext *c); - #endif /* AVCODEC_DWT_H */ diff --git a/libavcodec/snow.c b/libavcodec/snow.c index d69f452..f437926 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -25,6 +25,7 @@ #include "dsputil.h" #include "dwt.h" #include "snow.h" +#include "snow_dwt.h" #include "snowdata.h" #include "rangecoder.h" @@ -401,7 +402,7 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe ff_dsputil_init(&s->dsp, avctx); - ff_dwt_init(&s->dwt); + ff_snow_dwt_init(&s->dwt); #define mcf(dx,dy)\ s->dsp.put_qpel_pixels_tab [0][dy+dx/4]=\ diff --git a/libavcodec/snow_dwt.c b/libavcodec/snow_dwt.c new file mode 100644 index 0000000..fe1c629 --- /dev/null +++ b/libavcodec/snow_dwt.c @@ -0,0 +1,73 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "dwt.h" +#include "snow_dwt.h" + +void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width) +{ + const int w2 = (width + 1) >> 1; + int x; + + temp[0] = b[0] - ((3 * b[w2] + 2) >> 2); + for (x = 1; x < (width >> 1); x++) { + temp[2 * x] = b[x] - ((3 * (b[x + w2 - 1] + b[x + w2]) + 4) >> 3); + temp[2 * x - 1] = b[x + w2 - 1] - temp[2 * x - 2] - temp[2 * x]; + } + if (width & 1) { + temp[2 * x] = b[x] - ((3 * b[x + w2 - 1] + 2) >> 2); + temp[2 * x - 1] = b[x + w2 - 1] - temp[2 * x - 2] - temp[2 * x]; + } else + temp[2 * x - 1] = b[x + w2 - 1] - 2 * temp[2 * x - 2]; + + b[0] = temp[0] + ((2 * temp[0] + temp[1] + 4) >> 3); + for (x = 2; x < width - 1; x += 2) { + b[x] = temp[x] + ((4 * temp[x] + temp[x - 1] + temp[x + 1] + 8) >> 4); + b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1); + } + if (width & 1) { + b[x] = temp[x] + ((2 * temp[x] + temp[x - 1] + 4) >> 3); + b[x - 1] = temp[x - 1] + ((3 * (b[x - 2] + b[x])) >> 1); + } else + b[x - 1] = temp[x - 1] + 3 * b[x - 2]; +} + +void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, + IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, + int width) +{ + int i; + + for (i = 0; i < width; i++) { + b4[i] -= (W_DM * (b3[i] + b5[i]) + W_DO) >> W_DS; + b3[i] -= (W_CM * (b2[i] + b4[i]) + W_CO) >> W_CS; + b2[i] += (W_BM * (b1[i] + b3[i]) + 4 * b2[i] + W_BO) >> W_BS; + b1[i] += (W_AM * (b0[i] + b2[i]) + W_AO) >> W_AS; + } +} + +void ff_snow_dwt_init(DWTContext *c) +{ + c->vertical_compose97i = ff_snow_vertical_compose97i; + c->horizontal_compose97i = ff_snow_horizontal_compose97i; + c->inner_add_yblock = ff_snow_inner_add_yblock; + + if (HAVE_MMX) + ff_snow_dwt_init_x86(c); +} diff --git a/libavcodec/snow_dwt.h b/libavcodec/snow_dwt.h new file mode 100644 index 0000000..32b8143 --- /dev/null +++ b/libavcodec/snow_dwt.h @@ -0,0 +1,36 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_SNOW_DWT_H +#define AVCODEC_SNOW_DWT_H + +#include "dwt.h" + +void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, + IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, + int width); +void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width); +void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, + uint8_t **block, int b_w, int b_h, int src_x, + int src_y, int src_stride, slice_buffer *sb, + int add, uint8_t *dst8); + +void ff_snow_dwt_init(DWTContext *c); +void ff_snow_dwt_init_x86(DWTContext *c); + +#endif /* AVCODEC_SNOW_DWT_H */ diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index be4fd54..4bf0b70 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -16,7 +16,6 @@ MMX-OBJS += x86/dsputil_mmx.o \ MMX-OBJS-$(CONFIG_AAC_DECODER) += x86/sbrdsp_init.o MMX-OBJS-$(CONFIG_AC3DSP) += x86/ac3dsp_init.o MMX-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp.o -MMX-OBJS-$(CONFIG_DWT) += x86/snowdsp.o MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o \ x86/motion_est.o MMX-OBJS-$(CONFIG_FFT) += x86/fft_init.o @@ -29,6 +28,7 @@ MMX-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o MMX-OBJS-$(CONFIG_RV30_DECODER) += x86/rv34dsp_init.o MMX-OBJS-$(CONFIG_RV40_DECODER) += x86/rv34dsp_init.o \ x86/rv40dsp_init.o +MMX-OBJS-$(CONFIG_SNOW_DECODER) += x86/snowdsp.o MMX-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_mmx.o MMX-OBJS-$(CONFIG_VP5_DECODER) += x86/vp56dsp_init.o MMX-OBJS-$(CONFIG_VP6_DECODER) += x86/vp56dsp_init.o diff --git a/libavcodec/x86/snowdsp.c b/libavcodec/x86/snowdsp.c index fb190d8..fcab6cc 100644 --- a/libavcodec/x86/snowdsp.c +++ b/libavcodec/x86/snowdsp.c @@ -22,8 +22,9 @@ #include "libavutil/cpu.h" #include "libavutil/x86/asm.h" #include "libavcodec/avcodec.h" -#include "libavcodec/snow.h" #include "libavcodec/dwt.h" +#include "libavcodec/snow.h" +#include "libavcodec/snow_dwt.h" #include "dsputil_mmx.h" #if HAVE_INLINE_ASM @@ -875,7 +876,7 @@ static void ff_snow_inner_add_yblock_mmx(const uint8_t *obmc, const int obmc_str #endif /* HAVE_INLINE_ASM */ -void ff_dwt_init_x86(DWTContext *c) +void ff_snow_dwt_init_x86(DWTContext *c) { #if HAVE_INLINE_ASM int mm_flags = av_get_cpu_flags(); -- 1.7.10.4 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel