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.

71 lines
2.7KB

  1. /*
  2. * H.264 IDCT
  3. * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. */
  20. /**
  21. * @file h264-idct.c
  22. * H.264 IDCT.
  23. * @author Michael Niedermayer <michaelni@gmx.at>
  24. */
  25. #include "dsputil.h"
  26. static always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){
  27. int i;
  28. uint8_t *cm = cropTbl + MAX_NEG_CROP;
  29. block[0] += 1<<(shift-1);
  30. for(i=0; i<4; i++){
  31. const int z0= block[0 + block_stride*i] + block[2 + block_stride*i];
  32. const int z1= block[0 + block_stride*i] - block[2 + block_stride*i];
  33. const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i];
  34. const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1);
  35. block[0 + block_stride*i]= z0 + z3;
  36. block[1 + block_stride*i]= z1 + z2;
  37. block[2 + block_stride*i]= z1 - z2;
  38. block[3 + block_stride*i]= z0 - z3;
  39. }
  40. for(i=0; i<4; i++){
  41. const int z0= block[i + block_stride*0] + block[i + block_stride*2];
  42. const int z1= block[i + block_stride*0] - block[i + block_stride*2];
  43. const int z2= (block[i + block_stride*1]>>1) - block[i + block_stride*3];
  44. const int z3= block[i + block_stride*1] + (block[i + block_stride*3]>>1);
  45. dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ];
  46. dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ];
  47. dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ];
  48. dst[i + 3*stride]= cm[ add*dst[i + 3*stride] + ((z0 - z3) >> shift) ];
  49. }
  50. }
  51. void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride){
  52. idct_internal(dst, block, stride, 4, 6, 1);
  53. }
  54. void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block){
  55. idct_internal(dst, block, stride, 8, 3, 1);
  56. }
  57. void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block){
  58. idct_internal(dst, block, stride, 8, 3, 0);
  59. }