[FFmpeg-devel] [PATCH 1/2] PCM signed 16-bit big-endian planar decoder
Paul B Mahol
onemda at gmail.com
Thu Nov 15 21:42:18 CET 2012
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
doc/general.texi | 1 +
libavcodec/Makefile | 1 +
libavcodec/allcodecs.c | 1 +
libavcodec/avcodec.h | 1 +
libavcodec/codec_desc.c | 7 +++++++
libavcodec/pcm.c | 14 ++++++++++++++
libavcodec/utils.c | 1 +
libavformat/nut.c | 1 +
8 files changed, 27 insertions(+)
diff --git a/doc/general.texi b/doc/general.texi
index 9768339..28f813e 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -826,6 +826,7 @@ following image formats are supported:
@tab supported through external library libopus
@item PCM A-law @tab X @tab X
@item PCM mu-law @tab X @tab X
+ at item PCM signed 16-bit big-endian planar @tab @tab X
@item PCM 16-bit little-endian planar @tab @tab X
@item PCM 32-bit floating point big-endian @tab X @tab X
@item PCM 32-bit floating point little-endian @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5f8776d..ebe1f4c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -526,6 +526,7 @@ OBJS-$(CONFIG_PCM_S16BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_ENCODER) += pcm.o
+OBJS-$(CONFIG_PCM_S16BE_PLANAR_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_PLANAR_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S24BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S24BE_ENCODER) += pcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 6bad573..65c9f81 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -359,6 +359,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (PCM_S8_PLANAR, pcm_s8_planar);
REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
REGISTER_ENCDEC (PCM_S16LE, pcm_s16le);
+ REGISTER_DECODER (PCM_S16BE_PLANAR, pcm_s16be_planar);
REGISTER_DECODER (PCM_S16LE_PLANAR, pcm_s16le_planar);
REGISTER_ENCDEC (PCM_S24BE, pcm_s24be);
REGISTER_ENCDEC (PCM_S24DAUD, pcm_s24daud);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 368f2c4..1824bdc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -315,6 +315,7 @@ enum AVCodecID {
AV_CODEC_ID_PCM_LXF,
AV_CODEC_ID_S302M,
AV_CODEC_ID_PCM_S8_PLANAR,
+ AV_CODEC_ID_PCM_S16BE_PLANAR = MKBETAG('P','S','P', 16),
/* various ADPCM codecs */
AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 45432bc..fe509a0 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1455,6 +1455,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.props = AV_CODEC_PROP_LOSSLESS,
},
{
+ .id = AV_CODEC_ID_PCM_S16BE_PLANAR,
+ .type = AVMEDIA_TYPE_AUDIO,
+ .name = "pcm_s16be_planar",
+ .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16-bit big-endian planar"),
+ .props = AV_CODEC_PROP_LOSSLESS,
+ },
+ {
.id = AV_CODEC_ID_PCM_DVD,
.type = AVMEDIA_TYPE_AUDIO,
.name = "pcm_dvd",
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 70fa638..73c2200 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -343,6 +343,19 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,
samples += 2;
}
break;
+ case AV_CODEC_ID_PCM_S16BE_PLANAR:
+ {
+ int i;
+ n /= avctx->channels;
+ for (c = 0; c < avctx->channels; c++) {
+ samples = s->frame.extended_data[c];
+ for (i = n; i > 0; i--) {
+ AV_WN16A(samples, bytestream_get_be16(&src));
+ samples += 2;
+ }
+ }
+ break;
+ }
case AV_CODEC_ID_PCM_S16LE_PLANAR:
{
int i;
@@ -540,6 +553,7 @@ PCM_CODEC (PCM_MULAW, AV_SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law /
PCM_CODEC (PCM_S8, AV_SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");
PCM_CODEC (PCM_S16BE, AV_SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian");
PCM_CODEC (PCM_S16LE, AV_SAMPLE_FMT_S16, pcm_s16le, "PCM signed 16-bit little-endian");
+PCM_DECODER(PCM_S16BE_PLANAR, AV_SAMPLE_FMT_S16P,pcm_s16be_planar, "PCM signed 16-bit big-endian planar");
PCM_DECODER(PCM_S16LE_PLANAR, AV_SAMPLE_FMT_S16P,pcm_s16le_planar, "PCM signed 16-bit little-endian planar");
PCM_CODEC (PCM_S24BE, AV_SAMPLE_FMT_S32, pcm_s24be, "PCM signed 24-bit big-endian");
PCM_CODEC (PCM_S24DAUD, AV_SAMPLE_FMT_S16, pcm_s24daud, "PCM D-Cinema audio signed 24-bit");
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 364ce0f..08ded90 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2312,6 +2312,7 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
return 8;
case AV_CODEC_ID_PCM_S16BE:
case AV_CODEC_ID_PCM_S16LE:
+ case AV_CODEC_ID_PCM_S16BE_PLANAR:
case AV_CODEC_ID_PCM_S16LE_PLANAR:
case AV_CODEC_ID_PCM_U16BE:
case AV_CODEC_ID_PCM_U16LE:
diff --git a/libavformat/nut.c b/libavformat/nut.c
index 13f0091..238ed3c 100644
--- a/libavformat/nut.c
+++ b/libavformat/nut.c
@@ -167,6 +167,7 @@ const AVCodecTag ff_nut_audio_tags[] = {
{ AV_CODEC_ID_PCM_U32BE, MKTAG(32 , 'D', 'U', 'P') },
{ AV_CODEC_ID_PCM_U32LE, MKTAG('P', 'U', 'D', 32 ) },
{ AV_CODEC_ID_PCM_U8, MKTAG('P', 'U', 'D', 8 ) },
+ { AV_CODEC_ID_PCM_S16BE_PLANAR, MKTAG(16 , 'P', 'S', 'P') },
{ AV_CODEC_ID_PCM_S16LE_PLANAR, MKTAG('P', 'S', 'P', 16 ) },
{ AV_CODEC_ID_NONE, 0 }
};
--
1.7.11.4
More information about the ffmpeg-devel
mailing list