2014-09-22 00:46:03 +00:00
/*
2016-08-02 19:39:22 +00:00
* Blackmagic DeckLink input
2014-09-22 00:46:03 +00:00
* Copyright ( c ) 2014 Deti Fliegl
2017-08-10 06:29:30 +00:00
* Copyright ( c ) 2017 Akamai Technologies , Inc .
2014-09-22 00:46:03 +00:00
*
* This file is part of FFmpeg .
*
* FFmpeg is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ; either
* version 2.1 of the License , or ( at your option ) any later version .
*
* FFmpeg is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
*/
# include "libavformat/avformat.h"
# include "libavutil/opt.h"
# include "decklink_common_c.h"
# include "decklink_dec.h"
# define OFFSET(x) offsetof(struct decklink_cctx, x)
# define DEC AV_OPT_FLAG_DECODING_PARAM
static const AVOption options [ ] = {
{ " list_devices " , " list available devices " , OFFSET ( list_devices ) , AV_OPT_TYPE_INT , { . i64 = 0 } , 0 , 1 , DEC } ,
{ " list_formats " , " list supported formats " , OFFSET ( list_formats ) , AV_OPT_TYPE_INT , { . i64 = 0 } , 0 , 1 , DEC } ,
2017-03-19 23:16:37 +00:00
{ " format_code " , " set format by fourcc " , OFFSET ( format_code ) , AV_OPT_TYPE_STRING , { . str = NULL } , 0 , 0 , DEC } ,
2015-01-18 19:44:33 +00:00
{ " bm_v210 " , " v210 10 bit per channel " , OFFSET ( v210 ) , AV_OPT_TYPE_INT , { . i64 = 0 } , 0 , 1 , DEC } ,
2017-09-07 12:46:31 +00:00
{ " 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 " } ,
2016-01-12 02:09:37 +00:00
{ " 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 " } ,
2015-12-20 11:57:32 +00:00
{ " channels " , " number of audio channels " , OFFSET ( audio_channels ) , AV_OPT_TYPE_INT , { . i64 = 2 } , 2 , 16 , DEC } ,
2016-06-11 11:41:29 +00:00
{ " duplex_mode " , " duplex mode " , OFFSET ( duplex_mode ) , AV_OPT_TYPE_INT , { . i64 = 0 } , 0 , 2 , DEC , " duplex_mode " } ,
{ " unset " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 0 } , 0 , 0 , DEC , " duplex_mode " } ,
{ " half " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 1 } , 0 , 0 , DEC , " duplex_mode " } ,
{ " full " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 2 } , 0 , 0 , DEC , " duplex_mode " } ,
2016-06-18 10:04:15 +00:00
{ " video_input " , " video input " , OFFSET ( video_input ) , AV_OPT_TYPE_INT , { . i64 = 0 } , 0 , 6 , DEC , " video_input " } ,
{ " unset " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 0 } , 0 , 0 , DEC , " video_input " } ,
{ " sdi " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 1 } , 0 , 0 , DEC , " video_input " } ,
{ " hdmi " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 2 } , 0 , 0 , DEC , " video_input " } ,
{ " optical_sdi " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 3 } , 0 , 0 , DEC , " video_input " } ,
{ " component " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 4 } , 0 , 0 , DEC , " video_input " } ,
{ " composite " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 5 } , 0 , 0 , DEC , " video_input " } ,
{ " s_video " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 6 } , 0 , 0 , DEC , " video_input " } ,
{ " audio_input " , " audio input " , OFFSET ( audio_input ) , AV_OPT_TYPE_INT , { . i64 = 0 } , 0 , 6 , DEC , " audio_input " } ,
{ " unset " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 0 } , 0 , 0 , DEC , " audio_input " } ,
{ " embedded " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 1 } , 0 , 0 , DEC , " audio_input " } ,
{ " aes_ebu " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 2 } , 0 , 0 , DEC , " audio_input " } ,
{ " analog " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 3 } , 0 , 0 , DEC , " audio_input " } ,
{ " analog_xlr " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 4 } , 0 , 0 , DEC , " audio_input " } ,
{ " analog_rca " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 5 } , 0 , 0 , DEC , " audio_input " } ,
{ " microphone " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = 6 } , 0 , 0 , DEC , " audio_input " } ,
2018-01-15 08:22:11 +00:00
{ " audio_pts " , " audio pts source " , OFFSET ( audio_pts_source ) , AV_OPT_TYPE_INT , { . i64 = PTS_SRC_AUDIO } , 1 , PTS_SRC_NB - 1 , DEC , " pts_source " } ,
{ " video_pts " , " video pts source " , OFFSET ( video_pts_source ) , AV_OPT_TYPE_INT , { . i64 = PTS_SRC_VIDEO } , 1 , PTS_SRC_NB - 1 , DEC , " pts_source " } ,
2016-06-18 22:35:44 +00:00
{ " audio " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = PTS_SRC_AUDIO } , 0 , 0 , DEC , " pts_source " } ,
{ " video " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = PTS_SRC_VIDEO } , 0 , 0 , DEC , " pts_source " } ,
{ " reference " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = PTS_SRC_REFERENCE } , 0 , 0 , DEC , " pts_source " } ,
{ " wallclock " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = PTS_SRC_WALLCLOCK } , 0 , 0 , DEC , " pts_source " } ,
2018-01-15 08:22:26 +00:00
{ " abs_wallclock " , NULL , 0 , AV_OPT_TYPE_CONST , { . i64 = PTS_SRC_ABS_WALLCLOCK } , 0 , 0 , DEC , " pts_source " } ,
2016-10-13 21:56:45 +00:00
{ " draw_bars " , " draw bars on signal loss " , OFFSET ( draw_bars ) , AV_OPT_TYPE_BOOL , { . i64 = 1 } , 0 , 1 , DEC } ,
2017-08-10 06:29:30 +00:00
{ " queue_size " , " input queue buffer size " , OFFSET ( queue_size ) , AV_OPT_TYPE_INT64 , { . i64 = ( 1024 * 1024 * 1024 ) } , 0 , INT64_MAX , DEC } ,
2017-10-18 19:21:46 +00:00
{ " audio_depth " , " audio bitdepth (16 or 32) " , OFFSET ( audio_depth ) , AV_OPT_TYPE_INT , { . i64 = 16 } , 16 , 32 , DEC } ,
2018-01-15 08:21:46 +00:00
{ " decklink_copyts " , " copy timestamps, do not remove the initial offset " , OFFSET ( copyts ) , AV_OPT_TYPE_BOOL , { . i64 = 0 } , 0 , 1 , DEC } ,
2014-09-22 00:46:03 +00:00
{ NULL } ,
} ;
static const AVClass decklink_demuxer_class = {
. class_name = " Blackmagic DeckLink demuxer " ,
. item_name = av_default_item_name ,
. option = options ,
. version = LIBAVUTIL_VERSION_INT ,
. category = AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ,
} ;
AVInputFormat ff_decklink_demuxer = {
. name = " decklink " ,
. long_name = NULL_IF_CONFIG_SMALL ( " Blackmagic DeckLink input " ) ,
2017-02-18 17:18:18 +00:00
. flags = AVFMT_NOFILE ,
2014-09-22 00:46:03 +00:00
. priv_class = & decklink_demuxer_class ,
. priv_data_size = sizeof ( struct decklink_cctx ) ,
2017-10-06 12:55:43 +00:00
. get_device_list = ff_decklink_list_input_devices ,
2014-09-22 00:46:03 +00:00
. read_header = ff_decklink_read_header ,
. read_packet = ff_decklink_read_packet ,
. read_close = ff_decklink_read_close ,
} ;