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

Function tak_decode_frame

libavcodec/takdec.c:678–920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678static int tak_decode_frame(AVCodecContext *avctx, AVFrame *frame,
679 int *got_frame_ptr, AVPacket *pkt)
680{
681 TAKDecContext *s = avctx->priv_data;
682 GetBitContext *gb = &s->gb;
683 int chan, i, ret, hsize;
684
685 if (pkt->size < TAK_MIN_FRAME_HEADER_BYTES)
686 return AVERROR_INVALIDDATA;
687
688 if ((ret = init_get_bits8(gb, pkt->data, pkt->size)) < 0)
689 return ret;
690
691 if ((ret = ff_tak_decode_frame_header(avctx, gb, &s->ti, 0)) < 0)
692 return ret;
693
694 hsize = get_bits_count(gb) / 8;
695 if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_COMPLIANT)) {
696 if (ff_tak_check_crc(pkt->data, hsize)) {
697 av_log(avctx, AV_LOG_ERROR, "CRC error\n");
698 if (avctx->err_recognition & AV_EF_EXPLODE)
699 return AVERROR_INVALIDDATA;
700 }
701 }
702
703 if (s->ti.codec != TAK_CODEC_MONO_STEREO &&
704 s->ti.codec != TAK_CODEC_MULTICHANNEL) {
705 avpriv_report_missing_feature(avctx, "TAK codec type %d", s->ti.codec);
706 return AVERROR_PATCHWELCOME;
707 }
708 if (s->ti.data_type) {
709 av_log(avctx, AV_LOG_ERROR,
710 "unsupported data type: %d\n", s->ti.data_type);
711 return AVERROR_INVALIDDATA;
712 }
713 if (s->ti.codec == TAK_CODEC_MONO_STEREO && s->ti.channels > 2) {
714 av_log(avctx, AV_LOG_ERROR,
715 "invalid number of channels: %d\n", s->ti.channels);
716 return AVERROR_INVALIDDATA;
717 }
718 if (s->ti.channels > 6) {
719 av_log(avctx, AV_LOG_ERROR,
720 "unsupported number of channels: %d\n", s->ti.channels);
721 return AVERROR_INVALIDDATA;
722 }
723
724 if (s->ti.frame_samples <= 0) {
725 av_log(avctx, AV_LOG_ERROR, "unsupported/invalid number of samples\n");
726 return AVERROR_INVALIDDATA;
727 }
728
729 avctx->bits_per_raw_sample = s->ti.bps;
730 if ((ret = set_bps_params(avctx)) < 0)
731 return ret;
732 if (s->ti.sample_rate != avctx->sample_rate) {
733 avctx->sample_rate = s->ti.sample_rate;
734 set_sample_rate_params(avctx);
735 }

Callers

nothing calls this directly

Calls 15

init_get_bits8Function · 0.85
get_bits_countFunction · 0.85
ff_tak_check_crcFunction · 0.85
av_logFunction · 0.85
set_bps_paramsFunction · 0.85
set_sample_rate_paramsFunction · 0.85
av_channel_layout_uninitFunction · 0.85
av_fast_mallocFunction · 0.85

Tested by

no test coverage detected