Commit dd59f012 authored by Paul B Mahol's avatar Paul B Mahol

add some planar PCM encoders

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent f17f7595
...@@ -825,11 +825,11 @@ following image formats are supported: ...@@ -825,11 +825,11 @@ following image formats are supported:
@tab supported through external library libopus @tab supported through external library libopus
@item PCM A-law @tab X @tab X @item PCM A-law @tab X @tab X
@item PCM mu-law @tab X @tab X @item PCM mu-law @tab X @tab X
@item PCM signed 8-bit planar @tab @tab X @item PCM signed 8-bit planar @tab X @tab X
@item PCM signed 16-bit big-endian planar @tab @tab X @item PCM signed 16-bit big-endian planar @tab X @tab X
@item PCM signed 16-bit little-endian planar @tab @tab X @item PCM signed 16-bit little-endian planar @tab X @tab X
@item PCM signed 24-bit little-endian planar @tab @tab X @item PCM signed 24-bit little-endian planar @tab X @tab X
@item PCM signed 32-bit little-endian planar @tab @tab X @item PCM signed 32-bit little-endian planar @tab X @tab X
@item PCM 32-bit floating point big-endian @tab X @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 @item PCM 32-bit floating point little-endian @tab X @tab X
@item PCM 64-bit floating point big-endian @tab X @tab X @item PCM 64-bit floating point big-endian @tab X @tab X
......
...@@ -522,12 +522,15 @@ OBJS-$(CONFIG_PCM_MULAW_ENCODER) += pcm.o ...@@ -522,12 +522,15 @@ OBJS-$(CONFIG_PCM_MULAW_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S8_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S8_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_PLANAR_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S8_PLANAR_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_PLANAR_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S16BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S16BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S16BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S16BE_PLANAR_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S16BE_PLANAR_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16BE_PLANAR_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S16LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S16LE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_PLANAR_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S16LE_PLANAR_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_PLANAR_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S24BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S24BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S24BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S24DAUD_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24DAUD_DECODER) += pcm.o
...@@ -535,11 +538,13 @@ OBJS-$(CONFIG_PCM_S24DAUD_ENCODER) += pcm.o ...@@ -535,11 +538,13 @@ OBJS-$(CONFIG_PCM_S24DAUD_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S24LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S24LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S24LE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S24LE_PLANAR_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S24LE_PLANAR_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S24LE_PLANAR_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S32BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S32BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S32BE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S32BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S32LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S32LE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S32LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_S32LE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S32LE_PLANAR_DECODER) += pcm.o OBJS-$(CONFIG_PCM_S32LE_PLANAR_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S32LE_PLANAR_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_U8_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U8_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_U8_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_U8_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_U16BE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U16BE_DECODER) += pcm.o
......
...@@ -356,18 +356,18 @@ void avcodec_register_all(void) ...@@ -356,18 +356,18 @@ void avcodec_register_all(void)
REGISTER_DECODER (PCM_LXF, pcm_lxf); REGISTER_DECODER (PCM_LXF, pcm_lxf);
REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw); REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);
REGISTER_ENCDEC (PCM_S8, pcm_s8); REGISTER_ENCDEC (PCM_S8, pcm_s8);
REGISTER_DECODER (PCM_S8_PLANAR, pcm_s8_planar); REGISTER_ENCDEC (PCM_S8_PLANAR, pcm_s8_planar);
REGISTER_ENCDEC (PCM_S16BE, pcm_s16be); REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
REGISTER_DECODER (PCM_S16BE_PLANAR, pcm_s16be_planar); REGISTER_ENCDEC (PCM_S16BE_PLANAR, pcm_s16be_planar);
REGISTER_ENCDEC (PCM_S16LE, pcm_s16le); REGISTER_ENCDEC (PCM_S16LE, pcm_s16le);
REGISTER_DECODER (PCM_S16LE_PLANAR, pcm_s16le_planar); REGISTER_ENCDEC (PCM_S16LE_PLANAR, pcm_s16le_planar);
REGISTER_ENCDEC (PCM_S24BE, pcm_s24be); REGISTER_ENCDEC (PCM_S24BE, pcm_s24be);
REGISTER_ENCDEC (PCM_S24DAUD, pcm_s24daud); REGISTER_ENCDEC (PCM_S24DAUD, pcm_s24daud);
REGISTER_ENCDEC (PCM_S24LE, pcm_s24le); REGISTER_ENCDEC (PCM_S24LE, pcm_s24le);
REGISTER_DECODER (PCM_S24LE_PLANAR, pcm_s24le_planar); REGISTER_ENCDEC (PCM_S24LE_PLANAR, pcm_s24le_planar);
REGISTER_ENCDEC (PCM_S32BE, pcm_s32be); REGISTER_ENCDEC (PCM_S32BE, pcm_s32be);
REGISTER_ENCDEC (PCM_S32LE, pcm_s32le); REGISTER_ENCDEC (PCM_S32LE, pcm_s32le);
REGISTER_DECODER (PCM_S32LE_PLANAR, pcm_s32le_planar); REGISTER_ENCDEC (PCM_S32LE_PLANAR, pcm_s32le_planar);
REGISTER_ENCDEC (PCM_U8, pcm_u8); REGISTER_ENCDEC (PCM_U8, pcm_u8);
REGISTER_ENCDEC (PCM_U16BE, pcm_u16be); REGISTER_ENCDEC (PCM_U16BE, pcm_u16be);
REGISTER_ENCDEC (PCM_U16LE, pcm_u16le); REGISTER_ENCDEC (PCM_U16LE, pcm_u16le);
......
...@@ -79,10 +79,21 @@ static av_cold int pcm_encode_close(AVCodecContext *avctx) ...@@ -79,10 +79,21 @@ static av_cold int pcm_encode_close(AVCodecContext *avctx)
bytestream_put_ ## endian(&dst, v); \ bytestream_put_ ## endian(&dst, v); \
} }
#define ENCODE_PLANAR(type, endian, dst, n, shift, offset) \
n /= avctx->channels; \
for (c = 0; c < avctx->channels; c++) { \
int i; \
samples_ ## type = (const type *) frame->extended_data[c]; \
for (i = n; i > 0; i--) { \
register type v = (*samples_ ## type++ >> shift) + offset; \
bytestream_put_ ## endian(&dst, v); \
} \
}
static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr) const AVFrame *frame, int *got_packet_ptr)
{ {
int n, sample_size, v, ret; int n, c, sample_size, v, ret;
const short *samples; const short *samples;
unsigned char *dst; unsigned char *dst;
const uint8_t *samples_uint8_t; const uint8_t *samples_uint8_t;
...@@ -110,6 +121,9 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -110,6 +121,9 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
case AV_CODEC_ID_PCM_S24LE: case AV_CODEC_ID_PCM_S24LE:
ENCODE(int32_t, le24, samples, dst, n, 8, 0) ENCODE(int32_t, le24, samples, dst, n, 8, 0)
break; break;
case AV_CODEC_ID_PCM_S24LE_PLANAR:
ENCODE_PLANAR(int32_t, le24, dst, n, 8, 0)
break;
case AV_CODEC_ID_PCM_S24BE: case AV_CODEC_ID_PCM_S24BE:
ENCODE(int32_t, be24, samples, dst, n, 8, 0) ENCODE(int32_t, be24, samples, dst, n, 8, 0)
break; break;
...@@ -137,6 +151,9 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -137,6 +151,9 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
case AV_CODEC_ID_PCM_S8: case AV_CODEC_ID_PCM_S8:
ENCODE(uint8_t, byte, samples, dst, n, 0, -128) ENCODE(uint8_t, byte, samples, dst, n, 0, -128)
break; break;
case AV_CODEC_ID_PCM_S8_PLANAR:
ENCODE_PLANAR(uint8_t, byte, dst, n, 0, -128)
break;
#if HAVE_BIGENDIAN #if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_F64LE: case AV_CODEC_ID_PCM_F64LE:
ENCODE(int64_t, le64, samples, dst, n, 0, 0) ENCODE(int64_t, le64, samples, dst, n, 0, 0)
...@@ -145,9 +162,15 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -145,9 +162,15 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
case AV_CODEC_ID_PCM_F32LE: case AV_CODEC_ID_PCM_F32LE:
ENCODE(int32_t, le32, samples, dst, n, 0, 0) ENCODE(int32_t, le32, samples, dst, n, 0, 0)
break; break;
case AV_CODEC_ID_PCM_S32LE_PLANAR:
ENCODE_PLANAR(int32_t, le32, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE: case AV_CODEC_ID_PCM_S16LE:
ENCODE(int16_t, le16, samples, dst, n, 0, 0) ENCODE(int16_t, le16, samples, dst, n, 0, 0)
break; break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
ENCODE_PLANAR(int16_t, le16, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64BE: case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_F32BE: case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE: case AV_CODEC_ID_PCM_S32BE:
...@@ -163,6 +186,9 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -163,6 +186,9 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
case AV_CODEC_ID_PCM_S16BE: case AV_CODEC_ID_PCM_S16BE:
ENCODE(int16_t, be16, samples, dst, n, 0, 0) ENCODE(int16_t, be16, samples, dst, n, 0, 0)
break; break;
case AV_CODEC_ID_PCM_S16BE_PLANAR:
ENCODE_PLANAR(int16_t, be16, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64LE: case AV_CODEC_ID_PCM_F64LE:
case AV_CODEC_ID_PCM_F32LE: case AV_CODEC_ID_PCM_F32LE:
case AV_CODEC_ID_PCM_S32LE: case AV_CODEC_ID_PCM_S32LE:
...@@ -171,6 +197,18 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -171,6 +197,18 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
case AV_CODEC_ID_PCM_U8: case AV_CODEC_ID_PCM_U8:
memcpy(dst, samples, n * sample_size); memcpy(dst, samples, n * sample_size);
break; break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_S16BE_PLANAR:
#else
case AV_CODEC_ID_PCM_S16LE_PLANAR:
case AV_CODEC_ID_PCM_S32LE_PLANAR:
#endif /* HAVE_BIGENDIAN */
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
const uint8_t *src = frame->extended_data[c];
bytestream_put_buffer(&dst, src, n * sample_size);
}
break;
case AV_CODEC_ID_PCM_ALAW: case AV_CODEC_ID_PCM_ALAW:
for (; n > 0; n--) { for (; n > 0; n--) {
v = *samples++; v = *samples++;
...@@ -565,18 +603,18 @@ PCM_CODEC (PCM_F64LE, AV_SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit f ...@@ -565,18 +603,18 @@ PCM_CODEC (PCM_F64LE, AV_SAMPLE_FMT_DBL, pcm_f64le, "PCM 64-bit f
PCM_DECODER(PCM_LXF, AV_SAMPLE_FMT_S32P,pcm_lxf, "PCM signed 20-bit little-endian planar"); PCM_DECODER(PCM_LXF, AV_SAMPLE_FMT_S32P,pcm_lxf, "PCM signed 20-bit little-endian planar");
PCM_CODEC (PCM_MULAW, AV_SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law / G.711 mu-law"); PCM_CODEC (PCM_MULAW, AV_SAMPLE_FMT_S16, pcm_mulaw, "PCM mu-law / G.711 mu-law");
PCM_CODEC (PCM_S8, AV_SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit"); PCM_CODEC (PCM_S8, AV_SAMPLE_FMT_U8, pcm_s8, "PCM signed 8-bit");
PCM_DECODER(PCM_S8_PLANAR, AV_SAMPLE_FMT_U8P, pcm_s8_planar, "PCM signed 8-bit planar"); PCM_CODEC (PCM_S8_PLANAR, AV_SAMPLE_FMT_U8P, pcm_s8_planar, "PCM signed 8-bit planar");
PCM_CODEC (PCM_S16BE, AV_SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian"); PCM_CODEC (PCM_S16BE, AV_SAMPLE_FMT_S16, pcm_s16be, "PCM signed 16-bit big-endian");
PCM_DECODER(PCM_S16BE_PLANAR, AV_SAMPLE_FMT_S16P,pcm_s16be_planar, "PCM signed 16-bit big-endian planar"); PCM_CODEC (PCM_S16BE_PLANAR, AV_SAMPLE_FMT_S16P,pcm_s16be_planar, "PCM signed 16-bit big-endian planar");
PCM_CODEC (PCM_S16LE, AV_SAMPLE_FMT_S16, pcm_s16le, "PCM signed 16-bit little-endian"); PCM_CODEC (PCM_S16LE, AV_SAMPLE_FMT_S16, pcm_s16le, "PCM signed 16-bit little-endian");
PCM_DECODER(PCM_S16LE_PLANAR, AV_SAMPLE_FMT_S16P,pcm_s16le_planar, "PCM signed 16-bit little-endian planar"); PCM_CODEC (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_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"); PCM_CODEC (PCM_S24DAUD, AV_SAMPLE_FMT_S16, pcm_s24daud, "PCM D-Cinema audio signed 24-bit");
PCM_CODEC (PCM_S24LE, AV_SAMPLE_FMT_S32, pcm_s24le, "PCM signed 24-bit little-endian"); PCM_CODEC (PCM_S24LE, AV_SAMPLE_FMT_S32, pcm_s24le, "PCM signed 24-bit little-endian");
PCM_DECODER(PCM_S24LE_PLANAR, AV_SAMPLE_FMT_S32P,pcm_s24le_planar, "PCM signed 24-bit little-endian planar"); PCM_CODEC (PCM_S24LE_PLANAR, AV_SAMPLE_FMT_S32P,pcm_s24le_planar, "PCM signed 24-bit little-endian planar");
PCM_CODEC (PCM_S32BE, AV_SAMPLE_FMT_S32, pcm_s32be, "PCM signed 32-bit big-endian"); PCM_CODEC (PCM_S32BE, AV_SAMPLE_FMT_S32, pcm_s32be, "PCM signed 32-bit big-endian");
PCM_CODEC (PCM_S32LE, AV_SAMPLE_FMT_S32, pcm_s32le, "PCM signed 32-bit little-endian"); PCM_CODEC (PCM_S32LE, AV_SAMPLE_FMT_S32, pcm_s32le, "PCM signed 32-bit little-endian");
PCM_DECODER(PCM_S32LE_PLANAR, AV_SAMPLE_FMT_S32P,pcm_s32le_planar, "PCM signed 32-bit little-endian planar"); PCM_CODEC (PCM_S32LE_PLANAR, AV_SAMPLE_FMT_S32P,pcm_s32le_planar, "PCM signed 32-bit little-endian planar");
PCM_CODEC (PCM_U8, AV_SAMPLE_FMT_U8, pcm_u8, "PCM unsigned 8-bit"); PCM_CODEC (PCM_U8, AV_SAMPLE_FMT_U8, pcm_u8, "PCM unsigned 8-bit");
PCM_CODEC (PCM_U16BE, AV_SAMPLE_FMT_S16, pcm_u16be, "PCM unsigned 16-bit big-endian"); PCM_CODEC (PCM_U16BE, AV_SAMPLE_FMT_S16, pcm_u16be, "PCM unsigned 16-bit big-endian");
PCM_CODEC (PCM_U16LE, AV_SAMPLE_FMT_S16, pcm_u16le, "PCM unsigned 16-bit little-endian"); PCM_CODEC (PCM_U16LE, AV_SAMPLE_FMT_S16, pcm_u16le, "PCM unsigned 16-bit little-endian");
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 54 #define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 73 #define LIBAVCODEC_VERSION_MINOR 74
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment