From patchwork Mon Oct 30 23:40:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 5771 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp3272288jah; Mon, 30 Oct 2017 16:40:55 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Q1h0BT/c5SaA9tZnwuxOdxqi8CCmAEy7on+3nXpeEVNe9pdwf/dgdQrVuD2st8tpxZ3lbB X-Received: by 10.28.92.208 with SMTP id q199mr250301wmb.96.1509406855321; Mon, 30 Oct 2017 16:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509406855; cv=none; d=google.com; s=arc-20160816; b=L8dYgm/qy50GnK4hdSnZtmDRts/Y/kSWH4zRc8viZKsR1W9uBGrIlMqYexNicZZtU1 yx8Bs8fWBl7Cu5Oeac0ngFIXLsSZiu2Cv54QePhwqzpxickPL5x270juLiFpgstoObAA xzYI9ok/lPgsIhLzuLvuV8yBlsIG5m4lmFDagMPJPACSI9FlVLMM/JYJurtqEp/u3iqJ kwXJO2LWid3zDMl68SryXyLDjLUOgKHXtVMBUDuGZpmamSL+cpA3KMKgBAji393hjmnx AONHlLFlCdqN2uoYxT+d8JhFE35+NgeUwDM/zdIPrjHbmnV/+wNeRenXjhHBacFFleiX hG9Q== 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:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=49f+fsvYC3QLsDak4+V0MEuTyPkiUekxUQNYSwI0BL4=; b=0MRrjHsvF/gfxJANopz6z/uAUItnPV8FItLnylqQTks8vVE4kt9Pyl7WqbOxDFcKUe mqIeXcOgU1kjnoSohvtkFvhBK7wqJoh4RcZjjNfBgnrV2OlyaAg5zs5saNwLHOvWuGFX KRQHO9LbJe49NnC2RyvhiJz1H83jaKXOhrueqyIraeNq9gToISjcKm2TFKgiY4pqm3pX F/pTr8aB2Z6S2qTigWboCZWc1BxvbkGUtKE9FSzRlo68I/aN77+hWcLUDQceZD7efeRz kTH15PePscRgL7IlXOUbHlk7uI4i91hXLyNpuIq8hYBNUSorB+VKaHUYmp2NqGcZIEXH l0og== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Lw2mQuEI; 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 e28si122945wra.96.2017.10.30.16.40.54; Mon, 30 Oct 2017 16:40:55 -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=Lw2mQuEI; 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 C92C3689DE7; Tue, 31 Oct 2017 01:40:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f196.google.com (mail-io0-f196.google.com [209.85.223.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81723689C92 for ; Tue, 31 Oct 2017 01:40:36 +0200 (EET) Received: by mail-io0-f196.google.com with SMTP id 97so31103377iok.7 for ; Mon, 30 Oct 2017 16:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=NtdHx+cn1/AHQLfN9XWrghdh2/zmDqpmuScQgDFU7dE=; b=Lw2mQuEIQW0ZI1xQ8VTanfikMCDLeDrunNhtjbzoulH5FhhnpdPU509Ck+wAkKm+Jk PTWXPq0ckNSQ5qQDUoKJqb0H4ocaHAzM0RNhbrZi48Sduf3ckP3WVnj7JHzV42UT4ML/ XtJjNQMTduiZDr/VjmkPmJSo5C98lfFTQnDJKHJhol6XrG76sAntVTLTVLfNk1skgWqb YzdVPiRsYviRZRC/weQ2YT5QrVhzyVPL39mf3rROanichCI6N/6IHc+J0L6oIireCRze YS2q7fuo2qBSjcC9gn9UIJHTjeZkfdRmsmc6b624nucir8KMW0wFhYkaXwcBeSCBqy4j 6xxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=NtdHx+cn1/AHQLfN9XWrghdh2/zmDqpmuScQgDFU7dE=; b=DdKg7g83Z98g44Y43BYVXgh/DFzG5zH37+ToxFx4mqzIVUMxhV9CVN9xNKweeFnL2i Zf8u5B3Ic9wVwbZRaPLIL6BUTqkiFaTU8yiAH5seLFlAIL8LQBYQQPrjzk+CAcDTokl9 GOcaYILjooA4wGjUpIM88gu1li702HnN3DZYLyMVBOE7t3YLR5h90GUwTzeLwYSFYcF5 u8Xzr2LbIgOCbpKlQ1t6RofDqM+F/UAY8/Za66VFxWzEf6x3/+MZO/cQ4ist2QYl0Amr bpoYF0trxVd4vxUKvk7KPa2BNEHDlfxsEokYPa+7x0pNEA76SnN8vCMpzhiCgvbRLzby tBbg== X-Gm-Message-State: AMCzsaXA7+ESmPO9jLyzw59Azqxn18LjSW+G1Sdg7h0voJL0EKwO+vtc UbpeJ7IhXuIqMPt/DgiBbP9LnwG5s4G7CXNwBSM= X-Received: by 10.36.120.136 with SMTP id p130mr642486itc.54.1509406844600; Mon, 30 Oct 2017 16:40:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.63.101 with HTTP; Mon, 30 Oct 2017 16:40:24 -0700 (PDT) In-Reply-To: References: From: Carl Eugen Hoyos Date: Tue, 31 Oct 2017 00:40:24 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [RFC]lswr/rematrix: Support s32p 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" 2017-10-30 9:47 GMT+01:00 Muhammad Faiz : > On Sun, Oct 29, 2017 at 3:55 AM, Carl Eugen Hoyos wrote: >> Hi! >> >> Attached patch fixes a random testcase for ticket #6785 here but I >> don't know if this is the correct fix. >> >> Please review, Carl Eugen >> >> From a93b9309d74f5eadece371ee1e682d266af6cd83 Mon Sep 17 00:00:00 2001 >> From: Carl Eugen Hoyos >> Date: Sat, 28 Oct 2017 22:52:02 +0200 >> Subject: [PATCH] lswr/rematrix: Support s32p. >> >> Fixes ticket #6785. >> --- >> libswresample/rematrix.c | 21 +++++++++++++++------ >> 1 file changed, 15 insertions(+), 6 deletions(-) >> >> diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c >> index 66a43c1..a6aa6b0 100644 >> --- a/libswresample/rematrix.c >> +++ b/libswresample/rematrix.c >> @@ -445,14 +445,23 @@ av_cold int swri_rematrix_init(SwrContext *s){ >> s->mix_2_1_f = (mix_2_1_func_type*)sum2_double; >> s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s); >> }else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){ >> - // Only for dithering currently >> -// s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double)); >> - s->native_one = av_mallocz(sizeof(int)); >> + s->native_one = av_mallocz(sizeof(int64_t)); >> if (!s->native_one) >> return AVERROR(ENOMEM); >> -// for (i = 0; i < nb_out; i++) >> -// for (j = 0; j < nb_in; j++) >> -// ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j]; >> + s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int)); >> + if (!s->native_matrix) { >> + av_freep(&s->native_one); >> + return AVERROR(ENOMEM); >> + } >> + for (i = 0; i < nb_out; i++) { >> + double rem = 0; >> + >> + for (j = 0; j < nb_in; j++) { >> + double target = s->matrix[i][j] * 32768 + rem; >> + ((int*)s->native_matrix)[i * nb_in + j] = lrintf(target); >> + rem += target - ((int64_t*)s->native_matrix)[i * nb_in + j]; >> + } >> + } >> *((int*)s->native_one) = 32768; >> s->mix_1_1_f = (mix_1_1_func_type*)copy_s32; >> s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32; > > The code is confusing. > Which is the type of native_matrix and native_one? int or int64_t? New patch attached. Please review, Carl Eugen From a93b9309d74f5eadece371ee1e682d266af6cd83 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Sat, 28 Oct 2017 22:52:02 +0200 Subject: [PATCH] lswr/rematrix: Support s32p. Fixes ticket #6785. --- libswresample/rematrix.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 66a43c1..a6aa6b0 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -445,14 +445,23 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->mix_2_1_f = (mix_2_1_func_type*)sum2_double; s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s); }else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){ - // Only for dithering currently -// s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double)); - s->native_one = av_mallocz(sizeof(int)); + s->native_one = av_mallocz(sizeof(int)); if (!s->native_one) return AVERROR(ENOMEM); -// for (i = 0; i < nb_out; i++) -// for (j = 0; j < nb_in; j++) -// ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j]; + s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int)); + if (!s->native_matrix) { + av_freep(&s->native_one); + return AVERROR(ENOMEM); + } + for (i = 0; i < nb_out; i++) { + double rem = 0; + + for (j = 0; j < nb_in; j++) { + double target = s->matrix[i][j] * 32768 + rem; + ((int*)s->native_matrix)[i * nb_in + j] = lrintf(target); + rem += target - ((int*)s->native_matrix)[i * nb_in + j]; + } + } *((int*)s->native_one) = 32768; s->mix_1_1_f = (mix_1_1_func_type*)copy_s32; s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32; -- 1.7.10.4