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

Function parse_optional_info

libavcodec/dca_core.c:1683–1794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1681}
1682
1683static int parse_optional_info(DCACoreDecoder *s)
1684{
1685 DCAContext *dca = s->avctx->priv_data;
1686 int ret = -1;
1687
1688 // Time code stamp
1689 if (s->ts_present)
1690 skip_bits_long(&s->gb, 32);
1691
1692 // Auxiliary data
1693 if (s->aux_present && (ret = parse_aux_data(s)) < 0
1694 && (s->avctx->err_recognition & AV_EF_EXPLODE))
1695 return ret;
1696
1697 if (ret < 0)
1698 s->prim_dmix_embedded = 0;
1699
1700 // Core extensions
1701 if (s->ext_audio_present && !dca->core_only) {
1702 int sync_pos = FFMIN(s->frame_size / 4, s->gb.size_in_bits / 32) - 1;
1703 int last_pos = get_bits_count(&s->gb) / 32;
1704 int size, dist;
1705 uint32_t w1, w2 = 0;
1706
1707 // Search for extension sync words aligned on 4-byte boundary. Search
1708 // must be done backwards from the end of core frame to work around
1709 // sync word aliasing issues.
1710 switch (s->ext_audio_type) {
1711 case DCA_EXT_AUDIO_XCH:
1712 if (dca->request_channel_layout)
1713 break;
1714
1715 // The distance between XCH sync word and end of the core frame
1716 // must be equal to XCH frame size. Off by one error is allowed for
1717 // compatibility with legacy bitstreams. Minimum XCH frame size is
1718 // 96 bytes. AMODE and PCHS are further checked to reduce
1719 // probability of alias sync detection.
1720 for (; sync_pos >= last_pos; sync_pos--, w2 = w1) {
1721 w1 = AV_RB32(s->gb.buffer + sync_pos * 4);
1722 if (w1 == DCA_SYNCWORD_XCH) {
1723 size = (w2 >> 22) + 1;
1724 dist = s->frame_size - sync_pos * 4;
1725 if (size >= 96
1726 && (size == dist || size - 1 == dist)
1727 && (w2 >> 15 & 0x7f) == 0x08) {
1728 s->xch_pos = sync_pos * 32 + 49;
1729 break;
1730 }
1731 }
1732 }
1733
1734 if (!s->xch_pos) {
1735 av_log(s->avctx, AV_LOG_ERROR, "XCH sync word not found\n");
1736 if (s->avctx->err_recognition & AV_EF_EXPLODE)
1737 return AVERROR_INVALIDDATA;
1738 }
1739 break;
1740

Callers 1

ff_dca_core_parseFunction · 0.85

Calls 5

skip_bits_longFunction · 0.85
parse_aux_dataFunction · 0.85
get_bits_countFunction · 0.85
av_logFunction · 0.85
av_crcFunction · 0.85

Tested by

no test coverage detected