| 1016 | } |
| 1017 | |
| 1018 | static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb) |
| 1019 | { |
| 1020 | int old_rate = s->sample_rate; |
| 1021 | int old_band_limit = s->band_limit; |
| 1022 | int old_nchannels = s->nchannels; |
| 1023 | int version, bit_rate_hi; |
| 1024 | unsigned int sr_code; |
| 1025 | |
| 1026 | // Sample rate of LBR audio |
| 1027 | sr_code = bytestream2_get_byte(gb); |
| 1028 | if (sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs)) { |
| 1029 | av_log(s->avctx, AV_LOG_ERROR, "Invalid LBR sample rate\n"); |
| 1030 | return AVERROR_INVALIDDATA; |
| 1031 | } |
| 1032 | s->sample_rate = ff_dca_sampling_freqs[sr_code]; |
| 1033 | if (s->sample_rate > 48000) { |
| 1034 | avpriv_report_missing_feature(s->avctx, "%d Hz LBR sample rate", s->sample_rate); |
| 1035 | return AVERROR_PATCHWELCOME; |
| 1036 | } |
| 1037 | |
| 1038 | // LBR speaker mask |
| 1039 | s->ch_mask = bytestream2_get_le16(gb); |
| 1040 | if (!(s->ch_mask & 0x7)) { |
| 1041 | avpriv_report_missing_feature(s->avctx, "LBR channel mask %#x", s->ch_mask); |
| 1042 | return AVERROR_PATCHWELCOME; |
| 1043 | } |
| 1044 | if ((s->ch_mask & 0xfff0) && !(s->warned & 1)) { |
| 1045 | avpriv_report_missing_feature(s->avctx, "LBR channel mask %#x", s->ch_mask); |
| 1046 | s->warned |= 1; |
| 1047 | } |
| 1048 | |
| 1049 | // LBR bitstream version |
| 1050 | version = bytestream2_get_le16(gb); |
| 1051 | if ((version & 0xff00) != 0x0800) { |
| 1052 | avpriv_report_missing_feature(s->avctx, "LBR stream version %#x", version); |
| 1053 | return AVERROR_PATCHWELCOME; |
| 1054 | } |
| 1055 | |
| 1056 | // Flags for LBR decoder initialization |
| 1057 | s->flags = bytestream2_get_byte(gb); |
| 1058 | if (s->flags & LBR_FLAG_DMIX_MULTI_CH) { |
| 1059 | avpriv_report_missing_feature(s->avctx, "LBR multi-channel downmix"); |
| 1060 | return AVERROR_PATCHWELCOME; |
| 1061 | } |
| 1062 | if ((s->flags & LBR_FLAG_LFE_PRESENT) && s->sample_rate != 48000) { |
| 1063 | if (!(s->warned & 2)) { |
| 1064 | avpriv_report_missing_feature(s->avctx, "%d Hz LFE interpolation", s->sample_rate); |
| 1065 | s->warned |= 2; |
| 1066 | } |
| 1067 | s->flags &= ~LBR_FLAG_LFE_PRESENT; |
| 1068 | } |
| 1069 | |
| 1070 | // Most significant bit rate nibbles |
| 1071 | bit_rate_hi = bytestream2_get_byte(gb); |
| 1072 | |
| 1073 | // Least significant original bit rate word |
| 1074 | s->bit_rate_orig = bytestream2_get_le16(gb) | ((bit_rate_hi & 0x0F) << 16); |
| 1075 |
no test coverage detected