From patchwork Wed Oct 26 19:40:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 1192 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp220220vsd; Wed, 26 Oct 2016 12:52:22 -0700 (PDT) X-Received: by 10.28.43.199 with SMTP id r190mr9532029wmr.58.1477511542884; Wed, 26 Oct 2016 12:52:22 -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 s186si12397518wmf.124.2016.10.26.12.52.22; Wed, 26 Oct 2016 12:52:22 -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=@overt.org; dkim=neutral (body hash did not verify) header.i=@overt.org; 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 018D4689E85; Wed, 26 Oct 2016 22:51:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from rs224.mailgun.us (rs224.mailgun.us [209.61.151.224]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38F37689E6A for ; Wed, 26 Oct 2016 22:51:42 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1477511505; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=e6nsRkaQeBMxAidixflWcIIFFQmSDrarH2SvQDpH0Ts=; b=im8FDnllBHWpVr5ydBPibi7vvVYmij2vZm5/fLkU3SKd8eTpHb4W/Ixn54npOV8BHi/ATTeI gOF5x/kBrDXa4z8uxLhX1L/xDcdEO3rt4iRG02dqPsAsPdhsZ6+R0g7t//ds8TzNynPCEEo/ KpN/mUgiNKHvEwrz7dzkJiaHpS4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=overt.org; s=k1; q=dns; h=Sender: From: To: Cc: Subject: Date: Message-Id: In-Reply-To: References; b=U9rXg+CBbPAa5QqFfQ6sHkTZkuX60XmZGv90m+ySADg0cz6DI4j5xtTaVRjJ1laBTOxBhK vdWmcZ/lRNeWgamzlM5li0Y5sm/befG2qSLcKh1Ccxyj/cseV5Vd8zD/jA24F+sDp0VQkkrk BQQnO/+Pxmqkh8WhC3RNiuzxNmcJs= X-Mailgun-Sending-Ip: 209.61.151.224 X-Mailgun-Sid: WyIyM2Q3MCIsICJmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZyIsICI0YTg5NjEiXQ== Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com [107.178.208.155]) by mxa.mailgun.org with ESMTP id 581106b2.7f518b047340-in3; Wed, 26 Oct 2016 19:40:34 -0000 (UTC) Received: from authenticated-user (mail.overt.org [107.178.208.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 10315600D1; Wed, 26 Oct 2016 19:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1477510834; bh=FjvgsY8o7eYLKfyR2b5yVWP2r6cVjEcGdxV+Uqg87XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fg22gL7KMnUOkfQARaE25bQy5PEMra+TnUgNOr8WpqtvAZLuFBBln5XByCUH3bOfM xB35HoZiKg1T/IaWtLXSaXYqGTXNASaCcKNhwub0SCO7weFBys91/6D9pvTfu6+pIf hhRhVgR0xfkHtVLX/jgLgY+7EBMDFEImd5BtYt1R/2yAwrNtUw4DHtbRdCPHN18Y22 DQxgpfOxlQOX3hnSI/vS1AZl63fIntBvwgQ5L1uAlEcZQwUnwuDLDRkbXmBW+Ohejh l80qBUZKj8UnTVAS6xkngfmJu1l+G8/GeKM4OWADQhoGkAYk2FH146h7X2Kz102c5o Ft2L9rlAVGZrw== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Oct 2016 12:40:19 -0700 Message-Id: <20161026194028.26438-2-philipl@overt.org> In-Reply-To: <20161026194028.26438-1-philipl@overt.org> References: <20161026194028.26438-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 01/10] crystalhd: Fix up the missing first sample 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: Philip Langdale MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Why on earth the hardware returns garbage for the first sample of a decoded picture is anyone's guess. The simplest reasonable way to patch it up is to copy the first sample of the second line. This should result in the correct chroma values (because the data was original 4:2:0 upsampled to 4:2:2) even if the luma is isn't. Signed-off-by: Philip Langdale --- libavcodec/crystalhd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index 9120940..137ed20 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -706,6 +706,15 @@ static inline CopyRet copy_frame(AVCodecContext *avctx, av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n"); + /* + * The hardware doesn't return the first sample of a picture. + * Ignoring why it behaves this way, it's better to copy the sample from + * the second line, rather than the next sample across because the chroma + * values should be correct (assuming the decoded video was 4:2:0, which + * it was). + */ + *((uint32_t *)src) = *((uint32_t *)(src + sStride)); + if (interlaced) { int dY = 0; int sY = 0;