FFmpeg  3.4.9
utils.c
Go to the documentation of this file.
1 /*
2  * utils for libavcodec
3  * Copyright (c) 2001 Fabrice Bellard
4  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * utils.
26  */
27 
28 #include "config.h"
29 #include "libavutil/atomic.h"
30 #include "libavutil/attributes.h"
31 #include "libavutil/avassert.h"
32 #include "libavutil/avstring.h"
33 #include "libavutil/bprint.h"
35 #include "libavutil/crc.h"
36 #include "libavutil/frame.h"
37 #include "libavutil/hwcontext.h"
38 #include "libavutil/internal.h"
39 #include "libavutil/mathematics.h"
40 #include "libavutil/mem_internal.h"
41 #include "libavutil/pixdesc.h"
42 #include "libavutil/imgutils.h"
43 #include "libavutil/samplefmt.h"
44 #include "libavutil/dict.h"
45 #include "libavutil/thread.h"
46 #include "avcodec.h"
47 #include "decode.h"
48 #include "libavutil/opt.h"
49 #include "me_cmp.h"
50 #include "mpegvideo.h"
51 #include "thread.h"
52 #include "frame_thread_encoder.h"
53 #include "internal.h"
54 #include "raw.h"
55 #include "bytestream.h"
56 #include "version.h"
57 #include <stdlib.h>
58 #include <stdarg.h>
59 #include <limits.h>
60 #include <float.h>
61 #if CONFIG_ICONV
62 # include <iconv.h>
63 #endif
64 
65 #include "libavutil/ffversion.h"
66 const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
67 
68 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
69 static int default_lockmgr_cb(void **arg, enum AVLockOp op)
70 {
71  void * volatile * mutex = arg;
72  int err;
73 
74  switch (op) {
75  case AV_LOCK_CREATE:
76  return 0;
77  case AV_LOCK_OBTAIN:
78  if (!*mutex) {
80  if (!tmp)
81  return AVERROR(ENOMEM);
82  if ((err = pthread_mutex_init(tmp, NULL))) {
83  av_free(tmp);
84  return AVERROR(err);
85  }
86  if (avpriv_atomic_ptr_cas(mutex, NULL, tmp)) {
88  av_free(tmp);
89  }
90  }
91 
92  if ((err = pthread_mutex_lock(*mutex)))
93  return AVERROR(err);
94 
95  return 0;
96  case AV_LOCK_RELEASE:
97  if ((err = pthread_mutex_unlock(*mutex)))
98  return AVERROR(err);
99 
100  return 0;
101  case AV_LOCK_DESTROY:
102  if (*mutex)
103  pthread_mutex_destroy(*mutex);
104  av_free(*mutex);
105  avpriv_atomic_ptr_cas(mutex, *mutex, NULL);
106  return 0;
107  }
108  return 1;
109 }
110 static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = default_lockmgr_cb;
111 #else
112 static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL;
113 #endif
114 
115 
116 volatile int ff_avcodec_locked;
117 static int volatile entangled_thread_counter = 0;
118 static void *codec_mutex;
119 static void *avformat_mutex;
120 
121 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
122 {
123  uint8_t **p = ptr;
124  if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
125  av_freep(p);
126  *size = 0;
127  return;
128  }
129  if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1))
130  memset(*p + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
131 }
132 
133 void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
134 {
135  uint8_t **p = ptr;
136  if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
137  av_freep(p);
138  *size = 0;
139  return;
140  }
141  if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1))
142  memset(*p, 0, min_size + AV_INPUT_BUFFER_PADDING_SIZE);
143 }
144 
145 /* encoder management */
148 
150 {
151  if (c)
152  return c->next;
153  else
154  return first_avcodec;
155 }
156 
157 static av_cold void avcodec_init(void)
158 {
159  static int initialized = 0;
160 
161  if (initialized != 0)
162  return;
163  initialized = 1;
164 
165  if (CONFIG_ME_CMP)
167 }
168 
169 int av_codec_is_encoder(const AVCodec *codec)
170 {
171  return codec && (codec->encode_sub || codec->encode2 ||codec->send_frame);
172 }
173 
174 int av_codec_is_decoder(const AVCodec *codec)
175 {
176  return codec && (codec->decode || codec->receive_frame);
177 }
178 
180 {
181  AVCodec **p;
182  avcodec_init();
183  p = last_avcodec;
184  codec->next = NULL;
185 
186  while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
187  p = &(*p)->next;
188  last_avcodec = &codec->next;
189 
190  if (codec->init_static_data)
191  codec->init_static_data(codec);
192 }
193 
194 #if FF_API_EMU_EDGE
196 {
197  return EDGE_WIDTH;
198 }
199 #endif
200 
201 #if FF_API_SET_DIMENSIONS
203 {
204  int ret = ff_set_dimensions(s, width, height);
205  if (ret < 0) {
206  av_log(s, AV_LOG_WARNING, "Failed to set dimensions %d %d\n", width, height);
207  }
208 }
209 #endif
210 
212 {
213  int ret = av_image_check_size2(width, height, s->max_pixels, AV_PIX_FMT_NONE, 0, s);
214 
215  if (ret < 0)
216  width = height = 0;
217 
218  s->coded_width = width;
219  s->coded_height = height;
220  s->width = AV_CEIL_RSHIFT(width, s->lowres);
221  s->height = AV_CEIL_RSHIFT(height, s->lowres);
222 
223  return ret;
224 }
225 
227 {
228  int ret = av_image_check_sar(avctx->width, avctx->height, sar);
229 
230  if (ret < 0) {
231  av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %d/%d\n",
232  sar.num, sar.den);
233  avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
234  return ret;
235  } else {
236  avctx->sample_aspect_ratio = sar;
237  }
238  return 0;
239 }
240 
242  enum AVMatrixEncoding matrix_encoding)
243 {
244  AVFrameSideData *side_data;
245  enum AVMatrixEncoding *data;
246 
248  if (!side_data)
250  sizeof(enum AVMatrixEncoding));
251 
252  if (!side_data)
253  return AVERROR(ENOMEM);
254 
255  data = (enum AVMatrixEncoding*)side_data->data;
256  *data = matrix_encoding;
257 
258  return 0;
259 }
260 
262  int linesize_align[AV_NUM_DATA_POINTERS])
263 {
264  int i;
265  int w_align = 1;
266  int h_align = 1;
268 
269  if (desc) {
270  w_align = 1 << desc->log2_chroma_w;
271  h_align = 1 << desc->log2_chroma_h;
272  }
273 
274  switch (s->pix_fmt) {
275  case AV_PIX_FMT_YUV420P:
276  case AV_PIX_FMT_YUYV422:
277  case AV_PIX_FMT_YVYU422:
278  case AV_PIX_FMT_UYVY422:
279  case AV_PIX_FMT_YUV422P:
280  case AV_PIX_FMT_YUV440P:
281  case AV_PIX_FMT_YUV444P:
282  case AV_PIX_FMT_GBRP:
283  case AV_PIX_FMT_GBRAP:
284  case AV_PIX_FMT_GRAY8:
285  case AV_PIX_FMT_GRAY16BE:
286  case AV_PIX_FMT_GRAY16LE:
287  case AV_PIX_FMT_YUVJ420P:
288  case AV_PIX_FMT_YUVJ422P:
289  case AV_PIX_FMT_YUVJ440P:
290  case AV_PIX_FMT_YUVJ444P:
291  case AV_PIX_FMT_YUVA420P:
292  case AV_PIX_FMT_YUVA422P:
293  case AV_PIX_FMT_YUVA444P:
346  case AV_PIX_FMT_GBRP9LE:
347  case AV_PIX_FMT_GBRP9BE:
348  case AV_PIX_FMT_GBRP10LE:
349  case AV_PIX_FMT_GBRP10BE:
350  case AV_PIX_FMT_GBRP12LE:
351  case AV_PIX_FMT_GBRP12BE:
352  case AV_PIX_FMT_GBRP14LE:
353  case AV_PIX_FMT_GBRP14BE:
354  case AV_PIX_FMT_GBRP16LE:
355  case AV_PIX_FMT_GBRP16BE:
360  w_align = 16; //FIXME assume 16 pixel per macroblock
361  h_align = 16 * 2; // interlaced needs 2 macroblocks height
362  break;
363  case AV_PIX_FMT_YUV411P:
364  case AV_PIX_FMT_YUVJ411P:
366  w_align = 32;
367  h_align = 16 * 2;
368  break;
369  case AV_PIX_FMT_YUV410P:
370  if (s->codec_id == AV_CODEC_ID_SVQ1) {
371  w_align = 64;
372  h_align = 64;
373  }
374  break;
375  case AV_PIX_FMT_RGB555:
376  if (s->codec_id == AV_CODEC_ID_RPZA) {
377  w_align = 4;
378  h_align = 4;
379  }
381  w_align = 8;
382  h_align = 8;
383  }
384  break;
385  case AV_PIX_FMT_PAL8:
386  case AV_PIX_FMT_BGR8:
387  case AV_PIX_FMT_RGB8:
388  if (s->codec_id == AV_CODEC_ID_SMC ||
390  w_align = 4;
391  h_align = 4;
392  }
393  if (s->codec_id == AV_CODEC_ID_JV ||
395  w_align = 8;
396  h_align = 8;
397  }
398  if (s->codec_id == AV_CODEC_ID_MJPEG ||
400  s->codec_id == AV_CODEC_ID_LJPEG ||
402  s->codec_id == AV_CODEC_ID_AMV ||
403  s->codec_id == AV_CODEC_ID_SP5X ||
405  w_align = 8;
406  h_align = 2*8;
407  }
408  break;
409  case AV_PIX_FMT_BGR24:
410  if ((s->codec_id == AV_CODEC_ID_MSZH) ||
411  (s->codec_id == AV_CODEC_ID_ZLIB)) {
412  w_align = 4;
413  h_align = 4;
414  }
415  break;
416  case AV_PIX_FMT_RGB24:
417  if (s->codec_id == AV_CODEC_ID_CINEPAK) {
418  w_align = 4;
419  h_align = 4;
420  }
421  break;
422  default:
423  break;
424  }
425 
426  if (s->codec_id == AV_CODEC_ID_IFF_ILBM) {
427  w_align = FFMAX(w_align, 8);
428  }
429 
430  *width = FFALIGN(*width, w_align);
431  *height = FFALIGN(*height, h_align);
432  if (s->codec_id == AV_CODEC_ID_H264 || s->lowres ||
435  ) {
436  // some of the optimized chroma MC reads one line too much
437  // which is also done in mpeg decoders with lowres > 0
438  *height += 2;
439 
440  // H.264 uses edge emulation for out of frame motion vectors, for this
441  // it requires a temporary area large enough to hold a 21x21 block,
442  // increasing witdth ensure that the temporary area is large enough,
443  // the next rounded up width is 32
444  *width = FFMAX(*width, 32);
445  }
446 
447  for (i = 0; i < 4; i++)
448  linesize_align[i] = STRIDE_ALIGN;
449 }
450 
452 {
454  int chroma_shift = desc->log2_chroma_w;
455  int linesize_align[AV_NUM_DATA_POINTERS];
456  int align;
457 
458  avcodec_align_dimensions2(s, width, height, linesize_align);
459  align = FFMAX(linesize_align[0], linesize_align[3]);
460  linesize_align[1] <<= chroma_shift;
461  linesize_align[2] <<= chroma_shift;
462  align = FFMAX3(align, linesize_align[1], linesize_align[2]);
463  *width = FFALIGN(*width, align);
464 }
465 
466 int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
467 {
468  if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB)
469  return AVERROR(EINVAL);
470  pos--;
471 
472  *xpos = (pos&1) * 128;
473  *ypos = ((pos>>1)^(pos<4)) * 128;
474 
475  return 0;
476 }
477 
479 {
480  int pos, xout, yout;
481 
482  for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) {
483  if (avcodec_enum_to_chroma_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos)
484  return pos;
485  }
487 }
488 
490  enum AVSampleFormat sample_fmt, const uint8_t *buf,
491  int buf_size, int align)
492 {
493  int ch, planar, needed_size, ret = 0;
494 
495  needed_size = av_samples_get_buffer_size(NULL, nb_channels,
496  frame->nb_samples, sample_fmt,
497  align);
498  if (buf_size < needed_size)
499  return AVERROR(EINVAL);
500 
501  planar = av_sample_fmt_is_planar(sample_fmt);
502  if (planar && nb_channels > AV_NUM_DATA_POINTERS) {
503  if (!(frame->extended_data = av_mallocz_array(nb_channels,
504  sizeof(*frame->extended_data))))
505  return AVERROR(ENOMEM);
506  } else {
507  frame->extended_data = frame->data;
508  }
509 
510  if ((ret = av_samples_fill_arrays(frame->extended_data, &frame->linesize[0],
511  (uint8_t *)(intptr_t)buf, nb_channels, frame->nb_samples,
512  sample_fmt, align)) < 0) {
513  if (frame->extended_data != frame->data)
514  av_freep(&frame->extended_data);
515  return ret;
516  }
517  if (frame->extended_data != frame->data) {
518  for (ch = 0; ch < AV_NUM_DATA_POINTERS; ch++)
519  frame->data[ch] = frame->extended_data[ch];
520  }
521 
522  return ret;
523 }
524 
525 void ff_color_frame(AVFrame *frame, const int c[4])
526 {
528  int p, y;
529 
531 
532  for (p = 0; p<desc->nb_components; p++) {
533  uint8_t *dst = frame->data[p];
534  int is_chroma = p == 1 || p == 2;
535  int bytes = is_chroma ? AV_CEIL_RSHIFT(frame->width, desc->log2_chroma_w) : frame->width;
536  int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height;
537  if (desc->comp[0].depth >= 9) {
538  ((uint16_t*)dst)[0] = c[p];
539  av_memcpy_backptr(dst + 2, 2, bytes - 2);
540  dst += frame->linesize[p];
541  for (y = 1; y < height; y++) {
542  memcpy(dst, frame->data[p], 2*bytes);
543  dst += frame->linesize[p];
544  }
545  } else {
546  for (y = 0; y < height; y++) {
547  memset(dst, c[p], bytes);
548  dst += frame->linesize[p];
549  }
550  }
551  }
552 }
553 
554 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
555 {
556  int i;
557 
558  for (i = 0; i < count; i++) {
559  int r = func(c, (char *)arg + i * size);
560  if (ret)
561  ret[i] = r;
562  }
563  emms_c();
564  return 0;
565 }
566 
567 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
568 {
569  int i;
570 
571  for (i = 0; i < count; i++) {
572  int r = func(c, arg, i, 0);
573  if (ret)
574  ret[i] = r;
575  }
576  emms_c();
577  return 0;
578 }
579 
581  unsigned int fourcc)
582 {
583  while (tags->pix_fmt >= 0) {
584  if (tags->fourcc == fourcc)
585  return tags->pix_fmt;
586  tags++;
587  }
588  return AV_PIX_FMT_NONE;
589 }
590 
591 MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
592 MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
594 MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll)
595 MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
596 
598 {
599  return codec->properties;
600 }
601 
603 {
604  return codec->max_lowres;
605 }
606 
609 }
610 
612 {
613  int64_t bit_rate;
614  int bits_per_sample;
615 
616  switch (ctx->codec_type) {
617  case AVMEDIA_TYPE_VIDEO:
618  case AVMEDIA_TYPE_DATA:
621  bit_rate = ctx->bit_rate;
622  break;
623  case AVMEDIA_TYPE_AUDIO:
624  bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
625  if (bits_per_sample) {
626  bit_rate = ctx->sample_rate * (int64_t)ctx->channels;
627  if (bit_rate > INT64_MAX / bits_per_sample) {
628  bit_rate = 0;
629  } else
630  bit_rate *= bits_per_sample;
631  } else
632  bit_rate = ctx->bit_rate;
633  break;
634  default:
635  bit_rate = 0;
636  break;
637  }
638  return bit_rate;
639 }
640 
642 {
643  int ret = 0;
644 
645  ff_unlock_avcodec(codec);
646 
647  ret = avcodec_open2(avctx, codec, options);
648 
649  ff_lock_avcodec(avctx, codec);
650  return ret;
651 }
652 
654 {
655  int ret = 0;
656  int codec_init_ok = 0;
657  AVDictionary *tmp = NULL;
658  const AVPixFmtDescriptor *pixdesc;
659 
660  if (avcodec_is_open(avctx))
661  return 0;
662 
663  if ((!codec && !avctx->codec)) {
664  av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
665  return AVERROR(EINVAL);
666  }
667  if ((codec && avctx->codec && codec != avctx->codec)) {
668  av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
669  "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
670  return AVERROR(EINVAL);
671  }
672  if (!codec)
673  codec = avctx->codec;
674 
675  if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
676  return AVERROR(EINVAL);
677 
678  if (options)
679  av_dict_copy(&tmp, *options, 0);
680 
681  ret = ff_lock_avcodec(avctx, codec);
682  if (ret < 0)
683  return ret;
684 
685  avctx->internal = av_mallocz(sizeof(*avctx->internal));
686  if (!avctx->internal) {
687  ret = AVERROR(ENOMEM);
688  goto end;
689  }
690 
691  avctx->internal->pool = av_mallocz(sizeof(*avctx->internal->pool));
692  if (!avctx->internal->pool) {
693  ret = AVERROR(ENOMEM);
694  goto free_and_end;
695  }
696 
697  avctx->internal->to_free = av_frame_alloc();
698  if (!avctx->internal->to_free) {
699  ret = AVERROR(ENOMEM);
700  goto free_and_end;
701  }
702 
704  if (!avctx->internal->compat_decode_frame) {
705  ret = AVERROR(ENOMEM);
706  goto free_and_end;
707  }
708 
710  if (!avctx->internal->buffer_frame) {
711  ret = AVERROR(ENOMEM);
712  goto free_and_end;
713  }
714 
715  avctx->internal->buffer_pkt = av_packet_alloc();
716  if (!avctx->internal->buffer_pkt) {
717  ret = AVERROR(ENOMEM);
718  goto free_and_end;
719  }
720 
721  avctx->internal->ds.in_pkt = av_packet_alloc();
722  if (!avctx->internal->ds.in_pkt) {
723  ret = AVERROR(ENOMEM);
724  goto free_and_end;
725  }
726 
728  if (!avctx->internal->last_pkt_props) {
729  ret = AVERROR(ENOMEM);
730  goto free_and_end;
731  }
732 
733  avctx->internal->skip_samples_multiplier = 1;
734 
735  if (codec->priv_data_size > 0) {
736  if (!avctx->priv_data) {
737  avctx->priv_data = av_mallocz(codec->priv_data_size);
738  if (!avctx->priv_data) {
739  ret = AVERROR(ENOMEM);
740  goto end;
741  }
742  if (codec->priv_class) {
743  *(const AVClass **)avctx->priv_data = codec->priv_class;
745  }
746  }
747  if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
748  goto free_and_end;
749  } else {
750  avctx->priv_data = NULL;
751  }
752  if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
753  goto free_and_end;
754 
755  if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
756  av_log(avctx, AV_LOG_ERROR, "Codec (%s) not on whitelist \'%s\'\n", codec->name, avctx->codec_whitelist);
757  ret = AVERROR(EINVAL);
758  goto free_and_end;
759  }
760 
761  // only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not to overwrite previously setup dimensions
762  if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
763  (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) {
764  if (avctx->coded_width && avctx->coded_height)
765  ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
766  else if (avctx->width && avctx->height)
767  ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
768  if (ret < 0)
769  goto free_and_end;
770  }
771 
772  if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
773  && ( av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0
774  || av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)) {
775  av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n");
776  ff_set_dimensions(avctx, 0, 0);
777  }
778 
779  if (avctx->width > 0 && avctx->height > 0) {
780  if (av_image_check_sar(avctx->width, avctx->height,
781  avctx->sample_aspect_ratio) < 0) {
782  av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
783  avctx->sample_aspect_ratio.num,
784  avctx->sample_aspect_ratio.den);
785  avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
786  }
787  }
788 
789  /* if the decoder init function was already called previously,
790  * free the already allocated subtitle_header before overwriting it */
791  if (av_codec_is_decoder(codec))
792  av_freep(&avctx->subtitle_header);
793 
794  if (avctx->channels > FF_SANE_NB_CHANNELS) {
795  ret = AVERROR(EINVAL);
796  goto free_and_end;
797  }
798  if (avctx->sample_rate < 0) {
799  av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate);
800  ret = AVERROR(EINVAL);
801  goto free_and_end;
802  }
803  if (avctx->block_align < 0) {
804  av_log(avctx, AV_LOG_ERROR, "Invalid block align: %d\n", avctx->block_align);
805  ret = AVERROR(EINVAL);
806  goto free_and_end;
807  }
808 
809  avctx->codec = codec;
810  if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
811  avctx->codec_id == AV_CODEC_ID_NONE) {
812  avctx->codec_type = codec->type;
813  avctx->codec_id = codec->id;
814  }
815  if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
816  && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
817  av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
818  ret = AVERROR(EINVAL);
819  goto free_and_end;
820  }
821  avctx->frame_number = 0;
823 
824  if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
826  const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
827  AVCodec *codec2;
828  av_log(avctx, AV_LOG_ERROR,
829  "The %s '%s' is experimental but experimental codecs are not enabled, "
830  "add '-strict %d' if you want to use it.\n",
831  codec_string, codec->name, FF_COMPLIANCE_EXPERIMENTAL);
832  codec2 = av_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
833  if (!(codec2->capabilities & AV_CODEC_CAP_EXPERIMENTAL))
834  av_log(avctx, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n",
835  codec_string, codec2->name);
836  ret = AVERROR_EXPERIMENTAL;
837  goto free_and_end;
838  }
839 
840  if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
841  (!avctx->time_base.num || !avctx->time_base.den)) {
842  avctx->time_base.num = 1;
843  avctx->time_base.den = avctx->sample_rate;
844  }
845 
846  if (!HAVE_THREADS)
847  av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
848 
850  ff_unlock_avcodec(codec); //we will instantiate a few encoders thus kick the counter to prevent false detection of a problem
851  ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL);
852  ff_lock_avcodec(avctx, codec);
853  if (ret < 0)
854  goto free_and_end;
855  }
856 
857  if (HAVE_THREADS
859  ret = ff_thread_init(avctx);
860  if (ret < 0) {
861  goto free_and_end;
862  }
863  }
865  avctx->thread_count = 1;
866 
867  if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
868  av_log(avctx, AV_LOG_WARNING, "The maximum value for lowres supported by the decoder is %d\n",
869  avctx->codec->max_lowres);
870  avctx->lowres = avctx->codec->max_lowres;
871  }
872 
873 #if FF_API_VISMV
874  if (avctx->debug_mv)
875  av_log(avctx, AV_LOG_WARNING, "The 'vismv' option is deprecated, "
876  "see the codecview filter instead.\n");
877 #endif
878 
879  if (av_codec_is_encoder(avctx->codec)) {
880  int i;
881 #if FF_API_CODED_FRAME
883  avctx->coded_frame = av_frame_alloc();
884  if (!avctx->coded_frame) {
885  ret = AVERROR(ENOMEM);
886  goto free_and_end;
887  }
889 #endif
890 
891  if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) {
892  av_log(avctx, AV_LOG_ERROR, "The encoder timebase is not set.\n");
893  ret = AVERROR(EINVAL);
894  goto free_and_end;
895  }
896 
897  if (avctx->codec->sample_fmts) {
898  for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
899  if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
900  break;
901  if (avctx->channels == 1 &&
904  avctx->sample_fmt = avctx->codec->sample_fmts[i];
905  break;
906  }
907  }
908  if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
909  char buf[128];
910  snprintf(buf, sizeof(buf), "%d", avctx->sample_fmt);
911  av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is invalid or not supported\n",
912  (char *)av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), buf));
913  ret = AVERROR(EINVAL);
914  goto free_and_end;
915  }
916  }
917  if (avctx->codec->pix_fmts) {
918  for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
919  if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
920  break;
921  if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE
922  && !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG)
924  char buf[128];
925  snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);
926  av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid or not supported\n",
927  (char *)av_x_if_null(av_get_pix_fmt_name(avctx->pix_fmt), buf));
928  ret = AVERROR(EINVAL);
929  goto free_and_end;
930  }
931  if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
932  avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ411P ||
933  avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ422P ||
934  avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ440P ||
935  avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P)
936  avctx->color_range = AVCOL_RANGE_JPEG;
937  }
938  if (avctx->codec->supported_samplerates) {
939  for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
940  if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
941  break;
942  if (avctx->codec->supported_samplerates[i] == 0) {
943  av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n",
944  avctx->sample_rate);
945  ret = AVERROR(EINVAL);
946  goto free_and_end;
947  }
948  }
949  if (avctx->sample_rate < 0) {
950  av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n",
951  avctx->sample_rate);
952  ret = AVERROR(EINVAL);
953  goto free_and_end;
954  }
955  if (avctx->codec->channel_layouts) {
956  if (!avctx->channel_layout) {
957  av_log(avctx, AV_LOG_WARNING, "Channel layout not specified\n");
958  } else {
959  for (i = 0; avctx->codec->channel_layouts[i] != 0; i++)
960  if (avctx->channel_layout == avctx->codec->channel_layouts[i])
961  break;
962  if (avctx->codec->channel_layouts[i] == 0) {
963  char buf[512];
964  av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
965  av_log(avctx, AV_LOG_ERROR, "Specified channel layout '%s' is not supported\n", buf);
966  ret = AVERROR(EINVAL);
967  goto free_and_end;
968  }
969  }
970  }
971  if (avctx->channel_layout && avctx->channels) {
972  int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
973  if (channels != avctx->channels) {
974  char buf[512];
975  av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
976  av_log(avctx, AV_LOG_ERROR,
977  "Channel layout '%s' with %d channels does not match number of specified channels %d\n",
978  buf, channels, avctx->channels);
979  ret = AVERROR(EINVAL);
980  goto free_and_end;
981  }
982  } else if (avctx->channel_layout) {
984  }
985  if (avctx->channels < 0) {
986  av_log(avctx, AV_LOG_ERROR, "Specified number of channels %d is not supported\n",
987  avctx->channels);
988  ret = AVERROR(EINVAL);
989  goto free_and_end;
990  }
991  if(avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
992  pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
993  if ( avctx->bits_per_raw_sample < 0
994  || (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 8)) {
995  av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible with the specified pixel formats depth %d\n",
996  avctx->bits_per_raw_sample, pixdesc->comp[0].depth);
997  avctx->bits_per_raw_sample = pixdesc->comp[0].depth;
998  }
999  if (avctx->width <= 0 || avctx->height <= 0) {
1000  av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
1001  ret = AVERROR(EINVAL);
1002  goto free_and_end;
1003  }
1004  }
1005  if ( (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
1006  && avctx->bit_rate>0 && avctx->bit_rate<1000) {
1007  av_log(avctx, AV_LOG_WARNING, "Bitrate %"PRId64" is extremely low, maybe you mean %"PRId64"k\n", avctx->bit_rate, avctx->bit_rate);
1008  }
1009 
1010  if (!avctx->rc_initial_buffer_occupancy)
1011  avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3LL / 4;
1012 
1013  if (avctx->ticks_per_frame && avctx->time_base.num &&
1014  avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
1015  av_log(avctx, AV_LOG_ERROR,
1016  "ticks_per_frame %d too large for the timebase %d/%d.",
1017  avctx->ticks_per_frame,
1018  avctx->time_base.num,
1019  avctx->time_base.den);
1020  goto free_and_end;
1021  }
1022 
1023  if (avctx->hw_frames_ctx) {
1024  AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
1025  if (frames_ctx->format != avctx->pix_fmt) {
1026  av_log(avctx, AV_LOG_ERROR,
1027  "Mismatching AVCodecContext.pix_fmt and AVHWFramesContext.format\n");
1028  ret = AVERROR(EINVAL);
1029  goto free_and_end;
1030  }
1031  if (avctx->sw_pix_fmt != AV_PIX_FMT_NONE &&
1032  avctx->sw_pix_fmt != frames_ctx->sw_format) {
1033  av_log(avctx, AV_LOG_ERROR,
1034  "Mismatching AVCodecContext.sw_pix_fmt (%s) "
1035  "and AVHWFramesContext.sw_format (%s)\n",
1037  av_get_pix_fmt_name(frames_ctx->sw_format));
1038  ret = AVERROR(EINVAL);
1039  goto free_and_end;
1040  }
1041  avctx->sw_pix_fmt = frames_ctx->sw_format;
1042  }
1043  }
1044 
1046  avctx->pts_correction_num_faulty_dts = 0;
1047  avctx->pts_correction_last_pts =
1048  avctx->pts_correction_last_dts = INT64_MIN;
1049 
1050  if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY
1052  av_log(avctx, AV_LOG_WARNING,
1053  "gray decoding requested but not enabled at configuration time\n");
1054 
1055  if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME)
1056  || avctx->internal->frame_thread_encoder)) {
1057  ret = avctx->codec->init(avctx);
1058  if (ret < 0) {
1059  goto free_and_end;
1060  }
1061  codec_init_ok = 1;
1062  }
1063 
1064  ret=0;
1065 
1066 #if FF_API_AUDIOENC_DELAY
1067  if (av_codec_is_encoder(avctx->codec))
1068  avctx->delay = avctx->initial_padding;
1069 #endif
1070 
1071  if (av_codec_is_decoder(avctx->codec)) {
1072  if (!avctx->bit_rate)
1073  avctx->bit_rate = get_bit_rate(avctx);
1074  /* validate channel layout from the decoder */
1075  if (avctx->channel_layout) {
1076  int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
1077  if (!avctx->channels)
1078  avctx->channels = channels;
1079  else if (channels != avctx->channels) {
1080  char buf[512];
1081  av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
1082  av_log(avctx, AV_LOG_WARNING,
1083  "Channel layout '%s' with %d channels does not match specified number of channels %d: "
1084  "ignoring specified channel layout\n",
1085  buf, channels, avctx->channels);
1086  avctx->channel_layout = 0;
1087  }
1088  }
1089  if (avctx->channels && avctx->channels < 0 ||
1090  avctx->channels > FF_SANE_NB_CHANNELS) {
1091  ret = AVERROR(EINVAL);
1092  goto free_and_end;
1093  }
1094  if (avctx->bits_per_coded_sample < 0) {
1095  ret = AVERROR(EINVAL);
1096  goto free_and_end;
1097  }
1098  if (avctx->sub_charenc) {
1099  if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) {
1100  av_log(avctx, AV_LOG_ERROR, "Character encoding is only "
1101  "supported with subtitles codecs\n");
1102  ret = AVERROR(EINVAL);
1103  goto free_and_end;
1104  } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) {
1105  av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, "
1106  "subtitles character encoding will be ignored\n",
1107  avctx->codec_descriptor->name);
1109  } else {
1110  /* input character encoding is set for a text based subtitle
1111  * codec at this point */
1114 
1116 #if CONFIG_ICONV
1117  iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc);
1118  if (cd == (iconv_t)-1) {
1119  ret = AVERROR(errno);
1120  av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context "
1121  "with input character encoding \"%s\"\n", avctx->sub_charenc);
1122  goto free_and_end;
1123  }
1124  iconv_close(cd);
1125 #else
1126  av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles "
1127  "conversion needs a libavcodec built with iconv support "
1128  "for this codec\n");
1129  ret = AVERROR(ENOSYS);
1130  goto free_and_end;
1131 #endif
1132  }
1133  }
1134  }
1135 
1136 #if FF_API_AVCTX_TIMEBASE
1137  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
1138  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
1139 #endif
1140  }
1141  if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
1142  av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
1143  }
1144 
1145 end:
1146  ff_unlock_avcodec(codec);
1147  if (options) {
1148  av_dict_free(options);
1149  *options = tmp;
1150  }
1151 
1152  return ret;
1153 free_and_end:
1154  if (avctx->codec && avctx->codec->close &&
1155  (codec_init_ok ||
1157  avctx->codec->close(avctx);
1158 
1159  if (HAVE_THREADS && avctx->internal->thread_ctx)
1160  ff_thread_free(avctx);
1161 
1162  if (codec->priv_class && codec->priv_data_size)
1163  av_opt_free(avctx->priv_data);
1164  av_opt_free(avctx);
1165 
1166 #if FF_API_CODED_FRAME
1168  av_frame_free(&avctx->coded_frame);
1170 #endif
1171 
1172  av_dict_free(&tmp);
1173  av_freep(&avctx->priv_data);
1174  av_freep(&avctx->subtitle_header);
1175  if (avctx->internal) {
1176  av_frame_free(&avctx->internal->to_free);
1181 
1182  av_packet_free(&avctx->internal->ds.in_pkt);
1183 
1184  av_freep(&avctx->internal->pool);
1185  }
1186  av_freep(&avctx->internal);
1187  avctx->codec = NULL;
1188  goto end;
1189 }
1190 
1192 {
1193  int i;
1194 
1195  for (i = 0; i < sub->num_rects; i++) {
1196  av_freep(&sub->rects[i]->data[0]);
1197  av_freep(&sub->rects[i]->data[1]);
1198  av_freep(&sub->rects[i]->data[2]);
1199  av_freep(&sub->rects[i]->data[3]);
1200  av_freep(&sub->rects[i]->text);
1201  av_freep(&sub->rects[i]->ass);
1202  av_freep(&sub->rects[i]);
1203  }
1204 
1205  av_freep(&sub->rects);
1206 
1207  memset(sub, 0, sizeof(*sub));
1208 }
1209 
1211 {
1212  int i;
1213 
1214  if (!avctx)
1215  return 0;
1216 
1217  if (avcodec_is_open(avctx)) {
1218  FramePool *pool = avctx->internal->pool;
1220  avctx->internal->frame_thread_encoder && avctx->thread_count > 1) {
1222  }
1223  if (HAVE_THREADS && avctx->internal->thread_ctx)
1224  ff_thread_free(avctx);
1225  if (avctx->codec && avctx->codec->close)
1226  avctx->codec->close(avctx);
1227  avctx->internal->byte_buffer_size = 0;
1228  av_freep(&avctx->internal->byte_buffer);
1229  av_frame_free(&avctx->internal->to_free);
1234 
1235  av_packet_free(&avctx->internal->ds.in_pkt);
1236 
1237  for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
1238  av_buffer_pool_uninit(&pool->pools[i]);
1239  av_freep(&avctx->internal->pool);
1240 
1241  if (avctx->hwaccel && avctx->hwaccel->uninit)
1242  avctx->hwaccel->uninit(avctx);
1244 
1245  ff_decode_bsfs_uninit(avctx);
1246 
1247  av_freep(&avctx->internal);
1248  }
1249 
1250  for (i = 0; i < avctx->nb_coded_side_data; i++)
1251  av_freep(&avctx->coded_side_data[i].data);
1252  av_freep(&avctx->coded_side_data);
1253  avctx->nb_coded_side_data = 0;
1254 
1255  av_buffer_unref(&avctx->hw_frames_ctx);
1256  av_buffer_unref(&avctx->hw_device_ctx);
1257 
1258  if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
1259  av_opt_free(avctx->priv_data);
1260  av_opt_free(avctx);
1261  av_freep(&avctx->priv_data);
1262  if (av_codec_is_encoder(avctx->codec)) {
1263  av_freep(&avctx->extradata);
1264 #if FF_API_CODED_FRAME
1266  av_frame_free(&avctx->coded_frame);
1268 #endif
1269  }
1270  avctx->codec = NULL;
1271  avctx->active_thread_type = 0;
1272 
1273  return 0;
1274 }
1275 
1277 {
1278  switch(id){
1279  //This is for future deprecatec codec ids, its empty since
1280  //last major bump but will fill up again over time, please don't remove it
1281  default : return id;
1282  }
1283 }
1284 
1285 static AVCodec *find_encdec(enum AVCodecID id, int encoder)
1286 {
1287  AVCodec *p, *experimental = NULL;
1288  p = first_avcodec;
1289  id= remap_deprecated_codec_id(id);
1290  while (p) {
1291  if ((encoder ? av_codec_is_encoder(p) : av_codec_is_decoder(p)) &&
1292  p->id == id) {
1293  if (p->capabilities & AV_CODEC_CAP_EXPERIMENTAL && !experimental) {
1294  experimental = p;
1295  } else
1296  return p;
1297  }
1298  p = p->next;
1299  }
1300  return experimental;
1301 }
1302 
1304 {
1305  return find_encdec(id, 1);
1306 }
1307 
1309 {
1310  AVCodec *p;
1311  if (!name)
1312  return NULL;
1313  p = first_avcodec;
1314  while (p) {
1315  if (av_codec_is_encoder(p) && strcmp(name, p->name) == 0)
1316  return p;
1317  p = p->next;
1318  }
1319  return NULL;
1320 }
1321 
1323 {
1324  return find_encdec(id, 0);
1325 }
1326 
1328 {
1329  AVCodec *p;
1330  if (!name)
1331  return NULL;
1332  p = first_avcodec;
1333  while (p) {
1334  if (av_codec_is_decoder(p) && strcmp(name, p->name) == 0)
1335  return p;
1336  p = p->next;
1337  }
1338  return NULL;
1339 }
1340 
1341 const char *avcodec_get_name(enum AVCodecID id)
1342 {
1343  const AVCodecDescriptor *cd;
1344  AVCodec *codec;
1345 
1346  if (id == AV_CODEC_ID_NONE)
1347  return "none";
1348  cd = avcodec_descriptor_get(id);
1349  if (cd)
1350  return cd->name;
1351  av_log(NULL, AV_LOG_WARNING, "Codec 0x%x is not in the full list.\n", id);
1352  codec = avcodec_find_decoder(id);
1353  if (codec)
1354  return codec->name;
1355  codec = avcodec_find_encoder(id);
1356  if (codec)
1357  return codec->name;
1358  return "unknown_codec";
1359 }
1360 
1361 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
1362 {
1363  int i, len, ret = 0;
1364 
1365 #define TAG_PRINT(x) \
1366  (((x) >= '0' && (x) <= '9') || \
1367  ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
1368  ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))
1369 
1370  for (i = 0; i < 4; i++) {
1371  len = snprintf(buf, buf_size,
1372  TAG_PRINT(codec_tag & 0xFF) ? "%c" : "[%d]", codec_tag & 0xFF);
1373  buf += len;
1374  buf_size = buf_size > len ? buf_size - len : 0;
1375  ret += len;
1376  codec_tag >>= 8;
1377  }
1378  return ret;
1379 }
1380 
1381 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
1382 {
1383  const char *codec_type;
1384  const char *codec_name;
1385  const char *profile = NULL;
1386  int64_t bitrate;
1387  int new_line = 0;
1388  AVRational display_aspect_ratio;
1389  const char *separator = enc->dump_separator ? (const char *)enc->dump_separator : ", ";
1390 
1391  if (!buf || buf_size <= 0)
1392  return;
1393  codec_type = av_get_media_type_string(enc->codec_type);
1394  codec_name = avcodec_get_name(enc->codec_id);
1395  profile = avcodec_profile_name(enc->codec_id, enc->profile);
1396 
1397  snprintf(buf, buf_size, "%s: %s", codec_type ? codec_type : "unknown",
1398  codec_name);
1399  buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */
1400 
1401  if (enc->codec && strcmp(enc->codec->name, codec_name))
1402  snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", enc->codec->name);
1403 
1404  if (profile)
1405  snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", profile);
1406  if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
1408  && enc->refs)
1409  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1410  ", %d reference frame%s",
1411  enc->refs, enc->refs > 1 ? "s" : "");
1412 
1413  if (enc->codec_tag)
1414  snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s / 0x%04X)",
1415  av_fourcc2str(enc->codec_tag), enc->codec_tag);
1416 
1417  switch (enc->codec_type) {
1418  case AVMEDIA_TYPE_VIDEO:
1419  {
1420  char detail[256] = "(";
1421 
1422  av_strlcat(buf, separator, buf_size);
1423 
1424  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1425  "%s", enc->pix_fmt == AV_PIX_FMT_NONE ? "none" :
1427  if (enc->bits_per_raw_sample && enc->pix_fmt != AV_PIX_FMT_NONE &&
1429  av_strlcatf(detail, sizeof(detail), "%d bpc, ", enc->bits_per_raw_sample);
1431  av_strlcatf(detail, sizeof(detail), "%s, ",
1433 
1434  if (enc->colorspace != AVCOL_SPC_UNSPECIFIED ||
1436  enc->color_trc != AVCOL_TRC_UNSPECIFIED) {
1437  if (enc->colorspace != (int)enc->color_primaries ||
1438  enc->colorspace != (int)enc->color_trc) {
1439  new_line = 1;
1440  av_strlcatf(detail, sizeof(detail), "%s/%s/%s, ",
1444  } else
1445  av_strlcatf(detail, sizeof(detail), "%s, ",
1447  }
1448 
1449  if (enc->field_order != AV_FIELD_UNKNOWN) {
1450  const char *field_order = "progressive";
1451  if (enc->field_order == AV_FIELD_TT)
1452  field_order = "top first";
1453  else if (enc->field_order == AV_FIELD_BB)
1454  field_order = "bottom first";
1455  else if (enc->field_order == AV_FIELD_TB)
1456  field_order = "top coded first (swapped)";
1457  else if (enc->field_order == AV_FIELD_BT)
1458  field_order = "bottom coded first (swapped)";
1459 
1460  av_strlcatf(detail, sizeof(detail), "%s, ", field_order);
1461  }
1462 
1463  if (av_log_get_level() >= AV_LOG_VERBOSE &&
1465  av_strlcatf(detail, sizeof(detail), "%s, ",
1467 
1468  if (strlen(detail) > 1) {
1469  detail[strlen(detail) - 2] = 0;
1470  av_strlcatf(buf, buf_size, "%s)", detail);
1471  }
1472  }
1473 
1474  if (enc->width) {
1475  av_strlcat(buf, new_line ? separator : ", ", buf_size);
1476 
1477  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1478  "%dx%d",
1479  enc->width, enc->height);
1480 
1481  if (av_log_get_level() >= AV_LOG_VERBOSE &&
1482  (enc->width != enc->coded_width ||
1483  enc->height != enc->coded_height))
1484  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1485  " (%dx%d)", enc->coded_width, enc->coded_height);
1486 
1487  if (enc->sample_aspect_ratio.num) {
1488  av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
1489  enc->width * (int64_t)enc->sample_aspect_ratio.num,
1490  enc->height * (int64_t)enc->sample_aspect_ratio.den,
1491  1024 * 1024);
1492  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1493  " [SAR %d:%d DAR %d:%d]",
1495  display_aspect_ratio.num, display_aspect_ratio.den);
1496  }
1497  if (av_log_get_level() >= AV_LOG_DEBUG) {
1498  int g = av_gcd(enc->time_base.num, enc->time_base.den);
1499  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1500  ", %d/%d",
1501  enc->time_base.num / g, enc->time_base.den / g);
1502  }
1503  }
1504  if (encode) {
1505  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1506  ", q=%d-%d", enc->qmin, enc->qmax);
1507  } else {
1509  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1510  ", Closed Captions");
1512  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1513  ", lossless");
1514  }
1515  break;
1516  case AVMEDIA_TYPE_AUDIO:
1517  av_strlcat(buf, separator, buf_size);
1518 
1519  if (enc->sample_rate) {
1520  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1521  "%d Hz, ", enc->sample_rate);
1522  }
1523  av_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
1524  if (enc->sample_fmt != AV_SAMPLE_FMT_NONE) {
1525  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1526  ", %s", av_get_sample_fmt_name(enc->sample_fmt));
1527  }
1528  if ( enc->bits_per_raw_sample > 0
1530  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1531  " (%d bit)", enc->bits_per_raw_sample);
1532  if (av_log_get_level() >= AV_LOG_VERBOSE) {
1533  if (enc->initial_padding)
1534  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1535  ", delay %d", enc->initial_padding);
1536  if (enc->trailing_padding)
1537  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1538  ", padding %d", enc->trailing_padding);
1539  }
1540  break;
1541  case AVMEDIA_TYPE_DATA:
1542  if (av_log_get_level() >= AV_LOG_DEBUG) {
1543  int g = av_gcd(enc->time_base.num, enc->time_base.den);
1544  if (g)
1545  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1546  ", %d/%d",
1547  enc->time_base.num / g, enc->time_base.den / g);
1548  }
1549  break;
1550  case AVMEDIA_TYPE_SUBTITLE:
1551  if (enc->width)
1552  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1553  ", %dx%d", enc->width, enc->height);
1554  break;
1555  default:
1556  return;
1557  }
1558  if (encode) {
1559  if (enc->flags & AV_CODEC_FLAG_PASS1)
1560  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1561  ", pass 1");
1562  if (enc->flags & AV_CODEC_FLAG_PASS2)
1563  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1564  ", pass 2");
1565  }
1566  bitrate = get_bit_rate(enc);
1567  if (bitrate != 0) {
1568  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1569  ", %"PRId64" kb/s", bitrate / 1000);
1570  } else if (enc->rc_max_rate > 0) {
1571  snprintf(buf + strlen(buf), buf_size - strlen(buf),
1572  ", max. %"PRId64" kb/s", enc->rc_max_rate / 1000);
1573  }
1574 }
1575 
1576 const char *av_get_profile_name(const AVCodec *codec, int profile)
1577 {
1578  const AVProfile *p;
1579  if (profile == FF_PROFILE_UNKNOWN || !codec->profiles)
1580  return NULL;
1581 
1582  for (p = codec->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
1583  if (p->profile == profile)
1584  return p->name;
1585 
1586  return NULL;
1587 }
1588 
1590 {
1591  const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
1592  const AVProfile *p;
1593 
1594  if (profile == FF_PROFILE_UNKNOWN || !desc || !desc->profiles)
1595  return NULL;
1596 
1597  for (p = desc->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
1598  if (p->profile == profile)
1599  return p->name;
1600 
1601  return NULL;
1602 }
1603 
1604 unsigned avcodec_version(void)
1605 {
1606 // av_assert0(AV_CODEC_ID_V410==164);
1609 // av_assert0(AV_CODEC_ID_BMV_AUDIO==86071);
1610  av_assert0(AV_CODEC_ID_SRT==94216);
1612 
1613  return LIBAVCODEC_VERSION_INT;
1614 }
1615 
1616 const char *avcodec_configuration(void)
1617 {
1618  return FFMPEG_CONFIGURATION;
1619 }
1620 
1621 const char *avcodec_license(void)
1622 {
1623 #define LICENSE_PREFIX "libavcodec license: "
1624  return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
1625 }
1626 
1628 {
1629  switch (codec_id) {
1630  case AV_CODEC_ID_8SVX_EXP:
1631  case AV_CODEC_ID_8SVX_FIB:
1632  case AV_CODEC_ID_ADPCM_CT:
1640  return 4;
1641  case AV_CODEC_ID_DSD_LSBF:
1642  case AV_CODEC_ID_DSD_MSBF:
1645  case AV_CODEC_ID_PCM_ALAW:
1646  case AV_CODEC_ID_PCM_MULAW:
1647  case AV_CODEC_ID_PCM_S8:
1649  case AV_CODEC_ID_PCM_U8:
1650  case AV_CODEC_ID_PCM_ZORK:
1651  case AV_CODEC_ID_SDX2_DPCM:
1652  return 8;
1653  case AV_CODEC_ID_PCM_S16BE:
1655  case AV_CODEC_ID_PCM_S16LE:
1657  case AV_CODEC_ID_PCM_U16BE:
1658  case AV_CODEC_ID_PCM_U16LE:
1659  return 16;
1661  case AV_CODEC_ID_PCM_S24BE:
1662  case AV_CODEC_ID_PCM_S24LE:
1664  case AV_CODEC_ID_PCM_U24BE:
1665  case AV_CODEC_ID_PCM_U24LE:
1666  return 24;
1667  case AV_CODEC_ID_PCM_S32BE:
1668  case AV_CODEC_ID_PCM_S32LE:
1670  case AV_CODEC_ID_PCM_U32BE:
1671  case AV_CODEC_ID_PCM_U32LE:
1672  case AV_CODEC_ID_PCM_F32BE:
1673  case AV_CODEC_ID_PCM_F32LE:
1674  case AV_CODEC_ID_PCM_F24LE:
1675  case AV_CODEC_ID_PCM_F16LE:
1676  return 32;
1677  case AV_CODEC_ID_PCM_F64BE:
1678  case AV_CODEC_ID_PCM_F64LE:
1679  case AV_CODEC_ID_PCM_S64BE:
1680  case AV_CODEC_ID_PCM_S64LE:
1681  return 64;
1682  default:
1683  return 0;
1684  }
1685 }
1686 
1688 {
1689  static const enum AVCodecID map[AV_SAMPLE_FMT_NB][2] = {
1695  [AV_SAMPLE_FMT_U8P ] = { AV_CODEC_ID_PCM_U8, AV_CODEC_ID_PCM_U8 },
1696  [AV_SAMPLE_FMT_S16P] = { AV_CODEC_ID_PCM_S16LE, AV_CODEC_ID_PCM_S16BE },
1697  [AV_SAMPLE_FMT_S32P] = { AV_CODEC_ID_PCM_S32LE, AV_CODEC_ID_PCM_S32BE },
1699  [AV_SAMPLE_FMT_FLTP] = { AV_CODEC_ID_PCM_F32LE, AV_CODEC_ID_PCM_F32BE },
1700  [AV_SAMPLE_FMT_DBLP] = { AV_CODEC_ID_PCM_F64LE, AV_CODEC_ID_PCM_F64BE },
1701  };
1702  if (fmt < 0 || fmt >= AV_SAMPLE_FMT_NB)
1703  return AV_CODEC_ID_NONE;
1704  if (be < 0 || be > 1)
1705  be = AV_NE(1, 0);
1706  return map[fmt][be];
1707 }
1708 
1710 {
1711  switch (codec_id) {
1713  return 2;
1715  return 3;
1719  case AV_CODEC_ID_ADPCM_SWF:
1720  case AV_CODEC_ID_ADPCM_MS:
1721  return 4;
1722  default:
1723  return av_get_exact_bits_per_sample(codec_id);
1724  }
1725 }
1726 
1727 static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
1728  uint32_t tag, int bits_per_coded_sample, int64_t bitrate,
1729  uint8_t * extradata, int frame_size, int frame_bytes)
1730 {
1732  int framecount = (ba > 0 && frame_bytes / ba > 0) ? frame_bytes / ba : 1;
1733 
1734  /* codecs with an exact constant bits per sample */
1735  if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
1736  return (frame_bytes * 8LL) / (bps * ch);
1737  bps = bits_per_coded_sample;
1738 
1739  /* codecs with a fixed packet duration */
1740  switch (id) {
1741  case AV_CODEC_ID_ADPCM_ADX: return 32;
1742  case AV_CODEC_ID_ADPCM_IMA_QT: return 64;
1743  case AV_CODEC_ID_ADPCM_EA_XAS: return 128;
1744  case AV_CODEC_ID_AMR_NB:
1745  case AV_CODEC_ID_EVRC:
1746  case AV_CODEC_ID_GSM:
1747  case AV_CODEC_ID_QCELP:
1748  case AV_CODEC_ID_RA_288: return 160;
1749  case AV_CODEC_ID_AMR_WB:
1750  case AV_CODEC_ID_GSM_MS: return 320;
1751  case AV_CODEC_ID_MP1: return 384;
1752  case AV_CODEC_ID_ATRAC1: return 512;
1753  case AV_CODEC_ID_ATRAC3: return 1024 * framecount;
1754  case AV_CODEC_ID_ATRAC3P: return 2048;
1755  case AV_CODEC_ID_MP2:
1756  case AV_CODEC_ID_MUSEPACK7: return 1152;
1757  case AV_CODEC_ID_AC3: return 1536;
1758  }
1759 
1760  if (sr > 0) {
1761  /* calc from sample rate */
1762  if (id == AV_CODEC_ID_TTA)
1763  return 256 * sr / 245;
1764  else if (id == AV_CODEC_ID_DST)
1765  return 588 * sr / 44100;
1766 
1767  if (ch > 0) {
1768  /* calc from sample rate and channels */
1769  if (id == AV_CODEC_ID_BINKAUDIO_DCT) {
1770  if (sr / 22050 > 22)
1771  return 0;
1772  return (480 << (sr / 22050)) / ch;
1773  }
1774  }
1775 
1776  if (id == AV_CODEC_ID_MP3)
1777  return sr <= 24000 ? 576 : 1152;
1778  }
1779 
1780  if (ba > 0) {
1781  /* calc from block_align */
1782  if (id == AV_CODEC_ID_SIPR) {
1783  switch (ba) {
1784  case 20: return 160;
1785  case 19: return 144;
1786  case 29: return 288;
1787  case 37: return 480;
1788  }
1789  } else if (id == AV_CODEC_ID_ILBC) {
1790  switch (ba) {
1791  case 38: return 160;
1792  case 50: return 240;
1793  }
1794  }
1795  }
1796 
1797  if (frame_bytes > 0) {
1798  /* calc from frame_bytes only */
1799  if (id == AV_CODEC_ID_TRUESPEECH)
1800  return 240 * (frame_bytes / 32);
1801  if (id == AV_CODEC_ID_NELLYMOSER)
1802  return 256 * (frame_bytes / 64);
1803  if (id == AV_CODEC_ID_RA_144)
1804  return 160 * (frame_bytes / 20);
1805  if (id == AV_CODEC_ID_G723_1)
1806  return 240 * (frame_bytes / 24);
1807 
1808  if (bps > 0) {
1809  /* calc from frame_bytes and bits_per_coded_sample */
1811  return frame_bytes * 8 / bps;
1812  }
1813 
1814  if (ch > 0 && ch < INT_MAX/16) {
1815  /* calc from frame_bytes and channels */
1816  switch (id) {
1817  case AV_CODEC_ID_ADPCM_AFC:
1818  return frame_bytes / (9 * ch) * 16;
1819  case AV_CODEC_ID_ADPCM_PSX:
1820  case AV_CODEC_ID_ADPCM_DTK:
1821  frame_bytes /= 16 * ch;
1822  if (frame_bytes > INT_MAX / 28)
1823  return 0;
1824  return frame_bytes * 28;
1825  case AV_CODEC_ID_ADPCM_4XM:
1828  return (frame_bytes - 4 * ch) * 2 / ch;
1830  return (frame_bytes - 4) * 2 / ch;
1832  return (frame_bytes - 8) * 2 / ch;
1833  case AV_CODEC_ID_ADPCM_THP:
1835  if (extradata)
1836  return frame_bytes * 14LL / (8 * ch);
1837  break;
1838  case AV_CODEC_ID_ADPCM_XA:
1839  return (frame_bytes / 128) * 224 / ch;
1841  return (frame_bytes - 6 - ch) / ch;
1842  case AV_CODEC_ID_ROQ_DPCM:
1843  return (frame_bytes - 8) / ch;
1844  case AV_CODEC_ID_XAN_DPCM:
1845  return (frame_bytes - 2 * ch) / ch;
1846  case AV_CODEC_ID_MACE3:
1847  return 3 * frame_bytes / ch;
1848  case AV_CODEC_ID_MACE6:
1849  return 6 * frame_bytes / ch;
1850  case AV_CODEC_ID_PCM_LXF:
1851  return 2 * (frame_bytes / (5 * ch));
1852  case AV_CODEC_ID_IAC:
1853  case AV_CODEC_ID_IMC:
1854  return 4 * frame_bytes / ch;
1855  }
1856 
1857  if (tag) {
1858  /* calc from frame_bytes, channels, and codec_tag */
1859  if (id == AV_CODEC_ID_SOL_DPCM) {
1860  if (tag == 3)
1861  return frame_bytes / ch;
1862  else
1863  return frame_bytes * 2 / ch;
1864  }
1865  }
1866 
1867  if (ba > 0) {
1868  /* calc from frame_bytes, channels, and block_align */
1869  int blocks = frame_bytes / ba;
1870  int64_t tmp = 0;
1871  switch (id) {
1873  if (bps < 2 || bps > 5)
1874  return 0;
1875  tmp = blocks * (1LL + (ba - 4 * ch) / (bps * ch) * 8);
1876  break;
1878  tmp = blocks * (((ba - 16LL) * 2 / 3 * 4) / ch);
1879  break;
1881  tmp = blocks * (1 + (ba - 4LL * ch) * 2 / ch);
1882  break;
1884  tmp = blocks * ((ba - 4LL * ch) * 2 / ch);
1885  break;
1886  case AV_CODEC_ID_ADPCM_MS:
1887  tmp = blocks * (2 + (ba - 7LL * ch) * 2LL / ch);
1888  break;
1890  tmp = blocks * (ba - 16LL) * 2 / ch;
1891  break;
1892  }
1893  if (tmp) {
1894  if (tmp != (int)tmp)
1895  return 0;
1896  return tmp;
1897  }
1898  }
1899 
1900  if (bps > 0) {
1901  /* calc from frame_bytes, channels, and bits_per_coded_sample */
1902  switch (id) {
1903  case AV_CODEC_ID_PCM_DVD:
1904  if(bps<4)
1905  return 0;
1906  return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
1908  if(bps<4)
1909  return 0;
1910  return frame_bytes / ((FFALIGN(ch, 2) * bps) / 8);
1911  case AV_CODEC_ID_S302M:
1912  return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
1913  }
1914  }
1915  }
1916  }
1917 
1918  /* Fall back on using frame_size */
1919  if (frame_size > 1 && frame_bytes)
1920  return frame_size;
1921 
1922  //For WMA we currently have no other means to calculate duration thus we
1923  //do it here by assuming CBR, which is true for all known cases.
1924  if (bitrate > 0 && frame_bytes > 0 && sr > 0 && ba > 1) {
1925  if (id == AV_CODEC_ID_WMAV1 || id == AV_CODEC_ID_WMAV2)
1926  return (frame_bytes * 8LL * sr) / bitrate;
1927  }
1928 
1929  return 0;
1930 }
1931 
1932 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
1933 {
1935  avctx->channels, avctx->block_align,
1936  avctx->codec_tag, avctx->bits_per_coded_sample,
1937  avctx->bit_rate, avctx->extradata, avctx->frame_size,
1938  frame_bytes);
1939  return FFMAX(0, duration);
1940 }
1941 
1943 {
1945  par->channels, par->block_align,
1946  par->codec_tag, par->bits_per_coded_sample,
1947  par->bit_rate, par->extradata, par->frame_size,
1948  frame_bytes);
1949  return FFMAX(0, duration);
1950 }
1951 
1952 #if !HAVE_THREADS
1954 {
1955  return -1;
1956 }
1957 
1958 #endif
1959 
1960 unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
1961 {
1962  unsigned int n = 0;
1963 
1964  while (v >= 0xff) {
1965  *s++ = 0xff;
1966  v -= 0xff;
1967  n++;
1968  }
1969  *s = v;
1970  n++;
1971  return n;
1972 }
1973 
1974 int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
1975 {
1976  int i;
1977  for (i = 0; i < size && !(tab[i][0] == a && tab[i][1] == b); i++) ;
1978  return i;
1979 }
1980 
1981 #if FF_API_MISSING_SAMPLE
1983 void av_log_missing_feature(void *avc, const char *feature, int want_sample)
1984 {
1985  av_log(avc, AV_LOG_WARNING, "%s is not implemented. Update your FFmpeg "
1986  "version to the newest one from Git. If the problem still "
1987  "occurs, it means that your file has a feature which has not "
1988  "been implemented.\n", feature);
1989  if(want_sample)
1991 }
1992 
1993 void av_log_ask_for_sample(void *avc, const char *msg, ...)
1994 {
1995  va_list argument_list;
1996 
1997  va_start(argument_list, msg);
1998 
1999  if (msg)
2000  av_vlog(avc, AV_LOG_WARNING, msg, argument_list);
2001  av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
2002  "of this file to ftp://upload.ffmpeg.org/incoming/ "
2003  "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n");
2004 
2005  va_end(argument_list);
2006 }
2008 #endif /* FF_API_MISSING_SAMPLE */
2009 
2012 
2014 {
2015  AVHWAccel **p = last_hwaccel;
2016  hwaccel->next = NULL;
2017  while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
2018  p = &(*p)->next;
2019  last_hwaccel = &hwaccel->next;
2020 }
2021 
2023 {
2024  return hwaccel ? hwaccel->next : first_hwaccel;
2025 }
2026 
2027 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
2028 {
2029  if (lockmgr_cb) {
2030  // There is no good way to rollback a failure to destroy the
2031  // mutex, so we ignore failures.
2034  lockmgr_cb = NULL;
2035  codec_mutex = NULL;
2036  avformat_mutex = NULL;
2037  }
2038 
2039  if (cb) {
2040  void *new_codec_mutex = NULL;
2041  void *new_avformat_mutex = NULL;
2042  int err;
2043  if (err = cb(&new_codec_mutex, AV_LOCK_CREATE)) {
2044  return err > 0 ? AVERROR_UNKNOWN : err;
2045  }
2046  if (err = cb(&new_avformat_mutex, AV_LOCK_CREATE)) {
2047  // Ignore failures to destroy the newly created mutex.
2048  cb(&new_codec_mutex, AV_LOCK_DESTROY);
2049  return err > 0 ? AVERROR_UNKNOWN : err;
2050  }
2051  lockmgr_cb = cb;
2052  codec_mutex = new_codec_mutex;
2053  avformat_mutex = new_avformat_mutex;
2054  }
2055 
2056  return 0;
2057 }
2058 
2059 int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
2060 {
2061  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
2062  return 0;
2063 
2064  if (lockmgr_cb) {
2066  return -1;
2067  }
2068 
2070  av_log(log_ctx, AV_LOG_ERROR,
2071  "Insufficient thread locking. At least %d threads are "
2072  "calling avcodec_open2() at the same time right now.\n",
2074  if (!lockmgr_cb)
2075  av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see av_lockmgr_register()\n");
2076  ff_avcodec_locked = 1;
2077  ff_unlock_avcodec(codec);
2078  return AVERROR(EINVAL);
2079  }
2081  ff_avcodec_locked = 1;
2082  return 0;
2083 }
2084 
2085 int ff_unlock_avcodec(const AVCodec *codec)
2086 {
2087  if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init)
2088  return 0;
2089 
2091  ff_avcodec_locked = 0;
2093  if (lockmgr_cb) {
2095  return -1;
2096  }
2097 
2098  return 0;
2099 }
2100 
2102 {
2103  if (lockmgr_cb) {
2105  return -1;
2106  }
2107  return 0;
2108 }
2109 
2111 {
2112  if (lockmgr_cb) {
2114  return -1;
2115  }
2116  return 0;
2117 }
2118 
2119 unsigned int avpriv_toupper4(unsigned int x)
2120 {
2121  return av_toupper(x & 0xFF) +
2122  (av_toupper((x >> 8) & 0xFF) << 8) +
2123  (av_toupper((x >> 16) & 0xFF) << 16) +
2124 ((unsigned)av_toupper((x >> 24) & 0xFF) << 24);
2125 }
2126 
2128 {
2129  int ret;
2130 
2131  dst->owner[0] = src->owner[0];
2132  dst->owner[1] = src->owner[1];
2133 
2134  ret = av_frame_ref(dst->f, src->f);
2135  if (ret < 0)
2136  return ret;
2137 
2138  av_assert0(!dst->progress);
2139 
2140  if (src->progress &&
2141  !(dst->progress = av_buffer_ref(src->progress))) {
2142  ff_thread_release_buffer(dst->owner[0], dst);
2143  return AVERROR(ENOMEM);
2144  }
2145 
2146  return 0;
2147 }
2148 
2149 #if !HAVE_THREADS
2150 
2152 {
2153  return ff_get_format(avctx, fmt);
2154 }
2155 
2157 {
2158  f->owner[0] = f->owner[1] = avctx;
2159  return ff_get_buffer(avctx, f->f, flags);
2160 }
2161 
2163 {
2164  if (f->f)
2165  av_frame_unref(f->f);
2166 }
2167 
2169 {
2170 }
2171 
2172 void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
2173 {
2174 }
2175 
2176 void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
2177 {
2178 }
2179 
2181 {
2182  return 1;
2183 }
2184 
2186 {
2187  return 0;
2188 }
2189 
2191 {
2192 }
2193 
2194 void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
2195 {
2196 }
2197 
2198 void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
2199 {
2200 }
2201 
2202 #endif
2203 
2205 {
2206  return !!s->internal;
2207 }
2208 
2209 int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
2210 {
2211  int ret;
2212  char *str;
2213 
2214  ret = av_bprint_finalize(buf, &str);
2215  if (ret < 0)
2216  return ret;
2217  if (!av_bprint_is_complete(buf)) {
2218  av_free(str);
2219  return AVERROR(ENOMEM);
2220  }
2221 
2222  avctx->extradata = str;
2223  /* Note: the string is NUL terminated (so extradata can be read as a
2224  * string), but the ending character is not accounted in the size (in
2225  * binary formats you are likely not supposed to mux that character). When
2226  * extradata is copied, it is also padded with AV_INPUT_BUFFER_PADDING_SIZE
2227  * zeros. */
2228  avctx->extradata_size = buf->len;
2229  return 0;
2230 }
2231 
2233  const uint8_t *end,
2234  uint32_t *av_restrict state)
2235 {
2236  int i;
2237 
2238  av_assert0(p <= end);
2239  if (p >= end)
2240  return end;
2241 
2242  for (i = 0; i < 3; i++) {
2243  uint32_t tmp = *state << 8;
2244  *state = tmp + *(p++);
2245  if (tmp == 0x100 || p == end)
2246  return p;
2247  }
2248 
2249  while (p < end) {
2250  if (p[-1] > 1 ) p += 3;
2251  else if (p[-2] ) p += 2;
2252  else if (p[-3]|(p[-1]-1)) p++;
2253  else {
2254  p++;
2255  break;
2256  }
2257  }
2258 
2259  p = FFMIN(p, end) - 4;
2260  *state = AV_RB32(p);
2261 
2262  return p + 4;
2263 }
2264 
2266 {
2267  AVCPBProperties *props = av_mallocz(sizeof(AVCPBProperties));
2268  if (!props)
2269  return NULL;
2270 
2271  if (size)
2272  *size = sizeof(*props);
2273 
2274  props->vbv_delay = UINT64_MAX;
2275 
2276  return props;
2277 }
2278 
2280 {
2282  AVCPBProperties *props;
2283  size_t size;
2284 
2285  props = av_cpb_properties_alloc(&size);
2286  if (!props)
2287  return NULL;
2288 
2289  tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp));
2290  if (!tmp) {
2291  av_freep(&props);
2292  return NULL;
2293  }
2294 
2295  avctx->coded_side_data = tmp;
2296  avctx->nb_coded_side_data++;
2297 
2299  avctx->coded_side_data[avctx->nb_coded_side_data - 1].data = (uint8_t*)props;
2300  avctx->coded_side_data[avctx->nb_coded_side_data - 1].size = size;
2301 
2302  return props;
2303 }
2304 
2306 {
2307  av_freep(&par->extradata);
2308 
2309  memset(par, 0, sizeof(*par));
2310 
2312  par->codec_id = AV_CODEC_ID_NONE;
2313  par->format = -1;
2320  par->sample_aspect_ratio = (AVRational){ 0, 1 };
2321  par->profile = FF_PROFILE_UNKNOWN;
2322  par->level = FF_LEVEL_UNKNOWN;
2323 }
2324 
2326 {
2327  AVCodecParameters *par = av_mallocz(sizeof(*par));
2328 
2329  if (!par)
2330  return NULL;
2332  return par;
2333 }
2334 
2336 {
2337  AVCodecParameters *par = *ppar;
2338 
2339  if (!par)
2340  return;
2342 
2343  av_freep(ppar);
2344 }
2345 
2347 {
2349  memcpy(dst, src, sizeof(*dst));
2350 
2351  dst->extradata = NULL;
2352  dst->extradata_size = 0;
2353  if (src->extradata) {
2355  if (!dst->extradata)
2356  return AVERROR(ENOMEM);
2357  memcpy(dst->extradata, src->extradata, src->extradata_size);
2358  dst->extradata_size = src->extradata_size;
2359  }
2360 
2361  return 0;
2362 }
2363 
2365  const AVCodecContext *codec)
2366 {
2368 
2369  par->codec_type = codec->codec_type;
2370  par->codec_id = codec->codec_id;
2371  par->codec_tag = codec->codec_tag;
2372 
2373  par->bit_rate = codec->bit_rate;
2376  par->profile = codec->profile;
2377  par->level = codec->level;
2378 
2379  switch (par->codec_type) {
2380  case AVMEDIA_TYPE_VIDEO:
2381  par->format = codec->pix_fmt;
2382  par->width = codec->width;
2383  par->height = codec->height;
2384  par->field_order = codec->field_order;
2385  par->color_range = codec->color_range;
2386  par->color_primaries = codec->color_primaries;
2387  par->color_trc = codec->color_trc;
2388  par->color_space = codec->colorspace;
2391  par->video_delay = codec->has_b_frames;
2392  break;
2393  case AVMEDIA_TYPE_AUDIO:
2394  par->format = codec->sample_fmt;
2395  par->channel_layout = codec->channel_layout;
2396  par->channels = codec->channels;
2397  par->sample_rate = codec->sample_rate;
2398  par->block_align = codec->block_align;
2399  par->frame_size = codec->frame_size;
2400  par->initial_padding = codec->initial_padding;
2401  par->trailing_padding = codec->trailing_padding;
2402  par->seek_preroll = codec->seek_preroll;
2403  break;
2404  case AVMEDIA_TYPE_SUBTITLE:
2405  par->width = codec->width;
2406  par->height = codec->height;
2407  break;
2408  }
2409 
2410  if (codec->extradata) {
2412  if (!par->extradata)
2413  return AVERROR(ENOMEM);
2414  memcpy(par->extradata, codec->extradata, codec->extradata_size);
2415  par->extradata_size = codec->extradata_size;
2416  }
2417 
2418  return 0;
2419 }
2420 
2422  const AVCodecParameters *par)
2423 {
2424  codec->codec_type = par->codec_type;
2425  codec->codec_id = par->codec_id;
2426  codec->codec_tag = par->codec_tag;
2427 
2428  codec->bit_rate = par->bit_rate;
2431  codec->profile = par->profile;
2432  codec->level = par->level;
2433 
2434  switch (par->codec_type) {
2435  case AVMEDIA_TYPE_VIDEO:
2436  codec->pix_fmt = par->format;
2437  codec->width = par->width;
2438  codec->height = par->height;
2439  codec->field_order = par->field_order;
2440  codec->color_range = par->color_range;
2441  codec->color_primaries = par->color_primaries;
2442  codec->color_trc = par->color_trc;
2443  codec->colorspace = par->color_space;
2446  codec->has_b_frames = par->video_delay;
2447  break;
2448  case AVMEDIA_TYPE_AUDIO:
2449  codec->sample_fmt = par->format;
2450  codec->channel_layout = par->channel_layout;
2451  codec->channels = par->channels;
2452  codec->sample_rate = par->sample_rate;
2453  codec->block_align = par->block_align;
2454  codec->frame_size = par->frame_size;
2455  codec->delay =
2456  codec->initial_padding = par->initial_padding;
2457  codec->trailing_padding = par->trailing_padding;
2458  codec->seek_preroll = par->seek_preroll;
2459  break;
2460  case AVMEDIA_TYPE_SUBTITLE:
2461  codec->width = par->width;
2462  codec->height = par->height;
2463  break;
2464  }
2465 
2466  if (par->extradata) {
2467  av_freep(&codec->extradata);
2469  if (!codec->extradata)
2470  return AVERROR(ENOMEM);
2471  memcpy(codec->extradata, par->extradata, par->extradata_size);
2472  codec->extradata_size = par->extradata_size;
2473  }
2474 
2475  return 0;
2476 }
2477 
2478 int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
2479  void **data, size_t *sei_size)
2480 {
2481  AVFrameSideData *side_data = NULL;
2482  uint8_t *sei_data;
2483 
2484  if (frame)
2485  side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC);
2486 
2487  if (!side_data) {
2488  *data = NULL;
2489  return 0;
2490  }
2491 
2492  *sei_size = side_data->size + 11;
2493  *data = av_mallocz(*sei_size + prefix_len);
2494  if (!*data)
2495  return AVERROR(ENOMEM);
2496  sei_data = (uint8_t*)*data + prefix_len;
2497 
2498  // country code
2499  sei_data[0] = 181;
2500  sei_data[1] = 0;
2501  sei_data[2] = 49;
2502 
2503  /**
2504  * 'GA94' is standard in North America for ATSC, but hard coding
2505  * this style may not be the right thing to do -- other formats
2506  * do exist. This information is not available in the side_data
2507  * so we are going with this right now.
2508  */
2509  AV_WL32(sei_data + 3, MKTAG('G', 'A', '9', '4'));
2510  sei_data[7] = 3;
2511  sei_data[8] = ((side_data->size/3) & 0x1f) | 0x40;
2512  sei_data[9] = 0;
2513 
2514  memcpy(sei_data + 10, side_data->data, side_data->size);
2515 
2516  sei_data[side_data->size+10] = 255;
2517 
2518  return 0;
2519 }
2520 
2522 {
2523  AVRational framerate = avctx->framerate;
2524  int bits_per_coded_sample = avctx->bits_per_coded_sample;
2525  int64_t bitrate;
2526 
2527  if (!(framerate.num && framerate.den))
2528  framerate = av_inv_q(avctx->time_base);
2529  if (!(framerate.num && framerate.den))
2530  return 0;
2531 
2532  if (!bits_per_coded_sample) {
2534  bits_per_coded_sample = av_get_bits_per_pixel(desc);
2535  }
2536  bitrate = (int64_t)bits_per_coded_sample * avctx->width * avctx->height *
2537  framerate.num / framerate.den;
2538 
2539  return bitrate;
2540 }
int64_t ff_guess_coded_bitrate(AVCodecContext *avctx)
Get an estimated video bitrate based on frame size, frame rate and coded bits per pixel...
Definition: utils.c:2521
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
const char * name
Definition: avisynth_c.h:775
#define FF_SANE_NB_CHANNELS
Definition: internal.h:90
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: avcodec.h:2986
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:86
#define CONFIG_FRAME_THREAD_ENCODER
Definition: config.h:601
enum AVChromaLocation chroma_location
Definition: avcodec.h:4242
float, planar
Definition: samplefmt.h:69
#define FF_SUB_CHARENC_MODE_PRE_DECODER
the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv ...
Definition: avcodec.h:3518
#define NULL
Definition: coverity.c:32
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
Definition: decode.c:1184
const struct AVCodec * codec
Definition: avcodec.h:1770
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:181
AVRational framerate
Definition: avcodec.h:3460
#define avpriv_atomic_int_add_and_fetch
Definition: atomic_gcc.h:42
enum AVFieldOrder field_order
Video only.
Definition: avcodec.h:4233
static int64_t get_bit_rate(AVCodecContext *ctx)
Definition: utils.c:611
const AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
Definition: avcodec.h:3481
static AVCodec * find_encdec(enum AVCodecID id, int encoder)
Definition: utils.c:1285
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:293
const char * s
Definition: avisynth_c.h:768
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:270
uint32_t fourcc
Definition: hwcontext_qsv.c:90
enum AVColorTransferCharacteristic color_trc
Definition: avcodec.h:4240
Number of sample formats. DO NOT USE if linking dynamically.
Definition: samplefmt.h:74
#define AV_NUM_DATA_POINTERS
Definition: frame.h:202
static int shift(int a, int b)
Definition: sonic.c:82
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:263
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
Definition: os2threads.h:106
#define FF_SUB_CHARENC_MODE_AUTOMATIC
libavcodec will select the mode itself
Definition: avcodec.h:3517
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
Definition: avcodec.h:3498
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:125
int size
unsigned int fourcc
Definition: raw.h:35
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2419
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
#define pthread_mutex_lock(a)
Definition: ffprobe.c:61
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: utils.c:1303
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:267
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:174
static struct @260 state
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:1963
const char * fmt
Definition: avisynth_c.h:769
int av_lockmgr_register(int(*cb)(void **mutex, enum AVLockOp op))
Register a user provided lock manager supporting the operations specified by AVLockOp.
Definition: utils.c:2027
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
Definition: internal.h:174
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
misc image utilities
Unlock the mutex.
Definition: avcodec.h:6334
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
AVFrame * f
Definition: thread.h:36
int64_t bit_rate
the average bitrate
Definition: avcodec.h:1826
AVFrame * to_free
Definition: internal.h:161
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
const char * g
Definition: vf_curves.c:112
const char * desc
Definition: nvenc.c:60
#define LIBAVCODEC_VERSION_MICRO
Definition: version.h:32
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:177
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:2371
AVRational sample_aspect_ratio
Video only.
Definition: avcodec.h:4228
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
Definition: avcodec.h:2801
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:268
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1291
const char * avcodec_configuration(void)
Return the libavcodec build-time configuration.
Definition: utils.c:1616
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:2498
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:4152
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:184
int ff_unlock_avcodec(const AVCodec *codec)
Definition: utils.c:2085
int num
Numerator.
Definition: rational.h:59
#define FF_SUB_CHARENC_MODE_DO_NOTHING
do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for inst...
Definition: avcodec.h:3516
const char * b
Definition: vf_curves.c:113
const char * avcodec_license(void)
Return the libavcodec license.
Definition: utils.c:1621
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
Definition: avcodec.h:2172
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:205
double, planar
Definition: samplefmt.h:70
enum AVMediaType codec_type
Definition: rtp.c:37
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1989
enum AVPixelFormat pix_fmt
Definition: raw.h:34
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Definition: dict.c:217
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:206
unsigned num_rects
Definition: avcodec.h:4132
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec)
Definition: utils.c:607
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
Definition: utils.c:121
planar GBR 4:4:4 36bpp, little-endian
Definition: pixfmt.h:273
The following 12 formats have the disadvantage of needing 1 format for each bit depth.
Definition: pixfmt.h:171
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:1057
mpegvideo header.
enum AVMediaType type
Definition: avcodec.h:3752
AVBufferPool * pools[4]
Pools for each data plane.
Definition: internal.h:107
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:3164
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Wrapper around get_format() for frame-multithreaded codecs.
Definition: utils.c:2151
int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos)
Converts AVChromaLocation to swscale x/y chroma position.
Definition: utils.c:466
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
Definition: avcodec.h:1077
int trailing_padding
Audio only.
Definition: avcodec.h:4288
#define src
Definition: vp8dsp.c:254
int profile
profile
Definition: avcodec.h:3266
planar GBR 4:4:4 36bpp, big-endian
Definition: pixfmt.h:272
AVCodec.
Definition: avcodec.h:3739
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:143
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
Definition: avcodec.h:2560
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
This struct describes the properties of an encoded stream.
Definition: avcodec.h:4144
AVLockOp
Lock operation used by lockmgr.
Definition: avcodec.h:6331
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:211
#define FFMPEG_LICENSE
Definition: config.h:5
char * text
0 terminated plain UTF-8 text
Definition: avcodec.h:4116
enum AVColorSpace color_space
Definition: avcodec.h:4241
unsigned avcodec_get_edge_width(void)
Return the amount of padding in pixels which the get_buffer callback must provide around the edge of ...
Definition: utils.c:195
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:2803
Macro definitions for various function/variable attributes.
FF_DISABLE_DEPRECATION_WARNINGS void av_log_missing_feature(void *avc, const char *feature, int want_sample)
Log a generic warning message about a missing feature.
Definition: utils.c:1983
static void * codec_mutex
Definition: utils.c:118
void ff_decode_bsfs_uninit(AVCodecContext *avctx)
Definition: decode.c:1752
int frame_size
Audio only.
Definition: avcodec.h:4273
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1898
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:682
AVSubtitleRect ** rects
Definition: avcodec.h:4133
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:174
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
Definition: avcodec.h:3992
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
Definition: utils.c:2194
int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align)
Fill AVFrame audio data and linesize pointers.
Definition: utils.c:489
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:169
uint64_t vbv_delay
The delay between the time the packet this structure is associated with is received and the time when...
Definition: avcodec.h:1384
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian ...
Definition: pixfmt.h:195
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
Modify width and height values so that they will result in a memory buffer that is acceptable for the...
Definition: utils.c:451
#define FF_LEVEL_UNKNOWN
Definition: avcodec.h:3365
struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:3082
static int volatile entangled_thread_counter
Definition: utils.c:117
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
planar GBRA 4:4:4:4 64bpp, big-endian
Definition: pixfmt.h:234
Public dictionary API.
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:206
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:106
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:106
HMTX pthread_mutex_t
Definition: os2threads.h:49
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:62
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:2531
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
Lock the mutex.
Definition: avcodec.h:6333
uint8_t
#define av_cold
Definition: attributes.h:82
#define av_malloc(s)
AV_SAMPLE_FMT_U8
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:150
Opaque data information usually continuous.
Definition: avutil.h:203
int width
Video only.
Definition: avcodec.h:4218
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
AVOptions.
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
Definition: utils.c:2325
const char * av_color_range_name(enum AVColorRange range)
Definition: pixdesc.c:2746
#define AV_RB32
Definition: intreadwrite.h:130
void * thread_ctx
Definition: internal.h:165
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
static AVCodec * first_avcodec
Definition: utils.c:146
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
Definition: utils.c:241
int trailing_padding
Audio only.
Definition: avcodec.h:3638
Multithreading support functions.
#define AV_NE(be, le)
Definition: common.h:50
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:395
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:269
#define emms_c()
Definition: internal.h:54
#define FF_CODEC_PROPERTY_LOSSLESS
Definition: avcodec.h:3582
#define LIBAVCODEC_VERSION_INT
Definition: version.h:34
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1876
#define LICENSE_PREFIX
int64_t duration
Definition: movenc.c:63
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
Definition: utils.c:2421
static AVFrame * frame
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:207
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Definition: utils.c:2279
Public header for CRC hash function implementation.
void * frame_thread_encoder
Definition: internal.h:182
int initial_padding
Audio only.
Definition: avcodec.h:4281
const char data[16]
Definition: mxf.c:90
Structure to hold side data for an AVFrame.
Definition: frame.h:163
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
Definition: imgutils.c:286
int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Call avcodec_open2 recursively by decrementing counter, unlocking mutex, calling the function and the...
Definition: utils.c:641
planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:294
planar GBR 4:4:4 48bpp, big-endian
Definition: pixfmt.h:190
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:105
static int flags
Definition: log.c:57
uint32_t tag
Definition: movenc.c:1414
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:210
#define av_restrict
Definition: config.h:10
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
Definition: mem.c:412
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
uint8_t * data
Definition: avcodec.h:1623
static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, uint32_t tag, int bits_per_coded_sample, int64_t bitrate, uint8_t *extradata, int frame_size, int frame_bytes)
Definition: utils.c:1727
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
Definition: avcodec.h:3172
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
Definition: samplefmt.c:84
int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
Definition: utils.c:1974
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:3157
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
Definition: pixfmt.h:296
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
Definition: utils.c:226
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:904
signed 32 bits
Definition: samplefmt.h:62
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
Definition: mem.c:184
AVCPBProperties * av_cpb_properties_alloc(size_t *size)
Allocate a CPB properties structure and initialize its fields to default values.
Definition: utils.c:2265
const OptionDef options[]
Definition: ffserver.c:3948
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:2505
static void codec_parameters_reset(AVCodecParameters *par)
Definition: utils.c:2305
#define FFALIGN(x, a)
Definition: macros.h:48
uint64_t channel_layout
Audio only.
Definition: avcodec.h:4254
#define av_log(a,...)
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:112
FramePool * pool
Definition: internal.h:163
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: avcodec.h:4181
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
Definition: avcodec.h:2985
AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
Definition: utils.c:1308
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS])
Modify width and height values so that they will result in a memory buffer that is acceptable for the...
Definition: utils.c:261
static av_cold void avcodec_init(void)
Definition: utils.c:157
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:308
#define EDGE_WIDTH
Definition: mpegpicture.h:33
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:172
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
Definition: utils.c:202
Libavcodec version macros.
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
Definition: utils.c:1210
enum AVCodecID id
Definition: avcodec.h:3753
const uint64_t * channel_layouts
array of support channel layouts, or NULL if unknown. array is terminated by 0
Definition: avcodec.h:3763
planar GBR 4:4:4 27bpp, big-endian
Definition: pixfmt.h:186
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:180
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition: pixdesc.c:2822
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:192
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:214
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
Definition: utils.c:2346
int width
Definition: frame.h:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int has_b_frames
Size of the frame reordering buffer in the decoder.
Definition: avcodec.h:2083
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:1709
#define avpriv_atomic_ptr_cas
Definition: atomic_gcc.h:48
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
Create a mutex.
Definition: avcodec.h:6332
#define MAKE_ACCESSORS(str, name, type, field)
Definition: internal.h:90
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:148
#define AVERROR(e)
Definition: error.h:43
unsigned int avpriv_toupper4(unsigned int x)
Definition: utils.c:2119
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
int(* send_frame)(AVCodecContext *avctx, const AVFrame *frame)
Encode API with decoupled packet/frame dataflow.
Definition: avcodec.h:3832
int qmax
maximum quantizer
Definition: avcodec.h:2712
AVCodec * av_codec_next(const AVCodec *c)
If c is NULL, returns the first registered codec, if c is non-NULL, returns the next registered codec...
Definition: utils.c:149
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
Definition: avcodec.h:3499
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:3211
enum AVColorPrimaries color_primaries
Definition: avcodec.h:4239
int avcodec_is_open(AVCodecContext *s)
Definition: utils.c:2204
int video_delay
Video only.
Definition: avcodec.h:4247
const char * r
Definition: vf_curves.c:111
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
Definition: avstring.c:443
AVFrame * buffer_frame
Definition: internal.h:204
int capabilities
Codec capabilities.
Definition: avcodec.h:3758
int initial_padding
Audio only.
Definition: avcodec.h:3451
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
ATSC A53 Part 4 Closed Captions.
Definition: frame.h:58
int ff_thread_init(AVCodecContext *s)
Definition: utils.c:1953
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
Definition: dict.c:203
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: avcodec.h:557
#define av_fourcc2str(fourcc)
Definition: avutil.h:348
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
Definition: pixfmt.h:198
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:4148
const char * arg
Definition: jacosubdec.c:66
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:176
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:1856
uint16_t width
Definition: gdv.c:47
simple assert() macros that are a bit more flexible than ISO C assert().
planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:266
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:37
enum AVPacketSideDataType type
Definition: avcodec.h:1625
int av_log_get_level(void)
Get the current log level.
Definition: log.c:386
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
const char * name
Name of the codec implementation.
Definition: avcodec.h:3746
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:146
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition: samplefmt.c:49
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:3646
const struct AVProfile * profiles
If non-NULL, an array of profiles recognized for this codec.
Definition: avcodec.h:730
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition: pixfmt.h:199
void ff_thread_free(AVCodecContext *avctx)
Definition: pthread.c:82
#define FFMAX(a, b)
Definition: common.h:94
void avcodec_parameters_free(AVCodecParameters **ppar)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
Definition: utils.c:2335
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
Definition: utils.c:1942
static void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
Definition: mem.h:229
const char av_codec_ffversion[]
Definition: utils.c:66
av_cold void ff_me_cmp_init_static(void)
Definition: me_cmp.c:980
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:2765
reference-counted frame API
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3121
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:2574
int extradata_size
Size of the extradata content in bytes.
Definition: avcodec.h:4170
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
Definition: pixfmt.h:200
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
int rc_buffer_size
decoder bitstream buffer size
Definition: avcodec.h:2739
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
Definition: avcodec.h:719
static AVCodec ** last_avcodec
Definition: utils.c:147
int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options)
Initialize frame thread encoder.
common internal API header
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
Definition: internal.h:260
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
int refs
number of reference frames
Definition: avcodec.h:2442
planar GBR 4:4:4:4 48bpp, big-endian
Definition: pixfmt.h:305
int block_align
Audio only.
Definition: avcodec.h:4269
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
audio channel layout utility functions
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
Definition: avcodec.h:3760
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition: avcodec.h:3203
#define FFMIN(a, b)
Definition: common.h:96
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
Definition: avcodec.h:3591
Raw Video Codec.
signed 32 bits, planar
Definition: samplefmt.h:68
volatile int ff_avcodec_locked
Definition: utils.c:116
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:1627
AVFrame * compat_decode_frame
Definition: internal.h:215
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
Definition: utils.c:2198
int width
picture width / height.
Definition: avcodec.h:1948
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames...
Definition: avcodec.h:3616
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:3267
int priv_data_size
Definition: avcodec.h:3775
int profile
Definition: avcodec.h:3728
AVPacket * in_pkt
Definition: internal.h:122
AVFormatContext * ctx
Definition: movenc.c:48
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:892
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:2477
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Definition: os2threads.h:98
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
Definition: pixfmt.h:204
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:226
int level
level
Definition: avcodec.h:3364
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
Definition: utils.c:2168
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
Definition: pixfmt.h:196
#define CONFIG_GRAY
Definition: config.h:528
const AVProfile * profiles
array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} ...
Definition: avcodec.h:3766
int n
Definition: avisynth_c.h:684
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:185
unsigned 8 bits, planar
Definition: samplefmt.h:66
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Definition: avcodec.h:1907
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition: pixfmt.h:261
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:173
enum AVCodecID codec_id
Definition: vaapi_decode.c:235
enum AVColorRange color_range
Video only.
Definition: avcodec.h:4238
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
void av_log_ask_for_sample(void *avc, const char *msg,...)
Definition: utils.c:1993
Opaque data information usually sparse.
Definition: avutil.h:205
const char * av_get_colorspace_name(enum AVColorSpace val)
Get the name of a colorspace.
Definition: frame.c:83
#define pthread_mutex_unlock(a)
Definition: ffprobe.c:65
DecodeSimpleContext ds
Definition: internal.h:167
static pthread_mutex_t * mutex
Definition: w32pthreads.h:258
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
Definition: utils.c:580
char * sub_charenc
DTS of the last frame.
Definition: avcodec.h:3507
if(ret< 0)
Definition: vf_mcdeint.c:279
planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:182
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
Definition: avcodec.h:4111
#define FF_ARRAY_ELEMS(a)
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it...
Definition: error.h:72
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:1341
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
Definition: avcodec.h:3192
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:514
int sub_charenc_mode
Subtitles character encoding mode.
Definition: avcodec.h:3515
int av_codec_get_max_lowres(const AVCodec *codec)
Definition: utils.c:602
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
planar GBR 4:4:4:4 48bpp, little-endian
Definition: pixfmt.h:306
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:274
const AVS_VideoInfo int align
Definition: avisynth_c.h:795
AVBufferRef * progress
Definition: thread.h:40
const char * av_get_profile_name(const AVCodec *codec, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:1576
int frame_size
Number of samples per channel in an audio frame.
Definition: avcodec.h:2543
#define attribute_align_arg
Definition: internal.h:61
This structure describes the bitrate properties of an encoded bitstream.
Definition: avcodec.h:1354
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:88
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:144
int frame_size
Definition: mxfenc.c:1896
Libavcodec external API header.
enum AVMediaType codec_type
Definition: avcodec.h:1769
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
Definition: utils.c:1687
enum AVCodecID codec_id
Definition: avcodec.h:1778
int seek_preroll
Number of samples to skip after a discontinuity.
Definition: avcodec.h:3539
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
Definition: opt.c:1589
int sample_rate
samples per second
Definition: avcodec.h:2523
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:232
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:193
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
planar GBR 4:4:4 30bpp, big-endian
Definition: pixfmt.h:188
main external API structure.
Definition: avcodec.h:1761
int(* receive_frame)(AVCodecContext *avctx, AVFrame *frame)
Decode API with decoupled packet/frame dataflow.
Definition: avcodec.h:3840
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: utils.c:1322
int skip_samples_multiplier
Definition: internal.h:219
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:208
uint8_t * data
The data buffer.
Definition: buffer.h:89
int qmin
minimum quantizer
Definition: avcodec.h:2705
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: utils.c:1191
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> (&#39;D&#39;<<24) + (&#39;C&#39;<<16) + (&#39;B&#39;<<8) + &#39;A&#39;).
Definition: avcodec.h:1793
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:67
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1669
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
Definition: encode_audio.c:95
uint8_t * data
Definition: frame.h:165
planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
Definition: pixfmt.h:295
#define AV_CODEC_PROP_BITMAP_SUB
Subtitle codec is bitmap based Decoded AVSubtitle data can be read from the AVSubtitleRect->pict fiel...
Definition: avcodec.h:762
planar GBR 4:4:4 42bpp, little-endian
Definition: pixfmt.h:275
void * buf
Definition: avisynth_c.h:690
int extradata_size
Definition: avcodec.h:1877
int(* close)(AVCodecContext *)
Definition: avcodec.h:3823
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
Definition: utils.c:1960
struct AVCodec * next
Definition: avcodec.h:3776
int nb_coded_side_data
Definition: avcodec.h:3592
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:209
AVCodecContext * owner[2]
Definition: thread.h:37
int coded_height
Definition: avcodec.h:1963
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:67
Describe the class of an AVClass context structure.
Definition: log.h:67
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
Definition: avcodec.h:3583
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition: pixfmt.h:211
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
Definition: frame.c:674
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
Definition: avstring.h:231
Y , 16bpp, big-endian.
Definition: pixfmt.h:102
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
Definition: buffer.c:275
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
Definition: samplefmt.c:119
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:2491
Rational number (pair of numerator and denominator).
Definition: rational.h:58
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:2484
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
Definition: utils.c:2162
const char * name
short name for the profile
Definition: avcodec.h:3729
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Definition: utils.c:2364
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:121
planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:262
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
Definition: log.c:379
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:101
planar GBR 4:4:4 42bpp, big-endian
Definition: pixfmt.h:274
static FF_ENABLE_DEPRECATION_WARNINGS AVHWAccel * first_hwaccel
Definition: utils.c:2010
char * codec_whitelist
&#39;,&#39; separated list of allowed decoders.
Definition: avcodec.h:3574
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
Definition: pixfmt.h:194
const VDPAUPixFmtMap * map
#define STRIDE_ALIGN
Definition: internal.h:99
const char * name
Name of the codec described by this descriptor.
Definition: avcodec.h:711
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: utils.c:653
#define snprintf
Definition: snprintf.h:34
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
Definition: audioconvert.c:56
static AVHWAccel ** last_hwaccel
Definition: utils.c:2011
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
Definition: utils.c:1932
static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
Definition: utils.c:1276
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
Definition: avstring.c:93
mfxU16 profile
Definition: qsvenc.c:44
AVHWAccel * av_hwaccel_next(const AVHWAccel *hwaccel)
If hwaccel is NULL, returns the first registered hardware accelerator, if hwaccel is non-NULL...
Definition: utils.c:2022
int seek_preroll
Audio only.
Definition: avcodec.h:4292
This struct describes the properties of a single codec described by an AVCodecID. ...
Definition: avcodec.h:703
int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
Finalize buf into extradata and set its size appropriately.
Definition: utils.c:2209
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:505
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition: utils.c:79
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
Definition: pixfmt.h:203
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
Definition: utils.c:1327
int bits_per_raw_sample
This is the number of valid bits in each output sample.
Definition: avcodec.h:4207
const AVClass * priv_class
AVClass for the private context.
Definition: avcodec.h:3765
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:215
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:178
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:147
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:106
void ff_color_frame(AVFrame *frame, const int c[4])
Definition: utils.c:525
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
int sample_rate
Audio only.
Definition: avcodec.h:4262
enum AVMediaType type
Definition: avcodec.h:705
uint8_t max_lowres
maximum value for lowres supported by the decoder
Definition: avcodec.h:3764
AVPacket * buffer_pkt
buffers for using new encode/decode API through legacy API
Definition: internal.h:202
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition: anm.c:78
int
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:265
Y , 8bpp.
Definition: pixfmt.h:74
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1544
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:83
int(* decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt)
Definition: avcodec.h:3822
common internal api header.
enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos)
Converts swscale x/y chroma position to AVChromaLocation.
Definition: utils.c:478
Free mutex resources.
Definition: avcodec.h:6335
int avpriv_lock_avformat(void)
Definition: utils.c:2101
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
Definition: internal.h:60
void av_register_hwaccel(AVHWAccel *hwaccel)
Register the hardware accelerator hwaccel.
Definition: utils.c:2013
struct AVHWAccel * next
Definition: avcodec.h:3909
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:233
signed 16 bits
Definition: samplefmt.h:61
planar GBR 4:4:4 27bpp, little-endian
Definition: pixfmt.h:187
int(* init)(AVCodecContext *)
Definition: avcodec.h:3807
static double c[64]
int profile
Codec-specific bitstream restrictions that the stream conforms to.
Definition: avcodec.h:4212
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:2784
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:192
void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_padded_malloc except that buffer will always be 0-initialized after call...
Definition: utils.c:133
int(* encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, const struct AVSubtitle *sub)
Definition: avcodec.h:3808
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
AVProfile.
Definition: avcodec.h:3727
planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
Definition: pixfmt.h:145
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
int ff_thread_can_start_frame(AVCodecContext *avctx)
Definition: utils.c:2180
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
Definition: avcodec.h:3183
void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
Notify later decoding threads when part of their reference picture is ready.
Definition: utils.c:2172
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Definition: pixfmt.h:91
static const uint64_t c2
Definition: murmur3.c:50
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:371
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
int caps_internal
Internal codec capabilities.
Definition: avcodec.h:3850
unsigned properties
Properties of the stream that gets decoded.
Definition: avcodec.h:3581
#define CONFIG_ME_CMP
Definition: config.h:630
int den
Denominator.
Definition: rational.h:60
int avcodec_default_execute2(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
Definition: utils.c:567
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
Definition: imgutils.c:252
unsigned bps
Definition: movenc.c:1415
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition: pixfmt.h:201
#define FFMPEG_CONFIGURATION
Definition: config.h:4
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:777
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
Definition: utils.c:1381
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:896
static int lowres
Definition: ffplay.c:331
void * priv_data
Definition: avcodec.h:1803
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch const uint8_t **in ch off *out planar
Definition: audioconvert.c:56
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
Definition: utils.c:1361
int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
Definition: utils.c:2059
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill plane data pointers and linesize for samples with sample format sample_fmt.
Definition: samplefmt.c:151
#define av_free(p)
uint8_t * dump_separator
dump format separator.
Definition: avcodec.h:3566
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:84
int(* encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode data to an AVPacket.
Definition: avcodec.h:3820
#define TAG_PRINT(x)
#define FFMPEG_VERSION
Definition: ffversion.h:4
planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition: pixfmt.h:271
as in Berlin toast format
Definition: avcodec.h:574
int len
int channels
number of audio channels
Definition: avcodec.h:2524
const int * supported_samplerates
array of supported audio samplerates, or NULL if unknown, array is terminated by 0 ...
Definition: avcodec.h:3761
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:1811
unsigned avcodec_version(void)
Return the LIBAVCODEC_VERSION_INT constant.
Definition: utils.c:1604
Y , 16bpp, little-endian.
Definition: pixfmt.h:103
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:51
char * ass
0 terminated ASS/SSA compatible event line.
Definition: avcodec.h:4123
This side data corresponds to the AVCPBProperties struct.
Definition: avcodec.h:1510
static void * avformat_mutex
Definition: utils.c:119
unsigned av_codec_get_codec_properties(const AVCodecContext *codec)
Definition: utils.c:597
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:276
Not part of ABI.
Definition: pixfmt.h:541
signed 64 bits, planar
Definition: samplefmt.h:72
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: avcodec.h:4194
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: avcodec.h:4166
static const struct twinvq_data tab
unsigned int byte_buffer_size
Definition: internal.h:180
#define HAVE_THREADS
Definition: config.h:385
int channels
Audio only.
Definition: avcodec.h:4258
void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
Wait for earlier decoding threads to finish reference pictures.
Definition: utils.c:2176
planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
Definition: pixfmt.h:202
static int height
Definition: utils.c:158
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
av_cold void avcodec_register(AVCodec *codec)
Register the codec codec and initialize libavcodec.
Definition: utils.c:179
int64_t pts_correction_last_dts
PTS of the last frame.
Definition: avcodec.h:3500
int frame_number
Frame counter, set by libavcodec.
Definition: avcodec.h:2554
int height
Definition: frame.h:259
void ff_frame_thread_encoder_free(AVCodecContext *avctx)
#define av_freep(p)
void INT64 INT64 count
Definition: avisynth_c.h:690
int64_t pts_correction_num_faulty_pts
Current statistics for PTS correction.
Definition: avcodec.h:3497
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:104
enum AVFieldOrder field_order
Field order.
Definition: avcodec.h:2520
signed 16 bits, planar
Definition: samplefmt.h:67
void(* init_static_data)(struct AVCodec *codec)
Initialize codec static data, called from avcodec_register().
Definition: avcodec.h:3805
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:533
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
Definition: utils.c:2127
static int(* lockmgr_cb)(void **mutex, enum AVLockOp op)
Definition: utils.c:112
planar GBR 4:4:4 48bpp, little-endian
Definition: pixfmt.h:191
enum AVSampleFormat * sample_fmts
array of supported sample formats, or NULL if unknown, array is terminated by -1
Definition: avcodec.h:3762
AVMatrixEncoding
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
Definition: utils.c:2156
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: avcodec.h:4156
int ff_alloc_entries(AVCodecContext *avctx, int count)
Definition: utils.c:2185
int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len, void **data, size_t *sei_size)
Check AVFrame for A53 side data and allocate and fill SEI message with A53 info.
Definition: utils.c:2478
int nb_channels
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2335
planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
Definition: pixfmt.h:197
int avpriv_unlock_avformat(void)
Definition: utils.c:2110
const uint8_t * avpriv_find_start_code(const uint8_t *av_restrict p, const uint8_t *end, uint32_t *av_restrict state)
Definition: utils.c:2232
int debug_mv
debug
Definition: avcodec.h:3039
void ff_reset_entries(AVCodecContext *avctx)
Definition: utils.c:2190
int depth
Number of bits in the component.
Definition: pixdesc.h:58
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:248
#define MKTAG(a, b, c, d)
Definition: common.h:342
planar GBRA 4:4:4:4 64bpp, little-endian
Definition: pixfmt.h:235
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition: avcodec.h:3668
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
Definition: pixfmt.h:87
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:219
enum AVCodecID id
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
Definition: internal.h:179
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:1589
static int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
Definition: mem_internal.h:27
int delay
Codec delay.
Definition: avcodec.h:1931
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:267
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:144
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:2981
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
Definition: pixfmt.h:260
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
Definition: frame.h:67
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
Definition: pixfmt.h:179
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:3467
planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:264
#define FFMAX3(a, b, c)
Definition: common.h:95
planar GBR 4:4:4 30bpp, little-endian
Definition: pixfmt.h:189
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
Definition: utils.c:554
#define AV_WL32(p, v)
Definition: intreadwrite.h:431
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:2762
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
uint8_t * subtitle_header
Header containing style information for text subtitles.
Definition: avcodec.h:3396
static uint8_t tmp[11]
Definition: aes_ctr.c:26
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
Definition: pixfmt.h:175