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.

112 lines
3.6KB

  1. /*
  2. * Mpeg video formats-related defines and utility functions
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_MPEGPICTURE_H
  21. #define AVCODEC_MPEGPICTURE_H
  22. #include <stdint.h>
  23. #include "libavutil/frame.h"
  24. #include "avcodec.h"
  25. #include "motion_est.h"
  26. #include "thread.h"
  27. #define MAX_PICTURE_COUNT 32
  28. #define EDGE_WIDTH 16
  29. typedef struct ScratchpadContext {
  30. uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data
  31. uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision
  32. uint8_t *obmc_scratchpad;
  33. uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers
  34. } ScratchpadContext;
  35. /**
  36. * Picture.
  37. */
  38. typedef struct Picture {
  39. struct AVFrame *f;
  40. ThreadFrame tf;
  41. AVBufferRef *qscale_table_buf;
  42. int8_t *qscale_table;
  43. AVBufferRef *motion_val_buf[2];
  44. int16_t (*motion_val[2])[2];
  45. AVBufferRef *mb_type_buf;
  46. uint32_t *mb_type; ///< types and macros are defined in mpegutils.h
  47. AVBufferRef *mbskip_table_buf;
  48. uint8_t *mbskip_table;
  49. AVBufferRef *ref_index_buf[2];
  50. int8_t *ref_index[2];
  51. AVBufferRef *mb_var_buf;
  52. uint16_t *mb_var; ///< Table for MB variances
  53. AVBufferRef *mc_mb_var_buf;
  54. uint16_t *mc_mb_var; ///< Table for motion compensated MB variances
  55. AVBufferRef *mb_mean_buf;
  56. uint8_t *mb_mean; ///< Table for MB luminance
  57. AVBufferRef *hwaccel_priv_buf;
  58. void *hwaccel_picture_private; ///< Hardware accelerator private data
  59. int field_picture; ///< whether or not the picture was encoded in separate fields
  60. int mb_var_sum; ///< sum of MB variance for current frame
  61. int mc_mb_var_sum; ///< motion compensated MB variance for current frame
  62. int b_frame_score; /* */
  63. int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change)
  64. int reference;
  65. int shared;
  66. uint64_t encoding_error[4];
  67. } Picture;
  68. /**
  69. * Allocate a Picture.
  70. * The pixels are allocated/set by calling get_buffer() if shared = 0.
  71. */
  72. int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me,
  73. ScratchpadContext *sc, int shared, int encoding,
  74. int chroma_x_shift, int chroma_y_shift, int out_format,
  75. int mb_stride, int mb_height, int b8_stride,
  76. ptrdiff_t *linesize, ptrdiff_t *uvlinesize);
  77. int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
  78. ScratchpadContext *sc, int linesize);
  79. int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src);
  80. void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture);
  81. void ff_free_picture_tables(Picture *pic);
  82. int ff_update_picture_tables(Picture *dst, Picture *src);
  83. int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared);
  84. #endif /* AVCODEC_MPEGPICTURE_H */