summaryrefslogtreecommitdiffstats
path: root/libhb/decmpeg2.c
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-03-28 23:22:17 +0000
committerRodeo <[email protected]>2012-03-28 23:22:17 +0000
commit39425d02862f054e3ef87ef45b789254c64511ad (patch)
tree30583795947cec54860e51a8b675bfd29f03a26a /libhb/decmpeg2.c
parentcca9c898d2f57047ab2cdabee8c794ddf2775aa7 (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/decmpeg2.c')
-rw-r--r--libhb/decmpeg2.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c
index 7379964cf..82ba78e31 100644
--- a/libhb/decmpeg2.c
+++ b/libhb/decmpeg2.c
@@ -894,6 +894,82 @@ static int decmpeg2Info( hb_work_object_t *w, hb_work_info_t *info )
info->profile = m->info->sequence->profile_level_id >> 4;
info->level = m->info->sequence->profile_level_id & 0xf;
info->name = "mpeg2";
+
+ if( pv->libmpeg2->info->sequence->flags & SEQ_FLAG_COLOUR_DESCRIPTION )
+ {
+ switch( pv->libmpeg2->info->sequence->colour_primaries )
+ {
+ case 1: // ITU-R Recommendation 709
+ info->color_prim = HB_COLR_PRI_BT709;
+ break;
+ case 5: // ITU-R Recommendation 624-4 System B, G
+ info->color_prim = HB_COLR_PRI_EBUTECH;
+ break;
+ case 4: // ITU-R Recommendation 624-4 System M
+ case 6: // SMPTE 170M
+ case 7: // SMPTE 240M
+ info->color_prim = HB_COLR_PRI_SMPTEC;
+ break;
+ default:
+ info->color_prim = HB_COLR_PRI_UNDEF;
+ break;
+ }
+ switch( pv->libmpeg2->info->sequence->transfer_characteristics )
+ {
+ case 1: // ITU-R Recommendation 709
+ case 4: // ITU-R Recommendation 624-4 System M
+ case 5: // ITU-R Recommendation 624-4 System B, G
+ case 6: // SMPTE 170M
+ info->color_transfer = HB_COLR_TRA_BT709;
+ break;
+ case 7: // SMPTE 240M
+ info->color_transfer = HB_COLR_TRA_SMPTE240M;
+ break;
+ default:
+ info->color_transfer = HB_COLR_TRA_UNDEF;
+ break;
+ }
+ switch( pv->libmpeg2->info->sequence->matrix_coefficients )
+ {
+ case 1: // ITU-R Recommendation 709
+ info->color_matrix = HB_COLR_MAT_BT709;
+ break;
+ case 4: // FCC
+ case 5: // ITU-R Recommendation 624-4 System B, G
+ case 6: // SMPTE 170M
+ info->color_matrix = HB_COLR_MAT_SMPTE170M;
+ break;
+ case 7: // SMPTE 240M
+ info->color_matrix = HB_COLR_MAT_SMPTE240M;
+ break;
+ default:
+ info->color_matrix = HB_COLR_MAT_UNDEF;
+ break;
+ }
+ }
+ else 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;
+ info->color_transfer = HB_COLR_TRA_BT709;
+ info->color_matrix = HB_COLR_MAT_BT709;
+ }
+ else if( info->rate_base == 1080000 )
+ {
+ // ITU BT.601 DVD or SD TV content (PAL)
+ info->color_prim = HB_COLR_PRI_EBUTECH;
+ info->color_transfer = HB_COLR_TRA_BT709;
+ info->color_matrix = HB_COLR_MAT_SMPTE170M;
+ }
+ else
+ {
+ // ITU BT.601 DVD or SD TV content (NTSC)
+ info->color_prim = HB_COLR_PRI_SMPTEC;
+ info->color_transfer = HB_COLR_TRA_BT709;
+ info->color_matrix = HB_COLR_MAT_SMPTE170M;
+ }
+
return 1;
}
return 0;