video-frame.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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,
  23. uint32_t height);
  24. static inline void video_frame_free(struct video_frame *frame)
  25. {
  26. if (frame) {
  27. bfree(frame->data[0]);
  28. memset(frame, 0, sizeof(struct video_frame));
  29. }
  30. }
  31. static inline struct video_frame *
  32. video_frame_create(enum video_format format, uint32_t width, uint32_t height)
  33. {
  34. struct video_frame *frame;
  35. frame = (struct video_frame *)bzalloc(sizeof(struct video_frame));
  36. video_frame_init(frame, format, width, height);
  37. return frame;
  38. }
  39. static inline void video_frame_destroy(struct video_frame *frame)
  40. {
  41. if (frame) {
  42. bfree(frame->data[0]);
  43. bfree(frame);
  44. }
  45. }
  46. EXPORT void video_frame_copy(struct video_frame *dst,
  47. const struct video_frame *src,
  48. enum video_format format, uint32_t height);