Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
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.

mmalomx_marks.c 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /** \file
  26. * OpenMAX IL adaptation layer for MMAL - Marking related functions
  27. *
  28. * Note that we do not support buffer marks properly other than for conformance
  29. * testing. For input ports, we just move the mark over to the output port.
  30. */
  31. #include "mmalomx.h"
  32. #include "mmalomx_buffer.h"
  33. #include "mmalomx_marks.h"
  34. #include "mmalomx_commands.h"
  35. #include "mmalomx_logging.h"
  36. #define MMALOMX_GET_MARK(port, mark) \
  37. mark = &port->marks[port->marks_first]; \
  38. port->marks_num--; \
  39. port->marks_first = ++port->marks_first == MAX_MARKS_NUM ? 0 : port->marks_first
  40. #define MMALOMX_PUT_MARK(port, mark) \
  41. port->marks[(port->marks_first + port->marks_num) % MAX_MARKS_NUM] = *mark; \
  42. port->marks_num++;
  43. void mmalomx_mark_process_incoming(MMALOMX_COMPONENT_T *component,
  44. MMALOMX_PORT_T *port, OMX_BUFFERHEADERTYPE *omx_buffer)
  45. {
  46. /* Tag buffers with OMX marks */
  47. if (!omx_buffer->hMarkTargetComponent && port->marks_num > 0 &&
  48. port->direction == OMX_DirInput)
  49. {
  50. OMX_MARKTYPE *mark;
  51. MMALOMX_GET_MARK(port, mark);
  52. omx_buffer->hMarkTargetComponent = mark->hMarkTargetComponent;
  53. omx_buffer->pMarkData = mark->pMarkData;
  54. mmalomx_callback_event_handler(component, OMX_EventCmdComplete,
  55. OMX_CommandMarkBuffer, port->index, NULL);
  56. }
  57. /* We do not support buffer marks properly other than for conformance testing.
  58. * For input ports, we just move the mark over to the output port. */
  59. if (port->direction == OMX_DirInput && omx_buffer->hMarkTargetComponent)
  60. {
  61. OMX_MARKTYPE mark = {omx_buffer->hMarkTargetComponent, omx_buffer->pMarkData};
  62. unsigned int i;
  63. for (i = 0; i < component->ports_num; i++)
  64. {
  65. if (component->ports[i].direction != OMX_DirOutput ||
  66. component->ports[i].marks_num >= MAX_MARKS_NUM)
  67. continue;
  68. MMALOMX_PUT_MARK((&component->ports[i]), (&mark));
  69. }
  70. }
  71. }
  72. void mmalomx_mark_process_outgoing(MMALOMX_COMPONENT_T *component,
  73. MMALOMX_PORT_T *port, OMX_BUFFERHEADERTYPE *omx_buffer)
  74. {
  75. /* Tag buffers with OMX marks */
  76. if (port->direction == OMX_DirOutput &&
  77. !omx_buffer->hMarkTargetComponent && port->marks_num)
  78. {
  79. OMX_MARKTYPE *mark;
  80. MMALOMX_GET_MARK(port, mark);
  81. omx_buffer->hMarkTargetComponent = mark->hMarkTargetComponent;
  82. omx_buffer->pMarkData = mark->pMarkData;
  83. }
  84. /* Check if we need to trigger a Mark event */
  85. if (omx_buffer->hMarkTargetComponent &&
  86. omx_buffer->hMarkTargetComponent == (OMX_HANDLETYPE)&component->omx)
  87. {
  88. mmalomx_callback_event_handler(component, OMX_EventMark, 0, 0, omx_buffer->pMarkData);
  89. omx_buffer->hMarkTargetComponent = NULL;
  90. omx_buffer->pMarkData = NULL;
  91. }
  92. }