[FFmpeg-devel] [PATCH 1/2] avcodec: add pcm_f16le and pcm_f24le decoder

Michael Niedermayer michael at niedermayer.cc
Sun Nov 13 22:12:39 EET 2016


On Mon, Sep 19, 2016 at 11:17:19PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  libavcodec/Makefile     |  2 ++
>  libavcodec/allcodecs.c  |  2 ++
>  libavcodec/avcodec.h    |  2 ++
>  libavcodec/codec_desc.c | 14 ++++++++++++++
>  libavcodec/pcm.c        | 34 ++++++++++++++++++++++++++++++++++
>  libavcodec/utils.c      |  2 ++
>  6 files changed, 56 insertions(+)
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 276308b..72db88a 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -655,6 +655,8 @@ OBJS-$(CONFIG_PCM_ALAW_DECODER)           += pcm.o
>  OBJS-$(CONFIG_PCM_ALAW_ENCODER)           += pcm.o
>  OBJS-$(CONFIG_PCM_BLURAY_DECODER)         += pcm-bluray.o
>  OBJS-$(CONFIG_PCM_DVD_DECODER)            += pcm-dvd.o
> +OBJS-$(CONFIG_PCM_F16LE_DECODER)          += pcm.o
> +OBJS-$(CONFIG_PCM_F24LE_DECODER)          += pcm.o
>  OBJS-$(CONFIG_PCM_F32BE_DECODER)          += pcm.o
>  OBJS-$(CONFIG_PCM_F32BE_ENCODER)          += pcm.o
>  OBJS-$(CONFIG_PCM_F32LE_DECODER)          += pcm.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index b403bf2..6acd753 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -474,6 +474,8 @@ void avcodec_register_all(void)
>      REGISTER_ENCDEC (PCM_ALAW,          pcm_alaw);
>      REGISTER_DECODER(PCM_BLURAY,        pcm_bluray);
>      REGISTER_DECODER(PCM_DVD,           pcm_dvd);
> +    REGISTER_DECODER(PCM_F16LE,         pcm_f16le);
> +    REGISTER_DECODER(PCM_F24LE,         pcm_f24le);
>      REGISTER_ENCDEC (PCM_F32BE,         pcm_f32be);
>      REGISTER_ENCDEC (PCM_F32LE,         pcm_f32le);
>      REGISTER_ENCDEC (PCM_F64BE,         pcm_f64be);
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index db1061d..217bb27 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -448,6 +448,8 @@ enum AVCodecID {
>  
>      AV_CODEC_ID_PCM_S64LE = 0x10800,
>      AV_CODEC_ID_PCM_S64BE,
> +    AV_CODEC_ID_PCM_F16LE,
> +    AV_CODEC_ID_PCM_F24LE,
>  
>      /* various ADPCM codecs */
>      AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index 24948ca..0eebf41 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1742,6 +1742,20 @@ static const AVCodecDescriptor codec_descriptors[] = {
>          .props     = AV_CODEC_PROP_LOSSLESS,
>      },
>      {
> +        .id        = AV_CODEC_ID_PCM_F16LE,
> +        .type      = AVMEDIA_TYPE_AUDIO,
> +        .name      = "pcm_f16le",
> +        .long_name = NULL_IF_CONFIG_SMALL("PCM 16.8 floating point little-endian"),
> +        .props     = AV_CODEC_PROP_LOSSLESS,
> +    },
> +    {
> +        .id        = AV_CODEC_ID_PCM_F24LE,
> +        .type      = AVMEDIA_TYPE_AUDIO,
> +        .name      = "pcm_f24le",
> +        .long_name = NULL_IF_CONFIG_SMALL("PCM 24.0 floating point little-endian"),
> +        .props     = AV_CODEC_PROP_LOSSLESS,
> +    },
> +    {
>          .id        = AV_CODEC_ID_PCM_F32BE,
>          .type      = AVMEDIA_TYPE_AUDIO,
>          .name      = "pcm_f32be",
> diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
> index 2e8e8e7..8c326c6 100644
> --- a/libavcodec/pcm.c
> +++ b/libavcodec/pcm.c
> @@ -25,6 +25,7 @@
>   */
>  
>  #include "libavutil/attributes.h"
> +#include "libavutil/float_dsp.h"
>  #include "avcodec.h"
>  #include "bytestream.h"
>  #include "internal.h"
> @@ -225,6 +226,8 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
>  
>  typedef struct PCMDecode {
>      short   table[256];
> +    AVFloatDSPContext *fdsp;
> +    float   scale;
>  } PCMDecode;
>  
>  static av_cold int pcm_decode_init(AVCodecContext *avctx)
> @@ -246,6 +249,13 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
>          for (i = 0; i < 256; i++)
>              s->table[i] = ulaw2linear(i);
>          break;
> +    case AV_CODEC_ID_PCM_F16LE:
> +    case AV_CODEC_ID_PCM_F24LE:
> +        s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1));

> +        s->fdsp = avpriv_float_dsp_alloc(0);

why doesnt this pass the bitexact flag ?

other than that the patch LGTM

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161113/565e5524/attachment.sig>


More information about the ffmpeg-devel mailing list