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++) {
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 =
'?';
326 int width = -1, height = -1, raten = 0,
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",