Mercurial > libavcodec.hg
comparison mlpdec.c @ 9263:62774b28cde0 libavcodec
mlpdec: Split read_channel_params() into its own function.
author | ramiro |
---|---|
date | Fri, 27 Mar 2009 23:42:22 +0000 |
parents | 3c9a424163ee |
children | 230dac9ec1d4 |
comparison
equal
deleted
inserted
replaced
9262:3c9a424163ee | 9263:62774b28cde0 |
---|---|
543 } | 543 } |
544 | 544 |
545 return 0; | 545 return 0; |
546 } | 546 } |
547 | 547 |
548 /** Read channel parameters. */ | |
549 | |
550 static int read_channel_params(MLPDecodeContext *m, unsigned int substr, | |
551 GetBitContext *gbp, unsigned int ch) | |
552 { | |
553 ChannelParams *cp = &m->channel_params[ch]; | |
554 FilterParams *fir = &cp->filter_params[FIR]; | |
555 FilterParams *iir = &cp->filter_params[IIR]; | |
556 SubStream *s = &m->substream[substr]; | |
557 | |
558 if (s->param_presence_flags & PARAM_FIR) | |
559 if (get_bits1(gbp)) | |
560 if (read_filter_params(m, gbp, ch, FIR) < 0) | |
561 return -1; | |
562 | |
563 if (s->param_presence_flags & PARAM_IIR) | |
564 if (get_bits1(gbp)) | |
565 if (read_filter_params(m, gbp, ch, IIR) < 0) | |
566 return -1; | |
567 | |
568 if (fir->order && iir->order && | |
569 fir->shift != iir->shift) { | |
570 av_log(m->avctx, AV_LOG_ERROR, | |
571 "FIR and IIR filters must use the same precision.\n"); | |
572 return -1; | |
573 } | |
574 /* The FIR and IIR filters must have the same precision. | |
575 * To simplify the filtering code, only the precision of the | |
576 * FIR filter is considered. If only the IIR filter is employed, | |
577 * the FIR filter precision is set to that of the IIR filter, so | |
578 * that the filtering code can use it. */ | |
579 if (!fir->order && iir->order) | |
580 fir->shift = iir->shift; | |
581 | |
582 if (s->param_presence_flags & PARAM_HUFFOFFSET) | |
583 if (get_bits1(gbp)) | |
584 cp->huff_offset = get_sbits(gbp, 15); | |
585 | |
586 cp->codebook = get_bits(gbp, 2); | |
587 cp->huff_lsbs = get_bits(gbp, 5); | |
588 | |
589 cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); | |
590 | |
591 /* TODO: validate */ | |
592 | |
593 return 0; | |
594 } | |
595 | |
548 /** Read decoding parameters that change more often than those in the restart | 596 /** Read decoding parameters that change more often than those in the restart |
549 * header. */ | 597 * header. */ |
550 | 598 |
551 static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, | 599 static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp, |
552 unsigned int substr) | 600 unsigned int substr) |
594 cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); | 642 cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); |
595 } | 643 } |
596 | 644 |
597 for (ch = s->min_channel; ch <= s->max_channel; ch++) | 645 for (ch = s->min_channel; ch <= s->max_channel; ch++) |
598 if (get_bits1(gbp)) { | 646 if (get_bits1(gbp)) { |
599 ChannelParams *cp = &m->channel_params[ch]; | 647 if (read_channel_params(m, substr, gbp, ch) < 0) |
600 FilterParams *fir = &cp->filter_params[FIR]; | |
601 FilterParams *iir = &cp->filter_params[IIR]; | |
602 | |
603 if (s->param_presence_flags & PARAM_FIR) | |
604 if (get_bits1(gbp)) | |
605 if (read_filter_params(m, gbp, ch, FIR) < 0) | |
606 return -1; | |
607 | |
608 if (s->param_presence_flags & PARAM_IIR) | |
609 if (get_bits1(gbp)) | |
610 if (read_filter_params(m, gbp, ch, IIR) < 0) | |
611 return -1; | |
612 | |
613 if (fir->order && iir->order && | |
614 fir->shift != iir->shift) { | |
615 av_log(m->avctx, AV_LOG_ERROR, | |
616 "FIR and IIR filters must use the same precision.\n"); | |
617 return -1; | 648 return -1; |
618 } | |
619 /* The FIR and IIR filters must have the same precision. | |
620 * To simplify the filtering code, only the precision of the | |
621 * FIR filter is considered. If only the IIR filter is employed, | |
622 * the FIR filter precision is set to that of the IIR filter, so | |
623 * that the filtering code can use it. */ | |
624 if (!fir->order && iir->order) | |
625 fir->shift = iir->shift; | |
626 | |
627 if (s->param_presence_flags & PARAM_HUFFOFFSET) | |
628 if (get_bits1(gbp)) | |
629 cp->huff_offset = get_sbits(gbp, 15); | |
630 | |
631 cp->codebook = get_bits(gbp, 2); | |
632 cp->huff_lsbs = get_bits(gbp, 5); | |
633 | |
634 cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); | |
635 | |
636 /* TODO: validate */ | |
637 } | 649 } |
638 | 650 |
639 return 0; | 651 return 0; |
640 } | 652 } |
641 | 653 |