]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Wed, 1 Dec 1999 19:46:33 +0100 (CET)
authorJaroslav Kysela <perex@perex.cz>
Wed, 1 Dec 1999 19:44:14 +0000 (19:44 +0000)
committerJaroslav Kysela <perex@perex.cz>
Wed, 1 Dec 1999 19:44:14 +0000 (19:44 +0000)
Uros Bizjak <uros@kss-loka.si>
  Included in this message, you will find a diff to alsa-lib, which
implements g721 adpcm codec. It works well (only consumes a lot of CPU),
and it plays back the same data as is recorded.

  Also added is CSP patch, which adds noise suppression when CSP is
started or stopped (A few TODOs less :) Also changed is copyright for
mulaw, alaw and adpcm codecs (Based on sun implementation ... + I added
myself - if you don't mind. Please check this copyright, if it is OK)

include/pcm.h
src/pcm/pcm_plugin.c
src/pcm/plugin/Makefile.am
src/pcm/plugin/alaw.c

index c4fb558dec7ebe60f0e698527bd36e25017e1760..00f8c3a2afd401c0e36fd6a9aec0c365ec7f4a3c 100644 (file)
@@ -126,6 +126,7 @@ int snd_pcm_plugin_build_interleave(int src_interleave, int dst_interleave, int
 int snd_pcm_plugin_build_linear(int src_format, int dst_format, snd_pcm_plugin_t **r_plugin);
 int snd_pcm_plugin_build_mulaw(int src_format, int dst_format, snd_pcm_plugin_t **r_plugin);
 int snd_pcm_plugin_build_alaw(int src_format, int dst_format, snd_pcm_plugin_t **r_plugin);
+int snd_pcm_plugin_build_adpcm(int src_format, int dst_format, snd_pcm_plugin_t **r_plugin);
 int snd_pcm_plugin_build_rate(int src_format, int src_rate, int src_voices,
                              int dst_format, int dst_rate, int dst_voices,
                              snd_pcm_plugin_t **r_plugin);
index d368b6061032a79e79fd60c9c6066857e250e3d7..ce3cc17412fdbd58619fc5f2da13dd4363b5abfb 100644 (file)
@@ -248,7 +248,7 @@ double snd_pcm_plugin_hardware_ratio(snd_pcm_t *pcm, int channel)
 
 static unsigned int snd_pcm_plugin_formats(snd_pcm_t *pcm, unsigned int formats)
 {
-       formats |= SND_PCM_FMT_MU_LAW | SND_PCM_FMT_A_LAW;
+       formats |= SND_PCM_FMT_MU_LAW | SND_PCM_FMT_A_LAW | SND_PCM_FMT_IMA_ADPCM;
        if (formats & (SND_PCM_FMT_U8|SND_PCM_FMT_S8|
                       SND_PCM_FMT_U16_LE|SND_PCM_FMT_S16_LE))
                formats |= SND_PCM_FMT_U8|SND_PCM_FMT_S8|
@@ -393,6 +393,18 @@ int snd_pcm_plugin_params(snd_pcm_t *pcm, snd_pcm_channel_params_t *params)
                        } else {
                                return -EINVAL;
                        }
+               case SND_PCM_SFMT_IMA_ADPCM:
+                       if (sinfo.formats & SND_PCM_FMT_S16_LE) {
+                               sparams.format.format = SND_PCM_SFMT_S16_LE;
+                       } else if (sinfo.formats & SND_PCM_FMT_U16_LE) {
+                               sparams.format.format = SND_PCM_SFMT_U16_LE;
+                       } else if (sinfo.formats & SND_PCM_FMT_S8) {
+                               sparams.format.format = SND_PCM_SFMT_S8;
+                       } else if (sinfo.formats & SND_PCM_FMT_U8) {
+                               sparams.format.format = SND_PCM_SFMT_U8;
+                       } else {
+                               return -EINVAL;
+                       }
                        break;
                default:
                        return -EINVAL;
@@ -449,6 +461,12 @@ int snd_pcm_plugin_params(snd_pcm_t *pcm, snd_pcm_channel_params_t *params)
                swap_formats(params->channel, &srcfmt, &dstfmt);
                err = snd_pcm_plugin_build_alaw(srcfmt, dstfmt, &plugin);
                break;
+       case SND_PCM_SFMT_IMA_ADPCM:
+               srcfmt = SND_PCM_SFMT_IMA_ADPCM;
+               dstfmt = sparams.format.format;
+               swap_formats(params->channel, &srcfmt, &dstfmt);
+               err = snd_pcm_plugin_build_adpcm(srcfmt, dstfmt, &plugin);
+               break;
        default:
                srcfmt = params->format.format;
                dstfmt = sparams.format.format;
index 6e2adcd9457341e45b824898bfe5f2b7004fa006..0902e65638d025d85ad92deb071efb962524fec7 100644 (file)
@@ -1,7 +1,7 @@
 EXTRA_LTLIBRARIES = libpcmplugin.la
 
 libpcmplugin_la_SOURCES = block.c mmap.c stream.c linear.c interleave.c \
-                         mulaw.c alaw.c rate.c voices.c
+                         mulaw.c alaw.c adpcm.c rate.c voices.c
 all: libpcmplugin.la
 
 
index 0e1554b715d985bee75061a59154eb947f588eb7..0f1ef8bb3d59f52fe5801f20cd97aafea8db9499 100644 (file)
@@ -1,8 +1,9 @@
 /*
  *  A-Law conversion Plug-In Interface
  *  Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
- *   Portions (c) by Sun Microsystems, Inc.
+ *                        Uros Bizjak <uros@kss-loka.si>
  *
+ *  Based on reference implementation by Sun Microsystems, Inc.
  *
  *   This library is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU Library General Public License as