Re: [libav-devel] [PATCH 4/6] hevcdec: move parameter set parsing into a separate header

2016-09-22 Thread Diego Biurrun
On Thu, Sep 22, 2016 at 04:29:09PM +0200, Anton Khirnov wrote:
> 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_data.h   |  29 +
>  libavcodec/hevc_ps.c |  15 +--
>  libavcodec/hevc_ps.h | 320 
> +++
>  libavcodec/hevc_ps_enc.c |   2 +-
>  libavcodec/hevc_refs.c   |   2 +-
>  libavcodec/hevcdec.c |   3 +-
>  libavcodec/hevcdec.h | 301 +---
>  8 files changed, 370 insertions(+), 307 deletions(-)
>  create mode 100644 libavcodec/hevc_data.h
>  create mode 100644 libavcodec/hevc_ps.h
> 
> --- /dev/null
> +++ b/libavcodec/hevc_data.h
> @@ -0,0 +1,29 @@
> +
> +#ifndef AVCODEC_HEVC_DATA_H
> +#define AVCODEC_HEVC_DATA_H
> +
> +extern const uint8_t ff_hevc_diag_scan4x4_x[16];
> +extern const uint8_t ff_hevc_diag_scan4x4_y[16];
> +extern const uint8_t ff_hevc_diag_scan8x8_x[64];
> +extern const uint8_t ff_hevc_diag_scan8x8_y[64];
> +
> +#endif /* AVCODEC_HEVC_DATA_H */

This should be a separate patch IMO. Also, this header will not compile
standalone. Plus, hevc_data.c was not updated to #include it.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 4/6] hevcdec: move parameter set parsing into a separate header

2016-09-22 Thread Anton Khirnov
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_data.h   |  29 +
 libavcodec/hevc_ps.c |  15 +--
 libavcodec/hevc_ps.h | 320 +++
 libavcodec/hevc_ps_enc.c |   2 +-
 libavcodec/hevc_refs.c   |   2 +-
 libavcodec/hevcdec.c |   3 +-
 libavcodec/hevcdec.h | 301 +---
 8 files changed, 370 insertions(+), 307 deletions(-)
 create mode 100644 libavcodec/hevc_data.h
 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_data.h b/libavcodec/hevc_data.h
new file mode 100644
index 000..abd4dc7
--- /dev/null
+++ b/libavcodec/hevc_data.h
@@ -0,0 +1,29 @@
+/*
+ * HEVC shared data tables
+ *
+ * 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 AVCODEC_HEVC_DATA_H
+#define AVCODEC_HEVC_DATA_H
+
+extern const uint8_t ff_hevc_diag_scan4x4_x[16];
+extern const uint8_t ff_hevc_diag_scan4x4_y[16];
+extern const uint8_t ff_hevc_diag_scan8x8_x[64];
+extern const uint8_t ff_hevc_diag_scan8x8_y[64];
+
+#endif /* AVCODEC_HEVC_DATA_H */
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 520017b..6a8cfeb 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -26,7 +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,
@@ -199,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;
 }
@@ -405,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;
@@ -793,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;
@@ -803,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;