Mercurial > libavcodec.hg
comparison wavpack.c @ 9566:9a3fddd31092 libavcodec
Correctly update output sample format in wavpack decoder.
Patch by Laurent Aimar (at 'fenrir (cons 'videolan 'org))
author | kostya |
---|---|
date | Sun, 26 Apr 2009 04:23:29 +0000 |
parents | 7a51c0815b28 |
children | 3f7496cd7cab |
comparison
equal
deleted
inserted
replaced
9565:5c1aeaf1bc12 | 9566:9a3fddd31092 |
---|---|
522 int samplecount; | 522 int samplecount; |
523 int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0; | 523 int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0; |
524 int got_hybrid = 0; | 524 int got_hybrid = 0; |
525 const uint8_t* buf_end = buf + buf_size; | 525 const uint8_t* buf_end = buf + buf_size; |
526 int i, j, id, size, ssize, weights, t; | 526 int i, j, id, size, ssize, weights, t; |
527 int bpp = avctx->bits_per_coded_sample <= 16 ? 2 : 4; | 527 int bpp; |
528 | 528 |
529 if (buf_size == 0){ | 529 if (buf_size == 0){ |
530 *data_size = 0; | 530 *data_size = 0; |
531 return 0; | 531 return 0; |
532 } | 532 } |
538 s->samples = AV_RL32(buf); buf += 4; | 538 s->samples = AV_RL32(buf); buf += 4; |
539 if(!s->samples){ | 539 if(!s->samples){ |
540 *data_size = 0; | 540 *data_size = 0; |
541 return buf_size; | 541 return buf_size; |
542 } | 542 } |
543 /* should not happen but who knows */ | |
544 if(s->samples * bpp * avctx->channels > *data_size){ | |
545 av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n"); | |
546 return -1; | |
547 } | |
548 s->frame_flags = AV_RL32(buf); buf += 4; | 543 s->frame_flags = AV_RL32(buf); buf += 4; |
544 if((s->frame_flags&0x03) <= 1){ | |
545 bpp = 2; | |
546 avctx->sample_fmt = SAMPLE_FMT_S16; | |
547 } else { | |
548 bpp = 4; | |
549 avctx->sample_fmt = SAMPLE_FMT_S32; | |
550 } | |
549 s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo; | 551 s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo; |
550 s->joint = s->frame_flags & WV_JOINT_STEREO; | 552 s->joint = s->frame_flags & WV_JOINT_STEREO; |
551 s->hybrid = s->frame_flags & WV_HYBRID_MODE; | 553 s->hybrid = s->frame_flags & WV_HYBRID_MODE; |
552 s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE; | 554 s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE; |
553 s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f); | 555 s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f); |
554 s->CRC = AV_RL32(buf); buf += 4; | 556 s->CRC = AV_RL32(buf); buf += 4; |
557 | |
558 /* should not happen but who knows */ | |
559 if(s->samples * bpp * avctx->channels > *data_size){ | |
560 av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n"); | |
561 return -1; | |
562 } | |
563 | |
555 // parse metadata blocks | 564 // parse metadata blocks |
556 while(buf < buf_end){ | 565 while(buf < buf_end){ |
557 id = *buf++; | 566 id = *buf++; |
558 size = *buf++; | 567 size = *buf++; |
559 if(id & WP_IDF_LONG) { | 568 if(id & WP_IDF_LONG) { |