onyxd_int.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VP8_DECODER_ONYXD_INT_H_
  11. #define VP8_DECODER_ONYXD_INT_H_
  12. #include "vpx_config.h"
  13. #include "vp8/common/onyxd.h"
  14. #include "treereader.h"
  15. #include "vp8/common/onyxc_int.h"
  16. #include "vp8/common/threading.h"
  17. #if CONFIG_ERROR_CONCEALMENT
  18. #include "ec_types.h"
  19. #endif
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. typedef struct
  24. {
  25. int ithread;
  26. void *ptr1;
  27. void *ptr2;
  28. } DECODETHREAD_DATA;
  29. typedef struct
  30. {
  31. MACROBLOCKD mbd;
  32. } MB_ROW_DEC;
  33. typedef struct
  34. {
  35. int enabled;
  36. unsigned int count;
  37. const unsigned char *ptrs[MAX_PARTITIONS];
  38. unsigned int sizes[MAX_PARTITIONS];
  39. } FRAGMENT_DATA;
  40. #define MAX_FB_MT_DEC 32
  41. struct frame_buffers
  42. {
  43. /*
  44. * this struct will be populated with frame buffer management
  45. * info in future commits. */
  46. /* enable/disable frame-based threading */
  47. int use_frame_threads;
  48. /* decoder instances */
  49. struct VP8D_COMP *pbi[MAX_FB_MT_DEC];
  50. };
  51. typedef struct VP8D_COMP
  52. {
  53. DECLARE_ALIGNED(16, MACROBLOCKD, mb);
  54. YV12_BUFFER_CONFIG *dec_fb_ref[NUM_YV12_BUFFERS];
  55. DECLARE_ALIGNED(16, VP8_COMMON, common);
  56. /* the last partition will be used for the modes/mvs */
  57. vp8_reader mbc[MAX_PARTITIONS];
  58. VP8D_CONFIG oxcf;
  59. FRAGMENT_DATA fragments;
  60. #if CONFIG_MULTITHREAD
  61. /* variable for threading */
  62. int b_multithreaded_rd;
  63. int max_threads;
  64. int current_mb_col_main;
  65. unsigned int decoding_thread_count;
  66. int allocated_decoding_thread_count;
  67. int mt_baseline_filter_level[MAX_MB_SEGMENTS];
  68. int sync_range;
  69. int *mt_current_mb_col; /* Each row remembers its already decoded column. */
  70. pthread_mutex_t *pmutex;
  71. pthread_mutex_t mt_mutex; /* mutex for b_multithreaded_rd */
  72. unsigned char **mt_yabove_row; /* mb_rows x width */
  73. unsigned char **mt_uabove_row;
  74. unsigned char **mt_vabove_row;
  75. unsigned char **mt_yleft_col; /* mb_rows x 16 */
  76. unsigned char **mt_uleft_col; /* mb_rows x 8 */
  77. unsigned char **mt_vleft_col; /* mb_rows x 8 */
  78. MB_ROW_DEC *mb_row_di;
  79. DECODETHREAD_DATA *de_thread_data;
  80. pthread_t *h_decoding_thread;
  81. sem_t *h_event_start_decoding;
  82. sem_t h_event_end_decoding;
  83. /* end of threading data */
  84. #endif
  85. int64_t last_time_stamp;
  86. int ready_for_new_data;
  87. vp8_prob prob_intra;
  88. vp8_prob prob_last;
  89. vp8_prob prob_gf;
  90. vp8_prob prob_skip_false;
  91. #if CONFIG_ERROR_CONCEALMENT
  92. MB_OVERLAP *overlaps;
  93. /* the mb num from which modes and mvs (first partition) are corrupt */
  94. unsigned int mvs_corrupt_from_mb;
  95. #endif
  96. int ec_enabled;
  97. int ec_active;
  98. int decoded_key_frame;
  99. int independent_partitions;
  100. int frame_corrupt_residual;
  101. vpx_decrypt_cb decrypt_cb;
  102. void *decrypt_state;
  103. } VP8D_COMP;
  104. int vp8_decode_frame(VP8D_COMP *cpi);
  105. int vp8_create_decoder_instances(struct frame_buffers *fb, VP8D_CONFIG *oxcf);
  106. int vp8_remove_decoder_instances(struct frame_buffers *fb);
  107. #if CONFIG_DEBUG
  108. #define CHECK_MEM_ERROR(lval,expr) do {\
  109. lval = (expr); \
  110. if(!lval) \
  111. vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
  112. "Failed to allocate "#lval" at %s:%d", \
  113. __FILE__,__LINE__);\
  114. } while(0)
  115. #else
  116. #define CHECK_MEM_ERROR(lval,expr) do {\
  117. lval = (expr); \
  118. if(!lval) \
  119. vpx_internal_error(&pbi->common.error, VPX_CODEC_MEM_ERROR,\
  120. "Failed to allocate "#lval);\
  121. } while(0)
  122. #endif
  123. #ifdef __cplusplus
  124. } // extern "C"
  125. #endif
  126. #endif // VP8_DECODER_ONYXD_INT_H_