diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2012-09-12 11:21:41 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2012-09-12 10:38:46 +0100 |
commit | a08273be72a01e9b1c2e0e2845bfca904908403f (patch) | |
tree | 5a67dc062712441f6b118d2d9e09239a0a551189 | |
parent | 585bd3ee210b421906c3fa7a136d12d53249dc12 (diff) | |
download | gstreamer-plugins-bad-a08273be72a01e9b1c2e0e2845bfca904908403f.tar.gz |
codecparsers: h264: compute pixel aspect ratio.
Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
-rw-r--r-- | gst-libs/gst/codecparsers/gsth264parser.c | 33 | ||||
-rw-r--r-- | gst-libs/gst/codecparsers/gsth264parser.h | 4 |
2 files changed, 37 insertions, 0 deletions
diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c index 2866e8ec7..6e3dfe2bc 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.c +++ b/gst-libs/gst/codecparsers/gsth264parser.c @@ -136,6 +136,32 @@ static const guint8 zigzag_4x4[16] = { 7, 11, 14, 15, }; +typedef struct +{ + guint par_n, par_d; +} PAR; + +/* Table E-1 - Meaning of sample aspect ratio indicator (1..16) */ +static PAR aspect_ratios[17] = { + {0, 0}, + {1, 1}, + {12, 11}, + {10, 11}, + {16, 11}, + {40, 33}, + {24, 11}, + {20, 11}, + {32, 11}, + {80, 33}, + {18, 11}, + {15, 11}, + {64, 33}, + {160, 99}, + {4, 3}, + {3, 2}, + {2, 1} +}; + /* Compute Ceil(Log2(v)) */ /* Derived from branchless code for integer log2(v) from: <http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog> */ @@ -552,6 +578,8 @@ gst_h264_parse_vui_parameters (GstH264SPS * sps, NalReader * nr) vui->chroma_sample_loc_type_top_field = 0; vui->chroma_sample_loc_type_bottom_field = 0; vui->low_delay_hrd_flag = 0; + vui->par_n = 0; + vui->par_d = 0; READ_UINT8 (nr, vui->aspect_ratio_info_present_flag, 1); if (vui->aspect_ratio_info_present_flag) { @@ -559,6 +587,11 @@ gst_h264_parse_vui_parameters (GstH264SPS * sps, NalReader * nr) if (vui->aspect_ratio_idc == EXTENDED_SAR) { READ_UINT16 (nr, vui->sar_width, 16); READ_UINT16 (nr, vui->sar_height, 16); + vui->par_n = vui->sar_width; + vui->par_d = vui->sar_height; + } else if (vui->aspect_ratio_idc <= 16) { + vui->par_n = aspect_ratios[vui->aspect_ratio_idc].par_n; + vui->par_d = aspect_ratios[vui->aspect_ratio_idc].par_d; } } diff --git a/gst-libs/gst/codecparsers/gsth264parser.h b/gst-libs/gst/codecparsers/gsth264parser.h index 2e570c8a9..bfcef5c88 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.h +++ b/gst-libs/gst/codecparsers/gsth264parser.h @@ -362,6 +362,10 @@ struct _GstH264VUIParams guint32 log2_max_mv_length_vertical; guint32 num_reorder_frames; guint32 max_dec_frame_buffering; + + /* calculated values */ + guint par_n; + guint par_d; }; /** |