Re: [FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-10 Thread Rostislav Pehlivanov
On 10 November 2017 at 21:09, Aurelien Jacobs  wrote:

> ---
>  doc/general.texi |  1 +
>  libavformat/Makefile |  2 ++
>  libavformat/allformats.c |  1 +
>  libavformat/aptxdec.c| 78 ++
> ++
>  libavformat/rawenc.c | 13 
>  libavformat/utils.c  |  1 +
>  6 files changed, 96 insertions(+)
>  create mode 100644 libavformat/aptxdec.c
>
> diff --git a/doc/general.texi b/doc/general.texi
> index de4efee913..efd4a92495 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -441,6 +441,7 @@ library:
>  @item raw AC-3  @tab X @tab X
>  @item raw AMR-NB@tab   @tab X
>  @item raw AMR-WB@tab   @tab X
> +@item raw aptX  @tab X @tab X
>  @item raw Chinese AVS video @tab X @tab X
>  @item raw CRI ADX   @tab X @tab X
>  @item raw Dirac @tab X @tab X
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 146a4656f2..b1e7b193f4 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -94,6 +94,8 @@ OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
>  OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
>  OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
>  OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
> +OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
> +OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o
>  OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
>  OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
>  avlanguage.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 1896d50e9e..9213af9301 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -69,6 +69,7 @@ static void register_all(void)
>  REGISTER_DEMUXER (APC,  apc);
>  REGISTER_DEMUXER (APE,  ape);
>  REGISTER_MUXDEMUX(APNG, apng);
> +REGISTER_MUXDEMUX(APTX, aptx);
>  REGISTER_DEMUXER (AQTITLE,  aqtitle);
>  REGISTER_MUXDEMUX(ASF,  asf);
>  REGISTER_DEMUXER (ASF_O,asf_o);
> diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
> new file mode 100644
> index 00..3b8fae1b55
> --- /dev/null
> +++ b/libavformat/aptxdec.c
> @@ -0,0 +1,78 @@
> +/*
> + * RAW aptX demuxer
> + *
> + * Copyright (C) 2017  Aurelien Jacobs 
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#include "avformat.h"
> +#include "rawdec.h"
> +
> +#define APTX_BLOCK_SIZE   4
> +#define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
> +
> +typedef struct AptXDemuxerContext {
> +AVClass *class;
> +int sample_rate;
> +} AptXDemuxerContext;
> +
> +static int aptx_read_header(AVFormatContext *s)
> +{
> +AptXDemuxerContext *s1 = s->priv_data;
> +AVStream *st = avformat_new_stream(s, NULL);
> +if (!st)
> +return AVERROR(ENOMEM);
> +st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
> +st->codecpar->codec_id = AV_CODEC_ID_APTX;
> +st->codecpar->format = AV_SAMPLE_FMT_S32P;
> +st->codecpar->channels = 2;
> +st->codecpar->sample_rate = s1->sample_rate;
> +st->codecpar->bits_per_coded_sample = 4;
> +st->codecpar->block_align = APTX_BLOCK_SIZE;
> +st->codecpar->frame_size = APTX_PACKET_SIZE;
> +st->start_time = 0;
> +return 0;
> +}
> +
> +static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
> +}
> +
> +static const AVOption aptx_options[] = {
> +{ "sample_rate", "", offsetof(AptXDemuxerContext, sample_rate),
> AV_OPT_TYPE_INT, {.i64 = 48000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
> +{ NULL },
> +};
> +
> +static const AVClass aptx_demuxer_class = {
> +.class_name = "aptx demuxer",
> +.item_name  = av_default_item_name,
> +.option = aptx_options,
> +.version= LIBAVUTIL_VERSION_INT,
> +};
> +
> +AVInputFormat ff_aptx_demuxer = {
> +.name   = "aptx",
> +.long_name  = NULL_IF_CONFIG_SMALL("raw aptX"),
> +.extensions = "aptx",
> +.priv_data_size = sizeof(AptXDemuxerC

[FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-10 Thread Aurelien Jacobs
---
 doc/general.texi |  1 +
 libavformat/Makefile |  2 ++
 libavformat/allformats.c |  1 +
 libavformat/aptxdec.c| 78 
 libavformat/rawenc.c | 13 
 libavformat/utils.c  |  1 +
 6 files changed, 96 insertions(+)
 create mode 100644 libavformat/aptxdec.c

diff --git a/doc/general.texi b/doc/general.texi
index de4efee913..efd4a92495 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -441,6 +441,7 @@ library:
 @item raw AC-3  @tab X @tab X
 @item raw AMR-NB@tab   @tab X
 @item raw AMR-WB@tab   @tab X
+@item raw aptX  @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
 @item raw CRI ADX   @tab X @tab X
 @item raw Dirac @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 146a4656f2..b1e7b193f4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -94,6 +94,8 @@ OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
+OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
+OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1896d50e9e..9213af9301 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -69,6 +69,7 @@ static void register_all(void)
 REGISTER_DEMUXER (APC,  apc);
 REGISTER_DEMUXER (APE,  ape);
 REGISTER_MUXDEMUX(APNG, apng);
+REGISTER_MUXDEMUX(APTX, aptx);
 REGISTER_DEMUXER (AQTITLE,  aqtitle);
 REGISTER_MUXDEMUX(ASF,  asf);
 REGISTER_DEMUXER (ASF_O,asf_o);
diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
new file mode 100644
index 00..3b8fae1b55
--- /dev/null
+++ b/libavformat/aptxdec.c
@@ -0,0 +1,78 @@
+/*
+ * RAW aptX demuxer
+ *
+ * Copyright (C) 2017  Aurelien Jacobs 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rawdec.h"
+
+#define APTX_BLOCK_SIZE   4
+#define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
+
+typedef struct AptXDemuxerContext {
+AVClass *class;
+int sample_rate;
+} AptXDemuxerContext;
+
+static int aptx_read_header(AVFormatContext *s)
+{
+AptXDemuxerContext *s1 = s->priv_data;
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id = AV_CODEC_ID_APTX;
+st->codecpar->format = AV_SAMPLE_FMT_S32P;
+st->codecpar->channels = 2;
+st->codecpar->sample_rate = s1->sample_rate;
+st->codecpar->bits_per_coded_sample = 4;
+st->codecpar->block_align = APTX_BLOCK_SIZE;
+st->codecpar->frame_size = APTX_PACKET_SIZE;
+st->start_time = 0;
+return 0;
+}
+
+static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
+}
+
+static const AVOption aptx_options[] = {
+{ "sample_rate", "", offsetof(AptXDemuxerContext, sample_rate), 
AV_OPT_TYPE_INT, {.i64 = 48000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+{ NULL },
+};
+
+static const AVClass aptx_demuxer_class = {
+.class_name = "aptx demuxer",
+.item_name  = av_default_item_name,
+.option = aptx_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_aptx_demuxer = {
+.name   = "aptx",
+.long_name  = NULL_IF_CONFIG_SMALL("raw aptX"),
+.extensions = "aptx",
+.priv_data_size = sizeof(AptXDemuxerContext),
+.read_header= aptx_read_header,
+.read_packet= aptx_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+.priv_class = &aptx_demuxer_class,
+};
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index f640121cb4..aa3ef76fbf 100644
--- a/libavformat/rawenc.c
+++ b/lib

Re: [FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-08 Thread Aurelien Jacobs
On Wed, Nov 08, 2017 at 05:24:34PM +, Rostislav Pehlivanov wrote:
> 
> [...]
> 
> Patch doesn't apply

Here is a rebased patch.>From f6d9a7a804bc1c833e7c2e61411ac1b9155cb6ba Mon Sep 17 00:00:00 2001
From: Aurelien Jacobs 
Date: Thu, 31 Aug 2017 20:42:15 +0200
Subject: [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

---
 doc/general.texi |  1 +
 libavformat/Makefile |  2 ++
 libavformat/allformats.c |  1 +
 libavformat/aptxdec.c| 58 
 libavformat/rawenc.c | 13 +++
 libavformat/utils.c  |  1 +
 6 files changed, 76 insertions(+)
 create mode 100644 libavformat/aptxdec.c

diff --git a/doc/general.texi b/doc/general.texi
index de4efee913..efd4a92495 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -441,6 +441,7 @@ library:
 @item raw AC-3  @tab X @tab X
 @item raw AMR-NB@tab   @tab X
 @item raw AMR-WB@tab   @tab X
+@item raw aptX  @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
 @item raw CRI ADX   @tab X @tab X
 @item raw Dirac @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 146a4656f2..b1e7b193f4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -94,6 +94,8 @@ OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
+OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
+OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1896d50e9e..9213af9301 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -69,6 +69,7 @@ static void register_all(void)
 REGISTER_DEMUXER (APC,  apc);
 REGISTER_DEMUXER (APE,  ape);
 REGISTER_MUXDEMUX(APNG, apng);
+REGISTER_MUXDEMUX(APTX, aptx);
 REGISTER_DEMUXER (AQTITLE,  aqtitle);
 REGISTER_MUXDEMUX(ASF,  asf);
 REGISTER_DEMUXER (ASF_O,asf_o);
diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
new file mode 100644
index 00..90ce789454
--- /dev/null
+++ b/libavformat/aptxdec.c
@@ -0,0 +1,58 @@
+/*
+ * RAW aptX demuxer
+ *
+ * Copyright (C) 2017  Aurelien Jacobs 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rawdec.h"
+
+#define APTX_BLOCK_SIZE   4
+#define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
+
+static int aptx_read_header(AVFormatContext *s)
+{
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id = AV_CODEC_ID_APTX;
+st->codecpar->format = AV_SAMPLE_FMT_S32P;
+st->codecpar->channels = 2;
+st->codecpar->sample_rate = 44100;
+st->codecpar->bits_per_coded_sample = 4;
+st->codecpar->block_align = APTX_BLOCK_SIZE;
+st->codecpar->frame_size = APTX_PACKET_SIZE;
+st->start_time = 0;
+return 0;
+}
+
+static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
+}
+
+AVInputFormat ff_aptx_demuxer = {
+.name   = "aptx",
+.long_name  = NULL_IF_CONFIG_SMALL("raw aptX"),
+.extensions = "aptx",
+.read_header= aptx_read_header,
+.read_packet= aptx_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+};
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index f640121cb4..aa3ef76fbf 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -91,6 +91,19 @@ AVOutputFormat ff_adx_muxer = {
 };
 #endif
 
+#if CONFIG_APTX_MUXER
+AVOutputFormat ff_aptx_muxer = {
+.name  = "aptx",
+.long_name = NULL_IF_CONFIG_SMALL("raw aptX (Audio Processing Technology for Bluetooth)"),
+.extensions= "aptx",
+.audio_codec 

Re: [FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-08 Thread Rostislav Pehlivanov
On 7 November 2017 at 22:26, Aurelien Jacobs  wrote:

> ---
>  doc/general.texi |  1 +
>  libavformat/Makefile |  2 ++
>  libavformat/allformats.c |  1 +
>  libavformat/aptxdec.c| 58 ++
> ++
>  libavformat/rawenc.c | 13 +++
>  libavformat/utils.c  |  1 +
>  6 files changed, 76 insertions(+)
>  create mode 100644 libavformat/aptxdec.c
>
> diff --git a/doc/general.texi b/doc/general.texi
> index 4a89531c47..79e0bd0993 100644
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -439,6 +439,7 @@ library:
>  @item QCP   @tab   @tab X
>  @item raw ADTS (AAC)@tab X @tab X
>  @item raw AC-3  @tab X @tab X
> +@item raw aptX  @tab X @tab X
>  @item raw Chinese AVS video @tab X @tab X
>  @item raw CRI ADX   @tab X @tab X
>  @item raw Dirac @tab X @tab X
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index caebe5b146..21fb892a81 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -92,6 +92,8 @@ OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
>  OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
>  OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
>  OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
> +OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
> +OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o
>  OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
>  OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
>  avlanguage.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 405ddb5ad9..40964a0df0 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -67,6 +67,7 @@ static void register_all(void)
>  REGISTER_DEMUXER (APC,  apc);
>  REGISTER_DEMUXER (APE,  ape);
>  REGISTER_MUXDEMUX(APNG, apng);
> +REGISTER_MUXDEMUX(APTX, aptx);
>  REGISTER_DEMUXER (AQTITLE,  aqtitle);
>  REGISTER_MUXDEMUX(ASF,  asf);
>  REGISTER_DEMUXER (ASF_O,asf_o);
> diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
> new file mode 100644
> index 00..90ce789454
> --- /dev/null
> +++ b/libavformat/aptxdec.c
> @@ -0,0 +1,58 @@
> +/*
> + * RAW aptX demuxer
> + *
> + * Copyright (C) 2017  Aurelien Jacobs 
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#include "avformat.h"
> +#include "rawdec.h"
> +
> +#define APTX_BLOCK_SIZE   4
> +#define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
> +
> +static int aptx_read_header(AVFormatContext *s)
> +{
> +AVStream *st = avformat_new_stream(s, NULL);
> +if (!st)
> +return AVERROR(ENOMEM);
> +st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
> +st->codecpar->codec_id = AV_CODEC_ID_APTX;
> +st->codecpar->format = AV_SAMPLE_FMT_S32P;
> +st->codecpar->channels = 2;
> +st->codecpar->sample_rate = 44100;
> +st->codecpar->bits_per_coded_sample = 4;
> +st->codecpar->block_align = APTX_BLOCK_SIZE;
> +st->codecpar->frame_size = APTX_PACKET_SIZE;
> +st->start_time = 0;
> +return 0;
> +}
> +
> +static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
> +}
> +
> +AVInputFormat ff_aptx_demuxer = {
> +.name   = "aptx",
> +.long_name  = NULL_IF_CONFIG_SMALL("raw aptX"),
> +.extensions = "aptx",
> +.read_header= aptx_read_header,
> +.read_packet= aptx_read_packet,
> +.flags  = AVFMT_GENERIC_INDEX,
> +};
> diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
> index f640121cb4..aa3ef76fbf 100644
> --- a/libavformat/rawenc.c
> +++ b/libavformat/rawenc.c
> @@ -91,6 +91,19 @@ AVOutputFormat ff_adx_muxer = {
>  };
>  #endif
>
> +#if CONFIG_APTX_MUXER
> +AVOutputFormat ff_aptx_muxer = {
> +.name  = "aptx",
> +.long_name = NULL_IF_CONFIG_SMALL("raw aptX (Audio Processing
> Technology for Bluetooth)"),
> +.extensions= "aptx",
> +.audio_codec   = AV_CODEC_ID_APT

[FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-07 Thread Aurelien Jacobs
---
 doc/general.texi |  1 +
 libavformat/Makefile |  2 ++
 libavformat/allformats.c |  1 +
 libavformat/aptxdec.c| 58 
 libavformat/rawenc.c | 13 +++
 libavformat/utils.c  |  1 +
 6 files changed, 76 insertions(+)
 create mode 100644 libavformat/aptxdec.c

diff --git a/doc/general.texi b/doc/general.texi
index 4a89531c47..79e0bd0993 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -439,6 +439,7 @@ library:
 @item QCP   @tab   @tab X
 @item raw ADTS (AAC)@tab X @tab X
 @item raw AC-3  @tab X @tab X
+@item raw aptX  @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
 @item raw CRI ADX   @tab X @tab X
 @item raw Dirac @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index caebe5b146..21fb892a81 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -92,6 +92,8 @@ OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
+OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
+OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 405ddb5ad9..40964a0df0 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -67,6 +67,7 @@ static void register_all(void)
 REGISTER_DEMUXER (APC,  apc);
 REGISTER_DEMUXER (APE,  ape);
 REGISTER_MUXDEMUX(APNG, apng);
+REGISTER_MUXDEMUX(APTX, aptx);
 REGISTER_DEMUXER (AQTITLE,  aqtitle);
 REGISTER_MUXDEMUX(ASF,  asf);
 REGISTER_DEMUXER (ASF_O,asf_o);
diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
new file mode 100644
index 00..90ce789454
--- /dev/null
+++ b/libavformat/aptxdec.c
@@ -0,0 +1,58 @@
+/*
+ * RAW aptX demuxer
+ *
+ * Copyright (C) 2017  Aurelien Jacobs 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rawdec.h"
+
+#define APTX_BLOCK_SIZE   4
+#define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
+
+static int aptx_read_header(AVFormatContext *s)
+{
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id = AV_CODEC_ID_APTX;
+st->codecpar->format = AV_SAMPLE_FMT_S32P;
+st->codecpar->channels = 2;
+st->codecpar->sample_rate = 44100;
+st->codecpar->bits_per_coded_sample = 4;
+st->codecpar->block_align = APTX_BLOCK_SIZE;
+st->codecpar->frame_size = APTX_PACKET_SIZE;
+st->start_time = 0;
+return 0;
+}
+
+static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
+}
+
+AVInputFormat ff_aptx_demuxer = {
+.name   = "aptx",
+.long_name  = NULL_IF_CONFIG_SMALL("raw aptX"),
+.extensions = "aptx",
+.read_header= aptx_read_header,
+.read_packet= aptx_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+};
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index f640121cb4..aa3ef76fbf 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -91,6 +91,19 @@ AVOutputFormat ff_adx_muxer = {
 };
 #endif
 
+#if CONFIG_APTX_MUXER
+AVOutputFormat ff_aptx_muxer = {
+.name  = "aptx",
+.long_name = NULL_IF_CONFIG_SMALL("raw aptX (Audio Processing 
Technology for Bluetooth)"),
+.extensions= "aptx",
+.audio_codec   = AV_CODEC_ID_APTX,
+.video_codec   = AV_CODEC_ID_NONE,
+.write_header  = force_one_stream,
+.write_packet  = ff_raw_write_packet,
+.flags = AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #if CONFIG_CAVSVIDEO_MUXER
 AVOutputFormat ff_cavsvideo_muxer = {
 .name  = "cavsvideo",
dif

Re: [FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-05 Thread Aurelien Jacobs
On Mon, Nov 06, 2017 at 12:51:19AM +0100, Carl Eugen Hoyos wrote:
> 2017-11-06 0:39 GMT+01:00 Aurelien Jacobs :
> 
> > +static int aptx_probe(AVProbeData *p)
> > +{
> > +int len, score = 0;
> > +if (!p || !p->filename)
> > +return 0;
> > +len = strlen(p->filename);
> > +if (len > 5 && !strcmp(&p->filename[len-4], ".aptx"))
> > +score = AVPROBE_SCORE_EXTENSION;
> > +return score;
> > +}
> 
> Just remove the function;-)

Indeed, I don't know how I ended up writing this...
I will remove it.

--
Aurel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-05 Thread Carl Eugen Hoyos
2017-11-06 0:39 GMT+01:00 Aurelien Jacobs :

> +static int aptx_probe(AVProbeData *p)
> +{
> +int len, score = 0;
> +if (!p || !p->filename)
> +return 0;
> +len = strlen(p->filename);
> +if (len > 5 && !strcmp(&p->filename[len-4], ".aptx"))
> +score = AVPROBE_SCORE_EXTENSION;
> +return score;
> +}

Just remove the function;-)

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] aptx: add raw muxer and demuxer for aptX

2017-11-05 Thread Aurelien Jacobs
---
 doc/general.texi |  1 +
 libavformat/Makefile |  2 ++
 libavformat/allformats.c |  1 +
 libavformat/aptxdec.c| 70 
 libavformat/rawenc.c | 13 +
 libavformat/utils.c  |  1 +
 6 files changed, 88 insertions(+)
 create mode 100644 libavformat/aptxdec.c

diff --git a/doc/general.texi b/doc/general.texi
index 4a89531c47..79e0bd0993 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -439,6 +439,7 @@ library:
 @item QCP   @tab   @tab X
 @item raw ADTS (AAC)@tab X @tab X
 @item raw AC-3  @tab X @tab X
+@item raw aptX  @tab X @tab X
 @item raw Chinese AVS video @tab X @tab X
 @item raw CRI ADX   @tab X @tab X
 @item raw Dirac @tab X @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index caebe5b146..21fb892a81 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -92,6 +92,8 @@ OBJS-$(CONFIG_APC_DEMUXER)   += apc.o
 OBJS-$(CONFIG_APE_DEMUXER)   += ape.o apetag.o img2.o
 OBJS-$(CONFIG_APNG_DEMUXER)  += apngdec.o
 OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
+OBJS-$(CONFIG_APTX_DEMUXER)  += aptxdec.o rawdec.o
+OBJS-$(CONFIG_APTX_MUXER)+= rawenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 405ddb5ad9..40964a0df0 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -67,6 +67,7 @@ static void register_all(void)
 REGISTER_DEMUXER (APC,  apc);
 REGISTER_DEMUXER (APE,  ape);
 REGISTER_MUXDEMUX(APNG, apng);
+REGISTER_MUXDEMUX(APTX, aptx);
 REGISTER_DEMUXER (AQTITLE,  aqtitle);
 REGISTER_MUXDEMUX(ASF,  asf);
 REGISTER_DEMUXER (ASF_O,asf_o);
diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
new file mode 100644
index 00..769b666b4d
--- /dev/null
+++ b/libavformat/aptxdec.c
@@ -0,0 +1,70 @@
+/*
+ * RAW aptX demuxer
+ *
+ * Copyright (C) 2017  Aurelien Jacobs 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "rawdec.h"
+
+#define APTX_BLOCK_SIZE   4
+#define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
+
+static int aptx_probe(AVProbeData *p)
+{
+int len, score = 0;
+if (!p || !p->filename)
+return 0;
+len = strlen(p->filename);
+if (len > 5 && !strcmp(&p->filename[len-4], ".aptx"))
+score = AVPROBE_SCORE_EXTENSION;
+return score;
+}
+
+static int aptx_read_header(AVFormatContext *s)
+{
+AVStream *st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id = AV_CODEC_ID_APTX;
+st->codecpar->format = AV_SAMPLE_FMT_S16;
+st->codecpar->channels = 2;
+st->codecpar->sample_rate = 44100;
+st->codecpar->bits_per_coded_sample = 4;
+st->codecpar->block_align = APTX_BLOCK_SIZE;
+st->codecpar->frame_size = APTX_PACKET_SIZE;
+st->start_time = 0;
+return 0;
+}
+
+static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
+}
+
+AVInputFormat ff_aptx_demuxer = {
+.name   = "aptx",
+.long_name  = NULL_IF_CONFIG_SMALL("raw aptX"),
+.extensions = "aptx",
+.read_probe = aptx_probe,
+.read_header= aptx_read_header,
+.read_packet= aptx_read_packet,
+.flags  = AVFMT_GENERIC_INDEX,
+};
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index f640121cb4..aa3ef76fbf 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -91,6 +91,19 @@ AVOutputFormat ff_adx_muxer = {
 };
 #endif
 
+#if CONFIG_APTX_MUXER
+AVOutputFormat ff_aptx_muxer = {
+.name  = "aptx",
+.long_name = NULL_IF_CONFIG_SMALL("raw aptX (Audio Processing 
Technology for Bluetooth)"),
+.extensions= "aptx",
+.audio_codec   = AV_CODEC_ID_APTX,