| | 611 | } |
|---|
| | 612 | |
|---|
| | 613 | // Create the 'nclc' atom for video tracks. Guessed entirely from image size following ffdshow. |
|---|
| | 614 | // FIXME read H.264 VUI/MPEG2 etc and especially read chroma positioning information. |
|---|
| | 615 | // this needs the parsers working |
|---|
| | 616 | // References: http://developer.apple.com/quicktime/icefloe/dispatch019.html |
|---|
| | 617 | // http://www.mir.com/DMG/chroma.html |
|---|
| | 618 | void set_track_colorspace_ext(ImageDescriptionHandle imgDescHandle, Fixed displayW, Fixed displayH) |
|---|
| | 619 | { |
|---|
| | 620 | ImageDescription *imgDesc = *imgDescHandle; |
|---|
| | 621 | Boolean isHd, isPAL; // otherwise NTSC |
|---|
| | 622 | AVRational palRatio = (AVRational){5, 4}, displayRatio = (AVRational){displayW, displayH}; |
|---|
| | 623 | int colorPrimaries, transferFunction, yuvMatrix; |
|---|
| | 624 | |
|---|
| | 625 | isHd = imgDesc->height > 576; |
|---|
| | 626 | isPAL = imgDesc->height == 576 || av_cmp_q(palRatio, displayRatio) == 0; |
|---|
| | 627 | |
|---|
| | 628 | NCLCColorInfoImageDescriptionExtension **nclc = (NCLCColorInfoImageDescriptionExtension**)NewHandle(sizeof(NCLCColorInfoImageDescriptionExtension)); |
|---|
| | 629 | |
|---|
| | 630 | if (isHd) { |
|---|
| | 631 | colorPrimaries = kQTPrimaries_ITU_R709_2; |
|---|
| | 632 | transferFunction = kQTTransferFunction_ITU_R709_2; |
|---|
| | 633 | yuvMatrix = kQTMatrix_ITU_R_709_2; |
|---|
| | 634 | } else if (isPAL) { |
|---|
| | 635 | colorPrimaries = kQTPrimaries_EBU_3213; |
|---|
| | 636 | transferFunction = kQTTransferFunction_ITU_R709_2; |
|---|
| | 637 | yuvMatrix = kQTMatrix_ITU_R_601_4; |
|---|
| | 638 | } else { |
|---|
| | 639 | colorPrimaries = kQTPrimaries_SMPTE_C; |
|---|
| | 640 | transferFunction = kQTTransferFunction_ITU_R709_2; |
|---|
| | 641 | yuvMatrix = kQTMatrix_ITU_R_601_4; |
|---|
| | 642 | } |
|---|
| | 643 | |
|---|
| | 644 | **nclc = (NCLCColorInfoImageDescriptionExtension){EndianU32_NtoB(kVideoColorInfoImageDescriptionExtensionType), |
|---|
| | 645 | EndianU16_NtoB(colorPrimaries), |
|---|
| | 646 | EndianU16_NtoB(transferFunction), |
|---|
| | 647 | EndianU16_NtoB(yuvMatrix)}; |
|---|
| | 648 | |
|---|
| | 649 | AddImageDescriptionExtension(imgDescHandle, (Handle)nclc, kColorInfoImageDescriptionExtension); |
|---|
| | 650 | |
|---|
| | 651 | DisposeHandle((Handle)nclc); |
|---|