[FFmpeg-cvslog] Merge commit 'f638b67e5790735f34620bf82025c9b9d6fc7216'

James Almer git at videolan.org
Mon Aug 1 20:09:24 EEST 2016


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Aug  1 12:58:09 2016 -0300| [8c7932884d09bc580036640453fd6b7ad4dd77b4] | committer: James Almer

Merge commit 'f638b67e5790735f34620bf82025c9b9d6fc7216'

* commit 'f638b67e5790735f34620bf82025c9b9d6fc7216':
  h264: move the parameter set definitions to a new header file

Conflicts:
libavcodec/h264_parse.h
libavcodec/h264_ps.c
libavcodec/h264dec.h

Merged-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c7932884d09bc580036640453fd6b7ad4dd77b4
---

 libavcodec/dxva2_h264.c      |   1 +
 libavcodec/h264.h            |   2 +
 libavcodec/h264_direct.c     |   1 +
 libavcodec/h264_loopfilter.c |   1 +
 libavcodec/h264_mb.c         |   1 +
 libavcodec/h264_parse.c      |   1 +
 libavcodec/h264_parse.h      |  15 ++--
 libavcodec/h264_parser.c     |   1 +
 libavcodec/h264_ps.c         |   4 +-
 libavcodec/h264_ps.h         | 159 +++++++++++++++++++++++++++++++++++++++++++
 libavcodec/h264_slice.c      |   1 +
 libavcodec/h264dec.c         |   1 +
 libavcodec/h264dec.h         | 127 +---------------------------------
 libavcodec/vaapi_h264.c      |   1 +
 libavcodec/vdpau_h264.c      |   1 +
 15 files changed, 181 insertions(+), 136 deletions(-)

diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 9ed9c75..82a772d 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -24,6 +24,7 @@
 
 #include "h264dec.h"
 #include "h264data.h"
+#include "h264_ps.h"
 #include "mpegutils.h"
 
 // The headers above may include w32threads.h, which uses the original
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 72b133b..bcdd4f6 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -24,6 +24,8 @@
 #ifndef AVCODEC_H264_H
 #define AVCODEC_H264_H
 
+#define QP_MAX_NUM (51 + 6*6)           // The maximum supported qp
+
 /* NAL unit types */
 enum {
     NAL_SLICE           = 1,
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index a1e5c04..107c905 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -28,6 +28,7 @@
 #include "internal.h"
 #include "avcodec.h"
 #include "h264dec.h"
+#include "h264_ps.h"
 #include "mpegutils.h"
 #include "rectangle.h"
 #include "thread.h"
diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index 19a8851..0b44882 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -30,6 +30,7 @@
 #include "internal.h"
 #include "avcodec.h"
 #include "h264dec.h"
+#include "h264_ps.h"
 #include "mathops.h"
 #include "mpegutils.h"
 #include "rectangle.h"
diff --git a/libavcodec/h264_mb.c b/libavcodec/h264_mb.c
index edccf4d..638dcba 100644
--- a/libavcodec/h264_mb.c
+++ b/libavcodec/h264_mb.c
@@ -32,6 +32,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "h264dec.h"
+#include "h264_ps.h"
 #include "qpeldsp.h"
 #include "thread.h"
 
diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index 5d1157e..da67149 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -22,6 +22,7 @@
 #include "h264.h"
 #include "h264dec.h"
 #include "h264_parse.h"
+#include "h264_ps.h"
 
 int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
                               const int *ref_count, int slice_type_nos,
diff --git a/libavcodec/h264_parse.h b/libavcodec/h264_parse.h
index 40d88ed..290da34 100644
--- a/libavcodec/h264_parse.h
+++ b/libavcodec/h264_parse.h
@@ -25,6 +25,7 @@
 #define AVCODEC_H264_PARSE_H
 
 #include "get_bits.h"
+#include "h264_ps.h"
 
 typedef struct H264PredWeightTable {
     int use_weight;
@@ -52,11 +53,7 @@ typedef struct H264POCContext {
     int prev_frame_num;         ///< frame_num of the last pic for POC type 1/2
 } H264POCContext;
 
-struct SPS;
-struct PPS;
-struct H264ParamSets;
-
-int ff_h264_pred_weight_table(GetBitContext *gb, const struct SPS *sps,
+int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
                               const int *ref_count, int slice_type_nos,
                               H264PredWeightTable *pwt, void *logctx);
 
@@ -76,20 +73,20 @@ int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available,
                                   int mode, int is_chroma);
 
 int ff_h264_parse_ref_count(int *plist_count, int ref_count[2],
-                            GetBitContext *gb, const struct PPS *pps,
+                            GetBitContext *gb, const PPS *pps,
                             int slice_type_nos, int picture_structure, void *logctx);
 
 int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
-                     const struct SPS *sps, H264POCContext *poc,
+                     const SPS *sps, H264POCContext *poc,
                      int picture_structure, int nal_ref_idc);
 
-int ff_h264_decode_extradata(const uint8_t *data, int size, struct H264ParamSets *ps,
+int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
                              int *is_avc, int *nal_length_size,
                              int err_recognition, void *logctx);
 
 /**
  * compute profile from sps
  */
-int ff_h264_get_profile(const struct SPS *sps);
+int ff_h264_get_profile(const SPS *sps);
 
 #endif /* AVCODEC_H264_PARSE_H */
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 34bd0e1..81ccaab 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -41,6 +41,7 @@
 #include "h264.h"
 #include "h264dec.h"
 #include "h264_sei.h"
+#include "h264_ps.h"
 #include "h264data.h"
 #include "internal.h"
 #include "mpegutils.h"
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 8bc8f1f..f288ca2 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -31,13 +31,15 @@
 #include "internal.h"
 #include "mathops.h"
 #include "avcodec.h"
-#include "h264dec.h"
 #include "h264data.h"
+#include "h264_ps.h"
 #include "golomb.h"
 
 #define MAX_LOG2_MAX_FRAME_NUM    (12 + 4)
 #define MIN_LOG2_MAX_FRAME_NUM    4
 
+#define EXTENDED_SAR       255
+
 static const uint8_t default_scaling4[2][16] = {
     {  6, 13, 20, 28, 13, 20, 28, 32,
       20, 28, 32, 37, 28, 32, 37, 42 },
diff --git a/libavcodec/h264_ps.h b/libavcodec/h264_ps.h
new file mode 100644
index 0000000..ecf3a58
--- /dev/null
+++ b/libavcodec/h264_ps.h
@@ -0,0 +1,159 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * H.264 parameter set handling
+ */
+
+#ifndef AVCODEC_H264_PS_H
+#define AVCODEC_H264_PS_H
+
+#include <stdint.h>
+
+#include "libavutil/buffer.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/rational.h"
+
+#include "avcodec.h"
+#include "get_bits.h"
+#include "h264.h"
+
+#define MAX_SPS_COUNT          32
+#define MAX_PPS_COUNT         256
+
+/**
+ * Sequence parameter set
+ */
+typedef struct SPS {
+    unsigned int sps_id;
+    int profile_idc;
+    int level_idc;
+    int chroma_format_idc;
+    int transform_bypass;              ///< qpprime_y_zero_transform_bypass_flag
+    int log2_max_frame_num;            ///< log2_max_frame_num_minus4 + 4
+    int poc_type;                      ///< pic_order_cnt_type
+    int log2_max_poc_lsb;              ///< log2_max_pic_order_cnt_lsb_minus4
+    int delta_pic_order_always_zero_flag;
+    int offset_for_non_ref_pic;
+    int offset_for_top_to_bottom_field;
+    int poc_cycle_length;              ///< num_ref_frames_in_pic_order_cnt_cycle
+    int ref_frame_count;               ///< num_ref_frames
+    int gaps_in_frame_num_allowed_flag;
+    int mb_width;                      ///< pic_width_in_mbs_minus1 + 1
+    int mb_height;                     ///< pic_height_in_map_units_minus1 + 1
+    int frame_mbs_only_flag;
+    int mb_aff;                        ///< mb_adaptive_frame_field_flag
+    int direct_8x8_inference_flag;
+    int crop;                          ///< frame_cropping_flag
+
+    /* those 4 are already in luma samples */
+    unsigned int crop_left;            ///< frame_cropping_rect_left_offset
+    unsigned int crop_right;           ///< frame_cropping_rect_right_offset
+    unsigned int crop_top;             ///< frame_cropping_rect_top_offset
+    unsigned int crop_bottom;          ///< frame_cropping_rect_bottom_offset
+    int vui_parameters_present_flag;
+    AVRational sar;
+    int video_signal_type_present_flag;
+    int full_range;
+    int colour_description_present_flag;
+    enum AVColorPrimaries color_primaries;
+    enum AVColorTransferCharacteristic color_trc;
+    enum AVColorSpace colorspace;
+    int timing_info_present_flag;
+    uint32_t num_units_in_tick;
+    uint32_t time_scale;
+    int fixed_frame_rate_flag;
+    short offset_for_ref_frame[256]; // FIXME dyn aloc?
+    int bitstream_restriction_flag;
+    int num_reorder_frames;
+    int scaling_matrix_present;
+    uint8_t scaling_matrix4[6][16];
+    uint8_t scaling_matrix8[6][64];
+    int nal_hrd_parameters_present_flag;
+    int vcl_hrd_parameters_present_flag;
+    int pic_struct_present_flag;
+    int time_offset_length;
+    int cpb_cnt;                          ///< See H.264 E.1.2
+    int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1
+    int cpb_removal_delay_length;         ///< cpb_removal_delay_length_minus1 + 1
+    int dpb_output_delay_length;          ///< dpb_output_delay_length_minus1 + 1
+    int bit_depth_luma;                   ///< bit_depth_luma_minus8 + 8
+    int bit_depth_chroma;                 ///< bit_depth_chroma_minus8 + 8
+    int residual_color_transform_flag;    ///< residual_colour_transform_flag
+    int constraint_set_flags;             ///< constraint_set[0-3]_flag
+    uint8_t data[4096];
+    size_t data_size;
+} SPS;
+
+/**
+ * Picture parameter set
+ */
+typedef struct PPS {
+    unsigned int sps_id;
+    int cabac;                  ///< entropy_coding_mode_flag
+    int pic_order_present;      ///< pic_order_present_flag
+    int slice_group_count;      ///< num_slice_groups_minus1 + 1
+    int mb_slice_group_map_type;
+    unsigned int ref_count[2];  ///< num_ref_idx_l0/1_active_minus1 + 1
+    int weighted_pred;          ///< weighted_pred_flag
+    int weighted_bipred_idc;
+    int init_qp;                ///< pic_init_qp_minus26 + 26
+    int init_qs;                ///< pic_init_qs_minus26 + 26
+    int chroma_qp_index_offset[2];
+    int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
+    int constrained_intra_pred;     ///< constrained_intra_pred_flag
+    int redundant_pic_cnt_present;  ///< redundant_pic_cnt_present_flag
+    int transform_8x8_mode;         ///< transform_8x8_mode_flag
+    uint8_t scaling_matrix4[6][16];
+    uint8_t scaling_matrix8[6][64];
+    uint8_t chroma_qp_table[2][QP_MAX_NUM+1];  ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
+    int chroma_qp_diff;
+    uint8_t data[4096];
+    size_t data_size;
+
+    uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16];
+    uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
+    uint32_t(*dequant4_coeff[6])[16];
+    uint32_t(*dequant8_coeff[6])[64];
+} PPS;
+
+typedef struct H264ParamSets {
+    AVBufferRef *sps_list[MAX_SPS_COUNT];
+    AVBufferRef *pps_list[MAX_PPS_COUNT];
+
+    AVBufferRef *pps_ref;
+    AVBufferRef *sps_ref;
+    /* currently active parameters sets */
+    const PPS *pps;
+    const SPS *sps;
+} H264ParamSets;
+
+/**
+ * Decode SPS
+ */
+int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
+                                     H264ParamSets *ps, int ignore_truncation);
+
+/**
+ * Decode PPS
+ */
+int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
+                                         H264ParamSets *ps, int bit_length);
+
+#endif /* AVCODEC_H264_PS_H */
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 5c505a1..9495b6e 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -40,6 +40,7 @@
 #include "h264data.h"
 #include "h264chroma.h"
 #include "h264_mvpred.h"
+#include "h264_ps.h"
 #include "golomb.h"
 #include "mathops.h"
 #include "mpegutils.h"
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 511e78c..91bc38d 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -45,6 +45,7 @@
 #include "h264data.h"
 #include "h264chroma.h"
 #include "h264_mvpred.h"
+#include "h264_ps.h"
 #include "golomb.h"
 #include "mathops.h"
 #include "me_cmp.h"
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index c74b9fa..a73a9dd 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -35,6 +35,7 @@
 #include "cabac.h"
 #include "error_resilience.h"
 #include "h264_parse.h"
+#include "h264_ps.h"
 #include "h264_sei.h"
 #include "h2645_parse.h"
 #include "h264chroma.h"
@@ -50,9 +51,6 @@
 
 #define H264_MAX_PICTURE_COUNT 36
 
-#define MAX_SPS_COUNT          32
-#define MAX_PPS_COUNT         256
-
 #define MAX_MMCO_COUNT         66
 
 #define MAX_DELAYED_PIC_COUNT  16
@@ -102,122 +100,11 @@
 #define CHROMA422(h) ((h)->ps.sps->chroma_format_idc == 2)
 #define CHROMA444(h) ((h)->ps.sps->chroma_format_idc == 3)
 
-#define EXTENDED_SAR       255
-
 #define MB_TYPE_REF0       MB_TYPE_ACPRED // dirty but it fits in 16 bit
 #define MB_TYPE_8x8DCT     0x01000000
 #define IS_REF0(a)         ((a) & MB_TYPE_REF0)
 #define IS_8x8DCT(a)       ((a) & MB_TYPE_8x8DCT)
 
-#define QP_MAX_NUM (51 + 6*6)           // The maximum supported qp
-
-/**
- * Sequence parameter set
- */
-typedef struct SPS {
-    unsigned int sps_id;
-    int profile_idc;
-    int level_idc;
-    int chroma_format_idc;
-    int transform_bypass;              ///< qpprime_y_zero_transform_bypass_flag
-    int log2_max_frame_num;            ///< log2_max_frame_num_minus4 + 4
-    int poc_type;                      ///< pic_order_cnt_type
-    int log2_max_poc_lsb;              ///< log2_max_pic_order_cnt_lsb_minus4
-    int delta_pic_order_always_zero_flag;
-    int offset_for_non_ref_pic;
-    int offset_for_top_to_bottom_field;
-    int poc_cycle_length;              ///< num_ref_frames_in_pic_order_cnt_cycle
-    int ref_frame_count;               ///< num_ref_frames
-    int gaps_in_frame_num_allowed_flag;
-    int mb_width;                      ///< pic_width_in_mbs_minus1 + 1
-    int mb_height;                     ///< pic_height_in_map_units_minus1 + 1
-    int frame_mbs_only_flag;
-    int mb_aff;                        ///< mb_adaptive_frame_field_flag
-    int direct_8x8_inference_flag;
-    int crop;                          ///< frame_cropping_flag
-
-    /* those 4 are already in luma samples */
-    unsigned int crop_left;            ///< frame_cropping_rect_left_offset
-    unsigned int crop_right;           ///< frame_cropping_rect_right_offset
-    unsigned int crop_top;             ///< frame_cropping_rect_top_offset
-    unsigned int crop_bottom;          ///< frame_cropping_rect_bottom_offset
-    int vui_parameters_present_flag;
-    AVRational sar;
-    int video_signal_type_present_flag;
-    int full_range;
-    int colour_description_present_flag;
-    enum AVColorPrimaries color_primaries;
-    enum AVColorTransferCharacteristic color_trc;
-    enum AVColorSpace colorspace;
-    int timing_info_present_flag;
-    uint32_t num_units_in_tick;
-    uint32_t time_scale;
-    int fixed_frame_rate_flag;
-    short offset_for_ref_frame[256]; // FIXME dyn aloc?
-    int bitstream_restriction_flag;
-    int num_reorder_frames;
-    int scaling_matrix_present;
-    uint8_t scaling_matrix4[6][16];
-    uint8_t scaling_matrix8[6][64];
-    int nal_hrd_parameters_present_flag;
-    int vcl_hrd_parameters_present_flag;
-    int pic_struct_present_flag;
-    int time_offset_length;
-    int cpb_cnt;                          ///< See H.264 E.1.2
-    int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1
-    int cpb_removal_delay_length;         ///< cpb_removal_delay_length_minus1 + 1
-    int dpb_output_delay_length;          ///< dpb_output_delay_length_minus1 + 1
-    int bit_depth_luma;                   ///< bit_depth_luma_minus8 + 8
-    int bit_depth_chroma;                 ///< bit_depth_chroma_minus8 + 8
-    int residual_color_transform_flag;    ///< residual_colour_transform_flag
-    int constraint_set_flags;             ///< constraint_set[0-3]_flag
-    uint8_t data[4096];
-    size_t data_size;
-} SPS;
-
-/**
- * Picture parameter set
- */
-typedef struct PPS {
-    unsigned int sps_id;
-    int cabac;                  ///< entropy_coding_mode_flag
-    int pic_order_present;      ///< pic_order_present_flag
-    int slice_group_count;      ///< num_slice_groups_minus1 + 1
-    int mb_slice_group_map_type;
-    unsigned int ref_count[2];  ///< num_ref_idx_l0/1_active_minus1 + 1
-    int weighted_pred;          ///< weighted_pred_flag
-    int weighted_bipred_idc;
-    int init_qp;                ///< pic_init_qp_minus26 + 26
-    int init_qs;                ///< pic_init_qs_minus26 + 26
-    int chroma_qp_index_offset[2];
-    int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
-    int constrained_intra_pred;     ///< constrained_intra_pred_flag
-    int redundant_pic_cnt_present;  ///< redundant_pic_cnt_present_flag
-    int transform_8x8_mode;         ///< transform_8x8_mode_flag
-    uint8_t scaling_matrix4[6][16];
-    uint8_t scaling_matrix8[6][64];
-    uint8_t chroma_qp_table[2][QP_MAX_NUM+1];  ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
-    int chroma_qp_diff;
-    uint8_t data[4096];
-    size_t data_size;
-
-    uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16];
-    uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
-    uint32_t(*dequant4_coeff[6])[16];
-    uint32_t(*dequant8_coeff[6])[64];
-} PPS;
-
-typedef struct H264ParamSets {
-    AVBufferRef *sps_list[MAX_SPS_COUNT];
-    AVBufferRef *pps_list[MAX_PPS_COUNT];
-
-    AVBufferRef *pps_ref;
-    AVBufferRef *sps_ref;
-    /* currently active parameters sets */
-    const PPS *pps;
-    const SPS *sps;
-} H264ParamSets;
-
 /**
  * Memory management control operation opcode.
  */
@@ -683,18 +570,6 @@ extern const uint16_t ff_h264_mb_sizes[4];
 void ff_h264_ps_uninit(H264ParamSets *ps);
 
 /**
- * Decode SPS
- */
-int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
-                                     H264ParamSets *ps, int ignore_truncation);
-
-/**
- * Decode PPS
- */
-int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
-                                         H264ParamSets *ps, int bit_length);
-
-/**
  * Reconstruct bitstream slice_type.
  */
 int ff_h264_get_slice_type(const H264SliceContext *sl);
diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index d7aba2d..bc12d77 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -22,6 +22,7 @@
 
 #include "vaapi_internal.h"
 #include "h264dec.h"
+#include "h264_ps.h"
 #include "mpegutils.h"
 
 /**
diff --git a/libavcodec/vdpau_h264.c b/libavcodec/vdpau_h264.c
index 15f50f0..7265af2 100644
--- a/libavcodec/vdpau_h264.c
+++ b/libavcodec/vdpau_h264.c
@@ -26,6 +26,7 @@
 #include "avcodec.h"
 #include "internal.h"
 #include "h264dec.h"
+#include "h264_ps.h"
 #include "mpegutils.h"
 #include "vdpau.h"
 #include "vdpau_internal.h"


======================================================================

diff --cc libavcodec/dxva2_h264.c
index 9ed9c75,52c59fb..82a772d
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@@ -20,10 -20,9 +20,11 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
 +#include "libavutil/avassert.h"
 +
  #include "h264dec.h"
  #include "h264data.h"
+ #include "h264_ps.h"
  #include "mpegutils.h"
  
  // The headers above may include w32threads.h, which uses the original
diff --cc libavcodec/h264.h
index 72b133b,6a9b496..bcdd4f6
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@@ -24,6 -24,8 +24,8 @@@
  #ifndef AVCODEC_H264_H
  #define AVCODEC_H264_H
  
 -#define QP_MAX_NUM (51 + 2 * 6)           // The maximum supported qp
++#define QP_MAX_NUM (51 + 6*6)           // The maximum supported qp
+ 
  /* NAL unit types */
  enum {
      NAL_SLICE           = 1,
diff --cc libavcodec/h264_parse.h
index 40d88ed,5c6024d..290da34
--- a/libavcodec/h264_parse.h
+++ b/libavcodec/h264_parse.h
@@@ -52,13 -53,9 +53,9 @@@ typedef struct H264POCContext 
      int prev_frame_num;         ///< frame_num of the last pic for POC type 1/2
  } H264POCContext;
  
- struct SPS;
- struct PPS;
- struct H264ParamSets;
- 
- int ff_h264_pred_weight_table(GetBitContext *gb, const struct SPS *sps,
+ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps,
                                const int *ref_count, int slice_type_nos,
 -                              H264PredWeightTable *pwt);
 +                              H264PredWeightTable *pwt, void *logctx);
  
  /**
   * Check if the top & left blocks are available if needed & change the
@@@ -76,14 -73,14 +73,14 @@@ int ff_h264_check_intra_pred_mode(void 
                                    int mode, int is_chroma);
  
  int ff_h264_parse_ref_count(int *plist_count, int ref_count[2],
-                             GetBitContext *gb, const struct PPS *pps,
+                             GetBitContext *gb, const PPS *pps,
 -                            int slice_type_nos, int picture_structure);
 +                            int slice_type_nos, int picture_structure, void *logctx);
  
  int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
-                      const struct SPS *sps, H264POCContext *poc,
+                      const SPS *sps, H264POCContext *poc,
                       int picture_structure, int nal_ref_idc);
  
- int ff_h264_decode_extradata(const uint8_t *data, int size, struct H264ParamSets *ps,
+ int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
                               int *is_avc, int *nal_length_size,
                               int err_recognition, void *logctx);
  
diff --cc libavcodec/h264_ps.c
index 8bc8f1f,46457a8..f288ca2
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@@ -38,6 -38,28 +38,8 @@@
  #define MAX_LOG2_MAX_FRAME_NUM    (12 + 4)
  #define MIN_LOG2_MAX_FRAME_NUM    4
  
+ #define EXTENDED_SAR       255
+ 
 -static const AVRational pixel_aspect[17] = {
 -    {   0,  1 },
 -    {   1,  1 },
 -    {  12, 11 },
 -    {  10, 11 },
 -    {  16, 11 },
 -    {  40, 33 },
 -    {  24, 11 },
 -    {  20, 11 },
 -    {  32, 11 },
 -    {  80, 33 },
 -    {  18, 11 },
 -    {  15, 11 },
 -    {  64, 33 },
 -    { 160, 99 },
 -    {   4,  3 },
 -    {   3,  2 },
 -    {   2,  1 },
 -};
 -
  static const uint8_t default_scaling4[2][16] = {
      {  6, 13, 20, 28, 13, 20, 28, 32,
        20, 28, 32, 37, 28, 32, 37, 42 },
diff --cc libavcodec/h264_ps.h
index 0000000,2835b87..ecf3a58
mode 000000,100644..100644
--- a/libavcodec/h264_ps.h
+++ b/libavcodec/h264_ps.h
@@@ -1,0 -1,154 +1,159 @@@
+ /*
 - * This file is part of Libav.
++ * This file is part of FFmpeg.
+  *
 - * Libav is free software; you can redistribute it and/or
++ * FFmpeg 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,
++ * FFmpeg 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
++ * License along with FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ 
+ /**
+  * @file
+  * H.264 parameter set handling
+  */
+ 
+ #ifndef AVCODEC_H264_PS_H
+ #define AVCODEC_H264_PS_H
+ 
+ #include <stdint.h>
+ 
+ #include "libavutil/buffer.h"
+ #include "libavutil/pixfmt.h"
+ #include "libavutil/rational.h"
+ 
+ #include "avcodec.h"
+ #include "get_bits.h"
+ #include "h264.h"
+ 
+ #define MAX_SPS_COUNT          32
+ #define MAX_PPS_COUNT         256
+ 
+ /**
+  * Sequence parameter set
+  */
+ typedef struct SPS {
+     unsigned int sps_id;
+     int profile_idc;
+     int level_idc;
+     int chroma_format_idc;
+     int transform_bypass;              ///< qpprime_y_zero_transform_bypass_flag
+     int log2_max_frame_num;            ///< log2_max_frame_num_minus4 + 4
+     int poc_type;                      ///< pic_order_cnt_type
+     int log2_max_poc_lsb;              ///< log2_max_pic_order_cnt_lsb_minus4
+     int delta_pic_order_always_zero_flag;
+     int offset_for_non_ref_pic;
+     int offset_for_top_to_bottom_field;
+     int poc_cycle_length;              ///< num_ref_frames_in_pic_order_cnt_cycle
+     int ref_frame_count;               ///< num_ref_frames
+     int gaps_in_frame_num_allowed_flag;
+     int mb_width;                      ///< pic_width_in_mbs_minus1 + 1
+     int mb_height;                     ///< pic_height_in_map_units_minus1 + 1
+     int frame_mbs_only_flag;
+     int mb_aff;                        ///< mb_adaptive_frame_field_flag
+     int direct_8x8_inference_flag;
+     int crop;                          ///< frame_cropping_flag
+ 
+     /* those 4 are already in luma samples */
+     unsigned int crop_left;            ///< frame_cropping_rect_left_offset
+     unsigned int crop_right;           ///< frame_cropping_rect_right_offset
+     unsigned int crop_top;             ///< frame_cropping_rect_top_offset
+     unsigned int crop_bottom;          ///< frame_cropping_rect_bottom_offset
+     int vui_parameters_present_flag;
+     AVRational sar;
+     int video_signal_type_present_flag;
+     int full_range;
+     int colour_description_present_flag;
+     enum AVColorPrimaries color_primaries;
+     enum AVColorTransferCharacteristic color_trc;
+     enum AVColorSpace colorspace;
+     int timing_info_present_flag;
+     uint32_t num_units_in_tick;
+     uint32_t time_scale;
+     int fixed_frame_rate_flag;
+     short offset_for_ref_frame[256]; // FIXME dyn aloc?
+     int bitstream_restriction_flag;
+     int num_reorder_frames;
+     int scaling_matrix_present;
+     uint8_t scaling_matrix4[6][16];
+     uint8_t scaling_matrix8[6][64];
+     int nal_hrd_parameters_present_flag;
+     int vcl_hrd_parameters_present_flag;
+     int pic_struct_present_flag;
+     int time_offset_length;
+     int cpb_cnt;                          ///< See H.264 E.1.2
+     int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1
+     int cpb_removal_delay_length;         ///< cpb_removal_delay_length_minus1 + 1
+     int dpb_output_delay_length;          ///< dpb_output_delay_length_minus1 + 1
+     int bit_depth_luma;                   ///< bit_depth_luma_minus8 + 8
+     int bit_depth_chroma;                 ///< bit_depth_chroma_minus8 + 8
+     int residual_color_transform_flag;    ///< residual_colour_transform_flag
+     int constraint_set_flags;             ///< constraint_set[0-3]_flag
++    uint8_t data[4096];
++    size_t data_size;
+ } SPS;
+ 
+ /**
+  * Picture parameter set
+  */
+ typedef struct PPS {
+     unsigned int sps_id;
+     int cabac;                  ///< entropy_coding_mode_flag
+     int pic_order_present;      ///< pic_order_present_flag
+     int slice_group_count;      ///< num_slice_groups_minus1 + 1
+     int mb_slice_group_map_type;
+     unsigned int ref_count[2];  ///< num_ref_idx_l0/1_active_minus1 + 1
+     int weighted_pred;          ///< weighted_pred_flag
+     int weighted_bipred_idc;
+     int init_qp;                ///< pic_init_qp_minus26 + 26
+     int init_qs;                ///< pic_init_qs_minus26 + 26
+     int chroma_qp_index_offset[2];
+     int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
+     int constrained_intra_pred;     ///< constrained_intra_pred_flag
+     int redundant_pic_cnt_present;  ///< redundant_pic_cnt_present_flag
+     int transform_8x8_mode;         ///< transform_8x8_mode_flag
+     uint8_t scaling_matrix4[6][16];
+     uint8_t scaling_matrix8[6][64];
 -    uint8_t chroma_qp_table[2][64]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
++    uint8_t chroma_qp_table[2][QP_MAX_NUM+1];  ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
+     int chroma_qp_diff;
++    uint8_t data[4096];
++    size_t data_size;
+ 
+     uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16];
+     uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
+     uint32_t(*dequant4_coeff[6])[16];
+     uint32_t(*dequant8_coeff[6])[64];
+ } PPS;
+ 
+ typedef struct H264ParamSets {
+     AVBufferRef *sps_list[MAX_SPS_COUNT];
+     AVBufferRef *pps_list[MAX_PPS_COUNT];
+ 
++    AVBufferRef *pps_ref;
++    AVBufferRef *sps_ref;
+     /* currently active parameters sets */
+     const PPS *pps;
 -    // FIXME this should properly be const
 -    SPS *sps;
++    const SPS *sps;
+ } H264ParamSets;
+ 
+ /**
+  * Decode SPS
+  */
+ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
 -                                     H264ParamSets *ps);
++                                     H264ParamSets *ps, int ignore_truncation);
+ 
+ /**
+  * Decode PPS
+  */
+ int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
+                                          H264ParamSets *ps, int bit_length);
+ 
+ #endif /* AVCODEC_H264_PS_H */
diff --cc libavcodec/h264dec.h
index c74b9fa,fbe68c1..a73a9dd
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@@ -48,11 -49,8 +49,8 @@@
  #include "rectangle.h"
  #include "videodsp.h"
  
 -#define H264_MAX_PICTURE_COUNT 32
 +#define H264_MAX_PICTURE_COUNT 36
  
- #define MAX_SPS_COUNT          32
- #define MAX_PPS_COUNT         256
- 
  #define MAX_MMCO_COUNT         66
  
  #define MAX_DELAYED_PIC_COUNT  16
@@@ -95,15 -91,12 +93,13 @@@
  #define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h))
  
  #ifndef CABAC
 -#define CABAC(h) h->ps.pps->cabac
 +#define CABAC(h) (h)->ps.pps->cabac
  #endif
  
 -#define CHROMA422(h) (h->ps.sps->chroma_format_idc == 2)
 -#define CHROMA444(h) (h->ps.sps->chroma_format_idc == 3)
 +#define CHROMA(h)    ((h)->ps.sps->chroma_format_idc)
 +#define CHROMA422(h) ((h)->ps.sps->chroma_format_idc == 2)
 +#define CHROMA444(h) ((h)->ps.sps->chroma_format_idc == 3)
  
- #define EXTENDED_SAR       255
- 
  #define MB_TYPE_REF0       MB_TYPE_ACPRED // dirty but it fits in 16 bit
  #define MB_TYPE_8x8DCT     0x01000000
  #define IS_REF0(a)         ((a) & MB_TYPE_REF0)
@@@ -677,24 -518,6 +564,12 @@@ typedef struct H264Context 
  extern const uint16_t ff_h264_mb_sizes[4];
  
  /**
 + * Uninit H264 param sets structure.
 + */
 +
 +void ff_h264_ps_uninit(H264ParamSets *ps);
 +
 +/**
-  * Decode SPS
-  */
- int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
-                                      H264ParamSets *ps, int ignore_truncation);
- 
- /**
-  * Decode PPS
-  */
- int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
-                                          H264ParamSets *ps, int bit_length);
- 
- /**
   * Reconstruct bitstream slice_type.
   */
  int ff_h264_get_slice_type(const H264SliceContext *sl);



More information about the ffmpeg-cvslog mailing list