summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGildas Fargeas <fargeas.gildas@gmail.com>2017-09-07 14:46:31 +0200
committerMarton Balint <cus@passwd.hu>2017-09-28 21:06:03 +0200
commitcb8b729180cc3ccb85f6c0d2fa7190865cbc2cb7 (patch)
treedebede8be361d5f89ea128c46cba74a432d494f1
parent00a61f30a05a76d10e04253987202e41f8703ebe (diff)
avdevice/decklink_dec: add support for more pixel formats
The decklink input pixel format can now be specified with the 'raw_format' option. The -bm_v210 option is now deprecated. Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r--doc/indevs.texi22
-rw-r--r--libavdevice/decklink_common.cpp2
-rw-r--r--libavdevice/decklink_common_c.h1
-rw-r--r--libavdevice/decklink_dec.cpp46
-rw-r--r--libavdevice/decklink_dec_c.c6
-rw-r--r--libavdevice/version.h2
6 files changed, 68 insertions, 11 deletions
diff --git a/doc/indevs.texi b/doc/indevs.texi
index 776e563160..c6f96c41ea 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -214,8 +214,9 @@ need to configure with the appropriate @code{--extra-cflags}
and @code{--extra-ldflags}.
On Windows, you need to run the IDL files through @command{widl}.
-DeckLink is very picky about the formats it supports. Pixel format is
-uyvy422 or v210, framerate and video size must be determined for your device with
+DeckLink is very picky about the formats it supports. Pixel format of the
+input can be set with @option{raw_format}.
+Framerate and video size must be determined for your device with
@command{-list_formats 1}. Audio sample rate is always 48 kHz and the number
of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single
audio track.
@@ -239,9 +240,26 @@ Note that there is a FourCC @option{'pal '} that can also be used
as @option{pal} (3 letters).
@item bm_v210
+This is a deprecated option, you can use @option{raw_format} instead.
If set to @samp{1}, video is captured in 10 bit v210 instead
of uyvy422. Not all Blackmagic devices support this option.
+@item raw_format
+Set the pixel format of the captured video.
+Available values are:
+@table @samp
+@item uyvy422
+
+@item yuv422p10
+
+@item argb
+
+@item bgra
+
+@item rgb10
+
+@end table
+
@item teletext_lines
If set to nonzero, an additional teletext stream will be captured from the
vertical ancillary data. Both SD PAL (576i) and HD (1080i or 1080p)
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..c93ca68b80 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,42 @@ 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;
+ st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
+ 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;
+ st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
+ 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->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 30, st->time_base.den, st->time_base.num);
+ 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 +808,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..8b6ff067bc 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"},
+ { "rgb10", 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 da43e55c32..3fbd273fc3 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -29,7 +29,7 @@
#define LIBAVDEVICE_VERSION_MAJOR 57
#define LIBAVDEVICE_VERSION_MINOR 9
-#define LIBAVDEVICE_VERSION_MICRO 100
+#define LIBAVDEVICE_VERSION_MICRO 101
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
LIBAVDEVICE_VERSION_MINOR, \