FFmpeg
encode.c
Go to the documentation of this file.
1 /*
2  * generic encoding-related code
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 #include "libavutil/avassert.h"
23 #include "libavutil/emms.h"
24 #include "libavutil/frame.h"
25 #include "libavutil/internal.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mem.h"
28 #include "libavutil/pixdesc.h"
29 #include "libavutil/samplefmt.h"
30 
31 #include "avcodec.h"
32 #include "avcodec_internal.h"
33 #include "codec_desc.h"
34 #include "codec_internal.h"
35 #include "encode.h"
36 #include "frame_thread_encoder.h"
37 #include "internal.h"
38 
39 typedef struct EncodeContext {
41 
42  /**
43  * This is set to AV_PKT_FLAG_KEY for encoders that encode intra-only
44  * formats (i.e. whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set).
45  * This is used to set said flag generically for said encoders.
46  */
48 
49  /**
50  * An audio frame with less than required samples has been submitted (and
51  * potentially padded with silence). Reject all subsequent frames.
52  */
55 
57 {
58  return (EncodeContext*)avci;
59 }
60 
62 {
63  if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
64  av_log(avctx, AV_LOG_ERROR, "Invalid minimum required packet size %"PRId64" (max allowed is %d)\n",
66  return AVERROR(EINVAL);
67  }
68 
69  av_assert0(!avpkt->data);
70 
72  &avctx->internal->byte_buffer_size, size);
73  avpkt->data = avctx->internal->byte_buffer;
74  if (!avpkt->data) {
75  av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %"PRId64"\n", size);
76  return AVERROR(ENOMEM);
77  }
78  avpkt->size = size;
79 
80  return 0;
81 }
82 
84 {
85  int ret;
86 
87  if (avpkt->size < 0 || avpkt->size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
88  return AVERROR(EINVAL);
89 
90  if (avpkt->data || avpkt->buf) {
91  av_log(avctx, AV_LOG_ERROR, "avpkt->{data,buf} != NULL in avcodec_default_get_encode_buffer()\n");
92  return AVERROR(EINVAL);
93  }
94 
96  if (ret < 0) {
97  av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %d\n", avpkt->size);
98  return ret;
99  }
100  avpkt->data = avpkt->buf->data;
101 
102  return 0;
103 }
104 
106 {
107  int ret;
108 
109  if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
110  return AVERROR(EINVAL);
111 
112  av_assert0(!avpkt->data && !avpkt->buf);
113 
114  avpkt->size = size;
115  ret = avctx->get_encode_buffer(avctx, avpkt, flags);
116  if (ret < 0)
117  goto fail;
118 
119  if (!avpkt->data || !avpkt->buf) {
120  av_log(avctx, AV_LOG_ERROR, "No buffer returned by get_encode_buffer()\n");
121  ret = AVERROR(EINVAL);
122  goto fail;
123  }
124  memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
125 
126  ret = 0;
127 fail:
128  if (ret < 0) {
129  av_log(avctx, AV_LOG_ERROR, "get_encode_buffer() failed\n");
130  av_packet_unref(avpkt);
131  }
132 
133  return ret;
134 }
135 
137 {
138  uint8_t *data = avpkt->data;
139  int ret;
140 
141  if (avpkt->buf)
142  return 0;
143 
144  avpkt->data = NULL;
145  ret = ff_get_encode_buffer(avctx, avpkt, avpkt->size, 0);
146  if (ret < 0)
147  return ret;
148  memcpy(avpkt->data, data, avpkt->size);
149 
150  return 0;
151 }
152 
153 /**
154  * Pad last frame with silence.
155  */
156 static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src, int out_samples)
157 {
158  AVFrameSideData *sd;
159  int discard_padding;
160  int ret;
161 
162  frame->format = src->format;
163  frame->nb_samples = out_samples;
164  ret = av_channel_layout_copy(&frame->ch_layout, &s->ch_layout);
165  if (ret < 0)
166  goto fail;
168  if (ret < 0)
169  goto fail;
170 
172  if (ret < 0)
173  goto fail;
174 
175  if ((ret = av_samples_copy(frame->extended_data, src->extended_data, 0, 0,
176  src->nb_samples, s->ch_layout.nb_channels,
177  s->sample_fmt)) < 0)
178  goto fail;
179  if ((ret = av_samples_set_silence(frame->extended_data, src->nb_samples,
180  frame->nb_samples - src->nb_samples,
181  s->ch_layout.nb_channels, s->sample_fmt)) < 0)
182  goto fail;
183 
184  discard_padding = frame->nb_samples - src->nb_samples;
185  av_assert1(discard_padding > 0);
187  if (!sd) {
188  ret = AVERROR(ENOMEM);
189  goto fail;
190  }
191  AV_WL32A(sd->data, 0);
192  AV_WL32A(sd->data + 4, discard_padding);
193  AV_WL16A(sd->data + 8, 0);
194 
195  return 0;
196 
197 fail:
199  encode_ctx(s->internal)->last_audio_frame = 0;
200  return ret;
201 }
202 
203 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
204  const AVSubtitle *sub)
205 {
206  int ret;
207  if (sub->start_display_time) {
208  av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n");
209  return -1;
210  }
211 
212  ret = ffcodec(avctx->codec)->cb.encode_sub(avctx, buf, buf_size, sub);
213  avctx->frame_num++;
214  return ret;
215 }
216 
218 {
219  AVCodecInternal *avci = avctx->internal;
220 
221  if (avci->draining)
222  return AVERROR_EOF;
223 
224  if (!avci->buffer_frame->buf[0])
225  return AVERROR(EAGAIN);
226 
228 
229  return 0;
230 }
231 
232 static int encode_set_packet_props(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame)
233 {
234  AVCodecInternal *avci = avctx->internal;
235  EncodeContext *ec = encode_ctx(avci);
236 
237  if (avpkt->pts == AV_NOPTS_VALUE) {
238  avpkt->pts = frame->pts;
239  if (avctx->codec->type == AVMEDIA_TYPE_AUDIO && avpkt->pts != AV_NOPTS_VALUE)
240  avpkt->pts -= ff_samples_to_time_base(avctx, avctx->initial_padding);
241  }
242 
243  if (!avpkt->duration) {
244  if (frame->duration)
245  avpkt->duration = frame->duration;
246  else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
247  avpkt->duration = ff_samples_to_time_base(avctx,
248  frame->nb_samples);
249  }
250  if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
252 
253  if (frame_sd && frame_sd->size >= 10) {
254  int skip_samples = AV_RL32(frame_sd->data + 0);
255  int discard_padding = AV_RL32(frame_sd->data + 4);
256 
257  if (discard_padding > 0 && avctx->frame_size && ec->last_audio_frame) {
258  avpkt->duration = av_sat_add64(avpkt->duration, ff_samples_to_time_base(avctx, avctx->initial_padding));
259  avpkt->duration = FFMIN(avpkt->duration, ff_samples_to_time_base(avctx, avctx->frame_size));
260  discard_padding = avctx->frame_size - ff_samples_from_time_base(avctx, avpkt->duration);
261  }
262 
263  if (skip_samples > 0 || discard_padding > 0) {
264  uint8_t *packet_sd = av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
265  if (!packet_sd)
266  return AVERROR(ENOMEM);
267  AV_WL32A(packet_sd + 0, skip_samples);
268  AV_WL32A(packet_sd + 4, discard_padding);
269  AV_WL8 (packet_sd + 8, AV_RB8(frame_sd->data + 8));
270  AV_WL8 (packet_sd + 9, AV_RB8(frame_sd->data + 9));
271  }
272  }
273  }
274  }
275 
276  return 0;
277 }
278 
280  AVPacket *pkt, const AVFrame *frame)
281 {
282  if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
283  int ret = av_buffer_replace(&pkt->opaque_ref, frame->opaque_ref);
284  if (ret < 0)
285  return ret;
286  pkt->opaque = frame->opaque;
287  }
288 
289  return 0;
290 }
291 
293  AVFrame *frame, int *got_packet)
294 {
295  const FFCodec *const codec = ffcodec(avctx->codec);
296  int ret;
297 
298  ret = codec->cb.encode(avctx, avpkt, frame, got_packet);
299  ff_assert1_fpu();
300  av_assert0(ret <= 0);
301 
302  if (!ret && *got_packet) {
303  if (avpkt->data) {
304  ret = encode_make_refcounted(avctx, avpkt);
305  if (ret < 0)
306  goto unref;
307  // Date returned by encoders must always be ref-counted
308  av_assert0(avpkt->buf);
309  }
310 
311  // set the timestamps for the simple no-delay case
312  // encoders with delay have to set the timestamps themselves
313  if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) ||
314  (frame && (codec->caps_internal & FF_CODEC_CAP_EOF_FLUSH))) {
315  ret = encode_set_packet_props(avctx, avpkt, frame);
316  if (ret < 0)
317  goto unref;
318 
319  ret = ff_encode_reordered_opaque(avctx, avpkt, frame);
320  if (ret < 0)
321  goto unref;
322  }
323 
324  // dts equals pts unless there is reordering
325  // there can be no reordering if there is no encoder delay
326  if (!(avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) ||
327  !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) ||
329  avpkt->dts = avpkt->pts;
330  } else {
331 unref:
332  av_packet_unref(avpkt);
333  }
334 
335  if (frame)
337 
338  return ret;
339 }
340 
342 {
343  AVCodecInternal *avci = avctx->internal;
344  AVFrame *frame = avci->in_frame;
345  const FFCodec *const codec = ffcodec(avctx->codec);
346  int got_packet;
347  int ret;
348 
349  if (avci->draining_done)
350  return AVERROR_EOF;
351 
352  if (!frame->buf[0] && !avci->draining) {
354  ret = ff_encode_get_frame(avctx, frame);
355  if (ret < 0 && ret != AVERROR_EOF)
356  return ret;
357  }
358 
359  if (!frame->buf[0]) {
360  if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
361  avci->frame_thread_encoder))
362  return AVERROR_EOF;
363 
364  // Flushing is signaled with a NULL frame
365  frame = NULL;
366  }
367 
368  got_packet = 0;
369 
371 
372 #if CONFIG_FRAME_THREAD_ENCODER
373  if (avci->frame_thread_encoder)
374  /* This will unref frame. */
375  ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
376  else
377 #endif
378  ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet);
379 
380  if (avci->draining && !got_packet)
381  avci->draining_done = 1;
382 
383  return ret;
384 }
385 
387 {
388  int ret;
389 
390  while (!avpkt->data && !avpkt->side_data) {
391  ret = encode_simple_internal(avctx, avpkt);
392  if (ret < 0)
393  return ret;
394  }
395 
396  return 0;
397 }
398 
400 {
401  AVCodecInternal *avci = avctx->internal;
402  int ret;
403 
404  if (avci->draining_done)
405  return AVERROR_EOF;
406 
407  av_assert0(!avpkt->data && !avpkt->side_data);
408 
409  if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
410  if ((avctx->flags & AV_CODEC_FLAG_PASS1) && avctx->stats_out)
411  avctx->stats_out[0] = '\0';
412  }
413 
415  ret = ffcodec(avctx->codec)->cb.receive_packet(avctx, avpkt);
416  if (ret < 0)
417  av_packet_unref(avpkt);
418  else
419  // Encoders must always return ref-counted buffers.
420  // Side-data only packets have no data and can be not ref-counted.
421  av_assert0(!avpkt->data || avpkt->buf);
422  } else
423  ret = encode_simple_receive_packet(avctx, avpkt);
424  if (ret >= 0)
425  avpkt->flags |= encode_ctx(avci)->intra_only_flag;
426 
427  if (ret == AVERROR_EOF)
428  avci->draining_done = 1;
429 
430  return ret;
431 }
432 
433 #if CONFIG_LCMS2
435 {
436  enum AVColorTransferCharacteristic trc = frame->color_trc;
437  enum AVColorPrimaries prim = frame->color_primaries;
438  const FFCodec *const codec = ffcodec(avctx->codec);
439  AVCodecInternal *avci = avctx->internal;
440  cmsHPROFILE profile;
441  int ret;
442 
443  /* don't generate ICC profiles if disabled or unsupported */
444  if (!(avctx->flags2 & AV_CODEC_FLAG2_ICC_PROFILES))
445  return 0;
447  return 0;
448 
449  if (trc == AVCOL_TRC_UNSPECIFIED)
450  trc = avctx->color_trc;
451  if (prim == AVCOL_PRI_UNSPECIFIED)
452  prim = avctx->color_primaries;
453  if (trc == AVCOL_TRC_UNSPECIFIED || prim == AVCOL_PRI_UNSPECIFIED)
454  return 0; /* can't generate ICC profile with missing csp tags */
455 
457  return 0; /* don't overwrite existing ICC profile */
458 
459  if (!avci->icc.avctx) {
460  ret = ff_icc_context_init(&avci->icc, avctx);
461  if (ret < 0)
462  return ret;
463  }
464 
465  ret = ff_icc_profile_generate(&avci->icc, prim, trc, &profile);
466  if (ret < 0)
467  return ret;
468 
469  ret = ff_icc_profile_attach(&avci->icc, profile, frame);
470  cmsCloseProfile(profile);
471  return ret;
472 }
473 #else /* !CONFIG_LCMS2 */
475 {
476  return 0;
477 }
478 #endif
479 
481 {
482  AVCodecInternal *avci = avctx->internal;
483  EncodeContext *ec = encode_ctx(avci);
484  AVFrame *dst = avci->buffer_frame;
485  int ret;
486 
487  if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
488  /* extract audio service type metadata */
490  if (sd && sd->size >= sizeof(enum AVAudioServiceType))
491  avctx->audio_service_type = *(enum AVAudioServiceType*)sd->data;
492 
493  /* check for valid frame size */
494  if (avctx->frame_size) {
495  /* if we already got an undersized frame, that must have been the last */
496  if (ec->last_audio_frame) {
497  av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a non-last frame\n", avctx->frame_size);
498  return AVERROR(EINVAL);
499  }
500  if (src->nb_samples > avctx->frame_size) {
501  av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) > frame_size (%d)\n", src->nb_samples, avctx->frame_size);
502  return AVERROR(EINVAL);
503  }
504  if (src->nb_samples < avctx->frame_size) {
505  ec->last_audio_frame = 1;
508  int pad_samples = avci->pad_samples ? avci->pad_samples : avctx->frame_size;
509  int out_samples = (src->nb_samples + pad_samples - 1) / pad_samples * pad_samples;
510 
511  if (out_samples != src->nb_samples) {
512  ret = pad_last_frame(avctx, dst, src, out_samples);
513  if (ret < 0)
514  return ret;
515  goto finish;
516  }
517  }
518  }
519  }
520  }
521 
522  ret = av_frame_ref(dst, src);
523  if (ret < 0)
524  return ret;
525 
526 finish:
527 
528  if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
530  if (ret < 0)
531  return ret;
532  }
533 
534  // unset frame duration unless AV_CODEC_FLAG_FRAME_DURATION is set,
535  // since otherwise we cannot be sure that whatever value it has is in the
536  // right timebase, so we would produce an incorrect value, which is worse
537  // than none at all
538  if (!(avctx->flags & AV_CODEC_FLAG_FRAME_DURATION))
539  dst->duration = 0;
540 
541  return 0;
542 }
543 
545 {
546  AVCodecInternal *avci = avctx->internal;
547  int ret;
548 
549  if (!avcodec_is_open(avctx) || !av_codec_is_encoder(avctx->codec))
550  return AVERROR(EINVAL);
551 
552  if (avci->draining)
553  return AVERROR_EOF;
554 
555  if (avci->buffer_frame->buf[0])
556  return AVERROR(EAGAIN);
557 
558  if (!frame) {
559  avci->draining = 1;
560  } else {
562  if (ret < 0)
563  return ret;
564  }
565 
566  if (!avci->buffer_pkt->data && !avci->buffer_pkt->side_data) {
568  if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
569  return ret;
570  }
571 
572  avctx->frame_num++;
573 
574  return 0;
575 }
576 
578 {
579  AVCodecInternal *avci = avctx->internal;
580  int ret;
581 
582  av_packet_unref(avpkt);
583 
584  if (!avcodec_is_open(avctx) || !av_codec_is_encoder(avctx->codec))
585  return AVERROR(EINVAL);
586 
587  if (avci->buffer_pkt->data || avci->buffer_pkt->side_data) {
588  av_packet_move_ref(avpkt, avci->buffer_pkt);
589  } else {
590  ret = encode_receive_packet_internal(avctx, avpkt);
591  if (ret < 0)
592  return ret;
593  }
594 
595  return 0;
596 }
597 
599 {
600  const AVCodec *c = avctx->codec;
601  const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
602  const enum AVPixelFormat *pix_fmts;
603  int ret, i, num_pix_fmts;
604 
605  if (!pixdesc) {
606  av_log(avctx, AV_LOG_ERROR, "Invalid video pixel format: %d\n",
607  avctx->pix_fmt);
608  return AVERROR(EINVAL);
609  }
610 
612  0, (const void **) &pix_fmts, &num_pix_fmts);
613  if (ret < 0)
614  return ret;
615 
616  if (pix_fmts) {
617  for (i = 0; i < num_pix_fmts; i++)
618  if (avctx->pix_fmt == pix_fmts[i])
619  break;
620  if (i == num_pix_fmts) {
621  av_log(avctx, AV_LOG_ERROR,
622  "Specified pixel format %s is not supported by the %s encoder.\n",
623  av_get_pix_fmt_name(avctx->pix_fmt), c->name);
624 
625  av_log(avctx, AV_LOG_ERROR, "Supported pixel formats:\n");
626  for (int p = 0; pix_fmts[p] != AV_PIX_FMT_NONE; p++) {
627  av_log(avctx, AV_LOG_ERROR, " %s\n",
629  }
630 
631  return AVERROR(EINVAL);
632  }
633  if (pix_fmts[i] == AV_PIX_FMT_YUVJ420P ||
638  avctx->color_range = AVCOL_RANGE_JPEG;
639  }
640 
641  if (pixdesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
642  const enum AVAlphaMode *alpha_modes;
643  int num_alpha_modes;
645  0, (const void **) &alpha_modes, &num_alpha_modes);
646  if (ret < 0)
647  return ret;
648 
649  if (avctx->alpha_mode != AVALPHA_MODE_UNSPECIFIED && alpha_modes) {
650  for (i = 0; i < num_alpha_modes; i++) {
651  if (avctx->alpha_mode == alpha_modes[i])
652  break;
653  }
654  if (i == num_alpha_modes) {
655  av_log(avctx, AV_LOG_ERROR,
656  "Specified alpha mode '%s' is not supported by the %s encoder.\n",
657  av_alpha_mode_name(avctx->alpha_mode), c->name);
658  av_log(avctx, AV_LOG_ERROR, "Supported alpha modes:\n");
659  for (int p = 0; alpha_modes[p] != AVALPHA_MODE_UNSPECIFIED; p++) {
660  av_log(avctx, AV_LOG_ERROR, " %s\n",
661  av_alpha_mode_name(alpha_modes[p]));
662  }
663  return AVERROR(EINVAL);
664  }
665  }
666  }
667 
668  if ( avctx->bits_per_raw_sample < 0
669  || (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 8)) {
670  av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible with the specified pixel formats depth %d\n",
671  avctx->bits_per_raw_sample, pixdesc->comp[0].depth);
672  avctx->bits_per_raw_sample = pixdesc->comp[0].depth;
673  }
674  if (avctx->width <= 0 || avctx->height <= 0) {
675  av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
676  return AVERROR(EINVAL);
677  }
678 
679  if (avctx->hw_frames_ctx) {
680  AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
681  if (frames_ctx->format != avctx->pix_fmt) {
682  av_log(avctx, AV_LOG_ERROR,
683  "Mismatching AVCodecContext.pix_fmt and AVHWFramesContext.format\n");
684  return AVERROR(EINVAL);
685  }
686  if (avctx->sw_pix_fmt != AV_PIX_FMT_NONE &&
687  avctx->sw_pix_fmt != frames_ctx->sw_format) {
688  av_log(avctx, AV_LOG_ERROR,
689  "Mismatching AVCodecContext.sw_pix_fmt (%s) "
690  "and AVHWFramesContext.sw_format (%s)\n",
692  av_get_pix_fmt_name(frames_ctx->sw_format));
693  return AVERROR(EINVAL);
694  }
695  avctx->sw_pix_fmt = frames_ctx->sw_format;
696  }
697 
698  return 0;
699 }
700 
702 {
703  const AVCodec *c = avctx->codec;
704  const enum AVSampleFormat *sample_fmts;
705  const int *supported_samplerates;
706  const AVChannelLayout *ch_layouts;
707  int ret, i, num_sample_fmts, num_samplerates, num_ch_layouts;
708 
709  if (!av_get_sample_fmt_name(avctx->sample_fmt)) {
710  av_log(avctx, AV_LOG_ERROR, "Invalid audio sample format: %d\n",
711  avctx->sample_fmt);
712  return AVERROR(EINVAL);
713  }
714 
716  0, (const void **) &sample_fmts,
717  &num_sample_fmts);
718  if (ret < 0)
719  return ret;
720  if (sample_fmts) {
721  for (i = 0; i < num_sample_fmts; i++) {
722  if (avctx->sample_fmt == sample_fmts[i])
723  break;
724  if (avctx->ch_layout.nb_channels == 1 &&
727  avctx->sample_fmt = sample_fmts[i];
728  break;
729  }
730  }
731  if (i == num_sample_fmts) {
732  av_log(avctx, AV_LOG_ERROR,
733  "Specified sample format %s is not supported by the %s encoder\n",
734  av_get_sample_fmt_name(avctx->sample_fmt), c->name);
735 
736  av_log(avctx, AV_LOG_ERROR, "Supported sample formats:\n");
737  for (int p = 0; sample_fmts[p] != AV_SAMPLE_FMT_NONE; p++) {
738  av_log(avctx, AV_LOG_ERROR, " %s\n",
740  }
741 
742  return AVERROR(EINVAL);
743  }
744  }
745 
747  0, (const void **) &supported_samplerates,
748  &num_samplerates);
749  if (ret < 0)
750  return ret;
751  if (supported_samplerates) {
752  for (i = 0; i < num_samplerates; i++)
753  if (avctx->sample_rate == supported_samplerates[i])
754  break;
755  if (i == num_samplerates) {
756  av_log(avctx, AV_LOG_ERROR,
757  "Specified sample rate %d is not supported by the %s encoder\n",
758  avctx->sample_rate, c->name);
759 
760  av_log(avctx, AV_LOG_ERROR, "Supported sample rates:\n");
761  for (int p = 0; supported_samplerates[p]; p++)
762  av_log(avctx, AV_LOG_ERROR, " %d\n", supported_samplerates[p]);
763 
764  return AVERROR(EINVAL);
765  }
766  }
768  0, (const void **) &ch_layouts, &num_ch_layouts);
769  if (ret < 0)
770  return ret;
771  if (ch_layouts) {
772  for (i = 0; i < num_ch_layouts; i++) {
773  if (!av_channel_layout_compare(&avctx->ch_layout, &ch_layouts[i]))
774  break;
775  }
776  if (i == num_ch_layouts) {
777  char buf[512];
778  int ret = av_channel_layout_describe(&avctx->ch_layout, buf, sizeof(buf));
779  av_log(avctx, AV_LOG_ERROR,
780  "Specified channel layout '%s' is not supported by the %s encoder\n",
781  ret > 0 ? buf : "?", c->name);
782 
783  av_log(avctx, AV_LOG_ERROR, "Supported channel layouts:\n");
784  for (int p = 0; ch_layouts[p].nb_channels; p++) {
785  ret = av_channel_layout_describe(&ch_layouts[p], buf, sizeof(buf));
786  av_log(avctx, AV_LOG_ERROR, " %s\n", ret > 0 ? buf : "?");
787  }
788  return AVERROR(EINVAL);
789  }
790  }
791 
792  if (!avctx->bits_per_raw_sample)
794  if (!avctx->bits_per_raw_sample)
796 
797  return 0;
798 }
799 
801 {
802  AVCodecInternal *avci = avctx->internal;
803  EncodeContext *ec = encode_ctx(avci);
804  int ret = 0;
805 
806  if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) {
807  av_log(avctx, AV_LOG_ERROR, "The encoder timebase is not set.\n");
808  return AVERROR(EINVAL);
809  }
810 
811  if (avctx->bit_rate < 0) {
812  av_log(avctx, AV_LOG_ERROR, "The encoder bitrate is negative.\n");
813  return AVERROR(EINVAL);
814  }
815 
816  if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE &&
818  av_log(avctx, AV_LOG_ERROR, "The copy_opaque flag is set, but the "
819  "encoder does not support it.\n");
820  return AVERROR(EINVAL);
821  }
822 
823  switch (avctx->codec_type) {
824  case AVMEDIA_TYPE_VIDEO: ret = encode_preinit_video(avctx); break;
825  case AVMEDIA_TYPE_AUDIO: ret = encode_preinit_audio(avctx); break;
826  }
827  if (ret < 0)
828  return ret;
829 
830  if ( (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
831  && avctx->bit_rate>0 && avctx->bit_rate<1000) {
832  av_log(avctx, AV_LOG_WARNING, "Bitrate %"PRId64" is extremely low, maybe you mean %"PRId64"k\n", avctx->bit_rate, avctx->bit_rate);
833  }
834 
835  if (!avctx->rc_initial_buffer_occupancy)
836  avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3LL / 4;
837 
840 
841  if (ffcodec(avctx->codec)->cb_type == FF_CODEC_CB_TYPE_ENCODE) {
842  avci->in_frame = av_frame_alloc();
843  if (!avci->in_frame)
844  return AVERROR(ENOMEM);
845  }
846 
847  if ((avctx->flags & AV_CODEC_FLAG_RECON_FRAME)) {
849  av_log(avctx, AV_LOG_ERROR, "Reconstructed frame output requested "
850  "from an encoder not supporting it\n");
851  return AVERROR(ENOSYS);
852  }
853 
854  avci->recon_frame = av_frame_alloc();
855  if (!avci->recon_frame)
856  return AVERROR(ENOMEM);
857  }
858 
859  for (int i = 0; ff_sd_global_map[i].packet < AV_PKT_DATA_NB; i++) {
860  const enum AVPacketSideDataType type_packet = ff_sd_global_map[i].packet;
861  const enum AVFrameSideDataType type_frame = ff_sd_global_map[i].frame;
862  const AVFrameSideData *sd_frame;
863  AVPacketSideData *sd_packet;
864 
865  sd_frame = av_frame_side_data_get(avctx->decoded_side_data,
866  avctx->nb_decoded_side_data,
867  type_frame);
868  if (!sd_frame ||
870  type_packet))
871 
872  continue;
873 
874  sd_packet = av_packet_side_data_new(&avctx->coded_side_data, &avctx->nb_coded_side_data,
875  type_packet, sd_frame->size, 0);
876  if (!sd_packet)
877  return AVERROR(ENOMEM);
878 
879  memcpy(sd_packet->data, sd_frame->data, sd_frame->size);
880  }
881 
882 #if CONFIG_FRAME_THREAD_ENCODER
884  if (ret < 0)
885  return ret;
886 #endif
887 
888  return 0;
889 }
890 
892 {
893  int ret;
894 
896 
897  frame->format = avctx->pix_fmt;
898  if (frame->width <= 0 || frame->height <= 0) {
899  frame->width = avctx->width;
900  frame->height = avctx->height;
901  }
902 
904  if (ret < 0) {
905  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
907  return ret;
908  }
909 
910  return 0;
911 }
912 
914 {
915  AVCodecInternal *avci = avctx->internal;
916 
917  if (!avci->recon_frame)
918  return AVERROR(EINVAL);
919  if (!avci->recon_frame->buf[0])
920  return avci->draining_done ? AVERROR_EOF : AVERROR(EAGAIN);
921 
923  return 0;
924 }
925 
927 {
928  AVCodecInternal *avci = avctx->internal;
929 
930  if (avci->in_frame)
931  av_frame_unref(avci->in_frame);
932  if (avci->recon_frame)
934 }
935 
937 {
938  return av_mallocz(sizeof(EncodeContext));
939 }
940 
942 {
944  AVCPBProperties *props;
945  size_t size;
946  int i;
947 
948  for (i = 0; i < avctx->nb_coded_side_data; i++)
950  return (AVCPBProperties *)avctx->coded_side_data[i].data;
951 
952  props = av_cpb_properties_alloc(&size);
953  if (!props)
954  return NULL;
955 
956  tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp));
957  if (!tmp) {
958  av_freep(&props);
959  return NULL;
960  }
961 
962  avctx->coded_side_data = tmp;
963  avctx->nb_coded_side_data++;
964 
966  avctx->coded_side_data[avctx->nb_coded_side_data - 1].data = (uint8_t*)props;
967  avctx->coded_side_data[avctx->nb_coded_side_data - 1].size = size;
968 
969  return props;
970 }
971 
973  int error_count, enum AVPictureType pict_type)
974 {
975  uint8_t *side_data;
976  size_t side_data_size;
977 
978  side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
979  if (!side_data) {
980  side_data_size = 4+4+8*error_count;
982  side_data_size);
983  }
984 
985  if (!side_data || side_data_size < 4+4+8*error_count)
986  return AVERROR(ENOMEM);
987 
988  AV_WL32(side_data, quality);
989  side_data[4] = pict_type;
990  side_data[5] = error_count;
991  for (int i = 0; i < error_count; ++i)
992  AV_WL64(side_data+8 + 8*i , error[i]);
993 
994  return 0;
995 }
996 
997 int ff_check_codec_matrices(AVCodecContext *avctx, unsigned types, uint16_t min, uint16_t max)
998 {
999  uint16_t *matrices[] = {avctx->intra_matrix, avctx->inter_matrix, avctx->chroma_intra_matrix};
1000  const char *names[] = {"Intra", "Inter", "Chroma Intra"};
1001  static_assert(FF_ARRAY_ELEMS(matrices) == FF_ARRAY_ELEMS(names), "matrix count mismatch");
1002  for (int m = 0; m < FF_ARRAY_ELEMS(matrices); m++) {
1003  uint16_t *matrix = matrices[m];
1004  if (matrix && (types & (1U << m))) {
1005  for (int i = 0; i < 64; i++) {
1006  if (matrix[i] < min || matrix[i] > max) {
1007  av_log(avctx, AV_LOG_ERROR, "%s matrix[%d] is %d which is out of the allowed range [%"PRIu16"-%"PRIu16"].\n", names[m], i, matrix[i], min, max);
1008  return AVERROR(EINVAL);
1009  }
1010  }
1011  }
1012  }
1013  return 0;
1014 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
flags
const SwsFlags flags[]
Definition: swscale.c:85
AVSubtitle
Definition: avcodec.h:2100
avcodec_encode_subtitle
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
Definition: encode.c:203
ff_encode_reordered_opaque
int ff_encode_reordered_opaque(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame)
Propagate user opaque values from the frame to avctx/pkt as needed.
Definition: encode.c:279
av_samples_copy
int av_samples_copy(uint8_t *const *dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Copy samples from src to dst.
Definition: samplefmt.c:222
AVCodecContext::frame_size
int frame_size
Number of samples per channel in an audio frame.
Definition: avcodec.h:1068
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: packet.c:434
AVCodec
AVCodec.
Definition: codec.h:172
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AVCodecContext::alpha_mode
enum AVAlphaMode alpha_mode
Indicates how the alpha channel of the video is represented.
Definition: avcodec.h:1950
avcodec_receive_packet
int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
Definition: encode.c:577
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
AVCodecContext::audio_service_type
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
Definition: avcodec.h:1089
FF_CODEC_CB_TYPE_RECEIVE_PACKET
@ FF_CODEC_CB_TYPE_RECEIVE_PACKET
Definition: codec_internal.h:124
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:422
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:666
AVCodecContext::decoded_side_data
AVFrameSideData ** decoded_side_data
Array containing static side data, such as HDR10 CLL / MDCV structures.
Definition: avcodec.h:1942
av_frame_get_buffer
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
Definition: frame.c:206
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:1040
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:659
av_frame_new_side_data
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Definition: frame.c:647
AV_PKT_DATA_QUALITY_STATS
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
Definition: packet.h:129
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:933
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3456
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AV_CODEC_CONFIG_SAMPLE_RATE
@ AV_CODEC_CONFIG_SAMPLE_RATE
int, terminated by 0
Definition: avcodec.h:2562
matrix
Definition: vc1dsp.c:43
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:200
AVPictureType
AVPictureType
Definition: avutil.h:276
FF_CODEC_CAP_EOF_FLUSH
#define FF_CODEC_CAP_EOF_FLUSH
The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it only wants to be flushe...
Definition: codec_internal.h:90
AVCodecContext::codec_descriptor
const struct AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
Definition: avcodec.h:1722
AV_WL8
#define AV_WL8(p, d)
Definition: intreadwrite.h:395
AVCodecContext::coded_side_data
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
Definition: avcodec.h:1781
int64_t
long long int64_t
Definition: coverity.c:34
av_alpha_mode_name
const char * av_alpha_mode_name(enum AVAlphaMode mode)
Definition: pixdesc.c:3921
encode_make_refcounted
static int encode_make_refcounted(AVCodecContext *avctx, AVPacket *avpkt)
Definition: encode.c:136
AV_CODEC_CAP_ENCODER_RECON_FRAME
#define AV_CODEC_CAP_ENCODER_RECON_FRAME
The encoder is able to output reconstructed frame data, i.e.
Definition: codec.h:159
AVCodecContext::intra_matrix
uint16_t * intra_matrix
custom intra quantization matrix Must be allocated with the av_malloc() family of functions,...
Definition: avcodec.h:960
ff_encode_receive_frame
int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
avcodec_receive_frame() implementation for encoders.
Definition: encode.c:913
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:466
pixdesc.h
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:664
AVPacketSideData
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition: packet.h:424
AVCodec::capabilities
int capabilities
Codec capabilities.
Definition: codec.h:191
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:777
internal.h
av_samples_set_silence
int av_samples_set_silence(uint8_t *const *audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
Definition: samplefmt.c:246
AVPacket::data
uint8_t * data
Definition: packet.h:603
AVComponentDescriptor::depth
int depth
Number of bits in the component.
Definition: pixdesc.h:57
AVCodecInternal::frame_thread_encoder
void * frame_thread_encoder
Definition: internal.h:98
AVCodecInternal::in_frame
AVFrame * in_frame
The input frame is stored here for encoders implementing the simple encode API.
Definition: internal.h:106
encode.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:669
data
const char data[16]
Definition: mxf.c:149
FFCodec
Definition: codec_internal.h:127
FFCodec::encode
int(* encode)(struct AVCodecContext *avctx, struct AVPacket *avpkt, const struct AVFrame *frame, int *got_packet_ptr)
Encode data to an AVPacket.
Definition: codec_internal.h:231
ff_encode_encode_cb
int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, AVFrame *frame, int *got_packet)
Definition: encode.c:292
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:621
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:636
AV_CODEC_CONFIG_PIX_FORMAT
@ AV_CODEC_CONFIG_PIX_FORMAT
AVPixelFormat, terminated by AV_PIX_FMT_NONE.
Definition: avcodec.h:2560
avcodec_is_open
int avcodec_is_open(AVCodecContext *s)
Definition: avcodec.c:713
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:329
ff_icc_profile_attach
int ff_icc_profile_attach(FFIccContext *s, cmsHPROFILE profile, AVFrame *frame)
Attach an ICC profile to a frame.
Definition: fflcms2.c:170
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:643
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:658
quality
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
Definition: rate_distortion.txt:12
AVPacketSideData::size
size_t size
Definition: packet.h:426
AV_CODEC_FLAG_COPY_OPAQUE
#define AV_CODEC_FLAG_COPY_OPAQUE
Definition: avcodec.h:279
finish
static void finish(void)
Definition: movenc.c:374
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:452
AVPacket::opaque_ref
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: packet.h:639
AV_CODEC_FLAG_FRAME_DURATION
#define AV_CODEC_FLAG_FRAME_DURATION
Signal to the encoder that the values of AVFrame.duration are valid and should be used (typically for...
Definition: avcodec.h:286
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1055
ff_icc_context_init
int ff_icc_context_init(FFIccContext *s, void *avctx)
Initializes an FFIccContext.
Definition: fflcms2.c:30
encode_receive_packet_internal
static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt)
Definition: encode.c:399
samplefmt.h
AVCodecContext::initial_padding
int initial_padding
Audio only.
Definition: avcodec.h:1114
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:500
encode_preinit_video
static int encode_preinit_video(AVCodecContext *avctx)
Definition: encode.c:598
ff_encode_add_stats_side_data
int ff_encode_add_stats_side_data(AVPacket *pkt, int quality, const int64_t error[], int error_count, enum AVPictureType pict_type)
Definition: encode.c:972
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVFrameSideDataType
AVFrameSideDataType
Definition: frame.h:49
av_unused
#define av_unused
Definition: attributes.h:164
av_get_planar_sample_fmt
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
Definition: samplefmt.c:86
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
avassert.h
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:657
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
encode_send_frame_internal
static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
Definition: encode.c:480
frame_thread_encoder.h
AVFrameSideData::size
size_t size
Definition: frame.h:324
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
FFCodec::cb
union FFCodec::@109 cb
encode_simple_internal
static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
Definition: encode.c:341
AVCodecContext::rc_initial_buffer_occupancy
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
Definition: avcodec.h:1316
av_channel_layout_describe
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
Definition: channel_layout.c:654
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
ff_frame_thread_encoder_init
av_cold int ff_frame_thread_encoder_init(AVCodecContext *avctx)
Initialize frame thread encoder.
Definition: frame_thread_encoder.c:120
AV_CODEC_CONFIG_SAMPLE_FORMAT
@ AV_CODEC_CONFIG_SAMPLE_FORMAT
AVSampleFormat, terminated by AV_SAMPLE_FMT_NONE.
Definition: avcodec.h:2563
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVCodecInternal::buffer_pkt
AVPacket * buffer_pkt
Temporary buffers for newly received or not yet output packets/frames.
Definition: internal.h:144
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:217
AVCodecContext::nb_decoded_side_data
int nb_decoded_side_data
Definition: avcodec.h:1943
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:201
AV_FRAME_DATA_AUDIO_SERVICE_TYPE
@ AV_FRAME_DATA_AUDIO_SERVICE_TYPE
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
Definition: frame.h:114
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:144
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:42
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1571
EncodeContext::avci
AVCodecInternal avci
Definition: encode.c:40
AVPacketSideData::data
uint8_t * data
Definition: packet.h:425
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ff_assert1_fpu
#define ff_assert1_fpu()
Definition: emms.h:99
FF_CODEC_CB_TYPE_ENCODE
@ FF_CODEC_CB_TYPE_ENCODE
Definition: codec_internal.h:118
ff_samples_from_time_base
static av_always_inline int64_t ff_samples_from_time_base(const AVCodecContext *avctx, int64_t duration)
Rescale from time base to AVCodecContext.sample_rate.
Definition: encode.h:105
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:51
av_mallocz
#define av_mallocz(s)
Definition: tableprint_vlc.h:31
FFCodec::encode_sub
int(* encode_sub)(struct AVCodecContext *avctx, uint8_t *buf, int buf_size, const struct AVSubtitle *sub)
Encode subtitles to a raw buffer.
Definition: codec_internal.h:237
AVPacket::opaque
void * opaque
for some private data of the user
Definition: packet.h:628
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:639
AVCPBProperties
This structure describes the bitrate properties of an encoded bitstream.
Definition: defs.h:282
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:453
ff_thread_video_encode_frame
int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, AVFrame *frame, int *got_packet_ptr)
Definition: frame_thread_encoder.c:301
AVCodecDescriptor::props
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
Definition: codec_desc.h:54
if
if(ret)
Definition: filter_design.txt:179
AVCodecContext::rc_buffer_size
int rc_buffer_size
decoder bitstream buffer size
Definition: avcodec.h:1273
fail
#define fail
Definition: test.h:478
AV_CODEC_PROP_INTRA_ONLY
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
Definition: codec_desc.h:72
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:586
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:213
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:599
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:681
AVCodec::type
enum AVMediaType type
Definition: codec.h:185
AVCodecContext::nb_coded_side_data
int nb_coded_side_data
Definition: avcodec.h:1782
ff_samples_to_time_base
static av_always_inline int64_t ff_samples_to_time_base(const AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
Definition: encode.h:93
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:478
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:493
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:427
AV_FRAME_DATA_ICC_PROFILE
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:144
ff_encode_internal_alloc
AVCodecInternal * ff_encode_internal_alloc(void)
Definition: encode.c:936
AV_CODEC_FLAG2_ICC_PROFILES
#define AV_CODEC_FLAG2_ICC_PROFILES
Generate/parse ICC profiles on encode/decode, as appropriate for the type of file.
Definition: avcodec.h:382
av_packet_move_ref
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: packet.c:491
AVCodecInternal::draining_done
int draining_done
Definition: internal.h:146
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
ff_sd_global_map
const SideDataMap ff_sd_global_map[]
A map between packet and frame side data types.
Definition: avcodec.c:57
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
AVAudioServiceType
AVAudioServiceType
Definition: defs.h:235
AV_PKT_DATA_NB
@ AV_PKT_DATA_NB
The number of side data types.
Definition: packet.h:394
av_packet_side_data_get
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
Definition: packet.c:646
ff_icc_profile_generate
int ff_icc_profile_generate(FFIccContext *s, enum AVColorPrimaries color_prim, enum AVColorTransferCharacteristic color_trc, cmsHPROFILE *out_profile)
Generate an ICC profile for a given combination of color primaries and transfer function.
Definition: fflcms2.c:143
attribute_align_arg
#define attribute_align_arg
Definition: internal.h:50
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:547
AVAlphaMode
AVAlphaMode
Correlation between the alpha channel and color values.
Definition: pixfmt.h:810
ff_encode_alloc_frame
int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
Allocate buffers for a frame.
Definition: encode.c:891
avcodec_get_supported_config
int avcodec_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
Retrieve a list of all supported values for a given configuration type.
Definition: avcodec.c:831
AV_CODEC_CONFIG_CHANNEL_LAYOUT
@ AV_CODEC_CONFIG_CHANNEL_LAYOUT
AVChannelLayout, terminated by {0}.
Definition: avcodec.h:2564
AVCodecContext::stats_out
char * stats_out
pass1 encoding statistics output buffer
Definition: avcodec.h:1330
av_get_exact_bits_per_sample
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:446
pad_last_frame
static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src, int out_samples)
Pad last frame with silence.
Definition: encode.c:156
f
f
Definition: af_crystalizer.c:122
AVCodecContext::flags2
int flags2
AV_CODEC_FLAG2_*.
Definition: avcodec.h:507
SideDataMap::packet
enum AVPacketSideDataType packet
Definition: avcodec_internal.h:35
AVPacket::size
int size
Definition: packet.h:604
av_frame_ref
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:278
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
codec_internal.h
AV_CODEC_PROP_REORDER
#define AV_CODEC_PROP_REORDER
Codec supports frame reordering.
Definition: codec_desc.h:92
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
FFCodec::receive_packet
int(* receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt)
Encode API with decoupled frame/packet dataflow.
Definition: codec_internal.h:246
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
EncodeContext
Definition: encode.c:39
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1047
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
size
int size
Definition: twinvq_data.h:10344
AV_CODEC_CONFIG_ALPHA_MODE
@ AV_CODEC_CONFIG_ALPHA_MODE
AVAlphaMode, terminated by AVALPHA_MODE_UNSPECIFIED.
Definition: avcodec.h:2567
EncodeContext::last_audio_frame
int last_audio_frame
An audio frame with less than required samples has been submitted (and potentially padded with silenc...
Definition: encode.c:53
AV_WL32A
#define AV_WL32A(p, v)
Definition: intreadwrite.h:571
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:247
AVFrameSideData::data
uint8_t * data
Definition: frame.h:323
ffcodec
static const av_always_inline FFCodec * ffcodec(const AVCodec *codec)
Definition: codec_internal.h:290
AVCodecInternal::byte_buffer
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
Definition: internal.h:95
AVCodecContext::chroma_intra_matrix
uint16_t * chroma_intra_matrix
custom intra quantization matrix
Definition: avcodec.h:976
frame.h
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:602
AV_WL64
#define AV_WL64(p, v)
Definition: intreadwrite.h:436
SideDataMap::frame
enum AVFrameSideDataType frame
Definition: avcodec_internal.h:36
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:609
AVCodecInternal
Definition: internal.h:49
AVCodecInternal::byte_buffer_size
unsigned int byte_buffer_size
Definition: internal.h:96
encode_ctx
static EncodeContext * encode_ctx(AVCodecInternal *avci)
Definition: encode.c:56
ff_encode_preinit
int ff_encode_preinit(AVCodecContext *avctx)
Definition: encode.c:800
av_channel_layout_compare
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
Definition: channel_layout.c:811
AV_FRAME_DATA_SKIP_SAMPLES
@ AV_FRAME_DATA_SKIP_SAMPLES
Recommends skipping the specified number of samples.
Definition: frame.h:109
encode_set_packet_props
static int encode_set_packet_props(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame)
Definition: encode.c:232
av_codec_is_encoder
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:79
emms.h
avcodec_default_get_buffer2
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
Definition: get_buffer.c:253
FFCodec::caps_internal
unsigned caps_internal
Internal codec capabilities FF_CODEC_CAP_*.
Definition: codec_internal.h:136
AV_PKT_DATA_CPB_PROPERTIES
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
Definition: packet.h:142
AV_CODEC_FLAG_RECON_FRAME
#define AV_CODEC_FLAG_RECON_FRAME
Request the encoder to output reconstructed frames, i.e. frames that would be produced by decoding th...
Definition: avcodec.h:244
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:596
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:108
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
Definition: packet.c:252
internal.h
EncodeContext::intra_only_flag
int intra_only_flag
This is set to AV_PKT_FLAG_KEY for encoders that encode intra-only formats (i.e.
Definition: encode.c:47
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:58
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
av_fast_padded_malloc
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
Definition: utils.c:53
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_frame_move_ref
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:523
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:496
av_buffer_replace
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
Definition: buffer.c:233
profile
int profile
Definition: mxfenc.c:2299
AVCodecContext::height
int height
Definition: avcodec.h:604
avcodec_send_frame
int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
Definition: encode.c:544
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:643
FF_CODEC_CAP_ICC_PROFILES
#define FF_CODEC_CAP_ICC_PROFILES
Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).
Definition: codec_internal.h:82
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:1471
avcodec.h
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
AVCodecContext::frame_num
int64_t frame_num
Frame counter, set by libavcodec.
Definition: avcodec.h:1896
ret
ret
Definition: filter_design.txt:187
AVALPHA_MODE_UNSPECIFIED
@ AVALPHA_MODE_UNSPECIFIED
Unknown alpha handling, or no alpha channel.
Definition: pixfmt.h:811
ff_encode_flush_buffers
void ff_encode_flush_buffers(AVCodecContext *avctx)
Definition: encode.c:926
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
av_packet_side_data_new
AVPacketSideData * av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, size_t size, int flags)
Allocate a new packet side data.
Definition: packet.c:696
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:614
AVCodecInternal::recon_frame
AVFrame * recon_frame
When the AV_CODEC_FLAG_RECON_FRAME flag is used.
Definition: internal.h:114
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
av_sat_add64
#define av_sat_add64
Definition: common.h:139
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:443
channel_layout.h
avcodec_internal.h
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition: packet.c:231
ff_get_encode_buffer
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Definition: encode.c:105
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVCodecInternal::pad_samples
int pad_samples
Audio encoders can set this flag during init to indicate that they want the small last frame to be pa...
Definition: internal.h:67
AVCodecContext::get_encode_buffer
int(* get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags)
This callback is called at the beginning of each packet to get a data buffer for it.
Definition: avcodec.h:1885
encode_simple_receive_packet
static int encode_simple_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Definition: encode.c:386
AV_RB8
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL AV_RB8
Definition: bytestream.h:99
AVPixFmtDescriptor::comp
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:105
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommends skipping the specified number of samples.
Definition: packet.h:153
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
AVPacketSideDataType
AVPacketSideDataType
Definition: packet.h:41
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
FFCodec::cb_type
unsigned cb_type
This field determines the type of the codec (decoder/encoder) and also the exact callback cb implemen...
Definition: codec_internal.h:160
av_buffer_realloc
int av_buffer_realloc(AVBufferRef **pbuf, size_t size)
Reallocate a given buffer.
Definition: buffer.c:183
AVCodecInternal::buffer_frame
AVFrame * buffer_frame
Definition: internal.h:145
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:450
AVCodecInternal::draining
int draining
decoding: AVERROR_EOF has been returned from ff_decode_get_packet(); must not be used by decoders tha...
Definition: internal.h:139
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition: avcodec.h:451
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
mem.h
encode_preinit_audio
static int encode_preinit_audio(AVCodecContext *avctx)
Definition: encode.c:701
ff_encode_get_frame
int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
Called by encoders to get the next frame for encoding.
Definition: encode.c:217
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:321
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AVPacket
This structure stores compressed data.
Definition: packet.h:580
avcodec_default_get_encode_buffer
int avcodec_default_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int flags)
The default callback for AVCodecContext.get_encode_buffer().
Definition: encode.c:83
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVCodecContext::inter_matrix
uint16_t * inter_matrix
custom inter quantization matrix Must be allocated with the av_malloc() family of functions,...
Definition: avcodec.h:969
av_frame_side_data_get
static const AVFrameSideData * av_frame_side_data_get(AVFrameSideData *const *sd, const int nb_sd, enum AVFrameSideDataType type)
Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conver...
Definition: frame.h:1190
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:604
AV_CODEC_FLAG2_FIXED_FRAME_SIZE
#define AV_CODEC_FLAG2_FIXED_FRAME_SIZE
Force audio encoders to use a fixed frame size.
Definition: avcodec.h:359
encode_generate_icc_profile
static int encode_generate_icc_profile(av_unused AVCodecContext *c, av_unused AVFrame *f)
Definition: encode.c:474
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_encode_add_cpb_side_data
AVCPBProperties * ff_encode_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
Definition: encode.c:941
AVCodecContext::sw_pix_fmt
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:650
pkt
static AVPacket * pkt
Definition: demux_decode.c:55
AV_CODEC_CAP_SMALL_LAST_FRAME
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
Definition: codec.h:81
codec_desc.h
ff_alloc_packet
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition: encode.c:61
AVSubtitle::start_display_time
uint32_t start_display_time
Definition: avcodec.h:2102
AV_WL16A
#define AV_WL16A(p, v)
Definition: intreadwrite.h:557
src
#define src
Definition: vp8dsp.c:248
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:3376
av_cpb_properties_alloc
AVCPBProperties * av_cpb_properties_alloc(size_t *size)
Allocate a CPB properties structure and initialize its fields to default values.
Definition: utils.c:960
AV_CODEC_FLAG_PASS1
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition: avcodec.h:290
ff_check_codec_matrices
int ff_check_codec_matrices(AVCodecContext *avctx, unsigned types, uint16_t min, uint16_t max)
Definition: encode.c:997
min
float min
Definition: vorbis_enc_data.h:429