25 #define Y4M_MAGIC "YUV4MPEG2"
26 #define Y4M_FRAME_MAGIC "FRAME"
27 #define Y4M_LINE_MAX 256
34 #if CONFIG_YUV4MPEGPIPE_MUXER
39 int raten, rated, aspectn, aspectd, n;
53 if (aspectn == 0 && aspectd == 1)
62 colorspace =
" Cmono";
65 colorspace =
" Cmono16";
68 colorspace =
" C411 XYSCSS=411";
74 default: colorspace =
" C420jpeg XYSCSS=420JPEG";
break;
78 colorspace =
" C422 XYSCSS=422";
81 colorspace =
" C444 XYSCSS=444";
84 colorspace =
" C420p9 XYSCSS=420P9";
87 colorspace =
" C422p9 XYSCSS=422P9";
90 colorspace =
" C444p9 XYSCSS=444P9";
93 colorspace =
" C420p10 XYSCSS=420P10";
96 colorspace =
" C422p10 XYSCSS=422P10";
99 colorspace =
" C444p10 XYSCSS=444P10";
102 colorspace =
" C420p12 XYSCSS=420P12";
105 colorspace =
" C422p12 XYSCSS=422P12";
108 colorspace =
" C444p12 XYSCSS=444P12";
111 colorspace =
" C420p14 XYSCSS=420P14";
114 colorspace =
" C422p14 XYSCSS=422P14";
117 colorspace =
" C444p14 XYSCSS=444P14";
120 colorspace =
" C420p16 XYSCSS=420P16";
123 colorspace =
" C422p16 XYSCSS=422P16";
126 colorspace =
" C444p16 XYSCSS=444P16";
132 Y4M_MAGIC, width, height, raten, rated, inter,
133 aspectn, aspectd, colorspace);
151 picture = &picture_tmp;
156 if (yuv4_generate_header(s, buf2) < 0) {
158 "Error. YUV4MPEG stream header write failed.\n");
173 ptr = picture->
data[0];
206 for (i = 0; i <
height; i++) {
216 width >>= h_chroma_shift;
217 height >>= v_chroma_shift;
219 ptr1 = picture->
data[1];
220 ptr2 = picture->
data[2];
221 for (i = 0; i <
height; i++) {
225 for (i = 0; i <
height; i++) {
250 "stream, some mjpegtools might not work.\n");
275 "Use '-strict -1' to encode to this pixel format.\n",
280 "Mjpegtools will not work.\n");
284 "yuv444p, yuv422p, yuv420p, yuv411p and gray8 pixel formats. "
285 "And using 'strict -1' also yuv444p9, yuv422p9, yuv420p9, "
286 "yuv444p10, yuv422p10, yuv420p10, "
287 "yuv444p12, yuv422p12, yuv420p12, "
288 "yuv444p14, yuv422p14, yuv420p14, "
289 "yuv444p16, yuv422p16, yuv420p16 "
290 "and gray16 pixel formats. "
291 "Use -pix_fmt to select one.\n");
300 .
name =
"yuv4mpegpipe",
303 .priv_data_size =
sizeof(int),
313 #define MAX_YUV4_HEADER 80
314 #define MAX_FRAME_HEADER 80
320 char *tokstart, *tokend, *header_end;
323 int width = -1, height = -1, raten = 0,
324 rated = 0, aspectn = 0, aspectd = 0;
332 if (header[i] ==
'\n') {
333 header[i + 1] = 0x20;
339 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 switch (*tokstart++){
442 "interlaced and non-interlaced frames.\n");
450 sscanf(tokstart,
"%d:%d", &raten, &rated);
451 while (tokstart < header_end && *tokstart != 0x20)
455 sscanf(tokstart,
"%d:%d", &aspectn, &aspectd);
456 while (tokstart < header_end && *tokstart != 0x20)
460 if (strncmp(
"YSCSS=", tokstart, 6) == 0) {
463 if (strncmp(
"420JPEG", tokstart, 7) == 0)
465 else if (strncmp(
"420MPEG2", tokstart, 8) == 0)
467 else if (strncmp(
"420PALDV", tokstart, 8) == 0)
469 else if (strncmp(
"420P9", tokstart, 5) == 0)
471 else if (strncmp(
"422P9", tokstart, 5) == 0)
473 else if (strncmp(
"444P9", tokstart, 5) == 0)
475 else if (strncmp(
"420P10", tokstart, 6) == 0)
477 else if (strncmp(
"422P10", tokstart, 6) == 0)
479 else if (strncmp(
"444P10", tokstart, 6) == 0)
481 else if (strncmp(
"420P12", tokstart, 6) == 0)
483 else if (strncmp(
"422P12", tokstart, 6) == 0)
485 else if (strncmp(
"444P12", tokstart, 6) == 0)
487 else if (strncmp(
"420P14", tokstart, 6) == 0)
489 else if (strncmp(
"422P14", tokstart, 6) == 0)
491 else if (strncmp(
"444P14", tokstart, 6) == 0)
493 else if (strncmp(
"420P16", tokstart, 6) == 0)
495 else if (strncmp(
"422P16", tokstart, 6) == 0)
497 else if (strncmp(
"444P16", tokstart, 6) == 0)
499 else if (strncmp(
"411", tokstart, 3) == 0)
501 else if (strncmp(
"422", tokstart, 3) == 0)
503 else if (strncmp(
"444", tokstart, 3) == 0)
506 while (tokstart < header_end && *tokstart != 0x20)
512 if (width == -1 || height == -1) {
521 pix_fmt = alt_pix_fmt;
524 if (raten <= 0 || rated <= 0) {
530 if (aspectn == 0 && aspectd == 0) {
540 av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
561 if (header[i] ==
'\n') {
570 else if (i == MAX_FRAME_HEADER)
586 else if (ret != packet_size)
607 #if CONFIG_YUV4MPEGPIPE_DEMUXER
609 .
name =
"yuv4mpegpipe",