From patchwork Tue Apr 10 21:21:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Keroulas X-Patchwork-Id: 8387 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp78465jad; Tue, 10 Apr 2018 16:47:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx49KJJX57wSom1Bg47MktdVxQ9HQHYeyKfdgF2ewLc6fAUYH6/+PorN+QnrWJRoXU+dwfCzP X-Received: by 10.223.133.197 with SMTP id 5mr1776811wru.130.1523404034620; Tue, 10 Apr 2018 16:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404034; cv=none; d=google.com; s=arc-20160816; b=TbE42Pp+BnPJBRUbGXMyiwOli8KJ4d1I2pUQG+utJB5B/Cj5z4J9t9GS37eORA39Qb iYvYah0TrKDJSEH/2Ljx1xzsGPbWk5Cb95pp16AeJZdTEzvrx+BODNAk0ohEEdcMnBDV /tL9YtQNyKHU8K/GMo3zMY8uon4FOfS36ZmMSgHSHo/mzDSN/Y/2URv3TxZfDqIOWwEK oCxKvNugLOfzlrYRf3evekSdmrStVDtpVTMspGwSe/JYghd0ByRn7pLA5cvMyy/nKKvP hkSVDpzgWU/0yf4sN0x1uS+IH85660bfHr0t98E1LHB8S3OUNlnTcPVGGXmyQysqT71y w0FQ== 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=KHGJb4fL3QSOzZsvugD8h0sdnm/1RPpxl1mRLbSGcZeP7ykI4weiKltf+hMJoAEgZD f89TP/aqNQ8BXXf0HPxYG47ycZ4Wzi/3/uHb1tC7pc6qbi9sSB4A3I+lkGwzNjPZXNiT UHyPXEOTAsJLPUfUv14JphjU76Ez8KjEQ7nuFtBlsazCYJdkulksFIgiJVbiskXTLd6M Ll2/urX+6GdPCbeXntvjsUvH6mMmcSWJFpOzxVnv8WlQz2I6KWtyYcXsMNzB/OkJxwBT reMhOiACumjNMW9SMZC2hdU216vUk46K4Cbn1XcpMCjdtb7te8ZN/XEvwoe9S1P7Idfw Nsig== 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 b42si2742836wrd.365.2018.04.10.16.47.13; Tue, 10 Apr 2018 16:47:14 -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 47D1368A18D; Wed, 11 Apr 2018 02:46:48 +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 3098168A08B for ; Wed, 11 Apr 2018 00:21:20 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 581AB9C354E for ; Tue, 10 Apr 2018 17:21:42 -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 VpN19JspUp48; Tue, 10 Apr 2018 17:21:41 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id D19E29C354F; Tue, 10 Apr 2018 17:21:41 -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 cktJ7MH-U_yp; Tue, 10 Apr 2018 17:21:41 -0400 (EDT) Received: from pkeroulas.mtl.sfl (unknown [192.168.50.171]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id AA20B9C3093; Tue, 10 Apr 2018 17:21:41 -0400 (EDT) From: Patrick Keroulas To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Apr 2018 17:21:35 -0400 Message-Id: <1523395297-13466-1-git-send-email-patrick.keroulas@savoirfairelinux.com> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Wed, 11 Apr 2018 02:46:45 +0300 Subject: [FFmpeg-devel] [PATCH v1 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;