From patchwork Fri Jan 5 11:34:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: misty@brew.sh X-Patchwork-Id: 7139 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp661292jaa; Fri, 5 Jan 2018 03:35:32 -0800 (PST) X-Google-Smtp-Source: ACJfBosfPOha1c4EtC0SJsmElV6CbTZ4CJuzHDtpjP6UO06E/o37oRFaEXjsD60H+GPZ65Kn+rCM X-Received: by 10.28.7.144 with SMTP id 138mr1866453wmh.128.1515152132584; Fri, 05 Jan 2018 03:35:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515152132; cv=none; d=google.com; s=arc-20160816; b=MVR+enqqjIKCIqTcyJgs39BJDwZi7nlefFQpMEfhb/n2Ez3M4v5IjFz0cdenJlUr62 z16ECVsluXpmDJ0tUSd2QQ34i3wY5l1tl1NmjXhgBN/3cpmU8HeMvdtmMGNNVFm8nme0 NicgVPr7ORPbpW2b+zNO9ohLhVT9/rXYEltwg1W3/vHFSlNsetOCba/SaS5un0vghorj IQhgaZK+gfSMfQ3DYhwfCb+ZvgeT1q90Ug3QWJmnvhFeKSZC6G/ysAex1atgEzOPbxfa lBn+y6S/qBbFg1gMayv4zWxnZ+j1jfjbnYVBUPFFske41IaHdjpqeFmtQa1Ftu7AtWG+ tD/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=NEF0pMoF/PSExloGONFfomg7vPUFw404qGTUqU2aqmo=; b=X9LnFFeUhmxsLwO7QUjC3X2hR4tkOUH9xUyPql7t2ODxCvDxsx1ykXRNtSATiC5Si9 vKWSnNe6TJLX1JDU3pz1WCrKDcON7qIyZkuS1o7oXvT24B8laRxLcxVQR5stpxBvjGpd osKBUDt+v6rkVhizsx0OZm/jNUZAWg6jZoV2hMjut6cVx/hoRskPLBsYfu911RcCtNO1 djtoVdgZXhEEe3rUkAsffvotTNJIPsIvqXsEuvqGBkD+VOGa0oim3QzPoTsW4ITz0kgD H77LusPJP27AmJZ61wWsuIIGdt4ovblRZ6r8EZnCM7CaRhs4ys1lwplmAD7I3h0PcLjD /yRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Q/zqYxng; 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 x75si3515869wme.209.2018.01.05.03.35.32; Fri, 05 Jan 2018 03:35:32 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Q/zqYxng; 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 56A28689A33; Fri, 5 Jan 2018 13:34:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f48.google.com (mail-pl0-f48.google.com [209.85.160.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 45722689A11 for ; Fri, 5 Jan 2018 13:34:51 +0200 (EET) Received: by mail-pl0-f48.google.com with SMTP id b12so2903317plm.3 for ; Fri, 05 Jan 2018 03:35:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=D3FMBHjYPrw3TjFyGXN1kT+jX01JywgH5zDmTlNfIWk=; b=Q/zqYxng43DbqUl3YddrP+R/Er/7DFgz+/X4WVSxBY9Jih1zR2vCxtHKwBxmVhMu/f FYjuDDNQpscMhFoT/TjjyLEGYLxkeSwxyMxhnuFAHD7js79jleMjy9lt5ka3ApoAgqPs 1h+Hc+MIiNhSkfpHYiRoUbK2dxwbL6GaakhAqHpqEzb6nYu8KGMX8NzwFJAZ56ZyhJhP dqqBuBqMBrl83C0brZOnoiB3SyGmmD42fxWy7j3Zc51J7ddjWS2UAUWgp0VybbahQoAW 75KbAajcIkZSDPdBa8E88lCw8TqgXBjrwnYr3lXJvIP/7U/wCOuEwKxRYYhKqevTmWWH n5kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=D3FMBHjYPrw3TjFyGXN1kT+jX01JywgH5zDmTlNfIWk=; b=aK437YwsclmGJiRhhLXWlxTUVfU7FZvb9yB7NYXF/hunjGYaaBRztFatQuH0ffgC77 tAg/jPkuHjDgY0ihY2ZiepxW5do8C8b82kJoMHMzkp7FrU//s/cQPeEjFpeHqxoqO3Cy 7Z6PZ+Vh3wD8G8Y84u6IF/uiqHk+m3i8xwT3fMfqJ7mpRvMTuWK3gq4jveHXX0LKn2Te 6baY81kFoVT0E5c1InaLf9I9quu8t+QzjSZvfVVxwmwcKQb7Z+WewThaq44KsVFkZ3/u 4cR+FI5OSL+7/6Sa5jQiid8Y+cKGowa9lB3SaV2ciPIJTqScWvSKvnrizDiTddNn4TfH qQbg== X-Gm-Message-State: AKGB3mJH67RCIursTa3UsykTvf+HdVWFS8hbRoUreU1aBAU9+C5sLXFC FxzIrtaSQEQLUfxmUjyCw1vWnJXC X-Received: by 10.84.217.154 with SMTP id p26mr2740291pli.288.1515152106878; Fri, 05 Jan 2018 03:35:06 -0800 (PST) Received: from localhost.localdomain (180-150-45-216.NBN.mel.aussiebb.net. [180.150.45.216]) by smtp.gmail.com with ESMTPSA id s184sm11549586pfb.9.2018.01.05.03.35.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 03:35:06 -0800 (PST) From: misty@brew.sh To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Jan 2018 22:34:44 +1100 Message-Id: <20180105113448.13917-3-misty@brew.sh> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180105113448.13917-1-misty@brew.sh> References: <20180102213143.GE4926@michaelspb> <20180105113448.13917-1-misty@brew.sh> Subject: [FFmpeg-devel] [PATCH 2/6] oma: move some constants into libavcodec 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 Cc: Misty De Meo MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Misty De Meo Most of the constants in libavcodec/oma aren't specific to libavformat; moving them into libavcodec makes them available to libavcodec as well as keeping them compatible with libavformat. ff_oma_codec_tags uses a libavformat-specific type, so it has been left in libavformat. --- libavformat/oma.c => libavcodec/oma.h | 27 +++++++++++++-------------- libavcodec/version.h | 2 +- libavformat/Makefile | 4 ++-- libavformat/oma.h | 21 +++++++++------------ libavformat/omadec.c | 13 +++++++------ libavformat/omaenc.c | 7 ++++--- libavformat/version.h | 2 +- 7 files changed, 37 insertions(+), 39 deletions(-) rename libavformat/oma.c => libavcodec/oma.h (65%) diff --git a/libavformat/oma.c b/libavcodec/oma.h similarity index 65% rename from libavformat/oma.c rename to libavcodec/oma.h index f7ae3c9948..f091ef24ca 100644 --- a/libavformat/oma.c +++ b/libavcodec/oma.h @@ -18,25 +18,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef AVCODEC_OMA_H +#define AVCODEC_OMA_H + +#include + #include "internal.h" -#include "oma.h" -#include "libavcodec/avcodec.h" #include "libavutil/channel_layout.h" -const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 }; +#define EA3_HEADER_SIZE 96 +#define ID3v2_EA3_MAGIC "ea3" +#define OMA_ENC_HEADER_SIZE 16 -const AVCodecTag ff_oma_codec_tags[] = { - { AV_CODEC_ID_ATRAC3, OMA_CODECID_ATRAC3 }, - { AV_CODEC_ID_ATRAC3P, OMA_CODECID_ATRAC3P }, - { AV_CODEC_ID_MP3, OMA_CODECID_MP3 }, - { AV_CODEC_ID_PCM_S16BE, OMA_CODECID_LPCM }, - { AV_CODEC_ID_ATRAC3PAL, OMA_CODECID_ATRAC3PAL }, - { AV_CODEC_ID_ATRAC3AL, OMA_CODECID_ATRAC3AL }, - { 0 }, -}; +static const uint16_t oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 }; /** map ATRAC-X channel id to internal channel layout */ -const uint64_t ff_oma_chid_to_native_layout[7] = { +static const uint64_t oma_chid_to_native_layout[7] = { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_SURROUND, @@ -47,4 +44,6 @@ const uint64_t ff_oma_chid_to_native_layout[7] = { }; /** map ATRAC-X channel id to total number of channels */ -const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8}; +static const int oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8}; + +#endif /* AVCODEC_OMA_H */ diff --git a/libavcodec/version.h b/libavcodec/version.h index 47a15d52b8..ec536bf7b6 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MINOR 9 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavformat/Makefile b/libavformat/Makefile index cb70eac920..ef0365e6e2 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -358,8 +358,8 @@ OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \ vorbiscomment.o OBJS-$(CONFIG_OGV_MUXER) += oggenc.o \ vorbiscomment.o -OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o -OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o +OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o +OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o id3v2enc.o OBJS-$(CONFIG_OPUS_MUXER) += oggenc.o \ vorbiscomment.o OBJS-$(CONFIG_PAF_DEMUXER) += paf.o diff --git a/libavformat/oma.h b/libavformat/oma.h index 36fd0125e4..41972830ec 100644 --- a/libavformat/oma.h +++ b/libavformat/oma.h @@ -21,14 +21,8 @@ #ifndef AVFORMAT_OMA_H #define AVFORMAT_OMA_H -#include - #include "internal.h" -#define EA3_HEADER_SIZE 96 -#define ID3v2_EA3_MAGIC "ea3" -#define OMA_ENC_HEADER_SIZE 16 - enum { OMA_CODECID_ATRAC3 = 0, OMA_CODECID_ATRAC3P = 1, @@ -39,11 +33,14 @@ enum { OMA_CODECID_ATRAC3AL = 34, }; -extern const uint16_t ff_oma_srate_tab[8]; - -extern const AVCodecTag ff_oma_codec_tags[]; - -extern const uint64_t ff_oma_chid_to_native_layout[7]; -extern const int ff_oma_chid_to_num_channels[7]; +static const AVCodecTag oma_codec_tags[] = { + { AV_CODEC_ID_ATRAC3, OMA_CODECID_ATRAC3 }, + { AV_CODEC_ID_ATRAC3P, OMA_CODECID_ATRAC3P }, + { AV_CODEC_ID_MP3, OMA_CODECID_MP3 }, + { AV_CODEC_ID_PCM_S16BE, OMA_CODECID_LPCM }, + { AV_CODEC_ID_ATRAC3PAL, OMA_CODECID_ATRAC3PAL }, + { AV_CODEC_ID_ATRAC3AL, OMA_CODECID_ATRAC3AL }, + { 0 }, +}; #endif /* AVFORMAT_OMA_H */ diff --git a/libavformat/omadec.c b/libavformat/omadec.c index 423d52b3aa..24afaa417b 100644 --- a/libavformat/omadec.c +++ b/libavformat/omadec.c @@ -48,6 +48,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/des.h" #include "libavutil/mathematics.h" +#include "libavcodec/oma.h" #include "oma.h" #include "pcm.h" #include "id3v2.h" @@ -432,14 +433,14 @@ static int oma_read_header(AVFormatContext *s) st->start_time = 0; st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_tag = buf[32]; - st->codecpar->codec_id = ff_codec_get_id(ff_oma_codec_tags, + st->codecpar->codec_id = ff_codec_get_id(oma_codec_tags, st->codecpar->codec_tag); oc->read_packet = read_packet; switch (buf[32]) { case OMA_CODECID_ATRAC3: - samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; + samplerate = oma_srate_tab[(codec_params >> 13) & 7] * 100; if (!samplerate) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n"); return AVERROR_INVALIDDATA; @@ -479,10 +480,10 @@ static int oma_read_header(AVFormatContext *s) "Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id); return AVERROR_INVALIDDATA; } - st->codecpar->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1]; - st->codecpar->channels = ff_oma_chid_to_num_channels[channel_id - 1]; + st->codecpar->channel_layout = oma_chid_to_native_layout[channel_id - 1]; + st->codecpar->channels = oma_chid_to_num_channels[channel_id - 1]; framesize = ((codec_params & 0x3FF) * 8) + 8; - samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; + samplerate = oma_srate_tab[(codec_params >> 13) & 7] * 100; if (!samplerate) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n"); return AVERROR_INVALIDDATA; @@ -610,5 +611,5 @@ AVInputFormat ff_oma_demuxer = { .read_close = oma_read_close, .flags = AVFMT_GENERIC_INDEX, .extensions = "oma,omg,aa3", - .codec_tag = (const AVCodecTag* const []){ff_oma_codec_tags, 0}, + .codec_tag = (const AVCodecTag* const []){oma_codec_tags, 0}, }; diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c index 7952808bf8..7c497a83dd 100644 --- a/libavformat/omaenc.c +++ b/libavformat/omaenc.c @@ -24,6 +24,7 @@ #include "avio_internal.h" #include "id3v2.h" #include "internal.h" +#include "libavcodec/oma.h" #include "oma.h" #include "rawenc.h" @@ -38,13 +39,13 @@ static av_cold int oma_write_header(AVFormatContext *s) /* check for support of the format first */ for (srate_index = 0; ; srate_index++) { - if (ff_oma_srate_tab[srate_index] == 0) { + if (oma_srate_tab[srate_index] == 0) { av_log(s, AV_LOG_ERROR, "Sample rate %d not supported in OpenMG audio\n", par->sample_rate); return AVERROR(EINVAL); } - if (ff_oma_srate_tab[srate_index] * 100 == par->sample_rate) + if (oma_srate_tab[srate_index] * 100 == par->sample_rate) break; } @@ -102,6 +103,6 @@ AVOutputFormat ff_oma_muxer = { .audio_codec = AV_CODEC_ID_ATRAC3, .write_header = oma_write_header, .write_packet = ff_raw_write_packet, - .codec_tag = (const AVCodecTag* const []){ff_oma_codec_tags, 0}, + .codec_tag = (const AVCodecTag* const []){oma_codec_tags, 0}, .flags = AVFMT_NOTIMESTAMPS, }; diff --git a/libavformat/version.h b/libavformat/version.h index 5ced041f0a..6453d4559f 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -33,7 +33,7 @@ // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 #define LIBAVFORMAT_VERSION_MINOR 3 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \