31#define MAX_YUV4_HEADER 128
32#define MAX_FRAME_HEADER 80
38 char *tokstart, *tokend, *header_end;
41 rated = 0, aspectn = 0, aspectd = 0;
69 tokstart < header_end; tokstart++) {
70 if (*tokstart == 0x20)
72 switch (*tokstart++) {
74 width = strtol(tokstart, &tokend, 10);
78 height = strtol(tokstart, &tokend, 10);
84#define MAX_PIX_FMT_LENGTH 8
86#undef MAX_PIX_FMT_LENGTH
124 chroma_sample_location = pix_fmt_array[
i].chroma_loc;
133 while (tokstart < header_end && *tokstart != 0x20)
138 switch (*tokstart++){
153 "interlaced and non-interlaced frames.\n");
161 sscanf(tokstart,
"%d:%d", &raten, &rated);
162 while (tokstart < header_end && *tokstart != 0x20)
166 sscanf(tokstart,
"%d:%d", &aspectn, &aspectd);
167 while (tokstart < header_end && *tokstart != 0x20)
171 if (strncmp(
"YSCSS=", tokstart, 6) == 0) {
172 static const struct {
173#define MAX_PIX_FMT_LENGTH 8
175#undef MAX_PIX_FMT_LENGTH
177 } pix_fmt_array[] = {
203 alt_pix_fmt = pix_fmt_array[
i].pix_fmt;
206 }
else if (strncmp(
"COLORRANGE=", tokstart, 11) == 0) {
208 if (strncmp(
"FULL",tokstart, 4) == 0)
210 else if (strncmp(
"LIMITED", tokstart, 7) == 0)
213 while (tokstart < header_end && *tokstart != 0x20)
231 if (raten <= 0 || rated <= 0) {
237 if (aspectn == 0 && aspectd == 0) {
247 av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
258 if ((
int)
s->packet_size < 0)
259 return s->packet_size;
283 else if (
s->pb->eof_reached)
297 pkt->stream_index = 0;
329 .p.name =
"yuv4mpegpipe",
331 .p.extensions =
"y4m",
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_r8(AVIOContext *s)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
@ AV_FIELD_TT
Top coded_first, top displayed first.
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
static enum AVPixelFormat pix_fmt
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
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.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
AVChromaLocation
Location of chroma samples.
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
@ AVCHROMA_LOC_UNSPECIFIED
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV422P9
AVColorRange
Visual content value range.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
enum AVFieldOrder field_order
The order of the fields in interlaced video.
int height
The height of the video frame in pixels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
enum AVChromaLocation chroma_location
enum AVColorRange color_range
Additional colorspace characteristics.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int64_t duration
Decoding: duration of the stream, in stream time base.
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int64_t data_offset
offset of the first packet
#define Y4M_FRAME_MAGIC_LEN
static int yuv4_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
static int yuv4_read_header(AVFormatContext *s)
static int yuv4_probe(const AVProbeData *pd)
static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
#define MAX_PIX_FMT_LENGTH