aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-02-22 00:30:22 +0100
committerPaul B Mahol <onemda@gmail.com>2021-03-01 17:36:16 +0100
commit5111707df609796bf70a16ebbcf5a3d0bfa8c432 (patch)
tree5f42196318b9803bfda21520163f2787b3edab63 /libavcodec
parent0e645b98c66aafe32517b946a6484eb5579172d4 (diff)
downloadffmpeg-5111707df609796bf70a16ebbcf5a3d0bfa8c432.tar.gz
avcodec: add SGA PCM decoder
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/Makefile1
-rw-r--r--libavcodec/allcodecs.c1
-rw-r--r--libavcodec/codec_desc.c7
-rw-r--r--libavcodec/codec_id.h1
-rw-r--r--libavcodec/pcm.c9
-rw-r--r--libavcodec/utils.c1
-rw-r--r--libavcodec/version.h2
7 files changed, 21 insertions, 1 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0f67d8d2f6..16d062d2fb 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -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
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 354d146379..990998b64b 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -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;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 8e695b11d2..f64ba488f2 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -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 */
{
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 56a69cf1c2..7dd316afd2 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -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,
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 7f0af8564f..19d04e9181 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -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");
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4d1909b581..db6cd0cde8 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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:
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f4715063c0..f6930f6e63 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -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, \