[Ffmpeg-devel] [PATCH] GSM-MS decoder and encoder

Michel Bardiaux mbardiaux
Sat Feb 17 15:42:52 CET 2007


Michael Niedermayer wrote:
> Hi
> 
> On Wed, Feb 14, 2007 at 03:29:23PM +0100, Michel Bardiaux wrote:
> [...]
> 
>> // gsm.h miss some essential constants
>> #define GSM_BLOCK_SIZE 33
>>+#define GSM_MS_BLOCK_SIZE 65
>> #define GSM_FRAME_SIZE 160
>> 
>> static int libgsm_init(AVCodecContext *avctx) {
>>-    if (avctx->channels > 1 || avctx->sample_rate != 8000)
>>+    if (avctx->channels > 1 || avctx->sample_rate != 8000 || avctx->bit_rate != 13000)
> 
> 
> is 13000 exactly correct isnt it 13200 for CODEC_ID_GSM?

Yes and no. The last 4 bits of each frame are not actually used, they
come on stage only because we (both libgsm and lavc) use a byte-oriented
API, and files made of bytes. They should be considered as container
overhead in TOAST files, hence not part of the codec bitrate.

(A lot of people would have been spared a lot of sweat if ETSI had
simply required these 4 bits as mandatory zero padding, and had
specified the order of bits in bytes, which proves again that common
sense is not an attribute of standardization bodies...)

> [...]
> 
>>@@ -356,6 +357,10 @@
>>         put_le16(pb, 16); /* fwHeadFlags */
>>         put_le32(pb, 0);  /* dwPTSLow */
>>         put_le32(pb, 0);  /* dwPTSHigh */
>>+    } else if (enc->codec_id == CODEC_ID_GSM_MS) {
>>+        put_le16(pb, 2); /* wav_extra_size */
>>+        hdrsize += 2;
>>+        put_le16(pb, 320); /* wSamplesPerBlock */
> 
> 
> isnt this simply avctx->frame_size ? i mean hardcoding 320 looks a little ugly
> unless its really needed ...

Right. Changed that. But then you must be very unhappy about the next
lines in that source:

    } else if (enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
        put_le16(pb, 2); /* wav_extra_size */
        hdrsize += 2;
        put_le16(pb, ((enc->block_align - 4 * enc->channels) / (4 *
enc->channels)) * 8 + 1); /* wSamplesPerBlock */

which duplicate what is in adpcm_encode_init. Should I change them in
another patch (there doesnt seem to be an official maintainer for riff.c)

2 more notes about GSM:

I will contact Jutta Degener to have FFMPEG added to their (Berlin's)
list of applications using GSM.

And I will add the TOAST file format at some point (33-byte frames
stored raw).

Greetings,
-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/




More information about the ffmpeg-devel mailing list