FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
decklink_dec.cpp
Go to the documentation of this file.
1 /*
2  * Blackmagic DeckLink input
3  * Copyright (c) 2013-2014 Luca Barbato, Deti Fliegl
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <DeckLinkAPI.h>
23 
24 #include <pthread.h>
25 #include <semaphore.h>
26 
27 extern "C" {
28 #include "config.h"
29 #include "libavformat/avformat.h"
30 #include "libavformat/internal.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/common.h"
33 #include "libavutil/imgutils.h"
34 #include "libavutil/time.h"
35 #include "libavutil/mathematics.h"
36 #if CONFIG_LIBZVBI
37 #include <libzvbi.h>
38 #endif
39 }
40 
41 #include "decklink_common.h"
42 #include "decklink_dec.h"
43 
44 #if CONFIG_LIBZVBI
45 static uint8_t calc_parity_and_line_offset(int line)
46 {
47  uint8_t ret = (line < 313) << 5;
48  if (line >= 7 && line <= 22)
49  ret += line;
50  if (line >= 320 && line <= 335)
51  ret += (line - 313);
52  return ret;
53 }
54 
55 int teletext_data_unit_from_vbi_data(int line, uint8_t *src, uint8_t *tgt)
56 {
57  vbi_bit_slicer slicer;
58 
59  vbi_bit_slicer_init(&slicer, 720, 13500000, 6937500, 6937500, 0x00aaaae4, 0xffff, 18, 6, 42 * 8, VBI_MODULATION_NRZ_MSB, VBI_PIXFMT_UYVY);
60 
61  if (vbi_bit_slice(&slicer, src, tgt + 4) == FALSE)
62  return -1;
63 
64  tgt[0] = 0x02; // data_unit_id
65  tgt[1] = 0x2c; // data_unit_length
66  tgt[2] = calc_parity_and_line_offset(line); // field_parity, line_offset
67  tgt[3] = 0xe4; // framing code
68 
69  return 0;
70 }
71 #endif
72 
74 {
75  memset(q, 0, sizeof(AVPacketQueue));
78  q->avctx = avctx;
79 }
80 
82 {
83  AVPacketList *pkt, *pkt1;
84 
86  for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
87  pkt1 = pkt->next;
88  av_packet_unref(&pkt->pkt);
89  av_freep(&pkt);
90  }
91  q->last_pkt = NULL;
92  q->first_pkt = NULL;
93  q->nb_packets = 0;
94  q->size = 0;
96 }
97 
99 {
103 }
104 
105 static unsigned long long avpacket_queue_size(AVPacketQueue *q)
106 {
107  unsigned long long size;
109  size = q->size;
111  return size;
112 }
113 
115 {
116  AVPacketList *pkt1;
117 
118  // Drop Packet if queue size is > 1GB
119  if (avpacket_queue_size(q) > 1024 * 1024 * 1024 ) {
120  av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer overrun!\n");
121  return -1;
122  }
123  /* duplicate the packet */
124  if (av_dup_packet(pkt) < 0) {
125  return -1;
126  }
127 
128  pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
129  if (!pkt1) {
130  return -1;
131  }
132  pkt1->pkt = *pkt;
133  pkt1->next = NULL;
134 
136 
137  if (!q->last_pkt) {
138  q->first_pkt = pkt1;
139  } else {
140  q->last_pkt->next = pkt1;
141  }
142 
143  q->last_pkt = pkt1;
144  q->nb_packets++;
145  q->size += pkt1->pkt.size + sizeof(*pkt1);
146 
148 
150  return 0;
151 }
152 
154 {
155  AVPacketList *pkt1;
156  int ret;
157 
159 
160  for (;; ) {
161  pkt1 = q->first_pkt;
162  if (pkt1) {
163  q->first_pkt = pkt1->next;
164  if (!q->first_pkt) {
165  q->last_pkt = NULL;
166  }
167  q->nb_packets--;
168  q->size -= pkt1->pkt.size + sizeof(*pkt1);
169  *pkt = pkt1->pkt;
170  av_free(pkt1);
171  ret = 1;
172  break;
173  } else if (!block) {
174  ret = 0;
175  break;
176  } else {
177  pthread_cond_wait(&q->cond, &q->mutex);
178  }
179  }
181  return ret;
182 }
183 
184 class decklink_input_callback : public IDeckLinkInputCallback
185 {
186 public:
189 
190  virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
191  virtual ULONG STDMETHODCALLTYPE AddRef(void);
192  virtual ULONG STDMETHODCALLTYPE Release(void);
193  virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
194  virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);
195 
196 private:
201  int no_video;
204 };
205 
207 {
208  avctx = _avctx;
209  decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
210  ctx = (struct decklink_ctx *)cctx->ctx;
211  no_video = 0;
214 }
215 
217 {
219 }
220 
222 {
224  m_refCount++;
226 
227  return (ULONG)m_refCount;
228 }
229 
231 {
233  m_refCount--;
235 
236  if (m_refCount == 0) {
237  delete this;
238  return 0;
239  }
240 
241  return (ULONG)m_refCount;
242 }
243 
244 static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
245  IDeckLinkAudioInputPacket *audioFrame,
246  int64_t wallclock,
247  DecklinkPtsSource pts_src,
248  AVRational time_base, int64_t *initial_pts)
249 {
250  int64_t pts = AV_NOPTS_VALUE;
251  BMDTimeValue bmd_pts;
252  BMDTimeValue bmd_duration;
253  HRESULT res = E_INVALIDARG;
254  switch (pts_src) {
255  case PTS_SRC_AUDIO:
256  if (audioFrame)
257  res = audioFrame->GetPacketTime(&bmd_pts, time_base.den);
258  break;
259  case PTS_SRC_VIDEO:
260  if (videoFrame)
261  res = videoFrame->GetStreamTime(&bmd_pts, &bmd_duration, time_base.den);
262  break;
263  case PTS_SRC_REFERENCE:
264  if (videoFrame)
265  res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, &bmd_duration);
266  break;
267  case PTS_SRC_WALLCLOCK:
268  pts = av_rescale_q(wallclock, AV_TIME_BASE_Q, time_base);
269  break;
270  }
271  if (res == S_OK)
272  pts = bmd_pts / time_base.num;
273 
274  if (pts != AV_NOPTS_VALUE && *initial_pts == AV_NOPTS_VALUE)
275  *initial_pts = pts;
276  if (*initial_pts != AV_NOPTS_VALUE)
277  pts -= *initial_pts;
278 
279  return pts;
280 }
281 
283  IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame)
284 {
285  void *frameBytes;
286  void *audioFrameBytes;
287  BMDTimeValue frameTime;
288  BMDTimeValue frameDuration;
289  int64_t wallclock = 0;
290 
291  ctx->frameCount++;
293  wallclock = av_gettime_relative();
294 
295  // Handle Video Frame
296  if (videoFrame) {
297  AVPacket pkt;
298  av_init_packet(&pkt);
299  if (ctx->frameCount % 25 == 0) {
300  unsigned long long qsize = avpacket_queue_size(&ctx->queue);
302  "Frame received (#%lu) - Valid (%liB) - QSize %fMB\n",
303  ctx->frameCount,
304  videoFrame->GetRowBytes() * videoFrame->GetHeight(),
305  (double)qsize / 1024 / 1024);
306  }
307 
308  videoFrame->GetBytes(&frameBytes);
309  videoFrame->GetStreamTime(&frameTime, &frameDuration,
311 
312  if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) {
313  if (ctx->draw_bars && videoFrame->GetPixelFormat() == bmdFormat8BitYUV) {
314  unsigned bars[8] = {
315  0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035,
316  0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 };
317  int width = videoFrame->GetWidth();
318  int height = videoFrame->GetHeight();
319  unsigned *p = (unsigned *)frameBytes;
320 
321  for (int y = 0; y < height; y++) {
322  for (int x = 0; x < width; x += 2)
323  *p++ = bars[(x * 8) / width];
324  }
325  }
326 
327  if (!no_video) {
328  av_log(avctx, AV_LOG_WARNING, "Frame received (#%lu) - No input signal detected "
329  "- Frames dropped %u\n", ctx->frameCount, ++ctx->dropped);
330  }
331  no_video = 1;
332  } else {
333  if (no_video) {
334  av_log(avctx, AV_LOG_WARNING, "Frame received (#%lu) - Input returned "
335  "- Frames dropped %u\n", ctx->frameCount, ++ctx->dropped);
336  }
337  no_video = 0;
338  }
339 
340  pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->video_pts_source, ctx->video_st->time_base, &initial_video_pts);
341  pkt.dts = pkt.pts;
342 
343  pkt.duration = frameDuration;
344  //To be made sure it still applies
345  pkt.flags |= AV_PKT_FLAG_KEY;
346  pkt.stream_index = ctx->video_st->index;
347  pkt.data = (uint8_t *)frameBytes;
348  pkt.size = videoFrame->GetRowBytes() *
349  videoFrame->GetHeight();
350  //fprintf(stderr,"Video Frame size %d ts %d\n", pkt.size, pkt.pts);
351 
352 #if CONFIG_LIBZVBI
353  if (!no_video && ctx->teletext_lines && videoFrame->GetPixelFormat() == bmdFormat8BitYUV && videoFrame->GetWidth() == 720) {
354  IDeckLinkVideoFrameAncillary *vanc;
355  AVPacket txt_pkt;
356  uint8_t txt_buf0[1611]; // max 35 * 46 bytes decoded teletext lines + 1 byte data_identifier
357  uint8_t *txt_buf = txt_buf0;
358 
359  if (videoFrame->GetAncillaryData(&vanc) == S_OK) {
360  int i;
361  int64_t line_mask = 1;
362  txt_buf[0] = 0x10; // data_identifier - EBU_data
363  txt_buf++;
364  for (i = 6; i < 336; i++, line_mask <<= 1) {
365  uint8_t *buf;
366  if ((ctx->teletext_lines & line_mask) && vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) {
367  if (teletext_data_unit_from_vbi_data(i, buf, txt_buf) >= 0)
368  txt_buf += 46;
369  }
370  if (i == 22)
371  i = 317;
372  }
373  vanc->Release();
374  if (txt_buf - txt_buf0 > 1) {
375  int stuffing_units = (4 - ((45 + txt_buf - txt_buf0) / 46) % 4) % 4;
376  while (stuffing_units--) {
377  memset(txt_buf, 0xff, 46);
378  txt_buf[1] = 0x2c; // data_unit_length
379  txt_buf += 46;
380  }
381  av_init_packet(&txt_pkt);
382  txt_pkt.pts = pkt.pts;
383  txt_pkt.dts = pkt.dts;
384  txt_pkt.stream_index = ctx->teletext_st->index;
385  txt_pkt.data = txt_buf0;
386  txt_pkt.size = txt_buf - txt_buf0;
387  if (avpacket_queue_put(&ctx->queue, &txt_pkt) < 0) {
388  ++ctx->dropped;
389  }
390  }
391  }
392  }
393 #endif
394 
395  if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
396  ++ctx->dropped;
397  }
398  }
399 
400  // Handle Audio Frame
401  if (audioFrame) {
402  AVPacket pkt;
403  BMDTimeValue audio_pts;
404  av_init_packet(&pkt);
405 
406  //hack among hacks
407  pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (16 / 8);
408  audioFrame->GetBytes(&audioFrameBytes);
409  audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);
410  pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts);
411  pkt.dts = pkt.pts;
412 
413  //fprintf(stderr,"Audio Frame size %d ts %d\n", pkt.size, pkt.pts);
414  pkt.flags |= AV_PKT_FLAG_KEY;
415  pkt.stream_index = ctx->audio_st->index;
416  pkt.data = (uint8_t *)audioFrameBytes;
417 
418  if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
419  ++ctx->dropped;
420  }
421  }
422 
423  return S_OK;
424 }
425 
427  BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode,
428  BMDDetectedVideoInputFormatFlags)
429 {
430  return S_OK;
431 }
432 
434 {
435  struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
436  struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
437 
438  ctx->input_callback = new decklink_input_callback(avctx);
439  ctx->dli->SetCallback(ctx->input_callback);
440  return ctx->dli->StartStreams();
441 }
442 
443 extern "C" {
444 
446 {
447  struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
448  struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
449 
450  if (ctx->capture_started) {
451  ctx->dli->StopStreams();
452  ctx->dli->DisableVideoInput();
453  ctx->dli->DisableAudioInput();
454  }
455 
456  ff_decklink_cleanup(avctx);
457  avpacket_queue_end(&ctx->queue);
458 
459  av_freep(&cctx->ctx);
460 
461  return 0;
462 }
463 
465 {
466  struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
467  struct decklink_ctx *ctx;
468  AVStream *st;
469  HRESULT result;
470  char fname[1024];
471  char *tmp;
472  int mode_num = 0;
473  int ret;
474 
475  ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx));
476  if (!ctx)
477  return AVERROR(ENOMEM);
478  ctx->list_devices = cctx->list_devices;
479  ctx->list_formats = cctx->list_formats;
480  ctx->teletext_lines = cctx->teletext_lines;
481  ctx->preroll = cctx->preroll;
482  ctx->duplex_mode = cctx->duplex_mode;
483  if (cctx->video_input > 0 && (unsigned int)cctx->video_input < FF_ARRAY_ELEMS(decklink_video_connection_map))
484  ctx->video_input = decklink_video_connection_map[cctx->video_input];
485  if (cctx->audio_input > 0 && (unsigned int)cctx->audio_input < FF_ARRAY_ELEMS(decklink_audio_connection_map))
486  ctx->audio_input = decklink_audio_connection_map[cctx->audio_input];
487  ctx->audio_pts_source = cctx->audio_pts_source;
488  ctx->video_pts_source = cctx->video_pts_source;
489  ctx->draw_bars = cctx->draw_bars;
490  cctx->ctx = ctx;
491 
492 #if !CONFIG_LIBZVBI
493  if (ctx->teletext_lines) {
494  av_log(avctx, AV_LOG_ERROR, "Libzvbi support is needed for capturing teletext, please recompile FFmpeg.\n");
495  return AVERROR(ENOSYS);
496  }
497 #endif
498 
499  /* Check audio channel option for valid values: 2, 8 or 16 */
500  switch (cctx->audio_channels) {
501  case 2:
502  case 8:
503  case 16:
504  break;
505  default:
506  av_log(avctx, AV_LOG_ERROR, "Value of channels option must be one of 2, 8 or 16\n");
507  return AVERROR(EINVAL);
508  }
509 
510  /* List available devices. */
511  if (ctx->list_devices) {
513  return AVERROR_EXIT;
514  }
515 
516  strcpy (fname, avctx->filename);
517  tmp=strchr (fname, '@');
518  if (tmp != NULL) {
519  av_log(avctx, AV_LOG_WARNING, "The @mode syntax is deprecated and will be removed. Please use the -format_code option.\n");
520  mode_num = atoi (tmp+1);
521  *tmp = 0;
522  }
523 
524  ret = ff_decklink_init_device(avctx, fname);
525  if (ret < 0)
526  return ret;
527 
528  /* Get input device. */
529  if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
530  av_log(avctx, AV_LOG_ERROR, "Could not open input device from '%s'\n",
531  avctx->filename);
532  ret = AVERROR(EIO);
533  goto error;
534  }
535 
536  /* List supported formats. */
537  if (ctx->list_formats) {
539  ret = AVERROR_EXIT;
540  goto error;
541  }
542 
543  if (mode_num > 0 || cctx->format_code) {
544  if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
545  av_log(avctx, AV_LOG_ERROR, "Could not set mode number %d or format code %s for %s\n",
546  mode_num, (cctx->format_code) ? cctx->format_code : "(unset)", fname);
547  ret = AVERROR(EIO);
548  goto error;
549  }
550  }
551 
552  /* Setup streams. */
553  st = avformat_new_stream(avctx, NULL);
554  if (!st) {
555  av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
556  ret = AVERROR(ENOMEM);
557  goto error;
558  }
559  st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
560  st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
561  st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
562  st->codecpar->channels = cctx->audio_channels;
563  avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
564  ctx->audio_st=st;
565 
566  st = avformat_new_stream(avctx, NULL);
567  if (!st) {
568  av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
569  ret = AVERROR(ENOMEM);
570  goto error;
571  }
572  st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
573  st->codecpar->width = ctx->bmd_width;
574  st->codecpar->height = ctx->bmd_height;
575 
576  st->time_base.den = ctx->bmd_tb_den;
577  st->time_base.num = ctx->bmd_tb_num;
578  av_stream_set_r_frame_rate(st, av_make_q(st->time_base.den, st->time_base.num));
579 
580  if (cctx->v210) {
581  st->codecpar->codec_id = AV_CODEC_ID_V210;
582  st->codecpar->codec_tag = MKTAG('V', '2', '1', '0');
583  st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
584  } else {
585  st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
586  st->codecpar->format = AV_PIX_FMT_UYVY422;
587  st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y');
588  st->codecpar->bit_rate = av_rescale(ctx->bmd_width * ctx->bmd_height * 16, st->time_base.den, st->time_base.num);
589  }
590 
591  avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
592 
593  ctx->video_st=st;
594 
595  if (ctx->teletext_lines) {
596  st = avformat_new_stream(avctx, NULL);
597  if (!st) {
598  av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
599  ret = AVERROR(ENOMEM);
600  goto error;
601  }
602  st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
603  st->time_base.den = ctx->bmd_tb_den;
604  st->time_base.num = ctx->bmd_tb_num;
605  st->codecpar->codec_id = AV_CODEC_ID_DVB_TELETEXT;
606  avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
607  ctx->teletext_st = st;
608  }
609 
610  av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codecpar->channels);
611  result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels);
612 
613  if (result != S_OK) {
614  av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
615  ret = AVERROR(EIO);
616  goto error;
617  }
618 
619  result = ctx->dli->EnableVideoInput(ctx->bmd_mode,
620  cctx->v210 ? bmdFormat10BitYUV : bmdFormat8BitYUV,
621  bmdVideoInputFlagDefault);
622 
623  if (result != S_OK) {
624  av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");
625  ret = AVERROR(EIO);
626  goto error;
627  }
628 
629  avpacket_queue_init (avctx, &ctx->queue);
630 
631  if (decklink_start_input (avctx) != S_OK) {
632  av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");
633  ret = AVERROR(EIO);
634  goto error;
635  }
636 
637  return 0;
638 
639 error:
640  ff_decklink_cleanup(avctx);
641  return ret;
642 }
643 
645 {
646  struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
647  struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
648  AVFrame *frame = ctx->video_st->codec->coded_frame;
649 
650  avpacket_queue_get(&ctx->queue, pkt, 1);
651  if (frame && (ctx->bmd_field_dominance == bmdUpperFieldFirst || ctx->bmd_field_dominance == bmdLowerFieldFirst)) {
652  frame->interlaced_frame = 1;
653  if (ctx->bmd_field_dominance == bmdUpperFieldFirst) {
654  frame->top_field_first = 1;
655  }
656  }
657 
658  return 0;
659 }
660 
661 } /* extern "C" */
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:82
#define NULL
Definition: coverity.c:32
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
Definition: os2threads.h:106
#define S_OK
Definition: windows2linux.h:40
This structure describes decoded (raw) audio or video data.
Definition: frame.h:187
#define pthread_mutex_lock(a)
Definition: ffprobe.c:60
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Definition: os2threads.h:164
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4601
void av_stream_set_r_frame_rate(AVStream *s, AVRational r)
int num
Numerator.
Definition: rational.h:59
int index
stream index in AVFormatContext
Definition: avformat.h:890
int size
Definition: avcodec.h:1658
Convenience header that includes libavutil's core.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:222
static AVPacket pkt
pthread_cond_t cond
#define src
Definition: vp8dsp.c:254
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
Definition: os2threads.h:138
Format I/O context.
Definition: avformat.h:1349
static int16_t block[64]
Definition: dct.c:115
HMTX pthread_mutex_t
Definition: os2threads.h:49
uint8_t
#define av_cold
Definition: attributes.h:82
#define av_malloc(s)
pthread_mutex_t mutex
AVPacket pkt
Definition: avformat.h:1970
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1675
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4231
static AVFrame * frame
#define height
uint8_t * data
Definition: avcodec.h:1657
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
Definition: os2threads.h:146
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:325
ptrdiff_t size
Definition: opengl_enc.c:101
#define E_NOINTERFACE
Definition: windows2linux.h:42
#define av_log(a,...)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1689
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
AVPacketList * last_pkt
#define AVERROR(e)
Definition: error.h:43
#define FALSE
Definition: windows2linux.h:37
attribute_deprecated int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:253
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
Definition: graph2dot.c:48
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1663
char filename[1024]
input or output filename
Definition: avformat.h:1425
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
AVPacketList * first_pkt
unsigned long long size
#define width
AVFormatContext * ctx
Definition: movenc.c:48
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Definition: os2threads.h:98
#define pthread_mutex_unlock(a)
Definition: ffprobe.c:64
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:56
static void error(const char *err)
#define FF_ARRAY_ELEMS(a)
Stream structure.
Definition: avformat.h:889
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
void * LPVOID
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:589
void * buf
Definition: avisynth_c.h:690
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVFormatContext * avctx
static int64_t pts
Global timestamp for the audio frames.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
Definition: time.c:56
DWORD HRESULT
Main libavformat public API header.
struct AVPacketList * next
Definition: avformat.h:1971
common internal and external API header
uint32_t ULONG
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Definition: os2threads.h:127
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:33
int den
Denominator.
Definition: rational.h:60
#define av_free(p)
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:330
void * priv_data
Format private data.
Definition: avformat.h:1377
int channels
Audio only.
Definition: avcodec.h:4172
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1656
#define av_freep(p)
AVCodecParameters * codecpar
Definition: avformat.h:1252
int stream_index
Definition: avcodec.h:1659
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:926
#define MKTAG(a, b, c, d)
Definition: common.h:342
This structure stores compressed data.
Definition: avcodec.h:1634
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1650
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
static uint8_t tmp[11]
Definition: aes_ctr.c:26