mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cs_set_video_encoder_resolution improvements.
This commit is contained in:
parent
d6da08fe9d
commit
82ba83e526
|
@ -334,7 +334,7 @@ void test_addto_lists(IP ip)
|
|||
for (i = 0; i < dht->num_friends; ++i)
|
||||
test_addto_lists_possible_bad(dht, dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, &ip_port,
|
||||
dht->friends_list[i].client_id);
|
||||
*/
|
||||
*/
|
||||
// check "good" entries
|
||||
test_addto_lists_good(dht, dht->close_clientlist, LCLIENT_LIST, &ip_port, dht->self_public_key);
|
||||
|
||||
|
|
|
@ -270,9 +270,6 @@ static int init_video_encoder(CSSession *cs, uint16_t max_width, uint16_t max_he
|
|||
cfg.kf_max_dist = 48;
|
||||
cfg.kf_mode = VPX_KF_AUTO;
|
||||
|
||||
cs->max_width = max_width;
|
||||
cs->max_height = max_height;
|
||||
|
||||
rc = vpx_codec_enc_init_ver(&cs->v_encoder, VIDEO_CODEC_ENCODER_INTERFACE, &cfg, 0, VPX_ENCODER_ABI_VERSION);
|
||||
|
||||
if ( rc != VPX_CODEC_OK) {
|
||||
|
@ -287,6 +284,10 @@ static int init_video_encoder(CSSession *cs, uint16_t max_width, uint16_t max_he
|
|||
return -1;
|
||||
}
|
||||
|
||||
cs->max_width = max_width;
|
||||
cs->max_height = max_height;
|
||||
cs->video_bitrate = video_bitrate;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -436,8 +437,17 @@ int cs_set_video_encoder_resolution(CSSession *cs, uint16_t width, uint16_t heig
|
|||
if (cfg.g_w == width && cfg.g_h == height)
|
||||
return 0;
|
||||
|
||||
if (width * height > cs->max_width * cs->max_height)
|
||||
return cs_ErrorSettingVideoResolution;
|
||||
if (width * height > cs->max_width * cs->max_height) {
|
||||
vpx_codec_ctx_t v_encoder = cs->v_encoder;
|
||||
|
||||
if (init_video_encoder(cs, width, height, cs->video_bitrate) == -1) {
|
||||
cs->v_encoder = v_encoder;
|
||||
return cs_ErrorSettingVideoResolution;
|
||||
}
|
||||
|
||||
vpx_codec_destroy(&v_encoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOGGER_DEBUG("New video resolution: %u %u", width, height);
|
||||
cfg.g_w = width;
|
||||
|
@ -468,6 +478,7 @@ int cs_set_video_encoder_bitrate(CSSession *cs, uint32_t video_bitrate)
|
|||
return cs_ErrorSettingVideoBitrate;
|
||||
}
|
||||
|
||||
cs->video_bitrate = video_bitrate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ typedef struct _CSSession {
|
|||
vpx_codec_ctx_t v_decoder;
|
||||
int max_width;
|
||||
int max_height;
|
||||
unsigned int video_bitrate;
|
||||
|
||||
|
||||
/* Data handling */
|
||||
|
|
Loading…
Reference in New Issue
Block a user