26 #define Y4M_MAGIC "YUV4MPEG2"
27 #define Y4M_FRAME_MAGIC "FRAME"
28 #define Y4M_LINE_MAX 256
30 #if CONFIG_YUV4MPEGPIPE_MUXER
35 int raten, rated, aspectn, aspectd,
n;
49 if (aspectn == 0 && aspectd == 1)
65 colorspace =
" Cmono";
68 colorspace =
" Cmono16";
71 colorspace =
" C411 XYSCSS=411";
77 default: colorspace =
" C420jpeg XYSCSS=420JPEG";
break;
81 colorspace =
" C422 XYSCSS=422";
84 colorspace =
" C444 XYSCSS=444";
87 colorspace =
" C420p9 XYSCSS=420P9";
90 colorspace =
" C422p9 XYSCSS=422P9";
93 colorspace =
" C444p9 XYSCSS=444P9";
96 colorspace =
" C420p10 XYSCSS=420P10";
99 colorspace =
" C422p10 XYSCSS=422P10";
102 colorspace =
" C444p10 XYSCSS=444P10";
105 colorspace =
" C420p12 XYSCSS=420P12";
108 colorspace =
" C422p12 XYSCSS=422P12";
111 colorspace =
" C444p12 XYSCSS=444P12";
114 colorspace =
" C420p14 XYSCSS=420P14";
117 colorspace =
" C422p14 XYSCSS=422P14";
120 colorspace =
" C444p14 XYSCSS=444P14";
123 colorspace =
" C420p16 XYSCSS=420P16";
126 colorspace =
" C422p16 XYSCSS=422P16";
129 colorspace =
" C444p16 XYSCSS=444P16";
135 Y4M_MAGIC, width, height, raten, rated, inter,
136 aspectn, aspectd, colorspace);
154 picture = &picture_tmp;
159 if (yuv4_generate_header(s, buf2) < 0) {
161 "Error. YUV4MPEG stream header write failed.\n");
176 ptr = picture->
data[0];
209 for (i = 0; i <
height; i++) {
222 ptr1 = picture->
data[1];
223 ptr2 = picture->
data[2];
224 for (i = 0; i <
height; i++) {
228 for (i = 0; i <
height; i++) {
252 "stream, some mjpegtools might not work.\n");
277 "Use '-strict -1' to encode to this pixel format.\n",
282 "Mjpegtools will not work.\n");
286 "yuv444p, yuv422p, yuv420p, yuv411p and gray8 pixel formats. "
287 "And using 'strict -1' also yuv444p9, yuv422p9, yuv420p9, "
288 "yuv444p10, yuv422p10, yuv420p10, "
289 "yuv444p12, yuv422p12, yuv420p12, "
290 "yuv444p14, yuv422p14, yuv420p14, "
291 "yuv444p16, yuv422p16, yuv420p16 "
292 "and gray16 pixel formats. "
293 "Use -pix_fmt to select one.\n");
302 .
name =
"yuv4mpegpipe",
305 .priv_data_size =
sizeof(int),
315 #define MAX_YUV4_HEADER 80
316 #define MAX_FRAME_HEADER 80
322 char *tokstart, *tokend, *header_end, interlaced =
'?';
325 int width = -1, height = -1, raten = 0,
326 rated = 0, aspectn = 0, aspectd = 0;
333 if (header[i] ==
'\n') {
334 header[i + 1] = 0x20;
340 if (i == MAX_YUV4_HEADER)
345 header_end = &header[i + 1];
346 for (tokstart = &header[strlen(
Y4M_MAGIC) + 1];
347 tokstart < header_end; tokstart++) {
348 if (*tokstart == 0x20)
350 switch (*tokstart++) {
352 width = strtol(tokstart, &tokend, 10);
356 height = strtol(tokstart, &tokend, 10);
360 if (strncmp(
"420jpeg", tokstart, 7) == 0) {
363 }
else if (strncmp(
"420mpeg2", tokstart, 8) == 0) {
366 }
else if (strncmp(
"420paldv", tokstart, 8) == 0) {
369 }
else if (strncmp(
"420p16", tokstart, 6) == 0) {
371 }
else if (strncmp(
"422p16", tokstart, 6) == 0) {
373 }
else if (strncmp(
"444p16", tokstart, 6) == 0) {
375 }
else if (strncmp(
"420p14", tokstart, 6) == 0) {
377 }
else if (strncmp(
"422p14", tokstart, 6) == 0) {
379 }
else if (strncmp(
"444p14", tokstart, 6) == 0) {
381 }
else if (strncmp(
"420p12", tokstart, 6) == 0) {
383 }
else if (strncmp(
"422p12", tokstart, 6) == 0) {
385 }
else if (strncmp(
"444p12", tokstart, 6) == 0) {
387 }
else if (strncmp(
"420p10", tokstart, 6) == 0) {
389 }
else if (strncmp(
"422p10", tokstart, 6) == 0) {
391 }
else if (strncmp(
"444p10", tokstart, 6) == 0) {
393 }
else if (strncmp(
"420p9", tokstart, 5) == 0) {
395 }
else if (strncmp(
"422p9", tokstart, 5) == 0) {
397 }
else if (strncmp(
"444p9", tokstart, 5) == 0) {
399 }
else if (strncmp(
"420", tokstart, 3) == 0) {
402 }
else if (strncmp(
"411", tokstart, 3) == 0) {
404 }
else if (strncmp(
"422", tokstart, 3) == 0) {
406 }
else if (strncmp(
"444alpha", tokstart, 8) == 0 ) {
408 "YUV4MPEG stream.\n");
410 }
else if (strncmp(
"444", tokstart, 3) == 0) {
412 }
else if (strncmp(
"mono16", tokstart, 6) == 0) {
414 }
else if (strncmp(
"mono", tokstart, 4) == 0) {
421 while (tokstart < header_end && *tokstart != 0x20)
425 interlaced = *tokstart++;
428 sscanf(tokstart,
"%d:%d", &raten, &rated);
429 while (tokstart < header_end && *tokstart != 0x20)
433 sscanf(tokstart,
"%d:%d", &aspectn, &aspectd);
434 while (tokstart < header_end && *tokstart != 0x20)
438 if (strncmp(
"YSCSS=", tokstart, 6) == 0) {
441 if (strncmp(
"420JPEG", tokstart, 7) == 0)
443 else if (strncmp(
"420MPEG2", tokstart, 8) == 0)
445 else if (strncmp(
"420PALDV", tokstart, 8) == 0)
447 else if (strncmp(
"420P9", tokstart, 5) == 0)
449 else if (strncmp(
"422P9", tokstart, 5) == 0)
451 else if (strncmp(
"444P9", tokstart, 5) == 0)
453 else if (strncmp(
"420P10", tokstart, 6) == 0)
455 else if (strncmp(
"422P10", tokstart, 6) == 0)
457 else if (strncmp(
"444P10", tokstart, 6) == 0)
459 else if (strncmp(
"420P12", tokstart, 6) == 0)
461 else if (strncmp(
"422P12", tokstart, 6) == 0)
463 else if (strncmp(
"444P12", tokstart, 6) == 0)
465 else if (strncmp(
"420P14", tokstart, 6) == 0)
467 else if (strncmp(
"422P14", tokstart, 6) == 0)
469 else if (strncmp(
"444P14", tokstart, 6) == 0)
471 else if (strncmp(
"420P16", tokstart, 6) == 0)
473 else if (strncmp(
"422P16", tokstart, 6) == 0)
475 else if (strncmp(
"444P16", tokstart, 6) == 0)
477 else if (strncmp(
"411", tokstart, 3) == 0)
479 else if (strncmp(
"422", tokstart, 3) == 0)
481 else if (strncmp(
"444", tokstart, 3) == 0)
484 while (tokstart < header_end && *tokstart != 0x20)
490 if (width == -1 || height == -1) {
499 pix_fmt = alt_pix_fmt;
502 if (raten <= 0 || rated <= 0) {
508 if (aspectn == 0 && aspectd == 0) {
518 av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
538 "interlaced and non-interlaced frames.\n");
559 if (header[i] ==
'\n') {
568 else if (i == MAX_FRAME_HEADER)
584 else if (ret != packet_size)
600 #if CONFIG_YUV4MPEGPIPE_DEMUXER
602 .
name =
"yuv4mpegpipe",