diff options
author | Andreas Huber <andih@google.com> | 2014-02-18 18:00:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-02-18 18:00:39 +0000 |
commit | 1ebd04b5f4ffe774c37054aac305cd9e6c73d2b2 (patch) | |
tree | da01a8fe51541c8c77faf8076fc91f79ddc066e1 | |
parent | 9a73cd3face153cbd04ceff0cfc0efdd4837b94e (diff) | |
parent | 6dc91c957cfad4393b205a3c2f8421e549fa7e85 (diff) | |
download | frameworks_av-1ebd04b5f4ffe774c37054aac305cd9e6c73d2b2.zip frameworks_av-1ebd04b5f4ffe774c37054aac305cd9e6c73d2b2.tar.gz frameworks_av-1ebd04b5f4ffe774c37054aac305cd9e6c73d2b2.tar.bz2 |
Merge "Skip scaling_list definitions in AVC seq header."
-rw-r--r-- | media/libstagefright/avc_utils.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp index c6ac0da..38a1f6b 100644 --- a/media/libstagefright/avc_utils.cpp +++ b/media/libstagefright/avc_utils.cpp @@ -40,6 +40,25 @@ unsigned parseUE(ABitReader *br) { return x + (1u << numZeroes) - 1; } +signed parseSE(ABitReader *br) { + unsigned codeNum = parseUE(br); + + return (codeNum & 1) ? (codeNum + 1) / 2 : -(codeNum / 2); +} + +static void skipScalingList(ABitReader *br, size_t sizeOfScalingList) { + size_t lastScale = 8; + size_t nextScale = 8; + for (size_t j = 0; j < sizeOfScalingList; ++j) { + if (nextScale != 0) { + signed delta_scale = parseSE(br); + nextScale = (lastScale + delta_scale + 256) % 256; + } + + lastScale = (nextScale == 0) ? lastScale : nextScale; + } +} + // Determine video dimensions from the sequence parameterset. void FindAVCDimensions( const sp<ABuffer> &seqParamSet, @@ -63,7 +82,24 @@ void FindAVCDimensions( parseUE(&br); // bit_depth_luma_minus8 parseUE(&br); // bit_depth_chroma_minus8 br.skipBits(1); // qpprime_y_zero_transform_bypass_flag - CHECK_EQ(br.getBits(1), 0u); // seq_scaling_matrix_present_flag + + if (br.getBits(1)) { // seq_scaling_matrix_present_flag + for (size_t i = 0; i < 8; ++i) { + if (br.getBits(1)) { // seq_scaling_list_present_flag[i] + + // WARNING: the code below has not ever been exercised... + // need a real-world example. + + if (i < 6) { + // ScalingList4x4[i],16,... + skipScalingList(&br, 16); + } else { + // ScalingList8x8[i-6],64,... + skipScalingList(&br, 64); + } + } + } + } } parseUE(&br); // log2_max_frame_num_minus4 |