FFmpeg
decode.c
Go to the documentation of this file.
1 /*
2  * generic decoding-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 <stdint.h>
22 #include <string.h>
23 
24 #include "config.h"
25 
26 #if CONFIG_ICONV
27 # include <iconv.h>
28 #endif
29 
30 #include "libavutil/avassert.h"
32 #include "libavutil/common.h"
33 #include "libavutil/emms.h"
34 #include "libavutil/frame.h"
35 #include "libavutil/hwcontext.h"
36 #include "libavutil/imgutils.h"
37 #include "libavutil/internal.h"
39 #include "libavutil/mem.h"
40 #include "libavutil/stereo3d.h"
41 
42 #include "avcodec.h"
43 #include "avcodec_internal.h"
44 #include "bytestream.h"
45 #include "bsf.h"
46 #include "codec_desc.h"
47 #include "codec_internal.h"
48 #include "decode.h"
49 #include "hwaccel_internal.h"
50 #include "hwconfig.h"
51 #include "internal.h"
52 #include "lcevcdec.h"
53 #include "packet_internal.h"
54 #include "progressframe.h"
55 #include "refstruct.h"
56 #include "thread.h"
57 #include "threadprogress.h"
58 
59 typedef struct DecodeContext {
61 
62  /**
63  * This is set to AV_FRAME_FLAG_KEY for decoders of intra-only formats
64  * (those whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set)
65  * to set the flag generically.
66  */
68 
69  /**
70  * This is set to AV_PICTURE_TYPE_I for intra only video decoders
71  * and to AV_PICTURE_TYPE_NONE for other decoders. It is used to set
72  * the AVFrame's pict_type before the decoder receives it.
73  */
75 
76  /* to prevent infinite loop on errors when draining */
78 
79  /**
80  * The caller has submitted a NULL packet on input.
81  */
83 
84  int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
85  int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
86  int64_t pts_correction_last_pts; /// PTS of the last frame
87  int64_t pts_correction_last_dts; /// DTS of the last frame
88 
89  /**
90  * Bitmask indicating for which side data types we prefer user-supplied
91  * (global or attached to packets) side data over bytestream.
92  */
94 
97  int width;
98  int height;
100 
102 {
103  return (DecodeContext *)avci;
104 }
105 
106 static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
107 {
108  int ret;
109  size_t size;
110  const uint8_t *data;
111  uint32_t flags;
112  int64_t val;
113 
115  if (!data)
116  return 0;
117 
118  if (!(avctx->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE)) {
119  av_log(avctx, AV_LOG_ERROR, "This decoder does not support parameter "
120  "changes, but PARAM_CHANGE side data was sent to it.\n");
121  ret = AVERROR(EINVAL);
122  goto fail2;
123  }
124 
125  if (size < 4)
126  goto fail;
127 
128  flags = bytestream_get_le32(&data);
129  size -= 4;
130 
132  if (size < 4)
133  goto fail;
134  val = bytestream_get_le32(&data);
135  if (val <= 0 || val > INT_MAX) {
136  av_log(avctx, AV_LOG_ERROR, "Invalid sample rate");
138  goto fail2;
139  }
140  avctx->sample_rate = val;
141  size -= 4;
142  }
144  if (size < 8)
145  goto fail;
146  avctx->width = bytestream_get_le32(&data);
147  avctx->height = bytestream_get_le32(&data);
148  size -= 8;
149  ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
150  if (ret < 0)
151  goto fail2;
152  }
153 
154  return 0;
155 fail:
156  av_log(avctx, AV_LOG_ERROR, "PARAM_CHANGE side data too small.\n");
158 fail2:
159  if (ret < 0) {
160  av_log(avctx, AV_LOG_ERROR, "Error applying parameter changes.\n");
161  if (avctx->err_recognition & AV_EF_EXPLODE)
162  return ret;
163  }
164  return 0;
165 }
166 
168 {
169  int ret = 0;
170 
172  if (pkt) {
174 #if FF_API_FRAME_PKT
175  if (!ret)
176  avci->last_pkt_props->stream_index = pkt->size; // Needed for ff_decode_frame_props().
177 #endif
178  }
179  return ret;
180 }
181 
183 {
184  AVCodecInternal *avci = avctx->internal;
185  const FFCodec *const codec = ffcodec(avctx->codec);
186  int ret;
187 
188  if (avci->bsf)
189  return 0;
190 
191  ret = av_bsf_list_parse_str(codec->bsfs, &avci->bsf);
192  if (ret < 0) {
193  av_log(avctx, AV_LOG_ERROR, "Error parsing decoder bitstream filters '%s': %s\n", codec->bsfs, av_err2str(ret));
194  if (ret != AVERROR(ENOMEM))
195  ret = AVERROR_BUG;
196  goto fail;
197  }
198 
199  /* We do not currently have an API for passing the input timebase into decoders,
200  * but no filters used here should actually need it.
201  * So we make up some plausible-looking number (the MPEG 90kHz timebase) */
202  avci->bsf->time_base_in = (AVRational){ 1, 90000 };
204  if (ret < 0)
205  goto fail;
206 
207  ret = av_bsf_init(avci->bsf);
208  if (ret < 0)
209  goto fail;
210 
211  return 0;
212 fail:
213  av_bsf_free(&avci->bsf);
214  return ret;
215 }
216 
217 #if !HAVE_THREADS
218 #define ff_thread_get_packet(avctx, pkt) (AVERROR_BUG)
219 #define ff_thread_receive_frame(avctx, frame) (AVERROR_BUG)
220 #endif
221 
223 {
224  AVCodecInternal *avci = avctx->internal;
225  int ret;
226 
227  ret = av_bsf_receive_packet(avci->bsf, pkt);
228  if (ret < 0)
229  return ret;
230 
233  if (ret < 0)
234  goto finish;
235  }
236 
237  ret = apply_param_change(avctx, pkt);
238  if (ret < 0)
239  goto finish;
240 
241  return 0;
242 finish:
244  return ret;
245 }
246 
248 {
249  AVCodecInternal *avci = avctx->internal;
250  DecodeContext *dc = decode_ctx(avci);
251 
252  if (avci->draining)
253  return AVERROR_EOF;
254 
255  /* If we are a worker thread, get the next packet from the threading
256  * context. Otherwise we are the main (user-facing) context, so we get the
257  * next packet from the input filterchain.
258  */
259  if (avctx->internal->is_frame_mt)
260  return ff_thread_get_packet(avctx, pkt);
261 
262  while (1) {
263  int ret = decode_get_packet(avctx, pkt);
264  if (ret == AVERROR(EAGAIN) &&
265  (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
266  ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
267  if (ret >= 0)
268  continue;
269 
271  }
272 
273  if (ret == AVERROR_EOF)
274  avci->draining = 1;
275  return ret;
276  }
277 }
278 
279 /**
280  * Attempt to guess proper monotonic timestamps for decoded video frames
281  * which might have incorrect times. Input timestamps may wrap around, in
282  * which case the output will as well.
283  *
284  * @param pts the pts field of the decoded AVPacket, as passed through
285  * AVFrame.pts
286  * @param dts the dts field of the decoded AVPacket
287  * @return one of the input values, may be AV_NOPTS_VALUE
288  */
290  int64_t reordered_pts, int64_t dts)
291 {
293 
294  if (dts != AV_NOPTS_VALUE) {
295  dc->pts_correction_num_faulty_dts += dts <= dc->pts_correction_last_dts;
296  dc->pts_correction_last_dts = dts;
297  } else if (reordered_pts != AV_NOPTS_VALUE)
298  dc->pts_correction_last_dts = reordered_pts;
299 
300  if (reordered_pts != AV_NOPTS_VALUE) {
301  dc->pts_correction_num_faulty_pts += reordered_pts <= dc->pts_correction_last_pts;
302  dc->pts_correction_last_pts = reordered_pts;
303  } else if(dts != AV_NOPTS_VALUE)
304  dc->pts_correction_last_pts = dts;
305 
306  if ((dc->pts_correction_num_faulty_pts<=dc->pts_correction_num_faulty_dts || dts == AV_NOPTS_VALUE)
307  && reordered_pts != AV_NOPTS_VALUE)
308  pts = reordered_pts;
309  else
310  pts = dts;
311 
312  return pts;
313 }
314 
315 static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples)
316 {
317  AVCodecInternal *avci = avctx->internal;
318  AVFrameSideData *side;
319  uint32_t discard_padding = 0;
320  uint8_t skip_reason = 0;
321  uint8_t discard_reason = 0;
322 
324  if (side && side->size >= 10) {
325  avci->skip_samples = AV_RL32(side->data);
326  avci->skip_samples = FFMAX(0, avci->skip_samples);
327  discard_padding = AV_RL32(side->data + 4);
328  av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n",
329  avci->skip_samples, (int)discard_padding);
330  skip_reason = AV_RL8(side->data + 8);
331  discard_reason = AV_RL8(side->data + 9);
332  }
333 
334  if ((avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
335  if (!side && (avci->skip_samples || discard_padding))
337  if (side && (avci->skip_samples || discard_padding)) {
338  AV_WL32(side->data, avci->skip_samples);
339  AV_WL32(side->data + 4, discard_padding);
340  AV_WL8(side->data + 8, skip_reason);
341  AV_WL8(side->data + 9, discard_reason);
342  avci->skip_samples = 0;
343  }
344  return 0;
345  }
347 
348  if ((frame->flags & AV_FRAME_FLAG_DISCARD)) {
349  avci->skip_samples = FFMAX(0, avci->skip_samples - frame->nb_samples);
350  *discarded_samples += frame->nb_samples;
351  return AVERROR(EAGAIN);
352  }
353 
354  if (avci->skip_samples > 0) {
355  if (frame->nb_samples <= avci->skip_samples){
356  *discarded_samples += frame->nb_samples;
357  avci->skip_samples -= frame->nb_samples;
358  av_log(avctx, AV_LOG_DEBUG, "skip whole frame, skip left: %d\n",
359  avci->skip_samples);
360  return AVERROR(EAGAIN);
361  } else {
362  av_samples_copy(frame->extended_data, frame->extended_data, 0, avci->skip_samples,
363  frame->nb_samples - avci->skip_samples, avctx->ch_layout.nb_channels, frame->format);
364  if (avctx->pkt_timebase.num && avctx->sample_rate) {
365  int64_t diff_ts = av_rescale_q(avci->skip_samples,
366  (AVRational){1, avctx->sample_rate},
367  avctx->pkt_timebase);
368  if (frame->pts != AV_NOPTS_VALUE)
369  frame->pts += diff_ts;
370  if (frame->pkt_dts != AV_NOPTS_VALUE)
371  frame->pkt_dts += diff_ts;
372  if (frame->duration >= diff_ts)
373  frame->duration -= diff_ts;
374  } else
375  av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n");
376 
377  av_log(avctx, AV_LOG_DEBUG, "skip %d/%d samples\n",
378  avci->skip_samples, frame->nb_samples);
379  *discarded_samples += avci->skip_samples;
380  frame->nb_samples -= avci->skip_samples;
381  avci->skip_samples = 0;
382  }
383  }
384 
385  if (discard_padding > 0 && discard_padding <= frame->nb_samples) {
386  if (discard_padding == frame->nb_samples) {
387  *discarded_samples += frame->nb_samples;
388  return AVERROR(EAGAIN);
389  } else {
390  if (avctx->pkt_timebase.num && avctx->sample_rate) {
391  int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding,
392  (AVRational){1, avctx->sample_rate},
393  avctx->pkt_timebase);
394  frame->duration = diff_ts;
395  } else
396  av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n");
397 
398  av_log(avctx, AV_LOG_DEBUG, "discard %d/%d samples\n",
399  (int)discard_padding, frame->nb_samples);
400  frame->nb_samples -= discard_padding;
401  }
402  }
403 
404  return 0;
405 }
406 
407 /*
408  * The core of the receive_frame_wrapper for the decoders implementing
409  * the simple API. Certain decoders might consume partial packets without
410  * returning any output, so this function needs to be called in a loop until it
411  * returns EAGAIN.
412  **/
413 static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples)
414 {
415  AVCodecInternal *avci = avctx->internal;
416  DecodeContext *dc = decode_ctx(avci);
417  AVPacket *const pkt = avci->in_pkt;
418  const FFCodec *const codec = ffcodec(avctx->codec);
419  int got_frame, consumed;
420  int ret;
421 
422  if (!pkt->data && !avci->draining) {
424  ret = ff_decode_get_packet(avctx, pkt);
425  if (ret < 0 && ret != AVERROR_EOF)
426  return ret;
427  }
428 
429  // Some codecs (at least wma lossless) will crash when feeding drain packets
430  // after EOF was signaled.
431  if (avci->draining_done)
432  return AVERROR_EOF;
433 
434  if (!pkt->data &&
436  return AVERROR_EOF;
437 
438  got_frame = 0;
439 
440  frame->pict_type = dc->initial_pict_type;
441  frame->flags |= dc->intra_only_flag;
442  consumed = codec->cb.decode(avctx, frame, &got_frame, pkt);
443 
445  frame->pkt_dts = pkt->dts;
446  if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
447 #if FF_API_FRAME_PKT
449  if(!avctx->has_b_frames)
450  frame->pkt_pos = pkt->pos;
452 #endif
453  }
454  emms_c();
455 
456  if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
457  ret = (!got_frame || frame->flags & AV_FRAME_FLAG_DISCARD)
458  ? AVERROR(EAGAIN)
459  : 0;
460  } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
461  ret = !got_frame ? AVERROR(EAGAIN)
462  : discard_samples(avctx, frame, discarded_samples);
463  } else
464  av_assert0(0);
465 
466  if (ret == AVERROR(EAGAIN))
468 
469  // FF_CODEC_CB_TYPE_DECODE decoders must not return AVERROR EAGAIN
470  // code later will add AVERROR(EAGAIN) to a pointer
471  av_assert0(consumed != AVERROR(EAGAIN));
472  if (consumed < 0)
473  ret = consumed;
474  if (consumed >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO)
475  consumed = pkt->size;
476 
477  if (!ret)
478  av_assert0(frame->buf[0]);
479  if (ret == AVERROR(EAGAIN))
480  ret = 0;
481 
482  /* do not stop draining when got_frame != 0 or ret < 0 */
483  if (avci->draining && !got_frame) {
484  if (ret < 0) {
485  /* prevent infinite loop if a decoder wrongly always return error on draining */
486  /* reasonable nb_errors_max = maximum b frames + thread count */
487  int nb_errors_max = 20 + (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME ?
488  avctx->thread_count : 1);
489 
490  if (decode_ctx(avci)->nb_draining_errors++ >= nb_errors_max) {
491  av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, this is a bug. "
492  "Stop draining and force EOF.\n");
493  avci->draining_done = 1;
494  ret = AVERROR_BUG;
495  }
496  } else {
497  avci->draining_done = 1;
498  }
499  }
500 
501  if (consumed >= pkt->size || ret < 0) {
503  } else {
504  pkt->data += consumed;
505  pkt->size -= consumed;
509 #if FF_API_FRAME_PKT
510  // See extract_packet_props() comment.
511  avci->last_pkt_props->stream_index = avci->last_pkt_props->stream_index - consumed;
512 #endif
515  }
516  }
517 
518  return ret;
519 }
520 
521 #if CONFIG_LCMS2
522 static int detect_colorspace(AVCodecContext *avctx, AVFrame *frame)
523 {
524  AVCodecInternal *avci = avctx->internal;
526  AVColorPrimariesDesc coeffs;
527  enum AVColorPrimaries prim;
528  cmsHPROFILE profile;
529  AVFrameSideData *sd;
530  int ret;
531  if (!(avctx->flags2 & AV_CODEC_FLAG2_ICC_PROFILES))
532  return 0;
533 
535  if (!sd || !sd->size)
536  return 0;
537 
538  if (!avci->icc.avctx) {
539  ret = ff_icc_context_init(&avci->icc, avctx);
540  if (ret < 0)
541  return ret;
542  }
543 
544  profile = cmsOpenProfileFromMemTHR(avci->icc.ctx, sd->data, sd->size);
545  if (!profile)
546  return AVERROR_INVALIDDATA;
547 
548  ret = ff_icc_profile_sanitize(&avci->icc, profile);
549  if (!ret)
550  ret = ff_icc_profile_read_primaries(&avci->icc, profile, &coeffs);
551  if (!ret)
552  ret = ff_icc_profile_detect_transfer(&avci->icc, profile, &trc);
553  cmsCloseProfile(profile);
554  if (ret < 0)
555  return ret;
556 
557  prim = av_csp_primaries_id_from_desc(&coeffs);
558  if (prim != AVCOL_PRI_UNSPECIFIED)
559  frame->color_primaries = prim;
560  if (trc != AVCOL_TRC_UNSPECIFIED)
561  frame->color_trc = trc;
562  return 0;
563 }
564 #else /* !CONFIG_LCMS2 */
566 {
567  return 0;
568 }
569 #endif
570 
571 static int fill_frame_props(const AVCodecContext *avctx, AVFrame *frame)
572 {
573  int ret;
574 
575  if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED)
576  frame->color_primaries = avctx->color_primaries;
577  if (frame->color_trc == AVCOL_TRC_UNSPECIFIED)
578  frame->color_trc = avctx->color_trc;
579  if (frame->colorspace == AVCOL_SPC_UNSPECIFIED)
580  frame->colorspace = avctx->colorspace;
581  if (frame->color_range == AVCOL_RANGE_UNSPECIFIED)
582  frame->color_range = avctx->color_range;
583  if (frame->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
584  frame->chroma_location = avctx->chroma_sample_location;
585 
586  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
587  if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
588  if (frame->format == AV_PIX_FMT_NONE) frame->format = avctx->pix_fmt;
589  } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
590  if (frame->format == AV_SAMPLE_FMT_NONE)
591  frame->format = avctx->sample_fmt;
592  if (!frame->ch_layout.nb_channels) {
593  ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout);
594  if (ret < 0)
595  return ret;
596  }
597  if (!frame->sample_rate)
598  frame->sample_rate = avctx->sample_rate;
599  }
600 
601  return 0;
602 }
603 
605 {
606  int ret;
607  int64_t discarded_samples = 0;
608 
609  while (!frame->buf[0]) {
610  if (discarded_samples > avctx->max_samples)
611  return AVERROR(EAGAIN);
612  ret = decode_simple_internal(avctx, frame, &discarded_samples);
613  if (ret < 0)
614  return ret;
615  }
616 
617  return 0;
618 }
619 
621 {
622  AVCodecInternal *avci = avctx->internal;
623  DecodeContext *dc = decode_ctx(avci);
624  const FFCodec *const codec = ffcodec(avctx->codec);
625  int ret;
626 
627  av_assert0(!frame->buf[0]);
628 
629  if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) {
630  while (1) {
631  frame->pict_type = dc->initial_pict_type;
632  frame->flags |= dc->intra_only_flag;
633  ret = codec->cb.receive_frame(avctx, frame);
634  emms_c();
635  if (!ret) {
636  if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
637  int64_t discarded_samples = 0;
638  ret = discard_samples(avctx, frame, &discarded_samples);
639  }
640  if (ret == AVERROR(EAGAIN) || (frame->flags & AV_FRAME_FLAG_DISCARD)) {
642  continue;
643  }
644  }
645  break;
646  }
647  } else
649 
650  if (ret == AVERROR_EOF)
651  avci->draining_done = 1;
652 
653  return ret;
654 }
655 
657 {
658  AVCodecInternal *avci = avctx->internal;
659  DecodeContext *dc = decode_ctx(avci);
660  int ret, ok;
661 
662  if (avctx->active_thread_type & FF_THREAD_FRAME)
664  else
666 
667  /* preserve ret */
668  ok = detect_colorspace(avctx, frame);
669  if (ok < 0) {
671  return ok;
672  }
673 
674  if (!ret) {
675  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
676  if (!frame->width)
677  frame->width = avctx->width;
678  if (!frame->height)
679  frame->height = avctx->height;
680  }
681 
682  ret = fill_frame_props(avctx, frame);
683  if (ret < 0) {
685  return ret;
686  }
687 
688 #if FF_API_FRAME_KEY
690  frame->key_frame = !!(frame->flags & AV_FRAME_FLAG_KEY);
692 #endif
693 #if FF_API_INTERLACED_FRAME
695  frame->interlaced_frame = !!(frame->flags & AV_FRAME_FLAG_INTERLACED);
696  frame->top_field_first = !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);
698 #endif
699  frame->best_effort_timestamp = guess_correct_pts(dc,
700  frame->pts,
701  frame->pkt_dts);
702 
703  /* the only case where decode data is not set should be decoders
704  * that do not call ff_get_buffer() */
705  av_assert0((frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) ||
706  !(avctx->codec->capabilities & AV_CODEC_CAP_DR1));
707 
708  if (frame->private_ref) {
709  FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
710 
711  if (fdd->post_process) {
712  ret = fdd->post_process(avctx, frame);
713  if (ret < 0) {
715  return ret;
716  }
717  }
718  }
719  }
720 
721  /* free the per-frame decode data */
722  av_buffer_unref(&frame->private_ref);
723 
724  return ret;
725 }
726 
728 {
729  AVCodecInternal *avci = avctx->internal;
730  DecodeContext *dc = decode_ctx(avci);
731  int ret;
732 
733  if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
734  return AVERROR(EINVAL);
735 
736  if (dc->draining_started)
737  return AVERROR_EOF;
738 
739  if (avpkt && !avpkt->size && avpkt->data)
740  return AVERROR(EINVAL);
741 
742  if (avpkt && (avpkt->data || avpkt->side_data_elems)) {
743  if (!AVPACKET_IS_EMPTY(avci->buffer_pkt))
744  return AVERROR(EAGAIN);
745  ret = av_packet_ref(avci->buffer_pkt, avpkt);
746  if (ret < 0)
747  return ret;
748  } else
749  dc->draining_started = 1;
750 
751  if (!avci->buffer_frame->buf[0] && !dc->draining_started) {
753  if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
754  return ret;
755  }
756 
757  return 0;
758 }
759 
761 {
762  /* make sure we are noisy about decoders returning invalid cropping data */
763  if (frame->crop_left >= INT_MAX - frame->crop_right ||
764  frame->crop_top >= INT_MAX - frame->crop_bottom ||
765  (frame->crop_left + frame->crop_right) >= frame->width ||
766  (frame->crop_top + frame->crop_bottom) >= frame->height) {
767  av_log(avctx, AV_LOG_WARNING,
768  "Invalid cropping information set by a decoder: "
770  "(frame size %dx%d). This is a bug, please report it\n",
771  frame->crop_left, frame->crop_right, frame->crop_top, frame->crop_bottom,
772  frame->width, frame->height);
773  frame->crop_left = 0;
774  frame->crop_right = 0;
775  frame->crop_top = 0;
776  frame->crop_bottom = 0;
777  return 0;
778  }
779 
780  if (!avctx->apply_cropping)
781  return 0;
782 
785 }
786 
787 // make sure frames returned to the caller are valid
789 {
790  if (!frame->buf[0] || frame->format < 0)
791  goto fail;
792 
793  switch (avctx->codec_type) {
794  case AVMEDIA_TYPE_VIDEO:
795  if (frame->width <= 0 || frame->height <= 0)
796  goto fail;
797  break;
798  case AVMEDIA_TYPE_AUDIO:
799  if (!av_channel_layout_check(&frame->ch_layout) ||
800  frame->sample_rate <= 0)
801  goto fail;
802 
803  break;
804  default: av_assert0(0);
805  }
806 
807  return 0;
808 fail:
809  av_log(avctx, AV_LOG_ERROR, "An invalid frame was output by a decoder. "
810  "This is a bug, please report it.\n");
811  return AVERROR_BUG;
812 }
813 
815 {
816  AVCodecInternal *avci = avctx->internal;
817  int ret;
818 
819  if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
820  return AVERROR(EINVAL);
821 
822  if (avci->buffer_frame->buf[0]) {
824  } else {
826  if (ret < 0)
827  return ret;
828  }
829 
830  ret = frame_validate(avctx, frame);
831  if (ret < 0)
832  goto fail;
833 
834  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
835  ret = apply_cropping(avctx, frame);
836  if (ret < 0)
837  goto fail;
838  }
839 
840  avctx->frame_num++;
841 
842 #if FF_API_DROPCHANGED
843  if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED) {
844 
845  if (avctx->frame_num == 1) {
846  avci->initial_format = frame->format;
847  switch(avctx->codec_type) {
848  case AVMEDIA_TYPE_VIDEO:
849  avci->initial_width = frame->width;
850  avci->initial_height = frame->height;
851  break;
852  case AVMEDIA_TYPE_AUDIO:
853  avci->initial_sample_rate = frame->sample_rate ? frame->sample_rate :
854  avctx->sample_rate;
855  ret = av_channel_layout_copy(&avci->initial_ch_layout, &frame->ch_layout);
856  if (ret < 0)
857  goto fail;
858  break;
859  }
860  }
861 
862  if (avctx->frame_num > 1) {
863  int changed = avci->initial_format != frame->format;
864 
865  switch(avctx->codec_type) {
866  case AVMEDIA_TYPE_VIDEO:
867  changed |= avci->initial_width != frame->width ||
868  avci->initial_height != frame->height;
869  break;
870  case AVMEDIA_TYPE_AUDIO:
871  changed |= avci->initial_sample_rate != frame->sample_rate ||
872  avci->initial_sample_rate != avctx->sample_rate ||
874  break;
875  }
876 
877  if (changed) {
878  avci->changed_frames_dropped++;
879  av_log(avctx, AV_LOG_INFO, "dropped changed frame #%"PRId64" pts %"PRId64
880  " drop count: %d \n",
881  avctx->frame_num, frame->pts,
882  avci->changed_frames_dropped);
884  goto fail;
885  }
886  }
887  }
888 #endif
889  return 0;
890 fail:
892  return ret;
893 }
894 
896 {
897  memset(sub, 0, sizeof(*sub));
898  sub->pts = AV_NOPTS_VALUE;
899 }
900 
901 #define UTF8_MAX_BYTES 4 /* 5 and 6 bytes sequences should not be used */
902 static int recode_subtitle(AVCodecContext *avctx, const AVPacket **outpkt,
903  const AVPacket *inpkt, AVPacket *buf_pkt)
904 {
905 #if CONFIG_ICONV
906  iconv_t cd = (iconv_t)-1;
907  int ret = 0;
908  char *inb, *outb;
909  size_t inl, outl;
910 #endif
911 
912  if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_PRE_DECODER || inpkt->size == 0) {
913  *outpkt = inpkt;
914  return 0;
915  }
916 
917 #if CONFIG_ICONV
918  inb = inpkt->data;
919  inl = inpkt->size;
920 
921  if (inl >= INT_MAX / UTF8_MAX_BYTES - AV_INPUT_BUFFER_PADDING_SIZE) {
922  av_log(avctx, AV_LOG_ERROR, "Subtitles packet is too big for recoding\n");
923  return AVERROR(ERANGE);
924  }
925 
926  cd = iconv_open("UTF-8", avctx->sub_charenc);
927  av_assert0(cd != (iconv_t)-1);
928 
929  ret = av_new_packet(buf_pkt, inl * UTF8_MAX_BYTES);
930  if (ret < 0)
931  goto end;
932  ret = av_packet_copy_props(buf_pkt, inpkt);
933  if (ret < 0)
934  goto end;
935  outb = buf_pkt->data;
936  outl = buf_pkt->size;
937 
938  if (iconv(cd, &inb, &inl, &outb, &outl) == (size_t)-1 ||
939  iconv(cd, NULL, NULL, &outb, &outl) == (size_t)-1 ||
940  outl >= buf_pkt->size || inl != 0) {
941  ret = FFMIN(AVERROR(errno), -1);
942  av_log(avctx, AV_LOG_ERROR, "Unable to recode subtitle event \"%s\" "
943  "from %s to UTF-8\n", inpkt->data, avctx->sub_charenc);
944  goto end;
945  }
946  buf_pkt->size -= outl;
947  memset(buf_pkt->data + buf_pkt->size, 0, outl);
948  *outpkt = buf_pkt;
949 
950  ret = 0;
951 end:
952  if (ret < 0)
953  av_packet_unref(buf_pkt);
954  if (cd != (iconv_t)-1)
955  iconv_close(cd);
956  return ret;
957 #else
958  av_log(avctx, AV_LOG_ERROR, "requesting subtitles recoding without iconv");
959  return AVERROR(EINVAL);
960 #endif
961 }
962 
963 static int utf8_check(const uint8_t *str)
964 {
965  const uint8_t *byte;
966  uint32_t codepoint, min;
967 
968  while (*str) {
969  byte = str;
970  GET_UTF8(codepoint, *(byte++), return 0;);
971  min = byte - str == 1 ? 0 : byte - str == 2 ? 0x80 :
972  1 << (5 * (byte - str) - 4);
973  if (codepoint < min || codepoint >= 0x110000 ||
974  codepoint == 0xFFFE /* BOM */ ||
975  codepoint >= 0xD800 && codepoint <= 0xDFFF /* surrogates */)
976  return 0;
977  str = byte;
978  }
979  return 1;
980 }
981 
983  int *got_sub_ptr, const AVPacket *avpkt)
984 {
985  int ret = 0;
986 
987  if (!avpkt->data && avpkt->size) {
988  av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
989  return AVERROR(EINVAL);
990  }
991  if (!avctx->codec)
992  return AVERROR(EINVAL);
994  av_log(avctx, AV_LOG_ERROR, "Codec not subtitle decoder\n");
995  return AVERROR(EINVAL);
996  }
997 
998  *got_sub_ptr = 0;
1000 
1001  if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size) {
1002  AVCodecInternal *avci = avctx->internal;
1003  const AVPacket *pkt;
1004 
1005  ret = recode_subtitle(avctx, &pkt, avpkt, avci->buffer_pkt);
1006  if (ret < 0)
1007  return ret;
1008 
1009  if (avctx->pkt_timebase.num && avpkt->pts != AV_NOPTS_VALUE)
1010  sub->pts = av_rescale_q(avpkt->pts,
1011  avctx->pkt_timebase, AV_TIME_BASE_Q);
1012  ret = ffcodec(avctx->codec)->cb.decode_sub(avctx, sub, got_sub_ptr, pkt);
1013  if (pkt == avci->buffer_pkt) // did we recode?
1014  av_packet_unref(avci->buffer_pkt);
1015  if (ret < 0) {
1016  *got_sub_ptr = 0;
1017  avsubtitle_free(sub);
1018  return ret;
1019  }
1020  av_assert1(!sub->num_rects || *got_sub_ptr);
1021 
1022  if (sub->num_rects && !sub->end_display_time && avpkt->duration &&
1023  avctx->pkt_timebase.num) {
1024  AVRational ms = { 1, 1000 };
1025  sub->end_display_time = av_rescale_q(avpkt->duration,
1026  avctx->pkt_timebase, ms);
1027  }
1028 
1030  sub->format = 0;
1031  else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
1032  sub->format = 1;
1033 
1034  for (unsigned i = 0; i < sub->num_rects; i++) {
1036  sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) {
1037  av_log(avctx, AV_LOG_ERROR,
1038  "Invalid UTF-8 in decoded subtitles text; "
1039  "maybe missing -sub_charenc option\n");
1040  avsubtitle_free(sub);
1041  *got_sub_ptr = 0;
1042  return AVERROR_INVALIDDATA;
1043  }
1044  }
1045 
1046  if (*got_sub_ptr)
1047  avctx->frame_num++;
1048  }
1049 
1050  return ret;
1051 }
1052 
1054  const enum AVPixelFormat *fmt)
1055 {
1056  const AVPixFmtDescriptor *desc;
1057  const AVCodecHWConfig *config;
1058  int i, n;
1059 
1060  // If a device was supplied when the codec was opened, assume that the
1061  // user wants to use it.
1062  if (avctx->hw_device_ctx && ffcodec(avctx->codec)->hw_configs) {
1063  AVHWDeviceContext *device_ctx =
1065  for (i = 0;; i++) {
1066  config = &ffcodec(avctx->codec)->hw_configs[i]->public;
1067  if (!config)
1068  break;
1069  if (!(config->methods &
1071  continue;
1072  if (device_ctx->type != config->device_type)
1073  continue;
1074  for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++) {
1075  if (config->pix_fmt == fmt[n])
1076  return fmt[n];
1077  }
1078  }
1079  }
1080  // No device or other setup, so we have to choose from things which
1081  // don't any other external information.
1082 
1083  // If the last element of the list is a software format, choose it
1084  // (this should be best software format if any exist).
1085  for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++);
1086  desc = av_pix_fmt_desc_get(fmt[n - 1]);
1087  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
1088  return fmt[n - 1];
1089 
1090  // Finally, traverse the list in order and choose the first entry
1091  // with no external dependencies (if there is no hardware configuration
1092  // information available then this just picks the first entry).
1093  for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++) {
1094  for (i = 0;; i++) {
1095  config = avcodec_get_hw_config(avctx->codec, i);
1096  if (!config)
1097  break;
1098  if (config->pix_fmt == fmt[n])
1099  break;
1100  }
1101  if (!config) {
1102  // No specific config available, so the decoder must be able
1103  // to handle this format without any additional setup.
1104  return fmt[n];
1105  }
1106  if (config->methods & AV_CODEC_HW_CONFIG_METHOD_INTERNAL) {
1107  // Usable with only internal setup.
1108  return fmt[n];
1109  }
1110  }
1111 
1112  // Nothing is usable, give up.
1113  return AV_PIX_FMT_NONE;
1114 }
1115 
1117  enum AVHWDeviceType dev_type)
1118 {
1119  AVHWDeviceContext *device_ctx;
1120  AVHWFramesContext *frames_ctx;
1121  int ret;
1122 
1123  if (!avctx->hwaccel)
1124  return AVERROR(ENOSYS);
1125 
1126  if (avctx->hw_frames_ctx)
1127  return 0;
1128  if (!avctx->hw_device_ctx) {
1129  av_log(avctx, AV_LOG_ERROR, "A hardware frames or device context is "
1130  "required for hardware accelerated decoding.\n");
1131  return AVERROR(EINVAL);
1132  }
1133 
1134  device_ctx = (AVHWDeviceContext *)avctx->hw_device_ctx->data;
1135  if (device_ctx->type != dev_type) {
1136  av_log(avctx, AV_LOG_ERROR, "Device type %s expected for hardware "
1137  "decoding, but got %s.\n", av_hwdevice_get_type_name(dev_type),
1138  av_hwdevice_get_type_name(device_ctx->type));
1139  return AVERROR(EINVAL);
1140  }
1141 
1143  avctx->hw_device_ctx,
1144  avctx->hwaccel->pix_fmt,
1145  &avctx->hw_frames_ctx);
1146  if (ret < 0)
1147  return ret;
1148 
1149  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
1150 
1151 
1152  if (frames_ctx->initial_pool_size) {
1153  // We guarantee 4 base work surfaces. The function above guarantees 1
1154  // (the absolute minimum), so add the missing count.
1155  frames_ctx->initial_pool_size += 3;
1156  }
1157 
1159  if (ret < 0) {
1160  av_buffer_unref(&avctx->hw_frames_ctx);
1161  return ret;
1162  }
1163 
1164  return 0;
1165 }
1166 
1168  AVBufferRef *device_ref,
1170  AVBufferRef **out_frames_ref)
1171 {
1172  AVBufferRef *frames_ref = NULL;
1173  const AVCodecHWConfigInternal *hw_config;
1174  const FFHWAccel *hwa;
1175  int i, ret;
1176 
1177  for (i = 0;; i++) {
1178  hw_config = ffcodec(avctx->codec)->hw_configs[i];
1179  if (!hw_config)
1180  return AVERROR(ENOENT);
1181  if (hw_config->public.pix_fmt == hw_pix_fmt)
1182  break;
1183  }
1184 
1185  hwa = hw_config->hwaccel;
1186  if (!hwa || !hwa->frame_params)
1187  return AVERROR(ENOENT);
1188 
1189  frames_ref = av_hwframe_ctx_alloc(device_ref);
1190  if (!frames_ref)
1191  return AVERROR(ENOMEM);
1192 
1193  if (!avctx->internal->hwaccel_priv_data) {
1194  avctx->internal->hwaccel_priv_data =
1195  av_mallocz(hwa->priv_data_size);
1196  if (!avctx->internal->hwaccel_priv_data) {
1197  av_buffer_unref(&frames_ref);
1198  return AVERROR(ENOMEM);
1199  }
1200  }
1201 
1202  ret = hwa->frame_params(avctx, frames_ref);
1203  if (ret >= 0) {
1204  AVHWFramesContext *frames_ctx = (AVHWFramesContext*)frames_ref->data;
1205 
1206  if (frames_ctx->initial_pool_size) {
1207  // If the user has requested that extra output surfaces be
1208  // available then add them here.
1209  if (avctx->extra_hw_frames > 0)
1210  frames_ctx->initial_pool_size += avctx->extra_hw_frames;
1211 
1212  // If frame threading is enabled then an extra surface per thread
1213  // is also required.
1214  if (avctx->active_thread_type & FF_THREAD_FRAME)
1215  frames_ctx->initial_pool_size += avctx->thread_count;
1216  }
1217 
1218  *out_frames_ref = frames_ref;
1219  } else {
1220  av_buffer_unref(&frames_ref);
1221  }
1222  return ret;
1223 }
1224 
1225 static int hwaccel_init(AVCodecContext *avctx,
1226  const FFHWAccel *hwaccel)
1227 {
1228  int err;
1229 
1230  if (hwaccel->p.capabilities & AV_HWACCEL_CODEC_CAP_EXPERIMENTAL &&
1232  av_log(avctx, AV_LOG_WARNING, "Ignoring experimental hwaccel: %s\n",
1233  hwaccel->p.name);
1234  return AVERROR_PATCHWELCOME;
1235  }
1236 
1237  if (!avctx->internal->hwaccel_priv_data && hwaccel->priv_data_size) {
1238  avctx->internal->hwaccel_priv_data =
1239  av_mallocz(hwaccel->priv_data_size);
1240  if (!avctx->internal->hwaccel_priv_data)
1241  return AVERROR(ENOMEM);
1242  }
1243 
1244  avctx->hwaccel = &hwaccel->p;
1245  if (hwaccel->init) {
1246  err = hwaccel->init(avctx);
1247  if (err < 0) {
1248  av_log(avctx, AV_LOG_ERROR, "Failed setup for format %s: "
1249  "hwaccel initialisation returned error.\n",
1250  av_get_pix_fmt_name(hwaccel->p.pix_fmt));
1252  avctx->hwaccel = NULL;
1253  return err;
1254  }
1255  }
1256 
1257  return 0;
1258 }
1259 
1261 {
1262  if (FF_HW_HAS_CB(avctx, uninit))
1263  FF_HW_SIMPLE_CALL(avctx, uninit);
1264 
1266 
1267  avctx->hwaccel = NULL;
1268 
1269  av_buffer_unref(&avctx->hw_frames_ctx);
1270 }
1271 
1272 int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
1273 {
1274  const AVPixFmtDescriptor *desc;
1275  enum AVPixelFormat *choices;
1276  enum AVPixelFormat ret, user_choice;
1277  const AVCodecHWConfigInternal *hw_config;
1278  const AVCodecHWConfig *config;
1279  int i, n, err;
1280 
1281  // Find end of list.
1282  for (n = 0; fmt[n] != AV_PIX_FMT_NONE; n++);
1283  // Must contain at least one entry.
1284  av_assert0(n >= 1);
1285  // If a software format is available, it must be the last entry.
1286  desc = av_pix_fmt_desc_get(fmt[n - 1]);
1287  if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
1288  // No software format is available.
1289  } else {
1290  avctx->sw_pix_fmt = fmt[n - 1];
1291  }
1292 
1293  choices = av_memdup(fmt, (n + 1) * sizeof(*choices));
1294  if (!choices)
1295  return AV_PIX_FMT_NONE;
1296 
1297  for (;;) {
1298  // Remove the previous hwaccel, if there was one.
1299  ff_hwaccel_uninit(avctx);
1300 
1301  user_choice = avctx->get_format(avctx, choices);
1302  if (user_choice == AV_PIX_FMT_NONE) {
1303  // Explicitly chose nothing, give up.
1304  ret = AV_PIX_FMT_NONE;
1305  break;
1306  }
1307 
1308  desc = av_pix_fmt_desc_get(user_choice);
1309  if (!desc) {
1310  av_log(avctx, AV_LOG_ERROR, "Invalid format returned by "
1311  "get_format() callback.\n");
1312  ret = AV_PIX_FMT_NONE;
1313  break;
1314  }
1315  av_log(avctx, AV_LOG_DEBUG, "Format %s chosen by get_format().\n",
1316  desc->name);
1317 
1318  for (i = 0; i < n; i++) {
1319  if (choices[i] == user_choice)
1320  break;
1321  }
1322  if (i == n) {
1323  av_log(avctx, AV_LOG_ERROR, "Invalid return from get_format(): "
1324  "%s not in possible list.\n", desc->name);
1325  ret = AV_PIX_FMT_NONE;
1326  break;
1327  }
1328 
1329  if (ffcodec(avctx->codec)->hw_configs) {
1330  for (i = 0;; i++) {
1331  hw_config = ffcodec(avctx->codec)->hw_configs[i];
1332  if (!hw_config)
1333  break;
1334  if (hw_config->public.pix_fmt == user_choice)
1335  break;
1336  }
1337  } else {
1338  hw_config = NULL;
1339  }
1340 
1341  if (!hw_config) {
1342  // No config available, so no extra setup required.
1343  ret = user_choice;
1344  break;
1345  }
1346  config = &hw_config->public;
1347 
1348  if (config->methods &
1350  avctx->hw_frames_ctx) {
1351  const AVHWFramesContext *frames_ctx =
1353  if (frames_ctx->format != user_choice) {
1354  av_log(avctx, AV_LOG_ERROR, "Invalid setup for format %s: "
1355  "does not match the format of the provided frames "
1356  "context.\n", desc->name);
1357  goto try_again;
1358  }
1359  } else if (config->methods &
1361  avctx->hw_device_ctx) {
1362  const AVHWDeviceContext *device_ctx =
1364  if (device_ctx->type != config->device_type) {
1365  av_log(avctx, AV_LOG_ERROR, "Invalid setup for format %s: "
1366  "does not match the type of the provided device "
1367  "context.\n", desc->name);
1368  goto try_again;
1369  }
1370  } else if (config->methods &
1372  // Internal-only setup, no additional configuration.
1373  } else if (config->methods &
1375  // Some ad-hoc configuration we can't see and can't check.
1376  } else {
1377  av_log(avctx, AV_LOG_ERROR, "Invalid setup for format %s: "
1378  "missing configuration.\n", desc->name);
1379  goto try_again;
1380  }
1381  if (hw_config->hwaccel) {
1382  av_log(avctx, AV_LOG_DEBUG, "Format %s requires hwaccel %s "
1383  "initialisation.\n", desc->name, hw_config->hwaccel->p.name);
1384  err = hwaccel_init(avctx, hw_config->hwaccel);
1385  if (err < 0)
1386  goto try_again;
1387  }
1388  ret = user_choice;
1389  break;
1390 
1391  try_again:
1392  av_log(avctx, AV_LOG_DEBUG, "Format %s not usable, retrying "
1393  "get_format() without it.\n", desc->name);
1394  for (i = 0; i < n; i++) {
1395  if (choices[i] == user_choice)
1396  break;
1397  }
1398  for (; i + 1 < n; i++)
1399  choices[i] = choices[i + 1];
1400  --n;
1401  }
1402 
1403  if (ret < 0)
1404  ff_hwaccel_uninit(avctx);
1405 
1406  av_freep(&choices);
1407  return ret;
1408 }
1409 
1410 static const AVPacketSideData*
1413 {
1414  for (int i = 0; i < nb_sd; i++)
1415  if (sd[i].type == type)
1416  return &sd[i];
1417 
1418  return NULL;
1419 }
1420 
1423 {
1425 }
1426 
1428  const AVPacketSideData *sd_pkt)
1429 {
1430  const AVStereo3D *src;
1431  AVStereo3D *dst;
1432  int ret;
1433 
1434  ret = av_buffer_make_writable(&sd_frame->buf);
1435  if (ret < 0)
1436  return ret;
1437  sd_frame->data = sd_frame->buf->data;
1438 
1439  dst = ( AVStereo3D*)sd_frame->data;
1440  src = (const AVStereo3D*)sd_pkt->data;
1441 
1442  if (dst->type == AV_STEREO3D_UNSPEC)
1443  dst->type = src->type;
1444 
1445  if (dst->view == AV_STEREO3D_VIEW_UNSPEC)
1446  dst->view = src->view;
1447 
1448  if (dst->primary_eye == AV_PRIMARY_EYE_NONE)
1449  dst->primary_eye = src->primary_eye;
1450 
1451  if (!dst->baseline)
1452  dst->baseline = src->baseline;
1453 
1454  if (!dst->horizontal_disparity_adjustment.num)
1455  dst->horizontal_disparity_adjustment = src->horizontal_disparity_adjustment;
1456 
1457  if (!dst->horizontal_field_of_view.num)
1458  dst->horizontal_field_of_view = src->horizontal_field_of_view;
1459 
1460  return 0;
1461 }
1462 
1464  const AVPacketSideData *sd_src, int nb_sd_src,
1465  const SideDataMap *map)
1466 
1467 {
1468  for (int i = 0; map[i].packet < AV_PKT_DATA_NB; i++) {
1469  const enum AVPacketSideDataType type_pkt = map[i].packet;
1470  const enum AVFrameSideDataType type_frame = map[i].frame;
1471  const AVPacketSideData *sd_pkt;
1472  AVFrameSideData *sd_frame;
1473 
1474  sd_pkt = packet_side_data_get(sd_src, nb_sd_src, type_pkt);
1475  if (!sd_pkt)
1476  continue;
1477 
1478  sd_frame = av_frame_get_side_data(dst, type_frame);
1479  if (sd_frame) {
1480  if (type_frame == AV_FRAME_DATA_STEREO3D) {
1481  int ret = side_data_stereo3d_merge(sd_frame, sd_pkt);
1482  if (ret < 0)
1483  return ret;
1484  }
1485 
1486  continue;
1487  }
1488 
1489  sd_frame = av_frame_new_side_data(dst, type_frame, sd_pkt->size);
1490  if (!sd_frame)
1491  return AVERROR(ENOMEM);
1492 
1493  memcpy(sd_frame->data, sd_pkt->data, sd_pkt->size);
1494  }
1495 
1496  return 0;
1497 }
1498 
1500 {
1501  size_t size;
1502  const uint8_t *side_metadata;
1503 
1504  AVDictionary **frame_md = &frame->metadata;
1505 
1506  side_metadata = av_packet_get_side_data(avpkt,
1508  return av_packet_unpack_dictionary(side_metadata, size, frame_md);
1509 }
1510 
1512  AVFrame *frame, const AVPacket *pkt)
1513 {
1514  static const SideDataMap sd[] = {
1521  { AV_PKT_DATA_NB }
1522  };
1523 
1524  int ret = 0;
1525 
1526  frame->pts = pkt->pts;
1527  frame->duration = pkt->duration;
1528 #if FF_API_FRAME_PKT
1530  frame->pkt_pos = pkt->pos;
1531  frame->pkt_size = pkt->size;
1533 #endif
1534 
1536  if (ret < 0)
1537  return ret;
1538 
1540  if (ret < 0)
1541  return ret;
1542 
1544 
1545  if (pkt->flags & AV_PKT_FLAG_DISCARD) {
1546  frame->flags |= AV_FRAME_FLAG_DISCARD;
1547  }
1548 
1549  if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
1550  int ret = av_buffer_replace(&frame->opaque_ref, pkt->opaque_ref);
1551  if (ret < 0)
1552  return ret;
1553  frame->opaque = pkt->opaque;
1554  }
1555 
1556  return 0;
1557 }
1558 
1560 {
1561  int ret;
1562 
1565  if (ret < 0)
1566  return ret;
1567 
1569  const AVPacket *pkt = avctx->internal->last_pkt_props;
1570 
1572  if (ret < 0)
1573  return ret;
1574 #if FF_API_FRAME_PKT
1576  frame->pkt_size = pkt->stream_index;
1578 #endif
1579  }
1580 
1581  ret = fill_frame_props(avctx, frame);
1582  if (ret < 0)
1583  return ret;
1584 
1585  switch (avctx->codec->type) {
1586  case AVMEDIA_TYPE_VIDEO:
1587  if (frame->width && frame->height &&
1588  av_image_check_sar(frame->width, frame->height,
1589  frame->sample_aspect_ratio) < 0) {
1590  av_log(avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
1591  frame->sample_aspect_ratio.num,
1592  frame->sample_aspect_ratio.den);
1593  frame->sample_aspect_ratio = (AVRational){ 0, 1 };
1594  }
1595  break;
1596  }
1597  return 0;
1598 }
1599 
1601 {
1602  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
1603  int i;
1604  int num_planes = av_pix_fmt_count_planes(frame->format);
1606  int flags = desc ? desc->flags : 0;
1607  if (num_planes == 1 && (flags & AV_PIX_FMT_FLAG_PAL))
1608  num_planes = 2;
1609  for (i = 0; i < num_planes; i++) {
1610  av_assert0(frame->data[i]);
1611  }
1612  // For formats without data like hwaccel allow unused pointers to be non-NULL.
1613  for (i = num_planes; num_planes > 0 && i < FF_ARRAY_ELEMS(frame->data); i++) {
1614  if (frame->data[i])
1615  av_log(avctx, AV_LOG_ERROR, "Buffer returned by get_buffer2() did not zero unused plane pointers\n");
1616  frame->data[i] = NULL;
1617  }
1618  }
1619 }
1620 
1621 static void decode_data_free(void *opaque, uint8_t *data)
1622 {
1624 
1625  if (fdd->post_process_opaque_free)
1627 
1628  if (fdd->hwaccel_priv_free)
1629  fdd->hwaccel_priv_free(fdd->hwaccel_priv);
1630 
1631  av_freep(&fdd);
1632 }
1633 
1635 {
1636  AVBufferRef *fdd_buf;
1637  FrameDecodeData *fdd;
1638 
1639  av_assert1(!frame->private_ref);
1640  av_buffer_unref(&frame->private_ref);
1641 
1642  fdd = av_mallocz(sizeof(*fdd));
1643  if (!fdd)
1644  return AVERROR(ENOMEM);
1645 
1646  fdd_buf = av_buffer_create((uint8_t*)fdd, sizeof(*fdd), decode_data_free,
1648  if (!fdd_buf) {
1649  av_freep(&fdd);
1650  return AVERROR(ENOMEM);
1651  }
1652 
1653  frame->private_ref = fdd_buf;
1654 
1655  return 0;
1656 }
1657 
1659 {
1660  AVCodecInternal *avci = avctx->internal;
1661  DecodeContext *dc = decode_ctx(avci);
1662 
1663  dc->lcevc_frame = dc->lcevc && avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
1665 
1666  if (dc->lcevc_frame) {
1667  dc->width = frame->width;
1668  dc->height = frame->height;
1669  frame->width = frame->width * 2 / FFMAX(frame->sample_aspect_ratio.den, 1);
1670  frame->height = frame->height * 2 / FFMAX(frame->sample_aspect_ratio.num, 1);
1671  }
1672 }
1673 
1675 {
1676  AVCodecInternal *avci = avctx->internal;
1677  DecodeContext *dc = decode_ctx(avci);
1678 
1679  if (dc->lcevc_frame) {
1680  FrameDecodeData *fdd = (FrameDecodeData*)frame->private_ref->data;
1681  FFLCEVCFrame *frame_ctx;
1682  int ret;
1683 
1684  frame_ctx = av_mallocz(sizeof(*frame_ctx));
1685  if (!frame_ctx)
1686  return AVERROR(ENOMEM);
1687 
1688  frame_ctx->frame = av_frame_alloc();
1689  if (!frame_ctx->frame) {
1690  av_free(frame_ctx);
1691  return AVERROR(ENOMEM);
1692  }
1693 
1694  frame_ctx->lcevc = ff_refstruct_ref(dc->lcevc);
1695  frame_ctx->frame->width = frame->width;
1696  frame_ctx->frame->height = frame->height;
1697  frame_ctx->frame->format = frame->format;
1698 
1699  frame->width = dc->width;
1700  frame->height = dc->height;
1701 
1702  ret = avctx->get_buffer2(avctx, frame_ctx->frame, 0);
1703  if (ret < 0) {
1704  ff_lcevc_unref(frame_ctx);
1705  return ret;
1706  }
1707 
1708  validate_avframe_allocation(avctx, frame_ctx->frame);
1709 
1710  fdd->post_process_opaque = frame_ctx;
1713  }
1714  dc->lcevc_frame = 0;
1715 
1716  return 0;
1717 }
1718 
1720 {
1721  const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
1722  int override_dimensions = 1;
1723  int ret;
1724 
1726 
1727  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
1728  if ((unsigned)avctx->width > INT_MAX - STRIDE_ALIGN ||
1729  (ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) {
1730  av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
1731  ret = AVERROR(EINVAL);
1732  goto fail;
1733  }
1734 
1735  if (frame->width <= 0 || frame->height <= 0) {
1736  frame->width = FFMAX(avctx->width, AV_CEIL_RSHIFT(avctx->coded_width, avctx->lowres));
1737  frame->height = FFMAX(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres));
1738  override_dimensions = 0;
1739  }
1740 
1741  if (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3]) {
1742  av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n");
1743  ret = AVERROR(EINVAL);
1744  goto fail;
1745  }
1746  } else if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
1747  if (frame->nb_samples * (int64_t)avctx->ch_layout.nb_channels > avctx->max_samples) {
1748  av_log(avctx, AV_LOG_ERROR, "samples per frame %d, exceeds max_samples %"PRId64"\n", frame->nb_samples, avctx->max_samples);
1749  ret = AVERROR(EINVAL);
1750  goto fail;
1751  }
1752  }
1753  ret = ff_decode_frame_props(avctx, frame);
1754  if (ret < 0)
1755  goto fail;
1756 
1757  if (hwaccel) {
1758  if (hwaccel->alloc_frame) {
1759  ret = hwaccel->alloc_frame(avctx, frame);
1760  goto end;
1761  }
1762  } else {
1763  avctx->sw_pix_fmt = avctx->pix_fmt;
1764  update_frame_props(avctx, frame);
1765  }
1766 
1767  ret = avctx->get_buffer2(avctx, frame, flags);
1768  if (ret < 0)
1769  goto fail;
1770 
1772 
1774  if (ret < 0)
1775  goto fail;
1776 
1778  if (ret < 0)
1779  goto fail;
1780 
1781 end:
1782  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions &&
1784  frame->width = avctx->width;
1785  frame->height = avctx->height;
1786  }
1787 
1788 fail:
1789  if (ret < 0) {
1790  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1792  }
1793 
1794  return ret;
1795 }
1796 
1798 {
1799  AVFrame *tmp;
1800  int ret;
1801 
1803 
1804  // make sure the discard flag does not persist
1805  frame->flags &= ~AV_FRAME_FLAG_DISCARD;
1806 
1807  if (frame->data[0] && (frame->width != avctx->width || frame->height != avctx->height || frame->format != avctx->pix_fmt)) {
1808  av_log(avctx, AV_LOG_WARNING, "Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
1809  frame->width, frame->height, av_get_pix_fmt_name(frame->format), avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt));
1811  }
1812 
1813  if (!frame->data[0])
1814  return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
1815 
1816  av_frame_side_data_free(&frame->side_data, &frame->nb_side_data);
1817 
1819  return ff_decode_frame_props(avctx, frame);
1820 
1821  tmp = av_frame_alloc();
1822  if (!tmp)
1823  return AVERROR(ENOMEM);
1824 
1826 
1828  if (ret < 0) {
1829  av_frame_free(&tmp);
1830  return ret;
1831  }
1832 
1834  av_frame_free(&tmp);
1835 
1836  return 0;
1837 }
1838 
1840 {
1841  int ret = reget_buffer_internal(avctx, frame, flags);
1842  if (ret < 0)
1843  av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
1844  return ret;
1845 }
1846 
1847 typedef struct ProgressInternal {
1849  struct AVFrame *f;
1851 
1853 {
1854  av_assert1(!!f->f == !!f->progress);
1855  av_assert1(!f->progress || f->progress->f == f->f);
1856 }
1857 
1859 {
1861 
1862  av_assert1(!f->f && !f->progress);
1863 
1864  f->progress = ff_refstruct_pool_get(pool);
1865  if (!f->progress)
1866  return AVERROR(ENOMEM);
1867 
1868  f->f = f->progress->f;
1869  return 0;
1870 }
1871 
1873 {
1874  int ret;
1875 
1877  if (!f->f) {
1878  ret = ff_progress_frame_alloc(avctx, f);
1879  if (ret < 0)
1880  return ret;
1881  }
1882 
1883  ret = ff_thread_get_buffer(avctx, f->progress->f, flags);
1884  if (ret < 0) {
1885  f->f = NULL;
1886  ff_refstruct_unref(&f->progress);
1887  return ret;
1888  }
1889  return 0;
1890 }
1891 
1893 {
1894  av_assert1(src->progress && src->f && src->f == src->progress->f);
1895  av_assert1(!dst->f && !dst->progress);
1896  dst->f = src->f;
1897  dst->progress = ff_refstruct_ref(src->progress);
1898 }
1899 
1901 {
1903  f->f = NULL;
1904  ff_refstruct_unref(&f->progress);
1905 }
1906 
1908 {
1909  if (dst == src)
1910  return;
1913  if (src->f)
1915 }
1916 
1918 {
1919  ff_thread_progress_report(&f->progress->progress, n);
1920 }
1921 
1923 {
1924  ff_thread_progress_await(&f->progress->progress, n);
1925 }
1926 
1927 #if !HAVE_THREADS
1929 {
1931 }
1932 #endif /* !HAVE_THREADS */
1933 
1935 {
1936  const AVCodecContext *avctx = opaque.nc;
1937  ProgressInternal *progress = obj;
1938  int ret;
1939 
1941  if (ret < 0)
1942  return ret;
1943 
1944  progress->f = av_frame_alloc();
1945  if (!progress->f)
1946  return AVERROR(ENOMEM);
1947 
1948  return 0;
1949 }
1950 
1951 static void progress_frame_pool_reset_cb(FFRefStructOpaque unused, void *obj)
1952 {
1953  ProgressInternal *progress = obj;
1954 
1955  ff_thread_progress_reset(&progress->progress);
1956  av_frame_unref(progress->f);
1957 }
1958 
1960 {
1961  ProgressInternal *progress = obj;
1962 
1964  av_frame_free(&progress->f);
1965 }
1966 
1968 {
1969  AVCodecInternal *avci = avctx->internal;
1970  DecodeContext *dc = decode_ctx(avci);
1971  int ret = 0;
1972 
1973  dc->initial_pict_type = AV_PICTURE_TYPE_NONE;
1975  dc->intra_only_flag = AV_FRAME_FLAG_KEY;
1976  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO)
1977  dc->initial_pict_type = AV_PICTURE_TYPE_I;
1978  }
1979 
1980  /* if the decoder init function was already called previously,
1981  * free the already allocated subtitle_header before overwriting it */
1982  av_freep(&avctx->subtitle_header);
1983 
1984  if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
1985  av_log(avctx, AV_LOG_WARNING, "The maximum value for lowres supported by the decoder is %d\n",
1986  avctx->codec->max_lowres);
1987  avctx->lowres = avctx->codec->max_lowres;
1988  }
1989  if (avctx->sub_charenc) {
1990  if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) {
1991  av_log(avctx, AV_LOG_ERROR, "Character encoding is only "
1992  "supported with subtitles codecs\n");
1993  return AVERROR(EINVAL);
1994  } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) {
1995  av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, "
1996  "subtitles character encoding will be ignored\n",
1997  avctx->codec_descriptor->name);
1999  } else {
2000  /* input character encoding is set for a text based subtitle
2001  * codec at this point */
2004 
2006 #if CONFIG_ICONV
2007  iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc);
2008  if (cd == (iconv_t)-1) {
2009  ret = AVERROR(errno);
2010  av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context "
2011  "with input character encoding \"%s\"\n", avctx->sub_charenc);
2012  return ret;
2013  }
2014  iconv_close(cd);
2015 #else
2016  av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles "
2017  "conversion needs a libavcodec built with iconv support "
2018  "for this codec\n");
2019  return AVERROR(ENOSYS);
2020 #endif
2021  }
2022  }
2023  }
2024 
2025  dc->pts_correction_num_faulty_pts =
2026  dc->pts_correction_num_faulty_dts = 0;
2027  dc->pts_correction_last_pts =
2028  dc->pts_correction_last_dts = INT64_MIN;
2029 
2030  if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY
2032  av_log(avctx, AV_LOG_WARNING,
2033  "gray decoding requested but not enabled at configuration time\n");
2034  if (avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS) {
2036  }
2037 
2038  if (avctx->nb_side_data_prefer_packet == 1 &&
2039  avctx->side_data_prefer_packet[0] == -1)
2040  dc->side_data_pref_mask = ~0ULL;
2041  else {
2042  for (unsigned i = 0; i < avctx->nb_side_data_prefer_packet; i++) {
2043  int val = avctx->side_data_prefer_packet[i];
2044 
2045  if (val < 0 || val >= AV_PKT_DATA_NB) {
2046  av_log(avctx, AV_LOG_ERROR, "Invalid side data type: %d\n", val);
2047  return AVERROR(EINVAL);
2048  }
2049 
2050  for (unsigned j = 0; ff_sd_global_map[j].packet < AV_PKT_DATA_NB; j++) {
2051  if (ff_sd_global_map[j].packet == val) {
2052  val = ff_sd_global_map[j].frame;
2053 
2054  // this code will need to be changed when we have more than
2055  // 64 frame side data types
2056  if (val >= 64) {
2057  av_log(avctx, AV_LOG_ERROR, "Side data type too big\n");
2058  return AVERROR_BUG;
2059  }
2060 
2061  dc->side_data_pref_mask |= 1ULL << val;
2062  }
2063  }
2064  }
2065  }
2066 
2067  avci->in_pkt = av_packet_alloc();
2068  avci->last_pkt_props = av_packet_alloc();
2069  if (!avci->in_pkt || !avci->last_pkt_props)
2070  return AVERROR(ENOMEM);
2071 
2073  avci->progress_frame_pool =
2079  if (!avci->progress_frame_pool)
2080  return AVERROR(ENOMEM);
2081  }
2082  ret = decode_bsfs_init(avctx);
2083  if (ret < 0)
2084  return ret;
2085 
2087  ret = ff_lcevc_alloc(&dc->lcevc);
2088  if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
2089  return ret;
2090  }
2091 
2092 #if FF_API_DROPCHANGED
2093  if (avctx->flags & AV_CODEC_FLAG_DROPCHANGED)
2094  av_log(avctx, AV_LOG_WARNING, "The dropchanged flag is deprecated.\n");
2095 #endif
2096 
2097  return 0;
2098 }
2099 
2100 /**
2101  * Check side data preference and clear existing side data from frame
2102  * if needed.
2103  *
2104  * @retval 0 side data of this type can be added to frame
2105  * @retval 1 side data of this type should not be added to frame
2106  */
2107 static int side_data_pref(const AVCodecContext *avctx, AVFrameSideData ***sd,
2108  int *nb_sd, enum AVFrameSideDataType type)
2109 {
2110  DecodeContext *dc = decode_ctx(avctx->internal);
2111 
2112  // Note: could be skipped for `type` without corresponding packet sd
2113  if (av_frame_side_data_get(*sd, *nb_sd, type)) {
2114  if (dc->side_data_pref_mask & (1ULL << type))
2115  return 1;
2116  av_frame_side_data_remove(sd, nb_sd, type);
2117  }
2118 
2119  return 0;
2120 }
2121 
2122 
2124  enum AVFrameSideDataType type, size_t size,
2125  AVFrameSideData **psd)
2126 {
2127  AVFrameSideData *sd;
2128 
2129  if (side_data_pref(avctx, &frame->side_data, &frame->nb_side_data, type)) {
2130  if (psd)
2131  *psd = NULL;
2132  return 0;
2133  }
2134 
2136  if (psd)
2137  *psd = sd;
2138 
2139  return sd ? 0 : AVERROR(ENOMEM);
2140 }
2141 
2143  AVFrameSideData ***sd, int *nb_sd,
2145  AVBufferRef **buf)
2146 {
2147  int ret = 0;
2148 
2149  if (side_data_pref(avctx, sd, nb_sd, type))
2150  goto finish;
2151 
2152  if (!av_frame_side_data_add(sd, nb_sd, type, buf, 0))
2153  ret = AVERROR(ENOMEM);
2154 
2155 finish:
2157 
2158  return ret;
2159 }
2160 
2163  AVBufferRef **buf)
2164 {
2166  &frame->side_data, &frame->nb_side_data,
2167  type, buf);
2168 }
2169 
2171  AVFrameSideData ***sd, int *nb_sd,
2172  struct AVMasteringDisplayMetadata **mdm)
2173 {
2174  AVBufferRef *buf;
2175  size_t size;
2176 
2178  *mdm = NULL;
2179  return 0;
2180  }
2181 
2183  if (!*mdm)
2184  return AVERROR(ENOMEM);
2185 
2186  buf = av_buffer_create((uint8_t *)*mdm, size, NULL, NULL, 0);
2187  if (!buf) {
2188  av_freep(mdm);
2189  return AVERROR(ENOMEM);
2190  }
2191 
2193  &buf, 0)) {
2194  *mdm = NULL;
2195  av_buffer_unref(&buf);
2196  return AVERROR(ENOMEM);
2197  }
2198 
2199  return 0;
2200 }
2201 
2204 {
2205  if (side_data_pref(avctx, &frame->side_data, &frame->nb_side_data,
2207  *mdm = NULL;
2208  return 0;
2209  }
2210 
2212  return *mdm ? 0 : AVERROR(ENOMEM);
2213 }
2214 
2216  AVFrameSideData ***sd, int *nb_sd,
2217  AVContentLightMetadata **clm)
2218 {
2219  AVBufferRef *buf;
2220  size_t size;
2221 
2222  if (side_data_pref(avctx, sd, nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL)) {
2223  *clm = NULL;
2224  return 0;
2225  }
2226 
2228  if (!*clm)
2229  return AVERROR(ENOMEM);
2230 
2231  buf = av_buffer_create((uint8_t *)*clm, size, NULL, NULL, 0);
2232  if (!buf) {
2233  av_freep(clm);
2234  return AVERROR(ENOMEM);
2235  }
2236 
2238  &buf, 0)) {
2239  *clm = NULL;
2240  av_buffer_unref(&buf);
2241  return AVERROR(ENOMEM);
2242  }
2243 
2244  return 0;
2245 }
2246 
2248  AVContentLightMetadata **clm)
2249 {
2250  if (side_data_pref(avctx, &frame->side_data, &frame->nb_side_data,
2252  *clm = NULL;
2253  return 0;
2254  }
2255 
2257  return *clm ? 0 : AVERROR(ENOMEM);
2258 }
2259 
2260 int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
2261 {
2262  size_t size;
2263  const void *pal = av_packet_get_side_data(src, AV_PKT_DATA_PALETTE, &size);
2264 
2265  if (pal && size == AVPALETTE_SIZE) {
2266  memcpy(dst, pal, AVPALETTE_SIZE);
2267  return 1;
2268  } else if (pal) {
2269  av_log(logctx, AV_LOG_ERROR,
2270  "Palette size %"SIZE_SPECIFIER" is wrong\n", size);
2271  }
2272  return 0;
2273 }
2274 
2275 int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
2276 {
2277  const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
2278 
2279  if (!hwaccel || !hwaccel->frame_priv_data_size)
2280  return 0;
2281 
2282  av_assert0(!*hwaccel_picture_private);
2283 
2284  if (hwaccel->free_frame_priv) {
2285  AVHWFramesContext *frames_ctx;
2286 
2287  if (!avctx->hw_frames_ctx)
2288  return AVERROR(EINVAL);
2289 
2290  frames_ctx = (AVHWFramesContext *) avctx->hw_frames_ctx->data;
2291  *hwaccel_picture_private = ff_refstruct_alloc_ext(hwaccel->frame_priv_data_size, 0,
2292  frames_ctx->device_ctx,
2293  hwaccel->free_frame_priv);
2294  } else {
2295  *hwaccel_picture_private = ff_refstruct_allocz(hwaccel->frame_priv_data_size);
2296  }
2297 
2298  if (!*hwaccel_picture_private)
2299  return AVERROR(ENOMEM);
2300 
2301  return 0;
2302 }
2303 
2305 {
2306  AVCodecInternal *avci = avctx->internal;
2307  DecodeContext *dc = decode_ctx(avci);
2308 
2310  av_packet_unref(avci->in_pkt);
2311 
2312  dc->pts_correction_last_pts =
2313  dc->pts_correction_last_dts = INT64_MIN;
2314 
2315  if (avci->bsf)
2316  av_bsf_flush(avci->bsf);
2317 
2318  dc->nb_draining_errors = 0;
2319  dc->draining_started = 0;
2320 }
2321 
2323 {
2324  return av_mallocz(sizeof(DecodeContext));
2325 }
2326 
2328 {
2329  const DecodeContext *src_dc = decode_ctx(src->internal);
2330  DecodeContext *dst_dc = decode_ctx(dst->internal);
2331 
2332  ff_refstruct_replace(&dst_dc->lcevc, src_dc->lcevc);
2333 }
2334 
2336 {
2337  AVCodecInternal *avci = avctx->internal;
2338  DecodeContext *dc = decode_ctx(avci);
2339 
2340  ff_refstruct_unref(&dc->lcevc);
2341 }
lcevcdec.h
ff_get_coded_side_data
const AVPacketSideData * ff_get_coded_side_data(const AVCodecContext *avctx, enum AVPacketSideDataType type)
Get side data of the given type from a decoding context.
Definition: decode.c:1421
DecodeContext::intra_only_flag
int intra_only_flag
This is set to AV_FRAME_FLAG_KEY for decoders of intra-only formats (those whose codec descriptor has...
Definition: decode.c:67
AVSubtitle
Definition: avcodec.h:2238
AVCodecInternal::initial_sample_rate
int initial_sample_rate
Definition: internal.h:153
hwconfig.h
ff_progress_frame_report
void ff_progress_frame_report(ProgressFrame *f, int n)
Notify later decoding threads when part of their reference frame is ready.
Definition: decode.c:1917
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
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: packet.c:429
AVCodecContext::hwaccel
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:1437
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
FFCodec::receive_frame
int(* receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame)
Decode API with decoupled packet/frame dataflow.
Definition: codec_internal.h:208
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
AVBSFContext::par_in
AVCodecParameters * par_in
Parameters of the input stream.
Definition: bsf.h:90
hwaccel_init
static int hwaccel_init(AVCodecContext *avctx, const FFHWAccel *hwaccel)
Definition: decode.c:1225
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
ff_decode_get_packet
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
Definition: decode.c:247
hw_pix_fmt
static enum AVPixelFormat hw_pix_fmt
Definition: hw_decode.c:46
progress_frame_pool_reset_cb
static void progress_frame_pool_reset_cb(FFRefStructOpaque unused, void *obj)
Definition: decode.c:1951
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
Frame::width
int width
Definition: ffplay.c:159
AV_EF_EXPLODE
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition: defs.h:51
ff_thread_progress_report
void ff_thread_progress_report(ThreadProgress *pro, int n)
This function is a no-op in no-op mode; otherwise it notifies other threads that a certain level of p...
Definition: threadprogress.c:53
ff_refstruct_ref
void * ff_refstruct_ref(void *obj)
Create a new reference to an object managed via this API, i.e.
Definition: refstruct.c:140
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
AVSubtitle::rects
AVSubtitleRect ** rects
Definition: avcodec.h:2243
threadprogress.h
AVCodecContext::get_format
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
Callback to negotiate the pixel format.
Definition: avcodec.h:793
ff_icc_profile_read_primaries
int ff_icc_profile_read_primaries(FFIccContext *s, cmsHPROFILE profile, AVColorPrimariesDesc *out_primaries)
Read the color primaries and white point coefficients encoded by an ICC profile, and return the raw v...
Definition: fflcms2.c:255
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:422
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:691
AVColorTransferCharacteristic
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:580
attach_post_process_data
static int attach_post_process_data(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:1674
ff_get_format
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
Definition: decode.c:1272
apply_cropping
static int apply_cropping(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:760
ThreadProgress
ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can ...
Definition: threadprogress.h:43
AVCodecContext::sample_rate
int sample_rate
samples per second
Definition: avcodec.h:1056
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:951
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:799
AVColorPrimariesDesc
Struct that contains both white point location and primaries location, providing the complete descrip...
Definition: csp.h:78
DecodeContext::initial_pict_type
enum AVPictureType initial_pict_type
This is set to AV_PICTURE_TYPE_I for intra only video decoders and to AV_PICTURE_TYPE_NONE for other ...
Definition: decode.c:74
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
ff_lcevc_alloc
int ff_lcevc_alloc(FFLCEVCContext **plcevc)
Definition: lcevcdec.c:310
AV_HWACCEL_CODEC_CAP_EXPERIMENTAL
#define AV_HWACCEL_CODEC_CAP_EXPERIMENTAL
HWAccel is experimental and is thus avoided in favor of non experimental codecs.
Definition: avcodec.h:2139
AV_FRAME_DATA_A53_CC
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: frame.h:59
AV_PKT_FLAG_DISCARD
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
Definition: packet.h:601
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:197
AVPictureType
AVPictureType
Definition: avutil.h:277
AVCodecInternal::skip_samples
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
Definition: internal.h:125
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1430
AV_CODEC_FLAG_UNALIGNED
#define AV_CODEC_FLAG_UNALIGNED
Allow decoders to produce frames with data planes that are not aligned to CPU requirements (e....
Definition: avcodec.h:220
AVCodecContext::codec_descriptor
const struct AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
Definition: avcodec.h:1872
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
AVCodecDescriptor::name
const char * name
Name of the codec described by this descriptor.
Definition: codec_desc.h:46
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:1926
ff_refstruct_alloc_ext
static void * ff_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(FFRefStructOpaque opaque, void *obj))
A wrapper around ff_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition: refstruct.h:94
int64_t
long long int64_t
Definition: coverity.c:34
AVSubtitle::num_rects
unsigned num_rects
Definition: avcodec.h:2242
av_unused
#define av_unused
Definition: attributes.h:131
decode_simple_receive_frame
static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:604
AV_FRAME_DATA_S12M_TIMECODE
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
Definition: frame.h:152
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
AVFrame::opaque
void * opaque
Frame owner's private data.
Definition: frame.h:537
FrameDecodeData
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
Definition: decode.h:33
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:322
DecodeContext::pts_correction_last_pts
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
Definition: decode.c:86
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
AVFrameSideData::buf
AVBufferRef * buf
Definition: frame.h:270
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:684
AVPacketSideData
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition: packet.h:390
AVCodec::capabilities
int capabilities
Codec capabilities.
Definition: codec.h:206
FFHWAccel::frame_params
int(* frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Fill the given hw_frames context with current codec parameters.
Definition: hwaccel_internal.h:144
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:248
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:539
FFLCEVCContext
Definition: lcevcdec.h:32
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:583
ff_progress_frame_get_buffer
int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int flags)
This function sets up the ProgressFrame, i.e.
Definition: decode.c:1872
data
const char data[16]
Definition: mxf.c:148
AV_PKT_DATA_S12M_TIMECODE
@ AV_PKT_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1:2014.
Definition: packet.h:288
FFCodec
Definition: codec_internal.h:127
AVCodecContext::subtitle_header
uint8_t * subtitle_header
Definition: avcodec.h:1902
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
@ AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
Definition: packet.h:616
FrameDecodeData::hwaccel_priv_free
void(* hwaccel_priv_free)(void *priv)
Definition: decode.h:52
FF_HW_SIMPLE_CALL
#define FF_HW_SIMPLE_CALL(avctx, function)
Definition: hwaccel_internal.h:174
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:557
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: defs.h:62
FF_SUB_CHARENC_MODE_PRE_DECODER
#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:1890
AVDictionary
Definition: dict.c:34
FFRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVColorPrimaries
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:555
avcodec_default_get_format
enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Definition: decode.c:1053
avcodec_is_open
int avcodec_is_open(AVCodecContext *s)
Definition: avcodec.c:708
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:321
ff_thread_receive_frame
#define ff_thread_receive_frame(avctx, frame)
Definition: decode.c:219
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:602
AV_RL8
#define AV_RL8(x)
Definition: intreadwrite.h:394
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:94
decode_ctx
static DecodeContext * decode_ctx(AVCodecInternal *avci)
Definition: decode.c:101
av_bsf_free
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:52
FF_SUB_CHARENC_MODE_AUTOMATIC
#define FF_SUB_CHARENC_MODE_AUTOMATIC
libavcodec will select the mode itself
Definition: avcodec.h:1889
AV_STEREO3D_VIEW_UNSPEC
@ AV_STEREO3D_VIEW_UNSPEC
Content is unspecified.
Definition: stereo3d.h:168
tf_sess_config.config
config
Definition: tf_sess_config.py:33
thread.h
AV_STEREO3D_UNSPEC
@ AV_STEREO3D_UNSPEC
Video is stereoscopic but the packing is unspecified.
Definition: stereo3d.h:143
av_frame_apply_cropping
int av_frame_apply_cropping(AVFrame *frame, int flags)
Crop the given video AVFrame according to its crop_left/crop_top/crop_right/ crop_bottom fields.
Definition: frame.c:1066
AV_CODEC_HW_CONFIG_METHOD_INTERNAL
@ AV_CODEC_HW_CONFIG_METHOD_INTERNAL
The codec supports this format by some internal method.
Definition: codec.h:333
DecodeContext::pts_correction_num_faulty_dts
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
Definition: decode.c:85
ff_hwaccel_uninit
void ff_hwaccel_uninit(AVCodecContext *avctx)
Definition: decode.c:1260
AV_FRAME_FLAG_TOP_FIELD_FIRST
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
Definition: frame.h:653
av_memdup
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition: mem.c:304
AVContentLightMetadata
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
Definition: mastering_display_metadata.h:107
decode_get_packet
static int decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: decode.c:222
AVCodec::max_lowres
uint8_t max_lowres
maximum value for lowres supported by the decoder
Definition: codec.h:207
AVPacketSideData::size
size_t size
Definition: packet.h:392
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3005
AVCodecInternal::progress_frame_pool
struct FFRefStructPool * progress_frame_pool
Definition: internal.h:71
DecodeContext::nb_draining_errors
int nb_draining_errors
Definition: decode.c:77
AV_CODEC_FLAG_COPY_OPAQUE
#define AV_CODEC_FLAG_COPY_OPAQUE
Definition: avcodec.h:299
finish
static void finish(void)
Definition: movenc.c:374
FFHWAccel
Definition: hwaccel_internal.h:34
bsf.h
guess_correct_pts
static int64_t guess_correct_pts(DecodeContext *dc, int64_t reordered_pts, int64_t dts)
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect time...
Definition: decode.c:289
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:460
AV_PKT_DATA_PALETTE
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
Definition: packet.h:47
AVPacket::opaque_ref
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: packet.h:575
STRIDE_ALIGN
#define STRIDE_ALIGN
Definition: internal.h:46
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1071
fail
#define fail()
Definition: checkasm.h:188
ff_icc_context_init
int ff_icc_context_init(FFIccContext *s, void *avctx)
Initializes an FFIccContext.
Definition: fflcms2.c:30
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1593
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
ff_lcevc_process
int ff_lcevc_process(void *logctx, AVFrame *frame)
Definition: lcevcdec.c:279
FF_SUB_CHARENC_MODE_DO_NOTHING
#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:1888
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:508
val
static double val(void *priv, double ch)
Definition: aeval.c:77
FrameDecodeData::post_process_opaque_free
void(* post_process_opaque_free)(void *opaque)
Definition: decode.h:46
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
ff_decode_frame_props_from_pkt
int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt)
Set various frame properties from the provided packet.
Definition: decode.c:1511
AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
The codec supports this format via the hw_frames_ctx interface.
Definition: codec.h:326
pts
static int64_t pts
Definition: transcode_aac.c:644
add_metadata_from_side_data
static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
Definition: decode.c:1499
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:639
AVCodecContext::max_samples
int64_t max_samples
The number of samples per frame to maximally accept.
Definition: avcodec.h:1988
AVRational::num
int num
Numerator.
Definition: rational.h:59
progressframe.h
AVFrameSideDataType
AVFrameSideDataType
Definition: frame.h:49
refstruct.h
AVSubtitleRect::ass
char * ass
0 terminated ASS/SSA compatible event line.
Definition: avcodec.h:2235
av_image_check_size2
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
Definition: imgutils.c:289
ff_frame_new_side_data_from_buf
int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf)
Similar to ff_frame_new_side_data, but using an existing buffer ref.
Definition: decode.c:2161
AV_CODEC_HW_CONFIG_METHOD_AD_HOC
@ AV_CODEC_HW_CONFIG_METHOD_AD_HOC
The codec supports this format by some ad-hoc method.
Definition: codec.h:342
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:406
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:60
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:150
AVCodecContext::get_buffer2
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
This callback is called at the beginning of each frame to get data buffer(s) for it.
Definition: avcodec.h:1232
FF_REFSTRUCT_POOL_FLAG_FREE_ON_INIT_ERROR
#define FF_REFSTRUCT_POOL_FLAG_FREE_ON_INIT_ERROR
If this flag is set and both init_cb and free_entry_cb callbacks are provided, then free_cb will be c...
Definition: refstruct.h:213
GET_UTF8
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
Definition: common.h:488
avcodec_decode_subtitle2
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Decode a subtitle message.
Definition: decode.c:982
ff_decode_content_light_new_ext
int ff_decode_content_light_new_ext(const AVCodecContext *avctx, AVFrameSideData ***sd, int *nb_sd, AVContentLightMetadata **clm)
Same as ff_decode_content_light_new, but taking a AVFrameSideData array directly instead of an AVFram...
Definition: decode.c:2215
AV_CODEC_FLAG_DROPCHANGED
#define AV_CODEC_FLAG_DROPCHANGED
Don't output frames whose parameters differ from first decoded frame in stream.
Definition: avcodec.h:244
avassert.h
FF_CODEC_CAP_USES_PROGRESSFRAMES
#define FF_CODEC_CAP_USES_PROGRESSFRAMES
The decoder might make use of the ProgressFrame API.
Definition: codec_internal.h:69
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:677
AV_PKT_DATA_PARAM_CHANGE
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: packet.h:69
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
AVFrameSideData::size
size_t size
Definition: frame.h:268
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
ff_decode_receive_frame
int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
avcodec_receive_frame() implementation for decoders.
Definition: decode.c:814
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:640
emms_c
#define emms_c()
Definition: emms.h:63
AVCodecContext::has_b_frames
int has_b_frames
Size of the frame reordering buffer in the decoder.
Definition: avcodec.h:729
ff_progress_frame_ref
void ff_progress_frame_ref(ProgressFrame *dst, const ProgressFrame *src)
Set dst->f to src->f and make dst a co-owner of src->f.
Definition: decode.c:1892
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
@ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
Definition: packet.h:617
AVCodecContext::side_data_prefer_packet
int * side_data_prefer_packet
Decoding only.
Definition: avcodec.h:2071
stereo3d.h
ff_hwaccel_frame_priv_alloc
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
Definition: decode.c:2275
get_subtitle_defaults
static void get_subtitle_defaults(AVSubtitle *sub)
Definition: decode.c:895
FrameDecodeData::post_process_opaque
void * post_process_opaque
Definition: decode.h:45
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: packet.c:98
validate_avframe_allocation
static void validate_avframe_allocation(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:1600
AVCodecInternal::buffer_pkt
AVPacket * buffer_pkt
Temporary buffers for newly received or not yet output packets/frames.
Definition: internal.h:144
av_bsf_flush
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
Definition: bsf.c:190
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
FFHWAccel::priv_data_size
int priv_data_size
Size of the private data to allocate in AVCodecInternal.hwaccel_priv_data.
Definition: hwaccel_internal.h:112
AV_BUFFER_FLAG_READONLY
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
Definition: buffer.h:114
AV_GET_BUFFER_FLAG_REF
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:431
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ff_thread_get_buffer
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
Definition: pthread_frame.c:1049
AVERROR_INPUT_CHANGED
#define AVERROR_INPUT_CHANGED
Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
Definition: error.h:75
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
AVCodecDescriptor::type
enum AVMediaType type
Definition: codec_desc.h:40
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AVPacketSideData::data
uint8_t * data
Definition: packet.h:391
ff_progress_frame_unref
void ff_progress_frame_unref(ProgressFrame *f)
Give up a reference to the underlying frame contained in a ProgressFrame and reset the ProgressFrame,...
Definition: decode.c:1900
decode.h
AVBSFContext::time_base_in
AVRational time_base_in
The timebase used for the timestamps of the input packets.
Definition: bsf.h:102
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVCodecHWConfig::pix_fmt
enum AVPixelFormat pix_fmt
For decoders, a hardware pixel format which that decoder may be able to decode to if suitable hardwar...
Definition: codec.h:354
AVSubtitle::pts
int64_t pts
Same as packet pts, in AV_TIME_BASE.
Definition: avcodec.h:2244
av_csp_primaries_id_from_desc
enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm)
Detects which enum AVColorPrimaries constant corresponds to the given complete gamut description.
Definition: csp.c:110
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:1945
AV_PKT_DATA_LCEVC
@ AV_PKT_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
Definition: packet.h:346
av_hwdevice_get_type_name
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
Definition: hwcontext.c:112
FFRefStructPool
FFRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
Definition: refstruct.c:183
AVPacket::opaque
void * opaque
for some private data of the user
Definition: packet.h:564
ProgressInternal
Definition: decode.c:1847
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:558
AVCodecHWConfigInternal::hwaccel
const struct FFHWAccel * hwaccel
If this configuration uses a hwaccel, a pointer to it.
Definition: hwconfig.h:35
check_progress_consistency
static void check_progress_consistency(const ProgressFrame *f)
Definition: decode.c:1852
av_content_light_metadata_alloc
AVContentLightMetadata * av_content_light_metadata_alloc(size_t *size)
Allocate an AVContentLightMetadata structure and set its fields to default values.
Definition: mastering_display_metadata.c:72
FFCodec::decode
int(* decode)(struct AVCodecContext *avctx, struct AVFrame *frame, int *got_frame_ptr, struct AVPacket *avpkt)
Decode to an AVFrame.
Definition: codec_internal.h:191
discard_samples
static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples)
Definition: decode.c:315
decode_data_free
static void decode_data_free(void *opaque, uint8_t *data)
Definition: decode.c:1621
ff_decode_get_hw_frames_ctx
int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx, enum AVHWDeviceType dev_type)
Make sure avctx.hw_frames_ctx is set.
Definition: decode.c:1116
ff_decode_mastering_display_new
int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, AVMasteringDisplayMetadata **mdm)
Wrapper around av_mastering_display_metadata_create_side_data(), which rejects side data overridden b...
Definition: decode.c:2202
DecodeContext::draining_started
int draining_started
The caller has submitted a NULL packet on input.
Definition: decode.c:82
ff_thread_get_packet
#define ff_thread_get_packet(avctx, pkt)
Definition: decode.c:218
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
AVCodecInternal::changed_frames_dropped
int changed_frames_dropped
Definition: internal.h:150
AVCodecContext::sub_charenc
char * sub_charenc
Character encoding of the input subtitles file.
Definition: avcodec.h:1879
ff_decode_internal_alloc
AVCodecInternal * ff_decode_internal_alloc(void)
Definition: decode.c:2322
AV_CODEC_FLAG2_SKIP_MANUAL
#define AV_CODEC_FLAG2_SKIP_MANUAL
Do not skip samples and export skip information as frame side data.
Definition: avcodec.h:388
AV_CODEC_PROP_INTRA_ONLY
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
Definition: codec_desc.h:72
ff_thread_progress_await
void ff_thread_progress_await(const ThreadProgress *pro_c, int n)
This function is a no-op in no-op mode; otherwise it waits until other threads have reached a certain...
Definition: threadprogress.c:65
av_bsf_init
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:149
utf8_check
static int utf8_check(const uint8_t *str)
Definition: decode.c:963
update_frame_props
static void update_frame_props(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:1658
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
ff_decode_flush_buffers
void ff_decode_flush_buffers(AVCodecContext *avctx)
Definition: decode.c:2304
AVCodecContext::apply_cropping
int apply_cropping
Video decoding only.
Definition: avcodec.h:1972
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:701
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
hwaccel_internal.h
av_bsf_receive_packet
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:230
AVCodec::type
enum AVMediaType type
Definition: codec.h:200
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCodecContext::nb_coded_side_data
int nb_coded_side_data
Definition: avcodec.h:1927
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:486
av_frame_side_data_remove
void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type from an array.
Definition: frame.c:945
FF_CODEC_CB_TYPE_DECODE_SUB
@ FF_CODEC_CB_TYPE_DECODE_SUB
Definition: codec_internal.h:112
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
ff_lcevc_unref
void ff_lcevc_unref(void *opaque)
Definition: lcevcdec.c:322
AV_CODEC_PROP_BITMAP_SUB
#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:103
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_refstruct_allocz
static void * ff_refstruct_allocz(size_t size)
Equivalent to ff_refstruct_alloc_ext(size, 0, NULL, NULL)
Definition: refstruct.h:105
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
AVCodecInternal::initial_height
int initial_height
Definition: internal.h:152
DecodeContext::pts_correction_last_dts
int64_t pts_correction_last_dts
PTS of the last frame.
Definition: decode.c:87
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:398
ff_icc_profile_detect_transfer
int ff_icc_profile_detect_transfer(FFIccContext *s, cmsHPROFILE profile, enum AVColorTransferCharacteristic *out_trc)
Attempt detecting the transfer characteristic that best approximates the transfer function encoded by...
Definition: fflcms2.c:302
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition: codec.h:313
av_packet_ref
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition: packet.c:437
AVCodecInternal::draining_done
int draining_done
Definition: internal.h:146
FF_HW_HAS_CB
#define FF_HW_HAS_CB(avctx, function)
Definition: hwaccel_internal.h:177
UTF8_MAX_BYTES
#define UTF8_MAX_BYTES
Definition: decode.c:901
AVPACKET_IS_EMPTY
#define AVPACKET_IS_EMPTY(pkt)
Definition: packet_internal.h:26
AV_FRAME_DATA_AFD
@ AV_FRAME_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: frame.h:90
ff_sd_global_map
const SideDataMap ff_sd_global_map[]
A map between packet and frame side data types.
Definition: avcodec.c:58
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:652
AV_CODEC_EXPORT_DATA_ENHANCEMENTS
#define AV_CODEC_EXPORT_DATA_ENHANCEMENTS
Decoding only.
Definition: avcodec.h:426
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
AVCodecInternal::last_pkt_props
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
Definition: internal.h:90
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:55
AV_PKT_DATA_NB
@ AV_PKT_DATA_NB
The number of side data types.
Definition: packet.h:356
attribute_align_arg
#define attribute_align_arg
Definition: internal.h:50
av_codec_is_decoder
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:86
AVCodecContext::lowres
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
Definition: avcodec.h:1865
f
f
Definition: af_crystalizer.c:122
AVCodecContext::flags2
int flags2
AV_CODEC_FLAG2_*.
Definition: avcodec.h:515
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1719
SideDataMap::packet
enum AVPacketSideDataType packet
Definition: avcodec_internal.h:35
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_CODEC_FLAG_GRAY
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:322
AVPacket::size
int size
Definition: packet.h:540
ff_progress_frame_alloc
int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f)
This function allocates ProgressFrame.f May be called before ff_progress_frame_get_buffer() in the ca...
Definition: decode.c:1858
dc
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff) *mv_scale Intra DC Prediction block[y][x] dc[1]
Definition: snow.txt:400
byte
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 byte
Definition: bytestream.h:99
AVCodecContext::extra_hw_frames
int extra_hw_frames
Video decoding only.
Definition: avcodec.h:1530
codec_internal.h
FrameDecodeData::post_process
int(* post_process)(void *logctx, AVFrame *frame)
The callback to perform some delayed processing on the frame right before it is returned to the calle...
Definition: decode.h:44
AVCodecInternal::hwaccel_priv_data
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:130
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
av_frame_copy
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:1003
av_bsf_send_packet
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:202
AV_PKT_DATA_DYNAMIC_HDR10_PLUS
@ AV_PKT_DATA_DYNAMIC_HDR10_PLUS
HDR10+ dynamic metadata associated with a video frame.
Definition: packet.h:296
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:122
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
FF_CODEC_CAP_SETS_FRAME_PROPS
#define FF_CODEC_CAP_SETS_FRAME_PROPS
Codec handles output frame properties internally instead of letting the internal logic derive them fr...
Definition: codec_internal.h:78
AVCodecInternal::initial_format
int initial_format
Definition: internal.h:151
AVCodecInternal::bsf
struct AVBSFContext * bsf
Definition: internal.h:84
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1063
AV_FRAME_DATA_LCEVC
@ AV_FRAME_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
Definition: frame.h:236
AVCodecContext::pkt_timebase
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
Definition: avcodec.h:557
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
FF_CODEC_CAP_EXPORTS_CROPPING
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
Definition: codec_internal.h:61
size
int size
Definition: twinvq_data.h:10344
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
frame_validate
static int frame_validate(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:788
ff_frame_new_side_data
int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, size_t size, AVFrameSideData **psd)
Wrapper around av_frame_new_side_data, which rejects side data overridden by the demuxer.
Definition: decode.c:2123
ff_frame_new_side_data_from_buf_ext
int ff_frame_new_side_data_from_buf_ext(const AVCodecContext *avctx, AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef **buf)
Same as ff_frame_new_side_data_from_buf, but taking a AVFrameSideData array directly instead of an AV...
Definition: decode.c:2142
side_data_pref
static int side_data_pref(const AVCodecContext *avctx, AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type)
Check side data preference and clear existing side data from frame if needed.
Definition: decode.c:2107
AVFrameSideData::data
uint8_t * data
Definition: frame.h:267
DecodeContext::height
int height
Definition: decode.c:98
ffcodec
static const av_always_inline FFCodec * ffcodec(const AVCodec *codec)
Definition: codec_internal.h:330
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:649
fill_frame_props
static int fill_frame_props(const AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:571
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:706
AVCodecHWConfigInternal
Definition: hwconfig.h:25
AV_PICTURE_TYPE_NONE
@ AV_PICTURE_TYPE_NONE
Undefined.
Definition: avutil.h:278
av_buffer_make_writable
int av_buffer_make_writable(AVBufferRef **pbuf)
Create a writable reference from a given buffer reference, avoiding data copy if possible.
Definition: buffer.c:165
AVSubtitle::end_display_time
uint32_t end_display_time
Definition: avcodec.h:2241
frame.h
av_packet_unpack_dictionary
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict)
Unpack a dictionary from side_data.
Definition: packet.c:349
av_frame_remove_side_data
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
Definition: frame.c:1017
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:538
ProgressInternal::progress
ThreadProgress progress
Definition: decode.c:1848
AV_PRIMARY_EYE_NONE
@ AV_PRIMARY_EYE_NONE
Neither eye.
Definition: stereo3d.h:178
av_content_light_metadata_create_side_data
AVContentLightMetadata * av_content_light_metadata_create_side_data(AVFrame *frame)
Allocate a complete AVContentLightMetadata and add it to the frame.
Definition: mastering_display_metadata.c:82
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
SideDataMap::frame
enum AVFrameSideDataType frame
Definition: avcodec_internal.h:36
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:545
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: packet.c:63
ff_progress_frame_await
void ff_progress_frame_await(const ProgressFrame *f, int n)
Wait for earlier decoding threads to finish reference frames.
Definition: decode.c:1922
AVCodecInternal
Definition: internal.h:49
FFCodec::hw_configs
const struct AVCodecHWConfigInternal *const * hw_configs
Array of pointers to hardware configurations supported by the codec, or NULL if no hardware supported...
Definition: codec_internal.h:259
DecodeContext::side_data_pref_mask
uint64_t side_data_pref_mask
DTS of the last frame.
Definition: decode.c:93
FF_THREAD_NO_FRAME_THREADING
@ FF_THREAD_NO_FRAME_THREADING
Definition: thread.h:63
packet_side_data_get
static const AVPacketSideData * packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Definition: decode.c:1411
AVCodecContext::nb_side_data_prefer_packet
unsigned nb_side_data_prefer_packet
Number of entries in side_data_prefer_packet.
Definition: avcodec.h:2075
detect_colorspace
static int detect_colorspace(av_unused AVCodecContext *c, av_unused AVFrame *f)
Definition: decode.c:565
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:804
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
FF_THREAD_FRAME
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition: avcodec.h:1604
AV_FRAME_DATA_SKIP_SAMPLES
@ AV_FRAME_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: frame.h:109
av_mastering_display_metadata_alloc_size
AVMasteringDisplayMetadata * av_mastering_display_metadata_alloc_size(size_t *size)
Allocate an AVMasteringDisplayMetadata structure and set its fields to default values.
Definition: mastering_display_metadata.c:44
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:2105
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: packet.h:169
emms.h
AVCodecInternal::is_frame_mt
int is_frame_mt
This field is set to 1 when frame threading is being used and the parent AVCodecContext of this AVCod...
Definition: internal.h:61
avcodec_send_packet
int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
Definition: decode.c:727
FFCodec::caps_internal
unsigned caps_internal
Internal codec capabilities FF_CODEC_CAP_*.
Definition: codec_internal.h:136
extract_packet_props
static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
Definition: decode.c:167
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
av_packet_copy_props
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
Definition: packet.c:392
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
AVSubtitle::format
uint16_t format
Definition: avcodec.h:2239
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:532
av_frame_side_data_free
void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd)
Free all side data entries and their contents, then zeroes out the values which the pointers are poin...
Definition: frame.c:113
AVCodecInternal::initial_width
int initial_width
Definition: internal.h:152
reget_buffer_internal
static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
Definition: decode.c:1797
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
decode_receive_frame_internal
static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
Definition: decode.c:656
internal.h
ff_decode_receive_frame_internal
int ff_decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
Do the actual decoding and obtain a decoded frame from the decoder, if available.
Definition: decode.c:620
common.h
AVCodecInternal::in_pkt
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
Definition: internal.h:83
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
ff_decode_preinit
int ff_decode_preinit(AVCodecContext *avctx)
Perform decoder initialization and validation.
Definition: decode.c:1967
ff_thread_progress_init
av_cold int ff_thread_progress_init(ThreadProgress *pro, int init_mode)
Initialize a ThreadProgress.
Definition: threadprogress.c:33
AV_FRAME_DATA_STEREO3D
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
Definition: frame.h:64
DecodeContext::avci
AVCodecInternal avci
Definition: decode.c:60
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:637
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:610
DecodeContext::lcevc
FFLCEVCContext * lcevc
Definition: decode.c:95
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
AVCodecContext::hw_device_ctx
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
Definition: avcodec.h:1507
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
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:708
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
FF_CODEC_CAP_SETS_PKT_DTS
#define FF_CODEC_CAP_SETS_PKT_DTS
Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.
Definition: codec_internal.h:50
profile
int profile
Definition: mxfenc.c:2228
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:612
AVCodecContext::height
int height
Definition: avcodec.h:624
decode_simple_internal
static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples)
Definition: decode.c:413
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:663
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:648
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:1485
avcodec.h
FFCodec::decode_sub
int(* decode_sub)(struct AVCodecContext *avctx, struct AVSubtitle *sub, int *got_frame_ptr, const struct AVPacket *avpkt)
Decode subtitle data to an AVSubtitle.
Definition: codec_internal.h:199
AVCodecContext::sub_charenc_mode
int sub_charenc_mode
Subtitles character encoding mode.
Definition: avcodec.h:1887
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
AVCodecContext::frame_num
int64_t frame_num
Frame counter, set by libavcodec.
Definition: avcodec.h:2041
avcodec_get_hw_frames_parameters
int avcodec_get_hw_frames_parameters(AVCodecContext *avctx, AVBufferRef *device_ref, enum AVPixelFormat hw_pix_fmt, AVBufferRef **out_frames_ref)
Create and return a AVHWFramesContext with values adequate for hardware decoding.
Definition: decode.c:1167
ff_reget_buffer
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
Definition: decode.c:1839
ret
ret
Definition: filter_design.txt:187
AVHWDeviceContext::type
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
Definition: hwcontext.h:72
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:264
AVHWFramesContext::device_ctx
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition: hwcontext.h:134
AVCodecContext::strict_std_compliance
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1389
AV_CODEC_PROP_TEXT_SUB
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
Definition: codec_desc.h:108
av_channel_layout_check
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
Definition: channel_layout.c:778
ff_thread_sync_ref
enum ThreadingStatus ff_thread_sync_ref(AVCodecContext *avctx, size_t offset)
Allows to synchronize objects whose lifetime is the whole decoding process among all frame threads.
Definition: decode.c:1928
hwaccel
static const char * hwaccel
Definition: ffplay.c:353
ff_refstruct_replace
void ff_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
Definition: refstruct.c:160
ff_decode_content_light_new
int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, AVContentLightMetadata **clm)
Wrapper around av_content_light_metadata_create_side_data(), which rejects side data overridden by th...
Definition: decode.c:2247
ff_thread_progress_destroy
av_cold void ff_thread_progress_destroy(ThreadProgress *pro)
Destroy a ThreadProgress.
Definition: threadprogress.c:44
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:550
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
ff_progress_frame_replace
void ff_progress_frame_replace(ProgressFrame *dst, const ProgressFrame *src)
Do nothing if dst and src already refer to the same AVFrame; otherwise unreference dst and if src is ...
Definition: decode.c:1907
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:129
apply_param_change
static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
Definition: decode.c:106
progress_frame_pool_init_cb
static av_cold int progress_frame_pool_init_cb(FFRefStructOpaque opaque, void *obj)
Definition: decode.c:1934
progress_frame_pool_free_entry_cb
static av_cold void progress_frame_pool_free_entry_cb(FFRefStructOpaque opaque, void *obj)
Definition: decode.c:1959
ff_decode_frame_props
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
Definition: decode.c:1559
AV_FRAME_DATA_DYNAMIC_HDR_PLUS
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
Definition: frame.h:159
AVCodecContext
main external API structure.
Definition: avcodec.h:451
AVCodecContext::active_thread_type
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:1612
recode_subtitle
static int recode_subtitle(AVCodecContext *avctx, const AVPacket **outpkt, const AVPacket *inpkt, AVPacket *buf_pkt)
Definition: decode.c:902
channel_layout.h
av_mastering_display_metadata_create_side_data
AVMasteringDisplayMetadata * av_mastering_display_metadata_create_side_data(AVFrame *frame)
Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
Definition: mastering_display_metadata.c:58
avcodec_internal.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
ff_refstruct_pool_alloc_ext
static FFRefStructPool * ff_refstruct_pool_alloc_ext(size_t size, unsigned flags, void *opaque, int(*init_cb)(FFRefStructOpaque opaque, void *obj), void(*reset_cb)(FFRefStructOpaque opaque, void *obj), void(*free_entry_cb)(FFRefStructOpaque opaque, void *obj), void(*free_cb)(FFRefStructOpaque opaque))
A wrapper around ff_refstruct_pool_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition: refstruct.h:258
ffhwaccel
static const FFHWAccel * ffhwaccel(const AVHWAccel *codec)
Definition: hwaccel_internal.h:166
side_data_stereo3d_merge
static int side_data_stereo3d_merge(AVFrameSideData *sd_frame, const AVPacketSideData *sd_pkt)
Definition: decode.c:1427
AV_PKT_DATA_AFD
@ AV_PKT_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: packet.h:258
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:153
AVCodecContext::export_side_data
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
Definition: avcodec.h:1937
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
FF_CODEC_CB_TYPE_RECEIVE_FRAME
@ FF_CODEC_CB_TYPE_RECEIVE_FRAME
Definition: codec_internal.h:115
ProgressInternal::f
struct AVFrame * f
Definition: decode.c:1849
ff_thread_progress_reset
static void ff_thread_progress_reset(ThreadProgress *pro)
Reset the ThreadProgress.progress counter; must only be called if the ThreadProgress is not in use in...
Definition: threadprogress.h:72
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:149
AVPacket::stream_index
int stream_index
Definition: packet.h:541
avcodec_get_hw_config
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
Definition: utils.c:833
AVCodecInternal::buffer_frame
AVFrame * buffer_frame
Definition: internal.h:145
AV_CODEC_CAP_PARAM_CHANGE
#define AV_CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
Definition: codec.h:118
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:444
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
FFCodec::bsfs
const char * bsfs
Decoding only, a comma-separated list of bitstream filters to apply to packets before decoding.
Definition: codec_internal.h:250
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:639
AVHWFramesContext::initial_pool_size
int initial_pool_size
Initial size of the frame pool.
Definition: hwcontext.h:187
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition: avcodec.h:459
AV_FRAME_FLAG_DISCARD
#define AV_FRAME_FLAG_DISCARD
A flag to mark the frames which need to be decoded, but shouldn't be output.
Definition: frame.h:644
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
av_bsf_list_parse_str
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
Parse string describing list of bitstream filters and create single AVBSFContext describing the whole...
Definition: bsf.c:526
ff_decode_mastering_display_new_ext
int ff_decode_mastering_display_new_ext(const AVCodecContext *avctx, AVFrameSideData ***sd, int *nb_sd, struct AVMasteringDisplayMetadata **mdm)
Same as ff_decode_mastering_display_new, but taking a AVFrameSideData array directly instead of an AV...
Definition: decode.c:2170
side_data_map
static int side_data_map(AVFrame *dst, const AVPacketSideData *sd_src, int nb_sd_src, const SideDataMap *map)
Definition: decode.c:1463
AV_PKT_DATA_A53_CC
@ AV_PKT_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: packet.h:239
ff_decode_internal_uninit
void ff_decode_internal_uninit(AVCodecContext *avctx)
Definition: decode.c:2335
DecodeContext::width
int width
Definition: decode.c:97
mem.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
packet_internal.h
AV_CODEC_EXPORT_DATA_MVS
#define AV_CODEC_EXPORT_DATA_MVS
Export motion vectors through frame side data.
Definition: avcodec.h:406
ff_icc_profile_sanitize
int ff_icc_profile_sanitize(FFIccContext *s, cmsHPROFILE profile)
Sanitize an ICC profile to try and fix badly broken values.
Definition: fflcms2.c:213
mastering_display_metadata.h
ff_attach_decode_data
int ff_attach_decode_data(AVFrame *frame)
Definition: decode.c:1634
AV_FRAME_CROP_UNALIGNED
@ AV_FRAME_CROP_UNALIGNED
Apply the maximum possible cropping, even if it requires setting the AVFrame.data[] entries to unalig...
Definition: frame.h:1014
AVCodecInternal::initial_ch_layout
AVChannelLayout initial_ch_layout
Definition: internal.h:154
ThreadingStatus
ThreadingStatus
Definition: thread.h:60
avcodec_parameters_from_context
int avcodec_parameters_from_context(struct AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Definition: codec_par.c:137
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:265
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
DecodeContext::lcevc_frame
int lcevc_frame
Definition: decode.c:96
AV_CODEC_FLAG2_EXPORT_MVS
#define AV_CODEC_FLAG2_EXPORT_MVS
Export motion vectors through frame side data.
Definition: avcodec.h:384
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
ProgressFrame
The ProgressFrame structure.
Definition: progressframe.h:73
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
SideDataMap
Definition: avcodec_internal.h:34
AVPacket
This structure stores compressed data.
Definition: packet.h:516
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:559
FFCodec::cb
union FFCodec::@92 cb
DecodeContext::pts_correction_num_faulty_pts
int64_t pts_correction_num_faulty_pts
Definition: decode.c:84
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:1158
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:624
bytestream.h
FrameDecodeData::hwaccel_priv
void * hwaccel_priv
Per-frame private data for hwaccels.
Definition: decode.h:51
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
hwcontext.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AVCodecHWConfig
Definition: codec.h:345
AVStereo3D
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
Definition: stereo3d.h:203
AVCodecContext::sw_pix_fmt
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:670
av_image_check_sar
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
Definition: imgutils.c:323
ff_copy_palette
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
Check whether the side-data of src contains a palette of size AVPALETTE_SIZE; if so,...
Definition: decode.c:2260
AVCodecHWConfigInternal::public
AVCodecHWConfig public
This is the structure which will be returned to the user by avcodec_get_hw_config().
Definition: hwconfig.h:30
decode_bsfs_init
static int decode_bsfs_init(AVCodecContext *avctx)
Definition: decode.c:182
FFLCEVCFrame
Definition: lcevcdec.h:39
codec_desc.h
AV_PIX_FMT_FLAG_PAL
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:120
AVHWAccel::pix_fmt
enum AVPixelFormat pix_fmt
Supported pixel format.
Definition: avcodec.h:2126
ff_refstruct_unref
void ff_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition: refstruct.c:120
AVCodecContext::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
Definition: avcodec.h:648
DecodeContext
Definition: decode.c:59
av_frame_side_data_add
AVFrameSideData * av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef **pbuf, unsigned int flags)
Add a new side data entry to an array from an existing AVBufferRef.
Definition: frame.c:850
FF_REGET_BUFFER_FLAG_READONLY
#define FF_REGET_BUFFER_FLAG_READONLY
the returned buffer does not need to be writable
Definition: decode.h:128
src
#define src
Definition: vp8dsp.c:248
ff_refstruct_pool_get
void * ff_refstruct_pool_get(FFRefStructPool *pool)
Get an object from the pool, reusing an old one from the pool when available.
Definition: refstruct.c:297
ff_decode_internal_sync
void ff_decode_internal_sync(AVCodecContext *dst, const AVCodecContext *src)
Definition: decode.c:2327
Frame::height
int height
Definition: ffplay.c:160
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:551
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:2885
FF_SUB_CHARENC_MODE_IGNORE
#define FF_SUB_CHARENC_MODE_IGNORE
neither convert the subtitles, nor check them for valid UTF-8
Definition: avcodec.h:1891
min
float min
Definition: vorbis_enc_data.h:429