diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 19:12:19 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 20:04:16 +0100 |
commit | 633da98ae69866efb195e00d9a3a22ace6bada66 (patch) | |
tree | 875535f3d2257c4ea5bb97a553b2f1beab4a1590 /toxav/video.c | |
parent | 6356eb4e4fe407fa7870f2a685d0d08b5c2ec5bb (diff) |
Add braces to all if statements.
Diffstat (limited to 'toxav/video.c')
-rw-r--r-- | toxav/video.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/toxav/video.c b/toxav/video.c index 300eb377..c94579a6 100644 --- a/toxav/video.c +++ b/toxav/video.c | |||
@@ -51,8 +51,9 @@ VCSession *vc_new(Logger *log, ToxAV *av, uint32_t friend_number, toxav_video_re | |||
51 | return NULL; | 51 | return NULL; |
52 | } | 52 | } |
53 | 53 | ||
54 | if (!(vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE))) | 54 | if (!(vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE))) { |
55 | goto BASE_CLEANUP; | 55 | goto BASE_CLEANUP; |
56 | } | ||
56 | 57 | ||
57 | int rc = vpx_codec_dec_init(vc->decoder, VIDEO_CODEC_DECODER_INTERFACE, NULL, 0); | 58 | int rc = vpx_codec_dec_init(vc->decoder, VIDEO_CODEC_DECODER_INTERFACE, NULL, 0); |
58 | 59 | ||
@@ -118,16 +119,18 @@ BASE_CLEANUP: | |||
118 | } | 119 | } |
119 | void vc_kill(VCSession *vc) | 120 | void vc_kill(VCSession *vc) |
120 | { | 121 | { |
121 | if (!vc) | 122 | if (!vc) { |
122 | return; | 123 | return; |
124 | } | ||
123 | 125 | ||
124 | vpx_codec_destroy(vc->encoder); | 126 | vpx_codec_destroy(vc->encoder); |
125 | vpx_codec_destroy(vc->decoder); | 127 | vpx_codec_destroy(vc->decoder); |
126 | 128 | ||
127 | void *p; | 129 | void *p; |
128 | 130 | ||
129 | while (rb_read(vc->vbuf_raw, (void **)&p)) | 131 | while (rb_read(vc->vbuf_raw, (void **)&p)) { |
130 | free(p); | 132 | free(p); |
133 | } | ||
131 | 134 | ||
132 | rb_kill(vc->vbuf_raw); | 135 | rb_kill(vc->vbuf_raw); |
133 | 136 | ||
@@ -138,8 +141,9 @@ void vc_kill(VCSession *vc) | |||
138 | } | 141 | } |
139 | void vc_iterate(VCSession *vc) | 142 | void vc_iterate(VCSession *vc) |
140 | { | 143 | { |
141 | if (!vc) | 144 | if (!vc) { |
142 | return; | 145 | return; |
146 | } | ||
143 | 147 | ||
144 | struct RTPMessage *p; | 148 | struct RTPMessage *p; |
145 | int rc; | 149 | int rc; |
@@ -152,18 +156,19 @@ void vc_iterate(VCSession *vc) | |||
152 | rc = vpx_codec_decode(vc->decoder, p->data, p->len, NULL, MAX_DECODE_TIME_US); | 156 | rc = vpx_codec_decode(vc->decoder, p->data, p->len, NULL, MAX_DECODE_TIME_US); |
153 | free(p); | 157 | free(p); |
154 | 158 | ||
155 | if (rc != VPX_CODEC_OK) | 159 | if (rc != VPX_CODEC_OK) { |
156 | LOGGER_ERROR(vc->log, "Error decoding video: %s", vpx_codec_err_to_string(rc)); | 160 | LOGGER_ERROR(vc->log, "Error decoding video: %s", vpx_codec_err_to_string(rc)); |
157 | else { | 161 | } else { |
158 | vpx_codec_iter_t iter = NULL; | 162 | vpx_codec_iter_t iter = NULL; |
159 | vpx_image_t *dest = vpx_codec_get_frame(vc->decoder, &iter); | 163 | vpx_image_t *dest = vpx_codec_get_frame(vc->decoder, &iter); |
160 | 164 | ||
161 | /* Play decoded images */ | 165 | /* Play decoded images */ |
162 | for (; dest; dest = vpx_codec_get_frame(vc->decoder, &iter)) { | 166 | for (; dest; dest = vpx_codec_get_frame(vc->decoder, &iter)) { |
163 | if (vc->vcb.first) | 167 | if (vc->vcb.first) { |
164 | vc->vcb.first(vc->av, vc->friend_number, dest->d_w, dest->d_h, | 168 | vc->vcb.first(vc->av, vc->friend_number, dest->d_w, dest->d_h, |
165 | (const uint8_t *)dest->planes[0], (const uint8_t *)dest->planes[1], (const uint8_t *)dest->planes[2], | 169 | (const uint8_t *)dest->planes[0], (const uint8_t *)dest->planes[1], (const uint8_t *)dest->planes[2], |
166 | dest->stride[0], dest->stride[1], dest->stride[2], vc->vcb.second); | 170 | dest->stride[0], dest->stride[1], dest->stride[2], vc->vcb.second); |
171 | } | ||
167 | 172 | ||
168 | vpx_img_free(dest); | 173 | vpx_img_free(dest); |
169 | } | 174 | } |
@@ -179,8 +184,9 @@ int vc_queue_message(void *vcp, struct RTPMessage *msg) | |||
179 | /* This function does the reconstruction of video packets. | 184 | /* This function does the reconstruction of video packets. |
180 | * See more info about video splitting in docs | 185 | * See more info about video splitting in docs |
181 | */ | 186 | */ |
182 | if (!vcp || !msg) | 187 | if (!vcp || !msg) { |
183 | return -1; | 188 | return -1; |
189 | } | ||
184 | 190 | ||
185 | VCSession *vc = vcp; | 191 | VCSession *vc = vcp; |
186 | 192 | ||
@@ -210,14 +216,16 @@ int vc_queue_message(void *vcp, struct RTPMessage *msg) | |||
210 | } | 216 | } |
211 | int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height) | 217 | int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height) |
212 | { | 218 | { |
213 | if (!vc) | 219 | if (!vc) { |
214 | return -1; | 220 | return -1; |
221 | } | ||
215 | 222 | ||
216 | vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; | 223 | vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; |
217 | int rc; | 224 | int rc; |
218 | 225 | ||
219 | if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) | 226 | if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) { |
220 | return 0; /* Nothing changed */ | 227 | return 0; /* Nothing changed */ |
228 | } | ||
221 | 229 | ||
222 | if (cfg.g_w == width && cfg.g_h == height) { | 230 | if (cfg.g_w == width && cfg.g_h == height) { |
223 | /* Only bit rate changed */ | 231 | /* Only bit rate changed */ |