diff options
author | damienv@chromium.org <damienv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-05 06:40:16 +0000 |
---|---|---|
committer | damienv@chromium.org <damienv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-05 06:40:16 +0000 |
commit | 07b1823108d51c9134f4130a047d1c582b6b9ea5 (patch) | |
tree | 6e23e136b1e7065661065a273c77565cc2312c06 | |
parent | b083ff9b8e003f5ba9045a2d076e5c805ff04e71 (diff) | |
download | chromium_src-07b1823108d51c9134f4130a047d1c582b6b9ea5.zip chromium_src-07b1823108d51c9134f4130a047d1c582b6b9ea5.tar.gz chromium_src-07b1823108d51c9134f4130a047d1c582b6b9ea5.tar.bz2 |
Add support for aspect ratio VUI parameters in H264Parser.
BUG=340426
Review URL: https://codereview.chromium.org/145973012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248880 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/filters/h264_parser.cc | 31 | ||||
-rw-r--r-- | media/filters/h264_parser.h | 2 |
2 files changed, 32 insertions, 1 deletions
diff --git a/media/filters/h264_parser.cc b/media/filters/h264_parser.cc index 67c2fe5..b559363 100644 --- a/media/filters/h264_parser.cc +++ b/media/filters/h264_parser.cc @@ -106,6 +106,21 @@ H264SEIMessage::H264SEIMessage() { } \ } while (0) +enum AspectRatioIdc { + kExtendedSar = 255, +}; + +// ISO 14496 part 10 +// VUI parameters: Table E-1 "Meaning of sample aspect ratio indicator" +static const int kTableSarWidth[] = { + 0, 1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2 +}; +static const int kTableSarHeight[] = { + 0, 1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1 +}; +COMPILE_ASSERT(arraysize(kTableSarWidth) == arraysize(kTableSarHeight), + sar_tables_must_have_same_size); + H264Parser::H264Parser() { Reset(); } @@ -672,7 +687,21 @@ H264Parser::Result H264Parser::ParseSPS(int* sps_id) { READ_BOOL_OR_RETURN(&sps->vui_parameters_present_flag); if (sps->vui_parameters_present_flag) { - DVLOG(1) << "VUI parameters present in SPS, ignoring"; + bool aspect_ratio_info_present_flag; + READ_BOOL_OR_RETURN(&aspect_ratio_info_present_flag); + if (aspect_ratio_info_present_flag) { + int aspect_ratio_idc; + READ_BITS_OR_RETURN(8, &aspect_ratio_idc); + if (aspect_ratio_idc == kExtendedSar) { + READ_BITS_OR_RETURN(16, &sps->sar_width); + READ_BITS_OR_RETURN(16, &sps->sar_height); + } else { + const int max_aspect_ratio_idc = arraysize(kTableSarWidth) - 1; + IN_RANGE_OR_RETURN(aspect_ratio_idc, 0, max_aspect_ratio_idc); + sps->sar_width = kTableSarWidth[aspect_ratio_idc]; + sps->sar_height = kTableSarHeight[aspect_ratio_idc]; + } + } } // If an SPS with the same id already exists, replace it. diff --git a/media/filters/h264_parser.h b/media/filters/h264_parser.h index 7f6eb3f..f336032 100644 --- a/media/filters/h264_parser.h +++ b/media/filters/h264_parser.h @@ -89,6 +89,8 @@ struct MEDIA_EXPORT H264SPS { int frame_crop_bottom_offset; bool vui_parameters_present_flag; int chroma_array_type; + int sar_width; // Set to 0 when not specified. + int sar_height; // Set to 0 when not specified. }; struct MEDIA_EXPORT H264PPS { |