TT#35456 fix regression from 895fa9605

Adding a fixed length to the size of the buffer requested from the
packetizer was wrong, as this is not just the length of the working
buffer but also the size of the buffer to be returned for sample stream
(PCM) codecs. Instead, use the codec definition's bit per sample spec
to make AMR provide a larger buffer than the bare frame.

Change-Id: Ibff59b21d491e3327cc9e907e6515379a8ca9188
changes/55/21255/1
Richard Fuchs 8 years ago
parent 7de16e104c
commit 5c3d39748b

@ -651,7 +651,6 @@ static int __packet_encoded(encoder_t *enc, void *u1, void *u2) {
while (1) {
// figure out how big of a buffer we need
unsigned int payload_len = MAX(enc->avpkt.size, ch->bytes_per_packet);
payload_len += 16; // extra room for certain protocols, e.g. AMR framing
unsigned int pkt_len = sizeof(struct rtp_header) + payload_len + RTP_BUFFER_TAIL_ROOM;
// prepare our buffers
char *buf = malloc(pkt_len);

@ -312,6 +312,7 @@ static codec_def_t __codec_defs[] = {
.default_ptime = 20,
.default_fmtp = "octet-align=1",
.packetizer = packetizer_amr,
.bits_per_sample = 2, // max is 12200 / 8000 = 1.525 bits per sample, rounded up
.media_type = MT_AUDIO,
.codec_type = &codec_type_amr,
.set_enc_options = amr_set_enc_options,
@ -327,6 +328,7 @@ static codec_def_t __codec_defs[] = {
.default_ptime = 20,
.default_fmtp = "octet-align=1",
.packetizer = packetizer_amr,
.bits_per_sample = 2, // max is 23850 / 16000 = 1.490625 bits per sample, rounded up
.media_type = MT_AUDIO,
.codec_type = &codec_type_amr,
.set_enc_options = amr_set_enc_options,

Loading…
Cancel
Save