Skip to content

Commit 9f2354b

Browse files
authored
sort private functions (#38)
1 parent 0ee4ff3 commit 9f2354b

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

camera.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,6 @@ namespace controls = libcamera::controls;
4646
namespace formats = libcamera::formats;
4747
namespace properties = libcamera::properties;
4848

49-
static const char *heap_positions[] = {
50-
"/dev/dma_heap/vidbuf_cached",
51-
"/dev/dma_heap/linux,cma",
52-
};
53-
54-
// https://github.com/raspberrypi/rpicam-apps/blob/6de1ab6a899df35f929b2a15c0831780bd8e750e/core/dma_heaps.cpp
55-
static int create_dma_allocator() {
56-
for (unsigned int i = 0; i < sizeof(heap_positions) / sizeof(const char *); i++) {
57-
int fd = open(heap_positions[i], O_RDWR | O_CLOEXEC, 0);
58-
if (fd >= 0) {
59-
return fd;
60-
}
61-
}
62-
return -1;
63-
}
64-
6549
static char errbuf[256];
6650

6751
static void set_error(const char *format, ...) {
@@ -74,6 +58,22 @@ const char *camera_get_error() {
7458
return errbuf;
7559
}
7660

61+
// https://github.com/raspberrypi/rpicam-apps/blob/6de1ab6a899df35f929b2a15c0831780bd8e750e/core/dma_heaps.cpp
62+
static int create_dma_allocator() {
63+
static const char *heap_positions[] = {
64+
"/dev/dma_heap/vidbuf_cached",
65+
"/dev/dma_heap/linux,cma",
66+
};
67+
68+
for (unsigned int i = 0; i < sizeof(heap_positions) / sizeof(const char *); i++) {
69+
int fd = open(heap_positions[i], O_RDWR | O_CLOEXEC, 0);
70+
if (fd >= 0) {
71+
return fd;
72+
}
73+
}
74+
return -1;
75+
}
76+
7777
// https://github.com/raspberrypi/libcamera-apps/blob/dd97618a25523c2c4aa58f87af5f23e49aa6069c/core/libcamera_app.cpp#L42
7878
static PixelFormat mode_to_pixel_format(sensor_mode_t *mode) {
7979
static std::vector<std::pair<std::pair<int, bool>, PixelFormat>> table = {
@@ -94,21 +94,6 @@ static PixelFormat mode_to_pixel_format(sensor_mode_t *mode) {
9494
return formats::SBGGR12_CSI2P;
9595
}
9696

97-
struct CameraPriv {
98-
const parameters_t *params;
99-
camera_frame_cb frame_cb;
100-
camera_error_cb error_cb;
101-
std::unique_ptr<CameraManager> camera_manager;
102-
std::shared_ptr<Camera> camera;
103-
Stream *video_stream;
104-
std::vector<std::unique_ptr<Request>> requests;
105-
std::mutex ctrls_mutex;
106-
std::unique_ptr<ControlList> ctrls;
107-
std::vector<std::unique_ptr<FrameBuffer>> frame_buffers;
108-
std::map<FrameBuffer *, uint8_t *> mapped_buffers;
109-
bool in_error;
110-
};
111-
11297
static int get_v4l2_colorspace(std::optional<ColorSpace> const &cs) {
11398
if (cs == ColorSpace::Rec709) {
11499
return V4L2_COLORSPACE_REC709;
@@ -133,6 +118,21 @@ static void set_hdr(bool hdr) {
133118
}
134119
}
135120

121+
struct CameraPriv {
122+
const parameters_t *params;
123+
camera_frame_cb frame_cb;
124+
camera_error_cb error_cb;
125+
std::unique_ptr<CameraManager> camera_manager;
126+
std::shared_ptr<Camera> camera;
127+
Stream *video_stream;
128+
std::vector<std::unique_ptr<Request>> requests;
129+
std::mutex ctrls_mutex;
130+
std::unique_ptr<ControlList> ctrls;
131+
std::vector<std::unique_ptr<FrameBuffer>> frame_buffers;
132+
std::map<FrameBuffer *, uint8_t *> mapped_buffers;
133+
bool in_error;
134+
};
135+
136136
bool camera_create(
137137
const parameters_t *params,
138138
camera_frame_cb frame_cb,

encoder.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ typedef void (*encode_cb)(void *enc, uint8_t *mapped_buffer, int buffer_fd, size
2929

3030
typedef void (*reload_params_cb)(void *enc, const parameters_t *params);
3131

32-
typedef struct {
33-
void *implementation;
34-
encode_cb encode;
35-
reload_params_cb reload_params;
36-
} encoder_priv_t;
37-
3832
static bool supports_hardware_h264() {
3933
int fd = open(ENCODER_HARD_H264_DEVICE, O_RDWR, 0);
4034
if (fd < 0) {
@@ -57,6 +51,12 @@ static bool supports_hardware_h264() {
5751
return false;
5852
}
5953

54+
typedef struct {
55+
void *implementation;
56+
encode_cb encode;
57+
reload_params_cb reload_params;
58+
} encoder_priv_t;
59+
6060
bool encoder_create(const parameters_t *params, int stride, int colorspace, encoder_output_cb output_cb, encoder_t **enc) {
6161
*enc = malloc(sizeof(encoder_priv_t));
6262
encoder_priv_t *encp = (encoder_priv_t *)(*enc);

0 commit comments

Comments
 (0)