mpp_compat.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright 2021 Rockchip Electronics Co. LTD
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #define MODULE_TAG "mpp_compat"
  17. #include "mpp_debug.h"
  18. #include "mpp_common.h"
  19. #include "mpp_compat.h"
  20. #include "mpp_compat_impl.h"
  21. static MppCompat compats[] = {
  22. {
  23. MPP_COMPAT_INC_FBC_BUF_SIZE,
  24. MPP_COMPAT_BOOL,
  25. 1,
  26. #if defined(__ANDROID__)
  27. /*
  28. * The codecs might need extra lines for deblock output, but the
  29. * android world rather risk memory overflow than using the correct
  30. * buf size.
  31. */
  32. 0,
  33. #else
  34. 1,
  35. #endif
  36. "increase decoder fbc buffer size",
  37. &compats[1],
  38. },
  39. {
  40. MPP_COMPAT_ENC_ASYNC_INPUT,
  41. MPP_COMPAT_BOOL,
  42. 1,
  43. 0,
  44. "support encoder async input mode",
  45. NULL,
  46. },
  47. {
  48. MPP_COMPAT_DEC_FBC_HDR_256_ODD,
  49. MPP_COMPAT_BOOL,
  50. 0,
  51. 0,
  52. "set decoder fbc header stride to 256 odd align",
  53. NULL,
  54. },
  55. };
  56. RK_S32 *compat_ext_fbc_buf_size = &compats[MPP_COMPAT_INC_FBC_BUF_SIZE].value_usr;
  57. RK_S32 *compat_ext_async_input = &compats[MPP_COMPAT_ENC_ASYNC_INPUT].value_usr;
  58. RK_S32 *compat_ext_fbc_hdr_256_odd = &compats[MPP_COMPAT_DEC_FBC_HDR_256_ODD].value_usr;
  59. MppCompat *mpp_compat_query(void)
  60. {
  61. return compats;
  62. }
  63. MppCompat *mpp_compat_query_by_id(MppCompatId id)
  64. {
  65. RK_U32 i;
  66. for (i = 0; i < MPP_ARRAY_ELEMS(compats); i++) {
  67. if (compats[i].feature_id == id)
  68. return &compats[i];
  69. }
  70. return NULL;
  71. }
  72. MPP_RET mpp_compat_update(MppCompat *compat, RK_S32 value)
  73. {
  74. if (NULL == compat)
  75. return MPP_NOK;
  76. if (compat->feature_id >= MPP_COMPAT_BUTT)
  77. return MPP_NOK;
  78. if (compat != &compats[compat->feature_id])
  79. return MPP_NOK;
  80. if (compat->feature_type == MPP_COMPAT_BOOL)
  81. if (value != 0 && value != 1)
  82. return MPP_NOK;
  83. compat->value_usr = value;
  84. return MPP_OK;
  85. }
  86. void mpp_compat_show(void)
  87. {
  88. const MppCompat *compat = compats;
  89. mpp_log("id| name -- mpp compat info\n");
  90. while (compat) {
  91. mpp_log("%d | %s\n", compat->feature_id, compat->name);
  92. compat = compat->next;
  93. }
  94. }