annotate ffmpeg/libavutil/timecode.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * Copyright (c) 2006 Smartjog S.A.S, Baptiste Coudurier <baptiste.coudurier@gmail.com>
yading@11 3 * Copyright (c) 2011-2012 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.com>
yading@11 4 *
yading@11 5 * This file is part of FFmpeg.
yading@11 6 *
yading@11 7 * FFmpeg is free software; you can redistribute it and/or
yading@11 8 * modify it under the terms of the GNU Lesser General Public
yading@11 9 * License as published by the Free Software Foundation; either
yading@11 10 * version 2.1 of the License, or (at your option) any later version.
yading@11 11 *
yading@11 12 * FFmpeg is distributed in the hope that it will be useful,
yading@11 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 15 * Lesser General Public License for more details.
yading@11 16 *
yading@11 17 * You should have received a copy of the GNU Lesser General Public
yading@11 18 * License along with FFmpeg; if not, write to the Free Software
yading@11 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 20 */
yading@11 21
yading@11 22 /**
yading@11 23 * @file
yading@11 24 * Timecode helpers header
yading@11 25 */
yading@11 26
yading@11 27 #ifndef AVUTIL_TIMECODE_H
yading@11 28 #define AVUTIL_TIMECODE_H
yading@11 29
yading@11 30 #include <stdint.h>
yading@11 31 #include "rational.h"
yading@11 32
yading@11 33 #define AV_TIMECODE_STR_SIZE 16
yading@11 34
yading@11 35 enum AVTimecodeFlag {
yading@11 36 AV_TIMECODE_FLAG_DROPFRAME = 1<<0, ///< timecode is drop frame
yading@11 37 AV_TIMECODE_FLAG_24HOURSMAX = 1<<1, ///< timecode wraps after 24 hours
yading@11 38 AV_TIMECODE_FLAG_ALLOWNEGATIVE = 1<<2, ///< negative time values are allowed
yading@11 39 };
yading@11 40
yading@11 41 typedef struct {
yading@11 42 int start; ///< timecode frame start (first base frame number)
yading@11 43 uint32_t flags; ///< flags such as drop frame, +24 hours support, ...
yading@11 44 AVRational rate; ///< frame rate in rational form
yading@11 45 unsigned fps; ///< frame per second; must be consistent with the rate field
yading@11 46 } AVTimecode;
yading@11 47
yading@11 48 /**
yading@11 49 * Adjust frame number for NTSC drop frame time code.
yading@11 50 *
yading@11 51 * @param framenum frame number to adjust
yading@11 52 * @param fps frame per second, 30 or 60
yading@11 53 * @return adjusted frame number
yading@11 54 * @warning adjustment is only valid in NTSC 29.97 and 59.94
yading@11 55 */
yading@11 56 int av_timecode_adjust_ntsc_framenum2(int framenum, int fps);
yading@11 57
yading@11 58 /**
yading@11 59 * Convert frame number to SMPTE 12M binary representation.
yading@11 60 *
yading@11 61 * @param tc timecode data correctly initialized
yading@11 62 * @param framenum frame number
yading@11 63 * @return the SMPTE binary representation
yading@11 64 *
yading@11 65 * @note Frame number adjustment is automatically done in case of drop timecode,
yading@11 66 * you do NOT have to call av_timecode_adjust_ntsc_framenum2().
yading@11 67 * @note The frame number is relative to tc->start.
yading@11 68 * @note Color frame (CF), binary group flags (BGF) and biphase mark polarity
yading@11 69 * correction (PC) bits are set to zero.
yading@11 70 */
yading@11 71 uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum);
yading@11 72
yading@11 73 /**
yading@11 74 * Load timecode string in buf.
yading@11 75 *
yading@11 76 * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
yading@11 77 * @param tc timecode data correctly initialized
yading@11 78 * @param framenum frame number
yading@11 79 * @return the buf parameter
yading@11 80 *
yading@11 81 * @note Timecode representation can be a negative timecode and have more than
yading@11 82 * 24 hours, but will only be honored if the flags are correctly set.
yading@11 83 * @note The frame number is relative to tc->start.
yading@11 84 */
yading@11 85 char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum);
yading@11 86
yading@11 87 /**
yading@11 88 * Get the timecode string from the SMPTE timecode format.
yading@11 89 *
yading@11 90 * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
yading@11 91 * @param tcsmpte the 32-bit SMPTE timecode
yading@11 92 * @param prevent_df prevent the use of a drop flag when it is known the DF bit
yading@11 93 * is arbitrary
yading@11 94 * @return the buf parameter
yading@11 95 */
yading@11 96 char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df);
yading@11 97
yading@11 98 /**
yading@11 99 * Get the timecode string from the 25-bit timecode format (MPEG GOP format).
yading@11 100 *
yading@11 101 * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
yading@11 102 * @param tc25bit the 25-bits timecode
yading@11 103 * @return the buf parameter
yading@11 104 */
yading@11 105 char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit);
yading@11 106
yading@11 107 /**
yading@11 108 * Init a timecode struct with the passed parameters.
yading@11 109 *
yading@11 110 * @param log_ctx a pointer to an arbitrary struct of which the first field
yading@11 111 * is a pointer to an AVClass struct (used for av_log)
yading@11 112 * @param tc pointer to an allocated AVTimecode
yading@11 113 * @param rate frame rate in rational form
yading@11 114 * @param flags miscellaneous flags such as drop frame, +24 hours, ...
yading@11 115 * (see AVTimecodeFlag)
yading@11 116 * @param frame_start the first frame number
yading@11 117 * @return 0 on success, AVERROR otherwise
yading@11 118 */
yading@11 119 int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx);
yading@11 120
yading@11 121 /**
yading@11 122 * Parse timecode representation (hh:mm:ss[:;.]ff).
yading@11 123 *
yading@11 124 * @param log_ctx a pointer to an arbitrary struct of which the first field is a
yading@11 125 * pointer to an AVClass struct (used for av_log).
yading@11 126 * @param tc pointer to an allocated AVTimecode
yading@11 127 * @param rate frame rate in rational form
yading@11 128 * @param str timecode string which will determine the frame start
yading@11 129 * @return 0 on success, AVERROR otherwise
yading@11 130 */
yading@11 131 int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx);
yading@11 132
yading@11 133 /**
yading@11 134 * Check if the timecode feature is available for the given frame rate
yading@11 135 *
yading@11 136 * @return 0 if supported, <0 otherwise
yading@11 137 */
yading@11 138 int av_timecode_check_frame_rate(AVRational rate);
yading@11 139
yading@11 140 #endif /* AVUTIL_TIMECODE_H */