History

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.

Gildas Fargeas committed 9 years ago

Commit cb8b7291 parent 00a61f36 files · +68 −11Browse files

Unified · Split

6 files
  1. doc/indevs.texi +20 −2
  2. libavdevice/decklink_common.cpp +1 −1
  3. libavdevice/decklink_common_c.h +1 −0
  4. libavdevice/decklink_dec.cpp +39 −7
  5. libavdevice/decklink_dec_c.c +6 −0
  6. libavdevice/version.h +1 −1
doc/indevs.texi+20−2
@@ -214,8 +214,9 @@ need to configure with the appropriate @code{--extra-cflags} · 213 unmodified lines
214214 and @code{--extra-ldflags}.
215215 On Windows, you need to run the IDL files through @command{widl}.
216216
217−DeckLink is very picky about the formats it supports. Pixel format is
218−uyvy422 or v210, framerate and video size must be determined for your device with
217+DeckLink is very picky about the formats it supports. Pixel format of the
218+input can be set with @option{raw_format}.
219+Framerate and video size must be determined for your device with
219220 @command{-list_formats 1}. Audio sample rate is always 48 kHz and the number
220221 of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single
221222 audio track.
@@ -239,9 +240,26 @@ Note that there is a FourCC @option{'pal '} that can also be used · 17 unmodified lines
239240 as @option{pal} (3 letters).
240241
241242 @item bm_v210
243+This is a deprecated option, you can use @option{raw_format} instead.
242244 If set to @samp{1}, video is captured in 10 bit v210 instead
243245 of uyvy422. Not all Blackmagic devices support this option.
244246
247+@item raw_format
248+Set the pixel format of the captured video.
249+Available values are:
250+@table @samp
251+@item uyvy422
252+
253+@item yuv422p10
254+
255+@item argb
256+
257+@item bgra
258+
259+@item rgb10
260+
261+@end table
262+
245263 @item teletext_lines
246264 If set to nonzero, an additional teletext stream will be captured from the
247265 vertical ancillary data. Both SD PAL (576i) and HD (1080i or 1080p)
libavdevice/decklink_common.cpp+1−1
@@ -241,7 +241,7 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 240 unmodified lines
241241 if (ctx->bmd_mode == bmdModeUnknown)
242242 return -1;
243243 if (direction == DIRECTION_IN) {
244− if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV,
244+ if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, (BMDPixelFormat) cctx->raw_format,
245245 bmdVideoOutputFlagDefault,
246246 &support, NULL) != S_OK)
247247 return -1;
libavdevice/decklink_common_c.h+1−0
@@ -49,6 +49,7 @@ struct decklink_cctx { · 48 unmodified lines
4949 int video_input;
5050 int draw_bars;
5151 char *format_code;
52+ int raw_format;
5253 int64_t queue_size;
5354 };
5455
libavdevice/decklink_dec.cpp+39−7
@@ -651,6 +651,11 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 650 unmodified lines
651651 return AVERROR_EXIT;
652652 }
653653
654+ if (cctx->v210) {
655+ av_log(avctx, AV_LOG_WARNING, "The bm_v210 option is deprecated and will be removed. Please use the -raw_format yuv422p10.\n");
656+ cctx->raw_format = MKBETAG('v','2','1','0');
657+ }
658+
654659 strcpy (fname, avctx->filename);
655660 tmp=strchr (fname, '@');
656661 if (tmp != NULL) {
@@ -723,15 +728,42 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 66 unmodified lines
723728 st->time_base.num = ctx->bmd_tb_num;
724729 av_stream_set_r_frame_rate(st, av_make_q(st->time_base.den, st->time_base.num));
725730
726− if (cctx->v210) {
727− st->codecpar->codec_id = AV_CODEC_ID_V210;
728− st->codecpar->codec_tag = MKTAG('V', '2', '1', '0');
729− st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
730− } else {
731+ switch((BMDPixelFormat)cctx->raw_format) {
732+ case bmdFormat8BitYUV:
731733 st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
732− st->codecpar->format = AV_PIX_FMT_UYVY422;
733734 st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y');
735+ st->codecpar->format = AV_PIX_FMT_UYVY422;
734736 st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 16, st->time_base.den, st->time_base.num);
737+ break;
738+ case bmdFormat10BitYUV:
739+ st->codecpar->codec_id = AV_CODEC_ID_V210;
740+ st->codecpar->codec_tag = MKTAG('V','2','1','0');
741+ st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
742+ st->codecpar->bits_per_coded_sample = 10;
743+ break;
744+ case bmdFormat8BitARGB:
745+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
746+ st->codecpar->codec_tag = avcodec_pix_fmt_to_codec_tag((enum AVPixelFormat)st->codecpar->format);;
747+ st->codecpar->format = AV_PIX_FMT_ARGB;
748+ st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
749+ break;
750+ case bmdFormat8BitBGRA:
751+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
752+ st->codecpar->codec_tag = avcodec_pix_fmt_to_codec_tag((enum AVPixelFormat)st->codecpar->format);
753+ st->codecpar->format = AV_PIX_FMT_BGRA;
754+ st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
755+ break;
756+ case bmdFormat10BitRGB:
757+ st->codecpar->codec_id = AV_CODEC_ID_R210;
758+ st->codecpar->codec_tag = MKTAG('R','2','1','0');
759+ st->codecpar->format = AV_PIX_FMT_RGB48LE;
760+ st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 30, st->time_base.den, st->time_base.num);
761+ st->codecpar->bits_per_coded_sample = 10;
762+ break;
763+ default:
764+ av_log(avctx, AV_LOG_ERROR, "Raw Format %.4s not supported\n", (char*) &cctx->raw_format);
765+ ret = AVERROR(EINVAL);
766+ goto error;
735767 }
736768
737769 switch (ctx->bmd_field_dominance) {
@@ -776,7 +808,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 38 unmodified lines
776808 }
777809
778810 result = ctx->dli->EnableVideoInput(ctx->bmd_mode,
779− cctx->v210 ? bmdFormat10BitYUV : bmdFormat8BitYUV,
811+ (BMDPixelFormat) cctx->raw_format,
780812 bmdVideoInputFlagDefault);
781813
782814 if (result != S_OK) {
libavdevice/decklink_dec_c.c+6−0
@@ -34,6 +34,12 @@ static const AVOption options[] = { · 33 unmodified lines
3434 { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
3535 { "format_code", "set format by fourcc" , OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },
3636 { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
37+ { "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" },
38+ { "uyvy422", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('2','v','u','y') }, 0, 0, DEC, "raw_format"},
39+ { "yuv422p10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('v','2','1','0') }, 0, 0, DEC, "raw_format"},
40+ { "argb", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 32 }, 0, 0, DEC, "raw_format"},
41+ { "bgra", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('B','G','R','A') }, 0, 0, DEC, "raw_format"},
42+ { "rgb10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MKBETAG('r','2','1','0') }, 0, 0, DEC, "raw_format"},
3743 { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},
3844 { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},
3945 { "all", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7ffffffffLL}, 0, 0, DEC, "teletext_lines"},
libavdevice/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929
3030 #define LIBAVDEVICE_VERSION_MAJOR 57
3131 #define LIBAVDEVICE_VERSION_MINOR 9
32−#define LIBAVDEVICE_VERSION_MICRO 100
32+#define LIBAVDEVICE_VERSION_MICRO 101
3333
3434 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
3535 LIBAVDEVICE_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t