yading@10
|
1 /*
|
yading@10
|
2 * Copyright (C) 2006 Smartjog S.A.S, Baptiste Coudurier <baptiste.coudurier@gmail.com>
|
yading@10
|
3 * Copyright (C) 2011 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.com>
|
yading@10
|
4 *
|
yading@10
|
5 * This file is part of FFmpeg.
|
yading@10
|
6 *
|
yading@10
|
7 * FFmpeg is free software; you can redistribute it and/or
|
yading@10
|
8 * modify it under the terms of the GNU Lesser General Public
|
yading@10
|
9 * License as published by the Free Software Foundation; either
|
yading@10
|
10 * version 2.1 of the License, or (at your option) any later version.
|
yading@10
|
11 *
|
yading@10
|
12 * FFmpeg is distributed in the hope that it will be useful,
|
yading@10
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@10
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@10
|
15 * Lesser General Public License for more details.
|
yading@10
|
16 *
|
yading@10
|
17 * You should have received a copy of the GNU Lesser General Public
|
yading@10
|
18 * License along with FFmpeg; if not, write to the Free Software
|
yading@10
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@10
|
20 */
|
yading@10
|
21
|
yading@10
|
22 /**
|
yading@10
|
23 * @file
|
yading@10
|
24 * Timecode helpers header
|
yading@10
|
25 * This *private* API is deprecated, please use the one available in libavutil instead.
|
yading@10
|
26 */
|
yading@10
|
27
|
yading@10
|
28 #ifndef AVCODEC_TIMECODE_H
|
yading@10
|
29 #define AVCODEC_TIMECODE_H
|
yading@10
|
30
|
yading@10
|
31 #include "version.h"
|
yading@10
|
32
|
yading@10
|
33 #if FF_API_OLD_TIMECODE
|
yading@10
|
34
|
yading@10
|
35 #include <stdint.h>
|
yading@10
|
36 #include "avcodec.h"
|
yading@10
|
37 #include "libavutil/rational.h"
|
yading@10
|
38
|
yading@10
|
39 #define TIMECODE_OPT(ctx, flags) \
|
yading@10
|
40 "timecode", "set timecode value following hh:mm:ss[:;.]ff format, " \
|
yading@10
|
41 "use ';' or '.' before frame number for drop frame", \
|
yading@10
|
42 offsetof(ctx, tc.str), \
|
yading@10
|
43 AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, flags
|
yading@10
|
44
|
yading@10
|
45 struct ff_timecode {
|
yading@10
|
46 char *str; ///< string following the hh:mm:ss[:;.]ff format
|
yading@10
|
47 int start; ///< timecode frame start
|
yading@10
|
48 int drop; ///< drop flag (1 if drop, else 0)
|
yading@10
|
49 AVRational rate; ///< Frame rate in rational form
|
yading@10
|
50 };
|
yading@10
|
51
|
yading@10
|
52 /**
|
yading@10
|
53 * @brief Adjust frame number for NTSC drop frame time code
|
yading@10
|
54 * @param frame_num Actual frame number to adjust
|
yading@10
|
55 * @return Adjusted frame number
|
yading@10
|
56 * @warning Adjustment is only valid in NTSC 29.97
|
yading@10
|
57 */
|
yading@10
|
58 int avpriv_framenum_to_drop_timecode(int frame_num);
|
yading@10
|
59
|
yading@10
|
60 /**
|
yading@10
|
61 * @brief Convert frame id (timecode) to SMPTE 12M binary representation
|
yading@10
|
62 * @param frame Frame number
|
yading@10
|
63 * @param fps Frame rate
|
yading@10
|
64 * @param drop Drop flag
|
yading@10
|
65 * @return The actual binary representation
|
yading@10
|
66 */
|
yading@10
|
67 uint32_t avpriv_framenum_to_smpte_timecode(unsigned frame, int fps, int drop);
|
yading@10
|
68
|
yading@10
|
69 /**
|
yading@10
|
70 * @brief Load timecode string in buf
|
yading@10
|
71 * @param buf Destination buffer
|
yading@10
|
72 * @param tc Timecode struct pointer
|
yading@10
|
73 * @param frame Frame id (timecode frame is computed with tc->start+frame)
|
yading@10
|
74 * @return a pointer to the buf parameter
|
yading@10
|
75 * @note timecode representation can be a negative timecode and have
|
yading@10
|
76 * more than 24 hours.
|
yading@10
|
77 * @note buf must have enough space to store the timecode representation: 16
|
yading@10
|
78 * bytes is the minimum required size.
|
yading@10
|
79 */
|
yading@10
|
80 char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigned frame);
|
yading@10
|
81
|
yading@10
|
82 /**
|
yading@10
|
83 * Check if timecode rate is valid and consistent with the drop flag.
|
yading@10
|
84 *
|
yading@10
|
85 * @return 0 on success, negative value on failure
|
yading@10
|
86 */
|
yading@10
|
87 int avpriv_check_timecode_rate(void *avcl, AVRational rate, int drop);
|
yading@10
|
88
|
yading@10
|
89 /**
|
yading@10
|
90 * Parse SMTPE 12M time representation (hh:mm:ss[:;.]ff). str and rate fields
|
yading@10
|
91 * from tc struct must be set.
|
yading@10
|
92 *
|
yading@10
|
93 * @param avcl A pointer to an arbitrary struct of which the first field is a
|
yading@10
|
94 * pointer to an AVClass struct (used for av_log).
|
yading@10
|
95 * @param tc Timecode struct pointer
|
yading@10
|
96 * @return 0 on success, negative value on failure
|
yading@10
|
97 * @warning Adjustement is only valid in NTSC 29.97
|
yading@10
|
98 */
|
yading@10
|
99 int avpriv_init_smpte_timecode(void *avcl, struct ff_timecode *tc);
|
yading@10
|
100
|
yading@10
|
101 attribute_deprecated int ff_framenum_to_drop_timecode(int frame_num);
|
yading@10
|
102 attribute_deprecated uint32_t ff_framenum_to_smtpe_timecode(unsigned frame, int fps, int drop);
|
yading@10
|
103 attribute_deprecated int ff_init_smtpe_timecode(void *avcl, struct ff_timecode *tc);
|
yading@10
|
104 #endif
|
yading@10
|
105
|
yading@10
|
106 #endif /* AVCODEC_TIMECODE_H */
|