Mercurial > libavcodec.hg
comparison wavpack.c @ 9542:c110790496ff libavcodec
Shift 9-15 bit samples to use full 16-bit range.
Patch by Laurent Aimar <fenrir at VLCsite>
Thread: [PATCH] Fixed wavpack 9-15 bits support
author | kostya |
---|---|
date | Thu, 23 Apr 2009 07:44:04 +0000 |
parents | 0dce4fe6e6f3 |
children | a00e7601b584 |
comparison
equal
deleted
inserted
replaced
9541:7afd4f44c450 | 9542:c110790496ff |
---|---|
89 int samples; | 89 int samples; |
90 int terms; | 90 int terms; |
91 Decorr decorr[MAX_TERMS]; | 91 Decorr decorr[MAX_TERMS]; |
92 int zero, one, zeroes; | 92 int zero, one, zeroes; |
93 int and, or, shift; | 93 int and, or, shift; |
94 int post_shift; | |
94 int hybrid, hybrid_bitrate; | 95 int hybrid, hybrid_bitrate; |
95 WvChannel ch[2]; | 96 WvChannel ch[2]; |
96 } WavpackContext; | 97 } WavpackContext; |
97 | 98 |
98 // exponent table copied from WavPack source | 99 // exponent table copied from WavPack source |
403 pos = (pos + 1) & 7; | 404 pos = (pos + 1) & 7; |
404 if(s->joint) | 405 if(s->joint) |
405 L += (R -= (L >> 1)); | 406 L += (R -= (L >> 1)); |
406 crc = (crc * 3 + L) * 3 + R; | 407 crc = (crc * 3 + L) * 3 + R; |
407 bit = (L & s->and) | s->or; | 408 bit = (L & s->and) | s->or; |
408 *dst++ = ((L + bit) << s->shift) - bit; | 409 *dst++ = (((L + bit) << s->shift) - bit) << s->post_shift; |
409 bit = (R & s->and) | s->or; | 410 bit = (R & s->and) | s->or; |
410 *dst++ = ((R + bit) << s->shift) - bit; | 411 *dst++ = (((R + bit) << s->shift) - bit) << s->post_shift; |
411 count++; | 412 count++; |
412 }while(!last && count < s->samples); | 413 }while(!last && count < s->samples); |
413 | 414 |
414 if(crc != s->CRC){ | 415 if(crc != s->CRC){ |
415 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); | 416 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); |
449 s->decorr[i].samplesA[j] = T = S; | 450 s->decorr[i].samplesA[j] = T = S; |
450 } | 451 } |
451 pos = (pos + 1) & 7; | 452 pos = (pos + 1) & 7; |
452 crc = crc * 3 + S; | 453 crc = crc * 3 + S; |
453 bit = (S & s->and) | s->or; | 454 bit = (S & s->and) | s->or; |
454 *dst++ = ((S + bit) << s->shift) - bit; | 455 *dst++ = (((S + bit) << s->shift) - bit) << s->post_shift; |
455 count++; | 456 count++; |
456 }while(!last && count < s->samples); | 457 }while(!last && count < s->samples); |
457 | 458 |
458 if(crc != s->CRC){ | 459 if(crc != s->CRC){ |
459 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); | 460 av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); |
510 s->frame_flags = AV_RL32(buf); buf += 4; | 511 s->frame_flags = AV_RL32(buf); buf += 4; |
511 s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo; | 512 s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo; |
512 s->joint = s->frame_flags & WV_JOINT_STEREO; | 513 s->joint = s->frame_flags & WV_JOINT_STEREO; |
513 s->hybrid = s->frame_flags & WV_HYBRID_MODE; | 514 s->hybrid = s->frame_flags & WV_HYBRID_MODE; |
514 s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE; | 515 s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE; |
516 s->post_shift = (s->frame_flags >> 13) & 0x1f; | |
515 s->CRC = AV_RL32(buf); buf += 4; | 517 s->CRC = AV_RL32(buf); buf += 4; |
516 // parse metadata blocks | 518 // parse metadata blocks |
517 while(buf < buf_end){ | 519 while(buf < buf_end){ |
518 id = *buf++; | 520 id = *buf++; |
519 size = *buf++; | 521 size = *buf++; |