On 1/11/2025 11:37 PM, Peter Ross wrote:
--- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/g728data.h | 70 +++++++++++++ libavcodec/g728dec.c | 213 ++++++++++++++++++++++++++++++++++++++++ libavcodec/utils.c | 1 + 7 files changed, 294 insertions(+) create mode 100644 libavcodec/g728data.h create mode 100644 libavcodec/g728dec.c
[...]
+ +static int g728_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *avpkt) +{ + G728Context *s = avctx->priv_data; + GetBitContext gb; + int ret; + + if (avpkt->size < 5) + return AVERROR_INVALIDDATA; + + if ((ret = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0) + return ret; + + frame->nb_samples = 20; + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + + decode_frame(s, &gb, (float *)frame->data[0]);
I assume this means the codec is mono only, right? I see you set AV_CODEC_CAP_CHANNEL_CONF below (meaning the decoder will set channel information and not depend on the caller doing it), but then don't force mono layout in avctx->ch_layout anywhere. You need to do it in g728_decode_init(), first uninitializing the existing layout and then setting it to mono.
+ + *got_frame_ptr = 1; + + return 5; +} + +const FFCodec ff_g728_decoder = { + .p.name = "g728", + CODEC_LONG_NAME("G.728)"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_G728, + .priv_data_size = sizeof(G728Context), + .init = g728_decode_init, + .close = g728_decode_close, + FF_CODEC_DECODE_CB(g728_decode_frame), + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | + AV_CODEC_CAP_DR1, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, + AV_SAMPLE_FMT_NONE }, +}; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index dd846b4ae9..58b29c4c9d 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -553,6 +553,7 @@ int av_get_bits_per_sample(enum AVCodecID codec_id) case AV_CODEC_ID_DFPWM: return 1; case AV_CODEC_ID_ADPCM_SBPRO_2: + case AV_CODEC_ID_G728: return 2; case AV_CODEC_ID_ADPCM_SBPRO_3: return 3; _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".