video-frame.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #pragma once
  15. #include "../util/bmem.h"
  16. #include "video-io.h"
  17. struct video_frame {
  18. uint8_t *data[MAX_AV_PLANES];
  19. uint32_t linesize[MAX_AV_PLANES];
  20. };
  21. EXPORT void video_frame_init(struct video_frame *frame,
  22. enum video_format format, uint32_t width, uint32_t height);
  23. static inline void video_frame_free(struct video_frame *frame)
  24. {
  25. if (frame) {
  26. bfree(frame->data[0]);
  27. memset(frame, 0, sizeof(struct video_frame));
  28. }
  29. }
  30. static inline struct video_frame *video_frame_create(
  31. enum video_format format, uint32_t width, uint32_t height)
  32. {
  33. struct video_frame *frame;
  34. frame = (struct video_frame*)bzalloc(sizeof(struct video_frame));
  35. video_frame_init(frame, format, width, height);
  36. return frame;
  37. }
  38. static inline void video_frame_destroy(struct video_frame *frame)
  39. {
  40. if (frame) {
  41. bfree(frame->data[0]);
  42. bfree(frame);
  43. }
  44. }