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

Function decode_frame

libavcodec/dstdec.c:242–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
243 int *got_frame_ptr, AVPacket *avpkt)
244{
245 unsigned samples_per_frame = DST_SAMPLES_PER_FRAME(avctx->sample_rate);
246 unsigned map_ch_to_felem[DST_MAX_CHANNELS];
247 unsigned map_ch_to_pelem[DST_MAX_CHANNELS];
248 unsigned i, ch, same_map, dst_x_bit;
249 unsigned half_prob[DST_MAX_CHANNELS];
250 const int channels = avctx->ch_layout.nb_channels;
251 DSTContext *s = avctx->priv_data;
252 GetBitContext *gb = &s->gb;
253 ArithCoder *ac = &s->ac;
254 uint8_t *dsd;
255 float *pcm;
256 int ret;
257
258 if (avpkt->size <= 1)
259 return AVERROR_INVALIDDATA;
260
261 frame->nb_samples = samples_per_frame / 8;
262 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
263 return ret;
264 dsd = frame->data[0];
265 pcm = (float *)frame->data[0];
266
267 if ((ret = init_get_bits8(gb, avpkt->data, avpkt->size)) < 0)
268 return ret;
269
270 if (!get_bits1(gb)) {
271 skip_bits1(gb);
272 if (get_bits(gb, 6))
273 return AVERROR_INVALIDDATA;
274 memcpy(frame->data[0], avpkt->data + 1, FFMIN(avpkt->size - 1, frame->nb_samples * channels));
275 goto dsd;
276 }
277
278 /* Segmentation (10.4, 10.5, 10.6) */
279
280 if (!get_bits1(gb)) {
281 avpriv_request_sample(avctx, "Not Same Segmentation");
282 return AVERROR_PATCHWELCOME;
283 }
284
285 if (!get_bits1(gb)) {
286 avpriv_request_sample(avctx, "Not Same Segmentation For All Channels");
287 return AVERROR_PATCHWELCOME;
288 }
289
290 if (!get_bits1(gb)) {
291 avpriv_request_sample(avctx, "Not End Of Channel Segmentation");
292 return AVERROR_PATCHWELCOME;
293 }
294
295 /* Mapping (10.7, 10.8, 10.9) */
296
297 same_map = get_bits1(gb);
298
299 if ((ret = read_map(gb, &s->fsets, map_ch_to_felem, channels)) < 0)

Callers

nothing calls this directly

Calls 14

ff_get_bufferFunction · 0.85
init_get_bits8Function · 0.85
get_bits1Function · 0.85
skip_bits1Function · 0.85
avpriv_request_sampleFunction · 0.85
read_mapFunction · 0.85
ac_getFunction · 0.85
prob_dst_x_bitFunction · 0.85
FFunction · 0.85
ff_dsd2pcm_translateFunction · 0.85
get_bitsFunction · 0.70
read_tableFunction · 0.70

Tested by

no test coverage detected