For faster navigation, this Iframe is preloading the Wikiwand page for A-закон.

A-закон

Матеріал з Вікіпедії — вільної енциклопедії.

А-закон — алгоритм стиснення зі втратою інформації, застосовується для стиснення звукових даних.

Реалізації для 16-бітових знакових цілих

[ред. | ред. код]

Принцип кодування схожий на кодування чисел з рухомою комою. Кожен семпл кодується у 8-бітове поле. Старший біт — біт знака, наступні 3 біти — беззнакова експонента, останні 4 — мантиса. Таким чином з використовуваних 16 біт, тільки 12 біт містять значущу інформацію, а 4 біти з 16 іноді відкидаються.

Крок 1

Якщо число від'ємне, його обертають, при цьому приймається, що s = 0, інакше s = 1.

Крок 2

16-бітове число перетворюється на 8-бітове відповідно до такої таблиці (для наочності півбайти — нібли — розділено знаком зворотного апострофа (`); s — знаковий біт; зірочками показано біти, що губляться при стисканні):

Початкове число Стиснене
s000`0000`wxyz`**** s000`wxyz
s000`0001`wxyz`**** s001`wxyz
s000`001w`xyz*`**** s010`wxyz
s000`01wx`yz**`**** s011`wxyz
s000`1wxy`z***`**** s100`wxyz
s001`wxyz`****`**** s101`wxyz
s01w`xyz*`****`**** s110`wxyz
s1wx`yz**`****`**** s111`wxyz
Крок 3

Біти інвертуються через один, починаючи від правого (тобто з 8-бітовим числом виконується операція XOR 0x55).

Приклади

[ред. | ред. код]

У прикладах нижче підрядковий індекс позначає розрядність (десяткове чи двійкове); на 1 кроці підкреслено мантису (частину цифр, що переходить у wxyz на 2 кроці).

Приклад 1
66610 = 0000 `0010'1001'10102
Крок 1. Знаковий біт s = 1: 0000'0010'1001'10102
Крок 2. Власне стискання (відповідає s001'wxyz): 1010'01002
Крок 3. Інвертування: 1111'00012 = F116 = 24110 .
Приклад 2
—666610 = 1110'0101'1111'01102
Крок 1. Число обертаємо, знаковий біт s = 0: 0001`1010`0000'10012
Крок 2. Власне стискання (відповідає s011'wxyz): 0101'10102
Крок 3. Інвертування: 0000'11112 = 1510

Див. також

[ред. | ред. код]

Посилання

[ред. | ред. код]
{{bottomLinkPreText}} {{bottomLinkText}}
A-закон
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?