video-frame.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include "../util/bmem.h"
  15. #include "video-io.h"
  16. struct video_frame {
  17. uint8_t *data[MAX_AV_PLANES];
  18. uint32_t linesize[MAX_AV_PLANES];
  19. };
  20. EXPORT void video_frame_init(struct video_frame *frame,
  21. enum video_format format, uint32_t width, uint32_t height);
  22. static inline void video_frame_free(struct video_frame *frame)
  23. {
  24. if (frame) {
  25. bfree(frame->data[0]);
  26. memset(frame, 0, sizeof(struct video_frame));
  27. }
  28. }
  29. static inline struct video_frame *video_frame_create(
  30. enum video_format format, uint32_t width, uint32_t height)
  31. {
  32. struct video_frame *frame;
  33. frame = (struct video_frame*)bzalloc(sizeof(struct video_frame));
  34. video_frame_init(frame, format, width, height);
  35. return frame;
  36. }
  37. static inline void video_frame_destroy(struct video_frame *frame)
  38. {
  39. if (frame) {
  40. bfree(frame->data[0]);
  41. bfree(frame);
  42. }
  43. }