diff options
author | Rodeo <[email protected]> | 2012-03-28 23:22:17 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-03-28 23:22:17 +0000 |
commit | 39425d02862f054e3ef87ef45b789254c64511ad (patch) | |
tree | 30583795947cec54860e51a8b675bfd29f03a26a /libhb/decavcodec.c | |
parent | cca9c898d2f57047ab2cdabee8c794ddf2775aa7 (diff) |
libhb: use source colorimetry information when available.
When source colorimetry can't be determined, guess.
Added code to guess PAL SD content and updated code to guess HD content.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4552 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decavcodec.c')
-rw-r--r-- | libhb/decavcodec.c | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 1bba19990..33b45fa12 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -1336,11 +1336,77 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info ) info->level = pv->context->level; info->name = pv->context->codec->name; + switch( pv->context->color_primaries ) + { + case AVCOL_PRI_BT709: + info->color_prim = HB_COLR_PRI_BT709; + break; + case AVCOL_PRI_BT470BG: + info->color_prim = HB_COLR_PRI_EBUTECH; + break; + case AVCOL_PRI_BT470M: + case AVCOL_PRI_SMPTE170M: + case AVCOL_PRI_SMPTE240M: + info->color_prim = HB_COLR_PRI_SMPTEC; + break; + default: + { + if( ( info->width >= 1280 || info->height >= 720 ) || + ( info->width > 720 && info->height > 576 ) ) + // ITU BT.709 HD content + info->color_prim = HB_COLR_PRI_BT709; + else if( info->rate_base == 1080000 ) + // ITU BT.601 DVD or SD TV content (PAL) + info->color_prim = HB_COLR_PRI_EBUTECH; + else + // ITU BT.601 DVD or SD TV content (NTSC) + info->color_prim = HB_COLR_PRI_SMPTEC; + break; + } + } + + /* AVCOL_TRC_BT709 -> HB_COLR_TRA_BT709 + * AVCOL_TRC_GAMMA22 (bt470m) -> HB_COLR_TRA_BT709 + * AVCOL_TRC_GAMMA28 (bt470bg) -> HB_COLR_TRA_BT709 + * AVCOL_TRC_UNSPECIFIED, AVCOL_TRC_NB: + * -> ITU BT.709 -> HB_COLR_TRA_BT709 + * -> ITU BT.601 -> HB_COLR_TRA_BT709 + * TODO: AVCOL_TRC_SMPTE240M -> HB_COLR_TRA_SMPTE240M but it's not yet in Libav */ + info->color_transfer = HB_COLR_TRA_BT709; + + switch( pv->context->colorspace ) + { + case AVCOL_SPC_BT709: + info->color_matrix = HB_COLR_MAT_BT709; + break; + case AVCOL_SPC_FCC: + case AVCOL_SPC_BT470BG: + case AVCOL_SPC_SMPTE170M: + case AVCOL_SPC_RGB: // libswscale rgb2yuv + info->color_matrix = HB_COLR_MAT_SMPTE170M; + break; + case AVCOL_SPC_SMPTE240M: + info->color_matrix = HB_COLR_MAT_SMPTE240M; + break; + default: + { + if( ( info->width >= 1280 || info->height >= 720 ) || + ( info->width > 720 && info->height > 576 ) ) + // ITU BT.709 HD content + info->color_matrix = HB_COLR_MAT_BT709; + else + // ITU BT.601 DVD or SD TV content (PAL) + // ITU BT.601 DVD or SD TV content (NTSC) + info->color_matrix = HB_COLR_MAT_SMPTE170M; + break; + } + } + return 1; } static int decavcodecvBSInfo( hb_work_object_t *w, const hb_buffer_t *buf, - hb_work_info_t *info ) + hb_work_info_t *info ) { return 0; } |