MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / mpc8_decode_init

Function mpc8_decode_init

libavcodec/mpc8.c:141–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141static av_cold int mpc8_decode_init(AVCodecContext * avctx)
142{
143 static AVOnce init_static_once = AV_ONCE_INIT;
144 MPCContext *c = avctx->priv_data;
145 GetBitContext gb;
146 int channels;
147
148 if(avctx->extradata_size < 2){
149 av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size);
150 return -1;
151 }
152 memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
153 av_lfg_init(&c->rnd, 0xDEADBEEF);
154 ff_mpadsp_init(&c->mpadsp);
155
156 init_get_bits(&gb, avctx->extradata, 16);
157
158 uint8_t sample_rate_idx = get_bits(&gb, 3);
159 static const int sample_rates[] = { 44100, 48000, 37800, 32000 };
160 if (sample_rate_idx >= FF_ARRAY_ELEMS(sample_rates)) {
161 av_log(avctx, AV_LOG_ERROR, "invalid sample rate index (%u)\n", sample_rate_idx);
162 return AVERROR_INVALIDDATA;
163 }
164 avctx->sample_rate = sample_rates[sample_rate_idx];
165 c->maxbands = get_bits(&gb, 5) + 1;
166 if (c->maxbands >= BANDS) {
167 av_log(avctx,AV_LOG_ERROR, "maxbands %d too high\n", c->maxbands);
168 return AVERROR_INVALIDDATA;
169 }
170 channels = get_bits(&gb, 4) + 1;
171 if (channels > 2) {
172 avpriv_request_sample(avctx, "Multichannel MPC SV8");
173 return AVERROR_PATCHWELCOME;
174 }
175 c->MSS = get_bits1(&gb);
176 c->frames = 1 << (get_bits(&gb, 3) * 2);
177
178 avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
179 av_channel_layout_uninit(&avctx->ch_layout);
180 av_channel_layout_default(&avctx->ch_layout, channels);
181
182 ff_thread_once(&init_static_once, mpc8_init_static);
183
184 return 0;
185}
186
187static int mpc8_decode_frame(AVCodecContext *avctx, AVFrame *frame,
188 int *got_frame_ptr, AVPacket *avpkt)

Callers

nothing calls this directly

Calls 10

av_logFunction · 0.85
av_lfg_initFunction · 0.85
ff_mpadsp_initFunction · 0.85
init_get_bitsFunction · 0.85
avpriv_request_sampleFunction · 0.85
get_bits1Function · 0.85
av_channel_layout_uninitFunction · 0.85
ff_thread_onceFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected