From patchwork Thu Aug 31 08:36:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jeyapal, Karthick" X-Patchwork-Id: 4918 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp1373807jao; Thu, 31 Aug 2017 01:37:21 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4JrJxiGAIQEJTYkZqBsjA/N5wGyLi6tu0viOR/aQ9u+9ShzNOEyfEgJt1Wj9rSEw5Safw/ X-Received: by 10.28.32.14 with SMTP id g14mr6614wmg.24.1504168641846; Thu, 31 Aug 2017 01:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504168641; cv=none; d=google.com; s=arc-20160816; b=cVOtaI95kfKK1UWqlWLwiznDrkBT8HIZKpE5v5zBBW8mZyAmKvty4M3k+spXgThFLk ppolmW21R53tgHnTsrUxTfx8/jmLD0T4VMyZ4jxZ2bVGIkDu4l7rRNol0sjh6V8pKFbf QjEYsl7XBLcgJ3qobGa46rqXf85EASI+PtD5Rwpe6wqSO1DR7Rc2wb4IP6Qtjl1K2cKr H/goix837hgjz7LcTkvk+CJcO9x6nWE9al81Z0BxPgqEM+DqvW1QU0wdA3AT+1uopYpO jMeXtitY2sLQ8NUj1fJfogIMY4RL4/Lf9Wj7VWAGWs+XGcCceELXqob/8UxkN0BRvrdx tNIg== 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:feedback-id:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=8AEkew8IsEYoC0+Cap6M/CUB09WFLQ4/bT8HlOp6bH0=; b=OAXtJC2/2KO4GR9lnKkLzqc1PNQ7UU4n+SzI66hPqr6DxWbebDSzL3TeYnOv/WXSkf L68r/qgKdjXYuC4ZuPc5PhHcsW7CNaYwVLIDRt+n328gKKAzD1fEO8UGqxOt+9GrGqYs 24BqaP6bjs7WuezkeJWh0t1hoRnLgCnHQeD+T5Snre+wUGJ8BEk2nFgXI1ENpU2BXYWZ kVlaz3lfFjzfa+gxKQI0S8De8SKDQDDpcwn1UyqrAr1u8uTossHitt7DumgUvO690aCw U1zdTFMExPmyd+zTxZGrDfSDzAxdjp6Fu5S59wJ6k+EXTT3cCjtKF4X2WOJpAiDkxDQC 53Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=MD4HOK/I; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z44si1413196wrz.15.2017.08.31.01.37.21; Thu, 31 Aug 2017 01:37:21 -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=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=MD4HOK/I; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C40768A1CD; Thu, 31 Aug 2017 11:37:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a1i844.smtp2go.com (a1i844.smtp2go.com [43.228.187.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EEC52689E33 for ; Thu, 31 Aug 2017 11:37:04 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1504190226; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=+cvEdHYSjmHu7JMHH40e9nNhi06W10quOvBwcj6YPyU=; b=MD4HOK/I Fw8guty45/LNYeylASABCc5DK8TP8tZ8/P1nID3pIqLBCujy1WKld4EPIbiX1no/u7RFaQNUCmMKq 2ofVQ89s7ZmEyZH5kRIKWoZEBrhZLJWIAHgWdjvQ3JEYZ6jgC1fZEjlEhkOkngmltl1+B5eRGU6wh Yy6HNrMFzJR5Tob4PYZVBoeuOobvriLoS8I+ZUMMk+52H2ZkjWhyfYLiIcysrnhUxxEZuzDcMIyuc hpPsW5YzRVnQJxlQu94NnOQSRifRSVUAT/CZobXro3wWakg1QZfTf210oQNpltFxsZ58l4dSIQVuJ RoVMZv4zhunQIKZB0EYN1anZrA==; From: kjeyapal@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 Aug 2017 14:06:47 +0530 Message-Id: <1504168610-2427-1-git-send-email-kjeyapal@akamai.com> X-Mailer: git-send-email 1.9.1 X-Smtpcorp-Track: 1dnKyURyIeo_Nf.p4qqKrn7n Feedback-ID: 337386m:337386asVRLGB:337386sMsGg9Kj0o:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH 1/4] avdevice/decklink_dec: Added VANC search for all resolutions 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: Karthick J MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Karthick J In preparation to make VANC decode modular, to support multiple other VANC data. Signed-off-by: Karthick J --- libavdevice/decklink_dec.cpp | 86 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 10 deletions(-) diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index c271ff3..40ef655 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -46,6 +46,66 @@ extern "C" { #include "decklink_common.h" #include "decklink_dec.h" +/* These VANC line numbers need not be very accurate. In any case + * GetBufferForVerticalBlankingLine() will return an error when invalid + * ancillary line number was requested. We just need to make sure that the + * entire VANC region is covered */ +static int get_vanc_lines_progressive (int height) +{ + switch (height) { + case 486: + return 39; + case 576: + return 45; + case 720: + return 30; + case 1080: + return 45; + default: + return 0; + } +} + +static void get_vanc_lines_interlaced (int height, int *field0_vanc_end, + int *field1_vanc_start, int *field1_vanc_end) +{ + switch (height) { + // NTSC + case 486: + *field0_vanc_end = 19; + *field1_vanc_start = *field0_vanc_end + 243; + *field1_vanc_end = *field1_vanc_start + 20; + break; + // PAL + case 576: + *field0_vanc_end = 22; + *field1_vanc_start = *field0_vanc_end + 288 + 2; + *field1_vanc_end = *field1_vanc_start + 23; + break; + // 1080i + case 1080: + *field0_vanc_end = 20; + *field1_vanc_start = *field0_vanc_end + 540 + 2; + *field1_vanc_end = *field1_vanc_start + 21; + break; + default: + *field0_vanc_end = *field1_vanc_start = *field1_vanc_end = 0; + } +} + +static void get_vanc_lines(int bmd_field_dominance, int height, int *field0_vanc_end, + int *field1_vanc_start, int *vanc_end) +{ + if (bmd_field_dominance == bmdLowerFieldFirst || bmd_field_dominance == bmdUpperFieldFirst) { + get_vanc_lines_interlaced (height, field0_vanc_end, field1_vanc_start, vanc_end); + } else if (bmd_field_dominance == bmdProgressiveFrame) { + *vanc_end = get_vanc_lines_progressive(height); + *field0_vanc_end = *field1_vanc_start = -1; + } else { + *field0_vanc_end = *field1_vanc_start = *vanc_end = 0; + } +} + static uint8_t calc_parity_and_line_offset(int line) { uint8_t ret = (line < 313) << 5; @@ -502,18 +562,24 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( } } #endif - if (videoFrame->GetWidth() == 1920 && vanc_format == bmdFormat10BitYUV) { - int first_active_line = ctx->bmd_field_dominance == bmdProgressiveFrame ? 42 : 584; - for (i = 8; i < first_active_line; i++) { + if (vanc_format == bmdFormat10BitYUV) { + int bmd_field_dominance, height; + int field0_vanc_end, field1_vanc_start, vanc_end; + get_vanc_lines(ctx->bmd_field_dominance, videoFrame->GetHeight(), + &field0_vanc_end, &field1_vanc_start, &vanc_end); + for (i = 0; i <= vanc_end; i++) { uint8_t *buf; - if (vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) - txt_buf = teletext_data_unit_from_vanc_data(buf, txt_buf, ctx->teletext_lines); - if (ctx->bmd_field_dominance != bmdProgressiveFrame && i == 20) // skip field1 active lines - i = 569; - if (txt_buf - txt_buf0 > 1611) { // ensure we still have at least 1920 bytes free in the buffer - av_log(avctx, AV_LOG_ERROR, "Too many OP47 teletext packets.\n"); - break; + if (vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) { + if (videoFrame->GetWidth() == 1920) { + txt_buf = teletext_data_unit_from_vanc_data(buf, txt_buf, ctx->teletext_lines); + if (txt_buf - txt_buf0 > 1611) { // ensure we still have at least 1920 bytes free in the buffer + av_log(avctx, AV_LOG_ERROR, "Too many OP47 teletext packets.\n"); + break; + } + } } + if (i == field0_vanc_end) + i = field1_vanc_start; } } vanc->Release();