diff options
author | Andreas Huber <andih@google.com> | 2010-10-08 10:38:39 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-10-08 10:38:39 -0700 |
commit | 6934207ac3cb850c9e548c48063956a7998ff2ed (patch) | |
tree | d0cf98704ffefd1cb066b1a85c2eae39f5fb46f7 /media/libstagefright | |
parent | bb245d35b6e81d750a91815543973b0a5976352b (diff) | |
download | frameworks_base-6934207ac3cb850c9e548c48063956a7998ff2ed.zip frameworks_base-6934207ac3cb850c9e548c48063956a7998ff2ed.tar.gz frameworks_base-6934207ac3cb850c9e548c48063956a7998ff2ed.tar.bz2 |
Respect the cropping rectangle when extracting the video dimensions from the sequence parameter set of H.264 streams.
Change-Id: Id7f21d5ab8533b4e17ceaa8619a39c27f0306150
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/avc_utils.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp index a8f1104..8762d29 100644 --- a/media/libstagefright/avc_utils.cpp +++ b/media/libstagefright/avc_utils.cpp @@ -41,10 +41,12 @@ void FindAVCDimensions( br.skipBits(16); parseUE(&br); // seq_parameter_set_id + unsigned chroma_format_idc = 1; // 4:2:0 chroma format + if (profile_idc == 100 || profile_idc == 110 || profile_idc == 122 || profile_idc == 244 || profile_idc == 44 || profile_idc == 83 || profile_idc == 86) { - unsigned chroma_format_idc = parseUE(&br); + chroma_format_idc = parseUE(&br); if (chroma_format_idc == 3) { br.skipBits(1); // residual_colour_transform_flag } @@ -85,6 +87,41 @@ void FindAVCDimensions( *height = (2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 * 16 + 16); + + if (!frame_mbs_only_flag) { + br.getBits(1); // mb_adaptive_frame_field_flag + } + + br.getBits(1); // direct_8x8_inference_flag + + if (br.getBits(1)) { // frame_cropping_flag + unsigned frame_crop_left_offset = parseUE(&br); + unsigned frame_crop_right_offset = parseUE(&br); + unsigned frame_crop_top_offset = parseUE(&br); + unsigned frame_crop_bottom_offset = parseUE(&br); + + unsigned cropUnitX, cropUnitY; + if (chroma_format_idc == 0 /* monochrome */) { + cropUnitX = 1; + cropUnitY = 2 - frame_mbs_only_flag; + } else { + unsigned subWidthC = (chroma_format_idc == 3) ? 1 : 2; + unsigned subHeightC = (chroma_format_idc == 1) ? 2 : 1; + + cropUnitX = subWidthC; + cropUnitY = subHeightC * (2 - frame_mbs_only_flag); + } + + LOGV("frame_crop = (%u, %u, %u, %u), cropUnitX = %u, cropUnitY = %u", + frame_crop_left_offset, frame_crop_right_offset, + frame_crop_top_offset, frame_crop_bottom_offset, + cropUnitX, cropUnitY); + + *width -= + (frame_crop_left_offset + frame_crop_right_offset) * cropUnitX; + *height -= + (frame_crop_top_offset + frame_crop_bottom_offset) * cropUnitY; + } } } // namespace android |