Merge changes from team/russell/g722-sillyness ...

Fix a number of other places where the number of samples in a G722 frame was
not properly handled because of various reasons.

main/rtp.c:
 - When a G722 frame is read from the smoother, the number of samples in the
   frame must be divided by 2 before being sent out over the network.  Even
   though G722 is 16 kHz, an error in some previous spec has made it so that
   we have to list the number of samples such as if it was 8 kHz.

main/file.c:
 - When scheduling the next time to expect a frame, take into account that the
   format of the file we're reading from may not be 8 kHz.

codecs/codec_g722.c:
 - When converting from G722 to slinear, g722_decode() expects its samples
   parameter to be in the silly (real samples / 2) format.  Make it so.
 - When converting from slinear to G722, properly set the number of samples in
   the frame to be the number of bytes of output * 2.

formats/format_pcm.c:
 - This format module handles G722, among a number of other formats.  However,
   the read() and seek() functions did not account for the fact that G722 has
   2 samples per byte.

(closes issue #12130, reported by rickross, patched by me)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@106501 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2008-03-07 00:24:58 +00:00
parent 49ef635a6d
commit 5ca5d97673
4 changed files with 36 additions and 13 deletions

View File

@@ -102,9 +102,13 @@ static int g722tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
{
struct g722_decoder_pvt *tmp = pvt->pvt;
int out_samples;
int in_samples;
/* g722_decode expects the samples to be in the invalid samples / 2 format */
in_samples = f->samples / 2;
out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)],
(uint8_t *) f->data, f->samples);
(uint8_t *) f->data, in_samples);
pvt->samples += out_samples;
@@ -121,7 +125,7 @@ static int lintog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
outlen = g722_encode(&tmp->g722, (uint8_t *) (&pvt->outbuf[pvt->datalen]),
(int16_t *) f->data, f->samples);
pvt->samples += outlen;
pvt->samples += outlen * 2;
pvt->datalen += outlen;