Commit 80914cde authored by Clément Bœsch's avatar Clément Bœsch Committed by Clément Bœsch

timecode: rename internal ff_* symbols to avpriv_*.

Those functions are shared between libs.

Also fix a typo in function names: smtpe → smpte.
parent fa4e30af
......@@ -182,7 +182,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (s->tc.str) {
s->tc.rate = avpriv_frame_rate_tab[s->frame_rate_index];
if (ff_init_smtpe_timecode(s, &s->tc) < 0)
if (avpriv_init_smpte_timecode(s, &s->tc) < 0)
return -1;
s->avctx->timecode_frame_start = s->tc.start;
} else {
......@@ -303,7 +303,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
av_assert0(s->drop_frame_timecode == s->tc.drop);
if (s->tc.drop)
time_code = ff_framenum_to_drop_timecode(time_code);
time_code = avpriv_framenum_to_drop_timecode(time_code);
put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
put_bits(&s->pb, 1, 1);
......
......@@ -28,7 +28,7 @@
#include "timecode.h"
#include "libavutil/log.h"
int ff_framenum_to_drop_timecode(int frame_num)
int avpriv_framenum_to_drop_timecode(int frame_num)
{
/* only works for NTSC 29.97 */
int d = frame_num / 17982;
......@@ -37,7 +37,7 @@ int ff_framenum_to_drop_timecode(int frame_num)
return frame_num + 18 * d + 2 * ((m - 2) / 1798);
}
uint32_t ff_framenum_to_smtpe_timecode(unsigned frame, int fps, int drop)
uint32_t avpriv_framenum_to_smpte_timecode(unsigned frame, int fps, int drop)
{
return (0 << 31) | // color frame flag
(drop << 30) | // drop frame flag
......@@ -89,13 +89,13 @@ char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigne
int hh = frame_num / (fps*3600) % 24;
if (tc->drop)
frame_num = ff_framenum_to_drop_timecode(frame_num);
frame_num = avpriv_framenum_to_drop_timecode(frame_num);
snprintf(buf, sizeof("hh:mm:ss.ff"), "%02d:%02d:%02d%c%02d",
hh, mm, ss, tc->drop ? ';' : ':', ff);
return buf;
}
int ff_init_smtpe_timecode(void *avcl, struct ff_timecode *tc)
int avpriv_init_smpte_timecode(void *avcl, struct ff_timecode *tc)
{
int hh, mm, ss, ff, fps, ret;
char c;
......@@ -121,3 +121,20 @@ int ff_init_smtpe_timecode(void *avcl, struct ff_timecode *tc)
}
return 0;
}
#if FF_API_OLD_TIMECODE
int ff_framenum_to_drop_timecode(int frame_num)
{
return avpriv_framenum_to_drop_timecode(frame_num);
}
uint32_t ff_framenum_to_smtpe_timecode(unsigned frame, int fps, int drop)
{
return avpriv_framenum_to_smpte_timecode(frame, fps, drop);
}
int ff_init_smtpe_timecode(void *avcl, struct ff_timecode *tc)
{
return avpriv_init_smpte_timecode(avcl, tc);
}
#endif
......@@ -28,6 +28,7 @@
#define AVCODEC_TIMECODE_H
#include <stdint.h>
#include "avcodec.h"
#include "libavutil/rational.h"
#define TIMECODE_OPT(ctx, flags) \
......@@ -49,7 +50,7 @@ struct ff_timecode {
* @return Adjusted frame number
* @warning Adjustment is only valid in NTSC 29.97
*/
int ff_framenum_to_drop_timecode(int frame_num);
int avpriv_framenum_to_drop_timecode(int frame_num);
/**
* @brief Convert frame id (timecode) to SMPTE 12M binary representation
......@@ -58,7 +59,7 @@ int ff_framenum_to_drop_timecode(int frame_num);
* @param drop Drop flag
* @return The actual binary representation
*/
uint32_t ff_framenum_to_smtpe_timecode(unsigned frame, int fps, int drop);
uint32_t avpriv_framenum_to_smpte_timecode(unsigned frame, int fps, int drop);
/**
* @brief Load timecode string in buf
......@@ -81,6 +82,12 @@ char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigne
* @return 0 on success, negative value on failure
* @warning Adjustement is only valid in NTSC 29.97
*/
int ff_init_smtpe_timecode(void *avcl, struct ff_timecode *tc);
int avpriv_init_smpte_timecode(void *avcl, struct ff_timecode *tc);
#if FF_API_OLD_TIMECODE
attribute_deprecated int ff_framenum_to_drop_timecode(int frame_num);
attribute_deprecated uint32_t ff_framenum_to_smtpe_timecode(unsigned frame, int fps, int drop);
attribute_deprecated int ff_init_smtpe_timecode(void *avcl, struct ff_timecode *tc);
#endif
#endif /* AVCODEC_TIMECODE_H */
......@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 42
#define LIBAVCODEC_VERSION_MINOR 43
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......@@ -116,5 +116,9 @@
#ifndef FF_API_OLD_DECODE_AUDIO
#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_OLD_TIMECODE
#define FF_API_OLD_TIMECODE (LIBAVCODEC_VERSION_MAJOR < 54)
#endif
#endif /* AVCODEC_VERSION_H */
......@@ -341,7 +341,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
}
if (dtext->tc.str) {
if (ff_init_smtpe_timecode(ctx, &dtext->tc) < 0)
if (avpriv_init_smpte_timecode(ctx, &dtext->tc) < 0)
return AVERROR(EINVAL);
if (!dtext->text)
dtext->text = av_strdup("");
......
......@@ -92,9 +92,9 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
*/
ltc_frame = c->tc.start + c->frames;
if (c->tc.drop)
ltc_frame = ff_framenum_to_drop_timecode(ltc_frame);
timecode = ff_framenum_to_smtpe_timecode(ltc_frame, c->sys->ltc_divisor,
c->tc.drop);
ltc_frame = avpriv_framenum_to_drop_timecode(ltc_frame);
timecode = avpriv_framenum_to_smpte_timecode(ltc_frame, c->sys->ltc_divisor,
c->tc.drop);
timecode |= 1<<23 | 1<<15 | 1<<7 | 1<<6; // biphase and binary group flags
AV_WB32(buf + 1, timecode);
break;
......@@ -378,7 +378,7 @@ static int dv_write_header(AVFormatContext *s)
if (dvc->tc.str) {
dvc->tc.rate.num = dvc->sys->time_base.den;
dvc->tc.rate.den = dvc->sys->time_base.num;
if (ff_init_smtpe_timecode(s, &dvc->tc) < 0)
if (avpriv_init_smpte_timecode(s, &dvc->tc) < 0)
return -1;
}
return 0;
......
......@@ -1432,7 +1432,7 @@ static int mxf_write_header(AVFormatContext *s)
if (mxf->tc.str) {
mxf->tc.rate.num = mxf->time_base.den;
mxf->tc.rate.den = mxf->time_base.num;
if (ff_init_smtpe_timecode(s, &mxf->tc) < 0)
if (avpriv_init_smpte_timecode(s, &mxf->tc) < 0)
return -1;
}
if (s->oformat == &ff_mxf_d10_muxer) {
......@@ -1572,9 +1572,9 @@ static void mxf_write_system_item(AVFormatContext *s)
avio_w8(pb, 0x81); // SMPTE 12M time code
time_code = frame;
if (mxf->tc.drop)
time_code = ff_framenum_to_drop_timecode(time_code);
time_code = ff_framenum_to_smtpe_timecode(time_code, mxf->timecode_base,
mxf->tc.drop);
time_code = avpriv_framenum_to_drop_timecode(time_code);
time_code = avpriv_framenum_to_smpte_timecode(time_code, mxf->timecode_base,
mxf->tc.drop);
avio_wb32(pb, time_code);
avio_wb32(pb, 0); // binary group data
avio_wb64(pb, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment