| 523 | } |
| 524 | |
| 525 | static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) |
| 526 | { |
| 527 | const enum AVPixelFormat *fmts; |
| 528 | enum AVPixelFormat fmt; |
| 529 | int ret; |
| 530 | |
| 531 | fmt = av_get_pix_fmt(name); |
| 532 | if (fmt == AV_PIX_FMT_NONE) { |
| 533 | av_log(ost, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", name); |
| 534 | return AV_PIX_FMT_NONE; |
| 535 | } |
| 536 | |
| 537 | ret = avcodec_get_supported_config(ost->enc->enc_ctx, NULL, AV_CODEC_CONFIG_PIX_FORMAT, |
| 538 | 0, (const void **) &fmts, NULL); |
| 539 | if (ret < 0) |
| 540 | return AV_PIX_FMT_NONE; |
| 541 | |
| 542 | /* when the user specified-format is an alias for an endianness-specific |
| 543 | * one (e.g. rgb48 -> rgb48be/le), it gets translated into the native |
| 544 | * endianness by av_get_pix_fmt(); |
| 545 | * the following code handles the case when the native endianness is not |
| 546 | * supported by the encoder, but the other one is */ |
| 547 | if (fmts && !pixfmt_in_list(fmts, fmt)) { |
| 548 | const char *name_canonical = av_get_pix_fmt_name(fmt); |
| 549 | int len = strlen(name_canonical); |
| 550 | |
| 551 | if (strcmp(name, name_canonical) && |
| 552 | (!strcmp(name_canonical + len - 2, "le") || |
| 553 | !strcmp(name_canonical + len - 2, "be"))) { |
| 554 | char name_other[64]; |
| 555 | enum AVPixelFormat fmt_other; |
| 556 | |
| 557 | snprintf(name_other, sizeof(name_other), "%s%ce", |
| 558 | name, name_canonical[len - 2] == 'l' ? 'b' : 'l'); |
| 559 | fmt_other = av_get_pix_fmt(name_other); |
| 560 | if (fmt_other != AV_PIX_FMT_NONE && pixfmt_in_list(fmts, fmt_other)) { |
| 561 | av_log(ost, AV_LOG_VERBOSE, "Mapping pixel format %s->%s\n", |
| 562 | name, name_other); |
| 563 | fmt = fmt_other; |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | if (fmts && !pixfmt_in_list(fmts, fmt)) |
| 569 | fmt = choose_pixel_fmt(ost->enc->enc_ctx, fmt); |
| 570 | |
| 571 | return fmt; |
| 572 | } |
| 573 | |
| 574 | static int new_stream_video(Muxer *mux, const OptionsContext *o, |
| 575 | OutputStream *ost, int *keep_pix_fmt, |
no test coverage detected