avcodec: add SGA PCM decoder

This commit is contained in:
Paul B Mahol 2021-02-22 00:30:22 +01:00
parent 0e645b98c6
commit 5111707df6
7 changed files with 21 additions and 1 deletions

View File

@ -830,6 +830,7 @@ OBJS-$(CONFIG_PCM_S64BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S64BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S64LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S64LE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_SGA_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_U8_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_U8_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_U16BE_DECODER) += pcm.o

View File

@ -568,6 +568,7 @@ extern AVCodec ff_pcm_s64be_encoder;
extern AVCodec ff_pcm_s64be_decoder;
extern AVCodec ff_pcm_s64le_encoder;
extern AVCodec ff_pcm_s64le_decoder;
extern AVCodec ff_pcm_sga_decoder;
extern AVCodec ff_pcm_u8_encoder;
extern AVCodec ff_pcm_u8_decoder;
extern AVCodec ff_pcm_u16be_encoder;

View File

@ -2096,6 +2096,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("PCM Archimedes VIDC"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
},
{
.id = AV_CODEC_ID_PCM_SGA,
.type = AVMEDIA_TYPE_AUDIO,
.name = "pcm_sga",
.long_name = NULL_IF_CONFIG_SMALL("PCM SGA"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
/* various ADPCM codecs */
{

View File

@ -346,6 +346,7 @@ enum AVCodecID {
AV_CODEC_ID_PCM_F16LE,
AV_CODEC_ID_PCM_F24LE,
AV_CODEC_ID_PCM_VIDC,
AV_CODEC_ID_PCM_SGA,
/* various ADPCM codecs */
AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,

View File

@ -419,6 +419,14 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
for (; n > 0; n--)
*samples++ = *src++ + 128;
break;
case AV_CODEC_ID_PCM_SGA:
for (; n > 0; n--) {
int sign = *src >> 7;
int magn = *src & 0x7f;
*samples++ = sign ? 128 - magn : 128 + magn;
src++;
}
break;
case AV_CODEC_ID_PCM_S8_PLANAR:
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
@ -622,3 +630,4 @@ PCM_CODEC (PCM_U32LE, AV_SAMPLE_FMT_S32, pcm_u32le, "PCM unsigned
PCM_CODEC (PCM_S64BE, AV_SAMPLE_FMT_S64, pcm_s64be, "PCM signed 64-bit big-endian");
PCM_CODEC (PCM_S64LE, AV_SAMPLE_FMT_S64, pcm_s64le, "PCM signed 64-bit little-endian");
PCM_CODEC (PCM_VIDC, AV_SAMPLE_FMT_S16, pcm_vidc, "PCM Archimedes VIDC");
PCM_DECODER(PCM_SGA, AV_SAMPLE_FMT_U8, pcm_sga, "PCM SGA");

View File

@ -1547,6 +1547,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
case AV_CODEC_ID_PCM_VIDC:
case AV_CODEC_ID_PCM_S8:
case AV_CODEC_ID_PCM_S8_PLANAR:
case AV_CODEC_ID_PCM_SGA:
case AV_CODEC_ID_PCM_U8:
case AV_CODEC_ID_SDX2_DPCM:
case AV_CODEC_ID_DERF_DPCM:

View File

@ -28,7 +28,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 126
#define LIBAVCODEC_VERSION_MINOR 127
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \