This code is independent from the decoder, so it makes more sense for it
to to have its own header.
---
libavcodec/hevc.h| 5 +
libavcodec/hevc_ps.c | 14 +--
libavcodec/hevc_ps.h | 320 +++
libavcodec/hevc_ps_enc.c | 2 +-
libavcodec/hevc_refs.c | 2 +-
libavcodec/hevcdec.c | 2 +-
libavcodec/hevcdec.h | 296 +--
7 files changed, 339 insertions(+), 302 deletions(-)
create mode 100644 libavcodec/hevc_ps.h
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 66816b8..9536608 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -62,4 +62,9 @@ enum HEVCNALUnitType {
#define HEVC_MAX_SHORT_TERM_RPS_COUNT 64
#define HEVC_MAX_CU_SIZE 128
+#define HEVC_MAX_REFS 16
+#define HEVC_MAX_DPB_SIZE 16 // A.4.1
+
+#define HEVC_MAX_LOG2_CTB_SIZE 6
+
#endif /* AVCODEC_HEVC_H */
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 44db326..6a8cfeb 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -26,8 +26,8 @@
#include "libavutil/imgutils.h"
#include "golomb.h"
-#include "hevcdec.h"
#include "hevc_data.h"
+#include "hevc_ps.h"
static const uint8_t default_scaling_list_intra[] = {
16, 16, 16, 16, 17, 18, 21, 24,
@@ -200,8 +200,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb,
AVCodecContext *avctx,
rps->num_negative_pics = get_ue_golomb_long(gb);
nb_positive_pics = get_ue_golomb_long(gb);
-if (rps->num_negative_pics >= MAX_REFS ||
-nb_positive_pics >= MAX_REFS) {
+if (rps->num_negative_pics >= HEVC_MAX_REFS ||
+nb_positive_pics >= HEVC_MAX_REFS) {
av_log(avctx, AV_LOG_ERROR, "Too many refs in a short term
RPS.\n");
return AVERROR_INVALIDDATA;
}
@@ -406,7 +406,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb,
AVCodecContext *avctx,
vps->vps_num_reorder_pics[i] = get_ue_golomb_long(gb);
vps->vps_max_latency_increase[i] = get_ue_golomb_long(gb) - 1;
-if (vps->vps_max_dec_pic_buffering[i] > MAX_DPB_SIZE) {
+if (vps->vps_max_dec_pic_buffering[i] > HEVC_MAX_DPB_SIZE) {
av_log(avctx, AV_LOG_ERROR, "vps_max_dec_pic_buffering_minus1 out
of range: %d\n",
vps->vps_max_dec_pic_buffering[i] - 1);
goto err;
@@ -794,7 +794,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb,
unsigned int *sps_id,
sps->temporal_layer[i].max_dec_pic_buffering = get_ue_golomb_long(gb)
+ 1;
sps->temporal_layer[i].num_reorder_pics = get_ue_golomb_long(gb);
sps->temporal_layer[i].max_latency_increase = get_ue_golomb_long(gb)
- 1;
-if (sps->temporal_layer[i].max_dec_pic_buffering > MAX_DPB_SIZE) {
+if (sps->temporal_layer[i].max_dec_pic_buffering > HEVC_MAX_DPB_SIZE) {
av_log(avctx, AV_LOG_ERROR, "sps_max_dec_pic_buffering_minus1 out
of range: %d\n",
sps->temporal_layer[i].max_dec_pic_buffering - 1);
ret = AVERROR_INVALIDDATA;
@@ -804,7 +804,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb,
unsigned int *sps_id,
av_log(avctx, AV_LOG_WARNING, "sps_max_num_reorder_pics out of
range: %d\n",
sps->temporal_layer[i].num_reorder_pics);
if (avctx->err_recognition & AV_EF_EXPLODE ||
-sps->temporal_layer[i].num_reorder_pics > MAX_DPB_SIZE - 1) {
+sps->temporal_layer[i].num_reorder_pics > HEVC_MAX_DPB_SIZE -
1) {
ret = AVERROR_INVALIDDATA;
goto err;
}
@@ -955,7 +955,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb,
unsigned int *sps_id,
goto err;
}
-if (sps->log2_ctb_size > MAX_LOG2_CTB_SIZE) {
+if (sps->log2_ctb_size > HEVC_MAX_LOG2_CTB_SIZE) {
av_log(avctx, AV_LOG_ERROR, "CTB size out of range: 2^%d\n",
sps->log2_ctb_size);
goto err;
}
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
new file mode 100644
index 000..d95aa51
--- /dev/null
+++ b/libavcodec/hevc_ps.h
@@ -0,0 +1,320 @@
+/*
+ * HEVC parameter set parsing
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef