Changeset 1170
- Timestamp:
- 10/21/09 23:18:10 (11 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
MatroskaImportPrivate.cpp (modified) (1 diff)
-
ff_private.c (modified) (3 diffs)
-
ff_private.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/MatroskaImportPrivate.cpp
r1149 r1170 472 472 473 473 set_track_clean_aperture_ext(imgDesc, width, height, IntToFixed(uint32(pxl_width)), IntToFixed(uint32(pxl_height))); 474 set_track_colorspace_ext(imgDesc, width, height); 474 475 mkvTrack.desc = (SampleDescriptionHandle) imgDesc; 475 476 -
trunk/ff_private.c
r1169 r1170 587 587 } 588 588 589 // Create the 'pasp' atom for video tracks. No guesswork required. 590 // References http://www.uwasa.fi/~f76998/video/conversion/ 589 591 void set_track_clean_aperture_ext(ImageDescriptionHandle imgDesc, Fixed displayW, Fixed displayH, Fixed pixelW, Fixed pixelH) 590 592 { … … 607 609 608 610 DisposeHandle((Handle)pasp); 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); 609 652 } 610 653 … … 647 690 initialize_video_map(&map[j], track, dataRef, dataRefType, storage->firstFrames + j); 648 691 set_track_clean_aperture_ext((ImageDescriptionHandle)map[j].sampleHdl, width, height, IntToFixed(st->codec->width), IntToFixed(st->codec->height)); 692 set_track_colorspace_ext((ImageDescriptionHandle)map[j].sampleHdl, width, height); 649 693 } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) { 650 694 if (st->codec->sample_rate > 0) { -
trunk/ff_private.h
r1052 r1170 113 113 Handle create_strf_ext(AVCodecContext *codec); 114 114 void set_track_clean_aperture_ext(ImageDescriptionHandle imgDesc, Fixed displayW, Fixed displayH, Fixed pixelW, Fixed pixelH); 115 void set_track_colorspace_ext(ImageDescriptionHandle imgDescHandle, Fixed displayW, Fixed displayH); 115 116 116 117 uint8_t *write_int32(uint8_t *target, int32_t data);
