1 /*****************************************************************************
2 * hxxx_helper.h: AnnexB / avcC helper for dumb decoders
3 *****************************************************************************
4 * Copyright (C) 2017 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
25 #include <vlc_block.h>
26 #include <vlc_fourcc.h>
28 #include "../packetizer/h264_nal.h"
29 #include "../packetizer/hevc_nal.h"
31 struct hxxx_helper_nal
36 h264_sequence_parameter_set_t
*h264_sps
;
37 h264_picture_parameter_set_t
*h264_pps
;
38 hevc_sequence_parameter_set_t
*hevc_sps
;
39 hevc_picture_parameter_set_t
*hevc_pps
;
40 hevc_video_parameter_set_t
*hevc_vps
;
44 #define HXXX_HELPER_SEI_COUNT 16
48 vlc_object_t
*p_obj
; /* for logs */
50 bool b_need_xvcC
; /* Need avcC or hvcC */
53 uint8_t i_nal_length_size
;
56 struct hxxx_helper_nal sps_list
[H264_SPS_ID_MAX
+ 1];
57 struct hxxx_helper_nal pps_list
[H264_PPS_ID_MAX
+ 1];
58 uint8_t i_current_sps
;
63 struct hxxx_helper_nal sps_list
[HEVC_SPS_ID_MAX
+ 1];
64 struct hxxx_helper_nal pps_list
[HEVC_PPS_ID_MAX
+ 1];
65 struct hxxx_helper_nal vps_list
[HEVC_VPS_ID_MAX
+ 1];
66 struct hxxx_helper_nal sei_list
[HXXX_HELPER_SEI_COUNT
];
67 uint8_t i_current_sps
;
68 uint8_t i_current_vps
;
73 uint8_t i_previous_nal_type
;
77 /* Process the block: do the AnnexB <-> xvcC conversion if needed. If
78 * p_config_changed is not NULL, parse nals to detect a SPS/PPS or a video
80 block_t
* (*pf_process_block
)(struct hxxx_helper
*hh
, block_t
*p_block
,
81 bool *p_config_changed
);
84 void hxxx_helper_init(struct hxxx_helper
*hh
, vlc_object_t
*p_obj
,
85 vlc_fourcc_t i_codec
, bool b_need_xvcC
);
86 void hxxx_helper_clean(struct hxxx_helper
*hh
);
88 int hxxx_helper_set_extra(struct hxxx_helper
*hh
, const void *p_extra
,
91 block_t
*h264_helper_get_annexb_config(const struct hxxx_helper
*hh
);
92 block_t
*hevc_helper_get_annexb_config(const struct hxxx_helper
*hh
);
94 block_t
*h264_helper_get_avcc_config(const struct hxxx_helper
*hh
);
95 block_t
*hevc_helper_get_hvcc_config(const struct hxxx_helper
*hh
);
97 int hxxx_helper_get_current_picture_size(const struct hxxx_helper
*hh
,
98 unsigned *p_w
, unsigned *p_h
,
99 unsigned *p_vw
, unsigned *p_vh
);
101 int hxxx_helper_get_current_sar(const struct hxxx_helper
*hh
, int *p_num
, int *p_den
);
103 int h264_helper_get_current_dpb_values(const struct hxxx_helper
*hh
,
104 uint8_t *p_depth
, unsigned *pi_delay
);
106 int hxxx_helper_get_current_profile_level(const struct hxxx_helper
*hh
,
107 uint8_t *p_profile
, uint8_t *p_level
);
110 hxxx_helper_get_chroma_chroma(const struct hxxx_helper
*hh
, uint8_t *pi_chroma_format
,
111 uint8_t *pi_depth_luma
, uint8_t *pi_depth_chroma
);
113 int hxxx_helper_get_colorimetry(const struct hxxx_helper
*hh
,
114 video_color_primaries_t
*p_primaries
,
115 video_transfer_func_t
*p_transfer
,
116 video_color_space_t
*p_colorspace
,
117 video_color_range_t
*p_full_range
);