FFmpeg
yuv4mpegdec.c
Go to the documentation of this file.
1 /*
2  * YUV4MPEG demuxer
3  * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/imgutils.h"
23 
24 #include "avformat.h"
25 #include "internal.h"
26 #include "yuv4mpeg.h"
27 
28 /* Header size increased to allow room for optional flags */
29 #define MAX_YUV4_HEADER 80
30 #define MAX_FRAME_HEADER 80
31 
33 {
34  char header[MAX_YUV4_HEADER + 10]; // Include headroom for
35  // the longest option
36  char *tokstart, *tokend, *header_end;
37  int i;
38  AVIOContext *pb = s->pb;
39  int width = -1, height = -1, raten = 0,
40  rated = 0, aspectn = 0, aspectd = 0;
42  enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED;
43  enum AVFieldOrder field_order = AV_FIELD_UNKNOWN;
45  AVStream *st;
46 
47  for (i = 0; i < MAX_YUV4_HEADER; i++) {
48  header[i] = avio_r8(pb);
49  if (header[i] == '\n') {
50  header[i + 1] = 0x20; // Add a space after last option.
51  // Makes parsing "444" vs "444alpha" easier.
52  header[i + 2] = 0;
53  break;
54  }
55  }
56  if (i == MAX_YUV4_HEADER)
57  return -1;
58  if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))
59  return -1;
60 
61  header_end = &header[i + 1]; // Include space
62  for (tokstart = &header[strlen(Y4M_MAGIC) + 1];
63  tokstart < header_end; tokstart++) {
64  if (*tokstart == 0x20)
65  continue;
66  switch (*tokstart++) {
67  case 'W': // Width. Required.
68  width = strtol(tokstart, &tokend, 10);
69  tokstart = tokend;
70  break;
71  case 'H': // Height. Required.
72  height = strtol(tokstart, &tokend, 10);
73  tokstart = tokend;
74  break;
75  case 'C': // Color space
76  if (strncmp("420jpeg", tokstart, 7) == 0) {
77  pix_fmt = AV_PIX_FMT_YUV420P;
78  chroma_sample_location = AVCHROMA_LOC_CENTER;
79  } else if (strncmp("420mpeg2", tokstart, 8) == 0) {
80  pix_fmt = AV_PIX_FMT_YUV420P;
81  chroma_sample_location = AVCHROMA_LOC_LEFT;
82  } else if (strncmp("420paldv", tokstart, 8) == 0) {
83  pix_fmt = AV_PIX_FMT_YUV420P;
84  chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
85  } else if (strncmp("420p16", tokstart, 6) == 0) {
86  pix_fmt = AV_PIX_FMT_YUV420P16;
87  } else if (strncmp("422p16", tokstart, 6) == 0) {
88  pix_fmt = AV_PIX_FMT_YUV422P16;
89  } else if (strncmp("444p16", tokstart, 6) == 0) {
90  pix_fmt = AV_PIX_FMT_YUV444P16;
91  } else if (strncmp("420p14", tokstart, 6) == 0) {
92  pix_fmt = AV_PIX_FMT_YUV420P14;
93  } else if (strncmp("422p14", tokstart, 6) == 0) {
94  pix_fmt = AV_PIX_FMT_YUV422P14;
95  } else if (strncmp("444p14", tokstart, 6) == 0) {
96  pix_fmt = AV_PIX_FMT_YUV444P14;
97  } else if (strncmp("420p12", tokstart, 6) == 0) {
98  pix_fmt = AV_PIX_FMT_YUV420P12;
99  } else if (strncmp("422p12", tokstart, 6) == 0) {
100  pix_fmt = AV_PIX_FMT_YUV422P12;
101  } else if (strncmp("444p12", tokstart, 6) == 0) {
102  pix_fmt = AV_PIX_FMT_YUV444P12;
103  } else if (strncmp("420p10", tokstart, 6) == 0) {
104  pix_fmt = AV_PIX_FMT_YUV420P10;
105  } else if (strncmp("422p10", tokstart, 6) == 0) {
106  pix_fmt = AV_PIX_FMT_YUV422P10;
107  } else if (strncmp("444p10", tokstart, 6) == 0) {
108  pix_fmt = AV_PIX_FMT_YUV444P10;
109  } else if (strncmp("420p9", tokstart, 5) == 0) {
110  pix_fmt = AV_PIX_FMT_YUV420P9;
111  } else if (strncmp("422p9", tokstart, 5) == 0) {
112  pix_fmt = AV_PIX_FMT_YUV422P9;
113  } else if (strncmp("444p9", tokstart, 5) == 0) {
114  pix_fmt = AV_PIX_FMT_YUV444P9;
115  } else if (strncmp("420", tokstart, 3) == 0) {
116  pix_fmt = AV_PIX_FMT_YUV420P;
117  chroma_sample_location = AVCHROMA_LOC_CENTER;
118  } else if (strncmp("411", tokstart, 3) == 0) {
119  pix_fmt = AV_PIX_FMT_YUV411P;
120  } else if (strncmp("422", tokstart, 3) == 0) {
121  pix_fmt = AV_PIX_FMT_YUV422P;
122  } else if (strncmp("444alpha", tokstart, 8) == 0 ) {
123  av_log(s, AV_LOG_ERROR, "Cannot handle 4:4:4:4 "
124  "YUV4MPEG stream.\n");
125  return -1;
126  } else if (strncmp("444", tokstart, 3) == 0) {
127  pix_fmt = AV_PIX_FMT_YUV444P;
128  } else if (strncmp("mono16", tokstart, 6) == 0) {
129  pix_fmt = AV_PIX_FMT_GRAY16;
130  } else if (strncmp("mono12", tokstart, 6) == 0) {
131  pix_fmt = AV_PIX_FMT_GRAY12;
132  } else if (strncmp("mono10", tokstart, 6) == 0) {
133  pix_fmt = AV_PIX_FMT_GRAY10;
134  } else if (strncmp("mono9", tokstart, 5) == 0) {
135  pix_fmt = AV_PIX_FMT_GRAY9;
136  } else if (strncmp("mono", tokstart, 4) == 0) {
137  pix_fmt = AV_PIX_FMT_GRAY8;
138  } else {
139  av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown "
140  "pixel format.\n");
141  return -1;
142  }
143  while (tokstart < header_end && *tokstart != 0x20)
144  tokstart++;
145  break;
146  case 'I': // Interlace type
147  switch (*tokstart++){
148  case '?':
149  field_order = AV_FIELD_UNKNOWN;
150  break;
151  case 'p':
152  field_order = AV_FIELD_PROGRESSIVE;
153  break;
154  case 't':
155  field_order = AV_FIELD_TT;
156  break;
157  case 'b':
158  field_order = AV_FIELD_BB;
159  break;
160  case 'm':
161  av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains mixed "
162  "interlaced and non-interlaced frames.\n");
163  default:
164  av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");
165  return AVERROR(EINVAL);
166  }
167  break;
168  case 'F': // Frame rate
169  sscanf(tokstart, "%d:%d", &raten, &rated); // 0:0 if unknown
170  while (tokstart < header_end && *tokstart != 0x20)
171  tokstart++;
172  break;
173  case 'A': // Pixel aspect
174  sscanf(tokstart, "%d:%d", &aspectn, &aspectd); // 0:0 if unknown
175  while (tokstart < header_end && *tokstart != 0x20)
176  tokstart++;
177  break;
178  case 'X': // Vendor extensions
179  if (strncmp("YSCSS=", tokstart, 6) == 0) {
180  // Older nonstandard pixel format representation
181  tokstart += 6;
182  if (strncmp("420JPEG", tokstart, 7) == 0)
183  alt_pix_fmt = AV_PIX_FMT_YUV420P;
184  else if (strncmp("420MPEG2", tokstart, 8) == 0)
185  alt_pix_fmt = AV_PIX_FMT_YUV420P;
186  else if (strncmp("420PALDV", tokstart, 8) == 0)
187  alt_pix_fmt = AV_PIX_FMT_YUV420P;
188  else if (strncmp("420P9", tokstart, 5) == 0)
189  alt_pix_fmt = AV_PIX_FMT_YUV420P9;
190  else if (strncmp("422P9", tokstart, 5) == 0)
191  alt_pix_fmt = AV_PIX_FMT_YUV422P9;
192  else if (strncmp("444P9", tokstart, 5) == 0)
193  alt_pix_fmt = AV_PIX_FMT_YUV444P9;
194  else if (strncmp("420P10", tokstart, 6) == 0)
195  alt_pix_fmt = AV_PIX_FMT_YUV420P10;
196  else if (strncmp("422P10", tokstart, 6) == 0)
197  alt_pix_fmt = AV_PIX_FMT_YUV422P10;
198  else if (strncmp("444P10", tokstart, 6) == 0)
199  alt_pix_fmt = AV_PIX_FMT_YUV444P10;
200  else if (strncmp("420P12", tokstart, 6) == 0)
201  alt_pix_fmt = AV_PIX_FMT_YUV420P12;
202  else if (strncmp("422P12", tokstart, 6) == 0)
203  alt_pix_fmt = AV_PIX_FMT_YUV422P12;
204  else if (strncmp("444P12", tokstart, 6) == 0)
205  alt_pix_fmt = AV_PIX_FMT_YUV444P12;
206  else if (strncmp("420P14", tokstart, 6) == 0)
207  alt_pix_fmt = AV_PIX_FMT_YUV420P14;
208  else if (strncmp("422P14", tokstart, 6) == 0)
209  alt_pix_fmt = AV_PIX_FMT_YUV422P14;
210  else if (strncmp("444P14", tokstart, 6) == 0)
211  alt_pix_fmt = AV_PIX_FMT_YUV444P14;
212  else if (strncmp("420P16", tokstart, 6) == 0)
213  alt_pix_fmt = AV_PIX_FMT_YUV420P16;
214  else if (strncmp("422P16", tokstart, 6) == 0)
215  alt_pix_fmt = AV_PIX_FMT_YUV422P16;
216  else if (strncmp("444P16", tokstart, 6) == 0)
217  alt_pix_fmt = AV_PIX_FMT_YUV444P16;
218  else if (strncmp("411", tokstart, 3) == 0)
219  alt_pix_fmt = AV_PIX_FMT_YUV411P;
220  else if (strncmp("422", tokstart, 3) == 0)
221  alt_pix_fmt = AV_PIX_FMT_YUV422P;
222  else if (strncmp("444", tokstart, 3) == 0)
223  alt_pix_fmt = AV_PIX_FMT_YUV444P;
224  } else if (strncmp("COLORRANGE=", tokstart, 11) == 0) {
225  tokstart += 11;
226  if (strncmp("FULL",tokstart, 4) == 0)
227  color_range = AVCOL_RANGE_JPEG;
228  else if (strncmp("LIMITED", tokstart, 7) == 0)
229  color_range = AVCOL_RANGE_MPEG;
230  }
231  while (tokstart < header_end && *tokstart != 0x20)
232  tokstart++;
233  break;
234  }
235  }
236 
237  if (width == -1 || height == -1) {
238  av_log(s, AV_LOG_ERROR, "YUV4MPEG has invalid header.\n");
239  return -1;
240  }
241 
242  if (pix_fmt == AV_PIX_FMT_NONE) {
243  if (alt_pix_fmt == AV_PIX_FMT_NONE)
244  pix_fmt = AV_PIX_FMT_YUV420P;
245  else
246  pix_fmt = alt_pix_fmt;
247  }
248 
249  if (raten <= 0 || rated <= 0) {
250  // Frame rate unknown
251  raten = 25;
252  rated = 1;
253  }
254 
255  if (aspectn == 0 && aspectd == 0) {
256  // Pixel aspect unknown
257  aspectd = 1;
258  }
259 
260  st = avformat_new_stream(s, NULL);
261  if (!st)
262  return AVERROR(ENOMEM);
263  st->codecpar->width = width;
264  st->codecpar->height = height;
265  av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
266  avpriv_set_pts_info(st, 64, rated, raten);
267  st->avg_frame_rate = av_inv_q(st->time_base);
268  st->codecpar->format = pix_fmt;
271  st->sample_aspect_ratio = (AVRational){ aspectn, aspectd };
272  st->codecpar->chroma_location = chroma_sample_location;
274  st->codecpar->field_order = field_order;
276  if ((int) s->packet_size < 0)
277  return s->packet_size;
278  s->internal->data_offset = avio_tell(pb);
279 
280  st->duration = (avio_size(pb) - avio_tell(pb)) / s->packet_size;
281 
282  return 0;
283 }
284 
286 {
287  int i;
288  char header[MAX_FRAME_HEADER+1];
289  int ret;
290  int64_t off = avio_tell(s->pb);
291 
292  for (i = 0; i < MAX_FRAME_HEADER; i++) {
293  header[i] = avio_r8(s->pb);
294  if (header[i] == '\n') {
295  header[i + 1] = 0;
296  break;
297  }
298  }
299  if (s->pb->error)
300  return s->pb->error;
301  else if (s->pb->eof_reached)
302  return AVERROR_EOF;
303  else if (i == MAX_FRAME_HEADER)
304  return AVERROR_INVALIDDATA;
305 
306  if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC)))
307  return AVERROR_INVALIDDATA;
308 
309  ret = av_get_packet(s->pb, pkt, s->packet_size - Y4M_FRAME_MAGIC_LEN);
310  if (ret < 0)
311  return ret;
312  else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) {
313  av_packet_unref(pkt);
314  return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
315  }
316  pkt->stream_index = 0;
317  pkt->pts = (off - s->internal->data_offset) / s->packet_size;
318  pkt->duration = 1;
319  return 0;
320 }
321 
322 static int yuv4_read_seek(AVFormatContext *s, int stream_index,
323  int64_t pts, int flags)
324 {
325  int64_t pos;
326 
327  if (flags & AVSEEK_FLAG_BACKWARD)
328  pts = FFMAX(0, pts - 1);
329  pos = pts * s->packet_size;
330 
331  if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0)
332  return -1;
333  return 0;
334 }
335 
336 static int yuv4_probe(const AVProbeData *pd)
337 {
338  /* check file header */
339  if (strncmp(pd->buf, Y4M_MAGIC, sizeof(Y4M_MAGIC) - 1) == 0)
340  return AVPROBE_SCORE_MAX;
341  else
342  return 0;
343 }
344 
346  .name = "yuv4mpegpipe",
347  .long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe"),
348  .read_probe = yuv4_probe,
349  .read_header = yuv4_read_header,
350  .read_packet = yuv4_read_packet,
351  .read_seek = yuv4_read_seek,
352  .extensions = "y4m",
353 };
#define AVSEEK_FLAG_BACKWARD
Definition: avformat.h:2511
enum AVChromaLocation chroma_location
Definition: avcodec.h:4047
unsigned int packet_size
Definition: avformat.h:1482
#define NULL
Definition: coverity.c:32
enum AVFieldOrder field_order
Video only.
Definition: avcodec.h:4038
Bytestream IO Context.
Definition: avio.h:161
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static enum AVPixelFormat pix_fmt
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:339
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:543
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:397
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
misc image utilities
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4892
int64_t data_offset
offset of the first packet
Definition: internal.h:82
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3957
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:943
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1811
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:367
color_range
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:391
static AVPacket pkt
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:368
Format I/O context.
Definition: avformat.h:1358
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:369
int width
Video only.
Definition: avcodec.h:4023
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1495
#define Y4M_FRAME_MAGIC
Definition: yuv4mpeg.h:25
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4465
#define height
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:400
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:310
AVColorRange
MPEG vs JPEG YUV range.
Definition: pixfmt.h:519
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
static const uint8_t header[24]
Definition: sdr2.c:67
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:392
#define av_log(a,...)
#define Y4M_MAGIC
Definition: yuv4mpeg.h:24
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
Definition: imgutils.c:431
static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: yuv4mpegdec.c:285
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3953
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:390
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:954
#define FFMAX(a, b)
Definition: common.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:641
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:448
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:385
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:371
#define width
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:545
#define s(width, name)
Definition: cbs_vp9.c:257
static int yuv4_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
Definition: yuv4mpegdec.c:322
enum AVColorRange color_range
Video only.
Definition: avcodec.h:4043
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:386
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:522
Stream structure.
Definition: avformat.h:881
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:398
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:395
static int yuv4_read_header(AVFormatContext *s)
Definition: yuv4mpegdec.c:32
AVIOContext * pb
I/O context.
Definition: avformat.h:1400
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:599
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:387
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVFieldOrder
Definition: avcodec.h:1543
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:384
int error
contains the error code or 0 if no error happened
Definition: avio.h:245
This structure contains the data a format has to probe a file.
Definition: avformat.h:446
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:396
static int64_t pts
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:388
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:394
the normal 219*2^(n-8) "MPEG" YUV ranges
Definition: pixfmt.h:521
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:930
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:458
Main libavformat public API header.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Y , 8bpp.
Definition: pixfmt.h:74
static int yuv4_probe(const AVProbeData *pd)
Definition: yuv4mpegdec.c:336
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
int eof_reached
true if was unable to read due to error or eof
Definition: avio.h:239
AVInputFormat ff_yuv4mpegpipe_demuxer
Definition: yuv4mpegdec.c:345
#define Y4M_FRAME_MAGIC_LEN
Definition: yuv4mpeg.h:26
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:654
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:541
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
Definition: pixfmt.h:544
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1028
int stream_index
Definition: avcodec.h:1479
#define MAX_YUV4_HEADER
Definition: yuv4mpegdec.c:29
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:910
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
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
This structure stores compressed data.
Definition: avcodec.h:1454
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:399
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1470
#define MAX_FRAME_HEADER
Definition: yuv4mpegdec.c:30