27 #define Y4M_MAGIC "YUV4MPEG2" 28 #define Y4M_FRAME_MAGIC "FRAME" 29 #define Y4M_LINE_MAX 256 31 #if CONFIG_YUV4MPEGPIPE_MUXER 36 int raten, rated, aspectn, aspectd,
n;
50 if (aspectn == 0 && aspectd == 1)
66 colorspace =
" Cmono";
69 colorspace =
" Cmono16";
72 colorspace =
" C411 XYSCSS=411";
78 default: colorspace =
" C420jpeg XYSCSS=420JPEG";
break;
82 colorspace =
" C422 XYSCSS=422";
85 colorspace =
" C444 XYSCSS=444";
88 colorspace =
" C420p9 XYSCSS=420P9";
91 colorspace =
" C422p9 XYSCSS=422P9";
94 colorspace =
" C444p9 XYSCSS=444P9";
97 colorspace =
" C420p10 XYSCSS=420P10";
100 colorspace =
" C422p10 XYSCSS=422P10";
103 colorspace =
" C444p10 XYSCSS=444P10";
106 colorspace =
" C420p12 XYSCSS=420P12";
109 colorspace =
" C422p12 XYSCSS=422P12";
112 colorspace =
" C444p12 XYSCSS=444P12";
115 colorspace =
" C420p14 XYSCSS=420P14";
118 colorspace =
" C422p14 XYSCSS=422P14";
121 colorspace =
" C444p14 XYSCSS=444P14";
124 colorspace =
" C420p16 XYSCSS=420P16";
127 colorspace =
" C422p16 XYSCSS=422P16";
130 colorspace =
" C444p16 XYSCSS=444P16";
136 Y4M_MAGIC, width, height, raten, rated, inter,
137 aspectn, aspectd, colorspace);
155 picture = &picture_tmp;
160 if (yuv4_generate_header(s, buf2) < 0) {
162 "Error. YUV4MPEG stream header write failed.\n");
177 ptr = picture->
data[0];
210 for (i = 0; i <
height; i++) {
220 width >>= h_chroma_shift;
221 height >>= v_chroma_shift;
223 ptr1 = picture->
data[1];
224 ptr2 = picture->
data[2];
225 for (i = 0; i <
height; i++) {
229 for (i = 0; i <
height; i++) {
253 "stream, some mjpegtools might not work.\n");
278 "Use '-strict -1' to encode to this pixel format.\n",
283 "Mjpegtools will not work.\n");
287 "yuv444p, yuv422p, yuv420p, yuv411p and gray8 pixel formats. " 288 "And using 'strict -1' also yuv444p9, yuv422p9, yuv420p9, " 289 "yuv444p10, yuv422p10, yuv420p10, " 290 "yuv444p12, yuv422p12, yuv420p12, " 291 "yuv444p14, yuv422p14, yuv420p14, " 292 "yuv444p16, yuv422p16, yuv420p16 " 293 "and gray16 pixel formats. " 294 "Use -pix_fmt to select one.\n");
303 .
name =
"yuv4mpegpipe",
306 .priv_data_size =
sizeof(int),
316 #define MAX_YUV4_HEADER 80 317 #define MAX_FRAME_HEADER 80 323 char *tokstart, *tokend, *header_end, interlaced =
'?';
327 rated = 0, aspectn = 0, aspectd = 0;
334 if (header[i] ==
'\n') {
335 header[i + 1] = 0x20;
341 if (i == MAX_YUV4_HEADER)
346 header_end = &header[i + 1];
347 for (tokstart = &header[strlen(
Y4M_MAGIC) + 1];
348 tokstart < header_end; tokstart++) {
349 if (*tokstart == 0x20)
351 switch (*tokstart++) {
353 width = strtol(tokstart, &tokend, 10);
357 height = strtol(tokstart, &tokend, 10);
361 if (strncmp(
"420jpeg", tokstart, 7) == 0) {
364 }
else if (strncmp(
"420mpeg2", tokstart, 8) == 0) {
367 }
else if (strncmp(
"420paldv", tokstart, 8) == 0) {
370 }
else if (strncmp(
"420p16", tokstart, 6) == 0) {
372 }
else if (strncmp(
"422p16", tokstart, 6) == 0) {
374 }
else if (strncmp(
"444p16", tokstart, 6) == 0) {
376 }
else if (strncmp(
"420p14", tokstart, 6) == 0) {
378 }
else if (strncmp(
"422p14", tokstart, 6) == 0) {
380 }
else if (strncmp(
"444p14", tokstart, 6) == 0) {
382 }
else if (strncmp(
"420p12", tokstart, 6) == 0) {
384 }
else if (strncmp(
"422p12", tokstart, 6) == 0) {
386 }
else if (strncmp(
"444p12", tokstart, 6) == 0) {
388 }
else if (strncmp(
"420p10", tokstart, 6) == 0) {
390 }
else if (strncmp(
"422p10", tokstart, 6) == 0) {
392 }
else if (strncmp(
"444p10", tokstart, 6) == 0) {
394 }
else if (strncmp(
"420p9", tokstart, 5) == 0) {
396 }
else if (strncmp(
"422p9", tokstart, 5) == 0) {
398 }
else if (strncmp(
"444p9", tokstart, 5) == 0) {
400 }
else if (strncmp(
"420", tokstart, 3) == 0) {
403 }
else if (strncmp(
"411", tokstart, 3) == 0) {
405 }
else if (strncmp(
"422", tokstart, 3) == 0) {
407 }
else if (strncmp(
"444alpha", tokstart, 8) == 0 ) {
409 "YUV4MPEG stream.\n");
411 }
else if (strncmp(
"444", tokstart, 3) == 0) {
413 }
else if (strncmp(
"mono16", tokstart, 6) == 0) {
415 }
else if (strncmp(
"mono", tokstart, 4) == 0) {
422 while (tokstart < header_end && *tokstart != 0x20)
426 interlaced = *tokstart++;
429 sscanf(tokstart,
"%d:%d", &raten, &rated);
430 while (tokstart < header_end && *tokstart != 0x20)
434 sscanf(tokstart,
"%d:%d", &aspectn, &aspectd);
435 while (tokstart < header_end && *tokstart != 0x20)
439 if (strncmp(
"YSCSS=", tokstart, 6) == 0) {
442 if (strncmp(
"420JPEG", tokstart, 7) == 0)
444 else if (strncmp(
"420MPEG2", tokstart, 8) == 0)
446 else if (strncmp(
"420PALDV", tokstart, 8) == 0)
448 else if (strncmp(
"420P9", tokstart, 5) == 0)
450 else if (strncmp(
"422P9", tokstart, 5) == 0)
452 else if (strncmp(
"444P9", tokstart, 5) == 0)
454 else if (strncmp(
"420P10", tokstart, 6) == 0)
456 else if (strncmp(
"422P10", tokstart, 6) == 0)
458 else if (strncmp(
"444P10", tokstart, 6) == 0)
460 else if (strncmp(
"420P12", tokstart, 6) == 0)
462 else if (strncmp(
"422P12", tokstart, 6) == 0)
464 else if (strncmp(
"444P12", tokstart, 6) == 0)
466 else if (strncmp(
"420P14", tokstart, 6) == 0)
468 else if (strncmp(
"422P14", tokstart, 6) == 0)
470 else if (strncmp(
"444P14", tokstart, 6) == 0)
472 else if (strncmp(
"420P16", tokstart, 6) == 0)
474 else if (strncmp(
"422P16", tokstart, 6) == 0)
476 else if (strncmp(
"444P16", tokstart, 6) == 0)
478 else if (strncmp(
"411", tokstart, 3) == 0)
480 else if (strncmp(
"422", tokstart, 3) == 0)
482 else if (strncmp(
"444", tokstart, 3) == 0)
485 while (tokstart < header_end && *tokstart != 0x20)
491 if (width == -1 ||
height == -1) {
500 pix_fmt = alt_pix_fmt;
503 if (raten <= 0 || rated <= 0) {
509 if (aspectn == 0 && aspectd == 0) {
519 av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
539 "interlaced and non-interlaced frames.\n");
560 if (header[i] ==
'\n') {
569 else if (i == MAX_FRAME_HEADER)
585 else if (ret != packet_size)
601 #if CONFIG_YUV4MPEGPIPE_DEMUXER 603 .
name =
"yuv4mpegpipe",
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
#define AV_PIX_FMT_YUV444P14
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
AVFrame * coded_frame
the picture in the bitstream
#define AV_LOG_WARNING
Something somehow does not look correct.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_PIX_FMT_YUV420P12
AVChromaLocation
X X 3 4 X X are luma samples, 1 2 1-6 are possible chroma positions X X 5 6 X 0 is undefined/unknown ...
four components are given, that's all.
static int yuv4_probe(AVProbeData *pd)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
uint8_t * data[AV_NUM_DATA_POINTERS]
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
enum AVPixelFormat pix_fmt
#define AV_PIX_FMT_YUV444P16
int interlaced_frame
The content of the picture is interlaced.
#define AV_PIX_FMT_YUV422P12
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define FF_COMPLIANCE_NORMAL
void av_log(void *avcl, int level, const char *fmt,...)
#define AV_PIX_FMT_YUV444P10
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
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.
unsigned int nb_streams
A list of all streams in the file.
#define AV_PIX_FMT_YUV422P9
struct AVRational AVRational
rational number numerator/denominator
#define AV_PIX_FMT_GRAY16
int width
picture width / height.
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P14
enum AVMediaType codec_type
AVIOContext * pb
I/O context.
static int yuv4_read_header(AVFormatContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
BYTE int const BYTE int int int height
#define AV_PIX_FMT_YUV420P10
synthesis window for stochastic i
#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.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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.Buffer references ownership and permissions
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
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
int top_field_first
If the content is interlaced, is top field displayed first.
void * priv_data
Format private data.
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...
static void write_header(FFV1Context *f)
enum AVFieldOrder field_order
Field order.
static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
enum AVColorSpace colorspace
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVPixelFormat
Pixel format.
This structure stores compressed data.
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
#define AV_PIX_FMT_YUV422P16