| 507 | } |
| 508 | |
| 509 | void FFMS_VideoSource::ReAdjustOutputFormat(AVFrame *Frame) { |
| 510 | if (SWS) { |
| 511 | sws_freeContext(SWS); |
| 512 | SWS = nullptr; |
| 513 | } |
| 514 | |
| 515 | DetectInputFormat(); |
| 516 | |
| 517 | OutputFormat = FindBestPixelFormat(TargetPixelFormats, InputFormat); |
| 518 | if (OutputFormat == AV_PIX_FMT_NONE) { |
| 519 | ResetOutputFormat(); |
| 520 | throw FFMS_Exception(FFMS_ERROR_SCALING, FFMS_ERROR_INVALID_ARGUMENT, |
| 521 | "No suitable output format found"); |
| 522 | } |
| 523 | |
| 524 | OutputColorRange = handle_jpeg(&OutputFormat); |
| 525 | if (OutputColorRange == AVCOL_RANGE_UNSPECIFIED) |
| 526 | OutputColorRange = CodecContext->color_range; |
| 527 | if (OutputColorRange == AVCOL_RANGE_UNSPECIFIED) |
| 528 | OutputColorRange = InputColorRange; |
| 529 | |
| 530 | OutputColorSpace = CodecContext->colorspace; |
| 531 | if (OutputColorSpace == AVCOL_SPC_UNSPECIFIED) |
| 532 | OutputColorSpace = InputColorSpace; |
| 533 | |
| 534 | BCSType InputType = GuessCSType(InputFormat); |
| 535 | BCSType OutputType = GuessCSType(OutputFormat); |
| 536 | |
| 537 | if (InputType != OutputType) { |
| 538 | if (OutputType == cRGB) { |
| 539 | OutputColorSpace = AVCOL_SPC_RGB; |
| 540 | OutputColorRange = AVCOL_RANGE_UNSPECIFIED; |
| 541 | OutputColorPrimaries = AVCOL_PRI_UNSPECIFIED; |
| 542 | OutputTransferCharateristics = AVCOL_TRC_UNSPECIFIED; |
| 543 | OutputChromaLocation = AVCHROMA_LOC_UNSPECIFIED; |
| 544 | } else if (OutputType == cYUV) { |
| 545 | OutputColorSpace = AVCOL_SPC_BT470BG; |
| 546 | OutputColorRange = AVCOL_RANGE_MPEG; |
| 547 | OutputColorPrimaries = AVCOL_PRI_UNSPECIFIED; |
| 548 | OutputTransferCharateristics = AVCOL_TRC_UNSPECIFIED; |
| 549 | OutputChromaLocation = AVCHROMA_LOC_LEFT; |
| 550 | } else if (OutputType == cGRAY) { |
| 551 | OutputColorSpace = AVCOL_SPC_UNSPECIFIED; |
| 552 | OutputColorRange = AVCOL_RANGE_UNSPECIFIED; |
| 553 | OutputColorPrimaries = AVCOL_PRI_UNSPECIFIED; |
| 554 | OutputTransferCharateristics = AVCOL_TRC_UNSPECIFIED; |
| 555 | OutputChromaLocation = AVCHROMA_LOC_UNSPECIFIED; |
| 556 | } |
| 557 | } else { |
| 558 | OutputColorPrimaries = -1; |
| 559 | OutputTransferCharateristics = -1; |
| 560 | OutputChromaLocation = -1; |
| 561 | } |
| 562 | |
| 563 | if (InputFormat != OutputFormat || |
| 564 | TargetWidth != CodecContext->width || |
| 565 | TargetHeight != CodecContext->height || |
| 566 | InputColorSpace != OutputColorSpace || |
nothing calls this directly
no test coverage detected