30 #include <DeckLinkAPI.h>
52 #define MAX_WIDTH_VANC 1920
71 {bmdModeNTSC, 11, 19, 274, 282},
72 {bmdModeNTSC2398, 11, 19, 274, 282},
73 {bmdModePAL, 7, 22, 320, 335},
74 {bmdModeNTSCp, 11, -1, -1, 39},
75 {bmdModePALp, 7, -1, -1, 45},
79 {bmdModeHD1080p2398, 8, -1, -1, 42},
80 {bmdModeHD1080p24, 8, -1, -1, 42},
81 {bmdModeHD1080p25, 8, -1, -1, 42},
82 {bmdModeHD1080p2997, 8, -1, -1, 42},
83 {bmdModeHD1080p30, 8, -1, -1, 42},
84 {bmdModeHD1080i50, 8, 20, 570, 585},
85 {bmdModeHD1080i5994, 8, 20, 570, 585},
86 {bmdModeHD1080i6000, 8, 20, 570, 585},
87 {bmdModeHD1080p50, 8, -1, -1, 42},
88 {bmdModeHD1080p5994, 8, -1, -1, 42},
89 {bmdModeHD1080p6000, 8, -1, -1, 42},
93 {bmdModeHD720p50, 8, -1, -1, 26},
94 {bmdModeHD720p5994, 8, -1, -1, 26},
95 {bmdModeHD720p60, 8, -1, -1, 26},
98 {bmdModeUnknown, 0, -1, -1, -1}
105 if (mode == vanc_line_numbers[i].mode)
114 for (i = 0; i <
len; i++)
120 uint16_t vanc_sum = 0;
121 for (i = 3; i < len - 1; i++) {
125 if ((!!p ^ !!(v & 0x100)) || (np != 1 && np != 2)) {
132 vanc_sum |= ((~vanc_sum & 0x100) << 1);
133 if (checksum != vanc_sum) {
144 for (i = 0; i < width / 3; i++) {
145 *dst++ = (src[1] >> 2) + ((src[2] & 15) << 6);
146 *dst++ = src[4] + ((src[5] & 3) << 8);
147 *dst++ = (src[6] >> 4) + ((src[7] & 63) << 4);
155 for (i = 0; i < width * 2 / 3; i++) {
156 *dst++ = src[0] + ((src[1] & 3) << 8);
157 *dst++ = (src[1] >> 2) + ((src[2] & 15) << 6);
158 *dst++ = (src[2] >> 4) + ((src[3] & 63) << 4);
165 uint8_t ret = (line < 313) << 5;
166 if (line >= 7 && line <= 22)
168 if (line >= 320 && line <= 335)
184 vbi_bit_slicer slicer;
186 vbi_bit_slicer_init(&slicer, 720, 13500000, 6937500, 6937500, 0x00aaaae4, 0xffff, 18, 6, 42 * 8, VBI_MODULATION_NRZ_MSB, fmt);
188 if (vbi_bit_slice(&slicer, src, tgt + 4) ==
FALSE)
205 *py++ = (src[1] >> 4) + ((src[2] & 15) << 4);
206 *py++ = (src[4] >> 2) + ((src[5] & 3 ) << 6);
207 *py++ = (src[6] >> 6) + ((src[7] & 63) << 2);
210 return teletext_data_unit_from_vbi_data(line, y, tgt, VBI_PIXFMT_YUV420);
218 if (py[0] != 0x255 || py[1] != 0x255 || py[2] != 0x227)
226 for (i = 0; i < 42; i++)
235 if (line >= 6 && line <= 22)
237 if (line >= 318 && line <= 335)
238 shift = line - 318 + 17;
239 return shift >= 0 && ((1ULL <<
shift) & mask);
245 if (py[0] == 0x151 && py[1] == 0x115 && py[3] == 0x102) {
246 uint16_t *descriptors = py + 4;
249 for (i = 0; i < 5 && py < pend - 45; i++, py += 45) {
250 int line = (descriptors[i] & 31) + (!(descriptors[i] & 128)) * 313;
261 uint16_t did = py[0];
262 uint16_t sdid = py[1];
263 uint16_t
dc = py[2] & 255;
265 pend =
FFMIN(pend, py + dc);
266 if (did == 0x143 && sdid == 0x102) {
268 }
else if (allow_multipacket && did == 0x143 && sdid == 0x203) {
270 while (py < pend - 3) {
272 py += 4 + (py[2] & 255);
281 size_t i,
len = (buf[5] & 0xff) + 6 + 1;
285 uint16_t *cdp = &buf[6];
286 if (cdp[0] != 0x96 || cdp[1] != 0x69) {
299 for (i = 0; i < len - 1; i++)
301 cdp_sum = cdp_sum ? 256 - cdp_sum : 0;
302 if (cdp[len - 1] != cdp_sum) {
308 if (!(rate & 0x0f)) {
318 if (!(cdp[4] & 0x43)) {
323 hdr = (cdp[5] << 8) | cdp[6];
324 if (cdp[7] != 0x72) {
330 if (!(cc_count & 0xe0)) {
336 if ((len - 13) < cc_count * 3) {
341 if (cdp[len - 4] != 0x74) {
346 ftr = (cdp[len - 3] << 8) | cdp[len - 2];
358 for (
size_t i = 0; i < cc_count; i++) {
359 cc[3*i + 0] = cdp[9 + 3*i+0] ;
360 cc[3*i + 1] = cdp[9 + 3*i+1];
361 cc[3*i + 2] = cdp[9 + 3*i+2];
372 uint16_t *max_buf = buf + width;
374 while (buf < max_buf - 6) {
376 uint16_t did = buf[3] & 0xFF;
377 uint16_t sdid = buf[4] & 0xFF;
379 if (buf[0] != 0 || buf[1] != 0x3ff || buf[2] != 0x3ff) {
383 len = (buf[5] & 0xff) + 6 + 1;
384 if (len > max_buf - buf) {
390 if (did == 0x43 && (sdid == 0x02 || sdid == 0x03) && cctx->
teletext_lines &&
391 width == 1920 && tgt_size >= 1920) {
397 }
else if (did == 0x61 && sdid == 0x01) {
398 unsigned int data_len;
405 data =
vanc_to_cc(avctx, buf, width, data_len);
457 unsigned long long size;
546 virtual HRESULT STDMETHODCALLTYPE
VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
598 IDeckLinkAudioInputPacket *audioFrame,
600 int64_t abs_wallclock,
606 BMDTimeValue bmd_pts;
607 BMDTimeValue bmd_duration;
612 res = audioFrame->GetPacketTime(&bmd_pts, time_base.
den);
616 res = videoFrame->GetStreamTime(&bmd_pts, &bmd_duration, time_base.
den);
620 res = videoFrame->GetHardwareReferenceTimestamp(time_base.
den, &bmd_pts, &bmd_duration);
639 pts = bmd_pts / time_base.
num;
652 IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame)
655 void *audioFrameBytes;
656 BMDTimeValue frameTime;
657 BMDTimeValue frameDuration;
658 int64_t wallclock = 0, abs_wallclock = 0;
662 if (videoFrame && !(videoFrame->GetFlags() & bmdFrameHasNoInputSource) &&
683 "Frame received (#%lu) - Valid (%liB) - QSize %fMB\n",
685 videoFrame->GetRowBytes() * videoFrame->GetHeight(),
686 (double)qsize / 1024 / 1024);
689 videoFrame->GetBytes(&frameBytes);
690 videoFrame->GetStreamTime(&frameTime, &frameDuration,
693 if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) {
694 if (
ctx->
draw_bars && videoFrame->GetPixelFormat() == bmdFormat8BitYUV) {
696 0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035,
697 0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 };
698 int width = videoFrame->GetWidth();
699 int height = videoFrame->GetHeight();
700 unsigned *p = (
unsigned *)frameBytes;
702 for (
int y = 0; y <
height; y++) {
703 for (
int x = 0; x <
width; x += 2)
704 *p++ = bars[(x * 8) /
width];
729 pkt.
size = videoFrame->GetRowBytes() *
730 videoFrame->GetHeight();
734 IDeckLinkVideoFrameAncillary *vanc;
739 if (videoFrame->GetAncillaryData(&vanc) ==
S_OK) {
741 int64_t line_mask = 1;
742 BMDPixelFormat vanc_format = vanc->GetPixelFormat();
747 (vanc_format == bmdFormat8BitYUV || vanc_format == bmdFormat10BitYUV)) {
749 for (i = 6; i < 336; i++, line_mask <<= 1) {
751 if ((
ctx->
teletext_lines & line_mask) && vanc->GetBufferForVerticalBlankingLine(i, (
void**)&buf) ==
S_OK) {
752 if (vanc_format == bmdFormat8BitYUV)
753 txt_buf = teletext_data_unit_from_vbi_data(i, buf, txt_buf, VBI_PIXFMT_UYVY);
755 txt_buf = teletext_data_unit_from_vbi_data_10bit(i, buf, txt_buf);
762 if (vanc_format == bmdFormat10BitYUV && videoFrame->GetWidth() <=
MAX_WIDTH_VANC) {
764 for (i = vanc_line_numbers[idx].vanc_start; i <= vanc_line_numbers[idx].
vanc_end; i++) {
766 if (vanc->GetBufferForVerticalBlankingLine(i, (
void**)&buf) ==
S_OK) {
768 size_t vanc_size = videoFrame->GetWidth();
770 vanc_size = vanc_size * 2;
776 txt_buf,
sizeof(txt_buf0) - (txt_buf - txt_buf0), &pkt);
778 if (i == vanc_line_numbers[idx].field0_vanc_end)
783 if (txt_buf - txt_buf0 > 1) {
784 int stuffing_units = (4 - ((45 + txt_buf - txt_buf0) / 46) % 4) % 4;
785 while (stuffing_units--) {
786 memset(txt_buf, 0xff, 46);
794 txt_pkt.
data = txt_buf0;
795 txt_pkt.
size = txt_buf - txt_buf0;
811 BMDTimeValue audio_pts;
816 audioFrame->GetBytes(&audioFrameBytes);
835 BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *
mode,
836 BMDDetectedVideoInputFormatFlags)
847 if (ctx->
attr->GetFlag(BMDDeckLinkSupportsInputFormatDetection, &autodetect_supported) !=
S_OK)
849 if (autodetect_supported ==
false)
856 bmdVideoInputEnableFormatDetection) !=
S_OK) {
860 if (ctx->
dli->StartStreams() !=
S_OK) {
865 for (i = 0; i < 10; i++) {
870 if (ctx->
bmd_mode != bmdModeUnknown &&
875 ctx->
dli->PauseStreams();
876 ctx->
dli->FlushStreams();
878 if (ctx->
bmd_mode != bmdModeUnknown) {
897 if (
ctx->capture_started) {
898 ctx->dli->StopStreams();
899 ctx->dli->DisableVideoInput();
900 ctx->dli->DisableAudioInput();
957 av_log(avctx,
AV_LOG_ERROR,
"Value for audio bit depth option must be either 16 or 32\n");
962 if (
ctx->list_devices) {
968 av_log(avctx,
AV_LOG_WARNING,
"The bm_v210 option is deprecated and will be removed. Please use the -raw_format yuv422p10.\n");
973 tmp=strchr (fname,
'@');
975 av_log(avctx,
AV_LOG_WARNING,
"The @mode syntax is deprecated and will be removed. Please use the -format_code option.\n");
976 mode_num = atoi (
tmp+1);
985 if (
ctx->dl->QueryInterface(IID_IDeckLinkInput, (
void **) &
ctx->dli) !=
S_OK) {
993 if (
ctx->list_formats) {
1006 ctx->dli->SetCallback(
ctx->input_callback);
1017 av_log(avctx,
AV_LOG_ERROR,
"Could not set mode number %d or format code %s for %s\n",
1024 if (
ctx->teletext_lines &&
ctx->bmd_mode == bmdModePAL) {
1025 av_log(avctx,
AV_LOG_ERROR,
"Libzvbi support is needed for capturing SD PAL teletext, please recompile FFmpeg.\n");
1040 st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
1052 st->codecpar->width =
ctx->bmd_width;
1053 st->codecpar->height =
ctx->bmd_height;
1055 st->time_base.den =
ctx->bmd_tb_den;
1056 st->time_base.num =
ctx->bmd_tb_num;
1057 st->r_frame_rate =
av_make_q(st->time_base.den, st->time_base.num);
1060 case bmdFormat8BitYUV:
1062 st->codecpar->codec_tag =
MKTAG(
'U',
'Y',
'V',
'Y');
1064 st->codecpar->bit_rate =
av_rescale(
ctx->bmd_width *
ctx->bmd_height * 16, st->time_base.den, st->time_base.num);
1066 case bmdFormat10BitYUV:
1068 st->codecpar->codec_tag =
MKTAG(
'V',
'2',
'1',
'0');
1069 st->codecpar->bit_rate =
av_rescale(
ctx->bmd_width *
ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
1070 st->codecpar->bits_per_coded_sample = 10;
1072 case bmdFormat8BitARGB:
1076 st->codecpar->bit_rate =
av_rescale(
ctx->bmd_width *
ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
1078 case bmdFormat8BitBGRA:
1082 st->codecpar->bit_rate =
av_rescale(
ctx->bmd_width *
ctx->bmd_height * 32, st->time_base.den, st->time_base.num);
1084 case bmdFormat10BitRGB:
1086 st->codecpar->codec_tag =
MKTAG(
'R',
'2',
'1',
'0');
1088 st->codecpar->bit_rate =
av_rescale(
ctx->bmd_width *
ctx->bmd_height * 30, st->time_base.den, st->time_base.num);
1089 st->codecpar->bits_per_coded_sample = 10;
1097 switch (
ctx->bmd_field_dominance) {
1098 case bmdUpperFieldFirst:
1101 case bmdLowerFieldFirst:
1104 case bmdProgressiveFrame:
1105 case bmdProgressiveSegmentedFrame:
1114 if (
ctx->teletext_lines) {
1122 st->time_base.den =
ctx->bmd_tb_den;
1123 st->time_base.num =
ctx->bmd_tb_num;
1126 ctx->teletext_st = st;
1130 result =
ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, cctx->
audio_depth == 32 ? bmdAudioSampleType32bitInteger : bmdAudioSampleType16bitInteger,
ctx->audio_st->codecpar->channels);
1132 if (result !=
S_OK) {
1138 result =
ctx->dli->EnableVideoInput(
ctx->bmd_mode,
1140 bmdVideoInputFlagDefault);
1142 if (result !=
S_OK) {
1150 if (
ctx->dli->StartStreams() !=
S_OK) {
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
static int decklink_autodetect(struct decklink_cctx *cctx)
static int shift(int a, int b)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame, int64_t wallclock, int64_t abs_wallclock, DecklinkPtsSource pts_src, AVRational time_base, int64_t *initial_pts, int copyts)
#define pthread_mutex_lock(a)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
ptrdiff_t const GLvoid * data
static uint8_t calc_parity_and_line_offset(int line)
#define AV_LOG_WARNING
Something somehow does not look correct.
const uint8_t ff_reverse[256]
ATSC A53 Part 4 Closed Captions.
int index
stream index in AVFormatContext
Convenience header that includes libavutil's core.
static void avpacket_queue_init(AVFormatContext *avctx, AVPacketQueue *q)
int ff_decklink_init_device(AVFormatContext *avctx, const char *name)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_usleep(unsigned usec)
Sleep for a period of time.
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
DecklinkPtsSource audio_pts_source
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const BMDVideoConnection decklink_video_connection_map[]
const BMDDisplayMode AUTODETECT_DEFAULT_MODE
DecklinkPtsSource audio_pts_source
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
static void fill_data_unit_head(int line, uint8_t *tgt)
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt)
Return a value representing the fourCC code associated to the pixel format pix_fmt, or 0 if no associated fourCC code can be found.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
IDeckLinkAttributes * attr
static const BMDAudioConnection decklink_audio_connection_map[]
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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 num)
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
#define AV_LOG_VERBOSE
Detailed information.
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
static uint8_t * vanc_to_cc(AVFormatContext *avctx, uint16_t *buf, size_t words, unsigned &cc_count)
int ff_decklink_list_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list, int show_inputs, int show_outputs)
static int get_vanc_line_idx(BMDDisplayMode mode)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Main libavdevice API header.
static void avpacket_queue_flush(AVPacketQueue *q)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
char * url
input or output URL.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
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_close(AVFormatContext *avctx)
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int flags
A combination of AV_PKT_FLAG values.
int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
int ff_decklink_list_input_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list)
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction)
#define pthread_mutex_unlock(a)
static volatile int checksum
static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static void extract_luma_from_v210(uint16_t *dst, const uint8_t *src, int width)
static void error(const char *err)
#define FF_ARRAY_ELEMS(a)
static uint8_t * get_metadata(AVFormatContext *avctx, uint16_t *buf, size_t width, uint8_t *tgt, size_t tgt_size, AVPacket *pkt)
int64_t av_gettime(void)
Get the current time in microseconds.
#define AV_LOG_INFO
Standard information.
static AVRational av_make_q(int num, int den)
Create an AVRational.
DecklinkPtsSource video_pts_source
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static uint8_t * teletext_data_unit_from_op47_vbi_packet(int line, uint16_t *py, uint8_t *tgt)
static int avpacket_queue_get(AVPacketQueue *q, AVPacket *pkt, int block)
Rational number (pair of numerator and denominator).
static int linemask_matches(int line, int64_t mask)
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.
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
void ff_decklink_cleanup(AVFormatContext *avctx)
static int check_vanc_parity_checksum(uint16_t *buf, int len, uint16_t checksum)
static void avpacket_queue_end(AVPacketQueue *q)
struct AVPacketList * next
common internal and external API header
static unsigned long long avpacket_queue_size(AVPacketQueue *q)
int ff_decklink_read_packet(AVFormatContext *avctx, AVPacket *pkt)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define MKBETAG(a, b, c, d)
static void clear_parity_bits(uint16_t *buf, int len)
void * priv_data
Format private data.
av_cold int ff_decklink_read_header(AVFormatContext *avctx)
static void unpack_v210(uint16_t *dst, const uint8_t *src, int width)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
static VANCLineNumber vanc_line_numbers[]
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
DecklinkPtsSource video_pts_source
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static uint8_t * teletext_data_unit_from_op47_data(uint16_t *py, uint16_t *pend, uint8_t *tgt, int64_t wanted_lines)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define MKTAG(a, b, c, d)
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
AVPixelFormat
Pixel format.
This structure stores compressed data.
mode
Use these values in ebur128_init (or'ed).
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.