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.

101 lines
3.0KB

  1. /*
  2. * Optimization of some functions from mpegvideo.c for armv5te
  3. * Copyright (c) 2007 Siarhei Siamashka <ssvb@users.sourceforge.net>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "libavcodec/avcodec.h"
  22. #include "libavcodec/dsputil.h"
  23. #include "libavcodec/mpegvideo.h"
  24. void ff_dct_unquantize_h263_armv5te(DCTELEM *block, int qmul, int qadd, int count);
  25. #ifdef ENABLE_ARM_TESTS
  26. /**
  27. * h263 dequantizer supplementary function, it is performance critical and needs to
  28. * have optimized implementations for each architecture. Is also used as a reference
  29. * implementation in regression tests
  30. */
  31. static inline void dct_unquantize_h263_helper_c(DCTELEM *block, int qmul, int qadd, int count)
  32. {
  33. int i, level;
  34. for (i = 0; i < count; i++) {
  35. level = block[i];
  36. if (level) {
  37. if (level < 0) {
  38. level = level * qmul - qadd;
  39. } else {
  40. level = level * qmul + qadd;
  41. }
  42. block[i] = level;
  43. }
  44. }
  45. }
  46. #endif
  47. static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s,
  48. DCTELEM *block, int n, int qscale)
  49. {
  50. int level, qmul, qadd;
  51. int nCoeffs;
  52. assert(s->block_last_index[n]>=0);
  53. qmul = qscale << 1;
  54. if (!s->h263_aic) {
  55. if (n < 4)
  56. level = block[0] * s->y_dc_scale;
  57. else
  58. level = block[0] * s->c_dc_scale;
  59. qadd = (qscale - 1) | 1;
  60. }else{
  61. qadd = 0;
  62. level = block[0];
  63. }
  64. if(s->ac_pred)
  65. nCoeffs=63;
  66. else
  67. nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
  68. ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
  69. block[0] = level;
  70. }
  71. static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s,
  72. DCTELEM *block, int n, int qscale)
  73. {
  74. int qmul, qadd;
  75. int nCoeffs;
  76. assert(s->block_last_index[n]>=0);
  77. qadd = (qscale - 1) | 1;
  78. qmul = qscale << 1;
  79. nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
  80. ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
  81. }
  82. void MPV_common_init_armv5te(MpegEncContext *s)
  83. {
  84. s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_armv5te;
  85. s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_armv5te;
  86. }