aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/g729dec.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>2019-09-16 20:57:53 +0200
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2019-09-16 20:57:53 +0200
commit551fcbbccbca8e78443c049421f01f350d4bc370 (patch)
treef71f4719dcd6375b176e2955f848485a48f436eb /libavcodec/g729dec.c
parentdc0806dd25882f41f6085c8356712f95fded56c7 (diff)
downloadffmpeg-551fcbbccbca8e78443c049421f01f350d4bc370.tar.gz
lavc/g729dec: Support decoding Sipro ACELP.KELVIN.
Fixes ticket #4799. Analyzed-by: Aleksandr Ustinov
Diffstat (limited to 'libavcodec/g729dec.c')
-rw-r--r--libavcodec/g729dec.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 2e4756b805..25951716ef 100644
--- a/libavcodec/g729dec.c
+++ b/libavcodec/g729dec.c
@@ -424,7 +424,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
- if (buf_size % (G729_8K_BLOCK_SIZE * avctx->channels) == 0) {
+ if (buf_size % ((G729_8K_BLOCK_SIZE + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * avctx->channels) == 0) {
packet_type = FORMAT_G729_8K;
format = &format_g729_8k;
//Reset voice decision
@@ -445,6 +445,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
int bad_pitch = 0; ///< parity check failed
int is_periodic = 0; ///< whether one of the subframes is declared as periodic or not
out_frame = (int16_t*)frame->data[c];
+ if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN) {
+ if (*buf != ((avctx->channels - 1 - c) * 0x80 | 2))
+ avpriv_request_sample(avctx, "First byte value %x for channel %d", *buf, c);
+ buf++;
+ }
for (i = 0; i < buf_size; i++)
frame_erasure |= buf[i];
@@ -727,7 +732,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
}
*got_frame_ptr = 1;
- return packet_type == FORMAT_G729_8K ? G729_8K_BLOCK_SIZE * avctx->channels : G729D_6K4_BLOCK_SIZE * avctx->channels;
+ return packet_type == FORMAT_G729_8K ? (G729_8K_BLOCK_SIZE + (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)) * avctx->channels : G729D_6K4_BLOCK_SIZE * avctx->channels;
}
static av_cold int decode_close(AVCodecContext *avctx)
@@ -749,3 +754,15 @@ AVCodec ff_g729_decoder = {
.close = decode_close,
.capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1,
};
+
+AVCodec ff_acelp_kelvin_decoder = {
+ .name = "acelp.kelvin",
+ .long_name = NULL_IF_CONFIG_SMALL("Sipro ACELP.KELVIN"),
+ .type = AVMEDIA_TYPE_AUDIO,
+ .id = AV_CODEC_ID_ACELP_KELVIN,
+ .priv_data_size = sizeof(G729Context),
+ .init = decoder_init,
+ .decode = decode_frame,
+ .close = decode_close,
+ .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1,
+};