2
0

mpegvideo_armv5te.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 "libavutil/attributes.h"
  22. #include "libavutil/avassert.h"
  23. #include "libavcodec/avcodec.h"
  24. #include "libavcodec/mpegvideo.h"
  25. #include "mpegvideo_arm.h"
  26. void ff_dct_unquantize_h263_armv5te(int16_t *block, int qmul, int qadd, int count);
  27. #ifdef ENABLE_ARM_TESTS
  28. /**
  29. * H.263 dequantizer supplementary function, it is performance critical and needs to
  30. * have optimized implementations for each architecture. Is also used as a reference
  31. * implementation in regression tests
  32. */
  33. static inline void dct_unquantize_h263_helper_c(int16_t *block, int qmul, int qadd, int count)
  34. {
  35. int i, level;
  36. for (i = 0; i < count; i++) {
  37. level = block[i];
  38. if (level) {
  39. if (level < 0) {
  40. level = level * qmul - qadd;
  41. } else {
  42. level = level * qmul + qadd;
  43. }
  44. block[i] = level;
  45. }
  46. }
  47. }
  48. #endif
  49. static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s,
  50. int16_t *block, int n, int qscale)
  51. {
  52. int level, qmul, qadd;
  53. int nCoeffs;
  54. av_assert2(s->block_last_index[n]>=0);
  55. qmul = qscale << 1;
  56. if (!s->h263_aic) {
  57. if (n < 4)
  58. level = block[0] * s->y_dc_scale;
  59. else
  60. level = block[0] * s->c_dc_scale;
  61. qadd = (qscale - 1) | 1;
  62. }else{
  63. qadd = 0;
  64. level = block[0];
  65. }
  66. if(s->ac_pred)
  67. nCoeffs=63;
  68. else
  69. nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
  70. ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
  71. block[0] = level;
  72. }
  73. static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s,
  74. int16_t *block, int n, int qscale)
  75. {
  76. int qmul, qadd;
  77. int nCoeffs;
  78. av_assert2(s->block_last_index[n]>=0);
  79. qadd = (qscale - 1) | 1;
  80. qmul = qscale << 1;
  81. nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
  82. ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
  83. }
  84. av_cold void ff_mpv_common_init_armv5te(MpegEncContext *s)
  85. {
  86. s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_armv5te;
  87. s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_armv5te;
  88. }