2012-08-13 14:11:38 +03:00
|
|
|
/*
|
|
|
|
* The simplest mpeg encoder (well, it was the simplest!)
|
|
|
|
* Copyright (c) 2000,2001 Fabrice Bellard
|
|
|
|
*
|
2012-08-24 15:22:38 +03:00
|
|
|
* This file is part of FFmpeg.
|
2012-08-13 14:11:38 +03:00
|
|
|
*
|
2012-08-24 15:22:38 +03:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-08-13 14:11:38 +03:00
|
|
|
* 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.
|
|
|
|
*
|
2012-08-24 15:22:38 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-08-13 14:11:38 +03:00
|
|
|
* 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
|
2012-08-24 15:22:38 +03:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-08-13 14:11:38 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2013-02-01 12:31:59 +03:00
|
|
|
#include "libavutil/attributes.h"
|
2012-08-13 14:11:38 +03:00
|
|
|
#include "libavutil/cpu.h"
|
|
|
|
#include "libavutil/x86/asm.h"
|
2012-08-29 20:01:05 +03:00
|
|
|
#include "libavutil/x86/cpu.h"
|
2012-08-13 14:11:38 +03:00
|
|
|
#include "libavcodec/avcodec.h"
|
2013-02-07 23:58:48 +03:00
|
|
|
#include "libavcodec/dct.h"
|
2012-08-13 14:11:38 +03:00
|
|
|
#include "libavcodec/mpegvideo.h"
|
2013-05-08 02:52:57 +03:00
|
|
|
#include "dsputil_x86.h"
|
2012-08-13 14:11:38 +03:00
|
|
|
|
2013-12-01 07:05:23 +03:00
|
|
|
/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
|
|
|
|
DECLARE_ALIGNED(16, static uint16_t, inv_zigzag_direct16)[64];
|
2012-08-13 14:11:38 +03:00
|
|
|
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_MMX_INLINE
|
2012-08-28 18:37:54 +03:00
|
|
|
#define COMPILE_TEMPLATE_MMXEXT 0
|
|
|
|
#define COMPILE_TEMPLATE_SSE2 0
|
|
|
|
#define COMPILE_TEMPLATE_SSSE3 0
|
2012-08-13 14:11:38 +03:00
|
|
|
#define RENAME(a) a ## _MMX
|
|
|
|
#define RENAMEl(a) a ## _mmx
|
|
|
|
#include "mpegvideoenc_template.c"
|
2012-08-28 15:53:33 +03:00
|
|
|
#endif /* HAVE_MMX_INLINE */
|
2012-08-13 14:11:38 +03:00
|
|
|
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_MMXEXT_INLINE
|
2012-08-28 18:37:54 +03:00
|
|
|
#undef COMPILE_TEMPLATE_SSSE3
|
|
|
|
#undef COMPILE_TEMPLATE_SSE2
|
|
|
|
#undef COMPILE_TEMPLATE_MMXEXT
|
|
|
|
#define COMPILE_TEMPLATE_MMXEXT 1
|
|
|
|
#define COMPILE_TEMPLATE_SSE2 0
|
|
|
|
#define COMPILE_TEMPLATE_SSSE3 0
|
2012-08-13 14:11:38 +03:00
|
|
|
#undef RENAME
|
|
|
|
#undef RENAMEl
|
2012-07-08 20:56:10 +03:00
|
|
|
#define RENAME(a) a ## _MMXEXT
|
|
|
|
#define RENAMEl(a) a ## _mmxext
|
2012-08-13 14:11:38 +03:00
|
|
|
#include "mpegvideoenc_template.c"
|
2012-08-28 15:53:33 +03:00
|
|
|
#endif /* HAVE_MMXEXT_INLINE */
|
2012-08-13 14:11:38 +03:00
|
|
|
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_SSE2_INLINE
|
2012-08-28 18:37:54 +03:00
|
|
|
#undef COMPILE_TEMPLATE_MMXEXT
|
|
|
|
#undef COMPILE_TEMPLATE_SSE2
|
|
|
|
#undef COMPILE_TEMPLATE_SSSE3
|
|
|
|
#define COMPILE_TEMPLATE_MMXEXT 0
|
|
|
|
#define COMPILE_TEMPLATE_SSE2 1
|
|
|
|
#define COMPILE_TEMPLATE_SSSE3 0
|
2012-08-13 14:11:38 +03:00
|
|
|
#undef RENAME
|
|
|
|
#undef RENAMEl
|
|
|
|
#define RENAME(a) a ## _SSE2
|
|
|
|
#define RENAMEl(a) a ## _sse2
|
|
|
|
#include "mpegvideoenc_template.c"
|
2012-08-28 15:53:33 +03:00
|
|
|
#endif /* HAVE_SSE2_INLINE */
|
2012-08-13 14:11:38 +03:00
|
|
|
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_SSSE3_INLINE
|
2012-08-28 18:37:54 +03:00
|
|
|
#undef COMPILE_TEMPLATE_MMXEXT
|
|
|
|
#undef COMPILE_TEMPLATE_SSE2
|
|
|
|
#undef COMPILE_TEMPLATE_SSSE3
|
|
|
|
#define COMPILE_TEMPLATE_MMXEXT 0
|
|
|
|
#define COMPILE_TEMPLATE_SSE2 1
|
|
|
|
#define COMPILE_TEMPLATE_SSSE3 1
|
2012-08-13 14:11:38 +03:00
|
|
|
#undef RENAME
|
|
|
|
#undef RENAMEl
|
|
|
|
#define RENAME(a) a ## _SSSE3
|
|
|
|
#define RENAMEl(a) a ## _sse2
|
|
|
|
#include "mpegvideoenc_template.c"
|
2012-08-28 15:53:33 +03:00
|
|
|
#endif /* HAVE_SSSE3_INLINE */
|
2012-08-13 14:11:38 +03:00
|
|
|
|
2013-02-06 15:27:24 +03:00
|
|
|
av_cold void ff_dct_encode_init_x86(MpegEncContext *s)
|
2012-08-13 14:11:38 +03:00
|
|
|
{
|
|
|
|
const int dct_algo = s->avctx->dct_algo;
|
2013-12-01 07:05:23 +03:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 64; i++)
|
|
|
|
inv_zigzag_direct16[ff_zigzag_direct[i]] = i + 1;
|
2012-08-13 14:11:38 +03:00
|
|
|
|
|
|
|
if (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX) {
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_MMX_INLINE
|
2013-07-17 21:19:24 +03:00
|
|
|
int cpu_flags = av_get_cpu_flags();
|
|
|
|
if (INLINE_MMX(cpu_flags))
|
2012-08-29 12:14:17 +03:00
|
|
|
s->dct_quantize = dct_quantize_MMX;
|
|
|
|
#endif
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_MMXEXT_INLINE
|
2013-07-17 21:19:24 +03:00
|
|
|
if (INLINE_MMXEXT(cpu_flags))
|
2012-07-08 20:56:10 +03:00
|
|
|
s->dct_quantize = dct_quantize_MMXEXT;
|
2012-08-29 12:14:17 +03:00
|
|
|
#endif
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_SSE2_INLINE
|
2013-07-17 21:19:24 +03:00
|
|
|
if (INLINE_SSE2(cpu_flags))
|
2012-08-29 12:14:17 +03:00
|
|
|
s->dct_quantize = dct_quantize_SSE2;
|
|
|
|
#endif
|
2012-08-28 15:53:33 +03:00
|
|
|
#if HAVE_SSSE3_INLINE
|
2013-07-17 21:19:24 +03:00
|
|
|
if (INLINE_SSSE3(cpu_flags))
|
2012-08-13 14:11:38 +03:00
|
|
|
s->dct_quantize = dct_quantize_SSSE3;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|