1 /***************************************************************************** 2 * libavsmash_video.h 3 ***************************************************************************** 4 * Copyright (C) 2012-2015 L-SMASH Works project 5 * 6 * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com> 7 * 8 * Permission to use, copy, modify, and/or distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above 10 * copyright notice and this permission notice appear in all copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 *****************************************************************************/ 20 21 /* This file is available under an ISC license. */ 22 23 /***************************************************************************** 24 * Opaque Handlers 25 *****************************************************************************/ 26 typedef lw_video_scaler_handler_t libavsmash_video_scaler_handler_t; 27 typedef lw_video_output_handler_t libavsmash_video_output_handler_t; 28 29 typedef struct libavsmash_video_decode_handler_tag libavsmash_video_decode_handler_t; 30 31 /***************************************************************************** 32 * Allocators / Deallocators 33 *****************************************************************************/ 34 libavsmash_video_decode_handler_t *libavsmash_video_alloc_decode_handler 35 ( 36 void 37 ); 38 39 libavsmash_video_output_handler_t *libavsmash_video_alloc_output_handler 40 ( 41 void 42 ); 43 44 void libavsmash_video_free_decode_handler 45 ( 46 libavsmash_video_decode_handler_t *vdhp 47 ); 48 49 void libavsmash_video_free_output_handler 50 ( 51 libavsmash_video_output_handler_t *vohp 52 ); 53 54 void libavsmash_video_free_decode_handler_ptr 55 ( 56 libavsmash_video_decode_handler_t **vdhpp 57 ); 58 59 void libavsmash_video_free_output_handler_ptr 60 ( 61 libavsmash_video_output_handler_t **vohpp 62 ); 63 64 /***************************************************************************** 65 * Setters 66 *****************************************************************************/ 67 void libavsmash_video_set_root 68 ( 69 libavsmash_video_decode_handler_t *vdhp, 70 lsmash_root_t *root 71 ); 72 73 void libavsmash_video_set_track_id 74 ( 75 libavsmash_video_decode_handler_t *vdhp, 76 uint32_t track_id 77 ); 78 79 void libavsmash_video_set_forward_seek_threshold 80 ( 81 libavsmash_video_decode_handler_t *vdhp, 82 uint32_t forward_seek_threshold 83 ); 84 85 void libavsmash_video_set_seek_mode 86 ( 87 libavsmash_video_decode_handler_t *vdhp, 88 int seek_mode 89 ); 90 91 void libavsmash_video_set_preferred_decoder_names 92 ( 93 libavsmash_video_decode_handler_t *vdhp, 94 const char **preferred_decoder_names 95 ); 96 97 void libavsmash_video_set_log_handler 98 ( 99 libavsmash_video_decode_handler_t *vdhp, 100 lw_log_handler_t *lh 101 ); 102 103 void libavsmash_video_set_get_buffer_func 104 ( 105 libavsmash_video_decode_handler_t *vdhp 106 ); 107 108 /***************************************************************************** 109 * Getters 110 *****************************************************************************/ 111 lsmash_root_t *libavsmash_video_get_root 112 ( 113 libavsmash_video_decode_handler_t *vdhp 114 ); 115 116 uint32_t libavsmash_video_get_track_id 117 ( 118 libavsmash_video_decode_handler_t *vdhp 119 ); 120 121 uint32_t libavsmash_video_get_forward_seek_threshold 122 ( 123 libavsmash_video_decode_handler_t *vdhp 124 ); 125 126 int libavsmash_video_get_seek_mode 127 ( 128 libavsmash_video_decode_handler_t *vdhp 129 ); 130 131 const char **libavsmash_video_get_preferred_decoder_names 132 ( 133 libavsmash_video_decode_handler_t *vdhp 134 ); 135 136 int libavsmash_video_get_error 137 ( 138 libavsmash_video_decode_handler_t *vdhp 139 ); 140 141 lw_log_handler_t *libavsmash_video_get_log_handler 142 ( 143 libavsmash_video_decode_handler_t *vdhp 144 ); 145 146 AVCodecContext *libavsmash_video_get_codec_context 147 ( 148 libavsmash_video_decode_handler_t *vdhp 149 ); 150 151 int libavsmash_video_get_max_width 152 ( 153 libavsmash_video_decode_handler_t *vdhp 154 ); 155 156 int libavsmash_video_get_max_height 157 ( 158 libavsmash_video_decode_handler_t *vdhp 159 ); 160 161 AVFrame *libavsmash_video_get_frame_buffer 162 ( 163 libavsmash_video_decode_handler_t *vdhp 164 ); 165 166 uint32_t libavsmash_video_get_sample_count 167 ( 168 libavsmash_video_decode_handler_t *vdhp 169 ); 170 171 uint32_t libavsmash_video_get_media_timescale 172 ( 173 libavsmash_video_decode_handler_t *vdhp 174 ); 175 176 uint64_t libavsmash_video_get_media_duration 177 ( 178 libavsmash_video_decode_handler_t *vdhp 179 ); 180 181 /* This function must be called after a success of libavsmash_video_setup_timestamp_info(). */ 182 uint64_t libavsmash_video_get_min_cts 183 ( 184 libavsmash_video_decode_handler_t *vdhp 185 ); 186 187 /***************************************************************************** 188 * Others 189 *****************************************************************************/ 190 int libavsmash_video_get_track 191 ( 192 libavsmash_video_decode_handler_t *vdhp, 193 uint32_t track_number 194 ); 195 196 int libavsmash_video_initialize_decoder_configuration 197 ( 198 libavsmash_video_decode_handler_t *vdhp, 199 AVFormatContext *format_ctx, 200 int threads 201 ); 202 203 int libavsmash_video_get_summaries 204 ( 205 libavsmash_video_decode_handler_t *vdhp 206 ); 207 208 void libavsmash_video_force_seek 209 ( 210 libavsmash_video_decode_handler_t *vdhp 211 ); 212 213 uint32_t libavsmash_video_get_coded_sample_number 214 ( 215 libavsmash_video_decode_handler_t *vdhp, 216 uint32_t composition_sample_number 217 ); 218 219 int libavsmash_video_get_cts 220 ( 221 libavsmash_video_decode_handler_t *vdhp, 222 uint32_t coded_sample_number, 223 uint64_t *cts 224 ); 225 226 int libavsmash_video_get_sample_duration 227 ( 228 libavsmash_video_decode_handler_t *vdhp, 229 uint32_t coded_sample_number, 230 uint32_t *sample_duration 231 ); 232 233 void libavsmash_video_clear_error 234 ( 235 libavsmash_video_decode_handler_t *vdhp 236 ); 237 238 void libavsmash_video_close_codec_context 239 ( 240 libavsmash_video_decode_handler_t *vdhp 241 ); 242 243 /* Setup average framerate and timestamp list. 244 * This function sets an error if failed to get the minimum composition timestamp. 245 * The minimum composition timestamp is used for VFR -> CFR conversion. */ 246 int libavsmash_video_setup_timestamp_info 247 ( 248 libavsmash_video_decode_handler_t *vdhp, 249 libavsmash_video_output_handler_t *vohp, 250 int64_t *framerate_num, 251 int64_t *framerate_den 252 ); 253 254 int libavsmash_video_get_frame 255 ( 256 libavsmash_video_decode_handler_t *vdhp, 257 libavsmash_video_output_handler_t *vohp, 258 uint32_t sample_number 259 ); 260 261 int libavsmash_video_find_first_valid_frame 262 ( 263 libavsmash_video_decode_handler_t *vdhp 264 ); 265 266 int libavsmash_video_create_keyframe_list 267 ( 268 libavsmash_video_decode_handler_t *vdhp 269 ); 270 271 int libavsmash_video_is_keyframe 272 ( 273 libavsmash_video_decode_handler_t *vdhp, 274 libavsmash_video_output_handler_t *vohp, 275 uint32_t sample_number 276 ); 277