Changeset 2734 for pjproject/trunk/pjmedia/src/pjmedia-codec/ipp_codecs.c
- Timestamp:
- Jun 2, 2009 4:28:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/ipp_codecs.c
r2733 r2734 27 27 #include <pj/assert.h> 28 28 #include <pj/log.h> 29 #include <pj/math.h> 29 30 #include <pj/pool.h> 30 31 #include <pj/string.h> … … 1099 1100 amr_settings_t *s; 1100 1101 pj_uint8_t octet_align = 0; 1101 pj_int8_t enc_mode = -1; 1102 pj_int8_t enc_mode; 1103 1104 enc_mode = pjmedia_codec_amr_get_mode( 1105 codec_data->info->params.modes.bitrate); 1106 pj_assert(enc_mode >= 0 && enc_mode <= 8); 1102 1107 1103 1108 /* Check AMR specific attributes */ … … 1119 1124 } 1120 1125 } 1126 1121 1127 for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) { 1122 /* mode-set */ 1128 /* mode-set, encoding mode is chosen based on local default mode 1129 * setting: 1130 * - if local default mode is included in the mode-set, use it 1131 * - otherwise, find the closest mode to local default mode; 1132 * if there are two closest modes, prefer to use the higher 1133 * one, e.g: local default mode is 4, the mode-set param 1134 * contains '2,3,5,6', then 5 will be chosen. 1135 */ 1123 1136 const pj_str_t STR_FMTP_MODE_SET = {"mode-set", 8}; 1124 1137 … … 1128 1141 const char *p; 1129 1142 pj_size_t l; 1130 1131 /* Get the highest value, for better quality. */1143 pj_int8_t diff = 99; 1144 1132 1145 p = pj_strbuf(&attr->setting.enc_fmtp.param[i].val); 1133 1146 l = pj_strlen(&attr->setting.enc_fmtp.param[i].val); 1134 1147 1135 1148 while (l--) { 1136 if ((ippc->pt ==PJMEDIA_RTP_PT_AMR && *p>='0' && *p<='7') ||1137 (ippc->pt ==PJMEDIA_RTP_PT_AMRWB && *p>='0' && *p<='8'))1149 if ((ippc->pt==PJMEDIA_RTP_PT_AMR && *p>='0' && *p<='7') || 1150 (ippc->pt==PJMEDIA_RTP_PT_AMRWB && *p>='0' && *p<='8')) 1138 1151 { 1139 pj_int8_t tmp = *p - '0'; 1140 if (enc_mode < tmp) 1141 enc_mode = tmp; 1152 pj_int8_t tmp = *p - '0' - enc_mode; 1153 1154 if (PJ_ABS(diff) > PJ_ABS(tmp) || 1155 (PJ_ABS(diff) == PJ_ABS(tmp) && tmp > diff)) 1156 { 1157 diff = tmp; 1158 if (diff == 0) break; 1159 } 1142 1160 } 1143 1161 ++p; 1144 1162 } 1163 1164 if (diff == 99) 1165 goto on_error; 1166 1167 enc_mode = enc_mode + diff; 1168 1145 1169 break; 1146 1170 } … … 1160 1184 s->dec_setting.reorder = PJ_TRUE; 1161 1185 1162 if (enc_mode != -1) { 1163 s->enc_mode = enc_mode; 1164 } else { 1165 s->enc_mode = pjmedia_codec_amr_get_mode( 1166 codec_data->info->params.modes.bitrate); 1167 } 1168 1169 if (s->enc_mode < 0) 1170 goto on_error; 1171 1172 /* Apply requested encoder bitrate */ 1186 /* Apply encoder mode/bitrate */ 1187 s->enc_mode = enc_mode; 1173 1188 codec_data->info->params.modes.bitrate = s->enc_setting.amr_nb? 1174 1189 pjmedia_codec_amrnb_bitrates[s->enc_mode]:
Note: See TracChangeset
for help on using the changeset viewer.