diff options
Diffstat (limited to 'ffmpeg/libavcodec/g726.c')
| -rw-r--r-- | ffmpeg/libavcodec/g726.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/ffmpeg/libavcodec/g726.c b/ffmpeg/libavcodec/g726.c index 58d0468..b0331d8 100644 --- a/ffmpeg/libavcodec/g726.c +++ b/ffmpeg/libavcodec/g726.c @@ -96,6 +96,7 @@ typedef struct G726Context { int sez; /**< estimated second order prediction */ int y; /**< quantizer scaling factor for the next iteration */ int code_size; + int little_endian; /**< little-endian bitstream as used in aiff and Sun AU */ } G726Context; static const int quant_tbl16[] = /**< 16kbit/s 2bits per sample */ @@ -368,7 +369,7 @@ static const AVOption options[] = { { NULL }, }; -static const AVClass class = { +static const AVClass g726_class = { .class_name = "g726", .item_name = av_default_item_name, .option = options, @@ -382,6 +383,7 @@ static const AVCodecDefault defaults[] = { AVCodec ff_adpcm_g726_encoder = { .name = "g726", + .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ADPCM_G726, .priv_data_size = sizeof(G726Context), @@ -390,20 +392,25 @@ AVCodec ff_adpcm_g726_encoder = { .capabilities = CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), - .priv_class = &class, + .priv_class = &g726_class, .defaults = defaults, }; #endif -#if CONFIG_ADPCM_G726_DECODER +#if CONFIG_ADPCM_G726_DECODER || CONFIG_ADPCM_G726LE_DECODER static av_cold int g726_decode_init(AVCodecContext *avctx) { G726Context* c = avctx->priv_data; + if(avctx->channels > 1){ + avpriv_request_sample(avctx, "Decoding more than one channel"); + return AVERROR_PATCHWELCOME; + } avctx->channels = 1; avctx->channel_layout = AV_CH_LAYOUT_MONO; + c->little_endian = !strcmp(avctx->codec->name, "g726le"); + c->code_size = avctx->bits_per_coded_sample; if (c->code_size < 2 || c->code_size > 5) { av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", c->code_size); @@ -438,7 +445,9 @@ static int g726_decode_frame(AVCodecContext *avctx, void *data, init_get_bits(&gb, buf, buf_size * 8); while (out_samples--) - *samples++ = g726_decode(c, get_bits(&gb, c->code_size)); + *samples++ = g726_decode(c, c->little_endian ? + get_bits_le(&gb, c->code_size) : + get_bits(&gb, c->code_size)); if (get_bits_left(&gb) > 0) av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n"); @@ -453,9 +462,12 @@ static void g726_decode_flush(AVCodecContext *avctx) G726Context *c = avctx->priv_data; g726_reset(c); } +#endif +#if CONFIG_ADPCM_G726_DECODER AVCodec ff_adpcm_g726_decoder = { .name = "g726", + .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ADPCM_G726, .priv_data_size = sizeof(G726Context), @@ -463,6 +475,19 @@ AVCodec ff_adpcm_g726_decoder = { .decode = g726_decode_frame, .flush = g726_decode_flush, .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), +}; +#endif + +#if CONFIG_ADPCM_G726LE_DECODER +AVCodec ff_adpcm_g726le_decoder = { + .name = "g726le", + .type = AVMEDIA_TYPE_AUDIO, + .id = AV_CODEC_ID_ADPCM_G726LE, + .priv_data_size = sizeof(G726Context), + .init = g726_decode_init, + .decode = g726_decode_frame, + .flush = g726_decode_flush, + .capabilities = CODEC_CAP_DR1, + .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM little-endian"), }; #endif |
