From patchwork Wed Sep 6 12:42:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gildas Fargeas X-Patchwork-Id: 5011 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp561713jao; Wed, 6 Sep 2017 05:42:57 -0700 (PDT) X-Google-Smtp-Source: ADKCNb66t9adK2ax1XCoVrjwWJmiy94YdUisLxhz5q1Tn948QTQg3NogvfXQlMo2mBz2Wu6jAfeP X-Received: by 10.223.131.66 with SMTP id 60mr1515832wrd.171.1504701777237; Wed, 06 Sep 2017 05:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504701777; cv=none; d=google.com; s=arc-20160816; b=u9jI0RQpTKBlhp2crf4C2CPbOwVM34yaZUJkrWbsCcLjPTU8OoybTW0Cc/QPDG/Kw+ ijAHryc15/+JGUTPasm1aOKHqVMBVlixOVt0OLQ0SsXmuA6Ee5R5cpX5b6NeAKgdZLQD i82fu004EO+N33LNurarv6vr1/lC9uWGtikdwdT2oNAccxVomtzm4rz20DRpfyTlxuES y5AhgKNHP/nI+gACkyk8T6HMtSGLjeDoKLmoVXIRIwu5feiS6MhjAZMPcD8VGYTL5IK+ G7Cs9iw/wgTt0CWZkkaLHHlc+6Nh1tkp5BCmyG41rU2PK/+SbwYqY3rP5If6lz0CJagE O8XA== 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=cWoewaiwfZONKs/yPGF3aYMZsgzt+sr8CWwV5PyAN/U=; b=Pw9gslNnf4f16aejOiEkOBruPlj7irDMYAz1vTPXzmdF5VfbaTr+IQQpi0WlN4N0nD zmrEzl7T/mMlno2Y5Kq2A1sFifW+a/Ht0aRUFUeTe2gQd7W4neiBBstOTMprJhWPJqZZ SLIJbJXs8+zcq9zRSHmonY0WTPuOZJTlMgk6MQ4to6aXukb6fqDtq4EnnzO47ILNOMmS Gy54Q10F0Tz5FUiIjhHrKdOkrZmSd1h9tJg3966Le9kicKuCX+bJ79p2FRaU52y7mVEs 78xy1Cpqp6oUISCkHy3BEmauJ+OEyUUnTMCDXei71WtcpbnS1lCNhG7Ha4yovhxOnHdc VA5A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q127si1147768wmd.25.2017.09.06.05.42.56; Wed, 06 Sep 2017 05:42:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D192568A360; Wed, 6 Sep 2017 15:42:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.nerd.lan (unknown [185.84.18.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4D704689B7F for ; Wed, 6 Sep 2017 15:42:45 +0300 (EEST) Received: from WKS-41L8CC2-LN.nerd.lan (wks-41l8cc2-ln.nerd.lan [10.100.1.3]) by mail.nerd.lan (Postfix) with ESMTP id 65E63180608; Wed, 6 Sep 2017 14:42:47 +0200 (CEST) From: Gildas Fargeas To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Sep 2017 14:42:42 +0200 Message-Id: <20170906124242.8759-1-fargeas.gildas@gmail.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] avdevice/decklink: new options 'list_pixelformats' and 'pixelformat_code' to allow pixelformat selection by code 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: Gildas Fargeas MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Alright, this should do the trick: - use named const for raw_format option - deprecate bm_v210 - bumped avdevice micro version --- libavdevice/decklink_common.cpp | 2 +- libavdevice/decklink_common_c.h | 1 + libavdevice/decklink_dec.cpp | 43 ++++++++++++++++++++++++++++++++++------- libavdevice/decklink_dec_c.c | 6 ++++++ libavdevice/version.h | 2 +- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index cbb591ce64..ff2df95909 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -241,7 +241,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, if (ctx->bmd_mode == bmdModeUnknown) return -1; if (direction == DIRECTION_IN) { - if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV, + if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format, bmdVideoOutputFlagDefault, &support, NULL) != S_OK) return -1; diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index e263480474..5616ab32f9 100644 --- a/libavdevice/decklink_common_c.h +++ b/libavdevice/decklink_common_c.h @@ -49,6 +49,7 @@ struct decklink_cctx { int video_input; int draw_bars; char *format_code; + int raw_format; int64_t queue_size; }; diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index c271ff3639..ccbb6f09f5 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -651,6 +651,11 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) return AVERROR_EXIT; } + if (cctx->v210) { + av_log(avctx, AV_LOG_WARNING, "The bm_v210 option is deprecated and will be removed. Please use the -raw_format yuv422p10.\n"); + cctx->raw_format = MKBETAG('v','2','1','0'); + } + strcpy (fname, avctx->filename); tmp=strchr (fname, '@'); if (tmp != NULL) { @@ -723,15 +728,39 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) st->time_base.num = ctx->bmd_tb_num; av_stream_set_r_frame_rate(st, av_make_q(st->time_base.den, st->time_base.num)); - if (cctx->v210) { - st->codecpar->codec_id = AV_CODEC_ID_V210; - st->codecpar->codec_tag = MKTAG('V', '2', '1', '0'); - st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3); - } else { + switch((BMDPixelFormat)cctx->raw_format) { + case bmdFormat8BitYUV: st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; - st->codecpar->format = AV_PIX_FMT_UYVY422; st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y'); + st->codecpar->format = AV_PIX_FMT_UYVY422; st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 16, st->time_base.den, st->time_base.num); + break; + case bmdFormat10BitYUV: + st->codecpar->codec_id = AV_CODEC_ID_V210; + st->codecpar->codec_tag = MKTAG('V','2','1','0'); + st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3); + st->codecpar->bits_per_coded_sample = 10; + break; + case bmdFormat8BitARGB: + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->codec_tag = avcodec_pix_fmt_to_codec_tag((enum AVPixelFormat)st->codecpar->format);; + st->codecpar->format = AV_PIX_FMT_ARGB; + break; + case bmdFormat8BitBGRA: + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->codec_tag = avcodec_pix_fmt_to_codec_tag((enum AVPixelFormat)st->codecpar->format); + st->codecpar->format = AV_PIX_FMT_BGRA; + break; + case bmdFormat10BitRGB: + st->codecpar->codec_id = AV_CODEC_ID_R210; + st->codecpar->codec_tag = MKTAG('R','2','1','0'); + st->codecpar->format = AV_PIX_FMT_RGB48LE; + st->codecpar->bits_per_coded_sample = 10; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Raw Format %.4s not supported\n", (char*) &cctx->raw_format); + ret = AVERROR(EINVAL); + goto error; } switch (ctx->bmd_field_dominance) { @@ -776,7 +805,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) } result = ctx->dli->EnableVideoInput(ctx->bmd_mode, - cctx->v210 ? bmdFormat10BitYUV : bmdFormat8BitYUV, + (BMDPixelFormat) cctx->raw_format, bmdVideoInputFlagDefault); if (result != S_OK) { diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c index e2118a619c..464cf760d2 100644 --- a/libavdevice/decklink_dec_c.c +++ b/libavdevice/decklink_dec_c.c @@ -34,6 +34,12 @@ static const AVOption options[] = { { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, { "format_code", "set format by fourcc" , OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC }, { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC }, + { "raw_format", "pixel format to be returned by the card when capturing" , OFFSET(raw_format), AV_OPT_TYPE_INT, { .i64 = MKBETAG('2','v','u','y')}, 0, UINT_MAX, DEC, "raw_format" }, + { "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('2','v','u','y') }, 0, 0, DEC, "raw_format"}, + { "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('v','2','1','0') }, 0, 0, DEC, "raw_format"}, + { "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 32 }, 0, 0, DEC, "raw_format"}, + { "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('B','G','R','A') }, 0, 0, DEC, "raw_format"}, + { "rgb48", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('r','2','1','0') }, 0, 0, DEC, "raw_format"}, { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"}, { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"}, { "all", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7ffffffffLL}, 0, 0, DEC, "teletext_lines"}, diff --git a/libavdevice/version.h b/libavdevice/version.h index 948e4e1e08..358b6ff969 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -29,7 +29,7 @@ #define LIBAVDEVICE_VERSION_MAJOR 57 #define LIBAVDEVICE_VERSION_MINOR 8 -#define LIBAVDEVICE_VERSION_MICRO 100 +#define LIBAVDEVICE_VERSION_MICRO 101 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \