27 #define MAX_YUV4_HEADER 80
28 #define MAX_FRAME_HEADER 80
34 char *tokstart, *tokend, *header_end;
38 rated = 0, aspectn = 0, aspectd = 0;
46 if (header[i] ==
'\n') {
53 if (i == MAX_YUV4_HEADER)
58 header_end = &header[i + 1];
59 for (tokstart = &header[strlen(
Y4M_MAGIC) + 1];
60 tokstart < header_end; tokstart++) {
61 if (*tokstart == 0x20)
63 switch (*tokstart++) {
65 width = strtol(tokstart, &tokend, 10);
69 height = strtol(tokstart, &tokend, 10);
73 if (strncmp(
"420jpeg", tokstart, 7) == 0) {
76 }
else if (strncmp(
"420mpeg2", tokstart, 8) == 0) {
79 }
else if (strncmp(
"420paldv", tokstart, 8) == 0) {
82 }
else if (strncmp(
"420", tokstart, 3) == 0) {
85 }
else if (strncmp(
"411", tokstart, 3) == 0)
87 else if (strncmp(
"422", tokstart, 3) == 0)
89 else if (strncmp(
"444alpha", tokstart, 8) == 0 ) {
91 "YUV4MPEG stream.\n");
93 }
else if (strncmp(
"444", tokstart, 3) == 0)
95 else if (strncmp(
"mono", tokstart, 4) == 0) {
102 while (tokstart < header_end && *tokstart != 0x20)
106 switch (*tokstart++){
121 "interlaced and non-interlaced frames.\n");
129 sscanf(tokstart,
"%d:%d", &raten, &rated);
130 while (tokstart < header_end && *tokstart != 0x20)
134 sscanf(tokstart,
"%d:%d", &aspectn, &aspectd);
135 while (tokstart < header_end && *tokstart != 0x20)
139 if (strncmp(
"YSCSS=", tokstart, 6) == 0) {
142 if (strncmp(
"420JPEG", tokstart, 7) == 0)
144 else if (strncmp(
"420MPEG2", tokstart, 8) == 0)
146 else if (strncmp(
"420PALDV", tokstart, 8) == 0)
148 else if (strncmp(
"411", tokstart, 3) == 0)
150 else if (strncmp(
"422", tokstart, 3) == 0)
152 else if (strncmp(
"444", tokstart, 3) == 0)
155 while (tokstart < header_end && *tokstart != 0x20)
161 if (width == -1 ||
height == -1) {
170 pix_fmt = alt_pix_fmt;
173 if (raten <= 0 || rated <= 0) {
179 if (aspectn == 0 && aspectd == 0) {
189 av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
211 if (header[i] ==
'\n') {
220 else if (i == MAX_FRAME_HEADER)
236 else if (ret != packet_size)
253 .
name =
"yuv4mpegpipe",
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVCodecContext * codec
Codec context associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVChromaLocation
Location of chroma samples.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define AVERROR_EOF
End of file.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVRational avg_frame_rate
Average framerate.
AVPixelFormat
Pixel format.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int width
picture width / height.
AVStream ** streams
A list of all streams in the file.
enum AVPixelFormat pix_fmt
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
enum AVMediaType codec_type
static int yuv4_read_header(AVFormatContext *s)
AVIOContext * pb
I/O context.
rational number numerator/denominator
int error
contains the error code or 0 if no error happened
This structure contains the data a format has to probe a file.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int eof_reached
true if eof reached
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
Calculate the size in bytes that a picture of the given width and height would occupy if stored in th...
AVInputFormat ff_yuv4mpegpipe_demuxer
static int yuv4_probe(AVProbeData *pd)
enum AVFieldOrder field_order
Field order.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.