diff options
author | irungentoo <irungentoo@gmail.com> | 2015-11-03 13:42:05 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-11-03 13:42:05 -0500 |
commit | 6a494e2cbdd146bb13185d8220061322661a5f5a (patch) | |
tree | 6cb23bca09894cde6173bc7a362a112d72872215 /toxav/video.c | |
parent | f435e94397feb3121ef334de6873b93adaaf01dd (diff) |
Astyle.
Diffstat (limited to 'toxav/video.c')
-rw-r--r-- | toxav/video.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/toxav/video.c b/toxav/video.c index acc1852b..8a832201 100644 --- a/toxav/video.c +++ b/toxav/video.c | |||
@@ -207,43 +207,40 @@ int vc_queue_message(void *vcp, struct RTPMessage *msg) | |||
207 | 207 | ||
208 | return 0; | 208 | return 0; |
209 | } | 209 | } |
210 | int vc_reconfigure_encoder(VCSession* vc, uint32_t bit_rate, uint16_t width, uint16_t height) | 210 | int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height) |
211 | { | 211 | { |
212 | if (!vc) | 212 | if (!vc) |
213 | return -1; | 213 | return -1; |
214 | 214 | ||
215 | vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; | 215 | vpx_codec_enc_cfg_t cfg = *vc->encoder->config.enc; |
216 | int rc; | 216 | int rc; |
217 | 217 | ||
218 | if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) | 218 | if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height) |
219 | return 0; /* Nothing changed */ | 219 | return 0; /* Nothing changed */ |
220 | 220 | ||
221 | if (cfg.g_w == width && cfg.g_h == height) | 221 | if (cfg.g_w == width && cfg.g_h == height) { |
222 | { | ||
223 | /* Only bit rate changed */ | 222 | /* Only bit rate changed */ |
224 | cfg.rc_target_bitrate = bit_rate; | 223 | cfg.rc_target_bitrate = bit_rate; |
225 | 224 | ||
226 | rc = vpx_codec_enc_config_set(vc->encoder, &cfg); | 225 | rc = vpx_codec_enc_config_set(vc->encoder, &cfg); |
227 | 226 | ||
228 | if (rc != VPX_CODEC_OK) { | 227 | if (rc != VPX_CODEC_OK) { |
229 | LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); | 228 | LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc)); |
230 | return -1; | 229 | return -1; |
231 | } | 230 | } |
232 | } | 231 | } else { |
233 | else | ||
234 | { | ||
235 | /* Resolution is changed, must reinitialize encoder since libvpx v1.4 doesn't support | 232 | /* Resolution is changed, must reinitialize encoder since libvpx v1.4 doesn't support |
236 | * reconfiguring encoder to use resolutions greater than initially set. | 233 | * reconfiguring encoder to use resolutions greater than initially set. |
237 | */ | 234 | */ |
238 | 235 | ||
239 | LOGGER_DEBUG("Have to reinitialize vpx encoder on session %p", vc); | 236 | LOGGER_DEBUG("Have to reinitialize vpx encoder on session %p", vc); |
240 | 237 | ||
241 | cfg.rc_target_bitrate = bit_rate; | 238 | cfg.rc_target_bitrate = bit_rate; |
242 | cfg.g_w = width; | 239 | cfg.g_w = width; |
243 | cfg.g_h = height; | 240 | cfg.g_h = height; |
244 | 241 | ||
245 | vpx_codec_ctx_t new_c; | 242 | vpx_codec_ctx_t new_c; |
246 | 243 | ||
247 | rc = vpx_codec_enc_init(&new_c, VIDEO_CODEC_ENCODER_INTERFACE, &cfg, 0); | 244 | rc = vpx_codec_enc_init(&new_c, VIDEO_CODEC_ENCODER_INTERFACE, &cfg, 0); |
248 | 245 | ||
249 | if (rc != VPX_CODEC_OK) { | 246 | if (rc != VPX_CODEC_OK) { |
@@ -258,7 +255,7 @@ int vc_reconfigure_encoder(VCSession* vc, uint32_t bit_rate, uint16_t width, uin | |||
258 | vpx_codec_destroy(&new_c); | 255 | vpx_codec_destroy(&new_c); |
259 | return -1; | 256 | return -1; |
260 | } | 257 | } |
261 | 258 | ||
262 | vpx_codec_destroy(vc->encoder); | 259 | vpx_codec_destroy(vc->encoder); |
263 | memcpy(vc->encoder, &new_c, sizeof(new_c)); | 260 | memcpy(vc->encoder, &new_c, sizeof(new_c)); |
264 | } | 261 | } |