From patchwork Tue Oct 11 03:56:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Turner X-Patchwork-Id: 966 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp187131vsd; Tue, 11 Oct 2016 23:22:29 -0700 (PDT) X-Received: by 10.28.7.66 with SMTP id 63mr33985wmh.16.1476253347931; Tue, 11 Oct 2016 23:22:27 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kq1si8547422wjb.150.2016.10.11.23.22.27; Tue, 11 Oct 2016 23:22:27 -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=@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 dis=QUARANTINE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 50FEF689B4C; Wed, 12 Oct 2016 09:22:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f68.google.com (mail-pa0-f68.google.com [209.85.220.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5E545689AEC for ; Tue, 11 Oct 2016 06:57:21 +0300 (EEST) Received: by mail-pa0-f68.google.com with SMTP id rw4so727742pab.3 for ; Mon, 10 Oct 2016 20:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=l23LlAQqjutIryr1/HyYyAusOxL1O0t8ARIC1Leb1ik=; b=f6t4RIq/4GZrh/y0tlDFCD3B49TMGAzXvF41ssQuo3cpEP8RU95oqLzg1Ezh2NfX7m J2+HpWjljiMK7AWG3+7j1sZVxgSdBCB6qUHj1nHiAuS7zC7GQC8m8Z8TF4CkGUEQgwv3 SrqwEXijUTDI49Tx6zdYY2fLyY4p1bhiwgvReuQMbSt0sskgj1wRu5AFety4xoBntbJk +1WlO0fSF7ZBEq/UCxKi9WSaZVtn6ijsNtStaaPRaNZEYTdwAMCG8v152Pe0rFP7qUXw STx2TLX6qwlIMrG0eDdrMfoXCLZYdPz84Ru09f3QCZvldElnURH9phDfEEFHr0e2LwY8 2gPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=l23LlAQqjutIryr1/HyYyAusOxL1O0t8ARIC1Leb1ik=; b=j5z1t2w48tt/qlgiQpnCTy5mR+N27yYk2M1eJDsfSbogQRqKhTGeGc/PW2qqXP6VRd 53EkCWBA4a3MhjjNvJx2qoNp0Z2sQ444rTK5rfcxnxW3K1zctz3O3GHpx2koYqFV82Pz uAbdC4UgqVT35y46DK0YaTOY7OX830jCa+rm6GoVR8As30qVk4iPZP6ZvKpjLpuwLUPt ktIAmvEvd1Nd0+jEqBBY/PSWTgPfCdY46aE7rCxJWtZ95hYohBfHXSU1P7yAVH5GEInI hbIOOEpNNvi/tAfU7JK1wPK5aU18tAq/sM2mLj6E/rmjiQ3tDUj08XlMVlsTa0PKUqkT T+FA== X-Gm-Message-State: AA6/9RnG3M2dsktAUx8iLjFzy8XogUCrFb6DudZbu3MyOEtVjfUJaoFe826xi+y2b6O6uw== X-Received: by 10.66.19.232 with SMTP id i8mr3155434pae.34.1476158257010; Mon, 10 Oct 2016 20:57:37 -0700 (PDT) Received: from Zany.domain.actdsltmp ([47.136.133.132]) by smtp.gmail.com with ESMTPSA id a88sm1225528pfe.21.2016.10.10.20.57.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Oct 2016 20:57:36 -0700 (PDT) From: Thomas Turner X-Google-Original-From: Thomas Turner To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 Oct 2016 20:56:51 -0700 Message-Id: <1476158213-7542-1-git-send-email-thomastdt@gmail.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Wed, 12 Oct 2016 09:22:24 +0300 Subject: [FFmpeg-devel] [PATCH 1/3] Improve selftest coverage for libavutil library 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: Thomas Turner MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Code coverage for av_fifo_generic_peek(...) and av_fifo_grow(...) . --- libavutil/tests/fifo2.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 libavutil/tests/fifo2.c diff --git a/libavutil/tests/fifo2.c b/libavutil/tests/fifo2.c new file mode 100644 index 0000000..923feee --- /dev/null +++ b/libavutil/tests/fifo2.c @@ -0,0 +1,77 @@ +/* + * 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 + */ + +#include +#include +#include "libavutil/fifo.h" + + + +int main(void) +{ + + int16_t offset, fifo_size, space_size, data_size; + int32_t data, *data_arr; + int32_t elem[] = {0, 2, 4, 6, 8, 10, 12}; + AVFifoBuffer* fifo; + + data_size = sizeof(elem[0]); + fifo = av_fifo_alloc(sizeof(elem)); + + /*fill fifo buffer*/ + + if (av_fifo_generic_write(fifo, (void*)elem, av_fifo_space(fifo), NULL) != sizeof(elem)) { + + fprintf(stderr, "written incorrect number of bytes\n"); + return 1; + } + + + /* generic peek at fifo */ + + fifo_size = av_fifo_size(fifo); + data_arr = (int32_t*)malloc(fifo_size); + + (void) av_fifo_generic_peek(fifo, data_arr, fifo_size, NULL); + + printf("fifo->buffer: "); + for(offset = 0; offset < fifo_size/data_size; ++offset){ + printf("%" PRId32 ", ", data_arr[offset]); + } + + space_size = av_fifo_space(fifo); + printf("\nspace before av_fifo_grow\t:%" PRId16 "\n", space_size); + + /* grow AVFifoBuffer */ + + data = av_fifo_grow(fifo, data_size); + if(data < 0) + printf("\n%s\n", "failure growing fifo\n"); + + + space_size = av_fifo_space(fifo); + printf("space after av_fifo_grow\t:%" PRId16 "\n", space_size); + + + /* free AVFifoBuffer and data_arr */ + + av_fifo_free(fifo); + free(data_arr); + + return 0; +}