libaacplus: fix failed assertion

Top Page

Reply to this message
Author: Jindřich Makovička
Date:  
To: Debian Multimedia ML
Subject: libaacplus: fix failed assertion
Hi,

in the 3GPP code, SBR envelope is computed using floating point, and
probably due to rounding errors, the result sometimes exceeds the
allowed range [0-31], causing an assertion failure later when trying
to encode the value difference.

This patch fixes the problem by clamping the output values of
extractSbrEnvelope.

Example of gdb output:

#0  0x00007ff664added5 in raise () from /lib/libc.so.6
#1  0x00007ff664adf3f3 in abort () from /lib/libc.so.6
#2  0x00007ff664ad6dc9 in __assert_fail () from /lib/libc.so.6
#3  0x00007ff6650232e9 in computeBits (delta=-32,
codeBookScfLavLevel=31, codeBookScfLavBalance=31,
    hufftableLevel=0x7ff6650502e0 "\022\022", '\023' <repeats 15
times>, "\021\020\020\020\016\016\016\r\f\v\b\006\004\002\001\003\005\a\t\v\r\016\016\017\020\021\022",
'\023' <repeats 19 times>,
    hufftableBalance=0x7ff6650502e0 "\022\022", '\023' <repeats 15
times>, "\021\020\020\020\016\016\016\r\f\v\b\006\004\002\001\003\005\a\t\v\r\016\016\017\020\021\022",
'\023' <repeats 19 times>, coupling=0, channel=0) at code_env.c:404
#4  0x00007ff665023a56 in codeEnvelope (sfb_nrg=0x7fff1fe91090,
freq_res=0x26a7bc4, h_sbrCodeEnvelope=0x26a7438,
directionVec=0x26a8528,
    coupling=0, nEnvelopes=2, channel=0, headerActive=0) at code_env.c:652
#5  0x00007ff6650271a9 in extractSbrEnvelope (fftctx=0x26b1898,
timeInPtr=0x26b18b8, pCoreBuffer=0x26b18b8, timeInStride=2,
    h_con=0x26b0bb8, sbrHeaderData=0x26b0bf8,
sbrBitstreamData=0x26b0c40, h_envChan=0x26b0c60, hPsEnc=0x0,
hSynthesisQmfBank=0x0,
    hCmonData=0x26b0c70) at env_est.c:1148
#6  0x00007ff66503d3a0 in EnvEncodeFrame (hEnvEncoder=0x26b0bb0,
samples=0x26b18b8, pCoreBuffer=0x26b18b8, timeInStride=2,
    numAncBytes=0x26b8940, ancData=0x26b8944
"��L�|\024��\177���w���o\177?�\003\f") at sbr_main.c:540
#7  0x00007ff6650479dc in aacplusEncEncode (hEncoder=0x26ad2c0,
inputBuffer=0x26a9720, samplesInput=4096,
    outputBuffer=0x26cca50 "��X\200=\200", bufferSize=65536) at aacplusenc.c:331
#8  0x0000000000411216 in aacPlus_encode_frame (avctx=0x265a770,
frame=0x26cca50 "��X\200=\200", buf_size=65536, data=0x26a9720)
    at libaacplus.c:110
#9  0x00007ff666e71279 in avcodec_encode_audio () from
/opt/ffmpeg-svn/lib/libavcodec.so.52
#10 0x000000000040ea42 in processAudioPacket (pkt=0x7fff1fe91c90) at
encoder.cc:467
#11 0x000000000041012b in reencode (source_url=0x7fff1fe93e4f
"test.ts", dest_url=0x7fff1fe93e5a "out.ts", first_chunk_id=0x0,
    last_chunk_id=0x0, last_chunk_offset=0x0) at encoder.cc:996
#12 0x0000000000410d09 in main (argc=7, argv=0x7fff1fe92268) at encoder.cc:1237



--
Jindrich Makovicka