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
214and @code{--extra-ldflags}.214and @code{--extra-ldflags}.
215On Windows, you need to run the IDL files through @command{widl}.215On Windows, you need to run the IDL files through @command{widl}.
216 216
217DeckLink is very picky about the formats it supports. Pixel format is217DeckLink is very picky about the formats it supports. Pixel format of the
218uyvy422 or v210, framerate and video size must be determined for your device with218input can be set with @option{raw_format}.
219Framerate and video size must be determined for your device with
219@command{-list_formats 1}. Audio sample rate is always 48 kHz and the number220@command{-list_formats 1}. Audio sample rate is always 48 kHz and the number
220of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single221of channels can be 2, 8 or 16. Note that all audio channels are bundled in one single
221audio track.222audio track.
@@ -239,9 +240,26 @@ Note that there is a FourCC @option{'pal '} that can also be used · 17 unmodified lines
239as @option{pal} (3 letters).240as @option{pal} (3 letters).
240 241
241@item bm_v210242@item bm_v210
243This is a deprecated option, you can use @option{raw_format} instead.
242If set to @samp{1}, video is captured in 10 bit v210 instead244If set to @samp{1}, video is captured in 10 bit v210 instead
243of uyvy422. Not all Blackmagic devices support this option.245of uyvy422. Not all Blackmagic devices support this option.
244 246
247@item raw_format
248Set the pixel format of the captured video.
249Available 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
245@item teletext_lines263@item teletext_lines
246If set to nonzero, an additional teletext stream will be captured from the264If set to nonzero, an additional teletext stream will be captured from the
247vertical ancillary data. Both SD PAL (576i) and HD (1080i or 1080p)265vertical 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
241 if (ctx->bmd_mode == bmdModeUnknown)241 if (ctx->bmd_mode == bmdModeUnknown)
242 return -1;242 return -1;
243 if (direction == DIRECTION_IN) {243 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,
245 bmdVideoOutputFlagDefault,245 bmdVideoOutputFlagDefault,
246 &support, NULL) != S_OK)246 &support, NULL) != S_OK)
247 return -1;247 return -1;
libavdevice/decklink_common_c.h+1−0
@@ -49,6 +49,7 @@ struct decklink_cctx { · 48 unmodified lines
49 int video_input;49 int video_input;
50 int draw_bars;50 int draw_bars;
51 char *format_code;51 char *format_code;
52 int raw_format;
52 int64_t queue_size;53 int64_t queue_size;
53};54};
54 55
libavdevice/decklink_dec.cpp+39−7
@@ -651,6 +651,11 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 650 unmodified lines
651 return AVERROR_EXIT;651 return AVERROR_EXIT;
652 }652 }
653 653
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
654 strcpy (fname, avctx->filename);659 strcpy (fname, avctx->filename);
655 tmp=strchr (fname, '@');660 tmp=strchr (fname, '@');
656 if (tmp != NULL) {661 if (tmp != NULL) {
@@ -723,15 +728,42 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 66 unmodified lines
723 st->time_base.num = ctx->bmd_tb_num;728 st->time_base.num = ctx->bmd_tb_num;
724 av_stream_set_r_frame_rate(st, av_make_q(st->time_base.den, st->time_base.num));729 av_stream_set_r_frame_rate(st, av_make_q(st->time_base.den, st->time_base.num));
725 730
726 if (cctx->v210) {731 switch((BMDPixelFormat)cctx->raw_format) {
727 st->codecpar->codec_id = AV_CODEC_ID_V210;732 case bmdFormat8BitYUV:
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 st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;733 st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
732 st->codecpar->format = AV_PIX_FMT_UYVY422;
733 st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y');734 st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y');
735 st->codecpar->format = AV_PIX_FMT_UYVY422;
734 st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 16, st->time_base.den, st->time_base.num);736 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;
735 }767 }
736 768
737 switch (ctx->bmd_field_dominance) {769 switch (ctx->bmd_field_dominance) {
@@ -776,7 +808,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 38 unmodified lines
776 }808 }
777 809
778 result = ctx->dli->EnableVideoInput(ctx->bmd_mode,810 result = ctx->dli->EnableVideoInput(ctx->bmd_mode,
779 cctx->v210 ? bmdFormat10BitYUV : bmdFormat8BitYUV,811 (BMDPixelFormat) cctx->raw_format,
780 bmdVideoInputFlagDefault);812 bmdVideoInputFlagDefault);
781 813
782 if (result != S_OK) {814 if (result != S_OK) {
libavdevice/decklink_dec_c.c+6−0
@@ -34,6 +34,12 @@ static const AVOption options[] = { · 33 unmodified lines
34 { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },34 { "list_formats", "list supported formats" , OFFSET(list_formats), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },
35 { "format_code", "set format by fourcc" , OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },35 { "format_code", "set format by fourcc" , OFFSET(format_code), AV_OPT_TYPE_STRING, { .str = NULL}, 0, 0, DEC },
36 { "bm_v210", "v210 10 bit per channel" , OFFSET(v210), AV_OPT_TYPE_INT , { .i64 = 0 }, 0, 1, DEC },36 { "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"},
37 { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},43 { "teletext_lines", "teletext lines bitmask", OFFSET(teletext_lines), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, 0x7ffffffffLL, DEC, "teletext_lines"},
38 { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},44 { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},
39 { "all", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7ffffffffLL}, 0, 0, DEC, "teletext_lines"},45 { "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
29 29
30#define LIBAVDEVICE_VERSION_MAJOR 5730#define LIBAVDEVICE_VERSION_MAJOR 57
31#define LIBAVDEVICE_VERSION_MINOR 931#define LIBAVDEVICE_VERSION_MINOR 9
32#define LIBAVDEVICE_VERSION_MICRO 10032#define LIBAVDEVICE_VERSION_MICRO 101
33 33
34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
35 LIBAVDEVICE_VERSION_MINOR, \35 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