29 #define MAX_YUV4_HEADER 80 30 #define MAX_FRAME_HEADER 80 36 char *tokstart, *tokend, *header_end;
40 rated = 0, aspectn = 0, aspectd = 0;
48 if (header[i] ==
'\n') {
55 if (i == MAX_YUV4_HEADER)
60 header_end = &header[i + 1];
61 for (tokstart = &header[strlen(
Y4M_MAGIC) + 1];
62 tokstart < header_end; tokstart++) {
63 if (*tokstart == 0x20)
65 switch (*tokstart++) {
67 width = strtol(tokstart, &tokend, 10);
71 height = strtol(tokstart, &tokend, 10);
75 if (strncmp(
"420jpeg", tokstart, 7) == 0) {
78 }
else if (strncmp(
"420mpeg2", tokstart, 8) == 0) {
81 }
else if (strncmp(
"420paldv", tokstart, 8) == 0) {
84 }
else if (strncmp(
"420", tokstart, 3) == 0) {
87 }
else if (strncmp(
"411", tokstart, 3) == 0)
89 else if (strncmp(
"422", tokstart, 3) == 0)
91 else if (strncmp(
"444alpha", tokstart, 8) == 0 ) {
93 "YUV4MPEG stream.\n");
95 }
else if (strncmp(
"444", tokstart, 3) == 0)
97 else if (strncmp(
"mono", tokstart, 4) == 0) {
104 while (tokstart < header_end && *tokstart != 0x20)
108 switch (*tokstart++){
123 "interlaced and non-interlaced frames.\n");
131 sscanf(tokstart,
"%d:%d", &raten, &rated);
132 while (tokstart < header_end && *tokstart != 0x20)
136 sscanf(tokstart,
"%d:%d", &aspectn, &aspectd);
137 while (tokstart < header_end && *tokstart != 0x20)
141 if (strncmp(
"YSCSS=", tokstart, 6) == 0) {
144 if (strncmp(
"420JPEG", tokstart, 7) == 0)
146 else if (strncmp(
"420MPEG2", tokstart, 8) == 0)
148 else if (strncmp(
"420PALDV", tokstart, 8) == 0)
150 else if (strncmp(
"411", tokstart, 3) == 0)
152 else if (strncmp(
"422", tokstart, 3) == 0)
154 else if (strncmp(
"444", tokstart, 3) == 0)
157 while (tokstart < header_end && *tokstart != 0x20)
163 if (width == -1 ||
height == -1) {
172 pix_fmt = alt_pix_fmt;
175 if (raten <= 0 || rated <= 0) {
181 if (aspectn == 0 && aspectd == 0) {
191 av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
213 if (header[i] ==
'\n') {
222 else if (i == MAX_FRAME_HEADER)
239 else if (ret != packet_size)
256 .
name =
"yuv4mpegpipe",
enum AVChromaLocation chroma_location
enum AVFieldOrder field_order
Video only.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
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.
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)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
enum AVPixelFormat pix_fmt
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.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int eof_reached
true if eof reached
AVInputFormat ff_yuv4mpegpipe_demuxer
static int yuv4_probe(AVProbeData *pd)
AVChromaLocation
Location of chroma samples.
AVCodecParameters * codecpar
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
AVPixelFormat
Pixel format.
This structure stores compressed data.