Revision 5d6e4c16 libavcodec/wavpack.c

View differences:

libavcodec/wavpack.c
494 494
                    B = s->decorr[i].samplesB[pos];
495 495
                    j = (pos + t) & 7;
496 496
                }
497
                if(type != SAMPLE_FMT_S16){
497
                if(type != AV_SAMPLE_FMT_S16){
498 498
                    L2 = L + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
499 499
                    R2 = R + ((s->decorr[i].weightB * (int64_t)B + 512) >> 10);
500 500
                }else{
......
506 506
                s->decorr[i].samplesA[j] = L = L2;
507 507
                s->decorr[i].samplesB[j] = R = R2;
508 508
            }else if(t == -1){
509
                if(type != SAMPLE_FMT_S16)
509
                if(type != AV_SAMPLE_FMT_S16)
510 510
                    L2 = L + ((s->decorr[i].weightA * (int64_t)s->decorr[i].samplesA[0] + 512) >> 10);
511 511
                else
512 512
                    L2 = L + ((s->decorr[i].weightA * s->decorr[i].samplesA[0] + 512) >> 10);
513 513
                UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, s->decorr[i].samplesA[0], L);
514 514
                L = L2;
515
                if(type != SAMPLE_FMT_S16)
515
                if(type != AV_SAMPLE_FMT_S16)
516 516
                    R2 = R + ((s->decorr[i].weightB * (int64_t)L2 + 512) >> 10);
517 517
                else
518 518
                    R2 = R + ((s->decorr[i].weightB * L2 + 512) >> 10);
......
520 520
                R = R2;
521 521
                s->decorr[i].samplesA[0] = R;
522 522
            }else{
523
                if(type != SAMPLE_FMT_S16)
523
                if(type != AV_SAMPLE_FMT_S16)
524 524
                    R2 = R + ((s->decorr[i].weightB * (int64_t)s->decorr[i].samplesB[0] + 512) >> 10);
525 525
                else
526 526
                    R2 = R + ((s->decorr[i].weightB * s->decorr[i].samplesB[0] + 512) >> 10);
......
532 532
                    s->decorr[i].samplesA[0] = R;
533 533
                }
534 534

  
535
                if(type != SAMPLE_FMT_S16)
535
                if(type != AV_SAMPLE_FMT_S16)
536 536
                    L2 = L + ((s->decorr[i].weightA * (int64_t)R2 + 512) >> 10);
537 537
                else
538 538
                    L2 = L + ((s->decorr[i].weightA * R2 + 512) >> 10);
......
546 546
            L += (R -= (L >> 1));
547 547
        crc = (crc * 3 + L) * 3 + R;
548 548

  
549
        if(type == SAMPLE_FMT_FLT){
549
        if(type == AV_SAMPLE_FMT_FLT){
550 550
            *dstfl++ = wv_get_value_float(s, &crc_extra_bits, L);
551 551
            *dstfl++ = wv_get_value_float(s, &crc_extra_bits, R);
552
        } else if(type == SAMPLE_FMT_S32){
552
        } else if(type == AV_SAMPLE_FMT_S32){
553 553
            *dst32++ = wv_get_value_integer(s, &crc_extra_bits, L);
554 554
            *dst32++ = wv_get_value_integer(s, &crc_extra_bits, R);
555 555
        } else {
......
613 613
                A = s->decorr[i].samplesA[pos];
614 614
                j = (pos + t) & 7;
615 615
            }
616
            if(type != SAMPLE_FMT_S16)
616
            if(type != AV_SAMPLE_FMT_S16)
617 617
                S = T + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
618 618
            else
619 619
                S = T + ((s->decorr[i].weightA * A + 512) >> 10);
......
623 623
        pos = (pos + 1) & 7;
624 624
        crc = crc * 3 + S;
625 625

  
626
        if(type == SAMPLE_FMT_FLT)
626
        if(type == AV_SAMPLE_FMT_FLT)
627 627
            *dstfl++ = wv_get_value_float(s, &crc_extra_bits, S);
628
        else if(type == SAMPLE_FMT_S32)
628
        else if(type == AV_SAMPLE_FMT_S32)
629 629
            *dst32++ = wv_get_value_integer(s, &crc_extra_bits, S);
630 630
        else
631 631
            *dst16++ = wv_get_value_integer(s, &crc_extra_bits, S);
......
662 662
    s->avctx = avctx;
663 663
    s->stereo = (avctx->channels == 2);
664 664
    if(avctx->bits_per_coded_sample <= 16)
665
        avctx->sample_fmt = SAMPLE_FMT_S16;
665
        avctx->sample_fmt = AV_SAMPLE_FMT_S16;
666 666
    else
667
        avctx->sample_fmt = SAMPLE_FMT_S32;
667
        avctx->sample_fmt = AV_SAMPLE_FMT_S32;
668 668
    avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
669 669

  
670 670
    wv_reset_saved_context(s);
......
708 708
    s->frame_flags = AV_RL32(buf); buf += 4;
709 709
    if(s->frame_flags&0x80){
710 710
        bpp = sizeof(float);
711
        avctx->sample_fmt = SAMPLE_FMT_FLT;
711
        avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
712 712
    } else if((s->frame_flags&0x03) <= 1){
713 713
        bpp = 2;
714
        avctx->sample_fmt = SAMPLE_FMT_S16;
714
        avctx->sample_fmt = AV_SAMPLE_FMT_S16;
715 715
    } else {
716 716
        bpp = 4;
717
        avctx->sample_fmt = SAMPLE_FMT_S32;
717
        avctx->sample_fmt = AV_SAMPLE_FMT_S32;
718 718
    }
719 719
    s->stereo_in = (s->frame_flags & WV_FALSE_STEREO) ? 0 : s->stereo;
720 720
    s->joint = s->frame_flags & WV_JOINT_STEREO;
......
945 945
            av_log(avctx, AV_LOG_ERROR, "Packed samples not found\n");
946 946
            return -1;
947 947
        }
948
        if(!got_float && avctx->sample_fmt == SAMPLE_FMT_FLT){
948
        if(!got_float && avctx->sample_fmt == AV_SAMPLE_FMT_FLT){
949 949
            av_log(avctx, AV_LOG_ERROR, "Float information not found\n");
950 950
            return -1;
951 951
        }
952
        if(s->got_extra_bits && avctx->sample_fmt != SAMPLE_FMT_FLT){
952
        if(s->got_extra_bits && avctx->sample_fmt != AV_SAMPLE_FMT_FLT){
953 953
            const int size = get_bits_left(&s->gb_extra_bits);
954 954
            const int wanted = s->samples * s->extra_bits << s->stereo_in;
955 955
            if(size < wanted){
......
969 969
    }
970 970

  
971 971
    if(s->stereo_in){
972
        if(avctx->sample_fmt == SAMPLE_FMT_S16)
973
            samplecount = wv_unpack_stereo(s, &s->gb, samples, SAMPLE_FMT_S16);
974
        else if(avctx->sample_fmt == SAMPLE_FMT_S32)
975
            samplecount = wv_unpack_stereo(s, &s->gb, samples, SAMPLE_FMT_S32);
972
        if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
973
            samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
974
        else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
975
            samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
976 976
        else
977
            samplecount = wv_unpack_stereo(s, &s->gb, samples, SAMPLE_FMT_FLT);
977
            samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
978 978

  
979 979
    }else{
980
        if(avctx->sample_fmt == SAMPLE_FMT_S16)
981
            samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_S16);
982
        else if(avctx->sample_fmt == SAMPLE_FMT_S32)
983
            samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_S32);
980
        if(avctx->sample_fmt == AV_SAMPLE_FMT_S16)
981
            samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S16);
982
        else if(avctx->sample_fmt == AV_SAMPLE_FMT_S32)
983
            samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
984 984
        else
985
            samplecount = wv_unpack_mono(s, &s->gb, samples, SAMPLE_FMT_FLT);
985
            samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
986 986

  
987
        if(s->stereo && avctx->sample_fmt == SAMPLE_FMT_S16){
987
        if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){
988 988
            int16_t *dst = (int16_t*)samples + samplecount * 2;
989 989
            int16_t *src = (int16_t*)samples + samplecount;
990 990
            int cnt = samplecount;
......
993 993
                *--dst = *src;
994 994
            }
995 995
            samplecount *= 2;
996
        }else if(s->stereo && avctx->sample_fmt == SAMPLE_FMT_S32){
996
        }else if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S32){
997 997
            int32_t *dst = (int32_t*)samples + samplecount * 2;
998 998
            int32_t *src = (int32_t*)samples + samplecount;
999 999
            int cnt = samplecount;

Also available in: Unified diff