Skip to content

Commit 4f607cf

Browse files
committed
minivideo: work on scaling lists
1 parent 7c878dd commit 4f607cf

File tree

3 files changed

+60
-77
lines changed

3 files changed

+60
-77
lines changed

minivideo/src/decoder/h264/h264_parameterset.cpp

+1-37
Original file line numberDiff line numberDiff line change
@@ -984,16 +984,7 @@ int decodePPS(Bitstream_t *bitstr, h264_pps_t *pps, h264_sps_t **sps_array)
984984
pps->pic_scaling_list_present_flag[i] = read_bit(bitstr);
985985
if (pps->pic_scaling_list_present_flag[i])
986986
{
987-
TRACE_ERROR(PARAM, "UNIMPLEMENTED PPS scaling list !!!"); //FIXME
988-
/*
989-
// TODO
990-
if (i < 6)
991-
scaling_list_4x4(sps_array[pps->seq_parameter_set_id]->ScalingList4x4[i], 16,
992-
sps_array[pps->seq_parameter_set_id]->UseDefaultScalingMatrix4x4Flag[i]);
993-
else
994-
scaling_list_8x8(sps_array[pps->seq_parameter_set_id]->ScalingList8x8[i-6], 64,
995-
sps_array[pps->seq_parameter_set_id]->UseDefaultScalingMatrix8x8Flag[i-6]);
996-
*/
987+
TRACE_ERROR(PARAM, "UNIMPLEMENTED PPS scaling list !!!");
997988
}
998989
}
999990
}
@@ -1699,11 +1690,6 @@ static int checkVUI(h264_vui_t *vui, h264_sps_t *sps)
16991690
}
17001691
}
17011692
}
1702-
else if (vui->aspect_ratio_idc > 255)
1703-
{
1704-
TRACE_WARNING(PARAM, " - aspect_ratio_idc is %i but should be in range [0,255]", vui->aspect_ratio_idc);
1705-
retcode = FAILURE;
1706-
}
17071693
}
17081694

17091695
if (vui->video_signal_type_present_flag)
@@ -1713,28 +1699,6 @@ static int checkVUI(h264_vui_t *vui, h264_sps_t *sps)
17131699
TRACE_WARNING(PARAM, " - video_format is %i but should be in range [0,7]", vui->video_format);
17141700
retcode = FAILURE;
17151701
}
1716-
1717-
if (vui->colour_description_present_flag)
1718-
{
1719-
if (vui->colour_primaries > 255)
1720-
{
1721-
TRACE_WARNING(PARAM, " - colour_primaries is %i but should be in range [0,255]", vui->colour_primaries);
1722-
retcode = FAILURE;
1723-
}
1724-
1725-
if (vui->transfer_characteristics > 255)
1726-
{
1727-
TRACE_WARNING(PARAM, " - transfer_characteristics is %i but should be in range [0,255]", vui->colour_primaries);
1728-
retcode = FAILURE;
1729-
}
1730-
1731-
if (vui->matrix_coefficients > 255)
1732-
{
1733-
//FIXME better check
1734-
TRACE_WARNING(PARAM, " - matrix_coefficients is %i but should be in range [0,255]", vui->colour_primaries);
1735-
retcode = FAILURE;
1736-
}
1737-
}
17381702
}
17391703

17401704
// Check HRD content

minivideo/src/decoder/h264/h264_parameterset_struct.h

+8-12
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ typedef struct spse_t
157157
*/
158158
typedef struct h264_ScalingStruct_t
159159
{
160-
bool scaling_list_present_flag[12];
160+
bool seq_scaling_list_present_flag[12];
161161

162162
int ScalingList4x4[6][16];
163163
int ScalingList8x8[6][64];
@@ -211,14 +211,17 @@ typedef struct h264_sps_t
211211
bool seq_scaling_matrix_present_flag;
212212
//if (seq_scaling_matrix_present_flag)
213213
bool seq_scaling_list_present_flag[12];
214+
215+
bool UseDefaultScalingMatrix4x4Flag[6];
214216
int ScalingList4x4[6][16];
215-
int ScalingList8x8[6][64];
216217
int ScalingMatrix4x4[6][4][4]; // derived from ScalingList4x4
218+
219+
bool UseDefaultScalingMatrix8x8Flag[6];
220+
int ScalingList8x8[6][64];
217221
int ScalingMatrix8x8[6][8][8]; // derived from ScalingList8x8
222+
218223
int LevelScale4x4[3][6][4][4]; // derived from ScalingMatrix4x4, normAdjust4x4
219224
int LevelScale8x8[3][6][8][8]; // derived from ScalingMatrix8x8, normAdjust8x8
220-
bool UseDefaultScalingMatrix4x4Flag[6];
221-
bool UseDefaultScalingMatrix8x8Flag[6];
222225

223226
unsigned log2_max_frame_num_minus4;
224227
unsigned MaxFrameNum; // derived from log2_max_frame_num_minus4
@@ -309,14 +312,7 @@ typedef struct h264_pps_t
309312
bool pic_scaling_matrix_present_flag;
310313
//if (pic_scaling_matrix_present_flag)
311314
bool pic_scaling_list_present_flag[12];
312-
//int ScalingList4x4[6][16];
313-
//int ScalingList8x8[6][64];
314-
//int ScalingMatrix4x4[6][4][4]; // derived from ScalingList4x4
315-
//int ScalingMatrix8x8[6][8][8]; // derived from ScalingList8x8
316-
//int LevelScale4x4[3][6][4][4]; // [YCbCr][qP%6][i][j] derived from ScalingMatrix4x4, normAdjust4x4
317-
//int LevelScale8x8[3][6][8][8]; // [YCbCr][qP%6][i][j] derived from ScalingMatrix8x8, normAdjust8x8
318-
//bool UseDefaultScalingMatrix4x4Flag[6];
319-
//bool UseDefaultScalingMatrix8x8Flag[6];
315+
// TODO
320316

321317
int second_chroma_qp_index_offset;
322318

minivideo/src/decoder/h264/h264_transform.cpp

+51-28
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,53 @@
3434
#include <cmath>
3535

3636
/* ************************************************************************** */
37-
/*
37+
38+
// Flat scaling lists
39+
40+
int8_t Flat_4x4[16] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 };
41+
42+
int8_t Flat_8x8[64] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
43+
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
44+
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
45+
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 };
46+
3847
// Default scaling lists
3948

40-
int Default_4x4_Intra[16] = { 6, 13, 13, 20, 20, 20, 28, 28, 28, 28, 32, 32, 32, 37, 37, 42};
49+
int8_t Default_4x4_Intra[16] = { 6, 13, 13, 20, 20, 20, 28, 28, 28, 28, 32, 32, 32, 37, 37, 42 };
4150

42-
int Default_4x4_Inter[16] = {10, 14, 14, 20, 20, 20, 24, 24, 24, 24, 27, 27, 27, 30, 30, 34};
51+
int8_t Default_4x4_Inter[16] = { 10, 14, 14, 20, 20, 20, 24, 24, 24, 24, 27, 27, 27, 30, 30, 34 };
4352

44-
int Default_8x8_Intra[64] = { 6, 10, 10, 13, 11, 13, 16, 16, 16, 16, 18, 18, 18, 18, 18, 23,
45-
23, 23, 23, 23, 23, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27,
46-
27, 27, 27, 27, 29, 29, 29, 29, 29, 29, 29, 31, 31, 31, 31, 31,
47-
31, 33, 33, 33, 33, 33, 36, 36, 36, 36, 38, 38, 38, 40, 40, 42};
53+
int8_t Default_8x8_Intra[64] = { 6, 10, 10, 13, 11, 13, 16, 16, 16, 16, 18, 18, 18, 18, 18, 23,
54+
23, 23, 23, 23, 23, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27,
55+
27, 27, 27, 27, 29, 29, 29, 29, 29, 29, 29, 31, 31, 31, 31, 31,
56+
31, 33, 33, 33, 33, 33, 36, 36, 36, 36, 38, 38, 38, 40, 40, 42 };
57+
58+
int8_t Default_8x8_Inter[64] = { 9, 13, 13, 15, 13, 15, 17, 17, 17, 17, 19, 19, 19, 19, 19, 21,
59+
21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24,
60+
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27, 27,
61+
27, 28, 28, 28, 28, 28, 30, 30, 30, 30, 32, 32, 32, 33, 33, 35 };
4862

49-
int Default_8x8_Inter[64] = { 9, 13, 13, 15, 13, 15, 17, 17, 17, 17, 19, 19, 19, 19, 19, 21,
50-
21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24,
51-
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27, 27,
52-
27, 28, 28, 28, 28, 28, 30, 30, 30, 30, 32, 32, 32, 33, 33, 35};
53-
*/
5463
/* ************************************************************************** */
5564

5665
const int idct_dccoeff_2x2[2][2] =
5766
{
58-
{ 1, 1},
59-
{ 1,-1}
67+
{ 1, 1 },
68+
{ 1, -1 }
6069
};
6170

6271
const int idct_dccoeff_4x4[4][4] =
6372
{
64-
{ 1, 1, 1, 1},
65-
{ 1, 1,-1,-1},
66-
{ 1,-1,-1, 1},
67-
{ 1,-1, 1,-1}
73+
{ 1, 1, 1, 1 },
74+
{ 1, 1, -1, -1 },
75+
{ 1, -1, -1, 1 },
76+
{ 1, -1, 1, -1 }
6877
};
6978

7079
/// Use Table 8-15: Specification of QPC as a function of qPI
71-
const int QPCfunctionofqPI[22] = {29, 30, 31, 32, 32, 33, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39};
80+
const int QPCfunctionofqPI[22] = { 29, 30, 31, 32, 32, 33, 34, 34, 35, 35, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39 };
7281

7382
/// Figure 8-7: Assignment of the indices of dcC to chroma4x4BlkIdx when ChromaArrayType equal to 2
74-
const int raster_chroma_cat2_2d[8][2] = {{0,0}, {0,1}, {1,0}, {1,1}, {2,0}, {2,1}, {3,0}, {3,1}};
83+
const int raster_chroma_cat2_2d[8][2] = { {0,0}, {0,1}, {1,0}, {1,1}, {2,0}, {2,1}, {3,0}, {3,1} };
7584

7685
/* ************************************************************************** */
7786

@@ -645,10 +654,9 @@ void computeLevelScale4x4(DecodingContext_t *dc, h264_sps_t *sps)
645654
{
646655
// Initialization
647656
int YCbCr = 0, q = 0, i = 0, j = 0;
648-
649-
#if ENABLE_INTER_PRED
650657
bool mbIsInterFlag = false;
651658

659+
#if ENABLE_INTER_PRED
652660
if (mb->MbPartPredMode[0] > 3)
653661
{
654662
mbIsInterFlag = true;
@@ -666,12 +674,20 @@ void computeLevelScale4x4(DecodingContext_t *dc, h264_sps_t *sps)
666674
}
667675
#endif // ENABLE_SEPARATE_COLOUR_PLANES
668676

669-
// Compute
677+
// Compute // if we have scaling lists
670678
for (YCbCr = 0; YCbCr < 3; YCbCr++)
679+
{
671680
for (q = 0; q < 6; q++)
681+
{
672682
for (i = 0; i < 4; i++)
683+
{
673684
for (j = 0; j < 4; j++)
674-
sps->LevelScale4x4[YCbCr][q][i][j] = sps->ScalingMatrix4x4[YCbCr /*+ ((mbIsInterFlag == true) ? 3 : 0)*/][i][j] * dc->normAdjust4x4[q][i][j];
685+
{
686+
sps->LevelScale4x4[YCbCr][q][i][j] = sps->ScalingMatrix4x4[YCbCr + ((mbIsInterFlag) ? 3 : 0)][i][j] * dc->normAdjust4x4[q][i][j];
687+
}
688+
}
689+
}
690+
}
675691
/*
676692
// Print
677693
for (YCbCr = 0; YCbCr < 3; YCbCr++)
@@ -701,10 +717,9 @@ void computeLevelScale8x8(DecodingContext_t *dc, h264_sps_t *sps)
701717
{
702718
// Initialization
703719
int YCbCr = 0, q = 0, i = 0, j = 0;
704-
705-
#if ENABLE_INTER_PRED
706720
bool mbIsInterFlag = false;
707721

722+
#if ENABLE_INTER_PRED
708723
if (mb->MbPartPredMode[0] > 3)
709724
{
710725
mbIsInterFlag = true;
@@ -722,12 +737,20 @@ void computeLevelScale8x8(DecodingContext_t *dc, h264_sps_t *sps)
722737
}
723738
#endif // ENABLE_SEPARATE_COLOUR_PLANES
724739

725-
// Compute
740+
// Compute // we have SPS scaling lists
726741
for (YCbCr = 0; YCbCr < 3; YCbCr++)
742+
{
727743
for (q = 0; q < 6; q++)
744+
{
728745
for (i = 0; i < 8; i++)
746+
{
729747
for (j = 0; j < 8; j++)
730-
sps->LevelScale8x8[YCbCr][q][i][j] = sps->ScalingMatrix8x8[YCbCr /*+ ((mbIsInterFlag == true) ? 3 : 0)*/][i][j] * dc->normAdjust8x8[q][i][j];
748+
{
749+
sps->LevelScale8x8[YCbCr][q][i][j] = sps->ScalingMatrix8x8[YCbCr + ((mbIsInterFlag) ? 3 : 0)][i][j] * dc->normAdjust8x8[q][i][j];
750+
}
751+
}
752+
}
753+
}
731754
/*
732755
// Print
733756
for (YCbCr = 0; YCbCr < 3; YCbCr++)

0 commit comments

Comments
 (0)