From patchwork Tue Aug 22 01:23:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Jones X-Patchwork-Id: 4794 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.137.29 with SMTP id o29csp350005jaj; Mon, 21 Aug 2017 18:31:10 -0700 (PDT) X-Received: by 10.223.136.39 with SMTP id d36mr7749266wrd.136.1503365470667; Mon, 21 Aug 2017 18:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503365470; cv=none; d=google.com; s=arc-20160816; b=lJqLZ+fbgk3pqfpzcQ2z604V3tQKKpGIqcUGcFWZg+0PIzXXfDRWD6wz3V34NSGm+m h4Nn8PzhYakqd2ryynSxp9Pe1/EDHjE2PAHWCKpJ22lOo1VoBUUrPhjE3GnnU4OABzJG xcp1Ni8YcubSsGUqmTVgZ3Q65dNnBGmTmKhRcTztsRLmEKt/UJEQn+oG9E9zjatnt6XQ 4aWQVQfgpWZFBVkPzgR7Vm4YFJWLuNpAoI++xUfhJ+wMTV6sIrABuI1l+AZL2VDWkXoh ialQhHMlepMgdR6qekTbmy1/mqtWPt0IX2ekVdZi+njsOCaI2tmm6tBLDmqQW23NSLzn UUGg== 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: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=GMrC9O9UkJIh4svqYbHaeZ/j7qakQXVnQS+XmO1tXcU=; b=QrFGCQhSO8fBfn8wtRJ8QaVjZONBu83Rp2mFL8M28YRtW7SP92EtBI8DWQNZLOCh7s btpE2cIOmYBSlRANBYHZYSmMXrW7CKRRrUyi2dMcBL/knDumg/2d6rCM6svbDQzyUGtZ DJe6BYF0JS1sdL1yJRmKG7fVe+vnmteFZRlPNNI4ghY0VLEC5jZl4Rcd23r4BaWfD9EV IBIYdB1MsOLupvv2M6vgemccdUZjc54fE4wuTGo3WJxt3vmMWYh5fw4DLhzCc+kkiVAL vGVcy+1CL9JOYSASmLJe1AW3W5KoQfvqOmF5NXKLCJbpIcNJgdbSDrVf/8wPL3CM2H/Q L7kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=AmHcCV/P; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z131si2482149wmz.236.2017.08.21.18.31.10; Mon, 21 Aug 2017 18:31:10 -0700 (PDT) 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=AmHcCV/P; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 40A22689BB8; Tue, 22 Aug 2017 04:31:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f68.google.com (mail-it0-f68.google.com [209.85.214.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B9330689B5C for ; Tue, 22 Aug 2017 04:30:53 +0300 (EEST) Received: by mail-it0-f68.google.com with SMTP id 190so2536797itx.3 for ; Mon, 21 Aug 2017 18:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=1gZZHf3iQQp5CNrVBKnIIEsrkIjbAo756+DXNvkuXdQ=; b=AmHcCV/PUOf9r5I937fZwqHSrxnQsA4xbtVZq5fI75hW8rWM+SqBx4gJtIPibP/YC3 5TZntm8ziZfX9pVbjc+YjEhpeAOdOhccxeX4WqGDtPtvLmB9nED5Sgs8CTyT45h7x6oJ IQEskxaC6phkdzg2dVFIxi2U57YjjODlvDZxZ1bStM15isDMyZ9YgKf43hPaHFCu9MwS DHXNl02XAuhkVy4Ay59YD1pDTo02mXvuOSj+NsR6QAmbht/gHFqK+ApzBbylJcE6WCkP bLB6K37GC+UeZg0PQRT6gQh2psUoyc9MYNyD5bi+kFa/pmf6F34wqjSXzLIFgOFhQPVe X4nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=1gZZHf3iQQp5CNrVBKnIIEsrkIjbAo756+DXNvkuXdQ=; b=XBfn556gUKuKG/UqrdT2SGB/6c3/vQ7XOlycak6fV1IA7LD0r15Qij6cNncJtjbGtw Gxoo+LdXJaROb13R+Zo2AF8alI9rWLdDI8tynQDiK5QgOGEbuIcQv5gmoufWRn/ay9aN rIQNbZt6xVu/WeDft98bmysnf2HJ/WLkhTEDe8/130askO6N0d5IsD5RmDyICRRbK4lj 7kkpK5HK6Y1qdT9RnXDnuFIlks497QW7ea/dwQxu/6xGyb5cl3kahDYzUawXZki/hqv6 Gq9d6s2Fwgh6lnyudDlRWWy3h6EnXfDj8upDi2yAImLIBUj3e2AHBYxHn7KBlVACyPFk KF+A== X-Gm-Message-State: AHYfb5hYJYAdPS9348AXm3Xihh79fsyDa/qSA/iOAYa5IFUopEpeN3T1 eh8bUPv1/ZMRr8Iy X-Received: by 10.36.79.12 with SMTP id c12mr1876068itb.26.1503364989785; Mon, 21 Aug 2017 18:23:09 -0700 (PDT) Received: from tdjones.localdomain (host-184-167-177-46.csp-wy.client.bresnan.net. [184.167.177.46]) by smtp.gmail.com with ESMTPSA id v142sm4607256ita.35.2017.08.21.18.23.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 18:23:08 -0700 (PDT) From: Tyler Jones To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Aug 2017 19:23:05 -0600 Message-Id: <20170822012307.6019-5-tdjones879@gmail.com> In-Reply-To: <20170822012307.6019-1-tdjones879@gmail.com> References: <20170822012307.6019-1-tdjones879@gmail.com> Subject: [FFmpeg-devel] [PATCH 4/6] avcodec/vorbisenc: Move encoder structures and macros to separate file 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Encoder structures are moved to a separate header file to improve readability. Signed-off-by: Tyler Jones --- libavcodec/vorbisenc.c | 118 +--------------------------------------- libavcodec/vorbisenc.h | 145 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 117 deletions(-) create mode 100644 libavcodec/vorbisenc.h diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 73182c6356..fae90c4a30 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -25,18 +25,12 @@ */ #include -#include "libavutil/float_dsp.h" +#include "vorbisenc.h" #include "avcodec.h" #include "internal.h" -#include "fft.h" #include "mathops.h" -#include "vorbis.h" #include "vorbis_enc_data.h" -#include "vorbispsy.h" - -#include "audio_frame_queue.h" -#include "libavfilter/bufferqueue.h" #define BITSTREAM_WRITER_LE #include "put_bits.h" @@ -44,116 +38,6 @@ #undef NDEBUG #include -typedef struct vorbis_enc_codebook { - int nentries; - uint8_t *lens; - uint32_t *codewords; - int ndimensions; - float min; - float delta; - int seq_p; - int lookup; - int *quantlist; - float *dimensions; - float *pow2; -} vorbis_enc_codebook; - -typedef struct vorbis_enc_floor_class { - int dim; - int subclass; - int masterbook; - int *books; -} vorbis_enc_floor_class; - -typedef struct vorbis_enc_floor { - int partitions; - int *partition_to_class; - int nclasses; - vorbis_enc_floor_class *classes; - int multiplier; - int rangebits; - int values; - vorbis_floor1_entry *list; -} vorbis_enc_floor; - -typedef struct vorbis_enc_residue { - int type; - int begin; - int end; - int partition_size; - int classifications; - int classbook; - int8_t (*books)[8]; - float (*maxes)[2]; -} vorbis_enc_residue; - -typedef struct vorbis_enc_mapping { - int submaps; - int *mux; - int *floor; - int *residue; - int coupling_steps; - int *magnitude; - int *angle; -} vorbis_enc_mapping; - -typedef struct vorbis_enc_mode { - int blockflag; - int mapping; -} vorbis_enc_mode; - -typedef struct vorbis_enc_context { - int channels; - int sample_rate; - int log2_blocksize[2]; - int blockflags[3]; ///< Flags used for the previous, current, next windows - int transient; ///< Negative if a series of transients are not being encoded - int num_transient; ///< Number of short blocks for each frame - FFTContext mdct[2]; - const float *win[2]; - int have_saved; - float *saved; - float *samples; - float *floor; // also used for tmp values for mdct - float *coeffs; // also used for residue after floor - float *scratch; //< Used for temp values for psy model and window application - float quality; - - AudioFrameQueue afq; - struct FFBufQueue bufqueue; - - int ncodebooks; - vorbis_enc_codebook *codebooks; - - int nfloors; - vorbis_enc_floor *floors; - - int nresidues; - vorbis_enc_residue *residues; - - int nmappings; - vorbis_enc_mapping *mappings; - - int nmodes; - vorbis_enc_mode *modes; - - int64_t next_pts; - - AVFloatDSPContext *fdsp; - VorbisPsyContext vpctx; -} vorbis_enc_context; - -#define MAX_CHANNELS 2 -#define MAX_CODEBOOK_DIM 8 - -#define MAX_FLOOR_CLASS_DIM 4 -#define NUM_FLOOR_PARTITIONS 8 -#define MAX_FLOOR_VALUES (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2) - -#define RESIDUE_SIZE 1600 -#define RESIDUE_PART_SIZE 32 -#define NUM_RESIDUE_PARTITIONS (RESIDUE_SIZE/RESIDUE_PART_SIZE) - static inline int put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb, int entry) { diff --git a/libavcodec/vorbisenc.h b/libavcodec/vorbisenc.h new file mode 100644 index 0000000000..15ee02dfa6 --- /dev/null +++ b/libavcodec/vorbisenc.h @@ -0,0 +1,145 @@ +/* + * Vorbis encoder + * Copyright (C) 2017 Tyler Jones + * + * 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 + */ + +#ifndef AVCODEC_VORBISENC_H +#define AVCODEC_VORBISENC_H + +#define MAX_CHANNELS 2 +#define MAX_CODEBOOK_DIM 8 + +#define MAX_FLOOR_CLASS_DIM 4 +#define NUM_FLOOR_PARTITIONS 8 +#define MAX_FLOOR_VALUES (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2) + +#define RESIDUE_SIZE 1600 +#define RESIDUE_PART_SIZE 32 +#define NUM_RESIDUE_PARTITIONS (RESIDUE_SIZE/RESIDUE_PART_SIZE) + +#include "vorbis.h" +#include "vorbispsy.h" +#include "audio_frame_queue.h" +#include "libavutil/float_dsp.h" +#include "libavfilter/bufferqueue.h" +#include "fft.h" + +typedef struct vorbis_enc_codebook { + int nentries; + uint8_t *lens; + uint32_t *codewords; + int ndimensions; + float min; + float delta; + int seq_p; + int lookup; + int *quantlist; + float *dimensions; + float *pow2; +} vorbis_enc_codebook; + +typedef struct vorbis_enc_floor_class { + int dim; + int subclass; + int masterbook; + int *books; +} vorbis_enc_floor_class; + +typedef struct vorbis_enc_floor { + int partitions; + int *partition_to_class; + int nclasses; + vorbis_enc_floor_class *classes; + int multiplier; + int rangebits; + int values; + vorbis_floor1_entry *list; +} vorbis_enc_floor; + +typedef struct vorbis_enc_residue { + int type; + int begin; + int end; + int partition_size; + int classifications; + int classbook; + int8_t (*books)[8]; + float (*maxes)[2]; +} vorbis_enc_residue; + +typedef struct vorbis_enc_mapping { + int submaps; + int *mux; + int *floor; + int *residue; + int coupling_steps; + int *magnitude; + int *angle; +} vorbis_enc_mapping; + +typedef struct vorbis_enc_mode { + int blockflag; + int mapping; +} vorbis_enc_mode; + +typedef struct vorbis_enc_context { + int channels; + int sample_rate; + int log2_blocksize[2]; + int blockflags[3]; ///< Flags used for the previous, current, next windows + int transient; ///< Negative if a series of transients are not being encoded + int num_transient; ///< Number of short blocks for each frame + FFTContext mdct[2]; + const float *win[2]; + int have_saved; + float *saved; + float *samples; + float *floor; // also used for tmp values for mdct + float *coeffs; // also used for residue after floor + float *scratch; //< Used for temp values for psy model and window application + float quality; + + AudioFrameQueue afq; + struct FFBufQueue bufqueue; + + int nfloor_books; + vorbis_enc_codebook *floor_books; + + int nfloors; + vorbis_enc_floor *floors; + + int nres_books; + vorbis_enc_codebook *res_books; + + int nresidues; + vorbis_enc_residue *residues; + + int nmappings; + vorbis_enc_mapping *mappings; + + int nmodes; + vorbis_enc_mode *modes; + + int64_t next_pts; + + AVFloatDSPContext *fdsp; + VorbisPsyContext vpctx; +} vorbis_enc_context; + +#endif /* AVCODEC_VORBISENC_H */