From patchwork Tue Apr 24 18:54:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Keroulas X-Patchwork-Id: 8631 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp2179449jad; Tue, 24 Apr 2018 11:55:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx49RcVYDpavkHr6FGhZJTpNJfZ9+RwJTfLMlnwkkuQNq5vxOykmyGGrIUkEiNd83PLKR+VyP X-Received: by 2002:adf:9287:: with SMTP id 7-v6mr13136381wrn.67.1524596106078; Tue, 24 Apr 2018 11:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524596106; cv=none; d=google.com; s=arc-20160816; b=QA8Qvj9Yn1by8sQ1Z1gTENie8QWMRc6sBNfCgJg+qtwG5Hcdy/SNH+UEg2Ov1fVtOK 0WgB+CARIxs4KJX4rR3jHvq1jvOhwfu15g2C4pr2FgOgRvLyiwGZ9uNNaAiOaYfbcWWt tFySdFe5q7+IEDVwz4T7zI2PJlCPmgYr8ju5K9BionZl9JTw5wy5M8x048OxK+kagcvh muz9UZcgC8vVBdrCKL7VRk3DLq9xk5J1JtoIBG4+sJztqatRBvb7RsG5RVdKT44TX3WF 8j96s7eQ5MtGPRh2VNP8D+PO7wsU+aSfhzfrATpXUbFcXhKHESCeSQLE2YSn6TGsOoYf ahMg== 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=PlsT9ZWHoYTToojAYDRyetm2hATUPToHbPJjHuMg0lyza+UPDn/81dAMIYu+ArWEOB jJ8kXq19mK3WR16EpgoozwTbtlXASqursAvZxyNs80A7NGXvQ32oi4vaDZzg1uaAQRS6 0YDnB6kYNcOPIUxCx/VLf6EnKhx2IiaARdhEMbaZr+eDykdAYcfkNgNjOddjBuyzrVwg 0AkcVIiEhJ8Sf6XEMBQJekeVR/82FUKzsU18Hdf6aKtTwRGyuOeVf8GZ+4rHmTYUndjG m2IxWQoYTE0MOdktw84Dl5/0kfpHgrf75f7Vvug2U+DNYeqZ+NvAg85s4E9wrOBbqIM2 Bj+A== 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 t11-v6si11579433wri.124.2018.04.24.11.55.05; Tue, 24 Apr 2018 11:55:06 -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 673BA68A1D2; Tue, 24 Apr 2018 21:54:34 +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 2B2A1689957 for ; Tue, 24 Apr 2018 21:54:28 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 26AD99C3568 for ; Tue, 24 Apr 2018 14:54:56 -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 b6zPlfPEZt2w; Tue, 24 Apr 2018 14:54:55 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id BA87D9C3569; Tue, 24 Apr 2018 14:54:55 -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 26z0qL99eBBH; Tue, 24 Apr 2018 14:54:55 -0400 (EDT) Received: from pkeroulas.media.in.cbcsrc.ca (unknown [192.168.50.171]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 92D469C3568; Tue, 24 Apr 2018 14:54:55 -0400 (EDT) From: Patrick Keroulas To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Apr 2018 14:54:51 -0400 Message-Id: <1524596093-27630-1-git-send-email-patrick.keroulas@savoirfairelinux.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH v3 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;