FFmpeg  4.4.9
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/imgutils.h"
30 #include "libavutil/mem.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/thread.h"
33 #include "avcodec.h"
34 #include "decode.h"
35 #include "encode.h"
36 #include "frame_thread_encoder.h"
37 #include "internal.h"
38 #include "thread.h"
39 #if CONFIG_ICONV
40 # include <iconv.h>
41 #endif
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  size_t i;
70 
71  for (i = 0; i < count; i++) {
72  size_t offset = i * size;
73  int r = func(c, FF_PTR_ADD((char *)arg, offset));
74  if (ret)
75  ret[i] = r;
76  }
77  emms_c();
78  return 0;
79 }
80 
81 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
82 {
83  int i;
84 
85  for (i = 0; i < count; i++) {
86  int r = func(c, arg, i, 0);
87  if (ret)
88  ret[i] = r;
89  }
90  emms_c();
91  return 0;
92 }
93 
95 
96 static void lock_avcodec(const AVCodec *codec)
97 {
98  if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init)
100 }
101 
102 static void unlock_avcodec(const AVCodec *codec)
103 {
104  if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init)
106 }
107 
108 #if FF_API_LOCKMGR
109 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
110 {
111  return 0;
112 }
113 #endif
114 
116 {
117  int64_t bit_rate;
118  int bits_per_sample;
119 
120  switch (ctx->codec_type) {
121  case AVMEDIA_TYPE_VIDEO:
122  case AVMEDIA_TYPE_DATA:
125  bit_rate = ctx->bit_rate;
126  break;
127  case AVMEDIA_TYPE_AUDIO:
128  bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
129  if (bits_per_sample) {
130  bit_rate = ctx->sample_rate * (int64_t)ctx->channels;
131  if (bit_rate > INT64_MAX / bits_per_sample) {
132  bit_rate = 0;
133  } else
134  bit_rate *= bits_per_sample;
135  } else
136  bit_rate = ctx->bit_rate;
137  break;
138  default:
139  bit_rate = 0;
140  break;
141  }
142  return bit_rate;
143 }
144 
146 {
147  int ret = 0;
148  int codec_init_ok = 0;
149  AVDictionary *tmp = NULL;
150  AVCodecInternal *avci;
151 
152  if (avcodec_is_open(avctx))
153  return 0;
154 
155  if (!codec && !avctx->codec) {
156  av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
157  return AVERROR(EINVAL);
158  }
159  if (codec && avctx->codec && codec != avctx->codec) {
160  av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
161  "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
162  return AVERROR(EINVAL);
163  }
164  if (!codec)
165  codec = avctx->codec;
166 
167  if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
168  return AVERROR(EINVAL);
169 
170  if (options)
171  av_dict_copy(&tmp, *options, 0);
172 
173  lock_avcodec(codec);
174 
175  avci = av_mallocz(sizeof(*avci));
176  if (!avci) {
177  ret = AVERROR(ENOMEM);
178  goto end;
179  }
180  avctx->internal = avci;
181 
182 #if FF_API_OLD_ENCDEC
183  avci->to_free = av_frame_alloc();
186  if (!avci->to_free || !avci->compat_decode_frame || !avci->compat_encode_packet) {
187  ret = AVERROR(ENOMEM);
188  goto free_and_end;
189  }
190 #endif
191  avci->buffer_frame = av_frame_alloc();
192  avci->buffer_pkt = av_packet_alloc();
193  avci->es.in_frame = av_frame_alloc();
194  avci->ds.in_pkt = av_packet_alloc();
196  avci->pkt_props = av_fifo_alloc(sizeof(*avci->last_pkt_props));
197  if (!avci->buffer_frame || !avci->buffer_pkt ||
198  !avci->es.in_frame || !avci->ds.in_pkt ||
199  !avci->last_pkt_props || !avci->pkt_props) {
200  ret = AVERROR(ENOMEM);
201  goto free_and_end;
202  }
203 
204  avci->skip_samples_multiplier = 1;
205 
206  if (codec->priv_data_size > 0) {
207  if (!avctx->priv_data) {
208  avctx->priv_data = av_mallocz(codec->priv_data_size);
209  if (!avctx->priv_data) {
210  ret = AVERROR(ENOMEM);
211  goto free_and_end;
212  }
213  if (codec->priv_class) {
214  *(const AVClass **)avctx->priv_data = codec->priv_class;
216  }
217  }
218  if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
219  goto free_and_end;
220  } else {
221  avctx->priv_data = NULL;
222  }
223  if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
224  goto free_and_end;
225 
226  if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
227  av_log(avctx, AV_LOG_ERROR, "Codec (%s) not on whitelist \'%s\'\n", codec->name, avctx->codec_whitelist);
228  ret = AVERROR(EINVAL);
229  goto free_and_end;
230  }
231 
232  // only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not to overwrite previously setup dimensions
233  if (!(avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
234  (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) {
235  if (avctx->coded_width && avctx->coded_height)
236  ret = ff_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
237  else if (avctx->width && avctx->height)
238  ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
239  if (ret < 0)
240  goto free_and_end;
241  }
242 
243  if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
244  && ( av_image_check_size2(avctx->coded_width, avctx->coded_height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0
245  || av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)) {
246  av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n");
247  ff_set_dimensions(avctx, 0, 0);
248  }
249 
250  if (avctx->width > 0 && avctx->height > 0) {
251  if (av_image_check_sar(avctx->width, avctx->height,
252  avctx->sample_aspect_ratio) < 0) {
253  av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
254  avctx->sample_aspect_ratio.num,
255  avctx->sample_aspect_ratio.den);
256  avctx->sample_aspect_ratio = (AVRational){ 0, 1 };
257  }
258  }
259 
260  if (avctx->channels > FF_SANE_NB_CHANNELS || avctx->channels < 0) {
261  av_log(avctx, AV_LOG_ERROR, "Too many or invalid channels: %d\n", avctx->channels);
262  ret = AVERROR(EINVAL);
263  goto free_and_end;
264  }
265  /* AV_CODEC_CAP_CHANNEL_CONF is a decoder-only flag; so the code below
266  * in particular checks that nb_channels is set for all audio encoders. */
267  if (codec->type == AVMEDIA_TYPE_AUDIO &&
269  avctx->channels == 0 &&
270  !(av_codec_is_encoder(codec) && avctx->channel_layout)) {
271  av_log(avctx, AV_LOG_ERROR, "%s requires channel layout to be set\n",
272  av_codec_is_decoder(codec) ? "Decoder" : "Encoder");
273  ret = AVERROR(EINVAL);
274  goto free_and_end;
275  }
276 
277  if (avctx->sample_rate < 0) {
278  av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate);
279  ret = AVERROR(EINVAL);
280  goto free_and_end;
281  }
282  if (avctx->block_align < 0) {
283  av_log(avctx, AV_LOG_ERROR, "Invalid block align: %d\n", avctx->block_align);
284  ret = AVERROR(EINVAL);
285  goto free_and_end;
286  }
287 
288  avctx->codec = codec;
289  if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
290  avctx->codec_id == AV_CODEC_ID_NONE) {
291  avctx->codec_type = codec->type;
292  avctx->codec_id = codec->id;
293  }
294  if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
295  && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
296  av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
297  ret = AVERROR(EINVAL);
298  goto free_and_end;
299  }
300  avctx->frame_number = 0;
302 
303  if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
305  const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
306  const AVCodec *codec2;
307  av_log(avctx, AV_LOG_ERROR,
308  "The %s '%s' is experimental but experimental codecs are not enabled, "
309  "add '-strict %d' if you want to use it.\n",
311  codec2 = av_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
312  if (!(codec2->capabilities & AV_CODEC_CAP_EXPERIMENTAL))
313  av_log(avctx, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n",
314  codec_string, codec2->name);
315  ret = AVERROR_EXPERIMENTAL;
316  goto free_and_end;
317  }
318 
319  if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
320  (!avctx->time_base.num || !avctx->time_base.den)) {
321  avctx->time_base.num = 1;
322  avctx->time_base.den = avctx->sample_rate;
323  }
324 
325  if (av_codec_is_encoder(avctx->codec))
326  ret = ff_encode_preinit(avctx);
327  else
328  ret = ff_decode_preinit(avctx);
329  if (ret < 0)
330  goto free_and_end;
331 
332  if (!HAVE_THREADS)
333  av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
334 
336  unlock_avcodec(codec); //we will instantiate a few encoders thus kick the counter to prevent false detection of a problem
338  lock_avcodec(codec);
339  if (ret < 0)
340  goto free_and_end;
341  }
342 
343  if (HAVE_THREADS
344  && !(avci->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
345  ret = ff_thread_init(avctx);
346  if (ret < 0) {
347  goto free_and_end;
348  }
349  }
351  avctx->thread_count = 1;
352 
353  if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME)
354  || avci->frame_thread_encoder)) {
355  ret = avctx->codec->init(avctx);
356  if (ret < 0) {
357  codec_init_ok = -1;
358  goto free_and_end;
359  }
360  codec_init_ok = 1;
361  }
362 
363  ret=0;
364 
365  if (av_codec_is_decoder(avctx->codec)) {
366  if (!avctx->bit_rate)
367  avctx->bit_rate = get_bit_rate(avctx);
368  /* validate channel layout from the decoder */
369  if (avctx->channel_layout) {
371  if (!avctx->channels)
372  avctx->channels = channels;
373  else if (channels != avctx->channels) {
374  char buf[512];
375  av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
376  av_log(avctx, AV_LOG_WARNING,
377  "Channel layout '%s' with %d channels does not match specified number of channels %d: "
378  "ignoring specified channel layout\n",
379  buf, channels, avctx->channels);
380  avctx->channel_layout = 0;
381  }
382  }
383  if (avctx->channels && avctx->channels < 0 ||
384  avctx->channels > FF_SANE_NB_CHANNELS) {
385  ret = AVERROR(EINVAL);
386  goto free_and_end;
387  }
388  if (avctx->bits_per_coded_sample < 0) {
389  ret = AVERROR(EINVAL);
390  goto free_and_end;
391  }
392  if (avctx->sub_charenc) {
393  if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) {
394  av_log(avctx, AV_LOG_ERROR, "Character encoding is only "
395  "supported with subtitles codecs\n");
396  ret = AVERROR(EINVAL);
397  goto free_and_end;
398  } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) {
399  av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, "
400  "subtitles character encoding will be ignored\n",
401  avctx->codec_descriptor->name);
403  } else {
404  /* input character encoding is set for a text based subtitle
405  * codec at this point */
408 
410 #if CONFIG_ICONV
411  iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc);
412  if (cd == (iconv_t)-1) {
413  ret = AVERROR(errno);
414  av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context "
415  "with input character encoding \"%s\"\n", avctx->sub_charenc);
416  goto free_and_end;
417  }
418  iconv_close(cd);
419 #else
420  av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles "
421  "conversion needs a libavcodec built with iconv support "
422  "for this codec\n");
423  ret = AVERROR(ENOSYS);
424  goto free_and_end;
425 #endif
426  }
427  }
428  }
429 
430 #if FF_API_AVCTX_TIMEBASE
431  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
432  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
433 #endif
434  }
435  if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
436  av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
437  }
438 
439 end:
440  unlock_avcodec(codec);
441  if (options) {
443  *options = tmp;
444  }
445 
446  return ret;
447 free_and_end:
448  if (avctx->codec && avctx->codec->close &&
449  (codec_init_ok > 0 || (codec_init_ok < 0 &&
451  avctx->codec->close(avctx);
452 
455  if (HAVE_THREADS && avci->thread_ctx)
456  ff_thread_free(avctx);
457 
458  if (codec->priv_class && avctx->priv_data)
459  av_opt_free(avctx->priv_data);
460  av_opt_free(avctx);
461 
462  if (av_codec_is_encoder(avctx->codec)) {
463 #if FF_API_CODED_FRAME
465  av_frame_free(&avctx->coded_frame);
467 #endif
468  av_freep(&avctx->extradata);
469  avctx->extradata_size = 0;
470  }
471 
472  av_dict_free(&tmp);
473  av_freep(&avctx->priv_data);
474  av_freep(&avctx->subtitle_header);
475 
476 #if FF_API_OLD_ENCDEC
477  av_frame_free(&avci->to_free);
480 #endif
481  av_frame_free(&avci->buffer_frame);
482  av_packet_free(&avci->buffer_pkt);
484  av_fifo_freep(&avci->pkt_props);
485 
486  av_packet_free(&avci->ds.in_pkt);
487  av_frame_free(&avci->es.in_frame);
488  av_bsf_free(&avci->bsf);
489 
490  av_buffer_unref(&avci->pool);
491  av_freep(&avci);
492  avctx->internal = NULL;
493  avctx->codec = NULL;
494  goto end;
495 }
496 
498 {
499  AVCodecInternal *avci = avctx->internal;
500 
501  if (av_codec_is_encoder(avctx->codec)) {
502  int caps = avctx->codec->capabilities;
503 
504  if (!(caps & AV_CODEC_CAP_ENCODER_FLUSH)) {
505  // Only encoders that explicitly declare support for it can be
506  // flushed. Otherwise, this is a no-op.
507  av_log(avctx, AV_LOG_WARNING, "Ignoring attempt to flush encoder "
508  "that doesn't support it\n");
509  return;
510  }
511 
512  // We haven't implemented flushing for frame-threaded encoders.
514  }
515 
516  avci->draining = 0;
517  avci->draining_done = 0;
518  avci->nb_draining_errors = 0;
520 #if FF_API_OLD_ENCDEC
523 #endif
525 
527  while (av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) {
529  avci->last_pkt_props, sizeof(*avci->last_pkt_props),
530  NULL);
532  }
533  av_fifo_reset(avci->pkt_props);
534 
535  av_frame_unref(avci->es.in_frame);
536  av_packet_unref(avci->ds.in_pkt);
537 
539  ff_thread_flush(avctx);
540  else if (avctx->codec->flush)
541  avctx->codec->flush(avctx);
542 
543  avctx->pts_correction_last_pts =
544  avctx->pts_correction_last_dts = INT64_MIN;
545 
546  if (av_codec_is_decoder(avctx->codec))
547  av_bsf_flush(avci->bsf);
548 
549 #if FF_API_OLD_ENCDEC
551  if (!avctx->refcounted_frames)
552  av_frame_unref(avci->to_free);
554 #endif
555 }
556 
558 {
559  int i;
560 
561  for (i = 0; i < sub->num_rects; i++) {
562  av_freep(&sub->rects[i]->data[0]);
563  av_freep(&sub->rects[i]->data[1]);
564  av_freep(&sub->rects[i]->data[2]);
565  av_freep(&sub->rects[i]->data[3]);
566  av_freep(&sub->rects[i]->text);
567  av_freep(&sub->rects[i]->ass);
568  av_freep(&sub->rects[i]);
569  }
570 
571  av_freep(&sub->rects);
572 
573  memset(sub, 0, sizeof(*sub));
574 }
575 
577 {
578  int i;
579 
580  if (!avctx)
581  return 0;
582 
583  if (avcodec_is_open(avctx)) {
585  avctx->internal->frame_thread_encoder && avctx->thread_count > 1) {
587  }
588  if (HAVE_THREADS && avctx->internal->thread_ctx)
589  ff_thread_free(avctx);
590  if (avctx->codec && avctx->codec->close)
591  avctx->codec->close(avctx);
592  avctx->internal->byte_buffer_size = 0;
593  av_freep(&avctx->internal->byte_buffer);
594 #if FF_API_OLD_ENCDEC
595  av_frame_free(&avctx->internal->to_free);
598 #endif
602  while (av_fifo_size(avctx->internal->pkt_props) >=
603  sizeof(*avctx->internal->last_pkt_props)) {
605  avctx->internal->last_pkt_props,
606  sizeof(*avctx->internal->last_pkt_props),
607  NULL);
609  }
611  av_fifo_freep(&avctx->internal->pkt_props);
612 
613  av_packet_free(&avctx->internal->ds.in_pkt);
614  av_frame_free(&avctx->internal->es.in_frame);
615 
616  av_buffer_unref(&avctx->internal->pool);
617 
618  if (avctx->hwaccel && avctx->hwaccel->uninit)
619  avctx->hwaccel->uninit(avctx);
621 
622  av_bsf_free(&avctx->internal->bsf);
623 
624  av_freep(&avctx->internal);
625  }
626 
627  for (i = 0; i < avctx->nb_coded_side_data; i++)
628  av_freep(&avctx->coded_side_data[i].data);
629  av_freep(&avctx->coded_side_data);
630  avctx->nb_coded_side_data = 0;
631 
634 
635  if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
636  av_opt_free(avctx->priv_data);
637  av_opt_free(avctx);
638  av_freep(&avctx->priv_data);
639  if (av_codec_is_encoder(avctx->codec)) {
640  av_freep(&avctx->extradata);
641 #if FF_API_CODED_FRAME
643  av_frame_free(&avctx->coded_frame);
645 #endif
646  }
647  avctx->codec = NULL;
648  avctx->active_thread_type = 0;
649 
650  return 0;
651 }
652 
653 static const char *unknown_if_null(const char *str)
654 {
655  return str ? str : "unknown";
656 }
657 
658 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
659 {
660  const char *codec_type;
661  const char *codec_name;
662  const char *profile = NULL;
664  int new_line = 0;
665  AVRational display_aspect_ratio;
666  const char *separator = enc->dump_separator ? (const char *)enc->dump_separator : ", ";
667  const char *str;
668 
669  if (!buf || buf_size <= 0)
670  return;
672  codec_name = avcodec_get_name(enc->codec_id);
674 
675  snprintf(buf, buf_size, "%s: %s", codec_type ? codec_type : "unknown",
676  codec_name);
677  buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */
678 
679  if (enc->codec && strcmp(enc->codec->name, codec_name))
680  snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", enc->codec->name);
681 
682  if (profile)
683  snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", profile);
684  if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
686  && enc->refs)
687  snprintf(buf + strlen(buf), buf_size - strlen(buf),
688  ", %d reference frame%s",
689  enc->refs, enc->refs > 1 ? "s" : "");
690 
691  if (enc->codec_tag)
692  snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s / 0x%04X)",
693  av_fourcc2str(enc->codec_tag), enc->codec_tag);
694 
695  switch (enc->codec_type) {
696  case AVMEDIA_TYPE_VIDEO:
697  {
698  char detail[256] = "(";
699 
700  av_strlcat(buf, separator, buf_size);
701 
702  snprintf(buf + strlen(buf), buf_size - strlen(buf),
703  "%s", enc->pix_fmt == AV_PIX_FMT_NONE ? "none" :
705  if (enc->bits_per_raw_sample && enc->pix_fmt != AV_PIX_FMT_NONE &&
707  av_strlcatf(detail, sizeof(detail), "%d bpc, ", enc->bits_per_raw_sample);
708  if (enc->color_range != AVCOL_RANGE_UNSPECIFIED &&
710  av_strlcatf(detail, sizeof(detail), "%s, ", str);
711 
712  if (enc->colorspace != AVCOL_SPC_UNSPECIFIED ||
715  const char *col = unknown_if_null(av_color_space_name(enc->colorspace));
717  const char *trc = unknown_if_null(av_color_transfer_name(enc->color_trc));
718  if (strcmp(col, pri) || strcmp(col, trc)) {
719  new_line = 1;
720  av_strlcatf(detail, sizeof(detail), "%s/%s/%s, ",
721  col, pri, trc);
722  } else
723  av_strlcatf(detail, sizeof(detail), "%s, ", col);
724  }
725 
726  if (enc->field_order != AV_FIELD_UNKNOWN) {
727  const char *field_order = "progressive";
728  if (enc->field_order == AV_FIELD_TT)
729  field_order = "top first";
730  else if (enc->field_order == AV_FIELD_BB)
731  field_order = "bottom first";
732  else if (enc->field_order == AV_FIELD_TB)
733  field_order = "top coded first (swapped)";
734  else if (enc->field_order == AV_FIELD_BT)
735  field_order = "bottom coded first (swapped)";
736 
737  av_strlcatf(detail, sizeof(detail), "%s, ", field_order);
738  }
739 
740  if (av_log_get_level() >= AV_LOG_VERBOSE &&
743  av_strlcatf(detail, sizeof(detail), "%s, ", str);
744 
745  if (strlen(detail) > 1) {
746  detail[strlen(detail) - 2] = 0;
747  av_strlcatf(buf, buf_size, "%s)", detail);
748  }
749  }
750 
751  if (enc->width) {
752  av_strlcat(buf, new_line ? separator : ", ", buf_size);
753 
754  snprintf(buf + strlen(buf), buf_size - strlen(buf),
755  "%dx%d",
756  enc->width, enc->height);
757 
758  if (av_log_get_level() >= AV_LOG_VERBOSE &&
759  (enc->width != enc->coded_width ||
760  enc->height != enc->coded_height))
761  snprintf(buf + strlen(buf), buf_size - strlen(buf),
762  " (%dx%d)", enc->coded_width, enc->coded_height);
763 
764  if (enc->sample_aspect_ratio.num) {
765  av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
766  enc->width * (int64_t)enc->sample_aspect_ratio.num,
767  enc->height * (int64_t)enc->sample_aspect_ratio.den,
768  1024 * 1024);
769  snprintf(buf + strlen(buf), buf_size - strlen(buf),
770  " [SAR %d:%d DAR %d:%d]",
772  display_aspect_ratio.num, display_aspect_ratio.den);
773  }
774  if (av_log_get_level() >= AV_LOG_DEBUG) {
775  int g = av_gcd(enc->time_base.num, enc->time_base.den);
776  snprintf(buf + strlen(buf), buf_size - strlen(buf),
777  ", %d/%d",
778  enc->time_base.num / g, enc->time_base.den / g);
779  }
780  }
781  if (encode) {
782  snprintf(buf + strlen(buf), buf_size - strlen(buf),
783  ", q=%d-%d", enc->qmin, enc->qmax);
784  } else {
786  snprintf(buf + strlen(buf), buf_size - strlen(buf),
787  ", Closed Captions");
789  snprintf(buf + strlen(buf), buf_size - strlen(buf),
790  ", lossless");
791  }
792  break;
793  case AVMEDIA_TYPE_AUDIO:
794  av_strlcat(buf, separator, buf_size);
795 
796  if (enc->sample_rate) {
797  snprintf(buf + strlen(buf), buf_size - strlen(buf),
798  "%d Hz, ", enc->sample_rate);
799  }
800  av_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
801  if (enc->sample_fmt != AV_SAMPLE_FMT_NONE &&
803  snprintf(buf + strlen(buf), buf_size - strlen(buf),
804  ", %s", str);
805  }
806  if ( enc->bits_per_raw_sample > 0
808  snprintf(buf + strlen(buf), buf_size - strlen(buf),
809  " (%d bit)", enc->bits_per_raw_sample);
810  if (av_log_get_level() >= AV_LOG_VERBOSE) {
811  if (enc->initial_padding)
812  snprintf(buf + strlen(buf), buf_size - strlen(buf),
813  ", delay %d", enc->initial_padding);
814  if (enc->trailing_padding)
815  snprintf(buf + strlen(buf), buf_size - strlen(buf),
816  ", padding %d", enc->trailing_padding);
817  }
818  break;
819  case AVMEDIA_TYPE_DATA:
820  if (av_log_get_level() >= AV_LOG_DEBUG) {
821  int g = av_gcd(enc->time_base.num, enc->time_base.den);
822  if (g)
823  snprintf(buf + strlen(buf), buf_size - strlen(buf),
824  ", %d/%d",
825  enc->time_base.num / g, enc->time_base.den / g);
826  }
827  break;
829  if (enc->width)
830  snprintf(buf + strlen(buf), buf_size - strlen(buf),
831  ", %dx%d", enc->width, enc->height);
832  break;
833  default:
834  return;
835  }
836  if (encode) {
837  if (enc->flags & AV_CODEC_FLAG_PASS1)
838  snprintf(buf + strlen(buf), buf_size - strlen(buf),
839  ", pass 1");
840  if (enc->flags & AV_CODEC_FLAG_PASS2)
841  snprintf(buf + strlen(buf), buf_size - strlen(buf),
842  ", pass 2");
843  }
844  bitrate = get_bit_rate(enc);
845  if (bitrate != 0) {
846  snprintf(buf + strlen(buf), buf_size - strlen(buf),
847  ", %"PRId64" kb/s", bitrate / 1000);
848  } else if (enc->rc_max_rate > 0) {
849  snprintf(buf + strlen(buf), buf_size - strlen(buf),
850  ", max. %"PRId64" kb/s", enc->rc_max_rate / 1000);
851  }
852 }
853 
855 {
856  return !!s->internal;
857 }
channels
Definition: aptx.h:33
#define av_cold
Definition: attributes.h:88
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
static void lock_avcodec(const AVCodec *codec)
Definition: avcodec.c:96
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:81
static void unlock_avcodec(const AVCodec *codec)
Definition: avcodec.c:102
static const char * unknown_if_null(const char *str)
Definition: avcodec.c:653
static AVMutex codec_mutex
Definition: avcodec.c:94
const char av_codec_ffversion[]
Definition: avcodec.c:44
#define LICENSE_PREFIX
static int64_t get_bit_rate(AVCodecContext *ctx)
Definition: avcodec.c:115
Libavcodec external API header.
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
Definition: avcodec.h:2189
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: avcodec.h:1610
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition: avcodec.h:1788
#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:2122
#define FF_CODEC_PROPERTY_LOSSLESS
Definition: avcodec.h:2188
#define FF_SUB_CHARENC_MODE_AUTOMATIC
libavcodec will select the mode itself
Definition: avcodec.h:2123
#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:2124
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:101
#define s(width, name)
Definition: cbs_vp9.c:257
@ AV_FIELD_TT
Definition: codec_par.h:39
@ AV_FIELD_BB
Definition: codec_par.h:40
@ AV_FIELD_UNKNOWN
Definition: codec_par.h:37
@ AV_FIELD_BT
Definition: codec_par.h:42
@ AV_FIELD_TB
Definition: codec_par.h:41
#define CONFIG_FRAME_THREAD_ENCODER
Definition: config.h:643
#define FFMPEG_CONFIGURATION
Definition: config.h:4
#define HAVE_THREADS
Definition: config.h:277
#define FFMPEG_LICENSE
Definition: config.h:5
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
int ff_decode_preinit(AVCodecContext *avctx)
Perform decoder initialization and validation.
Definition: decode.c:2026
static float sub(float src0, float src1)
int ff_encode_preinit(AVCodecContext *avctx)
Definition: encode.c:546
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
Definition: encode_audio.c:95
const OptionDef options[]
#define FFMPEG_VERSION
Definition: ffversion.h:4
int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options)
Initialize frame thread encoder.
void ff_frame_thread_encoder_free(AVCodecContext *avctx)
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1621
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1368
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
Definition: opt.c:1666
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.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
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:40
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: avcodec.c:145
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:946
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:497
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition: codec.h:178
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition: avcodec.h:300
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:74
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:79
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
Definition: bsf.c:189
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:296
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
Definition: allcodecs.c:941
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:557
const char * avcodec_configuration(void)
Return the libavcodec build-time configuration.
Definition: avcodec.c:56
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3501
#define AV_CODEC_PROP_BITMAP_SUB
Subtitle codec is bitmap based Decoded AVSubtitle data can be read from the AVSubtitleRect->pict fiel...
Definition: codec_desc.h:97
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:104
unsigned avcodec_version(void)
Return the LIBAVCODEC_VERSION_INT constant.
Definition: avcodec.c:46
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:108
const char * avcodec_license(void)
Return the libavcodec license.
Definition: avcodec.c:61
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:576
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: codec.h:100
@ AV_CODEC_ID_VP6F
Definition: codec_id.h:141
@ AV_CODEC_ID_ADPCM_G722
Definition: codec_id.h:381
@ AV_CODEC_ID_SRT
Definition: codec_id.h:531
@ AV_CODEC_ID_H264
Definition: codec_id.h:76
@ AV_CODEC_ID_NONE
Definition: codec_id.h:47
@ AV_CODEC_ID_DXV
Definition: codec_id.h:240
@ AV_CODEC_ID_PCM_S8_PLANAR
Definition: codec_id.h:340
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:656
int av_lockmgr_register(int(*cb)(void **mutex, enum AVLockOp op))
Register a user provided lock manager supporting the operations specified by AVLockOp.
Definition: avcodec.c:109
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
Definition: avcodec.c:658
AVLockOp
Lock operation used by lockmgr.
Definition: avcodec.h:4132
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
Definition: utils.c:552
int avcodec_is_open(AVCodecContext *s)
Definition: avcodec.c:854
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
Definition: avcodec.c:67
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
Definition: avcodec.c:497
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:75
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:634
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:64
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
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:199
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Definition: dict.c:213
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
Definition: error.h:72
#define AVERROR(e)
Definition: error.h:43
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:553
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:190
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:210
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
int av_log_get_level(void)
Get the current log level.
Definition: log.c:435
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
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
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:37
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
#define av_fourcc2str(fourcc)
Definition: avutil.h:348
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
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition: avutil.h:205
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
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:291
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:325
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:106
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
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
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
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
Definition: avstring.c:455
misc image utilities
int i
Definition: input.c:407
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:75
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
Definition: internal.h:244
#define FF_SANE_NB_CHANNELS
Definition: internal.h:107
#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:41
#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:49
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:84
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: internal.h:80
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:68
const char * arg
Definition: jacosubdec.c:67
int ff_thread_init(AVCodecContext *avctx)
Definition: pthread.c:70
void ff_thread_free(AVCodecContext *avctx)
Definition: pthread.c:82
#define LIBAVCODEC_VERSION_MICRO
Definition: version.h:32
#define LIBAVCODEC_VERSION_INT
Definition: version.h:34
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
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
Definition: fifo.c:63
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
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
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:43
common internal API header
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:83
#define FF_PTR_ADD(ptr, off)
Definition: internal.h:105
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:84
#define attribute_align_arg
Definition: internal.h:61
#define emms_c()
Definition: internal.h:54
#define AV_MUTEX_INITIALIZER
Definition: thread.h:165
static int ff_mutex_unlock(AVMutex *mutex)
Definition: thread.h:169
static int ff_mutex_lock(AVMutex *mutex)
Definition: thread.h:168
#define AVMutex
Definition: thread.h:164
static AVMutex mutex
Definition: log.c:44
Memory handling functions.
static const uint64_t c2
Definition: murmur3.c:52
AVOptions.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:2940
const char * av_chroma_location_name(enum AVChromaLocation location)
Definition: pixdesc.c:2982
const char * av_color_range_name(enum AVColorRange range)
Definition: pixdesc.c:2901
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:2961
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:2919
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:2489
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:606
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:552
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:461
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:486
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:515
void ff_thread_flush(AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
mfxU16 profile
Definition: qsvenc.c:45
enum AVMediaType codec_type
Definition: rtp.c:37
#define snprintf
Definition: snprintf.h:34
Describe the class of an AVClass context structure.
Definition: log.h:67
main external API structure.
Definition: avcodec.h:536
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
int64_t pts_correction_last_dts
PTS of the last frame.
Definition: avcodec.h:2106
const AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
Definition: avcodec.h:2096
int width
picture width / height.
Definition: avcodec.h:709
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
Definition: avcodec.h:2197
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
Definition: avcodec.h:2105
attribute_deprecated int refcounted_frames
If non-zero, the decoded audio and video frames returned from avcodec_decode_video2() and avcodec_dec...
Definition: avcodec.h:1372
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1204
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:2252
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1171
char * sub_charenc
DTS of the last frame.
Definition: avcodec.h:2113
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:561
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1605
int nb_coded_side_data
Definition: avcodec.h:2198
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:1150
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition: avcodec.h:2222
int qmin
minimum quantizer
Definition: avcodec.h:1384
enum AVMediaType codec_type
Definition: avcodec.h:544
AVRational framerate
Definition: avcodec.h:2075
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:915
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1744
uint8_t * dump_separator
dump format separator.
Definition: avcodec.h:2172
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
Definition: avcodec.h:1768
enum AVFieldOrder field_order
Field order.
Definition: avcodec.h:1193
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:1684
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:1796
int sub_charenc_mode
Subtitles character encoding mode.
Definition: avcodec.h:2121
char * codec_whitelist
',' separated list of allowed decoders.
Definition: avcodec.h:2180
int64_t bit_rate
the average bitrate
Definition: avcodec.h:586
const struct AVCodec * codec
Definition: avcodec.h:545
int profile
profile
Definition: avcodec.h:1862
unsigned properties
Properties of the stream that gets decoded.
Definition: avcodec.h:2187
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1751
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:1164
int initial_padding
Audio only.
Definition: avcodec.h:2066
int sample_rate
samples per second
Definition: avcodec.h:1196
int frame_number
Frame counter, set by libavcodec.
Definition: avcodec.h:1227
int refs
number of reference frames
Definition: avcodec.h:1124
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:1420
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1777
int qmax
maximum quantizer
Definition: avcodec.h:1391
int coded_height
Definition: avcodec.h:724
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:1157
uint8_t * subtitle_header
Header containing style information for text subtitles.
Definition: avcodec.h:2020
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avcodec.h:659
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:616
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:637
int channels
number of audio channels
Definition: avcodec.h:1197
int trailing_padding
Audio only.
Definition: avcodec.h:2244
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:1178
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition: avcodec.h:2274
enum AVCodecID codec_id
Definition: avcodec.h:546
int extradata_size
Definition: avcodec.h:638
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:724
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
Definition: avcodec.h:1233
uint64_t channel_layout
Audio channel layout.
Definition: avcodec.h:1247
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:571
void * priv_data
Definition: avcodec.h:563
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
Definition: codec_desc.h:54
int nb_draining_errors
Definition: internal.h:211
AVFrame * to_free
Definition: internal.h:145
void * thread_ctx
Definition: internal.h:150
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
Definition: internal.h:159
AVFifoBuffer * pkt_props
Definition: internal.h:160
unsigned int byte_buffer_size
Definition: internal.h:166
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
Definition: internal.h:165
EncodeSimpleContext es
Definition: internal.h:170
AVBSFContext * bsf
Definition: internal.h:153
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:180
AVFrame * buffer_frame
Definition: internal.h:191
AVPacket * buffer_pkt
buffers for using new encode/decode API through legacy API
Definition: internal.h:190
AVBufferRef * pool
Definition: internal.h:148
DecodeSimpleContext ds
Definition: internal.h:152
int skip_samples_multiplier
Definition: internal.h:208
int draining
checks API usage: after codec draining, flush is required to resume operation
Definition: internal.h:185
AVFrame * compat_decode_frame
Definition: internal.h:202
void * frame_thread_encoder
Definition: internal.h:168
AVPacket * compat_encode_packet
Definition: internal.h:203
AVCodec.
Definition: codec.h:197
enum AVCodecID id
Definition: codec.h:211
int caps_internal
Internal codec capabilities.
Definition: codec.h:328
const AVClass * priv_class
AVClass for the private context.
Definition: codec.h:223
int(* init)(struct AVCodecContext *)
Definition: codec.h:276
int priv_data_size
Definition: codec.h:245
void(* flush)(struct AVCodecContext *)
Flush buffers.
Definition: codec.h:323
enum AVMediaType type
Definition: codec.h:210
const char * name
Name of the codec implementation.
Definition: codec.h:204
int(* close)(struct AVCodecContext *)
Definition: codec.h:305
int capabilities
Codec capabilities.
Definition: codec.h:216
int depth
Number of bits in the component.
Definition: pixdesc.h:58
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1354
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
Definition: avcodec.h:2580
uint8_t * data
Definition: packet.h:307
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int num
Numerator.
Definition: rational.h:59
int den
Denominator.
Definition: rational.h:60
AVPacket * in_pkt
Definition: internal.h:122
AVFrame * in_frame
Definition: internal.h:126
#define av_freep(p)
#define av_log(a,...)
static uint8_t tmp[11]
Definition: aes_ctr.c:27
int64_t bitrate
Definition: h264_levels.c:131
AVFormatContext * ctx
Definition: movenc.c:48
int size
const char * g
Definition: vf_curves.c:118
const char * r
Definition: vf_curves.c:117
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:220
if(ret< 0)
Definition: vf_mcdeint.c:282
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
static double c[64]