error_resilience.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_ERROR_RESILIENCE_H
  19. #define AVCODEC_ERROR_RESILIENCE_H
  20. #include <stdint.h>
  21. #include <stdatomic.h>
  22. #include "avcodec.h"
  23. #include "me_cmp.h"
  24. #include "thread.h"
  25. ///< current MB is the first after a resync marker
  26. #define VP_START 1
  27. #define ER_AC_ERROR 2
  28. #define ER_DC_ERROR 4
  29. #define ER_MV_ERROR 8
  30. #define ER_AC_END 16
  31. #define ER_DC_END 32
  32. #define ER_MV_END 64
  33. #define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)
  34. #define ER_MB_END (ER_AC_END|ER_DC_END|ER_MV_END)
  35. typedef struct ERPicture {
  36. AVFrame *f;
  37. ThreadFrame *tf;
  38. // it is the caller's responsibility to allocate these buffers
  39. int16_t (*motion_val[2])[2];
  40. int8_t *ref_index[2];
  41. uint32_t *mb_type;
  42. int field_picture;
  43. } ERPicture;
  44. typedef struct ERContext {
  45. AVCodecContext *avctx;
  46. MECmpContext mecc;
  47. int mecc_inited;
  48. int *mb_index2xy;
  49. int mb_num;
  50. int mb_width, mb_height;
  51. ptrdiff_t mb_stride;
  52. ptrdiff_t b8_stride;
  53. atomic_int error_count;
  54. int error_occurred;
  55. uint8_t *error_status_table;
  56. uint8_t *er_temp_buffer;
  57. int16_t *dc_val[3];
  58. uint8_t *mbskip_table;
  59. uint8_t *mbintra_table;
  60. int mv[2][4][2];
  61. ERPicture cur_pic;
  62. ERPicture last_pic;
  63. ERPicture next_pic;
  64. AVBufferRef *ref_index_buf[2];
  65. AVBufferRef *motion_val_buf[2];
  66. uint16_t pp_time;
  67. uint16_t pb_time;
  68. int quarter_sample;
  69. int partitioned_frame;
  70. int ref_count;
  71. void (*decode_mb)(void *opaque, int ref, int mv_dir, int mv_type,
  72. int (*mv)[2][4][2],
  73. int mb_x, int mb_y, int mb_intra, int mb_skipped);
  74. void *opaque;
  75. } ERContext;
  76. void ff_er_frame_start(ERContext *s);
  77. void ff_er_frame_end(ERContext *s);
  78. void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy,
  79. int status);
  80. #endif /* AVCODEC_ERROR_RESILIENCE_H */