ffmpeg | branch: master | Aurelien Jacobs <au...@gnuage.org> | Sat Jan  6 
17:33:01 2018 +0100| [d8258489c87e5571337056be6ce1c2aa739e6873] | committer: 
Aurelien Jacobs

aptx: add raw muxer and demuxer for aptX HD

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d8258489c87e5571337056be6ce1c2aa739e6873
---

 Changelog                |  2 +-
 doc/general.texi         |  1 +
 libavformat/Makefile     |  2 ++
 libavformat/allformats.c |  2 ++
 libavformat/aptxdec.c    | 58 ++++++++++++++++++++++++++++++++++++++++++++----
 libavformat/rawenc.c     | 13 +++++++++++
 6 files changed, 73 insertions(+), 5 deletions(-)

diff --git a/Changelog b/Changelog
index e23fdd6ff8..2acdbbea30 100644
--- a/Changelog
+++ b/Changelog
@@ -12,7 +12,7 @@ version <next>:
 - Intel QSV-accelerated MJPEG encoding
 - PCE support for extended channel layouts in the AAC encoder
 - native aptX and aptX HD encoder and decoder
-- Raw aptX muxer and demuxer
+- Raw aptX and aptX HD muxer and demuxer
 - NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding
 - Intel QSV-accelerated overlay filter
 - mcompand audio filter
diff --git a/doc/general.texi b/doc/general.texi
index 352110f42c..9ddcccf041 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -455,6 +455,7 @@ library:
 @item raw AMR-NB                @tab   @tab X
 @item raw AMR-WB                @tab   @tab X
 @item raw aptX                  @tab X @tab X
+@item raw aptX HD               @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 f9a45338ec..404873624d 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -96,6 +96,8 @@ 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_APTX_HD_DEMUXER)           += aptxdec.o rawdec.o
+OBJS-$(CONFIG_APTX_HD_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 9fd649bb4c..e75cd917e4 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -59,6 +59,8 @@ extern AVInputFormat  ff_apng_demuxer;
 extern AVOutputFormat ff_apng_muxer;
 extern AVInputFormat  ff_aptx_demuxer;
 extern AVOutputFormat ff_aptx_muxer;
+extern AVInputFormat  ff_aptx_hd_demuxer;
+extern AVOutputFormat ff_aptx_hd_muxer;
 extern AVInputFormat  ff_aqtitle_demuxer;
 extern AVInputFormat  ff_asf_demuxer;
 extern AVOutputFormat ff_asf_muxer;
diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c
index 3b8fae1b55..467bc3fd5a 100644
--- a/libavformat/aptxdec.c
+++ b/libavformat/aptxdec.c
@@ -26,26 +26,49 @@
 #define APTX_BLOCK_SIZE   4
 #define APTX_PACKET_SIZE  (256*APTX_BLOCK_SIZE)
 
+#define APTX_HD_BLOCK_SIZE   6
+#define APTX_HD_PACKET_SIZE  (256*APTX_HD_BLOCK_SIZE)
+
 typedef struct AptXDemuxerContext {
     AVClass *class;
     int sample_rate;
 } AptXDemuxerContext;
 
-static int aptx_read_header(AVFormatContext *s)
+static AVStream *aptx_read_header_common(AVFormatContext *s)
 {
     AptXDemuxerContext *s1 = s->priv_data;
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
-        return AVERROR(ENOMEM);
+        return NULL;
     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->start_time = 0;
+    return st;
+}
+
+static int aptx_read_header(AVFormatContext *s)
+{
+    AVStream *st = aptx_read_header_common(s);
+    if (!st)
+        return AVERROR(ENOMEM);
+    st->codecpar->codec_id = AV_CODEC_ID_APTX;
     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_hd_read_header(AVFormatContext *s)
+{
+    AVStream *st = aptx_read_header_common(s);
+    if (!st)
+        return AVERROR(ENOMEM);
+    st->codecpar->codec_id = AV_CODEC_ID_APTX_HD;
+    st->codecpar->bits_per_coded_sample = 6;
+    st->codecpar->block_align = APTX_HD_BLOCK_SIZE;
+    st->codecpar->frame_size = APTX_HD_PACKET_SIZE;
     return 0;
 }
 
@@ -54,11 +77,17 @@ static int aptx_read_packet(AVFormatContext *s, AVPacket 
*pkt)
     return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE);
 }
 
+static int aptx_hd_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    return av_get_packet(s->pb, pkt, APTX_HD_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 },
 };
 
+#if CONFIG_APTX_MUXER
 static const AVClass aptx_demuxer_class = {
     .class_name = "aptx demuxer",
     .item_name  = av_default_item_name,
@@ -76,3 +105,24 @@ AVInputFormat ff_aptx_demuxer = {
     .flags          = AVFMT_GENERIC_INDEX,
     .priv_class     = &aptx_demuxer_class,
 };
+#endif
+
+#if CONFIG_APTX_HD_DEMUXER
+static const AVClass aptx_hd_demuxer_class = {
+    .class_name = "aptx hd demuxer",
+    .item_name  = av_default_item_name,
+    .option     = aptx_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_aptx_hd_demuxer = {
+    .name           = "aptx_hd",
+    .long_name      = NULL_IF_CONFIG_SMALL("raw aptX HD"),
+    .extensions     = "aptxhd",
+    .priv_data_size = sizeof(AptXDemuxerContext),
+    .read_header    = aptx_hd_read_header,
+    .read_packet    = aptx_hd_read_packet,
+    .flags          = AVFMT_GENERIC_INDEX,
+    .priv_class     = &aptx_hd_demuxer_class,
+};
+#endif
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index aa3ef76fbf..dcf880d17e 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -104,6 +104,19 @@ AVOutputFormat ff_aptx_muxer = {
 };
 #endif
 
+#if CONFIG_APTX_HD_MUXER
+AVOutputFormat ff_aptx_hd_muxer = {
+    .name              = "aptx_hd",
+    .long_name         = NULL_IF_CONFIG_SMALL("raw aptX HD (Audio Processing 
Technology for Bluetooth)"),
+    .extensions        = "aptxhd",
+    .audio_codec       = AV_CODEC_ID_APTX_HD,
+    .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",

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to