OLD | NEW |
1 /* Copyright (c) 2011 Xiph.Org Foundation | 1 /* Copyright (c) 2011 Xiph.Org Foundation |
2 Written by Jean-Marc Valin */ | 2 Written by Jean-Marc Valin */ |
3 /* | 3 /* |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 | 10 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 clt_mdct_forward(&celt_mode->mdct, in, freq, celt_mode->window, overlap, c
elt_mode->maxLM-LM, 1); | 260 clt_mdct_forward(&celt_mode->mdct, in, freq, celt_mode->window, overlap, c
elt_mode->maxLM-LM, 1); |
261 if (upsample != 1) | 261 if (upsample != 1) |
262 { | 262 { |
263 int bound = len; | 263 int bound = len; |
264 for (i=0;i<bound;i++) | 264 for (i=0;i<bound;i++) |
265 freq[i] *= upsample; | 265 freq[i] *= upsample; |
266 for (;i<frame_size;i++) | 266 for (;i<frame_size;i++) |
267 freq[i] = 0; | 267 freq[i] = 0; |
268 } | 268 } |
269 | 269 |
270 compute_band_energies(celt_mode, freq, bandE, 21, 1, 1<<LM); | 270 compute_band_energies(celt_mode, freq, bandE, 21, 1, LM); |
271 amp2Log2(celt_mode, 21, 21, bandE, bandLogE+21*c, 1); | 271 amp2Log2(celt_mode, 21, 21, bandE, bandLogE+21*c, 1); |
272 /* Apply spreading function with -6 dB/band going up and -12 dB/band going
down. */ | 272 /* Apply spreading function with -6 dB/band going up and -12 dB/band going
down. */ |
273 for (i=1;i<21;i++) | 273 for (i=1;i<21;i++) |
274 bandLogE[21*c+i] = MAX16(bandLogE[21*c+i], bandLogE[21*c+i-1]-QCONST16(
1.f, DB_SHIFT)); | 274 bandLogE[21*c+i] = MAX16(bandLogE[21*c+i], bandLogE[21*c+i-1]-QCONST16(
1.f, DB_SHIFT)); |
275 for (i=19;i>=0;i--) | 275 for (i=19;i>=0;i--) |
276 bandLogE[21*c+i] = MAX16(bandLogE[21*c+i], bandLogE[21*c+i+1]-QCONST16(
2.f, DB_SHIFT)); | 276 bandLogE[21*c+i] = MAX16(bandLogE[21*c+i], bandLogE[21*c+i+1]-QCONST16(
2.f, DB_SHIFT)); |
277 if (pos[c]==1) | 277 if (pos[c]==1) |
278 { | 278 { |
279 for (i=0;i<21;i++) | 279 for (i=0;i<21;i++) |
280 maskLogE[0][i] = logSum(maskLogE[0][i], bandLogE[21*c+i]); | 280 maskLogE[0][i] = logSum(maskLogE[0][i], bandLogE[21*c+i]); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 int application, | 401 int application, |
402 int surround | 402 int surround |
403 ) | 403 ) |
404 { | 404 { |
405 int coupled_size; | 405 int coupled_size; |
406 int mono_size; | 406 int mono_size; |
407 int i, ret; | 407 int i, ret; |
408 char *ptr; | 408 char *ptr; |
409 | 409 |
410 if ((channels>255) || (channels<1) || (coupled_streams>streams) || | 410 if ((channels>255) || (channels<1) || (coupled_streams>streams) || |
411 (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) | 411 (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) |
412 return OPUS_BAD_ARG; | 412 return OPUS_BAD_ARG; |
413 | 413 |
414 st->layout.nb_channels = channels; | 414 st->layout.nb_channels = channels; |
415 st->layout.nb_streams = streams; | 415 st->layout.nb_streams = streams; |
416 st->layout.nb_coupled_streams = coupled_streams; | 416 st->layout.nb_coupled_streams = coupled_streams; |
417 st->subframe_mem[0]=st->subframe_mem[1]=st->subframe_mem[2]=0; | 417 st->subframe_mem[0]=st->subframe_mem[1]=st->subframe_mem[2]=0; |
418 if (!surround) | 418 if (!surround) |
419 st->lfe_stream = -1; | 419 st->lfe_stream = -1; |
420 st->bitrate_bps = OPUS_AUTO; | 420 st->bitrate_bps = OPUS_AUTO; |
421 st->application = application; | 421 st->application = application; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 int streams, | 523 int streams, |
524 int coupled_streams, | 524 int coupled_streams, |
525 const unsigned char *mapping, | 525 const unsigned char *mapping, |
526 int application, | 526 int application, |
527 int *error | 527 int *error |
528 ) | 528 ) |
529 { | 529 { |
530 int ret; | 530 int ret; |
531 OpusMSEncoder *st; | 531 OpusMSEncoder *st; |
532 if ((channels>255) || (channels<1) || (coupled_streams>streams) || | 532 if ((channels>255) || (channels<1) || (coupled_streams>streams) || |
533 (coupled_streams+streams>255) || (streams<1) || (coupled_streams<0)) | 533 (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) |
534 { | 534 { |
535 if (error) | 535 if (error) |
536 *error = OPUS_BAD_ARG; | 536 *error = OPUS_BAD_ARG; |
537 return NULL; | 537 return NULL; |
538 } | 538 } |
539 st = (OpusMSEncoder *)opus_alloc(opus_multistream_encoder_get_size(streams, c
oupled_streams)); | 539 st = (OpusMSEncoder *)opus_alloc(opus_multistream_encoder_get_size(streams, c
oupled_streams)); |
540 if (st==NULL) | 540 if (st==NULL) |
541 { | 541 { |
542 if (error) | 542 if (error) |
543 *error = OPUS_ALLOC_FAIL; | 543 *error = OPUS_ALLOC_FAIL; |
(...skipping 15 matching lines...) Expand all Loading... |
559 int channels, | 559 int channels, |
560 int mapping_family, | 560 int mapping_family, |
561 int *streams, | 561 int *streams, |
562 int *coupled_streams, | 562 int *coupled_streams, |
563 unsigned char *mapping, | 563 unsigned char *mapping, |
564 int application, | 564 int application, |
565 int *error | 565 int *error |
566 ) | 566 ) |
567 { | 567 { |
568 int ret; | 568 int ret; |
| 569 opus_int32 size; |
569 OpusMSEncoder *st; | 570 OpusMSEncoder *st; |
570 if ((channels>255) || (channels<1)) | 571 if ((channels>255) || (channels<1)) |
571 { | 572 { |
572 if (error) | 573 if (error) |
573 *error = OPUS_BAD_ARG; | 574 *error = OPUS_BAD_ARG; |
574 return NULL; | 575 return NULL; |
575 } | 576 } |
576 st = (OpusMSEncoder *)opus_alloc(opus_multistream_surround_encoder_get_size(c
hannels, mapping_family)); | 577 size = opus_multistream_surround_encoder_get_size(channels, mapping_family); |
| 578 if (!size) |
| 579 { |
| 580 if (error) |
| 581 *error = OPUS_UNIMPLEMENTED; |
| 582 return NULL; |
| 583 } |
| 584 st = (OpusMSEncoder *)opus_alloc(size); |
577 if (st==NULL) | 585 if (st==NULL) |
578 { | 586 { |
579 if (error) | 587 if (error) |
580 *error = OPUS_ALLOC_FAIL; | 588 *error = OPUS_ALLOC_FAIL; |
581 return NULL; | 589 return NULL; |
582 } | 590 } |
583 ret = opus_multistream_surround_encoder_init(st, Fs, channels, mapping_family
, streams, coupled_streams, mapping, application); | 591 ret = opus_multistream_surround_encoder_init(st, Fs, channels, mapping_family
, streams, coupled_streams, mapping, application); |
584 if (ret != OPUS_OK) | 592 if (ret != OPUS_OK) |
585 { | 593 { |
586 opus_free(st); | 594 opus_free(st); |
587 st = NULL; | 595 st = NULL; |
588 } | 596 } |
589 if (error) | 597 if (error) |
590 *error = ret; | 598 *error = ret; |
591 return st; | 599 return st; |
592 } | 600 } |
593 | 601 |
594 static void surround_rate_allocation( | 602 static opus_int32 surround_rate_allocation( |
595 OpusMSEncoder *st, | 603 OpusMSEncoder *st, |
596 opus_int32 *rate, | 604 opus_int32 *rate, |
597 int frame_size | 605 int frame_size |
598 ) | 606 ) |
599 { | 607 { |
600 int i; | 608 int i; |
601 opus_int32 channel_rate; | 609 opus_int32 channel_rate; |
602 opus_int32 Fs; | 610 opus_int32 Fs; |
603 char *ptr; | 611 char *ptr; |
604 int stream_offset; | 612 int stream_offset; |
605 int lfe_offset; | 613 int lfe_offset; |
606 int coupled_ratio; /* Q8 */ | 614 int coupled_ratio; /* Q8 */ |
607 int lfe_ratio; /* Q8 */ | 615 int lfe_ratio; /* Q8 */ |
| 616 opus_int32 rate_sum=0; |
608 | 617 |
609 ptr = (char*)st + align(sizeof(OpusMSEncoder)); | 618 ptr = (char*)st + align(sizeof(OpusMSEncoder)); |
610 opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); | 619 opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); |
611 | 620 |
612 if (st->bitrate_bps > st->layout.nb_channels*40000) | 621 if (st->bitrate_bps > st->layout.nb_channels*40000) |
613 stream_offset = 20000; | 622 stream_offset = 20000; |
614 else | 623 else |
615 stream_offset = st->bitrate_bps/st->layout.nb_channels/2; | 624 stream_offset = st->bitrate_bps/st->layout.nb_channels/2; |
616 stream_offset += 60*(Fs/frame_size-50); | 625 stream_offset += 60*(Fs/frame_size-50); |
617 /* We start by giving each stream (coupled or uncoupled) the same bitrate. | 626 /* We start by giving each stream (coupled or uncoupled) the same bitrate. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 #endif | 662 #endif |
654 | 663 |
655 for (i=0;i<st->layout.nb_streams;i++) | 664 for (i=0;i<st->layout.nb_streams;i++) |
656 { | 665 { |
657 if (i<st->layout.nb_coupled_streams) | 666 if (i<st->layout.nb_coupled_streams) |
658 rate[i] = stream_offset+(channel_rate*coupled_ratio>>8); | 667 rate[i] = stream_offset+(channel_rate*coupled_ratio>>8); |
659 else if (i!=st->lfe_stream) | 668 else if (i!=st->lfe_stream) |
660 rate[i] = stream_offset+channel_rate; | 669 rate[i] = stream_offset+channel_rate; |
661 else | 670 else |
662 rate[i] = lfe_offset+(channel_rate*lfe_ratio>>8); | 671 rate[i] = lfe_offset+(channel_rate*lfe_ratio>>8); |
| 672 rate[i] = IMAX(rate[i], 500); |
| 673 rate_sum += rate[i]; |
663 } | 674 } |
| 675 return rate_sum; |
664 } | 676 } |
665 | 677 |
666 /* Max size in case the encoder decides to return three frames */ | 678 /* Max size in case the encoder decides to return three frames */ |
667 #define MS_FRAME_TMP (3*1275+7) | 679 #define MS_FRAME_TMP (3*1275+7) |
668 static int opus_multistream_encode_native | 680 static int opus_multistream_encode_native |
669 ( | 681 ( |
670 OpusMSEncoder *st, | 682 OpusMSEncoder *st, |
671 opus_copy_channel_in_func copy_channel_in, | 683 opus_copy_channel_in_func copy_channel_in, |
672 const void *pcm, | 684 const void *pcm, |
673 int analysis_frame_size, | 685 int analysis_frame_size, |
674 unsigned char *data, | 686 unsigned char *data, |
675 opus_int32 max_data_bytes, | 687 opus_int32 max_data_bytes, |
676 int lsb_depth, | 688 int lsb_depth, |
677 downmix_func downmix | 689 downmix_func downmix, |
| 690 int float_api |
678 ) | 691 ) |
679 { | 692 { |
680 opus_int32 Fs; | 693 opus_int32 Fs; |
681 int coupled_size; | 694 int coupled_size; |
682 int mono_size; | 695 int mono_size; |
683 int s; | 696 int s; |
684 char *ptr; | 697 char *ptr; |
685 int tot_size; | 698 int tot_size; |
686 VARDECL(opus_val16, buf); | 699 VARDECL(opus_val16, buf); |
687 VARDECL(opus_val16, bandSMR); | 700 VARDECL(opus_val16, bandSMR); |
688 unsigned char tmp_data[MS_FRAME_TMP]; | 701 unsigned char tmp_data[MS_FRAME_TMP]; |
689 OpusRepacketizer rp; | 702 OpusRepacketizer rp; |
690 opus_int32 vbr; | 703 opus_int32 vbr; |
691 const CELTMode *celt_mode; | 704 const CELTMode *celt_mode; |
692 opus_int32 bitrates[256]; | 705 opus_int32 bitrates[256]; |
693 opus_val16 bandLogE[42]; | 706 opus_val16 bandLogE[42]; |
694 opus_val32 *mem = NULL; | 707 opus_val32 *mem = NULL; |
695 opus_val32 *preemph_mem=NULL; | 708 opus_val32 *preemph_mem=NULL; |
696 int frame_size; | 709 int frame_size; |
| 710 opus_int32 rate_sum; |
| 711 opus_int32 smallest_packet; |
697 ALLOC_STACK; | 712 ALLOC_STACK; |
698 | 713 |
699 if (st->surround) | 714 if (st->surround) |
700 { | 715 { |
701 preemph_mem = ms_get_preemph_mem(st); | 716 preemph_mem = ms_get_preemph_mem(st); |
702 mem = ms_get_window_mem(st); | 717 mem = ms_get_window_mem(st); |
703 } | 718 } |
704 | 719 |
705 ptr = (char*)st + align(sizeof(OpusMSEncoder)); | 720 ptr = (char*)st + align(sizeof(OpusMSEncoder)); |
706 opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); | 721 opus_encoder_ctl((OpusEncoder*)ptr, OPUS_GET_SAMPLE_RATE(&Fs)); |
(...skipping 23 matching lines...) Expand all Loading... |
730 } | 745 } |
731 /* Validate frame_size before using it to allocate stack space. | 746 /* Validate frame_size before using it to allocate stack space. |
732 This mirrors the checks in opus_encode[_float](). */ | 747 This mirrors the checks in opus_encode[_float](). */ |
733 if (400*frame_size != Fs && 200*frame_size != Fs && | 748 if (400*frame_size != Fs && 200*frame_size != Fs && |
734 100*frame_size != Fs && 50*frame_size != Fs && | 749 100*frame_size != Fs && 50*frame_size != Fs && |
735 25*frame_size != Fs && 50*frame_size != 3*Fs) | 750 25*frame_size != Fs && 50*frame_size != 3*Fs) |
736 { | 751 { |
737 RESTORE_STACK; | 752 RESTORE_STACK; |
738 return OPUS_BAD_ARG; | 753 return OPUS_BAD_ARG; |
739 } | 754 } |
| 755 |
| 756 /* Smallest packet the encoder can produce. */ |
| 757 smallest_packet = st->layout.nb_streams*2-1; |
| 758 if (max_data_bytes < smallest_packet) |
| 759 { |
| 760 RESTORE_STACK; |
| 761 return OPUS_BUFFER_TOO_SMALL; |
| 762 } |
740 ALLOC(buf, 2*frame_size, opus_val16); | 763 ALLOC(buf, 2*frame_size, opus_val16); |
741 coupled_size = opus_encoder_get_size(2); | 764 coupled_size = opus_encoder_get_size(2); |
742 mono_size = opus_encoder_get_size(1); | 765 mono_size = opus_encoder_get_size(1); |
743 | 766 |
744 ALLOC(bandSMR, 21*st->layout.nb_channels, opus_val16); | 767 ALLOC(bandSMR, 21*st->layout.nb_channels, opus_val16); |
745 if (st->surround) | 768 if (st->surround) |
746 { | 769 { |
747 surround_analysis(celt_mode, pcm, bandSMR, mem, preemph_mem, frame_size, 1
20, st->layout.nb_channels, Fs, copy_channel_in); | 770 surround_analysis(celt_mode, pcm, bandSMR, mem, preemph_mem, frame_size, 1
20, st->layout.nb_channels, Fs, copy_channel_in); |
748 } | 771 } |
749 | 772 |
750 if (max_data_bytes < 4*st->layout.nb_streams-1) | |
751 { | |
752 RESTORE_STACK; | |
753 return OPUS_BUFFER_TOO_SMALL; | |
754 } | |
755 | |
756 /* Compute bitrate allocation between streams (this could be a lot better) */ | 773 /* Compute bitrate allocation between streams (this could be a lot better) */ |
757 surround_rate_allocation(st, bitrates, frame_size); | 774 rate_sum = surround_rate_allocation(st, bitrates, frame_size); |
758 | 775 |
759 if (!vbr) | 776 if (!vbr) |
760 max_data_bytes = IMIN(max_data_bytes, 3*st->bitrate_bps/(3*8*Fs/frame_size
)); | 777 { |
761 | 778 if (st->bitrate_bps == OPUS_AUTO) |
| 779 { |
| 780 max_data_bytes = IMIN(max_data_bytes, 3*rate_sum/(3*8*Fs/frame_size)); |
| 781 } else if (st->bitrate_bps != OPUS_BITRATE_MAX) |
| 782 { |
| 783 max_data_bytes = IMIN(max_data_bytes, IMAX(smallest_packet, |
| 784 3*st->bitrate_bps/(3*8*Fs/frame_size))); |
| 785 } |
| 786 } |
762 ptr = (char*)st + align(sizeof(OpusMSEncoder)); | 787 ptr = (char*)st + align(sizeof(OpusMSEncoder)); |
763 for (s=0;s<st->layout.nb_streams;s++) | 788 for (s=0;s<st->layout.nb_streams;s++) |
764 { | 789 { |
765 OpusEncoder *enc; | 790 OpusEncoder *enc; |
766 enc = (OpusEncoder*)ptr; | 791 enc = (OpusEncoder*)ptr; |
767 if (s < st->layout.nb_coupled_streams) | 792 if (s < st->layout.nb_coupled_streams) |
768 ptr += align(coupled_size); | 793 ptr += align(coupled_size); |
769 else | 794 else |
770 ptr += align(mono_size); | 795 ptr += align(mono_size); |
771 opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrates[s])); | 796 opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrates[s])); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 for (i=0;i<21;i++) | 861 for (i=0;i<21;i++) |
837 bandLogE[i] = bandSMR[21*chan+i]; | 862 bandLogE[i] = bandSMR[21*chan+i]; |
838 } | 863 } |
839 c1 = chan; | 864 c1 = chan; |
840 c2 = -1; | 865 c2 = -1; |
841 } | 866 } |
842 if (st->surround) | 867 if (st->surround) |
843 opus_encoder_ctl(enc, OPUS_SET_ENERGY_MASK(bandLogE)); | 868 opus_encoder_ctl(enc, OPUS_SET_ENERGY_MASK(bandLogE)); |
844 /* number of bytes left (+Toc) */ | 869 /* number of bytes left (+Toc) */ |
845 curr_max = max_data_bytes - tot_size; | 870 curr_max = max_data_bytes - tot_size; |
846 /* Reserve three bytes for the last stream and four for the others */ | 871 /* Reserve one byte for the last stream and two for the others */ |
847 curr_max -= IMAX(0,4*(st->layout.nb_streams-s-1)-1); | 872 curr_max -= IMAX(0,2*(st->layout.nb_streams-s-1)-1); |
848 curr_max = IMIN(curr_max,MS_FRAME_TMP); | 873 curr_max = IMIN(curr_max,MS_FRAME_TMP); |
| 874 /* Repacketizer will add one or two bytes for self-delimited frames */ |
| 875 if (s != st->layout.nb_streams-1) curr_max -= curr_max>253 ? 2 : 1; |
849 if (!vbr && s == st->layout.nb_streams-1) | 876 if (!vbr && s == st->layout.nb_streams-1) |
850 opus_encoder_ctl(enc, OPUS_SET_BITRATE(curr_max*(8*Fs/frame_size))); | 877 opus_encoder_ctl(enc, OPUS_SET_BITRATE(curr_max*(8*Fs/frame_size))); |
851 len = opus_encode_native(enc, buf, frame_size, tmp_data, curr_max, lsb_dep
th, | 878 len = opus_encode_native(enc, buf, frame_size, tmp_data, curr_max, lsb_dep
th, |
852 pcm, analysis_frame_size, c1, c2, st->layout.nb_channels, downmix); | 879 pcm, analysis_frame_size, c1, c2, st->layout.nb_channels, downmix, f
loat_api); |
853 if (len<0) | 880 if (len<0) |
854 { | 881 { |
855 RESTORE_STACK; | 882 RESTORE_STACK; |
856 return len; | 883 return len; |
857 } | 884 } |
858 /* We need to use the repacketizer to add the self-delimiting lengths | 885 /* We need to use the repacketizer to add the self-delimiting lengths |
859 while taking into account the fact that the encoder can now return | 886 while taking into account the fact that the encoder can now return |
860 more than one frame at a time (e.g. 60 ms CELT-only) */ | 887 more than one frame at a time (e.g. 60 ms CELT-only) */ |
861 opus_repacketizer_cat(&rp, tmp_data, len); | 888 opus_repacketizer_cat(&rp, tmp_data, len); |
862 len = opus_repacketizer_out_range_impl(&rp, 0, opus_repacketizer_get_nb_fr
ames(&rp), | 889 len = opus_repacketizer_out_range_impl(&rp, 0, opus_repacketizer_get_nb_fr
ames(&rp), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 #ifdef FIXED_POINT | 942 #ifdef FIXED_POINT |
916 int opus_multistream_encode( | 943 int opus_multistream_encode( |
917 OpusMSEncoder *st, | 944 OpusMSEncoder *st, |
918 const opus_val16 *pcm, | 945 const opus_val16 *pcm, |
919 int frame_size, | 946 int frame_size, |
920 unsigned char *data, | 947 unsigned char *data, |
921 opus_int32 max_data_bytes | 948 opus_int32 max_data_bytes |
922 ) | 949 ) |
923 { | 950 { |
924 return opus_multistream_encode_native(st, opus_copy_channel_in_short, | 951 return opus_multistream_encode_native(st, opus_copy_channel_in_short, |
925 pcm, frame_size, data, max_data_bytes, 16, downmix_int); | 952 pcm, frame_size, data, max_data_bytes, 16, downmix_int, 0); |
926 } | 953 } |
927 | 954 |
928 #ifndef DISABLE_FLOAT_API | 955 #ifndef DISABLE_FLOAT_API |
929 int opus_multistream_encode_float( | 956 int opus_multistream_encode_float( |
930 OpusMSEncoder *st, | 957 OpusMSEncoder *st, |
931 const float *pcm, | 958 const float *pcm, |
932 int frame_size, | 959 int frame_size, |
933 unsigned char *data, | 960 unsigned char *data, |
934 opus_int32 max_data_bytes | 961 opus_int32 max_data_bytes |
935 ) | 962 ) |
936 { | 963 { |
937 return opus_multistream_encode_native(st, opus_copy_channel_in_float, | 964 return opus_multistream_encode_native(st, opus_copy_channel_in_float, |
938 pcm, frame_size, data, max_data_bytes, 16, downmix_float); | 965 pcm, frame_size, data, max_data_bytes, 16, downmix_float, 1); |
939 } | 966 } |
940 #endif | 967 #endif |
941 | 968 |
942 #else | 969 #else |
943 | 970 |
944 int opus_multistream_encode_float | 971 int opus_multistream_encode_float |
945 ( | 972 ( |
946 OpusMSEncoder *st, | 973 OpusMSEncoder *st, |
947 const opus_val16 *pcm, | 974 const opus_val16 *pcm, |
948 int frame_size, | 975 int frame_size, |
949 unsigned char *data, | 976 unsigned char *data, |
950 opus_int32 max_data_bytes | 977 opus_int32 max_data_bytes |
951 ) | 978 ) |
952 { | 979 { |
953 return opus_multistream_encode_native(st, opus_copy_channel_in_float, | 980 return opus_multistream_encode_native(st, opus_copy_channel_in_float, |
954 pcm, frame_size, data, max_data_bytes, 24, downmix_float); | 981 pcm, frame_size, data, max_data_bytes, 24, downmix_float, 1); |
955 } | 982 } |
956 | 983 |
957 int opus_multistream_encode( | 984 int opus_multistream_encode( |
958 OpusMSEncoder *st, | 985 OpusMSEncoder *st, |
959 const opus_int16 *pcm, | 986 const opus_int16 *pcm, |
960 int frame_size, | 987 int frame_size, |
961 unsigned char *data, | 988 unsigned char *data, |
962 opus_int32 max_data_bytes | 989 opus_int32 max_data_bytes |
963 ) | 990 ) |
964 { | 991 { |
965 return opus_multistream_encode_native(st, opus_copy_channel_in_short, | 992 return opus_multistream_encode_native(st, opus_copy_channel_in_short, |
966 pcm, frame_size, data, max_data_bytes, 16, downmix_int); | 993 pcm, frame_size, data, max_data_bytes, 16, downmix_int, 0); |
967 } | 994 } |
968 #endif | 995 #endif |
969 | 996 |
970 int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) | 997 int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) |
971 { | 998 { |
972 va_list ap; | 999 va_list ap; |
973 int coupled_size, mono_size; | 1000 int coupled_size, mono_size; |
974 char *ptr; | 1001 char *ptr; |
975 int ret = OPUS_OK; | 1002 int ret = OPUS_OK; |
976 | 1003 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 return ret; | 1192 return ret; |
1166 bad_arg: | 1193 bad_arg: |
1167 va_end(ap); | 1194 va_end(ap); |
1168 return OPUS_BAD_ARG; | 1195 return OPUS_BAD_ARG; |
1169 } | 1196 } |
1170 | 1197 |
1171 void opus_multistream_encoder_destroy(OpusMSEncoder *st) | 1198 void opus_multistream_encoder_destroy(OpusMSEncoder *st) |
1172 { | 1199 { |
1173 opus_free(st); | 1200 opus_free(st); |
1174 } | 1201 } |
OLD | NEW |