[FFmpeg-trac] #8081(avcodec:new): support of g729b codec
FFmpeg
trac at avcodec.org
Sun Aug 18 18:39:00 EEST 2019
#8081: support of g729b codec
-------------------------------------+-----------------------------------
Reporter: AlexanderU | Owner:
Type: enhancement | Status: new
Priority: wish | Component: avcodec
Version: git-master | Resolution:
Keywords: g729 | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-----------------------------------
Comment (by cehoyos):
Thank you for the analysis, please test the following patch with more
samples:
{{{
diff --git a/configure b/configure
index 34c2adb4a4..b23009994a 100755
--- a/configure
+++ b/configure
@@ -2632,6 +2632,7 @@ ac3_decoder_select="ac3_parser ac3dsp bswapdsp
fmtconvert mdct"
ac3_fixed_decoder_select="ac3_parser ac3dsp bswapdsp mdct"
ac3_encoder_select="ac3dsp audiodsp mdct me_cmp"
ac3_fixed_encoder_select="ac3dsp audiodsp mdct me_cmp"
+acelp_kelvin_decoder_select="g729_decoder"
adpcm_g722_decoder_select="g722dsp"
adpcm_g722_encoder_select="g722dsp"
aic_decoder_select="golomb idctdsp"
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d234271c5b..7ec4014d8b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -629,6 +629,7 @@ enum AVCodecID {
AV_CODEC_ID_ON2AVC,
AV_CODEC_ID_DSS_SP,
AV_CODEC_ID_CODEC2,
+ AV_CODEC_ID_ACELP_KELVIN,
AV_CODEC_ID_FFWAVESYNTH = 0x15800,
AV_CODEC_ID_SONIC,
diff --git a/libavcodec/g729_parser.c b/libavcodec/g729_parser.c
index 9982dbfffc..5a57025d62 100644
--- a/libavcodec/g729_parser.c
+++ b/libavcodec/g729_parser.c
@@ -45,9 +45,10 @@ static int g729_parse(AVCodecParserContext *s1,
AVCodecContext *avctx,
int next;
if (!s->block_size) {
- av_assert1(avctx->codec_id == AV_CODEC_ID_G729);
/* FIXME: replace this heuristic block_size with more precise
estimate */
s->block_size = (avctx->bit_rate < 8000) ? G729D_6K4_BLOCK_SIZE :
G729_8K_BLOCK_SIZE;
+ if (avctx->codec_id == AV_CODEC_ID_ACELP_KELVIN)
+ s->block_size++;
s->block_size *= avctx->channels;
s->duration = avctx->frame_size;
}
@@ -76,7 +77,7 @@ static int g729_parse(AVCodecParserContext *s1,
AVCodecContext *avctx,
}
AVCodecParser ff_g729_parser = {
- .codec_ids = { AV_CODEC_ID_G729 },
+ .codec_ids = { AV_CODEC_ID_G729, AV_CODEC_ID_ACELP_KELVIN },
.priv_data_size = sizeof(G729ParseContext),
.parser_parse = g729_parse,
.parser_close = ff_parse_close,
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
index 2e4756b805..7c7f4d49f2 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,8 @@ 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)
+ buf++;
for (i = 0; i < buf_size; i++)
frame_erasure |= buf[i];
@@ -749,3 +751,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("Sipr 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,
+};
diff --git a/libavformat/riff.c b/libavformat/riff.c
index e755ad8d5f..27518216a6 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -534,6 +534,7 @@ const AVCodecTag ff_codec_wav_tags[] = {
{ AV_CODEC_ID_AAC, 0x00ff },
{ AV_CODEC_ID_G723_1, 0x0111 },
{ AV_CODEC_ID_SIPR, 0x0130 },
+ { AV_CODEC_ID_ACELP_KELVIN, 0x0135 },
{ AV_CODEC_ID_WMAV1, 0x0160 },
{ AV_CODEC_ID_WMAV2, 0x0161 },
{ AV_CODEC_ID_WMAPRO, 0x0162 },
}}}
Please ignore the many error messages the patch currently produces.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8081#comment:9>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list