From patchwork Sun Jan 7 15:55:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jacobs X-Patchwork-Id: 7179 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp1682128jaa; Sun, 7 Jan 2018 07:56:01 -0800 (PST) X-Google-Smtp-Source: ACJfBotw6TEfLvbWmtyQ/QqK3cteD7jmF/vrfraRmZ/c7WTH9aQyyaDLCiYoT3ju2FONVdw5F3Q6 X-Received: by 10.28.211.75 with SMTP id k72mr7367133wmg.39.1515340561294; Sun, 07 Jan 2018 07:56:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515340561; cv=none; d=google.com; s=arc-20160816; b=myrhGe6TyAyCI9LYvR4DPxR3vCKHJj0jTdqZIVqRWzAhSCeIOh+AtTMhR/XYYuyL8x k/d0aJGJ8mh6mPWjyo6hAqOZMvVwz62OVw76uQdVLRHA1zM4lKeZJ8saH/hwWFyjnNZq V1zI9ietKBuY9QwABQz/Yusg6pIWaln+QWo3aWY4n9ctH88D/dHqwDExA5rf0wam2BGj aKjGGqBHEW6kqvwm+xDfEgDFtQxzH8rRdwDdxD9XY3zcainO0Eny/B17EmR7VxPFWAw+ LLm9x2z30zO5ZtA5ZZzpWenhsjUr20MK1FbRuPX540ZW+c21sjSSFE431K+whjbZhCzl O9Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :in-reply-to:content-disposition:mime-version:references:message-id :to:from:date:delivered-to:arc-authentication-results; bh=Z5M2+ZRqnFI1cSMXY9+EeGyp5ZfVA6xdqbS3X+ts3sE=; b=LRIMycPmv3wsUXj07RGZGKwjJOP33BLUMJYRtLCZtY6OqajFonPdQmplq8NSfF0ElC XqBWR43KQvp67glG/9Q6EuIwvX8eXNvnIL9wD6fBwmjw5GWIiu7GBK8D96yMw7wwkys8 0NxhPCZDjIYs5ln8nIHlp9+QfjECTUjoP4xnRrmE+hP8h7dgLjDyzJGIfsA9nQ2Q/Dfr 7pHonchKSr5vlcFJn+0n8pPXwVoVszpRb7WtBPGVRi63da95BuPgUdAH80EnkP4mSN+3 Y2VIcq0Ws7aW7h4Lns7J9EmEgkYoYe84SDCCYfegg2CZCZNddUx1IHDpV0jmiJu/NerJ yXiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 11si6556718wmv.197.2018.01.07.07.56.00; Sun, 07 Jan 2018 07:56:01 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A118689DFF; Sun, 7 Jan 2018 17:55:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpfb1-g21.free.fr (smtpfb1-g21.free.fr [212.27.42.9]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 54AD0688395 for ; Sun, 7 Jan 2018 17:55:51 +0200 (EET) Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [212.27.42.6]) by smtpfb1-g21.free.fr (Postfix) with ESMTP id EA97E78037F for ; Sun, 7 Jan 2018 16:55:50 +0100 (CET) Received: from marge.gnuage.org (unknown [IPv6:2a01:e35:2e26:9790::10]) by smtp6-g21.free.fr (Postfix) with ESMTPS id B5B3B78034D for ; Sun, 7 Jan 2018 16:55:44 +0100 (CET) Received: from aurel by marge.gnuage.org with local (Exim 4.89) (envelope-from ) id 1eYDIV-0005YC-Vy for ffmpeg-devel@ffmpeg.org; Sun, 07 Jan 2018 16:55:43 +0100 Date: Sun, 7 Jan 2018 16:55:43 +0100 From: Aurelien Jacobs To: FFmpeg development discussions and patches Message-ID: <20180107155543.y44gnb5aqw2aytgm@gnuage.org> References: <20180106164808.26162-1-aurel@gnuage.org> <20180106164808.26162-6-aurel@gnuage.org> <20180106235327.GG4926@michaelspb> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180106235327.GG4926@michaelspb> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: aurel@gnuage.org X-SA-Exim-Scanned: No (on marge.gnuage.org); SAEximRunCond expanded to false Subject: Re: [FFmpeg-devel] [PATCH 5/5] aptx: add raw muxer and demuxer for aptX HD X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On Sun, Jan 07, 2018 at 12:53:27AM +0100, Michael Niedermayer wrote: > On Sat, Jan 06, 2018 at 05:48:08PM +0100, Aurelien Jacobs wrote: > > --- > > Changelog | 2 +- > > libavformat/Makefile | 2 ++ > > libavformat/allformats.c | 1 + > > libavformat/aptxdec.c | 51 ++++++++++++++++++++++++++++++++++++++++++++---- > > libavformat/rawenc.c | 13 ++++++++++++ > > 5 files changed, 64 insertions(+), 5 deletions(-) > [...] > > @@ -66,6 +94,7 @@ static const AVClass aptx_demuxer_class = { > > .version = LIBAVUTIL_VERSION_INT, > > }; > > > > +#if CONFIG_APTX_MUXER > > AVInputFormat ff_aptx_demuxer = { > > .name = "aptx", > > .long_name = NULL_IF_CONFIG_SMALL("raw aptX"), > > @@ -76,3 +105,17 @@ AVInputFormat ff_aptx_demuxer = { > > .flags = AVFMT_GENERIC_INDEX, > > > .priv_class = &aptx_demuxer_class, > [...] > > + .priv_class = &aptx_demuxer_class, > > this cause the code (for example fate) to infinite loop Oh, indeed, it seems 2 demuxers can't share the same priv_class. Here is an updated patch. From 319e203fc6ec9ae7b17d28ac63b658a63c933176 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Sat, 6 Jan 2018 17:33:01 +0100 Subject: [PATCH 5/5] aptx: add raw muxer and demuxer for aptX HD --- Changelog | 2 +- libavformat/Makefile | 2 ++ libavformat/allformats.c | 1 + libavformat/aptxdec.c | 58 ++++++++++++++++++++++++++++++++++++++++++++---- libavformat/rawenc.c | 13 +++++++++++ 5 files changed, 71 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 9349bf1e8d..3a97b0b02e 100644 --- a/Changelog +++ b/Changelog @@ -12,7 +12,7 @@ version : - 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/libavformat/Makefile b/libavformat/Makefile index cb70eac920..dbe2890297 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 6a9b9883c9..b70b7463b9 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -70,6 +70,7 @@ static void register_all(void) REGISTER_DEMUXER (APE, ape); REGISTER_MUXDEMUX(APNG, apng); REGISTER_MUXDEMUX(APTX, aptx); + REGISTER_MUXDEMUX(APTX_HD, aptx_hd); REGISTER_DEMUXER (AQTITLE, aqtitle); REGISTER_MUXDEMUX(ASF, asf); REGISTER_DEMUXER (ASF_O, asf_o); 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", -- 2.15.1