Browse code

Move cavs dsp functions to their own struct

Originally committed as revision 24685 to svn://svn.ffmpeg.org/ffmpeg/trunk

Måns Rullgård authored on 2010/08/04 05:59:00
Showing 10 changed files
... ...
@@ -113,22 +113,22 @@ void ff_cavs_filter(AVSContext *h, enum cavs_mb mb_type) {
113 113
             if(h->flags & A_AVAIL) {
114 114
                 qp_avg = (h->qp + h->left_qp + 1) >> 1;
115 115
                 SET_PARAMS;
116
-                h->s.dsp.cavs_filter_lv(h->cy,h->l_stride,alpha,beta,tc,bs[0],bs[1]);
117
-                h->s.dsp.cavs_filter_cv(h->cu,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
118
-                h->s.dsp.cavs_filter_cv(h->cv,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
116
+                h->cdsp.cavs_filter_lv(h->cy,h->l_stride,alpha,beta,tc,bs[0],bs[1]);
117
+                h->cdsp.cavs_filter_cv(h->cu,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
118
+                h->cdsp.cavs_filter_cv(h->cv,h->c_stride,alpha,beta,tc,bs[0],bs[1]);
119 119
             }
120 120
             qp_avg = h->qp;
121 121
             SET_PARAMS;
122
-            h->s.dsp.cavs_filter_lv(h->cy + 8,h->l_stride,alpha,beta,tc,bs[2],bs[3]);
123
-            h->s.dsp.cavs_filter_lh(h->cy + 8*h->l_stride,h->l_stride,alpha,beta,tc,
122
+            h->cdsp.cavs_filter_lv(h->cy + 8,h->l_stride,alpha,beta,tc,bs[2],bs[3]);
123
+            h->cdsp.cavs_filter_lh(h->cy + 8*h->l_stride,h->l_stride,alpha,beta,tc,
124 124
                            bs[6],bs[7]);
125 125
 
126 126
             if(h->flags & B_AVAIL) {
127 127
                 qp_avg = (h->qp + h->top_qp[h->mbx] + 1) >> 1;
128 128
                 SET_PARAMS;
129
-                h->s.dsp.cavs_filter_lh(h->cy,h->l_stride,alpha,beta,tc,bs[4],bs[5]);
130
-                h->s.dsp.cavs_filter_ch(h->cu,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
131
-                h->s.dsp.cavs_filter_ch(h->cv,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
129
+                h->cdsp.cavs_filter_lh(h->cy,h->l_stride,alpha,beta,tc,bs[4],bs[5]);
130
+                h->cdsp.cavs_filter_ch(h->cu,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
131
+                h->cdsp.cavs_filter_ch(h->cv,h->c_stride,alpha,beta,tc,bs[4],bs[5]);
132 132
             }
133 133
         }
134 134
     }
... ...
@@ -414,30 +414,30 @@ static inline void mc_part_std(AVSContext *h,int square,int chroma_height,int de
414 414
 void ff_cavs_inter(AVSContext *h, enum cavs_mb mb_type) {
415 415
     if(ff_cavs_partition_flags[mb_type] == 0){ // 16x16
416 416
         mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0,
417
-                h->s.dsp.put_cavs_qpel_pixels_tab[0],
417
+                h->cdsp.put_cavs_qpel_pixels_tab[0],
418 418
                 h->s.dsp.put_h264_chroma_pixels_tab[0],
419
-                h->s.dsp.avg_cavs_qpel_pixels_tab[0],
419
+                h->cdsp.avg_cavs_qpel_pixels_tab[0],
420 420
                 h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]);
421 421
     }else{
422 422
         mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0,
423
-                h->s.dsp.put_cavs_qpel_pixels_tab[1],
423
+                h->cdsp.put_cavs_qpel_pixels_tab[1],
424 424
                 h->s.dsp.put_h264_chroma_pixels_tab[1],
425
-                h->s.dsp.avg_cavs_qpel_pixels_tab[1],
425
+                h->cdsp.avg_cavs_qpel_pixels_tab[1],
426 426
                 h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X0]);
427 427
         mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 0,
428
-                h->s.dsp.put_cavs_qpel_pixels_tab[1],
428
+                h->cdsp.put_cavs_qpel_pixels_tab[1],
429 429
                 h->s.dsp.put_h264_chroma_pixels_tab[1],
430
-                h->s.dsp.avg_cavs_qpel_pixels_tab[1],
430
+                h->cdsp.avg_cavs_qpel_pixels_tab[1],
431 431
                 h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X1]);
432 432
         mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 4,
433
-                h->s.dsp.put_cavs_qpel_pixels_tab[1],
433
+                h->cdsp.put_cavs_qpel_pixels_tab[1],
434 434
                 h->s.dsp.put_h264_chroma_pixels_tab[1],
435
-                h->s.dsp.avg_cavs_qpel_pixels_tab[1],
435
+                h->cdsp.avg_cavs_qpel_pixels_tab[1],
436 436
                 h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X2]);
437 437
         mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 4, 4,
438
-                h->s.dsp.put_cavs_qpel_pixels_tab[1],
438
+                h->cdsp.put_cavs_qpel_pixels_tab[1],
439 439
                 h->s.dsp.put_h264_chroma_pixels_tab[1],
440
-                h->s.dsp.avg_cavs_qpel_pixels_tab[1],
440
+                h->cdsp.avg_cavs_qpel_pixels_tab[1],
441 441
                 h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]);
442 442
     }
443 443
 }
... ...
@@ -672,6 +672,7 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) {
672 672
     MpegEncContext * const s = &h->s;
673 673
 
674 674
     MPV_decode_defaults(s);
675
+    ff_cavsdsp_init(&h->cdsp, avctx);
675 676
     s->avctx = avctx;
676 677
 
677 678
     avctx->pix_fmt= PIX_FMT_YUV420P;
... ...
@@ -24,6 +24,7 @@
24 24
 
25 25
 #include "dsputil.h"
26 26
 #include "mpegvideo.h"
27
+#include "cavsdsp.h"
27 28
 
28 29
 #define SLICE_MAX_START_CODE    0x000001af
29 30
 #define EXT_START_CODE          0x000001b5
... ...
@@ -153,6 +154,7 @@ struct dec_2dvlc {
153 153
 
154 154
 typedef struct {
155 155
     MpegEncContext s;
156
+    CAVSDSPContext cdsp;
156 157
     Picture picture; ///< currently decoded frame
157 158
     Picture DPB[2];  ///< reference frames
158 159
     int dist[2];     ///< temporal distances from current frame to ref frames
... ...
@@ -143,7 +143,7 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
143 143
     if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp],
144 144
                ff_cavs_dequant_shift[qp], i))
145 145
         return -1;
146
-    h->s.dsp.cavs_idct8_add(dst,block,stride);
146
+    h->cdsp.cavs_idct8_add(dst,block,stride);
147 147
     h->s.dsp.clear_block(block);
148 148
     return 0;
149 149
 }
... ...
@@ -24,6 +24,7 @@
24 24
 
25 25
 #include <stdio.h>
26 26
 #include "dsputil.h"
27
+#include "cavsdsp.h"
27 28
 
28 29
 /*****************************************************************************
29 30
  *
... ...
@@ -510,7 +511,7 @@ CAVS_MC(put_, 16)
510 510
 CAVS_MC(avg_, 8)
511 511
 CAVS_MC(avg_, 16)
512 512
 
513
-av_cold void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
513
+av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) {
514 514
 #define dspfunc(PFX, IDX, NUM) \
515 515
     c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \
516 516
     c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \
... ...
@@ -537,4 +538,6 @@ av_cold void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
537 537
     c->cavs_filter_cv = cavs_filter_cv_c;
538 538
     c->cavs_filter_ch = cavs_filter_ch_c;
539 539
     c->cavs_idct8_add = cavs_idct8_add_c;
540
+
541
+    if (HAVE_MMX) ff_cavsdsp_init_mmx(c, avctx);
540 542
 }
541 543
new file mode 100644
... ...
@@ -0,0 +1,41 @@
0
+/*
1
+ * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
2
+ * Copyright (c) 2006  Stefan Gehrer <stefan.gehrer@gmx.de>
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+#ifndef AVCODEC_CAVSDSP_H
22
+#define AVCODEC_CAVSDSP_H
23
+
24
+#include <stdint.h>
25
+#include "dsputil.h"
26
+
27
+typedef struct CAVSDSPContext {
28
+    qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
29
+    qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
30
+    void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
31
+    void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
32
+    void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
33
+    void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
34
+    void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
35
+} CAVSDSPContext;
36
+
37
+void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx);
38
+void ff_cavsdsp_init_mmx(CAVSDSPContext* c, AVCodecContext *avctx);
39
+
40
+#endif
... ...
@@ -4343,10 +4343,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
4343 4343
 
4344 4344
     c->draw_edges = draw_edges_c;
4345 4345
 
4346
-#if CONFIG_CAVS_DECODER
4347
-    ff_cavsdsp_init(c,avctx);
4348
-#endif
4349
-
4350 4346
 #if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER
4351 4347
     ff_mlp_init(c, avctx);
4352 4348
 #endif
... ...
@@ -339,15 +339,6 @@ typedef struct DSPContext {
339 339
     qpel_mc_func put_2tap_qpel_pixels_tab[4][16];
340 340
     qpel_mc_func avg_2tap_qpel_pixels_tab[4][16];
341 341
 
342
-    /* AVS specific */
343
-    qpel_mc_func put_cavs_qpel_pixels_tab[2][16];
344
-    qpel_mc_func avg_cavs_qpel_pixels_tab[2][16];
345
-    void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
346
-    void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
347
-    void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
348
-    void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2);
349
-    void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
350
-
351 342
     me_cmp_func pix_abs[2][4];
352 343
 
353 344
     /* huffyuv specific */
... ...
@@ -640,7 +631,6 @@ void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
640 640
 void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
641 641
 
642 642
 void ff_dsputil_init_dwt(DSPContext *c);
643
-void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx);
644 643
 void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
645 644
 void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
646 645
 void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
... ...
@@ -25,6 +25,7 @@
25 25
 #include "libavutil/common.h"
26 26
 #include "libavutil/x86_cpu.h"
27 27
 #include "libavcodec/dsputil.h"
28
+#include "libavcodec/cavsdsp.h"
28 29
 #include "dsputil_mmx.h"
29 30
 
30 31
 /*****************************************************************************
... ...
@@ -437,7 +438,7 @@ CAVS_MC(put_, 16,mmx2)
437 437
 CAVS_MC(avg_, 8, mmx2)
438 438
 CAVS_MC(avg_, 16,mmx2)
439 439
 
440
-void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx) {
440
+static void ff_cavsdsp_init_mmx2(CAVSDSPContext* c, AVCodecContext *avctx) {
441 441
 #define dspfunc(PFX, IDX, NUM) \
442 442
     c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
443 443
     c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_mmx2; \
... ...
@@ -453,7 +454,7 @@ void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx) {
453 453
     c->cavs_idct8_add = cavs_idct8_add_mmx;
454 454
 }
455 455
 
456
-void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx) {
456
+static void ff_cavsdsp_init_3dnow(CAVSDSPContext* c, AVCodecContext *avctx) {
457 457
 #define dspfunc(PFX, IDX, NUM) \
458 458
     c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_mmx2; \
459 459
     c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_3dnow; \
... ...
@@ -468,3 +469,11 @@ void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx) {
468 468
 #undef dspfunc
469 469
     c->cavs_idct8_add = cavs_idct8_add_mmx;
470 470
 }
471
+
472
+void ff_cavsdsp_init_mmx(CAVSDSPContext *c, AVCodecContext *avctx)
473
+{
474
+    int mm_flags = mm_support();
475
+
476
+    if (mm_flags & FF_MM_MMX2)  ff_cavsdsp_init_mmx2 (c, avctx);
477
+    if (mm_flags & FF_MM_3DNOW) ff_cavsdsp_init_3dnow(c, avctx);
478
+}
... ...
@@ -2727,9 +2727,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
2727 2727
                 c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov;
2728 2728
 #endif
2729 2729
 
2730
-            if (CONFIG_CAVS_DECODER)
2731
-                ff_cavsdsp_init_mmx2(c, avctx);
2732
-
2733 2730
             if (CONFIG_VC1_DECODER)
2734 2731
                 ff_vc1dsp_init_mmx(c, avctx);
2735 2732
 
... ...
@@ -2790,9 +2787,6 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
2790 2790
 
2791 2791
             c->avg_rv40_chroma_pixels_tab[0]= avg_rv40_chroma_mc8_3dnow;
2792 2792
             c->avg_rv40_chroma_pixels_tab[1]= avg_rv40_chroma_mc4_3dnow;
2793
-
2794
-            if (CONFIG_CAVS_DECODER)
2795
-                ff_cavsdsp_init_3dnow(c, avctx);
2796 2793
         }
2797 2794
 
2798 2795
 
... ...
@@ -162,8 +162,6 @@ void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size
162 162
 void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
163 163
 void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
164 164
 
165
-void ff_cavsdsp_init_mmx2(DSPContext* c, AVCodecContext *avctx);
166
-void ff_cavsdsp_init_3dnow(DSPContext* c, AVCodecContext *avctx);
167 165
 void ff_put_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
168 166
 void ff_avg_cavs_qpel8_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);
169 167
 void ff_put_cavs_qpel16_mc00_mmx2(uint8_t *dst, uint8_t *src, int stride);