From patchwork Thu Jan 12 01:20:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Turner X-Patchwork-Id: 2187 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp1053555vsb; Wed, 11 Jan 2017 17:20:45 -0800 (PST) X-Received: by 10.223.131.99 with SMTP id 90mr6397773wrd.14.1484184045185; Wed, 11 Jan 2017 17:20:45 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rk19si6005641wjb.69.2017.01.11.17.20.44; Wed, 11 Jan 2017 17:20:45 -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=@googlemail.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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5BA2568A19A; Thu, 12 Jan 2017 03:20:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F221068A149 for ; Thu, 12 Jan 2017 03:20:26 +0200 (EET) Received: by mail-pf0-f193.google.com with SMTP id f144so739814pfa.2 for ; Wed, 11 Jan 2017 17:20:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id; bh=vEyqXaFqeNacFl0H/l3cuFGXxu95sGwmkDJIcI0tlrQ=; b=uF0U4PQFgKXB6rwL++MLj6K+Bu5t5kwbWsAX0KzhDUL/UOnnL1uFGy2FFVRovoHtc3 jb3C9HludZsmBHP6WrKVjhi+/l9fzl8GOoomWVYqvnCYdnI4rt6hTSwDFrLJ9YX63jjO IVCdYxUtRQ3YrdgAS3wZDoJ6YLWTIKzw5gVmAmokxJ3wka9yaP7M1WDowUgxCFRJkKC7 LfNOvZqGGet8KfBry4dR5rXpTt8MY03VzF4XtJMgTrTK57tEcaepK4tevm1c4Dm0ZMLT uEQaXytKrRz/3JUhAXaECk4oEpcQb1jfmwKqBpJDD44GVF1BHEIGRoJ9pCKV+8XBY3Az sKmg== 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; bh=vEyqXaFqeNacFl0H/l3cuFGXxu95sGwmkDJIcI0tlrQ=; b=JANFkAtJIxNhYdx5/bB40s+IkuA6Cvynz9Vs6j7uo4kzuBuB/vJ0MTCdlEjeLtihUN 4yQi7JRe9ui5Q21flsW/kLHZoXksqXw7ey82Oxa4SLrwG31bGtBxsNN+bPG3oh7NkMIf 5LGYdClAzb9RQTWKTXmMFXwS1heuJrnnKUi4+rbai0Pon12BdwGS3NRGbeQjrDDE8qgc 0MRBnBdtfsaKvBG4kjOqwY7As45pC+5/cHzGU2iXR37P7V+iu1A1LIAtSV0qEPeW62TY cm7YtldNLGxVy3xOqTe+6s0yAvhmRq61hvvcwDQlw84ikBEIZGkn+fD9AGh4T+ExXzDq dpew== X-Gm-Message-State: AIkVDXLdKNZVCrWw836RDUl7/K7J8b8offZME33F5k9oi+kYErcbXqJUvWteaJlLQKSaFA== X-Received: by 10.99.176.76 with SMTP id z12mr14302631pgo.158.1484184032859; Wed, 11 Jan 2017 17:20:32 -0800 (PST) Received: from Zany.attlocal.net ([198.8.80.157]) by smtp.gmail.com with ESMTPSA id 135sm16582318pgc.7.2017.01.11.17.20.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 17:20:32 -0800 (PST) From: Thomas Turner To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Jan 2017 17:20:30 -0800 Message-Id: <1484184030-21669-1-git-send-email-thomastdt@googlemail.com> X-Mailer: git-send-email 1.9.1 Subject: [FFmpeg-devel] [PATCH] avutil/tests/audio_fifo.c: pass by reference for efficiency and change datatype to const 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" Signed-off-by: Thomas Turner --- libavutil/tests/audio_fifo.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c index 861cebb..e107166 100644 --- a/libavutil/tests/audio_fifo.c +++ b/libavutil/tests/audio_fifo.c @@ -29,7 +29,7 @@ typedef struct TestStruct { const enum AVSampleFormat format; const int nb_ch; void const *data_planes[MAX_CHANNELS]; - int nb_samples_pch; + const int nb_samples_pch; } TestStruct; static const uint8_t data_U8 [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; @@ -102,55 +102,55 @@ static int read_samples_from_audio_fifo(AVAudioFifo* afifo, void ***output, int return av_audio_fifo_read(afifo, *output, nb_samples); } -static int write_samples_to_audio_fifo(AVAudioFifo* afifo, const TestStruct test_sample, +static int write_samples_to_audio_fifo(AVAudioFifo* afifo, const TestStruct *test_sample, int nb_samples, int offset) { int offset_size, i; void *data_planes[MAX_CHANNELS]; - if(nb_samples > test_sample.nb_samples_pch - offset){ + if(nb_samples > test_sample->nb_samples_pch - offset){ return 0; } - if(offset >= test_sample.nb_samples_pch){ + if(offset >= test_sample->nb_samples_pch){ return 0; } offset_size = offset * afifo->sample_size; for (i = 0; i < afifo->nb_buffers ; ++i){ - data_planes[i] = (uint8_t*)test_sample.data_planes[i] + offset_size; + data_planes[i] = (uint8_t*)test_sample->data_planes[i] + offset_size; } return av_audio_fifo_write(afifo, data_planes, nb_samples); } -static void test_function(const TestStruct test_sample) +static void test_function(const TestStruct *test_sample) { int ret, i; void **output_data = NULL; - AVAudioFifo *afifo = av_audio_fifo_alloc(test_sample.format, test_sample.nb_ch, - test_sample.nb_samples_pch); + AVAudioFifo *afifo = av_audio_fifo_alloc(test_sample->format, test_sample->nb_ch, + test_sample->nb_samples_pch); if (!afifo) { ERROR("ERROR: av_audio_fifo_alloc returned NULL!"); } - ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0); + ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample->nb_samples_pch, 0); if (ret < 0){ ERROR("ERROR: av_audio_fifo_write failed!"); } printf("written: %d\n", ret); - ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample.nb_samples_pch, 0); + ret = write_samples_to_audio_fifo(afifo, test_sample, test_sample->nb_samples_pch, 0); if (ret < 0){ ERROR("ERROR: av_audio_fifo_write failed!"); } printf("written: %d\n", ret); printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo)); - ret = read_samples_from_audio_fifo(afifo, &output_data, test_sample.nb_samples_pch); + ret = read_samples_from_audio_fifo(afifo, &output_data, test_sample->nb_samples_pch); if (ret < 0){ ERROR("ERROR: av_audio_fifo_read failed!"); } printf("read: %d\n", ret); - print_audio_bytes(&test_sample, output_data, ret); + print_audio_bytes(test_sample, output_data, ret); printf("remaining samples in audio_fifo: %d\n\n", av_audio_fifo_size(afifo)); /* test av_audio_fifo_peek */ @@ -159,7 +159,7 @@ static void test_function(const TestStruct test_sample) ERROR("ERROR: av_audio_fifo_peek failed!"); } printf("peek:\n"); - print_audio_bytes(&test_sample, output_data, ret); + print_audio_bytes(test_sample, output_data, ret); printf("\n"); /* test av_audio_fifo_peek_at */ @@ -170,7 +170,7 @@ static void test_function(const TestStruct test_sample) ERROR("ERROR: av_audio_fifo_peek_at failed!"); } printf("%d:\n", i); - print_audio_bytes(&test_sample, output_data, ret); + print_audio_bytes(test_sample, output_data, ret); } printf("\n"); @@ -194,7 +194,7 @@ int main(void) for (t = 0; t < tests; ++t){ printf("\nTEST: %d\n\n", t+1); - test_function(test_struct[t]); + test_function(&test_struct[t]); } return 0; }