mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec: Add little-endian G726 decoder
Fixes part of Ticket1955 suggested by Roman. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
5b9f39860d
commit
10c240a085
|
@ -433,6 +433,7 @@ void avcodec_register_all(void)
|
|||
REGISTER_DECODER(ADPCM_EA_XAS, adpcm_ea_xas);
|
||||
REGISTER_ENCDEC (ADPCM_G722, adpcm_g722);
|
||||
REGISTER_ENCDEC (ADPCM_G726, adpcm_g726);
|
||||
REGISTER_DECODER(ADPCM_G726LE, adpcm_g726le);
|
||||
REGISTER_DECODER(ADPCM_IMA_AMV, adpcm_ima_amv);
|
||||
REGISTER_DECODER(ADPCM_IMA_APC, adpcm_ima_apc);
|
||||
REGISTER_DECODER(ADPCM_IMA_DK3, adpcm_ima_dk3);
|
||||
|
|
|
@ -377,6 +377,7 @@ enum AVCodecID {
|
|||
AV_CODEC_ID_ADPCM_IMA_OKI = MKBETAG('O','K','I',' '),
|
||||
AV_CODEC_ID_ADPCM_DTK = MKBETAG('D','T','K',' '),
|
||||
AV_CODEC_ID_ADPCM_IMA_RAD = MKBETAG('R','A','D',' '),
|
||||
AV_CODEC_ID_ADPCM_G726LE = MKBETAG('6','2','7','G'),
|
||||
|
||||
/* AMR */
|
||||
AV_CODEC_ID_AMR_NB = 0x12000,
|
||||
|
|
|
@ -1853,6 +1853,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
|
|||
.long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Radical"),
|
||||
.props = AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
{
|
||||
.id = AV_CODEC_ID_ADPCM_G726LE,
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
.name = "adpcm_g726le",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM little-endian"),
|
||||
.props = AV_CODEC_PROP_LOSSY,
|
||||
},
|
||||
|
||||
/* AMR */
|
||||
{
|
||||
|
|
|
@ -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 */
|
||||
|
@ -396,7 +397,7 @@ AVCodec ff_adpcm_g726_encoder = {
|
|||
};
|
||||
#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;
|
||||
|
@ -408,6 +409,8 @@ static av_cold int g726_decode_init(AVCodecContext *avctx)
|
|||
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);
|
||||
|
@ -442,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");
|
||||
|
@ -457,7 +462,9 @@ 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"),
|
||||
|
@ -470,3 +477,17 @@ AVCodec ff_adpcm_g726_decoder = {
|
|||
.capabilities = CODEC_CAP_DR1,
|
||||
};
|
||||
#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
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 55
|
||||
#define LIBAVCODEC_VERSION_MINOR 37
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
#define LIBAVCODEC_VERSION_MICRO 101
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
|
|
Loading…
Reference in New Issue