[FFmpeg-cvslog] r24685 - in trunk/libavcodec: cavs.c cavs.h cavsdec.c cavsdsp.c cavsdsp.h dsputil.c dsputil.h x86/cavsdsp_mmx.c x86/dsputil_mmx.c x86/dsputil_mmx.h

mru subversion
Tue Aug 3 22:59:00 CEST 2010


Author: mru
Date: Tue Aug  3 22:59:00 2010
New Revision: 24685

Log:
Move cavs dsp functions to their own struct

Added:
   trunk/libavcodec/cavsdsp.h
Modified:
   trunk/libavcodec/cavs.c
   trunk/libavcodec/cavs.h
   trunk/libavcodec/cavsdec.c
   trunk/libavcodec/cavsdsp.c
   trunk/libavcodec/dsputil.c
   trunk/libavcodec/dsputil.h
   trunk/libavcodec/x86/cavsdsp_mmx.c
   trunk/libavcodec/x86/dsputil_mmx.c
   trunk/libavcodec/x86/dsputil_mmx.h

Modified: trunk/libavcodec/cavs.c
==============================================================================
--- trunk/libavcodec/cavs.c	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/cavs.c	Tue Aug  3 22:59:00 2010	(r24685)
@@ -113,22 +113,22 @@ void ff_cavs_filter(AVSContext *h, enum 
             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 @@ static inline void mc_part_std(AVSContex
 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 @@ av_cold int ff_cavs_init(AVCodecContext 
     MpegEncContext * const s = &h->s;
 
     MPV_decode_defaults(s);
+    ff_cavsdsp_init(&h->cdsp, avctx);
     s->avctx = avctx;
 
     avctx->pix_fmt= PIX_FMT_YUV420P;

Modified: trunk/libavcodec/cavs.h
==============================================================================
--- trunk/libavcodec/cavs.h	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/cavs.h	Tue Aug  3 22:59:00 2010	(r24685)
@@ -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 @@ struct dec_2dvlc {
 
 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

Modified: trunk/libavcodec/cavsdec.c
==============================================================================
--- trunk/libavcodec/cavsdec.c	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/cavsdec.c	Tue Aug  3 22:59:00 2010	(r24685)
@@ -143,7 +143,7 @@ static int decode_residual_block(AVSCont
     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;
 }

Modified: trunk/libavcodec/cavsdsp.c
==============================================================================
--- trunk/libavcodec/cavsdsp.c	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/cavsdsp.c	Tue Aug  3 22:59:00 2010	(r24685)
@@ -24,6 +24,7 @@
 
 #include <stdio.h>
 #include "dsputil.h"
+#include "cavsdsp.h"
 
 /*****************************************************************************
  *
@@ -510,7 +511,7 @@ CAVS_MC(put_, 16)
 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 @@ av_cold void ff_cavsdsp_init(DSPContext*
     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);
 }

Added: trunk/libavcodec/cavsdsp.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/libavcodec/cavsdsp.h	Tue Aug  3 22:59:00 2010	(r24685)
@@ -0,0 +1,41 @@
+/*
+ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
+ * Copyright (c) 2006  Stefan Gehrer <stefan.gehrer at gmx.de>
+ *
+ * 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 <stdint.h>
+#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

Modified: trunk/libavcodec/dsputil.c
==============================================================================
--- trunk/libavcodec/dsputil.c	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/dsputil.c	Tue Aug  3 22:59:00 2010	(r24685)
@@ -4343,10 +4343,6 @@ av_cold void dsputil_init(DSPContext* c,
 
     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

Modified: trunk/libavcodec/dsputil.h
==============================================================================
--- trunk/libavcodec/dsputil.h	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/dsputil.h	Tue Aug  3 22:59:00 2010	(r24685)
@@ -339,15 +339,6 @@ typedef struct DSPContext {
     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_sh4(DSPContext* c, AVC
 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);

Modified: trunk/libavcodec/x86/cavsdsp_mmx.c
==============================================================================
--- trunk/libavcodec/x86/cavsdsp_mmx.c	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/x86/cavsdsp_mmx.c	Tue Aug  3 22:59:00 2010	(r24685)
@@ -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(put_, 16,mmx2)
 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 @@ void ff_cavsdsp_init_mmx2(DSPContext* c,
     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 @@ void ff_cavsdsp_init_3dnow(DSPContext* c
 #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);
+}

Modified: trunk/libavcodec/x86/dsputil_mmx.c
==============================================================================
--- trunk/libavcodec/x86/dsputil_mmx.c	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/x86/dsputil_mmx.c	Tue Aug  3 22:59:00 2010	(r24685)
@@ -2727,9 +2727,6 @@ void dsputil_init_mmx(DSPContext* c, AVC
                 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 @@ void dsputil_init_mmx(DSPContext* c, AVC
 
             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);
         }
 
 

Modified: trunk/libavcodec/x86/dsputil_mmx.h
==============================================================================
--- trunk/libavcodec/x86/dsputil_mmx.h	Tue Aug  3 13:35:41 2010	(r24684)
+++ trunk/libavcodec/x86/dsputil_mmx.h	Tue Aug  3 22:59:00 2010	(r24685)
@@ -162,8 +162,6 @@ void add_pixels_clamped_mmx(const DCTELE
 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);



More information about the ffmpeg-cvslog mailing list