From patchwork Wed Apr 25 21:22:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Keroulas X-Patchwork-Id: 8648 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp1160354jad; Wed, 25 Apr 2018 14:23:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx48e/ZmokzkUW1FgAvhJy/v8Up7pVuMmbbk3YxLfgBwVt2mAuiBDISeXyNcKqS5SSIvKpUxW X-Received: by 2002:adf:aa94:: with SMTP id h20-v6mr24924744wrc.149.1524691392217; Wed, 25 Apr 2018 14:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524691392; cv=none; d=google.com; s=arc-20160816; b=UvgjXwq5RerB4Ekca9lO4K6sOyN78V4B4YDBJMUQ6J8vm7Wth9MbrC4VOuMhkeaYEz FiBMiGr9L+/0PyQPFR2D1gIDGhJtAGucnl9aqhuEebgKsaFuJ94ju6YD6/Skq7zn8yxo lWGPmBL5DASp1UY678o9LdlZ8Uxr3XWZr0QsmGB9SfAeLY2awH8pxHnNl5DemeBoTOHF i0ro2Aj91pTA7ujJcmmSrucBpDvkZvXWeFdA9Sx7HdvuEVnN7bJtCimyf02HL/d0Z/yT ldtUAgwGUsVZGBG1alRaTm216xiX2ULGrGaMRIjz3CMV7Gf5bgPRhLQChNoZHqL1NmPb 05Bw== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=raRZBdHhFDMIFHkVKuyhb2x0on3iFDCXPmikpP6Y8qU=; b=EzSRSxpKZb1/aKDCvKgLnAGNzRsA08lw5BoQi7I6mckWB2DEzLnIl3g0xByFfANj4h MOCBD4Xq2/quOJtdJDFWeVVplOcCeE4vue9c4CLygCm84XqBLYsh2VNRXUsVU0fhQwyR wa3C+jDDRc9eiPvfsj19fy9a+9ekq8E5afY1UVFMXrbnsq0Ozjnig1JUKlXAq/6p09uD Ll/OrzlMNy4BY7FJOfur51QI0Ar2TBi9wNGHdh12/GjuSjES1eHQ1I9heoqOQ/mdEpC9 UTu8z1tlBLXrqjK3L0kSSnG2crT5zCQ9J4bINlA/2Qza7pkuq269UY4l7K9PxnLuQ4KW DmXA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m140si3814717wmd.141.2018.04.25.14.23.11; Wed, 25 Apr 2018 14:23:12 -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; 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 E2AD868A3FE; Thu, 26 Apr 2018 00:22:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D03BC68A3D5 for ; Thu, 26 Apr 2018 00:22:33 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 742C19C355F for ; Wed, 25 Apr 2018 17:23:02 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id yRKqeDX0lDNJ; Wed, 25 Apr 2018 17:23:02 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id E8B229C3563; Wed, 25 Apr 2018 17:23:01 -0400 (EDT) X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id abCDhXTKdaWS; Wed, 25 Apr 2018 17:23:01 -0400 (EDT) Received: from pkeroulas.media.in.cbcsrc.ca (unknown [192.168.50.171]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id C0D0C9C3541; Wed, 25 Apr 2018 17:23:01 -0400 (EDT) From: Patrick Keroulas To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Apr 2018 17:22:49 -0400 Message-Id: <1524691371-10166-1-git-send-email-patrick.keroulas@savoirfairelinux.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH v4 1/3] avcodec/bitpacked: move ff_get_buffer 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: Damien Riegel MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Damien Riegel ff_get_buffer is used to allocate a buffer to hold frame's content. This function was called in the function in charge of decoding an AVPacket containing raw video with the yuv422 pixel format and a depth of 10-bit. RFC4175 supports both progressive and interlaced mode. But the interlaced mode doesn't consist of interlaced frames, only of fields. FFmpeg cannot handle fields on their own, so the codec has to recreate interlaced frames based on two consecutive fields. As the function `bitpacked_decode_yuv422p10` will need to be called twice to do that, it cannot be in charge of the buffer allocation, so move it into its caller. Signed-off-by: Damien Riegel --- libavcodec/bitpacked.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/bitpacked.c b/libavcodec/bitpacked.c index f0b417d..85d4bdd 100644 --- a/libavcodec/bitpacked.c +++ b/libavcodec/bitpacked.c @@ -64,9 +64,6 @@ static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame, uint16_t *y, *u, *v; int ret, i, j; - ret = ff_get_buffer(avctx, frame, 0); - if (ret < 0) - return ret; if (frame_size > packet_size) return AVERROR_INVALIDDATA; @@ -128,6 +125,12 @@ static int bitpacked_decode(AVCodecContext *avctx, void *data, int *got_frame, frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; + if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10) { + res = ff_get_buffer(avctx, frame, 0); + if (res < 0) + return res; + } + res = bc->decode(avctx, frame, avpkt); if (res) return res;