mpeg4video.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * MPEG-4 encoder/decoder internal header.
  3. * Copyright (c) 2000,2001 Fabrice Bellard
  4. * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_MPEG4VIDEO_H
  23. #define AVCODEC_MPEG4VIDEO_H
  24. #include <stdint.h>
  25. #include "mpegvideo.h"
  26. void ff_mpeg4_clean_buffers(MpegEncContext *s);
  27. int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s);
  28. void ff_mpeg4_init_direct_mv(MpegEncContext *s);
  29. /**
  30. * @return the mb_type
  31. */
  32. int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
  33. #if 0 //3IV1 is quite rare and it slows things down a tiny bit
  34. #define IS_3IV1 s->codec_tag == AV_RL32("3IV1")
  35. #else
  36. #define IS_3IV1 0
  37. #endif
  38. /**
  39. * Predict the dc.
  40. * @param n block index (0-3 are luma, 4-5 are chroma)
  41. * @param dir_ptr pointer to an integer where the prediction direction will be stored
  42. */
  43. static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr)
  44. {
  45. int a, b, c, wrap, pred;
  46. const int16_t *dc_val;
  47. /* find prediction */
  48. wrap = s->block_wrap[n];
  49. dc_val = s->dc_val[0] + s->block_index[n];
  50. /* B C
  51. * A X
  52. */
  53. a = dc_val[-1];
  54. b = dc_val[-1 - wrap];
  55. c = dc_val[-wrap];
  56. /* outside slice handling (we can't do that by memset as we need the
  57. * dc for error resilience) */
  58. if (s->first_slice_line && n != 3) {
  59. if (n != 2)
  60. b = c = 1024;
  61. if (n != 1 && s->mb_x == s->resync_mb_x)
  62. b = a = 1024;
  63. }
  64. if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1) {
  65. if (n == 0 || n == 4 || n == 5)
  66. b = 1024;
  67. }
  68. if (abs(a - b) < abs(b - c)) {
  69. pred = c;
  70. *dir_ptr = 1; /* top */
  71. } else {
  72. pred = a;
  73. *dir_ptr = 0; /* left */
  74. }
  75. return pred;
  76. }
  77. #endif /* AVCODEC_MPEG4VIDEO_H */