summaryrefslogtreecommitdiff
path: root/libavformat/mxfenc.c
diff options
context:
space:
mode:
authorClément Bœsch <clement.boesch@smartjog.com>2011-07-06 15:04:26 +0200
committerClément Bœsch <ubitux@gmail.com>2011-08-13 19:13:02 +0200
commit4c3c6e60f97e450c35a90dc6d66f3726b7b938b4 (patch)
tree3a9e10114bc7b8ebf14f2fd7ac5e52c11e104c82 /libavformat/mxfenc.c
parentb7b72963e06f21fb985c58100c7d048cfea2736a (diff)
mxf: move framenum to timecode convert to timecode helpers.
This is based on the original work by Baptiste Coudurier.
Diffstat (limited to 'libavformat/mxfenc.c')
-rw-r--r--libavformat/mxfenc.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index b84504cf5c..50d2deda7b 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -37,6 +37,7 @@
#include "libavutil/random_seed.h"
#include "libavcodec/bytestream.h"
+#include "libavcodec/timecode.h"
#include "audiointerleave.h"
#include "avformat.h"
#include "internal.h"
@@ -1546,24 +1547,6 @@ static int mxf_write_header(AVFormatContext *s)
static const uint8_t system_metadata_pack_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x03,0x01,0x04,0x01,0x01,0x00 };
static const uint8_t system_metadata_package_set_key[] = { 0x06,0x0E,0x2B,0x34,0x02,0x43,0x01,0x01,0x0D,0x01,0x03,0x01,0x04,0x01,0x02,0x01 };
-static uint32_t ff_framenum_to_12m_time_code(unsigned frame, int drop, int fps)
-{
- return (0 << 31) | // color frame flag
- (drop << 30) | // drop frame flag
- ( ((frame % fps) / 10) << 28) | // tens of frames
- ( ((frame % fps) % 10) << 24) | // units of frames
- (0 << 23) | // field phase (NTSC), b0 (PAL)
- ((((frame / fps) % 60) / 10) << 20) | // tens of seconds
- ((((frame / fps) % 60) % 10) << 16) | // units of seconds
- (0 << 15) | // b0 (NTSC), b2 (PAL)
- ((((frame / (fps * 60)) % 60) / 10) << 12) | // tens of minutes
- ((((frame / (fps * 60)) % 60) % 10) << 8) | // units of minutes
- (0 << 7) | // b1
- (0 << 6) | // b2 (NTSC), field phase (PAL)
- ((((frame / (fps * 3600) % 24)) / 10) << 4) | // tens of hours
- ( (frame / (fps * 3600) % 24)) % 10; // units of hours
-}
-
static void mxf_write_system_item(AVFormatContext *s)
{
MXFContext *mxf = s->priv_data;
@@ -1592,7 +1575,8 @@ static void mxf_write_system_item(AVFormatContext *s)
avio_wb64(pb, 0); // creation date/time stamp
avio_w8(pb, 0x81); // SMPTE 12M time code
- time_code = ff_framenum_to_12m_time_code(frame, mxf->timecode_drop_frame, mxf->timecode_base);
+ time_code = ff_framenum_to_smtpe_timecode(frame, mxf->timecode_base,
+ mxf->timecode_drop_frame);
avio_wb32(pb, time_code);
avio_wb32(pb, 0); // binary group data
avio_wb64(pb, 0);