29 #define MAX_YUV4_HEADER 96 30 #define MAX_FRAME_HEADER 80 36 char *tokstart, *tokend, *header_end;
40 rated = 0, aspectn = 0, aspectd = 0;
49 if (header[i] ==
'\n') {
56 if (i == MAX_YUV4_HEADER) {
65 header_end = &header[i + 1];
66 for (tokstart = &header[strlen(
Y4M_MAGIC) + 1];
67 tokstart < header_end; tokstart++) {
68 if (*tokstart == 0x20)
70 switch (*tokstart++) {
72 width = strtol(tokstart, &tokend, 10);
76 height = strtol(tokstart, &tokend, 10);
80 if (strncmp(
"420jpeg", tokstart, 7) == 0) {
83 }
else if (strncmp(
"420mpeg2", tokstart, 8) == 0) {
86 }
else if (strncmp(
"420paldv", tokstart, 8) == 0) {
89 }
else if (strncmp(
"420p16", tokstart, 6) == 0) {
91 }
else if (strncmp(
"422p16", tokstart, 6) == 0) {
93 }
else if (strncmp(
"444p16", tokstart, 6) == 0) {
95 }
else if (strncmp(
"420p14", tokstart, 6) == 0) {
97 }
else if (strncmp(
"422p14", tokstart, 6) == 0) {
99 }
else if (strncmp(
"444p14", tokstart, 6) == 0) {
101 }
else if (strncmp(
"420p12", tokstart, 6) == 0) {
103 }
else if (strncmp(
"422p12", tokstart, 6) == 0) {
105 }
else if (strncmp(
"444p12", tokstart, 6) == 0) {
107 }
else if (strncmp(
"420p10", tokstart, 6) == 0) {
109 }
else if (strncmp(
"422p10", tokstart, 6) == 0) {
111 }
else if (strncmp(
"444p10", tokstart, 6) == 0) {
113 }
else if (strncmp(
"420p9", tokstart, 5) == 0) {
115 }
else if (strncmp(
"422p9", tokstart, 5) == 0) {
117 }
else if (strncmp(
"444p9", tokstart, 5) == 0) {
119 }
else if (strncmp(
"420", tokstart, 3) == 0) {
122 }
else if (strncmp(
"411", tokstart, 3) == 0) {
124 }
else if (strncmp(
"422", tokstart, 3) == 0) {
126 }
else if (strncmp(
"444alpha", tokstart, 8) == 0 ) {
128 }
else if (strncmp(
"444", tokstart, 3) == 0) {
130 }
else if (strncmp(
"mono16", tokstart, 6) == 0) {
132 }
else if (strncmp(
"mono12", tokstart, 6) == 0) {
134 }
else if (strncmp(
"mono10", tokstart, 6) == 0) {
136 }
else if (strncmp(
"mono9", tokstart, 5) == 0) {
138 }
else if (strncmp(
"mono", tokstart, 4) == 0) {
145 while (tokstart < header_end && *tokstart != 0x20)
149 switch (*tokstart++){
164 "interlaced and non-interlaced frames.\n");
171 sscanf(tokstart,
"%d:%d", &raten, &rated);
172 while (tokstart < header_end && *tokstart != 0x20)
176 sscanf(tokstart,
"%d:%d", &aspectn, &aspectd);
177 while (tokstart < header_end && *tokstart != 0x20)
181 if (strncmp(
"YSCSS=", tokstart, 6) == 0) {
184 if (strncmp(
"420JPEG", tokstart, 7) == 0)
186 else if (strncmp(
"420MPEG2", tokstart, 8) == 0)
188 else if (strncmp(
"420PALDV", tokstart, 8) == 0)
190 else if (strncmp(
"420P9", tokstart, 5) == 0)
192 else if (strncmp(
"422P9", tokstart, 5) == 0)
194 else if (strncmp(
"444P9", tokstart, 5) == 0)
196 else if (strncmp(
"420P10", tokstart, 6) == 0)
198 else if (strncmp(
"422P10", tokstart, 6) == 0)
200 else if (strncmp(
"444P10", tokstart, 6) == 0)
202 else if (strncmp(
"420P12", tokstart, 6) == 0)
204 else if (strncmp(
"422P12", tokstart, 6) == 0)
206 else if (strncmp(
"444P12", tokstart, 6) == 0)
208 else if (strncmp(
"420P14", tokstart, 6) == 0)
210 else if (strncmp(
"422P14", tokstart, 6) == 0)
212 else if (strncmp(
"444P14", tokstart, 6) == 0)
214 else if (strncmp(
"420P16", tokstart, 6) == 0)
216 else if (strncmp(
"422P16", tokstart, 6) == 0)
218 else if (strncmp(
"444P16", tokstart, 6) == 0)
220 else if (strncmp(
"411", tokstart, 3) == 0)
222 else if (strncmp(
"422", tokstart, 3) == 0)
224 else if (strncmp(
"444", tokstart, 3) == 0)
226 }
else if (strncmp(
"COLORRANGE=", tokstart, 11) == 0) {
228 if (strncmp(
"FULL",tokstart, 4) == 0)
230 else if (strncmp(
"LIMITED", tokstart, 7) == 0)
233 while (tokstart < header_end && *tokstart != 0x20)
239 if (width == -1 ||
height == -1) {
248 pix_fmt = alt_pix_fmt;
251 if (raten <= 0 || rated <= 0) {
257 if (aspectn == 0 && aspectd == 0) {
267 av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
296 if (header[i] ==
'\n') {
305 else if (i == MAX_FRAME_HEADER)
329 pts =
FFMAX(0, pts - 1);
349 .
name =
"yuv4mpegpipe",
enum AVChromaLocation chroma_location
enum AVFieldOrder field_order
Video only.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
int64_t avio_size(AVIOContext *s)
Get the filesize.
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
#define AV_PIX_FMT_YUV444P14
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY12
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
#define AV_PIX_FMT_YUV444P16
AVColorRange
Visual content value range.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static const uint8_t header[24]
#define AV_PIX_FMT_YUV422P12
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...
static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVMediaType codec_type
General type of the encoded data.
#define AV_PIX_FMT_YUV444P10
AVRational avg_frame_rate
Average framerate.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int avio_r8(AVIOContext *s)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_GRAY16
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
static int yuv4_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
enum AVColorRange color_range
Video only.
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P14
static int yuv4_read_header(AVFormatContext *s)
AVIOContext * pb
I/O context.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUV420P10
Rational number (pair of numerator and denominator).
#define AV_PIX_FMT_YUV420P9
int error
contains the error code or 0 if no error happened
This structure contains the data a format has to probe a file.
#define AV_PIX_FMT_YUV422P14
#define flags(name, subs,...)
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
Narrow or limited range content.
int64_t duration
Decoding: duration of the stream, in stream time base.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int yuv4_probe(const AVProbeData *pd)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int eof_reached
true if was unable to read due to error or eof
AVInputFormat ff_yuv4mpegpipe_demuxer
#define Y4M_FRAME_MAGIC_LEN
AVChromaLocation
Location of chroma samples.
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
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.
This structure stores compressed data.
#define AV_PIX_FMT_YUV422P16
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...