--- a/media/libstagefright/binding/H264.cpp
+++ b/media/libstagefright/binding/H264.cpp
@@ -176,37 +176,16 @@ SPSData::SPSData()
video_format = 5;
colour_primaries = 2;
transfer_characteristics = 2;
sample_ratio = 1.0;
memset(scaling_matrix4x4, 16, sizeof(scaling_matrix4x4));
memset(scaling_matrix8x8, 16, sizeof(scaling_matrix8x8));
}
-PPSData::PPSData()
-{
- PodZero(this);
- memset(scaling_matrix4x4, 16, sizeof(scaling_matrix4x4));
- memset(scaling_matrix8x8, 16, sizeof(scaling_matrix8x8));
-}
-
-const uint8_t H264::ZZ_SCAN[16] = { 0, 1, 4, 8,
- 5, 2, 3, 6,
- 9, 12, 13, 10,
- 7, 11, 14, 15 };
-
-const uint8_t H264::ZZ_SCAN8[64] = { 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63 };
-
/* static */ already_AddRefed<mozilla::MediaByteBuffer>
H264::DecodeNALUnit(const mozilla::MediaByteBuffer* aNAL)
{
MOZ_ASSERT(aNAL);
if (aNAL->Length() < 4) {
return nullptr;
}
@@ -602,79 +581,56 @@ H264::vui_parameters(BitReader& aBr, SPS
}
return true;
}
/* static */ bool
H264::DecodeSPSFromExtraData(const mozilla::MediaByteBuffer* aExtraData,
SPSData& aDest)
{
- H264ParametersSet ps;
- if (!DecodeSPSDataSetFromExtraData(aExtraData, ps.SPSes)) {
- return false;
- }
-
- uint16_t spsId = 0;
- if (DecodePPSDataSetFromExtraData(aExtraData, ps.SPSes, ps.PPSes)) {
- // We can't know which PPS is in use without parsing slice header if we
- // have multiple PPSes, so we always use the first one.
- spsId = ps.PPSes[0].seq_parameter_set_id;
- }
-
- aDest = Move(ps.SPSes[spsId]);
- return true;
-}
-
-/* static */ bool
-H264::DecodeSPSDataSetFromExtraData(const mozilla::MediaByteBuffer* aExtraData,
- SPSDataSet& aDest)
-{
if (!AnnexB::HasSPS(aExtraData)) {
return false;
}
ByteReader reader(aExtraData);
if (!reader.Read(5)) {
return false;
}
uint8_t numSps = reader.ReadU8() & 0x1f;
if (!numSps) {
// No SPS.
return false;
}
- for (uint32_t idx = 0; idx < numSps; idx++) {
- uint16_t length = reader.ReadU16();
+ if (numSps > 1) {
+ NS_WARNING("Multiple SPS, only decoding the first one");
+ }
- if ((reader.PeekU8() & 0x1f) != H264_NAL_SPS) {
- // Not a SPS NAL type.
- return false;
- }
- const uint8_t* ptr = reader.Read(length);
- if (!ptr) {
- return false;
- }
+ uint16_t length = reader.ReadU16();
- RefPtr<mozilla::MediaByteBuffer> rawNAL = new mozilla::MediaByteBuffer;
- rawNAL->AppendElements(ptr, length);
-
- RefPtr<mozilla::MediaByteBuffer> sps = DecodeNALUnit(rawNAL);
+ if ((reader.PeekU8() & 0x1f) != H264_NAL_SPS) {
+ // Not a SPS NAL type.
+ return false;
+ }
+ const uint8_t* ptr = reader.Read(length);
+ if (!ptr) {
+ return false;
+ }
- if (!sps) {
- return false;
- }
+ RefPtr<mozilla::MediaByteBuffer> rawNAL = new mozilla::MediaByteBuffer;
+ rawNAL->AppendElements(ptr, length);
+
+ RefPtr<mozilla::MediaByteBuffer> sps = DecodeNALUnit(rawNAL);
- SPSData spsData;
- if (!DecodeSPS(sps, spsData)) {
- return false;
- }
- aDest.AppendElement(spsData);
+ if (!sps) {
+ return false;
}
- return true;
+
+ return DecodeSPS(sps, aDest);
}
/* static */ bool
H264::EnsureSPSIsSane(SPSData& aSPS)
{
bool valid = true;
static const float default_aspect = 4.0f / 3.0f;
if (aSPS.sample_ratio <= 0.0f || aSPS.sample_ratio > 6.0f) {
@@ -689,223 +645,16 @@ H264::EnsureSPSIsSane(SPSData& aSPS)
}
if (aSPS.max_num_ref_frames > 16) {
aSPS.max_num_ref_frames = 16;
valid = false;
}
return valid;
}
-/* static */ bool
-H264::DecodePPSDataSetFromExtraData(const mozilla::MediaByteBuffer* aExtraData,
- const SPSDataSet& aSPSes, PPSDataSet& aDest)
-{
- if (!AnnexB::HasPPS(aExtraData)) {
- return false;
- }
- ByteReader reader(aExtraData);
-
- if (!reader.Read(5)) {
- return false;
- }
-
- uint8_t numSps = reader.ReadU8() & 0x1f;
- if (!numSps) {
- // No SPS.
- return false;
- }
- NS_ASSERTION(numSps == 1, "More than one SPS in extradata");
- for (uint8_t i = 0; i < numSps; i++) {
- uint16_t length = reader.ReadU16();
-
- if ((reader.PeekU8() & 0x1f) != H264_NAL_SPS) {
- // Not a SPS NAL type.
- return false;
- }
- const uint8_t* ptr = reader.Read(length);
- if (!ptr) {
- return false;
- }
- }
- uint8_t numPps = reader.ReadU8();
- if (!numPps) {
- // No PPs.
- return false;
- }
-
- for (uint32_t idx = 0; idx < numPps; idx++) {
- uint16_t length = reader.ReadU16();
-
- if ((reader.PeekU8() & 0x1f) != H264_NAL_PPS) {
- // Not a PPS NAL type.
- return false;
- }
- const uint8_t* ptr = reader.Read(length);
- if (!ptr) {
- return false;
- }
-
- RefPtr<mozilla::MediaByteBuffer> rawNAL = new mozilla::MediaByteBuffer;
- rawNAL->AppendElements(ptr, length);
-
- RefPtr<mozilla::MediaByteBuffer> pps = DecodeNALUnit(rawNAL);
-
- if (!pps) {
- return false;
- }
-
- PPSData ppsData;
- if (!DecodePPS(pps, aSPSes, ppsData)) {
- return false;
- }
- if (ppsData.pic_parameter_set_id >= aDest.Length()) {
- aDest.SetLength(ppsData.pic_parameter_set_id + 1);
- }
- aDest[ppsData.pic_parameter_set_id] = Move(ppsData);
- }
- return true;
-}
-
-/* static */ bool
-H264::DecodePPS(const mozilla::MediaByteBuffer* aPPS, const SPSDataSet& aSPSes,
- PPSData& aDest)
-{
- if (!aPPS) {
- return false;
- }
-
- if (aSPSes.IsEmpty()) {
- return false;
- }
-
- BitReader br(aPPS, GetBitLength(aPPS));
-
- READUE(pic_parameter_set_id, MAX_PPS_COUNT - 1);
- READUE(seq_parameter_set_id, MAX_SPS_COUNT - 1);
-
- if (aDest.seq_parameter_set_id >= aSPSes.Length()) {
- // Invalid SPS id.
- return false;
- }
- const SPSData& sps = aSPSes[aDest.seq_parameter_set_id];
-
- memcpy(aDest.scaling_matrix4x4, sps.scaling_matrix4x4,
- sizeof(aDest.scaling_matrix4x4));
- memcpy(aDest.scaling_matrix8x8, sps.scaling_matrix8x8,
- sizeof(aDest.scaling_matrix8x8));
-
- aDest.entropy_coding_mode_flag = br.ReadBit();
- aDest.bottom_field_pic_order_in_frame_present_flag = br.ReadBit();
- READUE(num_slice_groups_minus1, 7);
- if (aDest.num_slice_groups_minus1 > 0) {
- READUE(slice_group_map_type, 6);
- switch (aDest.slice_group_map_type) {
- case 0:
- for (uint8_t iGroup = 0; iGroup <= aDest.num_slice_groups_minus1;
- iGroup++) {
- aDest.run_length_minus1[iGroup] = br.ReadUE();
- }
- break;
- case 2:
- for (uint8_t iGroup = 0; iGroup < aDest.num_slice_groups_minus1;
- iGroup++) {
- aDest.top_left[iGroup] = br.ReadUE();
- aDest.bottom_right[iGroup] = br.ReadUE();
- }
- break;
- case 3:
- case 4:
- case 5:
- aDest.slice_group_change_direction_flag = br.ReadBit();
- aDest.slice_group_change_rate_minus1 = br.ReadUE();
- break;
- case 6:
- aDest.pic_size_in_map_units_minus1 = br.ReadUE();
- for (uint32_t i = 0; i <= aDest.pic_size_in_map_units_minus1; i++) {
- /* slice_group_id[ i ] identifies a slice group of the i-th slice group map
- unit in raster scan order. The length of the slice_group_id[i] syntax
- element is Ceil(Log2(num_slice_groups_minus1+1)) bits. The value of
- slice_group_id[i] shall be in the range of 0 to num_slice_groups_minus1,
- inclusive. */
- br.ReadBits(std::ceil(std::log2(aDest.num_slice_groups_minus1 + 1)));
- }
- break;
- default:
- return false;
- }
- }
- READUE(num_ref_idx_l0_default_active_minus1, 31);
- READUE(num_ref_idx_l1_default_active_minus1, 31);
- aDest.weighted_pred_flag = br.ReadBit();
- aDest.weighted_bipred_idc = br.ReadBits(2);
- READSE(pic_init_qp_minus26, -(26 + 6 * sps.bit_depth_luma_minus8), 25);
- READSE(pic_init_qs_minus26, -26, 26);
- READSE(chroma_qp_index_offset, -12, 12);
- aDest.deblocking_filter_control_present_flag = br.ReadBit();
- aDest.constrained_intra_pred_flag = br.ReadBit();
- aDest.redundant_pic_cnt_present_flag = br.ReadBit();
- if (br.BitsLeft()) {
- aDest.transform_8x8_mode_flag = br.ReadBit();
- if (br.ReadBit()) { // pic_scaling_matrix_present_flag
- if (sps.seq_scaling_matrix_present_flag) {
- scaling_list(br, aDest.scaling_matrix4x4[0], Default_4x4_Intra);
- scaling_list(br, aDest.scaling_matrix4x4[1], Default_4x4_Intra,
- aDest.scaling_matrix4x4[0]);
- scaling_list(br, aDest.scaling_matrix4x4[2], Default_4x4_Intra,
- aDest.scaling_matrix4x4[1]);
- scaling_list(br, aDest.scaling_matrix4x4[3], Default_4x4_Inter);
- } else {
- scaling_list(br, aDest.scaling_matrix4x4[0], Default_4x4_Intra,
- Default_4x4_Intra);
- scaling_list(br, aDest.scaling_matrix4x4[1], Default_4x4_Intra,
- aDest.scaling_matrix4x4[0]);
- scaling_list(br, aDest.scaling_matrix4x4[2], Default_4x4_Intra,
- aDest.scaling_matrix4x4[1]);
- scaling_list(br, aDest.scaling_matrix4x4[3], Default_4x4_Inter,
- Default_4x4_Inter);
- }
- scaling_list(br, aDest.scaling_matrix4x4[4], Default_4x4_Inter,
- aDest.scaling_matrix4x4[3]);
- scaling_list(br, aDest.scaling_matrix4x4[5], Default_4x4_Inter,
- aDest.scaling_matrix4x4[4]);
- if (aDest.transform_8x8_mode_flag) {
- if (sps.seq_scaling_matrix_present_flag) {
- scaling_list(br, aDest.scaling_matrix8x8[0], Default_8x8_Intra);
- scaling_list(br, aDest.scaling_matrix8x8[1], Default_8x8_Inter);
- } else {
- scaling_list(br, aDest.scaling_matrix8x8[0], Default_8x8_Intra,
- Default_8x8_Intra);
- scaling_list(br, aDest.scaling_matrix8x8[1], Default_8x8_Inter,
- Default_8x8_Inter);
- }
- if (sps.chroma_format_idc == 3) {
- scaling_list(br, aDest.scaling_matrix8x8[2], Default_8x8_Intra,
- aDest.scaling_matrix8x8[0]);
- scaling_list(br, aDest.scaling_matrix8x8[3], Default_8x8_Inter,
- aDest.scaling_matrix8x8[1]);
- scaling_list(br, aDest.scaling_matrix8x8[4], Default_8x8_Intra,
- aDest.scaling_matrix8x8[2]);
- scaling_list(br, aDest.scaling_matrix8x8[5], Default_8x8_Inter,
- aDest.scaling_matrix8x8[3]);
- }
- }
- }
- READSE(second_chroma_qp_index_offset, -12, 12);
- }
- return true;
-}
-
-/* static */ bool
-H264::DecodeParametersSet(const mozilla::MediaByteBuffer* aExtraData,
- H264ParametersSet& aDest)
-{
- return DecodeSPSDataSetFromExtraData(aExtraData, aDest.SPSes) &&
- DecodePPSDataSetFromExtraData(aExtraData, aDest.SPSes, aDest.PPSes);
-}
-
/* static */ uint32_t
H264::ComputeMaxRefFrames(const mozilla::MediaByteBuffer* aExtraData)
{
uint32_t maxRefFrames = 4;
// Retrieve video dimensions from H264 SPS NAL.
SPSData spsdata;
if (DecodeSPSFromExtraData(aExtraData, spsdata)) {
// max_num_ref_frames determines the size of the sliding window
--- a/media/libstagefright/binding/include/mp4_demuxer/H264.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/H264.h
@@ -398,212 +398,16 @@ struct SPSData
bool scaling_matrix_present;
uint8_t scaling_matrix4x4[6][16];
uint8_t scaling_matrix8x8[6][64];
SPSData();
};
-struct PPSData
-{
- /*
- H264 decoding parameters according to ITU-T H.264 (T-REC-H.264-201402-I/en)
- http://www.itu.int/rec/T-REC-H.264-201402-I/en
- 7.3.2.2 Picture parameter set RBSP syntax
- */
- /* pic_parameter_set_id identifies the picture parameter set that is referred
- to in the slice header. The value of pic_parameter_set_id shall be in the
- range of 0 to 255, inclusive. */
- uint8_t pic_parameter_set_id;
-
- /* seq_parameter_set_id refers to the active sequence parameter set. The value
- of seq_parameter_set_id shall be in the range of 0 to 31, inclusive. */
- uint8_t seq_parameter_set_id;
-
- /* entropy_coding_mode_flag selects the entropy decoding method to be applied
- for the syntax elements for which two descriptors appear in the syntax tables
- as follows:
- – If entropy_coding_mode_flag is equal to 0, the method specified by the
- left descriptor in the syntax table is applied (Exp-Golomb coded, see
- clause 9.1 or CAVLC, see clause 9.2).
- – Otherwise (entropy_coding_mode_flag is equal to 1), the method specified
- by the right descriptor in the syntax table is applied (CABAC, see clause
- 9.3) */
- bool entropy_coding_mode_flag;
-
- /* bottom_field_pic_order_in_frame_present_flag equal to 1 specifies that the
- syntax elements delta_pic_order_cnt_bottom (when pic_order_cnt_type is
- equal to 0) or delta_pic_order_cnt[ 1 ] (when pic_order_cnt_type is equal to
- 1), which are related to picture order counts for the bottom field of a
- coded frame, are present in the slice headers for coded frames as specified
- in clause 7.3.3. bottom_field_pic_order_in_frame_present_flag equal to 0
- specifies that the syntax elements delta_pic_order_cnt_bottom and
- delta_pic_order_cnt[ 1 ] are not present in the slice headers.
- Also known has pic_order_present_flag. */
- bool bottom_field_pic_order_in_frame_present_flag;
-
- /* num_slice_groups_minus1 plus 1 specifies the number of slice groups for a
- picture. When num_slice_groups_minus1 is equal to 0, all slices of the
- picture belong to the same slice group. The allowed range of
- num_slice_groups_minus1 is specified in Annex A. */
- uint8_t num_slice_groups_minus1;
-
- /* slice_group_map_type specifies how the mapping of slice group map units to
- slice groups is coded. The value of slice_group_map_type shall be in the
- range of 0 to 6, inclusive. */
- uint8_t slice_group_map_type;
-
- /* run_length_minus1[i] is used to specify the number of consecutive slice
- group map units to be assigned to the i-th slice group in raster scan order
- of slice group map units. The value of run_length_minus1[ i ] shall be in
- the range of 0 to PicSizeInMapUnits − 1, inclusive. */
- uint32_t run_length_minus1[8];
-
- /* top_left[i] and bottom_right[i] specify the top-left and bottom-right
- corners of a rectangle, respectively. top_left[i] and bottom_right[i] are
- slice group map unit positions in a raster scan of the picture for the slice
- group map units. For each rectangle i, all of the following constraints
- shall be obeyed by the values of the syntax elements top_left[i] and
- bottom_right[i]:
- – top_left[ i ] shall be less than or equal to bottom_right[i] and
- bottom_right[i] shall be less than PicSizeInMapUnits.
- – (top_left[i] % PicWidthInMbs) shall be less than or equal to the value
- of (bottom_right[i] % PicWidthInMbs). */
- uint32_t top_left[8];
- uint32_t bottom_right[8];
-
- /* slice_group_change_direction_flag is used with slice_group_map_type to
- specify the refined map type when slice_group_map_type is 3, 4, or 5. */
- bool slice_group_change_direction_flag;
-
- /* slice_group_change_rate_minus1 is used to specify the variable
- SliceGroupChangeRate. SliceGroupChangeRate specifies the multiple in number
- of slice group map units by which the size of a slice group can change from
- one picture to the next. The value of slice_group_change_rate_minus1 shall
- be in the range of 0 to PicSizeInMapUnits − 1, inclusive.
- The SliceGroupChangeRate variable is specified as follows:
- SliceGroupChangeRate = slice_group_change_rate_minus1 + 1 */
- uint32_t slice_group_change_rate_minus1;
-
- /* pic_size_in_map_units_minus1 is used to specify the number of slice group
- map units in the picture. pic_size_in_map_units_minus1 shall be equal to
- PicSizeInMapUnits − 1. */
- uint32_t pic_size_in_map_units_minus1;
-
- /* num_ref_idx_l0_default_active_minus1 specifies how
- num_ref_idx_l0_active_minus1 is inferred for P, SP, and B slices
- with num_ref_idx_active_override_flag equal to 0. The value of
- num_ref_idx_l0_default_active_minus1 shall be in the
- range of 0 to 31, inclusive. */
- uint8_t num_ref_idx_l0_default_active_minus1;
-
- /* num_ref_idx_l1_default_active_minus1 specifies how
- num_ref_idx_l1_active_minus1 is inferred for B slices with
- num_ref_idx_active_override_flag equal to 0. The value of
- num_ref_idx_l1_default_active_minus1 shall be in the range
- of 0 to 31, inclusive. */
- uint8_t num_ref_idx_l1_default_active_minus1;
-
- /* weighted_pred_flag equal to 0 specifies that the default weighted
- prediction shall be applied to P and SP slices.
- weighted_pred_flag equal to 1 specifies that explicit weighted prediction
- shall be applied to P and SP slices.weighted_pred_flag 1 */
- bool weighted_pred_flag;
-
- /* weighted_bipred_idc equal to 0 specifies that the default weighted
- prediction shall be applied to B slices.
- weighted_bipred_idc equal to 1 specifies that explicit weighted prediction
- shall be applied to B slices. weighted_bipred_idc equal to 2 specifies that
- implicit weighted prediction shall be applied to B slices. The value of
- weighted_bipred_idc shall be in the range of 0 to 2, inclusive. */
- uint8_t weighted_bipred_idc;
-
- /* pic_init_qp_minus26 specifies the initial value minus 26 of SliceQP Y for
- each slice. The initial value is modified at the slice layer when a
- non-zero value of slice_qp_delta is decoded, and is modified further when a
- non-zero value of mb_qp_delta is decoded at the macroblock layer.
- The value of pic_init_qp_minus26 shall be in the range of
- −(26 + QpBdOffset Y ) to +25, inclusive. */
- int8_t pic_init_qp_minus26;
-
- /* pic_init_qs_minus26 specifies the initial value minus 26 of SliceQS Y for
- all macroblocks in SP or SI slices. The initial value is modified at the
- slice layer when a non-zero value of slice_qs_delta is decoded.
- The value of pic_init_qs_minus26 shall be in the range of −26 to +25,
- inclusive. */
- int8_t pic_init_qs_minus26;
-
- /* chroma_qp_index_offset specifies the offset that shall be added to QP Y and
- QS Y for addressing the table of QP C values for the Cb chroma component.
- The value of chroma_qp_index_offset shall be in the range of −12 to +12,
- inclusive. */
- int8_t chroma_qp_index_offset;
-
- /* deblocking_filter_control_present_flag equal to 1 specifies that a set of
- syntax elements controlling the characteristics of the deblocking filter is
- present in the slice header. deblocking_filter_control_present_flag equal to
- 0 specifies that the set of syntax elements controlling the characteristics
- of the deblocking filter is not present in the slice headers and their
- inferred values are in effect. */
- bool deblocking_filter_control_present_flag;
-
- /* constrained_intra_pred_flag equal to 0 specifies that intra prediction
- allows usage of residual data and decoded samples of neighbouring
- macroblocks coded using Inter macroblock prediction modes for the prediction
- of macroblocks coded using Intra macroblock prediction modes.
- constrained_intra_pred_flag equal to 1 specifies constrained intra
- prediction, in which case prediction of macroblocks coded using Intra
- macroblock prediction modes only uses residual data and decoded samples from
- I or SI macroblock types. */
- bool constrained_intra_pred_flag;
-
- /* redundant_pic_cnt_present_flag equal to 0 specifies that the
- redundant_pic_cnt syntax element is not present in slice headers, coded
- slice data partition B NAL units, and coded slice data partition C NAL units
- that refer (either directly or by association with a corresponding coded
- slice data partition A NAL unit) to the picture parameter set.
- redundant_pic_cnt_present_flag equal to 1 specifies that the
- redundant_pic_cnt syntax element is present in all slice headers, coded
- slice data partition B NAL units, and coded slice data partition C NAL units
- that refer (either directly or by association with a corresponding coded
- slice data partition A NAL unit) to the picture parameter set. */
- bool redundant_pic_cnt_present_flag;
-
- /* transform_8x8_mode_flag equal to 1 specifies that the 8x8 transform
- decoding process may be in use (see clause 8.5).
- transform_8x8_mode_flag equal to 0 specifies that the 8x8 transform decoding
- process is not in use. When transform_8x8_mode_flag is not present, it shall
- be inferred to be 0. */
- bool transform_8x8_mode_flag;
-
- /* second_chroma_qp_index_offset specifies the offset that shall be added to
- QP Y and QS Y for addressing the table of QP C values for the Cr chroma
- component.
- The value of second_chroma_qp_index_offset shall be in the range of
- −12 to +12, inclusive.
- When second_chroma_qp_index_offset is not present, it shall be inferred to
- be equal to chroma_qp_index_offset. */
- int8_t second_chroma_qp_index_offset;
-
- uint8_t scaling_matrix4x4[6][16];
- uint8_t scaling_matrix8x8[6][64];
-
- PPSData();
-};
-
-typedef AutoTArray<SPSData, MAX_SPS_COUNT> SPSDataSet;
-typedef AutoTArray<PPSData, MAX_PPS_COUNT> PPSDataSet;
-
-struct H264ParametersSet
-{
- SPSDataSet SPSes;
- PPSDataSet PPSes;
-};
-
class H264
{
public:
/* Extract RAW BYTE SEQUENCE PAYLOAD from NAL content.
Returns nullptr if invalid content.
This is compliant to ITU H.264 7.3.1 Syntax in tabular form NAL unit syntax
*/
static already_AddRefed<mozilla::MediaByteBuffer> DecodeNALUnit(
@@ -611,56 +415,35 @@ public:
// Ensure that SPS data makes sense, Return true if SPS data was, and false
// otherwise. If false, then content will be adjusted accordingly.
static bool EnsureSPSIsSane(SPSData& aSPS);
static bool DecodeSPSFromExtraData(const mozilla::MediaByteBuffer* aExtraData,
SPSData& aDest);
- static bool DecodeParametersSet(const mozilla::MediaByteBuffer* aExtraData,
- H264ParametersSet& aDest);
-
// If the given aExtraData is valid, return the aExtraData.max_num_ref_frames
// clamped to be in the range of [4, 16]; otherwise return 4.
static uint32_t ComputeMaxRefFrames(
const mozilla::MediaByteBuffer* aExtraData);
enum class FrameType
{
I_FRAME,
OTHER,
INVALID,
};
// Returns the frame type. Returns I_FRAME if the sample is an IDR
// (Instantaneous Decoding Refresh) Picture.
static FrameType GetFrameType(const mozilla::MediaRawData* aSample);
- // ZigZag index taBles.
- // Some hardware requires the tables to be in zigzag order.
- // Use ZZ_SCAN table for the scaling_matrix4x4.
- // Use ZZ_SCAN8 table for the scaling_matrix8x8.
- // e.g. dest_scaling_matrix4x4[i,j] = scaling_matrix4x4[ZZ_SCAN(i,j)]
- static const uint8_t ZZ_SCAN[16];
- static const uint8_t ZZ_SCAN8[64];
-
private:
- static bool DecodeSPSDataSetFromExtraData(const mozilla::MediaByteBuffer* aExtraData,
- SPSDataSet& aDest);
-
- static bool DecodePPSDataSetFromExtraData(const mozilla::MediaByteBuffer* aExtraData,
- const SPSDataSet& aPS,
- PPSDataSet& aDest);
-
/* Decode SPS NAL RBSP and fill SPSData structure */
static bool DecodeSPS(const mozilla::MediaByteBuffer* aSPS, SPSData& aDest);
- /* Decode PPS NAL RBSP and fill PPSData structure */
- static bool DecodePPS(const mozilla::MediaByteBuffer* aPPS,
- const SPSDataSet& aSPSs, PPSData& aDest);
static bool vui_parameters(BitReader& aBr, SPSData& aDest);
// Read HRD parameters, all data is ignored.
static void hrd_parameters(BitReader& aBr);
};
} // namespace mp4_demuxer
#endif // MP4_DEMUXER_H264_H_