From f652daf2e9bad345c0e98ab058a5e07c3d45d13e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Tue, 26 Dec 2023 16:30:35 +0100
Subject: [PATCH 3/6] Un-mark IMA APC as intra-only, only mark first packet as
keyframe
Packets must be decoded in order.
There is no way to seek and get a bitexact decode.
---
libavcodec/codec_desc.c | 2 +-
libavformat/apc.c | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
@@ -2431,7 +2431,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
.type = AVMEDIA_TYPE_AUDIO,
.name = "adpcm_ima_apc",
.long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA CRYO APC"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
+ .props = AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_ADPCM_VIMA,
@@ -75,8 +75,13 @@ static int apc_read_header(AVFormatContext *s)
static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
+ int first = avio_tell(s->pb) == 32;
if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
return AVERROR(EIO);
+ // each IMA APC packet depends on the one before for bitexact decode
+ // extradata is used to initialize the decoder
+ if (first)
+ pkt->flags |= AV_PKT_FLAG_KEY;
pkt->stream_index = 0;
return 0;
}
--
2.39.2