[FFmpeg-cvslog] hevc/rext: fixing rdpcm and scaling list for Range Extension
Mickaël Raulet
git at videolan.org
Tue Jul 22 13:29:49 CEST 2014
ffmpeg | branch: master | Mickaël Raulet <mraulet at insa-rennes.fr> | Tue Jul 22 10:14:12 2014 +0200| [627c044f50da3046809314f7cc742b8a10cf26a1] | committer: Michael Niedermayer
hevc/rext: fixing rdpcm and scaling list for Range Extension
-new rext bitstreams:
PERSIST_RPARAM_A_RExt_Sony_1.bit ok =
QMATRIX_A_RExt_Sony_1.bit ok =
SAO_A_RExt_MediaTek_1.bit ok =
(cherry picked from commit cdea029d452c521f8e5bcbe589f44b13a4011604)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=627c044f50da3046809314f7cc742b8a10cf26a1
---
libavcodec/hevc_cabac.c | 24 ++++++++++++------------
libavcodec/hevc_ps.c | 37 ++++++++++++++++++++++++++++---------
2 files changed, 40 insertions(+), 21 deletions(-)
diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 92b2d7a..2b3d8c0 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -1113,6 +1113,11 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
};
int qp_y = lc->qp_y;
+ if (s->pps->transform_skip_enabled_flag &&
+ log2_trafo_size <= s->pps->log2_max_transform_skip_block_size) {
+ transform_skip_flag = ff_hevc_transform_skip_flag_decode(s, c_idx);
+ }
+
if (c_idx == 0) {
qp = qp_y + s->sps->qp_bd_offset;
} else {
@@ -1149,13 +1154,12 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
scale_m = 16; // default when no custom scaling lists.
dc_scale = 16;
- if (s->sps->scaling_list_enable_flag) {
+ if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) {
const ScalingList *sl = s->pps->scaling_list_data_present_flag ?
&s->pps->scaling_list : &s->sps->scaling_list;
int matrix_id = lc->cu.pred_mode != MODE_INTRA;
- if (log2_trafo_size != 5)
- matrix_id = 3 * matrix_id + c_idx;
+ matrix_id = 3 * matrix_id + c_idx;
scale_matrix = sl->sl[log2_trafo_size - 2][matrix_id];
if (log2_trafo_size >= 4)
@@ -1168,11 +1172,6 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
dc_scale = 0;
}
- if (s->pps->transform_skip_enabled_flag && !lc->cu.cu_transquant_bypass_flag &&
- log2_trafo_size <= s->pps->log2_max_transform_skip_block_size) {
- transform_skip_flag = ff_hevc_transform_skip_flag_decode(s, c_idx);
- }
-
if (lc->cu.pred_mode == MODE_INTER && s->sps->explicit_rdpcm_enabled_flag &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
explicit_rdpcm_flag = explicit_rdpcm_flag_decode(s, c_idx);
@@ -1481,7 +1480,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
trans_coeff_level = -trans_coeff_level;
coeff_sign_flag <<= 1;
if(!lc->cu.cu_transquant_bypass_flag) {
- if(s->sps->scaling_list_enable_flag) {
+ if (s->sps->scaling_list_enable_flag && !(transform_skip_flag && log2_trafo_size > 2)) {
if(y_c || x_c || log2_trafo_size < 4) {
switch(log2_trafo_size) {
case 3: pos = (y_c << 3) + x_c; break;
@@ -1518,10 +1517,11 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
} else {
if (transform_skip_flag) {
int rot = s->sps->transform_skip_rotation_enabled_flag &&
+ log2_trafo_size == 2 &&
lc->cu.pred_mode == MODE_INTRA;
if (rot) {
- for (i = 0; i < (trafo_size * trafo_size >> 1); i++)
- FFSWAP(int16_t, coeffs[i], coeffs[trafo_size * trafo_size - i - 1]);
+ for (i = 0; i < 8; i++)
+ FFSWAP(int16_t, coeffs[i], coeffs[16 - i - 1]);
}
s->hevcdsp.transform_skip(coeffs, log2_trafo_size);
@@ -1529,7 +1529,7 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
if (explicit_rdpcm_flag || (s->sps->implicit_rdpcm_enabled_flag &&
lc->cu.pred_mode == MODE_INTRA &&
(pred_mode_intra == 10 || pred_mode_intra == 26))) {
- int mode = s->sps->implicit_rdpcm_enabled_flag ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag;
+ int mode = explicit_rdpcm_flag ? explicit_rdpcm_dir_flag : (pred_mode_intra == 26);
s->hevcdsp.transform_rdpcm(coeffs, log2_trafo_size, mode);
}
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 166e555..e979676 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -568,20 +568,25 @@ static void set_default_scaling_list_data(ScalingList *sl)
memcpy(sl->sl[2][4], default_scaling_list_inter, 64);
memcpy(sl->sl[2][5], default_scaling_list_inter, 64);
memcpy(sl->sl[3][0], default_scaling_list_intra, 64);
- memcpy(sl->sl[3][1], default_scaling_list_inter, 64);
+ memcpy(sl->sl[3][1], default_scaling_list_intra, 64);
+ memcpy(sl->sl[3][2], default_scaling_list_intra, 64);
+ memcpy(sl->sl[3][3], default_scaling_list_inter, 64);
+ memcpy(sl->sl[3][4], default_scaling_list_inter, 64);
+ memcpy(sl->sl[3][5], default_scaling_list_inter, 64);
}
-static int scaling_list_data(HEVCContext *s, ScalingList *sl)
+static int scaling_list_data(HEVCContext *s, ScalingList *sl, HEVCSPS *sps)
{
GetBitContext *gb = &s->HEVClc->gb;
- uint8_t scaling_list_pred_mode_flag[4][6];
+ uint8_t scaling_list_pred_mode_flag;
int32_t scaling_list_dc_coef[2][6];
- int size_id, matrix_id, i, pos;
+ int size_id, matrix_id, pos;
+ int i;
for (size_id = 0; size_id < 4; size_id++)
- for (matrix_id = 0; matrix_id < (size_id == 3 ? 2 : 6); matrix_id++) {
- scaling_list_pred_mode_flag[size_id][matrix_id] = get_bits1(gb);
- if (!scaling_list_pred_mode_flag[size_id][matrix_id]) {
+ for (matrix_id = 0; matrix_id < 6; matrix_id += ((size_id == 3) ? 3 : 1)) {
+ scaling_list_pred_mode_flag = get_bits1(gb);
+ if (!scaling_list_pred_mode_flag) {
unsigned int delta = get_ue_golomb_long(gb);
/* Only need to handle non-zero delta. Zero means default,
* which should already be in the arrays. */
@@ -625,6 +630,20 @@ static int scaling_list_data(HEVCContext *s, ScalingList *sl)
}
}
+ if (sps->chroma_format_idc == 3) {
+ for (i = 0; i < 64; i++) {
+ sl->sl[3][1][i] = sl->sl[2][1][i];
+ sl->sl[3][2][i] = sl->sl[2][2][i];
+ sl->sl[3][4][i] = sl->sl[2][4][i];
+ sl->sl[3][5][i] = sl->sl[2][5][i];
+ }
+ sl->sl_dc[1][1] = sl->sl_dc[0][1];
+ sl->sl_dc[1][2] = sl->sl_dc[0][2];
+ sl->sl_dc[1][4] = sl->sl_dc[0][4];
+ sl->sl_dc[1][5] = sl->sl_dc[0][5];
+ }
+
+
return 0;
}
@@ -835,7 +854,7 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
set_default_scaling_list_data(&sps->scaling_list);
if (get_bits1(gb)) {
- ret = scaling_list_data(s, &sps->scaling_list);
+ ret = scaling_list_data(s, &sps->scaling_list, sps);
if (ret < 0)
goto err;
}
@@ -1281,7 +1300,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
pps->scaling_list_data_present_flag = get_bits1(gb);
if (pps->scaling_list_data_present_flag) {
set_default_scaling_list_data(&pps->scaling_list);
- ret = scaling_list_data(s, &pps->scaling_list);
+ ret = scaling_list_data(s, &pps->scaling_list, sps);
if (ret < 0)
goto err;
}
More information about the ffmpeg-cvslog
mailing list