Esempio n. 1
0
int main ( void )
{
    int mm_flags;
    mm_flags = mm_support();
    printf("mm_support = 0x%08X\n",mm_flags);
    return 0;
}
DecoderClass::DecoderClass(VideoDecoder* vid_stream,
			   MpegVideoStream* mpegVideoStream) {

  this->vid_stream=vid_stream;
  this->mpegVideoStream=mpegVideoStream;


#ifdef INTEL
  lmmx=mm_support();
#else
  lmmx=false;
  DEBUG_DECODERCLASS(cout << "no INTEL arch- disable MMX in decoderClass"<<endl;)

#endif

  if (lmmx==true) {
Esempio n. 3
0
/*
 * init_yuv_conversion
 *
 * This function precalculates all of the tables used for converting RGB
 * values to YUV values. This function also decides which conversion
 * functions to use.
 */
void init_yuv_conversion(void) 
{
    /* determine best YUV444 -> YUY2 converter to use */
    /* determine best YV12 -> YUY2 converter to use */
    /* determine best YV12 -> YUY2 converter to use */

#ifdef MMX
    if (mm_support() & FF_MM_MMXEXT)
    {
        yv12_to_yuy2 = yv12_to_yuy2_mmxext;
        yuy2_to_yv12 = yuy2_to_yv12_mmxext;
        vfilter_chroma_332_packed422_scanline = vfilter_chroma_332_packed422_scanline_mmx;
    }
    else
#endif
    {
        yv12_to_yuy2 = yv12_to_yuy2_c;
        yuy2_to_yv12 = yuy2_to_yv12_c;
        vfilter_chroma_332_packed422_scanline = vfilter_chroma_332_packed422_scanline_c;
    }
}
Esempio n. 4
0
/**
 * The size of the FFT is 2^nbits. If inverse is TRUE, inverse FFT is
 * done
 */
int ff_fft_init(FFTContext *s, int nbits, int inverse)
{
    int i, j, m, n;
    float alpha, c1, s1, s2;
    int split_radix = 1;
    int av_unused has_vectors;

    if (nbits < 2 || nbits > 16)
        goto fail;
    s->nbits = nbits;
    n = 1 << nbits;

    s->tmp_buf = NULL;
    s->exptab = av_malloc((n / 2) * sizeof(FFTComplex));
    if (!s->exptab)
        goto fail;
    s->revtab = av_malloc(n * sizeof(uint16_t));
    if (!s->revtab)
        goto fail;
    s->inverse = inverse;

    s2 = inverse ? 1.0 : -1.0;

    s->fft_permute = ff_fft_permute_c;
    s->fft_calc = ff_fft_calc_c;
    s->imdct_calc = ff_imdct_calc_c;
    s->imdct_half = ff_imdct_half_c;
    s->exptab1 = NULL;

#if defined HAVE_MMX && defined HAVE_YASM
    has_vectors = mm_support();
    if (has_vectors & FF_MM_SSE) {
        /* SSE for P3/P4/K8 */
        s->imdct_calc = ff_imdct_calc_sse;
        s->imdct_half = ff_imdct_half_sse;
        s->fft_permute = ff_fft_permute_sse;
        s->fft_calc = ff_fft_calc_sse;
    } else if (has_vectors & FF_MM_3DNOWEXT) {
        /* 3DNowEx for K7 */
        s->imdct_calc = ff_imdct_calc_3dn2;
        s->imdct_half = ff_imdct_half_3dn2;
        s->fft_calc = ff_fft_calc_3dn2;
    } else if (has_vectors & FF_MM_3DNOW) {
        /* 3DNow! for K6-2/3 */
        s->imdct_calc = ff_imdct_calc_3dn;
        s->imdct_half = ff_imdct_half_3dn;
        s->fft_calc = ff_fft_calc_3dn;
    }
#elif defined HAVE_ALTIVEC && !defined ALTIVEC_USE_REFERENCE_C_CODE
    has_vectors = mm_support();
    if (has_vectors & FF_MM_ALTIVEC) {
        s->fft_calc = ff_fft_calc_altivec;
        split_radix = 0;
    }
#endif

    if (split_radix) {
        for(j=4; j<=nbits; j++) {
            int m = 1<<j;
            double freq = 2*M_PI/m;
            FFTSample *tab = ff_cos_tabs[j-4];
            for(i=0; i<=m/4; i++)
                tab[i] = cos(i*freq);
            for(i=1; i<m/4; i++)
                tab[m/2-i] = tab[i];
        }
        for(i=0; i<n; i++)
            s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i;
        s->tmp_buf = av_malloc(n * sizeof(FFTComplex));
    } else {
        int np, nblocks, np2, l;
        FFTComplex *q;

        for(i=0; i<(n/2); i++) {
            alpha = 2 * M_PI * (float)i / (float)n;
            c1 = cos(alpha);
            s1 = sin(alpha) * s2;
            s->exptab[i].re = c1;
            s->exptab[i].im = s1;
        }

        np = 1 << nbits;
        nblocks = np >> 3;
        np2 = np >> 1;
        s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex));
        if (!s->exptab1)
            goto fail;
        q = s->exptab1;
        do {
            for(l = 0; l < np2; l += 2 * nblocks) {
                *q++ = s->exptab[l];
                *q++ = s->exptab[l + nblocks];

                q->re = -s->exptab[l].im;
                q->im = s->exptab[l].re;
                q++;
                q->re = -s->exptab[l + nblocks].im;
                q->im = s->exptab[l + nblocks].re;
                q++;
            }
            nblocks = nblocks >> 1;
        } while (nblocks != 0);
        av_freep(&s->exptab);

        /* compute bit reverse table */
        for(i=0;i<n;i++) {
            m=0;
            for(j=0;j<nbits;j++) {
                m |= ((i >> j) & 1) << (nbits-j-1);
            }
            s->revtab[i]=m;
        }
    }

    return 0;
 fail:
    av_freep(&s->revtab);
    av_freep(&s->exptab);
    av_freep(&s->exptab1);
    av_freep(&s->tmp_buf);
    return -1;
}
Esempio n. 5
0
File: fft.c Progetto: Erikhht/TCPMP
/**
 * The size of the FFT is 2^nbits. If inverse is TRUE, inverse FFT is
 * done 
 */
int ff_fft_init(FFTContext *s, int nbits, int inverse)
{
    int i, j, m, n;
    float alpha, c1, s1, s2;
    
    s->nbits = nbits;
    n = 1 << nbits;

    s->exptab = av_malloc((n / 2) * sizeof(FFTComplex));
    if (!s->exptab)
        goto fail;
    s->revtab = av_malloc(n * sizeof(uint16_t));
    if (!s->revtab)
        goto fail;
    s->inverse = inverse;

    s2 = inverse ? 1.0 : -1.0;
        
    for(i=0;i<(n/2);i++) {
        alpha = 2 * M_PI * (float)i / (float)n;
        c1 = cos(alpha);
        s1 = sin(alpha) * s2;
        s->exptab[i].re = c1;
        s->exptab[i].im = s1;
    }
    s->fft_calc = ff_fft_calc_c;
    s->exptab1 = NULL;

    /* compute constant table for HAVE_SSE version */
#if (defined(HAVE_MMX) && defined(HAVE_BUILTIN_VECTOR)) || defined(HAVE_ALTIVEC)
    {
        int has_vectors = 0;

#if defined(HAVE_MMX)
        has_vectors = mm_support() & MM_SSE;
#endif
#if defined(HAVE_ALTIVEC) && !defined(ALTIVEC_USE_REFERENCE_C_CODE)
        has_vectors = mm_support() & MM_ALTIVEC;
#endif
        if (has_vectors) {
            int np, nblocks, np2, l;
            FFTComplex *q;
            
            np = 1 << nbits;
            nblocks = np >> 3;
            np2 = np >> 1;
            s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex));
            if (!s->exptab1)
                goto fail;
            q = s->exptab1;
            do {
                for(l = 0; l < np2; l += 2 * nblocks) {
                    *q++ = s->exptab[l];
                    *q++ = s->exptab[l + nblocks];

                    q->re = -s->exptab[l].im;
                    q->im = s->exptab[l].re;
                    q++;
                    q->re = -s->exptab[l + nblocks].im;
                    q->im = s->exptab[l + nblocks].re;
                    q++;
                }
                nblocks = nblocks >> 1;
            } while (nblocks != 0);
            av_freep(&s->exptab);
#if defined(HAVE_MMX)
            s->fft_calc = ff_fft_calc_sse;
#else
            s->fft_calc = ff_fft_calc_altivec;
#endif
        }
    }
#endif

    /* compute bit reverse table */

    for(i=0;i<n;i++) {
        m=0;
        for(j=0;j<nbits;j++) {
            m |= ((i >> j) & 1) << (nbits-j-1);
        }
        s->revtab[i]=m;
    }
    return 0;
 fail:
    av_freep(&s->revtab);
    av_freep(&s->exptab);
    av_freep(&s->exptab1);
    return -1;
}
Esempio n. 6
0
av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c)
{
    mm_flags = mm_support();

#if HAVE_YASM
    if (mm_flags & FF_MM_MMX) {
        c->vp8_idct_dc_add                  = ff_vp8_idct_dc_add_mmx;
        c->vp8_idct_add                     = ff_vp8_idct_add_mmx;
        c->put_vp8_epel_pixels_tab[0][0][0]     =
        c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx;
        c->put_vp8_epel_pixels_tab[1][0][0]     =
        c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx;

        c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx;
        c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx;

        c->vp8_v_loop_filter16_inner = ff_vp8_v_loop_filter16_inner_mmx;
        c->vp8_h_loop_filter16_inner = ff_vp8_h_loop_filter16_inner_mmx;
    }

    /* note that 4-tap width=16 functions are missing because w=16
     * is only used for luma, and luma is always a copy or sixtap. */
    if (mm_flags & FF_MM_MMX2) {
        c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmxext;
        VP8_LUMA_MC_FUNC(0, 16, mmxext);
        VP8_MC_FUNC(1, 8, mmxext);
        VP8_MC_FUNC(2, 4, mmxext);
        VP8_BILINEAR_MC_FUNC(0, 16, mmxext);
        VP8_BILINEAR_MC_FUNC(1, 8, mmxext);
        VP8_BILINEAR_MC_FUNC(2, 4, mmxext);

        c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext;
        c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext;

        c->vp8_v_loop_filter16_inner = ff_vp8_v_loop_filter16_inner_mmxext;
        c->vp8_h_loop_filter16_inner = ff_vp8_h_loop_filter16_inner_mmxext;
    }

    if (mm_flags & FF_MM_SSE) {
        c->put_vp8_epel_pixels_tab[0][0][0]     =
        c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse;
    }

    if (mm_flags & FF_MM_SSE2) {
        VP8_LUMA_MC_FUNC(0, 16, sse2);
        VP8_MC_FUNC(1, 8, sse2);
        VP8_BILINEAR_MC_FUNC(0, 16, sse2);
        VP8_BILINEAR_MC_FUNC(1, 8, sse2);

        c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2;
        c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2;

        c->vp8_v_loop_filter16_inner = ff_vp8_v_loop_filter16_inner_sse2;
        c->vp8_h_loop_filter16_inner = ff_vp8_h_loop_filter16_inner_sse2;
    }

    if (mm_flags & FF_MM_SSSE3) {
        VP8_LUMA_MC_FUNC(0, 16, ssse3);
        VP8_MC_FUNC(1, 8, ssse3);
        VP8_MC_FUNC(2, 4, ssse3);
        VP8_BILINEAR_MC_FUNC(0, 16, ssse3);
        VP8_BILINEAR_MC_FUNC(1, 8, ssse3);
        VP8_BILINEAR_MC_FUNC(2, 4, ssse3);
    }

    if (mm_flags & FF_MM_SSE4) {
        c->vp8_idct_dc_add                  = ff_vp8_idct_dc_add_sse4;
    }
#endif
}
Esempio n. 7
0
/**
 * The size of the FFT is 2^nbits. If inverse is TRUE, inverse FFT is
 * done
 */
int ff_fft_init(FFTContext *s, int nbits, int inverse)
{
    int i, j, m, n;
    float alpha, c1, s1, s2;

    s->nbits = nbits;
    n = 1 << nbits;

    s->exptab = av_malloc((n / 2) * sizeof(FFTComplex));
    if (!s->exptab)
        goto fail;
    s->revtab = av_malloc(n * sizeof(uint16_t));
    if (!s->revtab)
        goto fail;
    s->inverse = inverse;

    s2 = inverse ? 1.0 : -1.0;

    for(i=0;i<(n/2);i++) {
        alpha = 2 * M_PI * (float)i / (float)n;
        c1 = cos(alpha);
        s1 = sin(alpha) * s2;
        s->exptab[i].re = c1;
        s->exptab[i].im = s1;
    }
    s->fft_calc = ff_fft_calc_c;
    s->imdct_calc = ff_imdct_calc;
    s->exptab1 = NULL;

    /* compute constant table for HAVE_SSE version */
#if defined(HAVE_MMX) \
    || (defined(HAVE_ALTIVEC) && !defined(ALTIVEC_USE_REFERENCE_C_CODE))
    {
        int has_vectors = mm_support();

        if (has_vectors) {
#if defined(HAVE_MMX)
            if (has_vectors & MM_3DNOWEXT) {
                /* 3DNowEx for K7/K8 */
                s->imdct_calc = ff_imdct_calc_3dn2;
                s->fft_calc = ff_fft_calc_3dn2;
            } else if (has_vectors & MM_3DNOW) {
                /* 3DNow! for K6-2/3 */
                s->fft_calc = ff_fft_calc_3dn;
            } else if (has_vectors & MM_SSE) {
                /* SSE for P3/P4 */
                s->imdct_calc = ff_imdct_calc_sse;
                s->fft_calc = ff_fft_calc_sse;
            }
#else /* HAVE_MMX */
            if (has_vectors & MM_ALTIVEC)
                s->fft_calc = ff_fft_calc_altivec;
#endif
        }
        if (s->fft_calc != ff_fft_calc_c) {
            int np, nblocks, np2, l;
            FFTComplex *q;

            np = 1 << nbits;
            nblocks = np >> 3;
            np2 = np >> 1;
            s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex));
            if (!s->exptab1)
                goto fail;
            q = s->exptab1;
            do {
                for(l = 0; l < np2; l += 2 * nblocks) {
                    *q++ = s->exptab[l];
                    *q++ = s->exptab[l + nblocks];

                    q->re = -s->exptab[l].im;
                    q->im = s->exptab[l].re;
                    q++;
                    q->re = -s->exptab[l + nblocks].im;
                    q->im = s->exptab[l + nblocks].re;
                    q++;
                }
                nblocks = nblocks >> 1;
            } while (nblocks != 0);
            av_freep(&s->exptab);
        }
    }