You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.9KB

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