]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264.h
Add functions to return library license and library configuration.
[ffmpeg] / libavcodec / h264.h
index 8bbf84f2c2acd7298fe9b42e38a360d78f4980ab..fa348a201fb84336e8654ecfe0edb9fbafacc2d4 100644 (file)
 #define CHROMA 1
 #endif
 
-#ifndef CONFIG_H264_ENCODER
-#define CONFIG_H264_ENCODER 0
-#endif
-
 #define EXTENDED_SAR          255
 
 #define MB_TYPE_REF0       MB_TYPE_ACPRED //dirty but it fits in 16 bit
@@ -115,6 +111,16 @@ enum {
     NAL_AUXILIARY_SLICE=19
 };
 
+/**
+ * SEI message types
+ */
+typedef enum {
+    SEI_BUFFERING_PERIOD             =  0, ///< buffering period (H.264, D.1.1)
+    SEI_TYPE_PIC_TIMING              =  1, ///< picture timing
+    SEI_TYPE_USER_DATA_UNREGISTERED  =  5, ///< unregistered user data
+    SEI_TYPE_RECOVERY_POINT          =  6  ///< recovery point (frame # to decoder sync)
+} SEI_Type;
+
 /**
  * pic_struct in picture timing SEI message
  */
@@ -174,6 +180,8 @@ typedef struct SPS{
     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
@@ -342,7 +350,7 @@ typedef struct H264Context{
     int mb_field_decoding_flag;
     int mb_mbaff;              ///< mb_aff_frame && mb_field_decoding_flag
 
-    uint16_t sub_mb_type[4];
+    DECLARE_ALIGNED_8(uint16_t, sub_mb_type[4]);
 
     //POC stuff
     int poc_lsb;
@@ -495,10 +503,83 @@ typedef struct H264Context{
      */
     SEI_PicStructType sei_pic_struct;
 
+    /**
+     * Complement sei_pic_struct
+     * SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced frames.
+     * However, soft telecined frames may have these values.
+     * This is used in an attempt to flag soft telecine progressive.
+     */
+    int prev_interlaced_frame;
+
+    /**
+     * Bit set of clock types for fields/frames in picture timing SEI message.
+     * For each found ct_type, appropriate bit is set (e.g., bit 1 for
+     * interlaced).
+     */
+    int sei_ct_type;
+
+    /**
+     * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
+     */
+    int sei_dpb_output_delay;
+
+    /**
+     * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
+     */
+    int sei_cpb_removal_delay;
+
+    /**
+     * recovery_frame_cnt from SEI message
+     *
+     * Set to -1 if no recovery point SEI message found or to number of frames
+     * before playback synchronizes. Frames having recovery point are key
+     * frames.
+     */
+    int sei_recovery_frame_cnt;
+
     int is_complex;
 
     int luma_weight_flag[2];   ///< 7.4.3.2 luma_weight_lX_flag
     int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
+
+    // Timestamp stuff
+    int sei_buffering_period_present;  ///< Buffering period SEI flag
+    int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
 }H264Context;
 
+/**
+ * Decode SEI
+ */
+int ff_h264_decode_sei(H264Context *h);
+
+/**
+ * Decode SPS
+ */
+int ff_h264_decode_seq_parameter_set(H264Context *h);
+
+/**
+ * Decode PPS
+ */
+int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length);
+
+/**
+ * Decodes a network abstraction layer unit.
+ * @param consumed is the number of bytes used as input
+ * @param length is the length of the array
+ * @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing?
+ * @returns decoded bytes, might be src+1 if no escapes
+ */
+const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length);
+
+/**
+ * identifies the exact end of the bitstream
+ * @return the length of the trailing, or 0 if damaged
+ */
+int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src);
+
+/**
+ * frees any data that may have been allocated in the H264 context like SPS, PPS etc.
+ */
+av_cold void ff_h264_free_context(H264Context *h);
+
 #endif /* AVCODEC_H264_H */