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 output
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/imgutils.h"
32 #if CONFIG_LIBZVBI
33 #include <libzvbi.h>
34 #endif
35 }
36 
37 #include "decklink_common.h"
38 #include "decklink_dec.h"
39 
40 #if CONFIG_LIBZVBI
41 static uint8_t calc_parity_and_line_offset(int line)
42 {
43  uint8_t ret = (line < 313) << 5;
44  if (line >= 7 && line <= 22)
45  ret += line;
46  if (line >= 320 && line <= 335)
47  ret += (line - 313);
48  return ret;
49 }
50 
51 int teletext_data_unit_from_vbi_data(int line, uint8_t *src, uint8_t *tgt)
52 {
53  vbi_bit_slicer slicer;
54 
55  vbi_bit_slicer_init(&slicer, 720, 13500000, 6937500, 6937500, 0x00aaaae4, 0xffff, 18, 6, 42 * 8, VBI_MODULATION_NRZ_MSB, VBI_PIXFMT_UYVY);
56 
57  if (vbi_bit_slice(&slicer, src, tgt + 4) == FALSE)
58  return -1;
59 
60  tgt[0] = 0x02; // data_unit_id
61  tgt[1] = 0x2c; // data_unit_length
62  tgt[2] = calc_parity_and_line_offset(line); // field_parity, line_offset
63  tgt[3] = 0xe4; // framing code
64 
65  return 0;
66 }
67 #endif
68 
70 {
71  memset(q, 0, sizeof(AVPacketQueue));
74  q->avctx = avctx;
75 }
76 
78 {
79  AVPacketList *pkt, *pkt1;
80 
82  for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
83  pkt1 = pkt->next;
84  av_packet_unref(&pkt->pkt);
85  av_freep(&pkt);
86  }
87  q->last_pkt = NULL;
88  q->first_pkt = NULL;
89  q->nb_packets = 0;
90  q->size = 0;
92 }
93 
95 {
99 }
100 
101 static unsigned long long avpacket_queue_size(AVPacketQueue *q)
102 {
103  unsigned long long size;
105  size = q->size;
107  return size;
108 }
109 
111 {
112  AVPacketList *pkt1;
113 
114  // Drop Packet if queue size is > 1GB
115  if (avpacket_queue_size(q) > 1024 * 1024 * 1024 ) {
116  av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer overrun!\n");
117  return -1;
118  }
119  /* duplicate the packet */
120  if (av_dup_packet(pkt) < 0) {
121  return -1;
122  }
123 
124  pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
125  if (!pkt1) {
126  return -1;
127  }
128  pkt1->pkt = *pkt;
129  pkt1->next = NULL;
130 
132 
133  if (!q->last_pkt) {
134  q->first_pkt = pkt1;
135  } else {
136  q->last_pkt->next = pkt1;
137  }
138 
139  q->last_pkt = pkt1;
140  q->nb_packets++;
141  q->size += pkt1->pkt.size + sizeof(*pkt1);
142 
144 
146  return 0;
147 }
148 
150 {
151  AVPacketList *pkt1;
152  int ret;
153 
155 
156  for (;; ) {
157  pkt1 = q->first_pkt;
158  if (pkt1) {
159  q->first_pkt = pkt1->next;
160  if (!q->first_pkt) {
161  q->last_pkt = NULL;
162  }
163  q->nb_packets--;
164  q->size -= pkt1->pkt.size + sizeof(*pkt1);
165  *pkt = pkt1->pkt;
166  av_free(pkt1);
167  ret = 1;
168  break;
169  } else if (!block) {
170  ret = 0;
171  break;
172  } else {
173  pthread_cond_wait(&q->cond, &q->mutex);
174  }
175  }
177  return ret;
178 }
179 
180 class decklink_input_callback : public IDeckLinkInputCallback
181 {
182 public:
185 
186  virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
187  virtual ULONG STDMETHODCALLTYPE AddRef(void);
188  virtual ULONG STDMETHODCALLTYPE Release(void);
189  virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
190  virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);
191 
192 private:
197  int no_video;
200 };
201 
203 {
204  avctx = _avctx;
205  decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
206  ctx = (struct decklink_ctx *) cctx->ctx;
209 }
210 
212 {
214 }
215 
217 {
219  m_refCount++;
221 
222  return (ULONG)m_refCount;
223 }
224 
226 {
228  m_refCount--;
230 
231  if (m_refCount == 0) {
232  delete this;
233  return 0;
234  }
235 
236  return (ULONG)m_refCount;
237 }
238 
240  IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame)
241 {
242  void *frameBytes;
243  void *audioFrameBytes;
244  BMDTimeValue frameTime;
245  BMDTimeValue frameDuration;
246 
247  ctx->frameCount++;
248 
249  // Handle Video Frame
250  if (videoFrame) {
251  AVPacket pkt;
252  av_init_packet(&pkt);
253  if (ctx->frameCount % 25 == 0) {
254  unsigned long long qsize = avpacket_queue_size(&ctx->queue);
256  "Frame received (#%lu) - Valid (%liB) - QSize %fMB\n",
257  ctx->frameCount,
258  videoFrame->GetRowBytes() * videoFrame->GetHeight(),
259  (double)qsize / 1024 / 1024);
260  }
261 
262  videoFrame->GetBytes(&frameBytes);
263  videoFrame->GetStreamTime(&frameTime, &frameDuration,
265 
266  if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) {
267  if (videoFrame->GetPixelFormat() == bmdFormat8BitYUV) {
268  unsigned bars[8] = {
269  0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035,
270  0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 };
271  int width = videoFrame->GetWidth();
272  int height = videoFrame->GetHeight();
273  unsigned *p = (unsigned *)frameBytes;
274 
275  for (int y = 0; y < height; y++) {
276  for (int x = 0; x < width; x += 2)
277  *p++ = bars[(x * 8) / width];
278  }
279  }
280 
281  if (!no_video) {
282  av_log(avctx, AV_LOG_WARNING, "Frame received (#%lu) - No input signal detected "
283  "- Frames dropped %u\n", ctx->frameCount, ++ctx->dropped);
284  }
285  no_video = 1;
286  } else {
287  if (no_video) {
288  av_log(avctx, AV_LOG_WARNING, "Frame received (#%lu) - Input returned "
289  "- Frames dropped %u\n", ctx->frameCount, ++ctx->dropped);
290  }
291  no_video = 0;
292  }
293 
294  pkt.pts = frameTime / ctx->video_st->time_base.num;
295 
297  initial_video_pts = pkt.pts;
298  }
299 
300  pkt.pts -= initial_video_pts;
301  pkt.dts = pkt.pts;
302 
303  pkt.duration = frameDuration;
304  //To be made sure it still applies
305  pkt.flags |= AV_PKT_FLAG_KEY;
306  pkt.stream_index = ctx->video_st->index;
307  pkt.data = (uint8_t *)frameBytes;
308  pkt.size = videoFrame->GetRowBytes() *
309  videoFrame->GetHeight();
310  //fprintf(stderr,"Video Frame size %d ts %d\n", pkt.size, pkt.pts);
311 
312 #if CONFIG_LIBZVBI
313  if (!no_video && ctx->teletext_lines && videoFrame->GetPixelFormat() == bmdFormat8BitYUV && videoFrame->GetWidth() == 720) {
314  IDeckLinkVideoFrameAncillary *vanc;
315  AVPacket txt_pkt;
316  uint8_t txt_buf0[1611]; // max 35 * 46 bytes decoded teletext lines + 1 byte data_identifier
317  uint8_t *txt_buf = txt_buf0;
318 
319  if (videoFrame->GetAncillaryData(&vanc) == S_OK) {
320  int i;
321  int64_t line_mask = 1;
322  txt_buf[0] = 0x10; // data_identifier - EBU_data
323  txt_buf++;
324  for (i = 6; i < 336; i++, line_mask <<= 1) {
325  uint8_t *buf;
326  if ((ctx->teletext_lines & line_mask) && vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) {
327  if (teletext_data_unit_from_vbi_data(i, buf, txt_buf) >= 0)
328  txt_buf += 46;
329  }
330  if (i == 22)
331  i = 317;
332  }
333  vanc->Release();
334  if (txt_buf - txt_buf0 > 1) {
335  int stuffing_units = (4 - ((45 + txt_buf - txt_buf0) / 46) % 4) % 4;
336  while (stuffing_units--) {
337  memset(txt_buf, 0xff, 46);
338  txt_buf[1] = 0x2c; // data_unit_length
339  txt_buf += 46;
340  }
341  av_init_packet(&txt_pkt);
342  txt_pkt.pts = pkt.pts;
343  txt_pkt.dts = pkt.dts;
344  txt_pkt.stream_index = ctx->teletext_st->index;
345  txt_pkt.data = txt_buf0;
346  txt_pkt.size = txt_buf - txt_buf0;
347  if (avpacket_queue_put(&ctx->queue, &txt_pkt) < 0) {
348  ++ctx->dropped;
349  }
350  }
351  }
352  }
353 #endif
354 
355  if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
356  ++ctx->dropped;
357  }
358  }
359 
360  // Handle Audio Frame
361  if (audioFrame) {
362  AVPacket pkt;
363  BMDTimeValue audio_pts;
364  av_init_packet(&pkt);
365 
366  //hack among hacks
367  pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (16 / 8);
368  audioFrame->GetBytes(&audioFrameBytes);
369  audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den);
370  pkt.pts = audio_pts / ctx->audio_st->time_base.num;
371 
373  initial_audio_pts = pkt.pts;
374  }
375 
376  pkt.pts -= initial_audio_pts;
377  pkt.dts = pkt.pts;
378 
379  //fprintf(stderr,"Audio Frame size %d ts %d\n", pkt.size, pkt.pts);
380  pkt.flags |= AV_PKT_FLAG_KEY;
381  pkt.stream_index = ctx->audio_st->index;
382  pkt.data = (uint8_t *)audioFrameBytes;
383 
384  if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
385  ++ctx->dropped;
386  }
387  }
388 
389  return S_OK;
390 }
391 
393  BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode *mode,
394  BMDDetectedVideoInputFormatFlags)
395 {
396  return S_OK;
397 }
398 
400 {
401  struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
402  struct decklink_ctx *ctx = (struct decklink_ctx *) cctx->ctx;
403 
404  ctx->input_callback = new decklink_input_callback(avctx);
405  ctx->dli->SetCallback(ctx->input_callback);
406  return ctx->dli->StartStreams();
407 }
408 
409 extern "C" {
410 
412 {
413  struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
414  struct decklink_ctx *ctx = (struct decklink_ctx *) cctx->ctx;
415 
416  if (ctx->capture_started) {
417  ctx->dli->StopStreams();
418  ctx->dli->DisableVideoInput();
419  ctx->dli->DisableAudioInput();
420  }
421 
422  if (ctx->dli)
423  ctx->dli->Release();
424  if (ctx->dl)
425  ctx->dl->Release();
426 
427  avpacket_queue_end(&ctx->queue);
428 
429  av_freep(&cctx->ctx);
430 
431  return 0;
432 }
433 
435 {
436  struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
437  struct decklink_ctx *ctx;
438  IDeckLinkDisplayModeIterator *itermode;
439  IDeckLinkIterator *iter;
440  IDeckLink *dl = NULL;
441  AVStream *st;
442  HRESULT result;
443  char fname[1024];
444  char *tmp;
445  int mode_num = 0;
446 
447  ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx));
448  if (!ctx)
449  return AVERROR(ENOMEM);
450  ctx->list_devices = cctx->list_devices;
451  ctx->list_formats = cctx->list_formats;
452  ctx->teletext_lines = cctx->teletext_lines;
453  ctx->preroll = cctx->preroll;
454  cctx->ctx = ctx;
455 
456 #if !CONFIG_LIBZVBI
457  if (ctx->teletext_lines) {
458  av_log(avctx, AV_LOG_ERROR, "Libzvbi support is needed for capturing teletext, please recompile FFmpeg.\n");
459  return AVERROR(ENOSYS);
460  }
461 #endif
462 
463  /* Check audio channel option for valid values: 2, 8 or 16 */
464  switch (cctx->audio_channels) {
465  case 2:
466  case 8:
467  case 16:
468  break;
469  default:
470  av_log(avctx, AV_LOG_ERROR, "Value of channels option must be one of 2, 8 or 16\n");
471  return AVERROR(EINVAL);
472  }
473 
474  iter = CreateDeckLinkIteratorInstance();
475  if (!iter) {
476  av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
477  return AVERROR(EIO);
478  }
479 
480  /* List available devices. */
481  if (ctx->list_devices) {
483  return AVERROR_EXIT;
484  }
485 
486  strcpy (fname, avctx->filename);
487  tmp=strchr (fname, '@');
488  if (tmp != NULL) {
489  mode_num = atoi (tmp+1);
490  *tmp = 0;
491  }
492 
493  /* Open device. */
494  while (iter->Next(&dl) == S_OK) {
495  const char *displayName;
496  ff_decklink_get_display_name(dl, &displayName);
497  if (!strcmp(fname, displayName)) {
498  av_free((void *) displayName);
499  ctx->dl = dl;
500  break;
501  }
502  av_free((void *) displayName);
503  dl->Release();
504  }
505  iter->Release();
506  if (!ctx->dl) {
507  av_log(avctx, AV_LOG_ERROR, "Could not open '%s'\n", fname);
508  return AVERROR(EIO);
509  }
510 
511  /* Get input device. */
512  if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
513  av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
514  avctx->filename);
515  ctx->dl->Release();
516  return AVERROR(EIO);
517  }
518 
519  /* List supported formats. */
520  if (ctx->list_formats) {
522  ctx->dli->Release();
523  ctx->dl->Release();
524  return AVERROR_EXIT;
525  }
526 
527  if (ctx->dli->GetDisplayModeIterator(&itermode) != S_OK) {
528  av_log(avctx, AV_LOG_ERROR, "Could not get Display Mode Iterator\n");
529  ctx->dl->Release();
530  return AVERROR(EIO);
531  }
532 
533  if (mode_num > 0) {
534  if (ff_decklink_set_format(avctx, DIRECTION_IN, mode_num) < 0) {
535  av_log(avctx, AV_LOG_ERROR, "Could not set mode %d for %s\n", mode_num, fname);
536  goto error;
537  }
538  }
539 
540  itermode->Release();
541 
542  /* Setup streams. */
543  st = avformat_new_stream(avctx, NULL);
544  if (!st) {
545  av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
546  goto error;
547  }
548  st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
549  st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
550  st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
551  st->codecpar->channels = cctx->audio_channels;
552  avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
553  ctx->audio_st=st;
554 
555  st = avformat_new_stream(avctx, NULL);
556  if (!st) {
557  av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
558  goto error;
559  }
560  st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
561  st->codecpar->width = ctx->bmd_width;
562  st->codecpar->height = ctx->bmd_height;
563 
564  st->time_base.den = ctx->bmd_tb_den;
565  st->time_base.num = ctx->bmd_tb_num;
566  st->codecpar->bit_rate = av_image_get_buffer_size((AVPixelFormat)st->codecpar->format, ctx->bmd_width, ctx->bmd_height, 1) * 1/av_q2d(st->time_base) * 8;
567 
568  if (cctx->v210) {
569  st->codecpar->codec_id = AV_CODEC_ID_V210;
570  st->codecpar->codec_tag = MKTAG('V', '2', '1', '0');
571  } else {
572  st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
573  st->codecpar->format = AV_PIX_FMT_UYVY422;
574  st->codecpar->codec_tag = MKTAG('U', 'Y', 'V', 'Y');
575  }
576 
577  avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
578 
579  ctx->video_st=st;
580 
581  if (ctx->teletext_lines) {
582  st = avformat_new_stream(avctx, NULL);
583  if (!st) {
584  av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
585  goto error;
586  }
587  st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
588  st->time_base.den = ctx->bmd_tb_den;
589  st->time_base.num = ctx->bmd_tb_num;
590  st->codecpar->codec_id = AV_CODEC_ID_DVB_TELETEXT;
591  avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
592  ctx->teletext_st = st;
593  }
594 
595  av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codecpar->channels);
596  result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels);
597 
598  if (result != S_OK) {
599  av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n");
600  goto error;
601  }
602 
603  result = ctx->dli->EnableVideoInput(ctx->bmd_mode,
604  cctx->v210 ? bmdFormat10BitYUV : bmdFormat8BitYUV,
605  bmdVideoInputFlagDefault);
606 
607  if (result != S_OK) {
608  av_log(avctx, AV_LOG_ERROR, "Cannot enable video input\n");
609  goto error;
610  }
611 
612  avpacket_queue_init (avctx, &ctx->queue);
613 
614  if (decklink_start_input (avctx) != S_OK) {
615  av_log(avctx, AV_LOG_ERROR, "Cannot start input stream\n");
616  goto error;
617  }
618 
619  return 0;
620 
621 error:
622 
623  ctx->dli->Release();
624  ctx->dl->Release();
625 
626  return AVERROR(EIO);
627 }
628 
630 {
631  struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
632  struct decklink_ctx *ctx = (struct decklink_ctx *) cctx->ctx;
633  AVFrame *frame = ctx->video_st->codec->coded_frame;
634 
635  avpacket_queue_get(&ctx->queue, pkt, 1);
636  if (frame && (ctx->bmd_field_dominance == bmdUpperFieldFirst || ctx->bmd_field_dominance == bmdLowerFieldFirst)) {
637  frame->interlaced_frame = 1;
638  if (ctx->bmd_field_dominance == bmdUpperFieldFirst) {
639  frame->top_field_first = 1;
640  }
641  }
642 
643  return 0;
644 }
645 
646 } /* 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:184
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:4427
int num
numerator
Definition: rational.h:44
int index
stream index in AVFormatContext
Definition: avformat.h:877
int size
Definition: avcodec.h:1581
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1427
static AVPacket pkt
pthread_cond_t cond
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
Definition: os2threads.h:138
Format I/O context.
Definition: avformat.h:1325
static int16_t block[64]
Definition: dct.c:113
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
mode
Definition: f_perms.c:27
AVPacket pkt
Definition: avformat.h:1933
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1598
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4065
static AVFrame * frame
#define height
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:80
uint8_t * data
Definition: avcodec.h:1580
#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:318
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:1612
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
Definition: imgutils.c:361
#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:249
#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:1586
char filename[1024]
input or output filename
Definition: avformat.h:1401
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 src
Definition: vp9dsp.c:530
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:56
Stream structure.
Definition: avformat.h:876
void * LPVOID
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:563
void * buf
Definition: avisynth_c.h:553
AVFormatContext * avctx
DWORD HRESULT
Main libavformat public API header.
struct AVPacketList * next
Definition: avformat.h:1934
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:45
#define av_free(p)
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:323
static av_always_inline int pthread_mutex_unlock(pthread_mutex_t *mutex)
Definition: os2threads.h:120
static uint8_t tmp[8]
Definition: des.c:38
void * priv_data
Format private data.
Definition: avformat.h:1353
int channels
Audio only.
Definition: avcodec.h:4028
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1579
#define av_freep(p)
static av_always_inline int pthread_mutex_lock(pthread_mutex_t *mutex)
Definition: os2threads.h:113
AVCodecParameters * codecpar
Definition: avformat.h:1006
int stream_index
Definition: avcodec.h:1582
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:913
#define MKTAG(a, b, c, d)
Definition: common.h:342
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
This structure stores compressed data.
Definition: avcodec.h:1557
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:252
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1573
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:240