2016-03-22 12:31:21 +00:00
|
|
|
/*
|
2016-06-18 12:04:17 +00:00
|
|
|
* This file is part of FFmpeg.
|
2016-03-22 12:31:21 +00:00
|
|
|
*
|
2016-06-18 12:04:17 +00:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2016-03-22 12:31:21 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2016-06-18 12:04:17 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2016-03-22 12:31:21 +00:00
|
|
|
* 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
|
2016-06-18 12:04:17 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2016-03-22 12:31:21 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVCODEC_H264_SEI_H
|
|
|
|
#define AVCODEC_H264_SEI_H
|
|
|
|
|
|
|
|
#include "get_bits.h"
|
2017-05-19 08:44:59 +00:00
|
|
|
#include "h264_ps.h"
|
2022-05-23 03:23:35 +00:00
|
|
|
#include "sei.h"
|
2016-03-22 12:31:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* pic_struct in picture timing SEI message
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2017-05-15 21:42:14 +00:00
|
|
|
H264_SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
|
|
|
|
H264_SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
|
|
|
|
H264_SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
|
|
|
|
H264_SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
|
|
|
|
H264_SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
|
|
|
|
H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
|
|
|
|
H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
|
|
|
|
H264_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
|
|
|
|
H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
|
|
|
|
} H264_SEI_PicStructType;
|
2016-03-22 12:31:21 +00:00
|
|
|
|
2016-06-18 12:04:17 +00:00
|
|
|
/**
|
|
|
|
* frame_packing_arrangement types
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2017-09-12 22:59:23 +00:00
|
|
|
H264_SEI_FPA_TYPE_CHECKERBOARD = 0,
|
|
|
|
H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN = 1,
|
|
|
|
H264_SEI_FPA_TYPE_INTERLEAVE_ROW = 2,
|
|
|
|
H264_SEI_FPA_TYPE_SIDE_BY_SIDE = 3,
|
|
|
|
H264_SEI_FPA_TYPE_TOP_BOTTOM = 4,
|
|
|
|
H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL = 5,
|
|
|
|
H264_SEI_FPA_TYPE_2D = 6,
|
|
|
|
} H264_SEI_FpaType;
|
2016-06-18 12:04:17 +00:00
|
|
|
|
2018-10-12 12:38:26 +00:00
|
|
|
typedef struct H264SEITimeCode {
|
|
|
|
/* When not continuously receiving full timecodes, we have to reference
|
|
|
|
the previous timecode received */
|
|
|
|
int full;
|
|
|
|
int frame;
|
|
|
|
int seconds;
|
|
|
|
int minutes;
|
|
|
|
int hours;
|
|
|
|
int dropframe;
|
|
|
|
} H264SEITimeCode;
|
|
|
|
|
2016-03-22 12:31:21 +00:00
|
|
|
typedef struct H264SEIPictureTiming {
|
2017-05-19 08:44:59 +00:00
|
|
|
// maximum size of pic_timing according to the spec should be 274 bits
|
|
|
|
uint8_t payload[40];
|
|
|
|
int payload_size_bits;
|
|
|
|
|
2017-02-14 22:45:01 +00:00
|
|
|
int present;
|
2017-05-15 21:42:14 +00:00
|
|
|
H264_SEI_PicStructType pic_struct;
|
2016-03-22 12:31:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 ct_type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dpb_output_delay in picture timing SEI message, see H.264 C.2.2
|
|
|
|
*/
|
|
|
|
int dpb_output_delay;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
|
|
|
|
*/
|
|
|
|
int cpb_removal_delay;
|
2018-06-29 18:57:13 +00:00
|
|
|
|
2018-10-12 12:38:26 +00:00
|
|
|
/**
|
|
|
|
* Maximum three timecodes in a pic_timing SEI.
|
|
|
|
*/
|
|
|
|
H264SEITimeCode timecode[3];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of timecode in use
|
|
|
|
*/
|
|
|
|
int timecode_cnt;
|
2016-03-22 12:31:21 +00:00
|
|
|
} H264SEIPictureTiming;
|
|
|
|
|
|
|
|
typedef struct H264SEIAFD {
|
|
|
|
int present;
|
|
|
|
uint8_t active_format_description;
|
|
|
|
} H264SEIAFD;
|
|
|
|
|
|
|
|
typedef struct H264SEIA53Caption {
|
2018-08-17 14:12:14 +00:00
|
|
|
AVBufferRef *buf_ref;
|
2016-03-22 12:31:21 +00:00
|
|
|
} H264SEIA53Caption;
|
|
|
|
|
|
|
|
typedef struct H264SEIUnregistered {
|
|
|
|
int x264_build;
|
2022-05-23 03:23:35 +00:00
|
|
|
AVBufferRef **buf_ref;
|
|
|
|
int nb_buf_ref;
|
2016-03-22 12:31:21 +00:00
|
|
|
} H264SEIUnregistered;
|
|
|
|
|
|
|
|
typedef struct H264SEIRecoveryPoint {
|
|
|
|
/**
|
|
|
|
* recovery_frame_cnt
|
|
|
|
*
|
|
|
|
* 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 recovery_frame_cnt;
|
|
|
|
} H264SEIRecoveryPoint;
|
|
|
|
|
|
|
|
typedef struct H264SEIBufferingPeriod {
|
|
|
|
int present; ///< Buffering period SEI flag
|
|
|
|
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
|
|
|
|
} H264SEIBufferingPeriod;
|
|
|
|
|
|
|
|
typedef struct H264SEIFramePacking {
|
|
|
|
int present;
|
2017-12-01 04:09:43 +00:00
|
|
|
int arrangement_id;
|
|
|
|
int arrangement_cancel_flag; ///< is previous arrangement canceled, -1 if never received
|
|
|
|
H264_SEI_FpaType arrangement_type;
|
|
|
|
int arrangement_repetition_period;
|
2016-03-22 12:31:21 +00:00
|
|
|
int content_interpretation_type;
|
2016-06-18 12:04:17 +00:00
|
|
|
int quincunx_sampling_flag;
|
2017-09-25 13:09:21 +00:00
|
|
|
int current_frame_is_frame0_flag;
|
2016-03-22 12:31:21 +00:00
|
|
|
} H264SEIFramePacking;
|
|
|
|
|
|
|
|
typedef struct H264SEIDisplayOrientation {
|
|
|
|
int present;
|
|
|
|
int anticlockwise_rotation;
|
|
|
|
int hflip, vflip;
|
|
|
|
} H264SEIDisplayOrientation;
|
|
|
|
|
2016-06-18 12:04:17 +00:00
|
|
|
typedef struct H264SEIGreenMetaData {
|
|
|
|
uint8_t green_metadata_type;
|
|
|
|
uint8_t period_type;
|
|
|
|
uint16_t num_seconds;
|
|
|
|
uint16_t num_pictures;
|
|
|
|
uint8_t percent_non_zero_macroblocks;
|
|
|
|
uint8_t percent_intra_coded_macroblocks;
|
|
|
|
uint8_t percent_six_tap_filtering;
|
|
|
|
uint8_t percent_alpha_point_deblocking_instance;
|
|
|
|
uint8_t xsd_metric_type;
|
|
|
|
uint16_t xsd_metric_value;
|
|
|
|
} H264SEIGreenMetaData;
|
|
|
|
|
2017-06-09 21:27:22 +00:00
|
|
|
typedef struct H264SEIAlternativeTransfer {
|
|
|
|
int present;
|
|
|
|
int preferred_transfer_characteristics;
|
|
|
|
} H264SEIAlternativeTransfer;
|
|
|
|
|
2024-04-25 09:18:18 +00:00
|
|
|
typedef struct H264SEIFilmGrainCharacteristics {
|
|
|
|
int present;
|
|
|
|
int model_id;
|
|
|
|
int separate_colour_description_present_flag;
|
|
|
|
int bit_depth_luma;
|
|
|
|
int bit_depth_chroma;
|
|
|
|
int full_range;
|
|
|
|
int color_primaries;
|
|
|
|
int transfer_characteristics;
|
|
|
|
int matrix_coeffs;
|
|
|
|
int blending_mode_id;
|
|
|
|
int log2_scale_factor;
|
|
|
|
int comp_model_present_flag[3];
|
|
|
|
uint16_t num_intensity_intervals[3];
|
|
|
|
uint8_t num_model_values[3];
|
|
|
|
uint8_t intensity_interval_lower_bound[3][256];
|
|
|
|
uint8_t intensity_interval_upper_bound[3][256];
|
|
|
|
int16_t comp_model_value[3][256][6];
|
|
|
|
int repetition_period;
|
|
|
|
} H264SEIFilmGrainCharacteristics;
|
|
|
|
|
2016-03-22 12:31:21 +00:00
|
|
|
typedef struct H264SEIContext {
|
|
|
|
H264SEIPictureTiming picture_timing;
|
|
|
|
H264SEIAFD afd;
|
|
|
|
H264SEIA53Caption a53_caption;
|
|
|
|
H264SEIUnregistered unregistered;
|
|
|
|
H264SEIRecoveryPoint recovery_point;
|
|
|
|
H264SEIBufferingPeriod buffering_period;
|
|
|
|
H264SEIFramePacking frame_packing;
|
|
|
|
H264SEIDisplayOrientation display_orientation;
|
2016-06-18 12:04:17 +00:00
|
|
|
H264SEIGreenMetaData green_metadata;
|
2017-06-09 21:27:22 +00:00
|
|
|
H264SEIAlternativeTransfer alternative_transfer;
|
2024-04-25 09:18:18 +00:00
|
|
|
H264SEIFilmGrainCharacteristics film_grain_characteristics;
|
2016-03-22 12:31:21 +00:00
|
|
|
} H264SEIContext;
|
|
|
|
|
|
|
|
struct H264ParamSets;
|
|
|
|
|
|
|
|
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
|
|
|
|
const struct H264ParamSets *ps, void *logctx);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset SEI values at the beginning of the frame.
|
|
|
|
*/
|
|
|
|
void ff_h264_sei_uninit(H264SEIContext *h);
|
|
|
|
|
2016-06-18 12:04:17 +00:00
|
|
|
/**
|
|
|
|
* Get stereo_mode string from the h264 frame_packing_arrangement
|
|
|
|
*/
|
|
|
|
const char *ff_h264_sei_stereo_mode(const H264SEIFramePacking *h);
|
|
|
|
|
2017-05-19 08:44:59 +00:00
|
|
|
/**
|
|
|
|
* Parse the contents of a picture timing message given an active SPS.
|
|
|
|
*/
|
|
|
|
int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps,
|
|
|
|
void *logctx);
|
|
|
|
|
2016-03-22 12:31:21 +00:00
|
|
|
#endif /* AVCODEC_H264_SEI_H */
|