[FFmpeg-devel] [PATCH] WMA Voice decoder

Michael Niedermayer michaelni
Thu Jan 21 01:53:55 CET 2010


On Wed, Jan 20, 2010 at 04:56:25PM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> On Tue, Jan 19, 2010 at 7:38 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> > my first decoder, please be kind. :-).
> 
> Updated reflecting Mans and Diego's comments. Thanks both!

diego? i didbnt see a reply from him?

anyway very incomplete review below, i guess ill try to look at h264 more
and leave this to others if we have volunteers

> 
> Ronald

>  Changelog                  |    1 
>  MAINTAINERS                |    1 
>  doc/general.texi           |    1 
>  libavcodec/Makefile        |    1 
>  libavcodec/allcodecs.c     |    1 
>  libavcodec/wmavoice.c      | 1503 ++++++++++++++++++++++
>  libavcodec/wmavoice_data.h | 2970 +++++++++++++++++++++++++++++++++++++++++++++
>  7 files changed, 4478 insertions(+)
> 543609fab29818ffd611409316697989e98fe282  wmavoice.patch
> Index: ffmpeg-svn/libavcodec/Makefile
> ===================================================================
> --- ffmpeg-svn.orig/libavcodec/Makefile	2010-01-20 12:21:23.000000000 -0500
> +++ ffmpeg-svn/libavcodec/Makefile	2010-01-20 12:58:29.000000000 -0500
> @@ -335,6 +335,7 @@
[...]
> +/**
> + * @}
> + *
> + * Generate a random number that is different for each frame/block
> + * and can be used as an index for a table with 1000 entries, if
> + * we want to read @block_size entries following.
> + *
> + * @param frame_cntr current frame number
> + * @param block_num current block index
> + * @param block_size amount of entries we want to read from a table
> + *                   that has 1000 entries
> + * @returns a unique random number for each @block_cntr/@block_num
> + *          combination, which can be used as index in a table that
> + *          has a 1000 entries from which we want to read @block_size
> + *          entries.
> + */
> +
> +static int pRNG(int frame_cntr, int block_num, int block_size)
> +{

> +    int x = (block_num * 1877 + frame_cntr) % 0xFFFF;

can this be >= 2 * 0xFFFF ?
if not
int x = block_num * 1877 + frame_cntr;
if(x>=0xFFFF) x-=0xFFFF could be used

modulo is slow and i assume this silly function must be like that exactly


> +    int y = (x % 9) * 5 + 6;

you can probably multiply x by some constant and >> (see FAST_DIV also)
to find x/9 and x - x/9*9 = x%9


> +    int z = (uint16_t) (x * 49995 / y);

I wonder if the 9 possible values for y could with a table  9 entries
and multiply + >> be used to simplify this

[...]
> +static const uint8_t ff_wmavoice_dq_lsp16r2[0x500] = {
> +     98,  98, 119, 121, 109, 112, 128, 135, 115, 121,
> +    159, 113, 113, 106, 127, 114, 101, 102, 105, 111,
> +    161, 162, 137, 138, 161, 159, 152, 150, 150, 148,
> +    128,  79, 131, 102, 142, 120, 133, 119, 130, 117,
> +    121, 115, 142, 133, 186, 155, 179, 144, 169, 135,
> +    107, 103, 106, 106, 122, 122, 111, 112, 112, 115,
> +    127, 123, 118, 115, 128, 125, 123, 119, 115, 109,
> +    124, 130, 117, 126, 121, 133,  84, 144,  99, 114,
> +    122, 125, 123, 131, 124, 135, 176, 200, 158, 176,
> +     68,  74,  86,  87, 117, 115, 119, 116, 135, 128,
> +    115, 116, 102, 104, 119, 123, 133, 148, 102, 109,
> +     71, 121, 106, 117, 107, 127, 106, 122, 100, 110,
> +    117, 115, 129, 128,  87,  84, 116, 116, 151, 157,
> +    116, 128, 110, 117, 119, 134, 100, 114, 120, 129,
> +    142, 141, 146, 151,  94,  91, 114, 114, 118, 118,
> +    114, 112, 112, 109, 115, 112, 123, 123, 147, 148,
> +    110, 164, 106, 152, 110, 158, 106, 151, 105, 135,
> +     85,  51,  71,  27,  71,  34,  74,  45,  85,  53,
> +    145, 134, 140, 130, 136, 134, 118, 122, 118, 126,
> +    117,  84, 121,  81, 106,  80, 109, 106, 121, 127,
> +     95,  94, 112, 110,  90,  94, 109, 107, 114, 109,
> +    117, 118, 118, 123, 107, 107,  86,  93,  29,  31,
> +    125, 112, 104,  60, 121, 111, 127, 116, 133, 130,
> +    118, 117, 148, 145, 122, 126, 124, 127,  90,  91,
> +    113, 110, 119, 118, 152, 147, 115, 112, 132, 131,
> +    129, 140,  98, 112,  73,  85, 109, 115, 122, 126,
> +    123, 122, 122, 122, 126, 125, 137, 140, 203, 210,
> +    164, 176, 114, 114, 125, 122, 119, 112, 125, 120,
> +    124, 122, 118, 115,  95,  96, 141, 144, 132, 131,
> +    127, 130, 132, 134, 116, 114, 122, 123, 137, 134,
> +    111, 111, 112, 116, 106, 118,  77, 101, 104, 115,
> +    111, 111, 125, 126, 118, 121, 113, 115, 113, 113,
> +    171, 170, 202, 199, 221, 206, 199, 184, 177, 167,
> +     73,  90,  61,  93,  43,  74,  51,  71,  51,  72,
> +    130, 130, 140, 137, 134, 132, 164, 160, 118, 111,
> +    123, 136, 133, 154, 130, 158, 106, 110, 110, 114,
> +     97,  97,  91,  94,  70,  69, 125, 123, 141, 140,
> +    119, 100, 116,  77, 111,  67, 105,  52,  95,  34,
> +    100, 122,  90, 124,  68, 120,  43, 117,  50, 112,
> +    130, 129, 192, 188, 123, 118, 124, 117, 121, 115,
> +    122, 111, 129, 111, 157,  85, 125, 109, 125, 119,
> +    143, 152, 119, 128, 114, 116, 129, 136, 148, 157,
> +    119, 117, 115, 115, 150, 148, 163, 154, 109, 102,
> +    120, 126,  73, 119, 106, 121, 102, 122,  96, 113,
> +     84,  83, 117, 115, 122, 117, 154, 143, 159, 142,
> +    118, 122, 114, 117, 115, 122, 114, 130,  99, 156,
> +    123, 120, 122, 116, 100,  81,  99,  91, 121, 112,
> +    139, 131, 164, 142, 132, 119, 145, 133, 157, 141,
> +    112, 109, 118, 116, 142, 134, 108, 110,  96,  99,
> +    111, 110, 113, 112, 111, 104,  98,  94, 131, 131,
> +    115, 114, 121, 118, 120, 115, 173, 148, 123, 117,
> +    121, 124, 122, 124, 140, 146,  78,  82,  96,  93,
> +     86,  90, 124, 125, 121, 123, 105, 106, 134, 135,
> +    107, 109, 132, 141, 100,  95, 113, 114, 102, 105,
> +    113, 130,  98, 145, 116, 115, 124, 117, 115, 105,
> +    120, 123,  89,  87, 109, 108, 102, 101, 117, 117,
> +    113, 122, 132, 138,  77, 116,  86,  99, 118, 126,
> +    123, 120, 117, 111, 124, 119, 129, 118,  63,  58,
> +    141, 135, 108, 106, 109, 111, 108, 110, 135, 138,
> +    117, 114, 134, 127, 139, 129, 138, 130, 126, 122,
> +    121, 118, 124, 121, 133, 130,  98,  85, 130, 123,
> +    147, 129, 118, 112, 148, 130, 136, 123, 148, 131,
> +    113, 112, 123, 118, 123, 115, 147,  95, 117, 110,
> +    118, 119, 112, 113, 112, 113, 119, 119, 120, 120,
> +    158, 133, 198, 145, 188, 129, 197, 137, 195, 133,
> +    132, 140, 140, 139, 158, 156, 223, 217, 233, 233,
> +     48,  56,  34,  37,  82,  84, 102, 102, 108, 110,
> +    120, 142, 136, 169, 146, 195, 136, 186, 140, 182,
> +    196, 186, 158, 155, 142, 134, 132, 125, 120, 119,
> +     97, 105,  72,  75,  82,  85,  81,  84, 107, 109,
> +     67, 121,  43, 119,  69, 124,  87, 129,  88, 128,
> +     53,  57,  93,  98,  91,  94,  93,  98, 104, 104,
> +    124, 123, 133, 133, 182, 181, 119, 121, 114, 116,
> +    128, 105, 134, 112, 131,  72, 119,  59, 111,  84,
> +    132, 142, 145, 180, 124, 132, 131, 143, 122, 134,
> +     88,  85, 103, 103, 136, 140, 131, 143, 114, 132,
> +    116,  57, 113,  57, 121,  76, 126,  80, 118,  86,
> +    127, 112, 127,  97, 131, 100, 149,  91, 163,  86,
> +    122, 119, 128, 121, 128, 116, 142, 127, 173, 139,
> +    162, 116, 166, 107, 149, 103, 152, 107, 141, 108,
> +    114, 113, 118, 116,  56,  43,  90,  90, 105, 105,
> +    132, 134, 110, 107, 106, 105,  82,  84,  84,  84,
> +    102, 106,  79,  89,  99,  99, 127, 129, 114, 118,
> +    139, 157, 116, 123, 116, 123,  87,  89, 110, 113,
> +    119, 126,  97,  97, 155, 163, 142, 153, 143, 146,
> +    117, 114,  66,  67, 125, 126, 127, 128, 114, 113,
> +    111, 114, 127, 133, 123, 132, 143, 162, 133, 148,
> +    105, 108, 114, 114, 110, 109,  57,  48, 109, 106,
> +    113, 130, 104, 131,  88, 139, 102, 169, 100, 172,
> +    129, 114, 150,  97, 114, 112, 117, 119, 109, 116,
> +     92, 107,  96, 116,  90, 125, 101, 122, 125, 140,
> +    125, 133, 122, 129, 136, 153, 125, 135, 131, 139,
> +     84,  71, 129, 123, 135, 120, 114, 103, 112, 101,
> +    108, 121, 115, 156, 106, 123, 116, 131, 127, 139,
> +    137, 147, 109, 117, 119, 126, 135, 144, 117, 119,
> +    120, 127,  76, 105, 111, 116, 120, 125, 141, 138,
> +    107, 104, 162, 155, 135, 130, 127, 123, 127, 121,
> +    102, 104,  84,  87, 112, 115,  97, 102,  78,  82,
> +    119, 118, 120, 123,  91, 105, 114, 119, 119, 126,
> +    130, 126, 134, 126, 158, 134, 133,  99, 116, 100,
> +    125, 122, 145, 143, 126, 117,  98,  96, 121, 120,
> +    152, 148, 131, 126, 130, 129, 126, 119,  87,  87,
> +    131, 131, 139, 137, 101, 102, 104, 105,  86,  83,
> +     92,  89, 111, 105, 121, 115, 137, 124,  96,  84,
> +    100,  96, 122, 119, 107, 108,  93,  96,  79,  82,
> +    128, 123, 108, 106, 123, 120, 150, 150, 143, 140,
> +    121, 120,  97,  99,  79,  80, 116, 116,  88,  90,
> +    128, 131, 101,  97, 140, 140, 117, 116, 116, 118,
> +    137, 135, 100,  91, 115, 112, 134, 121, 107,  99,
> +    120, 122, 122, 125, 124, 126, 136, 141,  89,  95,
> +    103, 119, 103, 116, 122, 139, 125, 137, 152, 170,
> +    121, 122, 124, 124,  98,  97, 137, 140,  96,  92,
> +    115, 113, 136, 136, 128, 132, 122, 124, 151, 158,
> +    100, 107, 121, 131, 131, 158, 119, 130, 113, 114,
> +    114, 109, 148, 130, 103,  95, 127, 116, 137, 120,
> +    103, 108,  97,  97, 133, 128, 113, 109, 136, 128,
> +    125, 124, 118, 118, 122, 121, 101,  99, 157, 152,
> +    138, 134, 124, 115, 113, 101, 123, 112, 124, 110,
> +    116, 113, 128, 121, 119, 110, 124, 113, 128,  67,
> +    114, 118, 114, 123, 109, 121, 102, 123,  56, 116,
> +    117, 111, 112,  99, 124, 114, 112,  79, 114,  88,
> +    112, 113, 115, 117, 126, 127, 130, 132, 123, 122,
> +    111, 104, 111, 102, 112, 102, 129, 118, 129, 115,
> +    123, 124, 130, 133, 114, 117, 125, 127, 112, 117,
> +    124, 125, 119, 120, 117, 116, 105, 104, 110, 110,
> +    125, 124, 118, 116, 124, 123, 124, 121, 133, 132,
> +    111, 111, 124, 124, 120, 119, 116, 116, 134, 130,
> +    114, 116, 112, 113, 109, 111, 116, 118,  95,  98
> +};
> +
> +static const uint8_t ff_wmavoice_dq_lsp16r3[0x600] = {

If you want to reuduce the size of these tables, i suspect it
might be possible, first convert them to deltas that is
new_table= oldtable[i] - oldtable[i-1]
then store using a wisely choosen vlc code
That might or might not be a good idea but as someone seemed
to dislike their size this might be able to cut them in half

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100121/64eae37d/attachment.pgp>



More information about the ffmpeg-devel mailing list