FFmpeg
avcodec.c
Go to the documentation of this file.
1 /*
2  * AVCodecContext functions for libavcodec
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * AVCodecContext functions for libavcodec
24  */
25 
26 #include "config.h"
27 #include "libavutil/avassert.h"
28 #include "libavutil/avstring.h"
29 #include "libavutil/bprint.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/mem.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/thread.h"
35 #include "avcodec.h"
36 #include "bsf.h"
37 #include "decode.h"
38 #include "encode.h"
39 #include "frame_thread_encoder.h"
40 #include "internal.h"
41 #include "thread.h"
42 
43 #include "libavutil/ffversion.h"
44 const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
45 
46 unsigned avcodec_version(void)
47 {
52 
54 }
55 
56 const char *avcodec_configuration(void)
57 {
58  return FFMPEG_CONFIGURATION;
59 }
60 
61 const char *avcodec_license(void)
62 {
63 #define LICENSE_PREFIX "libavcodec license: "
64  return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
65 }
66 
67 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
68 {
69  int i;
70 
71  for (i = 0; i < count; i++) {
72  int r = func(c, (char *)arg + i * size);
73  if (ret)
74  ret[i] = r;
75  }
76  emms_c();
77  return 0;
78 }
79 
80 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
81 {
82  int i;
83 
84  for (i = 0; i < count; i++) {
85  int r = func(c, arg, i, 0);
86  if (ret)
87  ret[i] = r;
88  }
89  emms_c();
90  return 0;
91 }
92 
94 
95 static void lock_avcodec(const AVCodec *codec)
96 {
97  if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init)
99 }
100 
101 static void unlock_avcodec(const AVCodec *codec)
102 {
103  if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init)
105 }
106 
108 {
109  int64_t bit_rate;
110  int bits_per_sample;
111 
112  switch (ctx->codec_type) {
113  case AVMEDIA_TYPE_VIDEO:
114  case AVMEDIA_TYPE_DATA:
117  bit_rate = ctx->bit_rate;
118  break;
119  case AVMEDIA_TYPE_AUDIO:
120  bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
121  if (bits_per_sample) {
122  bit_rate = ctx->sample_rate * (int64_t)ctx->channels;
123  if (bit_rate > INT64_MAX / bits_per_sample) {
124  bit_rate = 0;
125  } else
126  bit_rate *= bits_per_sample;
127  } else
128  bit_rate = ctx->bit_rate;
129  break;
130  default:
131  bit_rate = 0;
132  break;
133  }
134  return bit_rate;
135 }
136 
137 int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
138 {
139  int ret = 0;
140  AVCodecInternal *avci;
141 
142  if (avcodec_is_open(avctx))
143  return 0;
144 
145  if (!codec && !avctx->codec) {
146  av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
147  return AVERROR(EINVAL);
148  }
149  if (codec && avctx->codec && codec != avctx->codec) {
150  av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
151  "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
152  return AVERROR(EINVAL);
153  }
154  if (!codec)
155  codec = avctx->codec;
156 
157  if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
158  avctx->codec_id == AV_CODEC_ID_NONE) {
159  avctx->codec_type = codec->type;
160  avctx->codec_id = codec->id;
161  }
162  if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type &&
163  avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
164  av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
165  return AVERROR(EINVAL);
166  }
167  avctx->codec = codec;
168 
169  if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
170  return AVERROR(EINVAL);
171 
172  lock_avcodec(codec);
173 
174  avci = av_mallocz(sizeof(*avci));
175  if (!avci) {
176  ret = AVERROR(ENOMEM);
177  goto end;
178  }
179  avctx->internal = avci;
180 
181  avci->buffer_frame = av_frame_alloc();
182  avci->buffer_pkt = av_packet_alloc();
183  avci->es.in_frame = av_frame_alloc();
184  avci->in_pkt = av_packet_alloc();
186  avci->pkt_props = av_fifo_alloc(sizeof(*avci->last_pkt_props));
187  if (!avci->buffer_frame || !avci->buffer_pkt ||
188  !avci->es.in_frame || !avci->in_pkt ||
189  !avci->last_pkt_props || !avci->pkt_props) {
190  ret = AVERROR(ENOMEM);
191  goto free_and_end;
192  }
193 
194  avci->skip_samples_multiplier = 1;
195 
196  if (codec->priv_data_size > 0) {
197  if (!avctx->priv_data) {
198  avctx->priv_data = av_mallocz(codec->priv_data_size);
199  if (!avctx->priv_data) {
200  ret = AVERROR(ENOMEM);
201  goto free_and_end;
202  }
203  if (codec->priv_class) {
204  *(const AVClass **)avctx->priv_data = codec->priv_class;
206  }
207  }
208  if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, options)) < 0)
209  goto free_and_end;
210  } else {
211  avctx->priv_data = NULL;
212  }
213  if ((ret = av_opt_set_dict(avctx, options)) < 0)
214  goto free_and_end;
215 
216  if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
217  av_log(avctx, AV_LOG_ERROR, "Codec (%s) not on whitelist \'%s\'\n", codec->name, avctx->codec_whitelist);
218  ret = AVERROR(EINVAL);
219  goto free_and_end;
220  }
221 
222  // only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not to overwrite previously setup dimensions
223  if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
224  (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) {
225  if (avctx->coded_width && avctx->coded_height)
226  ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
227  else if (avctx->width && avctx->height)
228  ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
229  if (ret < 0)
230  goto free_and_end;
231  }
232 
233  if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
234  && ( av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0
235  || av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)) {
236  av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n");
237  ff_set_dimensions(avctx, 0, 0);
238  }
239 
240  if (avctx->width > 0 && avctx->height > 0) {
241  if (av_image_check_sar(avctx->width, avctx->height,
242  avctx->sample_aspect_ratio) < 0) {
243  av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
244  avctx->sample_aspect_ratio.num,
245  avctx->sample_aspect_ratio.den);
246  avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
247  }
248  }
249 
250  if (avctx->channels > FF_SANE_NB_CHANNELS || avctx->channels < 0) {
251  av_log(avctx, AV_LOG_ERROR, "Too many or invalid channels: %d\n", avctx->channels);
252  ret = AVERROR(EINVAL);
253  goto free_and_end;
254  }
255 
256  if (avctx->sample_rate < 0) {
257  av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate);
258  ret = AVERROR(EINVAL);
259  goto free_and_end;
260  }
261  if (avctx->block_align < 0) {
262  av_log(avctx, AV_LOG_ERROR, "Invalid block align: %d\n", avctx->block_align);
263  ret = AVERROR(EINVAL);
264  goto free_and_end;
265  }
266 
267  avctx->frame_number = 0;
269 
270  if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
272  const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
273  const AVCodec *codec2;
274  av_log(avctx, AV_LOG_ERROR,
275  "The %s '%s' is experimental but experimental codecs are not enabled, "
276  "add '-strict %d' if you want to use it.\n",
278  codec2 = av_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
279  if (!(codec2->capabilities & AV_CODEC_CAP_EXPERIMENTAL))
280  av_log(avctx, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n",
281  codec_string, codec2->name);
283  goto free_and_end;
284  }
285 
286  if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
287  (!avctx->time_base.num || !avctx->time_base.den)) {
288  avctx->time_base.num = 1;
289  avctx->time_base.den = avctx->sample_rate;
290  }
291 
292  if (av_codec_is_encoder(avctx->codec))
293  ret = ff_encode_preinit(avctx);
294  else
295  ret = ff_decode_preinit(avctx);
296  if (ret < 0)
297  goto free_and_end;
298 
299  if (!HAVE_THREADS)
300  av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
301 
302  if (CONFIG_FRAME_THREAD_ENCODER && av_codec_is_encoder(avctx->codec)) {
303  unlock_avcodec(codec); //we will instantiate a few encoders thus kick the counter to prevent false detection of a problem
305  lock_avcodec(codec);
306  if (ret < 0)
307  goto free_and_end;
308  }
309 
310  if (HAVE_THREADS
311  && !(avci->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
312  ret = ff_thread_init(avctx);
313  if (ret < 0) {
314  goto free_and_end;
315  }
316  }
317  if (!HAVE_THREADS && !(codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
318  avctx->thread_count = 1;
319 
320  if (!(avctx->active_thread_type & FF_THREAD_FRAME) ||
321  avci->frame_thread_encoder) {
322  if (avctx->codec->init) {
323  ret = avctx->codec->init(avctx);
324  if (ret < 0) {
326  goto free_and_end;
327  }
328  }
329  avci->needs_close = 1;
330  }
331 
332  ret=0;
333 
334  if (av_codec_is_decoder(avctx->codec)) {
335  if (!avctx->bit_rate)
336  avctx->bit_rate = get_bit_rate(avctx);
337  /* validate channel layout from the decoder */
338  if (avctx->channel_layout) {
340  if (!avctx->channels)
341  avctx->channels = channels;
342  else if (channels != avctx->channels) {
343  char buf[512];
344  av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
345  av_log(avctx, AV_LOG_WARNING,
346  "Channel layout '%s' with %d channels does not match specified number of channels %d: "
347  "ignoring specified channel layout\n",
348  buf, channels, avctx->channels);
349  avctx->channel_layout = 0;
350  }
351  }
352  if (avctx->channels && avctx->channels < 0 ||
353  avctx->channels > FF_SANE_NB_CHANNELS) {
354  ret = AVERROR(EINVAL);
355  goto free_and_end;
356  }
357  if (avctx->bits_per_coded_sample < 0) {
358  ret = AVERROR(EINVAL);
359  goto free_and_end;
360  }
361 
362 #if FF_API_AVCTX_TIMEBASE
363  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
364  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
365 #endif
366  }
367  if (codec->priv_class)
368  av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
369 
370 end:
371  unlock_avcodec(codec);
372 
373  return ret;
374 free_and_end:
375  avcodec_close(avctx);
376  goto end;
377 }
378 
380 {
381  AVCodecInternal *avci = avctx->internal;
382 
383  if (av_codec_is_encoder(avctx->codec)) {
384  int caps = avctx->codec->capabilities;
385 
386  if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
387  // Only encoders that explicitly declare support for it can be
388  // flushed. Otherwise, this is a no-op.
389  av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
390  "that doesn't support it\n");
391  return;
392  }
393  }
394 
395  avci->draining = 0;
396  avci->draining_done = 0;
397  avci->nb_draining_errors = 0;
400 
402  while (av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) {
404  avci->last_pkt_props, sizeof(*avci->last_pkt_props),
405  NULL);
407  }
408  av_fifo_reset(avci->pkt_props);
409 
410  av_frame_unref(avci->es.in_frame);
411  av_packet_unref(avci->in_pkt);
412 
413  if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
414  ff_thread_flush(avctx);
415  else if (avctx->codec->flush)
416  avctx->codec->flush(avctx);
417 
418  avctx->pts_correction_last_pts =
419  avctx->pts_correction_last_dts = INT64_MIN;
420 
421  if (avci->bsf)
422  av_bsf_flush(avci->bsf);
423 }
424 
426 {
427  int i;
428 
429  for (i = 0; i < sub->num_rects; i++) {
430  av_freep(&sub->rects[i]->data[0]);
431  av_freep(&sub->rects[i]->data[1]);
432  av_freep(&sub->rects[i]->data[2]);
433  av_freep(&sub->rects[i]->data[3]);
434  av_freep(&sub->rects[i]->text);
435  av_freep(&sub->rects[i]->ass);
436  av_freep(&sub->rects[i]);
437  }
438 
439  av_freep(&sub->rects);
440 
441  memset(sub, 0, sizeof(*sub));
442 }
443 
445 {
446  int i;
447 
448  if (!avctx)
449  return 0;
450 
451  if (avcodec_is_open(avctx)) {
452  AVCodecInternal *avci = avctx->internal;
453 
454  if (CONFIG_FRAME_THREAD_ENCODER &&
455  avci->frame_thread_encoder && avctx->thread_count > 1) {
457  }
458  if (HAVE_THREADS && avci->thread_ctx)
459  ff_thread_free(avctx);
460  if (avci->needs_close && avctx->codec->close)
461  avctx->codec->close(avctx);
462  avci->byte_buffer_size = 0;
463  av_freep(&avci->byte_buffer);
464  av_frame_free(&avci->buffer_frame);
465  av_packet_free(&avci->buffer_pkt);
466  if (avci->pkt_props) {
467  while (av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) {
470  sizeof(*avci->last_pkt_props), NULL);
471  }
472  av_fifo_freep(&avci->pkt_props);
473  }
475 
476  av_packet_free(&avci->in_pkt);
477  av_frame_free(&avci->es.in_frame);
478 
479  av_buffer_unref(&avci->pool);
480 
481  if (avctx->hwaccel && avctx->hwaccel->uninit)
482  avctx->hwaccel->uninit(avctx);
483  av_freep(&avci->hwaccel_priv_data);
484 
485  av_bsf_free(&avci->bsf);
486 
487  av_freep(&avctx->internal);
488  }
489 
490  for (i = 0; i < avctx->nb_coded_side_data; i++)
491  av_freep(&avctx->coded_side_data[i].data);
492  av_freep(&avctx->coded_side_data);
493  avctx->nb_coded_side_data = 0;
494 
497 
498  if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
499  av_opt_free(avctx->priv_data);
500  av_opt_free(avctx);
501  av_freep(&avctx->priv_data);
502  if (av_codec_is_encoder(avctx->codec)) {
503  av_freep(&avctx->extradata);
504  avctx->extradata_size = 0;
505  } else if (av_codec_is_decoder(avctx->codec))
506  av_freep(&avctx->subtitle_header);
507 
508  avctx->codec = NULL;
509  avctx->active_thread_type = 0;
510 
511  return 0;
512 }
513 
514 static const char *unknown_if_null(const char *str)
515 {
516  return str ? str : "unknown";
517 }
518 
519 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
520 {
521  const char *codec_type;
522  const char *codec_name;
523  const char *profile = NULL;
524  AVBPrint bprint;
525  int64_t bitrate;
526  int new_line = 0;
527  AVRational display_aspect_ratio;
528  const char *separator = enc->dump_separator ? (const char *)enc->dump_separator : ", ";
529  const char *str;
530 
531  if (!buf || buf_size <= 0)
532  return;
533  av_bprint_init_for_buffer(&bprint, buf, buf_size);
535  codec_name = avcodec_get_name(enc->codec_id);
537 
538  av_bprintf(&bprint, "%s: %s", codec_type ? codec_type : "unknown",
539  codec_name);
540  buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */
541 
542  if (enc->codec && strcmp(enc->codec->name, codec_name))
543  av_bprintf(&bprint, " (%s)", enc->codec->name);
544 
545  if (profile)
546  av_bprintf(&bprint, " (%s)", profile);
547  if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
549  && enc->refs)
550  av_bprintf(&bprint, ", %d reference frame%s",
551  enc->refs, enc->refs > 1 ? "s" : "");
552 
553  if (enc->codec_tag)
554  av_bprintf(&bprint, " (%s / 0x%04X)",
555  av_fourcc2str(enc->codec_tag), enc->codec_tag);
556 
557  switch (enc->codec_type) {
558  case AVMEDIA_TYPE_VIDEO:
559  {
560  unsigned len;
561 
562  av_bprintf(&bprint, "%s%s", separator,
563  enc->pix_fmt == AV_PIX_FMT_NONE ? "none" :
565 
566  av_bprint_chars(&bprint, '(', 1);
567  len = bprint.len;
568 
569  /* The following check ensures that '(' has been written
570  * and therefore allows us to erase it if it turns out
571  * to be unnecessary. */
572  if (!av_bprint_is_complete(&bprint))
573  return;
574 
575  if (enc->bits_per_raw_sample && enc->pix_fmt != AV_PIX_FMT_NONE &&
577  av_bprintf(&bprint, "%d bpc, ", enc->bits_per_raw_sample);
578  if (enc->color_range != AVCOL_RANGE_UNSPECIFIED &&
580  av_bprintf(&bprint, "%s, ", str);
581 
582  if (enc->colorspace != AVCOL_SPC_UNSPECIFIED ||
585  const char *col = unknown_if_null(av_color_space_name(enc->colorspace));
587  const char *trc = unknown_if_null(av_color_transfer_name(enc->color_trc));
588  if (strcmp(col, pri) || strcmp(col, trc)) {
589  new_line = 1;
590  av_bprintf(&bprint, "%s/%s/%s, ", col, pri, trc);
591  } else
592  av_bprintf(&bprint, "%s, ", col);
593  }
594 
595  if (enc->field_order != AV_FIELD_UNKNOWN) {
596  const char *field_order = "progressive";
597  if (enc->field_order == AV_FIELD_TT)
598  field_order = "top first";
599  else if (enc->field_order == AV_FIELD_BB)
600  field_order = "bottom first";
601  else if (enc->field_order == AV_FIELD_TB)
602  field_order = "top coded first (swapped)";
603  else if (enc->field_order == AV_FIELD_BT)
604  field_order = "bottom coded first (swapped)";
605 
606  av_bprintf(&bprint, "%s, ", field_order);
607  }
608 
609  if (av_log_get_level() >= AV_LOG_VERBOSE &&
612  av_bprintf(&bprint, "%s, ", str);
613 
614  if (len == bprint.len) {
615  bprint.str[len - 1] = '\0';
616  bprint.len--;
617  } else {
618  if (bprint.len - 2 < bprint.size) {
619  /* Erase the last ", " */
620  bprint.len -= 2;
621  bprint.str[bprint.len] = '\0';
622  }
623  av_bprint_chars(&bprint, ')', 1);
624  }
625  }
626 
627  if (enc->width) {
628  av_bprintf(&bprint, "%s%dx%d", new_line ? separator : ", ",
629  enc->width, enc->height);
630 
631  if (av_log_get_level() >= AV_LOG_VERBOSE &&
632  (enc->width != enc->coded_width ||
633  enc->height != enc->coded_height))
634  av_bprintf(&bprint, " (%dx%d)",
635  enc->coded_width, enc->coded_height);
636 
637  if (enc->sample_aspect_ratio.num) {
638  av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
639  enc->width * (int64_t)enc->sample_aspect_ratio.num,
640  enc->height * (int64_t)enc->sample_aspect_ratio.den,
641  1024 * 1024);
642  av_bprintf(&bprint, " [SAR %d:%d DAR %d:%d]",
644  display_aspect_ratio.num, display_aspect_ratio.den);
645  }
646  if (av_log_get_level() >= AV_LOG_DEBUG) {
647  int g = av_gcd(enc->time_base.num, enc->time_base.den);
648  av_bprintf(&bprint, ", %d/%d",
649  enc->time_base.num / g, enc->time_base.den / g);
650  }
651  }
652  if (encode) {
653  av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax);
654  } else {
656  av_bprintf(&bprint, ", Closed Captions");
658  av_bprintf(&bprint, ", Film Grain");
660  av_bprintf(&bprint, ", lossless");
661  }
662  break;
663  case AVMEDIA_TYPE_AUDIO:
664  av_bprintf(&bprint, "%s", separator);
665 
666  if (enc->sample_rate) {
667  av_bprintf(&bprint, "%d Hz, ", enc->sample_rate);
668  }
669  av_bprint_channel_layout(&bprint, enc->channels, enc->channel_layout);
670  if (enc->sample_fmt != AV_SAMPLE_FMT_NONE &&
672  av_bprintf(&bprint, ", %s", str);
673  }
674  if ( enc->bits_per_raw_sample > 0
676  av_bprintf(&bprint, " (%d bit)", enc->bits_per_raw_sample);
677  if (av_log_get_level() >= AV_LOG_VERBOSE) {
678  if (enc->initial_padding)
679  av_bprintf(&bprint, ", delay %d", enc->initial_padding);
680  if (enc->trailing_padding)
681  av_bprintf(&bprint, ", padding %d", enc->trailing_padding);
682  }
683  break;
684  case AVMEDIA_TYPE_DATA:
685  if (av_log_get_level() >= AV_LOG_DEBUG) {
686  int g = av_gcd(enc->time_base.num, enc->time_base.den);
687  if (g)
688  av_bprintf(&bprint, ", %d/%d",
689  enc->time_base.num / g, enc->time_base.den / g);
690  }
691  break;
693  if (enc->width)
694  av_bprintf(&bprint, ", %dx%d", enc->width, enc->height);
695  break;
696  default:
697  return;
698  }
699  if (encode) {
700  if (enc->flags & AV_CODEC_FLAG_PASS1)
701  av_bprintf(&bprint, ", pass 1");
702  if (enc->flags & AV_CODEC_FLAG_PASS2)
703  av_bprintf(&bprint, ", pass 2");
704  }
705  bitrate = get_bit_rate(enc);
706  if (bitrate != 0) {
707  av_bprintf(&bprint, ", %"PRId64" kb/s", bitrate / 1000);
708  } else if (enc->rc_max_rate > 0) {
709  av_bprintf(&bprint, ", max. %"PRId64" kb/s", enc->rc_max_rate / 1000);
710  }
711 }
712 
714 {
715  return !!s->internal;
716 }
AVSubtitle
Definition: avcodec.h:2289
avcodec_close
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: avcodec.c:444
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:68
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:424
AVCodecContext::hwaccel
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:1359
AVCodec
AVCodec.
Definition: codec.h:202
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
AV_CODEC_ID_VP6F
@ AV_CODEC_ID_VP6F
Definition: codec_id.h:142
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
FF_CODEC_CAP_INIT_THREADSAFE
#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:42
AVERROR_EXPERIMENTAL
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
Definition: error.h:74
r
const char * r
Definition: vf_curves.c:116
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecContext::channel_layout
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:1043
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:960
av_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1364
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: avcodec.h:1285
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:992
AVCodec::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: codec.h:228
sub
static float sub(float src0, float src1)
Definition: dnn_backend_native_layer_mathbinary.c:31
thread.h
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
ff_thread_flush
void ff_thread_flush(AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
Definition: pthread_frame.c:902
AVCodecInternal::es
EncodeSimpleContext es
Definition: internal.h:169
avcodec_string
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
Definition: avcodec.c:519
AVCodecContext::coded_side_data
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
Definition: avcodec.h:1833
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
avcodec_find_encoder
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:916
av_get_channel_layout_string
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.
Definition: channel_layout.c:217
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:953
AVCodec::capabilities
int capabilities
Codec capabilities.
Definition: codec.h:221
internal.h
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AVCodecContext::field_order
enum AVFieldOrder field_order
Field order.
Definition: avcodec.h:989
AVCodecInternal::frame_thread_encoder
void * frame_thread_encoder
Definition: internal.h:167
encode.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:497
unknown_if_null
static const char * unknown_if_null(const char *str)
Definition: avcodec.c:514
AVCodecContext::subtitle_header
uint8_t * subtitle_header
Header containing style information for text subtitles.
Definition: avcodec.h:1683
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AV_CODEC_ID_ADPCM_G722
@ AV_CODEC_ID_ADPCM_G722
Definition: codec_id.h:381
AVDictionary
Definition: dict.c:30
avcodec_profile_name
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:476
ff_thread_init
int ff_thread_init(AVCodecContext *avctx)
Definition: pthread.c:74
av_fifo_generic_read
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
Definition: fifo.c:213
avcodec_is_open
int avcodec_is_open(AVCodecContext *s)
Definition: avcodec.c:713
AVCodec::flush
void(* flush)(struct AVCodecContext *)
Flush buffers.
Definition: codec.h:336
AVCodecContext::qmax
int qmax
maximum quantizer
Definition: avcodec.h:1165
codec_type
enum AVMediaType codec_type
Definition: rtp.c:37
av_fifo_reset
void av_fifo_reset(AVFifoBuffer *f)
Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
Definition: fifo.c:71
thread.h
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:75
av_chroma_location_name
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition: pixdesc.c:3069
AVCodecInternal::pool
AVBufferRef * pool
Definition: internal.h:132
av_gcd
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:36
AV_CODEC_ID_SRT
@ AV_CODEC_ID_SRT
Definition: codec_id.h:530
ff_mutex_unlock
static int ff_mutex_unlock(AVMutex *mutex)
Definition: thread.h:169
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1710
EncodeSimpleContext::in_frame
AVFrame * in_frame
Definition: internal.h:116
AV_FIELD_TT
@ AV_FIELD_TT
Definition: codec_par.h:39
bsf.h
av_color_space_name
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:3048
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:392
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1440
get_bit_rate
static int64_t get_bit_rate(AVCodecContext *ctx)
Definition: avcodec.c:107
AVCodecContext::initial_padding
int initial_padding
Audio only.
Definition: avcodec.h:1701
AVCodecContext::refs
int refs
number of reference frames
Definition: avcodec.h:932
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:463
unlock_avcodec
static void unlock_avcodec(const AVCodec *codec)
Definition: avcodec.c:101
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:571
AV_CODEC_CAP_ENCODER_FLUSH
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition: codec.h:183
AV_FIELD_TB
@ AV_FIELD_TB
Definition: codec_par.h:41
av_reduce
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
AVRational::num
int num
Numerator.
Definition: rational.h:59
av_image_check_size2
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:289
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:425
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:97
AVFormatContext::bit_rate
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1309
av_get_bits_per_sample
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:580
avassert.h
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:946
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
frame_thread_encoder.h
AV_CODEC_CAP_EXPERIMENTAL
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: codec.h:105
av_cold
#define av_cold
Definition: attributes.h:90
FF_CODEC_PROPERTY_LOSSLESS
#define FF_CODEC_PROPERTY_LOSSLESS
Definition: avcodec.h:1823
LIBAVCODEC_VERSION_MICRO
#define LIBAVCODEC_VERSION_MICRO
Definition: version.h:32
AVMutex
#define AVMutex
Definition: thread.h:164
av_opt_set_dict
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
Definition: opt.c:1661
ff_frame_thread_encoder_init
av_cold int ff_frame_thread_encoder_init(AVCodecContext *avctx)
Initialize frame thread encoder.
Definition: frame_thread_encoder.c:133
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:485
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVCodecInternal::buffer_pkt
AVPacket * buffer_pkt
buffers for using new encode/decode API through legacy API
Definition: internal.h:195
AVHWAccel::uninit
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
Definition: avcodec.h:2177
g
const char * g
Definition: vf_curves.c:117
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_bprint_channel_layout
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout)
Append a description of a channel layout to a bprint buffer.
Definition: channel_layout.c:183
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AV_FIELD_UNKNOWN
@ AV_FIELD_UNKNOWN
Definition: codec_par.h:37
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1425
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AVPacketSideData::data
uint8_t * data
Definition: packet.h:315
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:33
decode.h
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:1886
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:1194
av_get_sample_fmt_name
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
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:472
AV_FIELD_BT
@ AV_FIELD_BT
Definition: codec_par.h:42
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:77
ff_thread_free
void ff_thread_free(AVCodecContext *avctx)
Definition: pthread.c:86
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:393
FF_CODEC_PROPERTY_FILM_GRAIN
#define FF_CODEC_PROPERTY_FILM_GRAIN
Definition: avcodec.h:1825
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
av_color_range_name
const char * av_color_range_name(enum AVColorRange range)
Definition: pixdesc.c:2988
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:435
LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_VERSION_INT
Definition: version.h:34
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
av_match_list
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
Definition: avstring.c:452
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:967
av_buffer_unref
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:139
AVCodec::type
enum AVMediaType type
Definition: codec.h:215
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCodecContext::nb_coded_side_data
int nb_coded_side_data
Definition: avcodec.h:1834
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:418
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:433
AVCodecContext::trailing_padding
int trailing_padding
Audio only.
Definition: avcodec.h:1878
av_color_primaries_name
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:3006
avcodec_license
const char * avcodec_license(void)
Return the libavcodec license.
Definition: avcodec.c:61
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1617
avcodec_open2
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: avcodec.c:137
avcodec_version
unsigned avcodec_version(void)
Return the LIBAVCODEC_VERSION_INT constant.
Definition: avcodec.c:46
AVCodecInternal::skip_samples_multiplier
int skip_samples_multiplier
Definition: internal.h:201
AVCodecInternal::draining_done
int draining_done
Definition: internal.h:197
AVCodecInternal::bsf
AVBSFContext * bsf
Definition: internal.h:145
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:563
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
av_get_channel_layout_nb_channels
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
Definition: channel_layout.c:226
AVCodecInternal::last_pkt_props
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
Definition: internal.h:151
av_bprint_is_complete
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:185
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:921
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avcodec.h:506
av_codec_is_decoder
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:81
FF_CODEC_CAP_AUTO_THREADS
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: internal.h:81
options
const OptionDef options[]
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:185
AVCodec::close
int(* close)(struct AVCodecContext *)
Definition: codec.h:318
AV_CODEC_ID_DXV
@ AV_CODEC_ID_DXV
Definition: codec_id.h:241
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1000
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
AV_MUTEX_INITIALIZER
#define AV_MUTEX_INITIALIZER
Definition: thread.h:165
size
int size
Definition: twinvq_data.h:10344
AVCodecInternal::byte_buffer
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
Definition: internal.h:157
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:617
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
codec_mutex
static AVMutex codec_mutex
Definition: avcodec.c:93
AV_CODEC_FLAG_PASS2
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:235
encode
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
Definition: encode_audio.c:95
lock_avcodec
static void lock_avcodec(const AVCodec *codec)
Definition: avcodec.c:95
AVCodecContext::pts_correction_last_pts
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
Definition: avcodec.h:1740
avcodec_default_execute
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
Definition: avcodec.c:67
ff_mutex_lock
static int ff_mutex_lock(AVMutex *mutex)
Definition: thread.h:168
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:64
AVCodecInternal
Definition: internal.h:119
AVCodecInternal::byte_buffer_size
unsigned int byte_buffer_size
Definition: internal.h:158
bitrate
int64_t bitrate
Definition: h264_levels.c:131
ff_encode_preinit
int ff_encode_preinit(AVCodecContext *avctx)
Definition: encode.c:409
FF_THREAD_FRAME
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition: avcodec.h:1451
AVCodecContext::channels
int channels
number of audio channels
Definition: avcodec.h:993
av_bprint_init_for_buffer
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
Definition: bprint.c:84
AVCodec::id
enum AVCodecID id
Definition: codec.h:216
av_codec_is_encoder
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:76
avcodec_get_name
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:443
AV_FIELD_BB
@ AV_FIELD_BB
Definition: codec_par.h:40
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1418
bprint.h
avcodec_default_execute2
int avcodec_default_execute2(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
Definition: avcodec.c:80
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:48
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
AVCodecContext::properties
unsigned properties
Properties of the stream that gets decoded.
Definition: avcodec.h:1822
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:106
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:484
FF_CODEC_CAP_INIT_CLEANUP
#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:50
AVCodecInternal::pkt_props
AVFifoBuffer * pkt_props
Definition: internal.h:152
AVCodecInternal::in_pkt
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
Definition: internal.h:144
AVCodecContext::pts_correction_last_dts
int64_t pts_correction_last_dts
PTS of the last frame.
Definition: avcodec.h:1741
ff_decode_preinit
int ff_decode_preinit(AVCodecContext *avctx)
Perform decoder initialization and validation.
Definition: decode.c:1767
AVMEDIA_TYPE_ATTACHMENT
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition: avutil.h:205
AVCodecContext::dump_separator
uint8_t * dump_separator
dump format separator.
Definition: avcodec.h:1807
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:435
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:263
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:209
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVCodecContext::hw_device_ctx
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition: avcodec.h:1908
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:974
len
int len
Definition: vorbis_enc_data.h:426
profile
int profile
Definition: mxfenc.c:2003
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:526
AVCodecContext::height
int height
Definition: avcodec.h:556
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:593
AVCodecInternal::nb_draining_errors
int nb_draining_errors
Definition: internal.h:204
AVCodec::priv_data_size
int priv_data_size
Definition: codec.h:256
AVCodecContext::hw_frames_ctx
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition: avcodec.h:1858
avcodec.h
ret
ret
Definition: filter_design.txt:187
AVCodec::caps_internal
int caps_internal
Internal codec capabilities.
Definition: codec.h:254
AVCodecContext::block_align
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition: avcodec.h:1029
avcodec_flush_buffers
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
Definition: avcodec.c:379
AVCodecContext::strict_std_compliance
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1280
LICENSE_PREFIX
#define LICENSE_PREFIX
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:93
AVCodecInternal::needs_close
int needs_close
If this is set, then AVCodec->close (if existing) needs to be called for the parent AVCodecContext.
Definition: internal.h:175
av_bsf_flush
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
Definition: bsf.c:186
av_get_media_type_string
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:71
AVCodecContext
main external API structure.
Definition: avcodec.h:383
AVCodecContext::active_thread_type
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:1459
AVCodecContext::codec_descriptor
const AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
Definition: avcodec.h:1731
c2
static const uint64_t c2
Definition: murmur3.c:52
channel_layout.h
AVCodecContext::qmin
int qmin
minimum quantizer
Definition: avcodec.h:1158
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1525
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
FF_CODEC_PROPERTY_CLOSED_CAPTIONS
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
Definition: avcodec.h:1824
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
ff_frame_thread_encoder_free
av_cold void ff_frame_thread_encoder_free(AVCodecContext *avctx)
Definition: frame_thread_encoder.c:256
AVCodecInternal::buffer_frame
AVFrame * buffer_frame
Definition: internal.h:196
AVCodecInternal::draining
int draining
checks API usage: after codec draining, flush is required to resume operation
Definition: internal.h:190
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:571
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition: avcodec.h:391
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
av_codec_ffversion
const char av_codec_ffversion[]
Definition: avcodec.c:44
mem.h
ff_set_dimensions
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:86
av_fifo_size
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
Definition: fifo.c:77
AVCodecContext::frame_number
int frame_number
Frame counter, set by libavcodec.
Definition: avcodec.h:1023
av_fifo_freep
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
Definition: fifo.c:63
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:408
FF_MAX_EXTRADATA_SIZE
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
Definition: internal.h:237
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:410
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_bsf_free
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:48
avcodec_configuration
const char * avcodec_configuration(void)
Return the libavcodec build-time configuration.
Definition: avcodec.c:56
AVCodec::init
int(* init)(struct AVCodecContext *)
Definition: codec.h:289
codec_string
Definition: dashenc.c:202
AVCodecInternal::thread_ctx
void * thread_ctx
Definition: internal.h:134
AV_CODEC_ID_PCM_S8_PLANAR
@ AV_CODEC_ID_PCM_S8_PLANAR
Definition: codec_id.h:341
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:556
convert_header.str
string str
Definition: convert_header.py:20
av_fifo_alloc
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
imgutils.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3521
av_image_check_sar
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:323
avstring.h
FF_SANE_NB_CHANNELS
#define FF_SANE_NB_CHANNELS
Definition: internal.h:101
AVCodecContext::codec_whitelist
char * codec_whitelist
',' separated list of allowed decoders.
Definition: avcodec.h:1815
av_color_transfer_name
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:3027
AVCodecContext::sample_aspect_ratio
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:753
av_bprint_chars
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
Definition: bprint.c:139
av_get_pix_fmt_name
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:2580
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:231
av_fourcc2str
#define av_fourcc2str(fourcc)
Definition: avutil.h:348