HAVE YOUR CAKE AND HEAR IT TOO: A HUFFMAN CODED, BLOCK SWITCHING, STEREO PERCEPTUAL AUDIO CODER

Similar documents
MUSIC A Darker Phonetic Audio Coder

/ / _ / _ / _ / / / / /_/ _/_/ _/_/ _/_/ _\ / All-American-Advanced-Audio-Codec

<< WILL FILL IN THESE SECTIONS THIS WEEK to provide sufficient background>>

Audio-coding standards

Perceptual Coding. Lossless vs. lossy compression Perceptual models Selecting info to eliminate Quantization and entropy encoding

Audio-coding standards

Multimedia Communications. Audio coding

Lecture 16 Perceptual Audio Coding

EE482: Digital Signal Processing Applications

Mpeg 1 layer 3 (mp3) general overview

Audio Compression. Audio Compression. Absolute Threshold. CD quality audio:

5: Music Compression. Music Coding. Mark Handley

Perceptual coding. A psychoacoustic model is used to identify those signals that are influenced by both these effects.

Chapter 14 MPEG Audio Compression

Principles of Audio Coding

Figure 1. Generic Encoder. Window. Spectral Analysis. Psychoacoustic Model. Quantize. Pack Data into Frames. Additional Coding.

Both LPC and CELP are used primarily for telephony applications and hence the compression of a speech signal.

MPEG-1. Overview of MPEG-1 1 Standard. Introduction to perceptual and entropy codings

Bit or Noise Allocation

ROW.mp3. Colin Raffel, Jieun Oh, Isaac Wang Music 422 Final Project 3/12/2010

Appendix 4. Audio coding algorithms

Introducing Audio Signal Processing & Audio Coding. Dr Michael Mason Senior Manager, CE Technology Dolby Australia Pty Ltd

Introducing Audio Signal Processing & Audio Coding. Dr Michael Mason Snr Staff Eng., Team Lead (Applied Research) Dolby Australia Pty Ltd

ELL 788 Computational Perception & Cognition July November 2015

New Results in Low Bit Rate Speech Coding and Bandwidth Extension

AUDIOVISUAL COMMUNICATION

Ch. 5: Audio Compression Multimedia Systems

Contents. 3 Vector Quantization The VQ Advantage Formulation Optimality Conditions... 48

Compressed Audio Demystified by Hendrik Gideonse and Connor Smith. All Rights Reserved.

Wavelet filter bank based wide-band audio coder

Optical Storage Technology. MPEG Data Compression

2.4 Audio Compression

Fundamentals of Perceptual Audio Encoding. Craig Lewiston HST.723 Lab II 3/23/06

AUDIOVISUAL COMMUNICATION

REDUCED FLOATING POINT FOR MPEG1/2 LAYER III DECODING. Mikael Olausson, Andreas Ehliar, Johan Eilert and Dake liu

DRA AUDIO CODING STANDARD

Audio Coding and MP3

Module 9 AUDIO CODING. Version 2 ECE IIT, Kharagpur

MPEG-4 General Audio Coding

The MPEG-4 General Audio Coder

Digital Communication Prof. Bikash Kumar Dey Department of Electrical Engineering Indian Institute of Technology, Bombay

DAB. Digital Audio Broadcasting

Efficient Implementation of Transform Based Audio Coders using SIMD Paradigm and Multifunction Computations

Efficient Representation of Sound Images: Recent Developments in Parametric Coding of Spatial Audio

Audio Fundamentals, Compression Techniques & Standards. Hamid R. Rabiee Mostafa Salehi, Fatemeh Dabiran, Hoda Ayatollahi Spring 2011

Principles of MPEG audio compression

Parametric Coding of High-Quality Audio

Chapter 4: Audio Coding

CISC 7610 Lecture 3 Multimedia data and data formats

For Mac and iphone. James McCartney Core Audio Engineer. Eric Allamanche Core Audio Engineer

_APP B_549_10/31/06. Appendix B. Producing for Multimedia and the Web

DSP. Presented to the IEEE Central Texas Consultants Network by Sergio Liberman

Squeeze Play: The State of Ady0 Cmprshn. Scott Selfon Senior Development Lead Xbox Advanced Technology Group Microsoft

Efficient Signal Adaptive Perceptual Audio Coding

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF INFORMATION TECHNOLOGY ACADEMIC YEAR / ODD SEMESTER QUESTION BANK

ITNP80: Multimedia! Sound-II!

Modeling of an MPEG Audio Layer-3 Encoder in Ptolemy

Novel Lossy Compression Algorithms with Stacked Autoencoders

Data Compression. Audio compression

Proceedings of Meetings on Acoustics

MPEG-4 aacplus - Audio coding for today s digital media world

CAPTURING AUDIO DATA FAQS

An adaptive wavelet-based approach for perceptual low bit rate audio coding attending to entropy-type criteria

Speech and audio coding

CHAPTER 5 AUDIO WATERMARKING SCHEME INHERENTLY ROBUST TO MP3 COMPRESSION

University of Mustansiriyah, Baghdad, Iraq

Audio Coding Standards

1 Audio quality determination based on perceptual measurement techniques 1 John G. Beerends

Mobile Peer-to-Peer Audio Streaming

Rich Recording Technology Technical overall description

Parametric Coding of Spatial Audio

Audio and video compression

Module 9 AUDIO CODING. Version 2 ECE IIT, Kharagpur

Design and Implementation of an MPEG-1 Layer III Audio Decoder KRISTER LAGERSTRÖM

Audio coding for digital broadcasting

Implementation of FPGA Based MP3 player using Invers Modified Discrete Cosine Transform

Transporting audio-video. over the Internet

Memory Access and Computational Behavior. of MP3 Encoding

Compression; Error detection & correction

Convention Paper Presented at the 121st Convention 2006 October 5 8 San Francisco, CA, USA

AUDIO MEDIA CHAPTER Background

QUANTIZER DESIGN FOR EXPLOITING COMMON INFORMATION IN LAYERED CODING. Mehdi Salehifar, Tejaswi Nanjundaswamy, and Kenneth Rose

soothe audio processor

MRT based Fixed Block size Transform Coding

MULTIMODE TREE CODING OF SPEECH WITH PERCEPTUAL PRE-WEIGHTING AND POST-WEIGHTING

ijdsp Interactive Illustrations of Speech/Audio Processing Concepts

MPEG-4 Structured Audio Systems

Design of a CELP Speech Coder and Study of Complexity vs Quality Trade-offs for Different Codebooks.

Review and Implementation of DWT based Scalable Video Coding with Scalable Motion Coding.

Replacing ECMs with Premium MEMS Microphones

Stereo Image Compression

CHAPTER 6. 6 Huffman Coding Based Image Compression Using Complex Wavelet Transform. 6.3 Wavelet Transform based compression technique 106

DIGITAL IMAGE PROCESSING WRITTEN REPORT ADAPTIVE IMAGE COMPRESSION TECHNIQUES FOR WIRELESS MULTIMEDIA APPLICATIONS

Compression of Stereo Images using a Huffman-Zip Scheme

An investigation of non-uniform bandwidths auditory filterbank in audio coding

Port of a Fixed Point MPEG-2 AAC Encoder on a ARM Platform

Lecture 7: Audio Compression & Coding

Features. Sequential encoding. Progressive encoding. Hierarchical encoding. Lossless encoding using a different strategy

An Experimental High Fidelity Perceptual Audio Coder

MODIFIED IMDCT-DECODER BASED MP3 MULTICHANNEL AUDIO DECODING SYSTEM Shanmuga Raju.S 1, Karthik.R 2, Sai Pradeep.K.P 3, Varadharajan.

Transcription:

HAVE YOUR CAKE AND HEAR IT TOO: A HUFFMAN CODED, BLOCK SWITCHING, STEREO PERCEPTUAL AUDIO CODER Rob Colcord, Elliot Kermit-Canfield and Blane Wilson Center for Computer Research in Music and Acoustics, Stanford University, Stanford, CA 94305 USA rcolcord@live.com kermit@ccrma.stanford.edu blanectwilson@gmail.com ABSTRACT This paper proposes several features to improve a baseline perceptual audio coder. Block switching increases the fidelity of encoding signals with transients, Mid/Side encoding reduces the number of bits required to encode a signal by reducing interchannel redundancy, and Huffman encoding decreases overall file size by store a more highly compressed mantissa that uses a look up table. 1. INTRODUCTION In this paper, we describe several improvements to a baseline perceptual audio coder. This baseline coding scheme uses a simple psychoacoustic model based on FFT analysis of audio signals to compute masking curves and allocate bits to reduce the store requirements of PCM audio files. A 104-length MDCT is used to represent audio signals in the frequency domain where block floating point quantization is used to represent the audio. This baseline coder sounds reasonable at high bit rates, but suffers on transients due to the long window length. Our improved coder uses transient detection and a variable window length to increase the time resolution when there are transients. This block-switching greatly increases the the perceptual quality of the audio coding. In order for our audio coder to be useful, we also need to achieve better compression ratios than the baseline coder. For this, we implemented stereo coding and Huffman coding to decrease the total number of bits required to acheive the same audio quality as the baseline coder.. BLOCK SWITCHING The block switching routine was modeled after the routine used in Dolby AC-3 [1]. It consists of a transient detection algorithm which informs a window switching sequence. The routine operates on three blocks of data the block presently to be encoded (block ), the previous block (block 1), and the next block (block 3), which acts as lookahead. Each block is 51 samples long..1. Transient Detection On each pass, the transient detector looks for transients in block 3 (the lookahead block). The reasons for this are discussed in the sections below. The transient detector works by first concatenating block with block 3, to allow for comparison. This 104-sample block of data is high-passed using a 0th-order Butterworth filter with cutoff frequency of 8 khz. The high-passed data is split into 18-sample segments, and a new array is constructed containing the peak values of each of these segments. Two steps are now performed to determine the presence of a transient. First, the second-half of the peak-value array (corresponding to the peaks in block 3) are compared to a hard-coded threshold level. If all the values are beneath the threshold, it is determined that no transient is present in block 3 and the detection routine ends. If at least one value is above the threshold, the ratios between consecutive peaks are then calculated (this is why we used block with block 3 to calculate the ratio between the last peak in block with the first peak in block 3). If one of the ratios is above another hard-coded threshold level, it is determined that a transient is present. In other words, if one of the peaks in block 3 is both above a threshold level and significantly larger than the peak in the previous segment, it is assumed to be a transient. If a transient is detected in block 3, it is flagged. On the next pass, this flag is transferred to block (because block 3 becomes block ). Thus, at all times we are aware of the presence of a transient in all three blocks... Transient Detection Results The transient detector was run apart from the coder on several of the SQAM samples to examine its efficacy. Several of these results are shown in the figure 1. The locations of the detected transients in each signal are marked with red dots. As seen above, the transient detector is highly effective in successfully identifying transients in several of the SQAM samples. It identifies all 43 hits in the castanets sample, 9/10 in the glockenspiel sample, and 7/9 in the harpsichord sample. On the German male speaker sample, it identifies transients, which are likely false positives (although this depends on what you consider to be a transient), but which is still impressive given the nature of the sample..3. Windows Four windows long, short, start, and stop are used in the routine, as seen in figure. All four are variations of the sine window. The long window is 104 samples long, and the short window is 56 samples long. The start window consists of the first half of a long window (51 samples) and second half of a short window (18 samples). The stop window consists of the first half of a short window (18 samples) and second half of a long window (51 samples). Thus, both the start and stop windows are 640 samples long. The window sequence long start short stop long allows for perfect reconstruction during transitions by overlapping equal-sized halves of the windows. The second half of a long window overlaps with the first half of a start window (51 samples), the second half of a start window overlaps with the first half of a short window (18 samples), the second half of a short window 1

overlaps with the first half of a stop window (18 samples), and the second half of a stop window overlaps with the first half of a long window (51 samples). This overlapping can be seen in figure 3..4. Block Switching Sequence As mentioned, each pass in the main loop of the coder contains three blocks of data the current block to be encoded (block ), the prior already-encoded block (block 1), and the block to be encoded on the next pass (block 3). The transient detector looks for transients in block 3, and knowledge of transients in blocks 1 and is already present from prior passes. The reason for detecting transients one block early is to allow for ample time to capture the transient with short windows; the progression of the window sequence requires a minimum of three blocks. If a transient is detected in block 3, the coder knows to use a start transition window in block so that short windows can be used to encode block (containing the transient) on the following pass. On this second pass, the coder again looks for transients in the new block 3. If one is not detected, the coder will switch to a stop window on the following pass. The net result of this process is shown in figure 4. Alternatively, if a transient is detected in block 3 on the third pass (the block following the first block containing a transient) then the coder will continue with short windows instead of switching to a stop window. This process can continue indefinitely (although consecutive transient blocks is relatively rare in most music signals). A sequence containing two consecutive blocks with transients is shown in figure 4. A third situation is one in which a blocking containing a transient is followed by one without, which is followed by another block with a transient. In this case, the coder knows to use a stop window after the first transient block immediately followed by a start window to allow the second transient to be properly captured by short windows. This sequence is depicted in figure 4. 3. MID-SIDE ENCODING When an input file is exactly two channels, our improved coder supports stereo encoding. In the baseline coder, each audio channel is processed independently. When two channels are provided to the improved coder, we can take advantage of possible redundancy between stereo channels by encoding with a mid-side technique to decrease the required number of bits to store an audio file without any lose of quality [, 3, 4]. Left and Right audio signals can be converted to Mid and Side signals adding and subtracting the signals as in Left + Right Mid = Left Right Side =, and can be losselessly converted back to Left and Right signals by (1) Left = Mid + Side () Right = Mid Side. When the Left and Right signals are highly coherent and there is redundancy between the channels, converting to Mid/Side cuts down the data requirement as the difference of the channels the Side signal will be very small. 3.1. Modifications to Psychoacoustic Model In our audio coder, we decide to encode L/R or M/S signals based on level differences in each Bark band in each data frame. In each critical band of the MDCT representation of the Left and Right channels, that band s signal will be encoded as a Mid/Side signal if they are on average within 3dB of each other. Figure 5 shows the MDCT of a signal that is duplicated in two channels, with an extra sinusoidal component present in only one channel. The second part of this figure shows the same data if it is encoded as a M/S signal rather than as Left and Right. Due to the natures of this test signal, the Mid channel stores the same data as the Left and Right signals with the exception of the sinusoidal component that only appears in one channel that data is encoded in the Side (difference) channel. We choose to encode M/S signals on a critical-by-critical band basis, which means that in this test signal, we would only choose to encode the frequency ranges where the signals are very similar in both channels. Figure 6 shows signal-to-masking ratios (SMR) for Left/Right, Mid/Side, and a composite L/M R/S signal. The colored bars behind the composite SMR Additionally, when we store M/S signals, we must also update our masking curves to take into account binaural masking effects. In the baseline coder, the masking thresholds are created by finding peaks in a Sine windowed FFT of the signal and adding maskers centered around those found frequencies by the following set of equations: 0, 1 z 1 masker(z, L M ) = 7( z 1 ), z < 1, 7 + 0.37 max(l M 40, 0)( z 1 ), z > 1 (3) where z is the center frequency of a critical band in Barks and L M is the SPL of the masker in db. To compute the masking curves for M/S signals, we use the same formula calculated on the Mid and Side channels, but also take an extra masking threshold into account. This extra masking function (MLD) is displayed in figure 7. The final masking curve for an M/S signal is determined by THR M = max (THR M, min (THR S, THR S MLD)) (4) THR S = max (THR S, min (THR M, THR M MLD)). This extra step biases the bit allocation to allocated extra bits to low frequencies and in any case where the M/S encoding is likely to expose extra perceptual artifacts if there are not enough bits allocated to mask them. In order to see any gains from the stereo coding, we also modified the bit allocation routine, which uses a water filling approach to allocate bits to the highest peaks in the SNR, to stop allocating bits once there are a sufficient number of bits allocated to a given Bark band. 4. HUFFMAN ENCODING In bandwidth-limited or storage limited applications, a low data rate is desirable for the encoding and decoding of audio files. One popular method of reducing the data rate without compromising audio quality is entropy encoding. Entropy encoding takes advantage of the uneven distribution of mantissa values to reduce the number of bits needed to code the most common mantissa values. The entropy encoding method used for the coder was Huffman coding. The Huffman coding feature utilized encoding and decoding tables based on binary trees built from the probability distribution of the unsigned mantissa values.

4.1. Design Due to the limited bit budget used to encode each block of data and pass the decoding tables, the coder utilized 16 static Huffman encoding and decoding tables. Each of the 16 static encoding tables was built through the distribution of unsigned mantissa values from audio files, encompassing diverse music genres, voice and instrument files from the SQAM disk, and ambient noise (e.g. nature and traffic). Each of the static encoding tables covered absolute mantissa code values from 0 to 047, supporting 1 bit mantissas, which include the sign-bit. The table size was limited due to the fact that each possible mantissa value needed to be coded. For this reason, the coder itself limited the maximum mantissa bit allocation to 1 from 16 in the baseline version. In testing the castanets SQAM disk file, there was no noticeable difference in sound quality between the two different mantissa bit allocation limits. In general, even with waterfilling, scale factor bands rarely receive more than 10 bits for the 18 kbps coder. For the 16-bit maximum mantissa size case, there was a very small percentage of absolute mantissa values that exceeded 103 (see Figure 8). This suggested that using Huffman tables based on 11-bit mantissa values could have still been feasible, with the help of escape codes (codes for values that are larger than what the table can support). Having set the table size, the possibility of a sample block having an unsigned mantissa value that was not present in a Huffman table had to accounted for. This problem was important to solve since the decoder assumes that each mantissa value in the incoming bitstream is a Huffman code. The solution to this was Laplace smoothing, which is performed on the distribution of unsigned mantissa values for each of the 16 training audio files. Laplace smoothing is adding a pseudocount to any value that was not present in the training file. This has the effect of ensuring that there is no mantissa value that has zero probability, and therefore ensuring that it will be included in the Huffman tree and tables produced. Given that there were 048 possible unsigned mantissa values, and thousands of total mantissa values in an entire song, Laplace smoothing had a negligible effect on the probabilities for the castanets training file. More importantly, Laplace smoothing had no effect on the number of bits in the Huffman codes of the top 5 most probable mantissa values. (See Figures 9 and 10). A final noteworthy observation of the training data throughout various files is that most common mantissa values were values between 0-10, in ascending order. 4.. Implementation The Huffman tables built from the training audio files were stored in a Python pickle file (.pkl). This file was loaded in the pacfile.py module. Before data was passed into the huffman.py module to be coded, the sign bit was stripped from each mantissa value and stored separately. Within the huffman.py module, a channel of data was Huffman coded through by each of the 16 static tables, from which point, the table that led to the smallest number of Huffman code bits was chosen. The table choice was written into the bitstream. Each channel for a block of data was written to the bit stream in the following format: { other header data }{ table chosen }{ pre-huffman bit allocation for a scale factor band }{ sign bit }{ huffman code }{ sign bit }{ huffman code }...etc. For reading the coded data for the decoding process, only one bit could be read at a time for a given scale factor band, since the mantissa codes had a variable number of bits. Between reading one bit at a time in the decoding stage and running the Huffman encoding routine 17 times to best encode each channel of a sample block, the overall coder ran noticeably slower than the baseline version. Although for this project, speed was not a priority. 5. CONCLUSIONS Block switching had a huge impact on the perceived quality of the coded samples by drastically reducing the amount of pre-echo present on transients. As a result of the reduced block size and the fact that at least three shorter windows are always used consecutively over transients, there is sometimes a small amount of frequency quantization distortion audible during a transient. Future work would focus on finding ways to minimize the number of short windows needed to effectively capture a transient in order to alleviate this problem. As it turns out, stereo encoding is very challenging. A significant number of bits need to be allocated to mask binaural artifacts that can be heard when the Left and Right signals are separated into Mid and Side signals. The literature is not very comprehensive or clear on the best way to implement stereo encoding making the task that much more difficult. While testing the coder that only contained the Huffman coding feature, the output.pac files ranged from 80-85% the size of the.pac files that came from the baseline. However, after integrating the Huffman coding feature with the stereo coding and blockswitching features, the output.pac files ranged from 90-95% the size of the.pac files that came from the baseline. This loss in compression can be attributed to the extra header bits allocated to indicate block switching and which scale factor bands had M/S coding. The Huffman feature can only reduce the number of mantissa bits, and was therefore, limited by the extra housekeeping data. Nevertheless, the tradeoff was necessary for a better sounding coder than the baseline. For future iterations, a larger more complex set of Huffman tables could be used, constructed based on scale factor band and number of mantissa bits. For smaller huffman tables, implementing escape codes would be necessary. When the bit savings sufficiently improve, the bits saved for a block of data would be fed back through the bit allocation routine and used to more precisely quantize the MDCT lines, reducing quantization noise and improving sound quality. Overall, this project has provided us deep insight on how to design and implement quality perceptual audio coders, given the ever-present limitations on data rate. 6. REFERENCES [1] Marina Bosi and Richard Goldberg, Introduction to Digital Audio Coding and Standards, Kluwer Academic Publishers, 003. [] James D. Jonston and Anibal J. Ferreira, Sum-difference stereo transform coding, in International Conference on Acoustics, Speech, and Signal Processing, 199. [3] Chi-Min Liu, Wen-Chieh Lee, and Yo-Hsa Hsiao, M/s coding based on allocation entropy, in International Conference on Digital Audio Effects, 003. [4] Jens Blauert, Spatial Hearing: The Psychophysics of Human Sound Localization, MIT Press, 1997. 3

(a) Castanets (a) Long (b) Short (c) Start (d) Stop (b) German Male Figure : Block switching windows (c) Glockenspiel (d) Harpsichord Figure 3: Window switching Figure 1: Transient detection for serval SQAM samples. 4

Figure 5: Left and Right MDCT vs Mid and Side MDCT (a) Typical window switching sequence with single transient block (b) Window switching sequence with consecutive transient blocks Figure 6: Left and Right SMR, Mid and Side SMR, and composite SMR (c) Window switching sequence with alternating transient blocks Figure 4: Block switching sequence Figure 7: Masking Level Difference 5

Figure 8: Unsigned Value Mantissa Distribution, MaxMatBits = 16 for castanets.wav Figure 9: Top 5 Unsigned Mantissa Values, No Laplace Smoothing for castanets.wav Figure 10: Top 5 Unsigned Mantissa Values, Laplace Smoothing for castanets.wav 6