You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.0KB

  1. /*
  2. * Copyright (c) 2002 Dieter Shirley
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "../dsputil.h"
  19. #include "../mpegvideo.h"
  20. #include <time.h>
  21. #ifdef HAVE_ALTIVEC
  22. #include "dsputil_altivec.h"
  23. #endif
  24. extern int dct_quantize_altivec(MpegEncContext *s,
  25. DCTELEM *block, int n,
  26. int qscale, int *overflow);
  27. extern void dct_unquantize_h263_altivec(MpegEncContext *s,
  28. DCTELEM *block, int n, int qscale);
  29. extern void idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
  30. extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
  31. void MPV_common_init_ppc(MpegEncContext *s)
  32. {
  33. #ifdef HAVE_ALTIVEC
  34. if (has_altivec())
  35. {
  36. if (s->avctx->lowres==0)
  37. {
  38. if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
  39. (s->avctx->idct_algo == FF_IDCT_ALTIVEC))
  40. {
  41. s->dsp.idct_put = idct_put_altivec;
  42. s->dsp.idct_add = idct_add_altivec;
  43. #ifndef ALTIVEC_USE_REFERENCE_C_CODE
  44. s->dsp.idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
  45. #else /* ALTIVEC_USE_REFERENCE_C_CODE */
  46. s->dsp.idct_permutation_type = FF_NO_IDCT_PERM;
  47. #endif /* ALTIVEC_USE_REFERENCE_C_CODE */
  48. }
  49. }
  50. // Test to make sure that the dct required alignments are met.
  51. if ((((long)(s->q_intra_matrix) & 0x0f) != 0) ||
  52. (((long)(s->q_inter_matrix) & 0x0f) != 0))
  53. {
  54. av_log(s->avctx, AV_LOG_INFO, "Internal Error: q-matrix blocks must be 16-byte aligned "
  55. "to use Altivec DCT. Reverting to non-altivec version.\n");
  56. return;
  57. }
  58. if (((long)(s->intra_scantable.inverse) & 0x0f) != 0)
  59. {
  60. av_log(s->avctx, AV_LOG_INFO, "Internal Error: scan table blocks must be 16-byte aligned "
  61. "to use Altivec DCT. Reverting to non-altivec version.\n");
  62. return;
  63. }
  64. if ((s->avctx->dct_algo == FF_DCT_AUTO) ||
  65. (s->avctx->dct_algo == FF_DCT_ALTIVEC))
  66. {
  67. #if 0 /* seems to cause trouble under some circumstances */
  68. s->dct_quantize = dct_quantize_altivec;
  69. #endif
  70. s->dct_unquantize_h263_intra = dct_unquantize_h263_altivec;
  71. s->dct_unquantize_h263_inter = dct_unquantize_h263_altivec;
  72. }
  73. } else
  74. #endif
  75. {
  76. /* Non-AltiVec PPC optimisations here */
  77. }
  78. }