# HG changeset patch # User mru # Date 1280869140 0 # Node ID 1241c824de4606f451ee1922046ed07d8428bce8 # Parent e25a985a550c64f36e1b9735aedf3f848a0e6394 Move cavs dsp functions to their own struct diff -r e25a985a550c -r 1241c824de46 cavs.c --- a/cavs.c Tue Aug 03 11:35:41 2010 +0000 +++ b/cavs.c Tue Aug 03 20:59:00 2010 +0000 @@ -113,22 +113,22 @@ if(h->flags & A_AVAIL) { qp_avg = (h->qp + h->left_qp + 1) >> 1; SET_PARAMS; - h->s.dsp.cavs_filter_lv(h->cy,h->l_stride,alpha,beta,tc,bs[0],bs[1]); - h->s.dsp.cavs_filter_cv(h->cu,h->c_stride,alpha,beta,tc,bs[0],bs[1]); - h->s.dsp.cavs_filter_cv(h->cv,h->c_stride,alpha,beta,tc,bs[0],bs[1]); + h->cdsp.cavs_filter_lv(h->cy,h->l_stride,alpha,beta,tc,bs[0],bs[1]); + h->cdsp.cavs_filter_cv(h->cu,h->c_stride,alpha,beta,tc,bs[0],bs[1]); + h->cdsp.cavs_filter_cv(h->cv,h->c_stride,alpha,beta,tc,bs[0],bs[1]); } qp_avg = h->qp; SET_PARAMS; - h->s.dsp.cavs_filter_lv(h->cy + 8,h->l_stride,alpha,beta,tc,bs[2],bs[3]); - h->s.dsp.cavs_filter_lh(h->cy + 8*h->l_stride,h->l_stride,alpha,beta,tc, + h->cdsp.cavs_filter_lv(h->cy + 8,h->l_stride,alpha,beta,tc,bs[2],bs[3]); + h->cdsp.cavs_filter_lh(h->cy + 8*h->l_stride,h->l_stride,alpha,beta,tc, bs[6],bs[7]); if(h->flags & B_AVAIL) { qp_avg = (h->qp + h->top_qp[h->mbx] + 1) >> 1; SET_PARAMS; - h->s.dsp.cavs_filter_lh(h->cy,h->l_stride,alpha,beta,tc,bs[4],bs[5]); - h->s.dsp.cavs_filter_ch(h->cu,h->c_stride,alpha,beta,tc,bs[4],bs[5]); - h->s.dsp.cavs_filter_ch(h->cv,h->c_stride,alpha,beta,tc,bs[4],bs[5]); + h->cdsp.cavs_filter_lh(h->cy,h->l_stride,alpha,beta,tc,bs[4],bs[5]); + h->cdsp.cavs_filter_ch(h->cu,h->c_stride,alpha,beta,tc,bs[4],bs[5]); + h->cdsp.cavs_filter_ch(h->cv,h->c_stride,alpha,beta,tc,bs[4],bs[5]); } } } @@ -414,30 +414,30 @@ void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type) { if(ff_cavs_partition_flags[mb_type] == 0){ // 16x16 mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0, - h->s.dsp.put_cavs_qpel_pixels_tab[0], + h->cdsp.put_cavs_qpel_pixels_tab[0], h->s.dsp.put_h264_chroma_pixels_tab[0], - h->s.dsp.avg_cavs_qpel_pixels_tab[0], + h->cdsp.avg_cavs_qpel_pixels_tab[0], h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]); }else{ mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0, - h->s.dsp.put_cavs_qpel_pixels_tab[1], + h->cdsp.put_cavs_qpel_pixels_tab[1], h->s.dsp.put_h264_chroma_pixels_tab[1], - h->s.dsp.avg_cavs_qpel_pixels_tab[1], + h->cdsp.avg_cavs_qpel_pixels_tab[1], h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X0]); mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 0, - h->s.dsp.put_cavs_qpel_pixels_tab[1], + h->cdsp.put_cavs_qpel_pixels_tab[1], h->s.dsp.put_h264_chroma_pixels_tab[1], - h->s.dsp.avg_cavs_qpel_pixels_tab[1], + h->cdsp.avg_cavs_qpel_pixels_tab[1], h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X1]); mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 4, - h->s.dsp.put_cavs_qpel_pixels_tab[1], + h->cdsp.put_cavs_qpel_pixels_tab[1], h->s.dsp.put_h264_chroma_pixels_tab[1], - h->s.dsp.avg_cavs_qpel_pixels_tab[1], + h->cdsp.avg_cavs_qpel_pixels_tab[1], h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X2]); mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 4, - h->s.dsp.put_cavs_qpel_pixels_tab[1], + h->cdsp.put_cavs_qpel_pixels_tab[1], h->s.dsp.put_h264_chroma_pixels_tab[1], - h->s.dsp.avg_cavs_qpel_pixels_tab[1], + h->cdsp.avg_cavs_qpel_pixels_tab[1], h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]); } } @@ -672,6 +672,7 @@ MpegEncContext * const s = &h->s; MPV_decode_defaults(s); + ff_cavsdsp_init(&h->cdsp, avctx); s->avctx = avctx; avctx->pix_fmt= PIX_FMT_YUV420P; diff -r e25a985a550c -r 1241c824de46 cavs.h --- a/cavs.h Tue Aug 03 11:35:41 2010 +0000 +++ b/cavs.h Tue Aug 03 20:59:00 2010 +0000 @@ -24,6 +24,7 @@ #include "dsputil.h" #include "mpegvideo.h" +#include "cavsdsp.h" #define SLICE_MAX_START_CODE 0x000001af #define EXT_START_CODE 0x000001b5 @@ -153,6 +154,7 @@ typedef struct { MpegEncContext s; + CAVSDSPContext cdsp; Picture picture; ///< currently decoded frame Picture DPB[2]; ///< reference frames int dist[2]; ///< temporal distances from current frame to ref frames diff -r e25a985a550c -r 1241c824de46 cavsdec.c --- a/cavsdec.c Tue Aug 03 11:35:41 2010 +0000 +++ b/cavsdec.c Tue Aug 03 20:59:00 2010 +0000 @@ -143,7 +143,7 @@ if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp], ff_cavs_dequant_shift[qp], i)) return -1; - h->s.dsp.cavs_idct8_add(dst,block,stride); + h->cdsp.cavs_idct8_add(dst,block,stride); h->s.dsp.clear_block(block); return 0; } diff -r e25a985a550c -r 1241c824de46 cavsdsp.c --- a/cavsdsp.c Tue Aug 03 11:35:41 2010 +0000 +++ b/cavsdsp.c Tue Aug 03 20:59:00 2010 +0000 @@ -24,6 +24,7 @@ #include #include "dsputil.h" +#include "cavsdsp.h" /***************************************************************************** * @@ -510,7 +511,7 @@ CAVS_MC(avg_, 8) CAVS_MC(avg_, 16) -av_cold void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) { +av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) { #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \ c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \ @@ -537,4 +538,6 @@ c->cavs_filter_cv = cavs_filter_cv_c; c->cavs_filter_ch = cavs_filter_ch_c; c->cavs_idct8_add = cavs_idct8_add_c; + + if (HAVE_MMX) ff_cavsdsp_init_mmx(c, avctx); } diff -r e25a985a550c -r 1241c824de46 cavsdsp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cavsdsp.h Tue Aug 03 20:59:00 2010 +0000 @@ -0,0 +1,41 @@ +/* + * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. + * Copyright (c) 2006 Stefan Gehrer + * + * 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 + */ + +#ifndef AVCODEC_CAVSDSP_H +#define AVCODEC_CAVSDSP_H + +#include +#include "dsputil.h" + +typedef struct CAVSDSPContext { + qpel_mc_func put_cavs_qpel_pixels_tab[2][16]; + qpel_mc_func avg_cavs_qpel_pixels_tab[2][16]; + void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); + void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); + void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); + void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); + void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride); +} CAVSDSPContext; + +void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx); +void ff_cavsdsp_init_mmx(CAVSDSPContext* c, AVCodecContext *avctx); + +#endif diff -r e25a985a550c -r 1241c824de46 dsputil.c --- a/dsputil.c Tue Aug 03 11:35:41 2010 +0000 +++ b/dsputil.c Tue Aug 03 20:59:00 2010 +0000 @@ -4343,10 +4343,6 @@ c->draw_edges = draw_edges_c; -#if CONFIG_CAVS_DECODER - ff_cavsdsp_init(c,avctx); -#endif - #if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER ff_mlp_init(c, avctx); #endif diff -r e25a985a550c -r 1241c824de46 dsputil.h --- a/dsputil.h Tue Aug 03 11:35:41 2010 +0000 +++ b/dsputil.h Tue Aug 03 20:59:00 2010 +0000 @@ -339,15 +339,6 @@ qpel_mc_func put_2tap_qpel_pixels_tab[4][16]; qpel_mc_func avg_2tap_qpel_pixels_tab[4][16]; - /* AVS specific */ - qpel_mc_func put_cavs_qpel_pixels_tab[2][16]; - qpel_mc_func avg_cavs_qpel_pixels_tab[2][16]; - void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); - void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); - void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); - void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); - void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride); - me_cmp_func pix_abs[2][4]; /* huffyuv specific */ @@ -640,7 +631,6 @@ void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx); void ff_dsputil_init_dwt(DSPContext *c); -void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx); void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx); void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx); void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx); diff -r e25a985a550c -r 1241c824de46 x86/cavsdsp_mmx.c --- a/x86/cavsdsp_mmx.c Tue Aug 03 11:35:41 2010 +0000 +++ b/x86/cavsdsp_mmx.c Tue Aug 03 20:59:00 2010 +0000 @@ -25,6 +25,7 @@ #include "libavutil/common.h" #include "libavutil/x86_cpu.h" #include "libavcodec/dsputil.h" +#include "libavcodec/cavsdsp.h" #include "dsputil_mmx.h" /***************************************************************************** @@ -437,7 +438,7 @@ CAVS_MC(avg_, 8, mmx2) CAVS_MC(avg_, 16,mmx2) -void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx) { +static void ff_cavsdsp_init_mmx2(CAVSDSPContext* c, AVCodecContext *avctx) { #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \ c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmx2; \ @@ -453,7 +454,7 @@ c->cavs_idct8_add = cavs_idct8_add_mmx; } -void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx) { +static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) { #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \ c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \ @@ -468,3 +469,11 @@ #undef dspfunc c->cavs_idct8_add = cavs_idct8_add_mmx; } + +void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx) +{ + int mm_flags = mm_support(); + + if (mm_flags & FF_MM_MMX2) ff_cavsdsp_init_mmx2 (c, avctx); + if (mm_flags & FF_MM_3DNOW) ff_cavsdsp_init_3dnow(c, avctx); +} diff -r e25a985a550c -r 1241c824de46 x86/dsputil_mmx.c --- a/x86/dsputil_mmx.c Tue Aug 03 11:35:41 2010 +0000 +++ b/x86/dsputil_mmx.c Tue Aug 03 20:59:00 2010 +0000 @@ -2727,9 +2727,6 @@ c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov; #endif - if (CONFIG_CAVS_DECODER) - ff_cavsdsp_init_mmx2(c, avctx); - if (CONFIG_VC1_DECODER) ff_vc1dsp_init_mmx(c, avctx); @@ -2790,9 +2787,6 @@ c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_3dnow; c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_3dnow; - - if (CONFIG_CAVS_DECODER) - ff_cavsdsp_init_3dnow(c, avctx); } diff -r e25a985a550c -r 1241c824de46 x86/dsputil_mmx.h --- a/x86/dsputil_mmx.h Tue Aug 03 11:35:41 2010 +0000 +++ b/x86/dsputil_mmx.h Tue Aug 03 20:59:00 2010 +0000 @@ -162,8 +162,6 @@ void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size); void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size); -void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx); -void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx); void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride); void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);