22 #include <DeckLinkAPI.h> 
   49     virtual BMDPixelFormat STDMETHODCALLTYPE 
GetPixelFormat(
void)          { 
return bmdFormat8BitYUV; }
 
   50     virtual BMDFrameFlags  STDMETHODCALLTYPE 
GetFlags      (
void)          { 
return bmdVideoOutputFlagDefault; }
 
  104                " Only AV_PIX_FMT_UYVY422 is supported.\n");
 
  110                " Check available formats with -list_formats 1.\n");
 
  113     if (
ctx->dlo->EnableVideoOutput(
ctx->bmd_mode,
 
  114                                     bmdVideoOutputFlagDefault) != 
S_OK) {
 
  121     ctx->dlo->SetScheduledFrameCompletionCallback(
ctx->output_callback);
 
  126         ctx->frames_preroll /= 1000;
 
  129     ctx->frames_buffer = 
ctx->frames_preroll * 2;
 
  130     ctx->frames_buffer = 
FFMIN(
ctx->frames_buffer, 60);
 
  153                " Only 48kHz is supported.\n");
 
  158                " Only stereo and 7.1 are supported.\n");
 
  161     if (
ctx->dlo->EnableAudioOutput(bmdAudioSampleRate48kHz,
 
  162                                     bmdAudioSampleType16bitInteger,
 
  164                                     bmdAudioOutputStreamTimestamped) != 
S_OK) {
 
  168     if (
ctx->dlo->BeginAudioPreroll() != 
S_OK) {
 
  187     if (
ctx->playback_started) {
 
  189         ctx->dlo->StopScheduledPlayback(
ctx->last_pts * 
ctx->bmd_tb_num,
 
  190                                         &actual, 
ctx->bmd_tb_den);
 
  191         ctx->dlo->DisableVideoOutput();
 
  193             ctx->dlo->DisableAudioOutput();
 
  201     if (
ctx->output_callback)
 
  202         delete ctx->output_callback;
 
  228     tmp->width  = 
ctx->bmd_width;
 
  229     tmp->height = 
ctx->bmd_height;
 
  247                                (
void *) avframe->
data[0]);
 
  257     hr = 
ctx->dlo->ScheduleVideoFrame((
struct IDeckLinkVideoFrame *) 
frame,
 
  258                                       pkt->
pts * 
ctx->bmd_tb_num,
 
  259                                       ctx->bmd_tb_num, 
ctx->bmd_tb_den);
 
  262                 " error %08x.\n", (uint32_t) hr);
 
  267     ctx->dlo->GetBufferedVideoFrameCount(&buffered);
 
  269     if (pkt->
pts > 2 && buffered <= 2)
 
  271                " Video may misbehave!\n");
 
  274     if (!
ctx->playback_started && pkt->
pts > 
ctx->frames_preroll) {
 
  276         if (
ctx->audio && 
ctx->dlo->EndAudioPreroll() != 
S_OK) {
 
  281         if (
ctx->dlo->StartScheduledPlayback(0, 
ctx->bmd_tb_den, 1.0) != 
S_OK) {
 
  285         ctx->playback_started = 1;
 
  295     int sample_count = pkt->
size / (
ctx->channels << 1);
 
  298     ctx->dlo->GetBufferedAudioSampleFrameCount(&buffered);
 
  299     if (pkt->
pts > 1 && !buffered)
 
  301                " Audio will misbehave!\n");
 
  303     if (
ctx->dlo->ScheduleAudioSamples(pkt->
data, sample_count, pkt->
pts,
 
  304                                        bmdAudioSampleRate48kHz, 
NULL) != 
S_OK) {
 
  318     IDeckLinkDisplayModeIterator *itermode;
 
  319     IDeckLinkIterator *iter;
 
  320     IDeckLink *dl = 
NULL;
 
  331     iter = CreateDeckLinkIteratorInstance();
 
  338     if (
ctx->list_devices) {
 
  344     while (iter->Next(&dl) == 
S_OK) {
 
  345         const char *displayName;
 
  347         if (!strcmp(avctx->
filename, displayName)) {
 
  362     if (
ctx->dl->QueryInterface(IID_IDeckLinkOutput, (
void **) &
ctx->dlo) != 
S_OK) {
 
  370     if (
ctx->list_formats) {
 
  377     if (
ctx->dlo->GetDisplayModeIterator(&itermode) != 
S_OK) {
 
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 
This structure describes decoded (raw) audio or video data. 
virtual long STDMETHODCALLTYPE GetWidth(void)
#define AV_LOG_WARNING
Something somehow does not look correct. 
decklink_frame(struct decklink_ctx *ctx, AVFrame *avframe, long width, long height, void *buffer)
static int decklink_setup_video(AVFormatContext *avctx, AVStream *st)
static int decklink_write_audio_packet(AVFormatContext *avctx, AVPacket *pkt)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx. 
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
av_cold int ff_decklink_write_trailer(AVFormatContext *avctx)
static int decklink_write_video_packet(AVFormatContext *avctx, AVPacket *pkt)
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values. 
attribute_deprecated int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line 
virtual long STDMETHODCALLTYPE GetHeight(void)
AVStream ** streams
A list of all streams in the file. 
int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, decklink_direction_t direction, int num)
static int decklink_setup_audio(AVFormatContext *avctx, AVStream *st)
virtual ULONG STDMETHODCALLTYPE Release(void)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
virtual HRESULT STDMETHODCALLTYPE ScheduledPlaybackHasStopped(void)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g. 
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers. 
#define sem_destroy(psem)
virtual BMDPixelFormat STDMETHODCALLTYPE GetPixelFormat(void)
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data. 
unsigned int nb_streams
Number of elements in AVFormatContext.streams. 
char filename[1024]
input or output filename 
struct decklink_ctx * _ctx
av_cold int ff_decklink_write_header(AVFormatContext *avctx)
int width
picture width / height. 
attribute_deprecated uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes 
uint32_t buffercount_type
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction)
virtual long STDMETHODCALLTYPE GetRowBytes(void)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted. 
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src. 
enum AVMediaType codec_type
virtual ULONG STDMETHODCALLTYPE AddRef(void)
int sample_rate
samples per second 
int ff_decklink_list_devices(AVFormatContext *avctx)
main external API structure. 
HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName)
static const char * format
virtual BMDFrameFlags STDMETHODCALLTYPE GetFlags(void)
virtual HRESULT STDMETHODCALLTYPE GetBytes(void **buffer)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data. 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted(IDeckLinkVideoFrame *_frame, BMDOutputFrameCompletionResult result)
virtual HRESULT STDMETHODCALLTYPE GetAncillaryData(IDeckLinkVideoFrameAncillary **ancillary)
virtual ULONG STDMETHODCALLTYPE AddRef(void)
int channels
number of audio channels 
void * priv_data
Format private data. 
int ff_decklink_write_packet(AVFormatContext *avctx, AVPacket *pkt)
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
virtual HRESULT STDMETHODCALLTYPE GetTimecode(BMDTimecodeFormat format, IDeckLinkTimecode **timecode)
AVPixelFormat
Pixel format. 
This structure stores compressed data. 
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
virtual ULONG STDMETHODCALLTYPE Release(void)