34#include <DeckLinkAPIVersion.h>
35#include <DeckLinkAPI.h>
36#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0e030000
37#include <DeckLinkAPI_v14_2_1.h>
63#define MAX_WIDTH_VANC 1920
82 {bmdModeNTSC, 11, 19, 274, 282},
83 {bmdModeNTSC2398, 11, 19, 274, 282},
84 {bmdModePAL, 7, 22, 320, 335},
85 {bmdModeNTSCp, 11, -1, -1, 39},
86 {bmdModePALp, 7, -1, -1, 45},
90 {bmdModeHD1080p2398, 8, -1, -1, 42},
91 {bmdModeHD1080p24, 8, -1, -1, 42},
92 {bmdModeHD1080p25, 8, -1, -1, 42},
93 {bmdModeHD1080p2997, 8, -1, -1, 42},
94 {bmdModeHD1080p30, 8, -1, -1, 42},
95 {bmdModeHD1080i50, 8, 20, 570, 585},
96 {bmdModeHD1080i5994, 8, 20, 570, 585},
97 {bmdModeHD1080i6000, 8, 20, 570, 585},
98 {bmdModeHD1080p50, 8, -1, -1, 42},
99 {bmdModeHD1080p5994, 8, -1, -1, 42},
100 {bmdModeHD1080p6000, 8, -1, -1, 42},
104 {bmdModeHD720p50, 8, -1, -1, 26},
105 {bmdModeHD720p5994, 8, -1, -1, 26},
106 {bmdModeHD720p60, 8, -1, -1, 26},
109 {bmdModeUnknown, 0, -1, -1, -1}
119 virtual HRESULT STDMETHODCALLTYPE
AllocateBuffer(
unsigned int bufferSize,
void* *allocatedBuffer)
123 return E_OUTOFMEMORY;
124 *allocatedBuffer = buf;
132 virtual HRESULT STDMETHODCALLTYPE
Commit() {
return S_OK; }
133 virtual HRESULT STDMETHODCALLTYPE
Decommit() {
return S_OK; }
139 *ppv =
static_cast<IUnknown*
>(
this);
144 return E_NOINTERFACE;
167 IUnknown *obj = (
class IUnknown *)opaque;
191 uint16_t vanc_sum = 0;
192 for (
i = 3;
i <
len - 1;
i++) {
196 if ((!!p ^ !!(v & 0x100)) || (np != 1 && np != 2)) {
203 vanc_sum |= ((~vanc_sum & 0x100) << 1);
204 if (checksum != vanc_sum) {
216 *
dst++ = (
src[1] >> 2) + ((
src[2] & 15) << 6);
218 *
dst++ = (
src[6] >> 4) + ((
src[7] & 63) << 4);
226 for (
i = 0;
i <
width * 2 / 3;
i++) {
228 *
dst++ = (
src[1] >> 2) + ((
src[2] & 15) << 6);
229 *
dst++ = (
src[2] >> 4) + ((
src[3] & 63) << 4);
236 uint8_t ret = (
line < 313) << 5;
253static uint8_t* teletext_data_unit_from_vbi_data(
int line, uint8_t *
src, uint8_t *tgt, vbi_pixfmt fmt)
255 vbi_bit_slicer slicer;
257 vbi_bit_slicer_init(&slicer, 720, 13500000, 6937500, 6937500, 0x00aaaae4, 0xffff, 18, 6, 42 * 8, VBI_MODULATION_NRZ_MSB, fmt);
259 if (vbi_bit_slice(&slicer,
src, tgt + 4) == FALSE)
267static uint8_t* teletext_data_unit_from_vbi_data_10bit(
int line, uint8_t *
src, uint8_t *tgt)
271 uint8_t *pend = y + 720;
276 *py++ = (
src[1] >> 4) + ((
src[2] & 15) << 4);
277 *py++ = (
src[4] >> 2) + ((
src[5] & 3 ) << 6);
278 *py++ = (
src[6] >> 6) + ((
src[7] & 63) << 2);
281 return teletext_data_unit_from_vbi_data(
line, y, tgt, VBI_PIXFMT_YUV420);
289 if (py[0] != 0x255 || py[1] != 0x255 || py[2] != 0x227)
297 for (
i = 0;
i < 42;
i++)
316 if (py[0] == 0x151 && py[1] == 0x115 && py[3] == 0x102) {
317 uint16_t *descriptors = py + 4;
320 for (
i = 0;
i < 5 && py < pend - 45;
i++, py += 45) {
321 int line = (descriptors[
i] & 31) + (!(descriptors[
i] & 128)) * 313;
332 uint16_t did = py[0];
333 uint16_t sdid = py[1];
334 uint16_t dc = py[2] & 255;
336 pend =
FFMIN(pend, py + dc);
337 if (did == 0x143 && sdid == 0x102) {
339 }
else if (allow_multipacket && did == 0x143 && sdid == 0x203) {
341 while (py < pend - 3) {
343 py += 4 + (py[2] & 255);
352 size_t i,
len = (buf[5] & 0xff) + 6 + 1;
353 uint8_t cdp_sum, rate;
356 uint16_t *cdp = &buf[6];
357 if (cdp[0] != 0x96 || cdp[1] != 0x69) {
370 for (
i = 0;
i <
len - 1;
i++)
372 cdp_sum = cdp_sum ? 256 - cdp_sum : 0;
373 if (cdp[
len - 1] != cdp_sum) {
379 if (!(rate & 0x0f)) {
389 if (!(cdp[4] & 0x43)) {
394 hdr = (cdp[5] << 8) | cdp[6];
395 if (cdp[7] != 0x72) {
401 if (!(cc_count & 0xe0)) {
407 if ((
len - 13) < cc_count * 3) {
412 if (cdp[
len - 4] != 0x74) {
417 ftr = (cdp[
len - 3] << 8) | cdp[
len - 2];
429 for (
size_t i = 0;
i < cc_count;
i++) {
430 cc[3*
i + 0] = cdp[9 + 3*
i+0] ;
431 cc[3*
i + 1] = cdp[9 + 3*
i+1];
432 cc[3*
i + 2] = cdp[9 + 3*
i+2];
443 uint16_t *max_buf = buf +
width;
445 while (buf < max_buf - 6) {
447 uint16_t did = buf[3] & 0xFF;
448 uint16_t sdid = buf[4] & 0xFF;
450 if (buf[0] != 0 || buf[1] != 0x3ff || buf[2] != 0x3ff) {
454 len = (buf[5] & 0xff) + 6 + 1;
455 if (
len > max_buf - buf) {
461 if (did == 0x43 && (sdid == 0x02 || sdid == 0x03) && cctx->
teletext_lines &&
462 width == 1920 && tgt_size >= 1920) {
468 }
else if (did == 0x61 && sdid == 0x01) {
469 unsigned int data_len;
495 const uint8_t KLV_DID = 0x44;
496 const uint8_t KLV_IN_VANC_SDID = 0x04;
500 uint16_t sequence_counter;
501 std::vector<uint8_t>
data;
504 size_t total_size = 0;
505 std::vector<std::vector<KLVPacket>> klv_packets(256);
507 IDeckLinkVideoFrameAncillaryPackets *packets =
nullptr;
508 if (videoFrame->QueryInterface(IID_IDeckLinkVideoFrameAncillaryPackets, (
void**)&packets) != S_OK)
511 IDeckLinkAncillaryPacketIterator *it =
nullptr;
512 if (packets->GetPacketIterator(&it) != S_OK) {
517 IDeckLinkAncillaryPacket *packet =
nullptr;
518 while (it->Next(&packet) == S_OK) {
519 uint8_t *
data =
nullptr;
522 if (packet->GetDID() == KLV_DID && packet->GetSDID() == KLV_IN_VANC_SDID) {
523 av_log(avctx,
AV_LOG_DEBUG,
"Found KLV VANC packet on line: %d\n", packet->GetLineNumber());
525 if (packet->GetBytes(bmdAncillaryPacketFormatUInt8, (
const void**) &
data, &
size) == S_OK) {
528 uint8_t mid =
data[0];
529 uint16_t psc =
data[1] << 8 |
data[2];
533 auto& list = klv_packets[mid];
534 uint16_t expected_psc = list.size() + 1;
536 if (psc == expected_psc) {
537 uint32_t data_len =
size - 3;
538 total_size += data_len;
541 packet.data.resize(data_len);
542 memcpy(packet.data.data(),
data + 3, data_len);
544 list.push_back(std::move(packet));
549 for (
auto& klv : list)
550 total_size -= klv.data.size();
565 if (total_size > 0) {
566 std::vector<uint8_t> klv;
567 klv.reserve(total_size);
569 for (
size_t i = 0;
i < klv_packets.size(); ++
i) {
570 auto& list = klv_packets[
i];
577 for (
auto& packet : list)
578 klv.insert(klv.end(), packet.data.begin(), packet.data.end());
586 klv_packet.
data = klv.data();
587 klv_packet.
size = klv.size();
604 *ppv =
static_cast<IUnknown*
>(
this);
609 return E_NOINTERFACE;
615 virtual ULONG STDMETHODCALLTYPE
AddRef(
void);
616 virtual ULONG STDMETHODCALLTYPE
Release(
void);
617 virtual HRESULT STDMETHODCALLTYPE
VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
660 IDeckLinkAudioInputPacket *audioFrame,
668 BMDTimeValue bmd_pts;
669 BMDTimeValue bmd_duration;
670 HRESULT res = E_INVALIDARG;
674 res = audioFrame->GetPacketTime(&bmd_pts, time_base.
den);
678 res = videoFrame->GetStreamTime(&bmd_pts, &bmd_duration, time_base.
den);
682 res = videoFrame->GetHardwareReferenceTimestamp(time_base.
den, &bmd_pts, &bmd_duration);
701 pts = bmd_pts / time_base.
num;
715 IDeckLinkTimecode *timecode;
717#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000
718 int hfr = (
tc_format == bmdTimecodeRP188HighFrameRate);
722 if (videoFrame->GetTimecode(
tc_format, &timecode) == S_OK) {
723 uint8_t hh, mm,
ss, ff;
724 if (timecode->GetComponents(&hh, &mm, &
ss, &ff) == S_OK) {
727 ff = ff << 1 | !!(timecode->GetFlags() & bmdTimecodeFieldMark);
744#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000
745 ret =
get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188HighFrameRate, videoFrame);
748 ret =
get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188VITC1, videoFrame);
750 ret =
get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188VITC2, videoFrame);
752 ret =
get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188LTC, videoFrame);
763 void *audioFrameBytes;
764 BMDTimeValue frameTime;
765 BMDTimeValue frameDuration;
766 int64_t wallclock = 0, abs_wallclock = 0;
767 int64_t video_pkt_pts, audio_pkt_pts;
770 if (
ctx->autodetect) {
771 if (videoFrame && !(videoFrame->GetFlags() & bmdFrameHasNoInputSource) &&
772 ctx->bmd_mode == bmdModeUnknown)
783 if (
av_cmp_q(remainder, frame_duration) > 0) {
800 if (
ctx->frameCount % 25 == 0) {
803 "Frame received (#%lu) - Valid (%liB) - QSize %fMB\n",
805 videoFrame->GetRowBytes() * videoFrame->GetHeight(),
806 (
double)qsize / 1024 / 1024);
809 videoFrame->GetBytes(&frameBytes);
810 videoFrame->GetStreamTime(&frameTime, &frameDuration,
811 ctx->video_st->time_base.den);
813 if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) {
814 if (
ctx->signal_loss_action ==
SIGNAL_LOSS_BARS && videoFrame->GetPixelFormat() == bmdFormat8BitYUV) {
816 0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035,
817 0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 };
818 int width = videoFrame->GetWidth();
819 int height = videoFrame->GetHeight();
820 unsigned *p = (
unsigned *)frameBytes;
822 for (
int y = 0; y <
height; y++) {
823 for (
int x = 0; x <
width; x += 2)
824 *p++ = bars[(x * 8) /
width];
828 videoFrame->GetBytes(&frameBytes);
833 "- Frames dropped %u\n",
ctx->frameCount, ++
ctx->dropped);
845 "- Frames dropped %u\n",
ctx->frameCount, ++
ctx->dropped);
850 if (
ctx->tc_format) {
857 uint8_t* packed_metadata;
861 int size =
sizeof(uint32_t) * 4;
870 if (
av_dict_set(&metadata_dict,
"timecode", tc, 0) >= 0) {
874 if (packed_metadata) {
877 else if (!
ctx->tc_seen)
878 ctx->tc_seen =
ctx->frameCount;
892 "- Frames dropped %u\n",
ctx->frameCount, ++
ctx->dropped);
896 pkt.pts = video_pkt_pts;
899 pkt.duration = frameDuration;
902 pkt.stream_index =
ctx->video_st->index;
903 pkt.data = (uint8_t *)frameBytes;
904 pkt.size = videoFrame->GetRowBytes() *
905 videoFrame->GetHeight();
909 IDeckLinkVideoFrameAncillary *vanc;
911 uint8_t txt_buf0[3531];
912 uint8_t *txt_buf = txt_buf0;
914 if (
ctx->enable_klv) {
918 if (videoFrame->GetAncillaryData(&vanc) == S_OK) {
920 BMDPixelFormat vanc_format = vanc->GetPixelFormat();
924 if (
ctx->bmd_mode == bmdModePAL &&
ctx->teletext_lines &&
925 (vanc_format == bmdFormat8BitYUV || vanc_format == bmdFormat10BitYUV)) {
928 for (
i = 6;
i < 336;
i++, line_mask <<= 1) {
930 if ((
ctx->teletext_lines & line_mask) && vanc->GetBufferForVerticalBlankingLine(
i, (
void**)&buf) == S_OK) {
931 if (vanc_format == bmdFormat8BitYUV)
932 txt_buf = teletext_data_unit_from_vbi_data(
i, buf, txt_buf, VBI_PIXFMT_UYVY);
934 txt_buf = teletext_data_unit_from_vbi_data_10bit(
i, buf, txt_buf);
941 if (vanc_format == bmdFormat10BitYUV && videoFrame->GetWidth() <=
MAX_WIDTH_VANC) {
945 if (vanc->GetBufferForVerticalBlankingLine(
i, (
void**)&buf) == S_OK) {
947 size_t vanc_size = videoFrame->GetWidth();
948 if (
ctx->bmd_mode == bmdModeNTSC && videoFrame->GetWidth() * 2 <=
MAX_WIDTH_VANC) {
949 vanc_size = vanc_size * 2;
955 txt_buf,
sizeof(txt_buf0) - (txt_buf - txt_buf0), &
pkt);
962 if (txt_buf - txt_buf0 > 1) {
963 int stuffing_units = (4 - ((45 + txt_buf - txt_buf0) / 46) % 4) % 4;
964 while (stuffing_units--) {
965 memset(txt_buf, 0xff, 46);
972 txt_pkt.
data = txt_buf0;
973 txt_pkt.
size = txt_buf - txt_buf0;
983 videoFrame->AddRef();
993 BMDTimeValue audio_pts;
996 pkt.size = audioFrame->GetSampleFrameCount() *
ctx->audio_st->codecpar->ch_layout.nb_channels * (
ctx->audio_depth / 8);
997 audioFrame->GetBytes(&audioFrameBytes);
998 audioFrame->GetPacketTime(&audio_pts,
ctx->audio_st->time_base.den);
999 pkt.pts = audio_pkt_pts;
1004 pkt.stream_index =
ctx->audio_st->index;
1005 pkt.data = (uint8_t *)audioFrameBytes;
1016 BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *
mode,
1017 BMDDetectedVideoInputFormatFlags formatFlags)
1020 ctx->bmd_mode =
mode->GetDisplayMode();
1023 ctx->raw_format = (formatFlags & bmdDetectedVideoInputRGB444) ? bmdFormat8BitARGB : bmdFormat8BitYUV;
1032 if (
ctx->attr->GetFlag(BMDDeckLinkSupportsInputFormatDetection, &autodetect_supported) != S_OK)
1034 if (autodetect_supported ==
false)
1037 ctx->autodetect = 1;
1038 ctx->bmd_mode = bmdModeUnknown;
1041 bmdVideoInputEnableFormatDetection) != S_OK) {
1045 if (
ctx->dli->StartStreams() != S_OK) {
1050 for (
i = 0;
i < 30;
i++) {
1055 if (
ctx->bmd_mode != bmdModeUnknown &&
1060 ctx->dli->PauseStreams();
1061 ctx->dli->FlushStreams();
1062 ctx->autodetect = 0;
1063 if (
ctx->bmd_mode != bmdModeUnknown) {
1083 ctx->dli->StopStreams();
1084 ctx->dli->DisableVideoInput();
1085 ctx->dli->DisableAudioInput();
1086 ctx->dli->SetCallback(
nullptr);
1128 av_log(avctx,
AV_LOG_WARNING,
"Setting signal_loss_action to none because draw_bars is false\n");
1131 av_log(avctx,
AV_LOG_ERROR,
"options draw_bars and signal_loss_action are mutually exclusive\n");
1158 av_log(avctx,
AV_LOG_ERROR,
"Value for audio bit depth option must be either 16 or 32\n");
1164 if (
ctx->list_devices) {
1189 if (
ctx->list_formats) {
1204 ret = (
ctx->dli->SetVideoInputFrameMemoryAllocator(allocator) == S_OK ? 0 :
AVERROR_EXTERNAL);
1219 if (
ctx->raw_format == (BMDPixelFormat)0)
1220 ctx->raw_format = bmdFormat8BitYUV;
1229 if (
ctx->teletext_lines &&
ctx->bmd_mode == bmdModePAL) {
1230 av_log(avctx,
AV_LOG_ERROR,
"Libzvbi support is needed for capturing SD PAL teletext, please recompile FFmpeg.\n");
1264 switch(
ctx->raw_format) {
1265 case bmdFormat8BitYUV:
1270 case bmdFormat10BitYUV:
1274 case bmdFormat8BitARGB:
1279 case bmdFormat8BitBGRA:
1284 case bmdFormat10BitRGB:
1296 switch (
ctx->bmd_field_dominance) {
1297 case bmdUpperFieldFirst:
1300 case bmdLowerFieldFirst:
1303 case bmdProgressiveFrame:
1304 case bmdProgressiveSegmentedFrame:
1313 if (
ctx->enable_klv) {
1327 if (
ctx->teletext_lines) {
1339 ctx->teletext_st = st;
1342 av_log(avctx,
AV_LOG_VERBOSE,
"Using %d input audio channels\n",
ctx->audio_st->codecpar->ch_layout.nb_channels);
1343 result =
ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, cctx->
audio_depth == 32 ? bmdAudioSampleType32bitInteger : bmdAudioSampleType16bitInteger,
ctx->audio_st->codecpar->ch_layout.nb_channels);
1345 if (result != S_OK) {
1351 result =
ctx->dli->EnableVideoInput(
ctx->bmd_mode,
1353 bmdVideoInputFlagDefault);
1355 if (result != S_OK) {
1363 if (
ctx->dli->StartStreams() != S_OK) {
1387 if (side_metadata) {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Main libavdevice API header.
Convenience header that includes libavutil's core.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define ss(width, name, subs,...)
virtual HRESULT STDMETHODCALLTYPE Decommit()
virtual HRESULT STDMETHODCALLTYPE Commit()
virtual ~decklink_allocator()
virtual ULONG STDMETHODCALLTYPE Release(void)
virtual ULONG STDMETHODCALLTYPE AddRef(void)
virtual HRESULT STDMETHODCALLTYPE AllocateBuffer(unsigned int bufferSize, void **allocatedBuffer)
virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(void *buffer)
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv)
common internal and external API header
int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction)
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction)
unsigned long long ff_decklink_packet_queue_size(DecklinkPacketQueue *q)
void ff_decklink_packet_queue_init(AVFormatContext *avctx, DecklinkPacketQueue *q, int64_t queue_size)
int ff_decklink_init_device(AVFormatContext *avctx, const char *name)
void ff_decklink_packet_queue_end(DecklinkPacketQueue *q)
int ff_decklink_packet_queue_get(DecklinkPacketQueue *q, AVPacket *pkt, int block)
void ff_decklink_list_devices_legacy(AVFormatContext *avctx, int show_inputs, int show_outputs)
int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t direction)
int ff_decklink_list_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list, int show_inputs, int show_outputs)
int ff_decklink_packet_queue_put(DecklinkPacketQueue *q, AVPacket *pkt)
void ff_decklink_cleanup(AVFormatContext *avctx)
#define IDeckLinkInputCallback_v14_2_1
static const BMDVideoConnection decklink_video_connection_map[]
#define IID_IDeckLinkInputCallback_v14_2_1
#define IDeckLinkVideoInputFrame_v14_2_1
#define IID_IDeckLinkMemoryAllocator_v14_2_1
static const BMDTimecodeFormat decklink_timecode_format_map[]
static bool DECKLINK_IsEqualIID(const REFIID &riid1, const REFIID &riid2)
static const BMDPixelFormat decklink_raw_format_map[]
#define IID_IDeckLinkInput_v14_2_1
#define IDeckLinkMemoryAllocator_v14_2_1
static const BMDAudioConnection decklink_audio_connection_map[]
static uint8_t * get_metadata(AVFormatContext *avctx, uint16_t *buf, size_t width, uint8_t *tgt, size_t tgt_size, AVPacket *pkt)
static void fill_data_unit_head(int line, uint8_t *tgt)
static VANCLineNumber vanc_line_numbers[]
static uint8_t calc_parity_and_line_offset(int line)
static int check_vanc_parity_checksum(uint16_t *buf, int len, uint16_t checksum)
static int get_frame_timecode(AVFormatContext *avctx, decklink_ctx *ctx, AVTimecode *tc, IDeckLinkVideoInputFrame_v14_2_1 *videoFrame)
static uint8_t * teletext_data_unit_from_op47_vbi_packet(int line, uint16_t *py, uint8_t *tgt)
static int decklink_autodetect(struct decklink_cctx *cctx)
av_cold int ff_decklink_read_close(AVFormatContext *avctx)
static int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame_v14_2_1 *videoFrame)
static int64_t get_pkt_pts(IDeckLinkVideoInputFrame_v14_2_1 *videoFrame, IDeckLinkAudioInputPacket *audioFrame, int64_t wallclock, int64_t abs_wallclock, DecklinkPtsSource pts_src, AVRational time_base, int64_t *initial_pts, int copyts)
static int linemask_matches(int line, int64_t mask)
static void clear_parity_bits(uint16_t *buf, int len)
const BMDDisplayMode AUTODETECT_DEFAULT_MODE
static int get_vanc_line_idx(BMDDisplayMode mode)
static uint8_t * vanc_to_cc(AVFormatContext *avctx, uint16_t *buf, size_t words, unsigned &cc_count)
static uint8_t * teletext_data_unit_from_op47_data(uint16_t *py, uint16_t *pend, uint8_t *tgt, int64_t wanted_lines)
int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)
int ff_decklink_list_input_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list)
static void unpack_v210(uint16_t *dst, const uint8_t *src, int width)
static void extract_luma_from_v210(uint16_t *dst, const uint8_t *src, int width)
static uint8_t * teletext_data_unit_from_ancillary_packet(uint16_t *py, uint16_t *pend, uint8_t *tgt, int64_t wanted_lines, int allow_multipacket)
av_cold int ff_decklink_read_header(AVFormatContext *avctx)
static void handle_klv(AVFormatContext *avctx, decklink_ctx *ctx, IDeckLinkVideoInputFrame_v14_2_1 *videoFrame, int64_t pts)
static void decklink_object_free(void *opaque, uint8_t *data)
@ AV_FIELD_TT
Top coded_first, top displayed first.
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
@ AV_CODEC_ID_DVB_TELETEXT
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
@ AV_PKT_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1:2014.
@ AV_PKT_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t * av_packet_pack_dictionary(const AVDictionary *dict, size_t *size)
Pack a dictionary for use in side_data.
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict)
Unpack a dictionary from side_data.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static AVRational av_make_q(int num, int den)
Create an AVRational.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
char * av_fourcc_make_string(char *buf, uint32_t fourcc)
Fill the provided buffer with a string containing a FourCC (four-character code) representation.
#define AV_FOURCC_MAX_STRING_SIZE
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE
Internal time base represented as integer.
static int shift(int a, int b)
common internal API header
const uint8_t ff_reverse[256]
static const uint16_t mask[17]
static void input_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
#define FF_ARRAY_ELEMS(a)
int nb_channels
Number of channels in this layout.
enum AVFieldOrder field_order
The order of the fields in interlaced video.
int height
The height of the video frame in pixels.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
char * url
input or output URL.
void * priv_data
Format private data.
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
AVRational r_frame_rate
Real base framerate of the stream.
DecklinkSignalLossAction signal_loss_action
DecklinkPtsSource video_pts_source
DecklinkPtsSource audio_pts_source
BMDTimecodeFormat tc_format
static void error(const char *err)
int av_usleep(unsigned usec)
Sleep for a period of time.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
int64_t av_gettime(void)
Get the current time in microseconds.
int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx)
Init a timecode struct from the passed timecode components.
uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
Convert frame number to SMPTE 12M binary representation.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum_arg)
Load timecode string in buf.
#define AV_TIMECODE_STR_SIZE
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame