yading@10: /* yading@10: * Copyright (C) 2006 Smartjog S.A.S, Baptiste Coudurier yading@10: * Copyright (C) 2011 Smartjog S.A.S, Clément Bœsch yading@10: * yading@10: * This file is part of FFmpeg. yading@10: * yading@10: * FFmpeg is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * FFmpeg is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with FFmpeg; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: /** yading@10: * @file yading@10: * Timecode helpers header yading@10: * This *private* API is deprecated, please use the one available in libavutil instead. yading@10: */ yading@10: yading@10: #ifndef AVCODEC_TIMECODE_H yading@10: #define AVCODEC_TIMECODE_H yading@10: yading@10: #include "version.h" yading@10: yading@10: #if FF_API_OLD_TIMECODE yading@10: yading@10: #include yading@10: #include "avcodec.h" yading@10: #include "libavutil/rational.h" yading@10: yading@10: #define TIMECODE_OPT(ctx, flags) \ yading@10: "timecode", "set timecode value following hh:mm:ss[:;.]ff format, " \ yading@10: "use ';' or '.' before frame number for drop frame", \ yading@10: offsetof(ctx, tc.str), \ yading@10: AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, flags yading@10: yading@10: struct ff_timecode { yading@10: char *str; ///< string following the hh:mm:ss[:;.]ff format yading@10: int start; ///< timecode frame start yading@10: int drop; ///< drop flag (1 if drop, else 0) yading@10: AVRational rate; ///< Frame rate in rational form yading@10: }; yading@10: yading@10: /** yading@10: * @brief Adjust frame number for NTSC drop frame time code yading@10: * @param frame_num Actual frame number to adjust yading@10: * @return Adjusted frame number yading@10: * @warning Adjustment is only valid in NTSC 29.97 yading@10: */ yading@10: int avpriv_framenum_to_drop_timecode(int frame_num); yading@10: yading@10: /** yading@10: * @brief Convert frame id (timecode) to SMPTE 12M binary representation yading@10: * @param frame Frame number yading@10: * @param fps Frame rate yading@10: * @param drop Drop flag yading@10: * @return The actual binary representation yading@10: */ yading@10: uint32_t avpriv_framenum_to_smpte_timecode(unsigned frame, int fps, int drop); yading@10: yading@10: /** yading@10: * @brief Load timecode string in buf yading@10: * @param buf Destination buffer yading@10: * @param tc Timecode struct pointer yading@10: * @param frame Frame id (timecode frame is computed with tc->start+frame) yading@10: * @return a pointer to the buf parameter yading@10: * @note timecode representation can be a negative timecode and have yading@10: * more than 24 hours. yading@10: * @note buf must have enough space to store the timecode representation: 16 yading@10: * bytes is the minimum required size. yading@10: */ yading@10: char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigned frame); yading@10: yading@10: /** yading@10: * Check if timecode rate is valid and consistent with the drop flag. yading@10: * yading@10: * @return 0 on success, negative value on failure yading@10: */ yading@10: int avpriv_check_timecode_rate(void *avcl, AVRational rate, int drop); yading@10: yading@10: /** yading@10: * Parse SMTPE 12M time representation (hh:mm:ss[:;.]ff). str and rate fields yading@10: * from tc struct must be set. yading@10: * yading@10: * @param avcl A pointer to an arbitrary struct of which the first field is a yading@10: * pointer to an AVClass struct (used for av_log). yading@10: * @param tc Timecode struct pointer yading@10: * @return 0 on success, negative value on failure yading@10: * @warning Adjustement is only valid in NTSC 29.97 yading@10: */ yading@10: int avpriv_init_smpte_timecode(void *avcl, struct ff_timecode *tc); yading@10: yading@10: attribute_deprecated int ff_framenum_to_drop_timecode(int frame_num); yading@10: attribute_deprecated uint32_t ff_framenum_to_smtpe_timecode(unsigned frame, int fps, int drop); yading@10: attribute_deprecated int ff_init_smtpe_timecode(void *avcl, struct ff_timecode *tc); yading@10: #endif yading@10: yading@10: #endif /* AVCODEC_TIMECODE_H */