The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/sound/pcm/feeder_fmt.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 #include <dev/sound/pcm/sound.h>
   28 
   29 #include "feeder_if.h"
   30 
   31 SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/feeder_fmt.c,v 1.13.4.1 2005/01/30 01:00:05 imp Exp $");
   32 
   33 MALLOC_DEFINE(M_FMTFEEDER, "fmtfeed", "pcm format feeder");
   34 
   35 #define FEEDBUFSZ       8192
   36 
   37 static unsigned char ulaw_to_u8[] = {
   38      3,    7,   11,   15,   19,   23,   27,   31,
   39     35,   39,   43,   47,   51,   55,   59,   63,
   40     66,   68,   70,   72,   74,   76,   78,   80,
   41     82,   84,   86,   88,   90,   92,   94,   96,
   42     98,   99,  100,  101,  102,  103,  104,  105,
   43    106,  107,  108,  109,  110,  111,  112,  113,
   44    113,  114,  114,  115,  115,  116,  116,  117,
   45    117,  118,  118,  119,  119,  120,  120,  121,
   46    121,  121,  122,  122,  122,  122,  123,  123,
   47    123,  123,  124,  124,  124,  124,  125,  125,
   48    125,  125,  125,  125,  126,  126,  126,  126,
   49    126,  126,  126,  126,  127,  127,  127,  127,
   50    127,  127,  127,  127,  127,  127,  127,  127,
   51    128,  128,  128,  128,  128,  128,  128,  128,
   52    128,  128,  128,  128,  128,  128,  128,  128,
   53    128,  128,  128,  128,  128,  128,  128,  128,
   54    253,  249,  245,  241,  237,  233,  229,  225,
   55    221,  217,  213,  209,  205,  201,  197,  193,
   56    190,  188,  186,  184,  182,  180,  178,  176,
   57    174,  172,  170,  168,  166,  164,  162,  160,
   58    158,  157,  156,  155,  154,  153,  152,  151,
   59    150,  149,  148,  147,  146,  145,  144,  143,
   60    143,  142,  142,  141,  141,  140,  140,  139,
   61    139,  138,  138,  137,  137,  136,  136,  135,
   62    135,  135,  134,  134,  134,  134,  133,  133,
   63    133,  133,  132,  132,  132,  132,  131,  131,
   64    131,  131,  131,  131,  130,  130,  130,  130,
   65    130,  130,  130,  130,  129,  129,  129,  129,
   66    129,  129,  129,  129,  129,  129,  129,  129,
   67    128,  128,  128,  128,  128,  128,  128,  128,
   68    128,  128,  128,  128,  128,  128,  128,  128,
   69    128,  128,  128,  128,  128,  128,  128,  128,
   70 };
   71 
   72 static unsigned char u8_to_ulaw[] = {
   73      0,    0,    0,    0,    0,    1,    1,    1,
   74      1,    2,    2,    2,    2,    3,    3,    3,
   75      3,    4,    4,    4,    4,    5,    5,    5,
   76      5,    6,    6,    6,    6,    7,    7,    7,
   77      7,    8,    8,    8,    8,    9,    9,    9,
   78      9,   10,   10,   10,   10,   11,   11,   11,
   79     11,   12,   12,   12,   12,   13,   13,   13,
   80     13,   14,   14,   14,   14,   15,   15,   15,
   81     15,   16,   16,   17,   17,   18,   18,   19,
   82     19,   20,   20,   21,   21,   22,   22,   23,
   83     23,   24,   24,   25,   25,   26,   26,   27,
   84     27,   28,   28,   29,   29,   30,   30,   31,
   85     31,   32,   33,   34,   35,   36,   37,   38,
   86     39,   40,   41,   42,   43,   44,   45,   46,
   87     47,   49,   51,   53,   55,   57,   59,   61,
   88     63,   66,   70,   74,   78,   84,   92,  104,
   89    254,  231,  219,  211,  205,  201,  197,  193,
   90    190,  188,  186,  184,  182,  180,  178,  176,
   91    175,  174,  173,  172,  171,  170,  169,  168,
   92    167,  166,  165,  164,  163,  162,  161,  160,
   93    159,  159,  158,  158,  157,  157,  156,  156,
   94    155,  155,  154,  154,  153,  153,  152,  152,
   95    151,  151,  150,  150,  149,  149,  148,  148,
   96    147,  147,  146,  146,  145,  145,  144,  144,
   97    143,  143,  143,  143,  142,  142,  142,  142,
   98    141,  141,  141,  141,  140,  140,  140,  140,
   99    139,  139,  139,  139,  138,  138,  138,  138,
  100    137,  137,  137,  137,  136,  136,  136,  136,
  101    135,  135,  135,  135,  134,  134,  134,  134,
  102    133,  133,  133,  133,  132,  132,  132,  132,
  103    131,  131,  131,  131,  130,  130,  130,  130,
  104    129,  129,  129,  129,  128,  128,  128,  128,
  105 };
  106 
  107 static unsigned char alaw_to_ulaw[] = {
  108    42,   43,   40,   41,   46,   47,   44,   45,
  109    34,   35,   32,   33,   38,   39,   36,   37,
  110    57,   58,   55,   56,   61,   62,   59,   60,
  111    49,   50,   48,   48,   53,   54,   51,   52,
  112    10,   11,    8,    9,   14,   15,   12,   13,
  113     2,    3,    0,    1,    6,    7,    4,    5,
  114    26,   27,   24,   25,   30,   31,   28,   29,
  115    18,   19,   16,   17,   22,   23,   20,   21,
  116    98,   99,   96,   97,  102,  103,  100,  101,
  117    93,   93,   92,   92,   95,   95,   94,   94,
  118   116,  118,  112,  114,  124,  126,  120,  122,
  119   106,  107,  104,  105,  110,  111,  108,  109,
  120    72,   73,   70,   71,   76,   77,   74,   75,
  121    64,   65,   63,   63,   68,   69,   66,   67,
  122    86,   87,   84,   85,   90,   91,   88,   89,
  123    79,   79,   78,   78,   82,   83,   80,   81,
  124   170,  171,  168,  169,  174,  175,  172,  173,
  125   162,  163,  160,  161,  166,  167,  164,  165,
  126   185,  186,  183,  184,  189,  190,  187,  188,
  127   177,  178,  176,  176,  181,  182,  179,  180,
  128   138,  139,  136,  137,  142,  143,  140,  141,
  129   130,  131,  128,  129,  134,  135,  132,  133,
  130   154,  155,  152,  153,  158,  159,  156,  157,
  131   146,  147,  144,  145,  150,  151,  148,  149,
  132   226,  227,  224,  225,  230,  231,  228,  229,
  133   221,  221,  220,  220,  223,  223,  222,  222,
  134   244,  246,  240,  242,  252,  254,  248,  250,
  135   234,  235,  232,  233,  238,  239,  236,  237,
  136   200,  201,  198,  199,  204,  205,  202,  203,
  137   192,  193,  191,  191,  196,  197,  194,  195,
  138   214,  215,  212,  213,  218,  219,  216,  217,
  139   207,  207,  206,  206,  210,  211,  208,  209,
  140 };
  141 
  142 static unsigned char ulaw_to_alaw[] = {
  143    42,   43,   40,   41,   46,   47,   44,   45,
  144    34,   35,   32,   33,   38,   39,   36,   37,
  145    58,   59,   56,   57,   62,   63,   60,   61,
  146    50,   51,   48,   49,   54,   55,   52,   53,
  147    10,   11,    8,    9,   14,   15,   12,   13,
  148     2,    3,    0,    1,    6,    7,    4,    5,
  149    27,   24,   25,   30,   31,   28,   29,   18,
  150    19,   16,   17,   22,   23,   20,   21,  106,
  151   104,  105,  110,  111,  108,  109,   98,   99,
  152    96,   97,  102,  103,  100,  101,  122,  120,
  153   126,  127,  124,  125,  114,  115,  112,  113,
  154   118,  119,  116,  117,   75,   73,   79,   77,
  155    66,   67,   64,   65,   70,   71,   68,   69,
  156    90,   91,   88,   89,   94,   95,   92,   93,
  157    82,   82,   83,   83,   80,   80,   81,   81,
  158    86,   86,   87,   87,   84,   84,   85,   85,
  159   170,  171,  168,  169,  174,  175,  172,  173,
  160   162,  163,  160,  161,  166,  167,  164,  165,
  161   186,  187,  184,  185,  190,  191,  188,  189,
  162   178,  179,  176,  177,  182,  183,  180,  181,
  163   138,  139,  136,  137,  142,  143,  140,  141,
  164   130,  131,  128,  129,  134,  135,  132,  133,
  165   155,  152,  153,  158,  159,  156,  157,  146,
  166   147,  144,  145,  150,  151,  148,  149,  234,
  167   232,  233,  238,  239,  236,  237,  226,  227,
  168   224,  225,  230,  231,  228,  229,  250,  248,
  169   254,  255,  252,  253,  242,  243,  240,  241,
  170   246,  247,  244,  245,  203,  201,  207,  205,
  171   194,  195,  192,  193,  198,  199,  196,  197,
  172   218,  219,  216,  217,  222,  223,  220,  221,
  173   210,  210,  211,  211,  208,  208,  209,  209,
  174   214,  214,  215,  215,  212,  212,  213,  213,
  175 };
  176 
  177 /*****************************************************************************/
  178 
  179 static int
  180 feed_8to16le(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  181 {
  182         int i, j, k;
  183 
  184         k = FEEDER_FEED(f->source, c, b, count / 2, source);
  185         j = k - 1;
  186         i = j * 2 + 1;
  187         while (i > 0 && j >= 0) {
  188                 b[i--] = b[j--];
  189                 b[i--] = 0;
  190         }
  191         return k * 2;
  192 }
  193 
  194 static struct pcm_feederdesc feeder_8to16le_desc[] = {
  195         {FEEDER_FMT, AFMT_U8, AFMT_U16_LE, 0},
  196         {FEEDER_FMT, AFMT_U8 | AFMT_STEREO, AFMT_U16_LE | AFMT_STEREO, 0},
  197         {FEEDER_FMT, AFMT_S8, AFMT_S16_LE, 0},
  198         {FEEDER_FMT, AFMT_S8 | AFMT_STEREO, AFMT_S16_LE | AFMT_STEREO, 0},
  199         {0},
  200 };
  201 static kobj_method_t feeder_8to16le_methods[] = {
  202         KOBJMETHOD(feeder_feed,         feed_8to16le),
  203         { 0, 0 }
  204 };
  205 FEEDER_DECLARE(feeder_8to16le, 0, NULL);
  206 
  207 /*****************************************************************************/
  208 
  209 static int
  210 feed_16to8_init(struct pcm_feeder *f)
  211 {
  212         f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO);
  213         if (f->data == NULL)
  214                 return ENOMEM;
  215         return 0;
  216 }
  217 
  218 static int
  219 feed_16to8_free(struct pcm_feeder *f)
  220 {
  221         if (f->data)
  222                 free(f->data, M_FMTFEEDER);
  223         f->data = NULL;
  224         return 0;
  225 }
  226 
  227 static int
  228 feed_16leto8(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  229 {
  230         u_int32_t i = 0, toget = count * 2;
  231         int j = 1, k;
  232 
  233         k = FEEDER_FEED(f->source, c, f->data, min(toget, FEEDBUFSZ), source);
  234         while (j < k) {
  235                 b[i++] = ((u_int8_t *)f->data)[j];
  236                 j += 2;
  237         }
  238         return i;
  239 }
  240 
  241 static struct pcm_feederdesc feeder_16leto8_desc[] = {
  242         {FEEDER_FMT, AFMT_U16_LE, AFMT_U8, 0},
  243         {FEEDER_FMT, AFMT_U16_LE | AFMT_STEREO, AFMT_U8 | AFMT_STEREO, 0},
  244         {FEEDER_FMT, AFMT_S16_LE, AFMT_S8, 0},
  245         {FEEDER_FMT, AFMT_S16_LE | AFMT_STEREO, AFMT_S8 | AFMT_STEREO, 0},
  246         {0},
  247 };
  248 static kobj_method_t feeder_16leto8_methods[] = {
  249         KOBJMETHOD(feeder_init,         feed_16to8_init),
  250         KOBJMETHOD(feeder_free,         feed_16to8_free),
  251         KOBJMETHOD(feeder_feed,         feed_16leto8),
  252         { 0, 0 }
  253 };
  254 FEEDER_DECLARE(feeder_16leto8, 1, NULL);
  255 
  256 /*****************************************************************************/
  257 
  258 static int
  259 feed_monotostereo8(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  260 {
  261         int i, j, k = FEEDER_FEED(f->source, c, b, count / 2, source);
  262 
  263         j = k - 1;
  264         i = j * 2 + 1;
  265         while (i > 0 && j >= 0) {
  266                 b[i--] = b[j];
  267                 b[i--] = b[j];
  268                 j--;
  269         }
  270         return k * 2;
  271 }
  272 
  273 static struct pcm_feederdesc feeder_monotostereo8_desc[] = {
  274         {FEEDER_FMT, AFMT_U8, AFMT_U8 | AFMT_STEREO, 0},
  275         {FEEDER_FMT, AFMT_S8, AFMT_S8 | AFMT_STEREO, 0},
  276         {0},
  277 };
  278 static kobj_method_t feeder_monotostereo8_methods[] = {
  279         KOBJMETHOD(feeder_feed,         feed_monotostereo8),
  280         { 0, 0 }
  281 };
  282 FEEDER_DECLARE(feeder_monotostereo8, 0, NULL);
  283 
  284 /*****************************************************************************/
  285 
  286 static int
  287 feed_monotostereo16(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  288 {
  289         int i, j, k = FEEDER_FEED(f->source, c, b, count / 2, source);
  290         u_int8_t x, y;
  291 
  292         j = k - 1;
  293         i = j * 2 + 1;
  294         while (i >= 3 && j >= 1) {
  295                 x = b[j--];
  296                 y = b[j--];
  297                 b[i--] = x;
  298                 b[i--] = y;
  299                 b[i--] = x;
  300                 b[i--] = y;
  301         }
  302         return k * 2;
  303 }
  304 
  305 static struct pcm_feederdesc feeder_monotostereo16_desc[] = {
  306         {FEEDER_FMT, AFMT_U16_LE, AFMT_U16_LE | AFMT_STEREO, 0},
  307         {FEEDER_FMT, AFMT_S16_LE, AFMT_S16_LE | AFMT_STEREO, 0},
  308         {FEEDER_FMT, AFMT_U16_BE, AFMT_U16_BE | AFMT_STEREO, 0},
  309         {FEEDER_FMT, AFMT_S16_BE, AFMT_S16_BE | AFMT_STEREO, 0},
  310         {0},
  311 };
  312 static kobj_method_t feeder_monotostereo16_methods[] = {
  313         KOBJMETHOD(feeder_feed,         feed_monotostereo16),
  314         { 0, 0 }
  315 };
  316 FEEDER_DECLARE(feeder_monotostereo16, 0, NULL);
  317 
  318 /*****************************************************************************/
  319 
  320 static int
  321 feed_stereotomono8_init(struct pcm_feeder *f)
  322 {
  323         f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO);
  324         if (f->data == NULL)
  325                 return ENOMEM;
  326         return 0;
  327 }
  328 
  329 static int
  330 feed_stereotomono8_free(struct pcm_feeder *f)
  331 {
  332         if (f->data)
  333                 free(f->data, M_FMTFEEDER);
  334         f->data = NULL;
  335         return 0;
  336 }
  337 
  338 static int
  339 feed_stereotomono8(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  340 {
  341         u_int32_t i = 0, toget = count * 2;
  342         int j = 0, k;
  343 
  344         k = FEEDER_FEED(f->source, c, f->data, min(toget, FEEDBUFSZ), source);
  345         while (j < k) {
  346                 b[i++] = ((u_int8_t *)f->data)[j];
  347                 j += 2;
  348         }
  349         return i;
  350 }
  351 
  352 static struct pcm_feederdesc feeder_stereotomono8_desc[] = {
  353         {FEEDER_FMT, AFMT_U8 | AFMT_STEREO, AFMT_U8, 0},
  354         {FEEDER_FMT, AFMT_S8 | AFMT_STEREO, AFMT_S8, 0},
  355         {0},
  356 };
  357 static kobj_method_t feeder_stereotomono8_methods[] = {
  358         KOBJMETHOD(feeder_init,         feed_stereotomono8_init),
  359         KOBJMETHOD(feeder_free,         feed_stereotomono8_free),
  360         KOBJMETHOD(feeder_feed,         feed_stereotomono8),
  361         { 0, 0 }
  362 };
  363 FEEDER_DECLARE(feeder_stereotomono8, 1, NULL);
  364 
  365 /*****************************************************************************/
  366 
  367 static int
  368 feed_stereotomono16_init(struct pcm_feeder *f)
  369 {
  370         f->data = malloc(FEEDBUFSZ, M_FMTFEEDER, M_NOWAIT | M_ZERO);
  371         if (f->data == NULL)
  372                 return ENOMEM;
  373         return 0;
  374 }
  375 
  376 static int
  377 feed_stereotomono16_free(struct pcm_feeder *f)
  378 {
  379         if (f->data)
  380                 free(f->data, M_FMTFEEDER);
  381         f->data = NULL;
  382         return 0;
  383 }
  384 
  385 static int
  386 feed_stereotomono16(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  387 {
  388         u_int32_t i = 0, toget = count * 2;
  389         int j = 0, k;
  390 
  391         k = FEEDER_FEED(f->source, c, f->data, min(toget, FEEDBUFSZ), source);
  392         while (j < k) {
  393                 b[i++] = ((u_int8_t *)f->data)[j];
  394                 b[i++] = ((u_int8_t *)f->data)[j + 1];
  395                 j += 4;
  396         }
  397         return i;
  398 }
  399 
  400 static struct pcm_feederdesc feeder_stereotomono16_desc[] = {
  401         {FEEDER_FMT, AFMT_U16_LE | AFMT_STEREO, AFMT_U16_LE, 0},
  402         {FEEDER_FMT, AFMT_S16_LE | AFMT_STEREO, AFMT_S16_LE, 0},
  403         {FEEDER_FMT, AFMT_U16_BE | AFMT_STEREO, AFMT_U16_BE, 0},
  404         {FEEDER_FMT, AFMT_S16_BE | AFMT_STEREO, AFMT_S16_BE, 0},
  405         {0},
  406 };
  407 static kobj_method_t feeder_stereotomono16_methods[] = {
  408         KOBJMETHOD(feeder_init,         feed_stereotomono16_init),
  409         KOBJMETHOD(feeder_free,         feed_stereotomono16_free),
  410         KOBJMETHOD(feeder_feed,         feed_stereotomono16),
  411         { 0, 0 }
  412 };
  413 FEEDER_DECLARE(feeder_stereotomono16, 1, NULL);
  414 
  415 /*****************************************************************************/
  416 
  417 static int
  418 feed_endian(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  419 {
  420         u_int8_t t;
  421         int i = 0, j = FEEDER_FEED(f->source, c, b, count, source);
  422 
  423         while (i < j) {
  424                 t = b[i];
  425                 b[i] = b[i + 1];
  426                 b[i + 1] = t;
  427                 i += 2;
  428         }
  429         return i;
  430 }
  431 
  432 static struct pcm_feederdesc feeder_endian_desc[] = {
  433         {FEEDER_FMT, AFMT_U16_LE, AFMT_U16_BE, 0},
  434         {FEEDER_FMT, AFMT_U16_LE | AFMT_STEREO, AFMT_U16_BE | AFMT_STEREO, 0},
  435         {FEEDER_FMT, AFMT_S16_LE, AFMT_S16_BE, 0},
  436         {FEEDER_FMT, AFMT_S16_LE | AFMT_STEREO, AFMT_S16_BE | AFMT_STEREO, 0},
  437         {FEEDER_FMT, AFMT_U16_BE, AFMT_U16_LE, 0},
  438         {FEEDER_FMT, AFMT_U16_BE | AFMT_STEREO, AFMT_U16_LE | AFMT_STEREO, 0},
  439         {FEEDER_FMT, AFMT_S16_BE, AFMT_S16_LE, 0},
  440         {FEEDER_FMT, AFMT_S16_BE | AFMT_STEREO, AFMT_S16_LE | AFMT_STEREO, 0},
  441         {0},
  442 };
  443 static kobj_method_t feeder_endian_methods[] = {
  444         KOBJMETHOD(feeder_feed,         feed_endian),
  445         { 0, 0 }
  446 };
  447 FEEDER_DECLARE(feeder_endian, 0, NULL);
  448 
  449 /*****************************************************************************/
  450 
  451 static int
  452 feed_sign(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  453 {
  454         int i = 0, j = FEEDER_FEED(f->source, c, b, count, source);
  455         intptr_t ssz = (intptr_t)f->data, ofs = ssz - 1;
  456 
  457         while (i < j) {
  458                 b[i + ofs] ^= 0x80;
  459                 i += ssz;
  460         }
  461         return i;
  462 }
  463 
  464 static struct pcm_feederdesc feeder_sign8_desc[] = {
  465         {FEEDER_FMT, AFMT_U8, AFMT_S8, 0},
  466         {FEEDER_FMT, AFMT_U8 | AFMT_STEREO, AFMT_S8 | AFMT_STEREO, 0},
  467         {FEEDER_FMT, AFMT_S8, AFMT_U8, 0},
  468         {FEEDER_FMT, AFMT_S8 | AFMT_STEREO, AFMT_U8 | AFMT_STEREO, 0},
  469         {0},
  470 };
  471 static kobj_method_t feeder_sign8_methods[] = {
  472         KOBJMETHOD(feeder_feed,         feed_sign),
  473         { 0, 0 }
  474 };
  475 FEEDER_DECLARE(feeder_sign8, 0, (void *)1);
  476 
  477 static struct pcm_feederdesc feeder_sign16le_desc[] = {
  478         {FEEDER_FMT, AFMT_U16_LE, AFMT_S16_LE, 0},
  479         {FEEDER_FMT, AFMT_U16_LE | AFMT_STEREO, AFMT_S16_LE | AFMT_STEREO, 0},
  480         {FEEDER_FMT, AFMT_S16_LE, AFMT_U16_LE, 0},
  481         {FEEDER_FMT, AFMT_S16_LE | AFMT_STEREO, AFMT_U16_LE | AFMT_STEREO, 0},
  482         {0},
  483 };
  484 static kobj_method_t feeder_sign16le_methods[] = {
  485         KOBJMETHOD(feeder_feed,         feed_sign),
  486         { 0, 0 }
  487 };
  488 FEEDER_DECLARE(feeder_sign16le, -1, (void *)2);
  489 
  490 /*****************************************************************************/
  491 
  492 static int
  493 feed_table(struct pcm_feeder *f, struct pcm_channel *c, u_int8_t *b, u_int32_t count, void *source)
  494 {
  495         int i = 0, j = FEEDER_FEED(f->source, c, b, count, source);
  496 
  497         while (i < j) {
  498                 b[i] = ((u_int8_t *)f->data)[b[i]];
  499                 i++;
  500         }
  501         return i;
  502 }
  503 
  504 static struct pcm_feederdesc feeder_ulawtou8_desc[] = {
  505         {FEEDER_FMT, AFMT_MU_LAW, AFMT_U8, 0},
  506         {FEEDER_FMT, AFMT_MU_LAW | AFMT_STEREO, AFMT_U8 | AFMT_STEREO, 0},
  507         {0},
  508 };
  509 static kobj_method_t feeder_ulawtou8_methods[] = {
  510         KOBJMETHOD(feeder_feed,         feed_table),
  511         { 0, 0 }
  512 };
  513 FEEDER_DECLARE(feeder_ulawtou8, 0, ulaw_to_u8);
  514 
  515 static struct pcm_feederdesc feeder_u8toulaw_desc[] = {
  516         {FEEDER_FMT, AFMT_U8, AFMT_MU_LAW, 0},
  517         {FEEDER_FMT, AFMT_U8 | AFMT_STEREO, AFMT_MU_LAW | AFMT_STEREO, 0},
  518         {0},
  519 };
  520 static kobj_method_t feeder_u8toulaw_methods[] = {
  521         KOBJMETHOD(feeder_feed,         feed_table),
  522         { 0, 0 }
  523 };
  524 FEEDER_DECLARE(feeder_u8toulaw, 0, u8_to_ulaw);
  525 
  526 static struct pcm_feederdesc feeder_alawtoulaw_desc[] = {
  527         {FEEDER_FMT, AFMT_A_LAW, AFMT_MU_LAW, 0},
  528         {FEEDER_FMT, AFMT_A_LAW | AFMT_STEREO, AFMT_MU_LAW | AFMT_STEREO, 0},
  529         {0},
  530 };
  531 static kobj_method_t feeder_alawtoulaw_methods[] = {
  532         KOBJMETHOD(feeder_feed,         feed_table),
  533         { 0, 0 }
  534 };
  535 FEEDER_DECLARE(feeder_alawtoulaw, 0, alaw_to_ulaw);
  536 
  537 static struct pcm_feederdesc feeder_ulawtoalaw_desc[] = {
  538         {FEEDER_FMT, AFMT_MU_LAW, AFMT_A_LAW, 0},
  539         {FEEDER_FMT, AFMT_MU_LAW | AFMT_STEREO, AFMT_A_LAW | AFMT_STEREO, 0},
  540         {0},
  541 };
  542 static kobj_method_t feeder_ulawtoalaw_methods[] = {
  543         KOBJMETHOD(feeder_feed,         feed_table),
  544         { 0, 0 }
  545 };
  546 FEEDER_DECLARE(feeder_ulawtoalaw, 0, ulaw_to_alaw);
  547 
  548 
  549 

Cache object: 314c229bfc6145d4893cc1eaf926d5f8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.