Open Broadcaster Software
Free, open source software for live streaming and recording
video-frame.h
Go to the documentation of this file.
1 /******************************************************************************
2  Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17 
18 #pragma once
19 
20 #include "../util/bmem.h"
21 #include "video-io.h"
22 
23 struct video_frame {
24  uint8_t *data[MAX_AV_PLANES];
25  uint32_t linesize[MAX_AV_PLANES];
26 };
27 
28 EXPORT void video_frame_init(struct video_frame *frame,
29  enum video_format format, uint32_t width,
30  uint32_t height);
31 
32 static inline void video_frame_free(struct video_frame *frame)
33 {
34  if (frame) {
35  bfree(frame->data[0]);
36  memset(frame, 0, sizeof(struct video_frame));
37  }
38 }
39 
40 static inline struct video_frame *
41 video_frame_create(enum video_format format, uint32_t width, uint32_t height)
42 {
43  struct video_frame *frame;
44 
45  frame = (struct video_frame *)bzalloc(sizeof(struct video_frame));
46  video_frame_init(frame, format, width, height);
47  return frame;
48 }
49 
50 static inline void video_frame_destroy(struct video_frame *frame)
51 {
52  if (frame) {
53  bfree(frame->data[0]);
54  bfree(frame);
55  }
56 }
57 
58 EXPORT void video_frame_copy(struct video_frame *dst,
59  const struct video_frame *src,
60  enum video_format format, uint32_t height);
video-io.h
video_frame::data
uint8_t * data[MAX_AV_PLANES]
Definition: video-frame.h:39
bfree
EXPORT void bfree(void *ptr)
EXPORT
#define EXPORT
Definition: c99defs.h:37
video_frame::linesize
uint32_t linesize[MAX_AV_PLANES]
Definition: video-frame.h:40
video_frame
Definition: video-frame.h:23
video_format
video_format
Definition: video-io.h:33
MAX_AV_PLANES
#define MAX_AV_PLANES
Definition: media-io-defs.h:20
video_frame_init
EXPORT void video_frame_init(struct video_frame *frame, enum video_format format, uint32_t width, uint32_t height)
video_frame_copy
EXPORT void video_frame_copy(struct video_frame *dst, const struct video_frame *src, enum video_format format, uint32_t height)