Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
b33ca05b
Commit
b33ca05b
authored
Jul 06, 2011
by
Clément Bœsch
Committed by
Clément Bœsch
Aug 13, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mxf: add cli option in mxfenc to replace GOP timecode parsing.
This is based on the original work by Baptiste Coudurier.
parent
4c3c6e60
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
23 deletions
+26
-23
mxfenc.c
libavformat/mxfenc.c
+25
-22
lavf-regression.sh
tests/lavf-regression.sh
+1
-1
No files found.
libavformat/mxfenc.c
View file @
b33ca05b
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include <math.h>
#include <math.h>
#include <time.h>
#include <time.h>
#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "libavutil/random_seed.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/timecode.h"
#include "libavcodec/timecode.h"
...
@@ -172,6 +173,7 @@ static const MXFContainerEssenceEntry mxf_essence_container_uls[] = {
...
@@ -172,6 +173,7 @@ static const MXFContainerEssenceEntry mxf_essence_container_uls[] = {
};
};
typedef
struct
MXFContext
{
typedef
struct
MXFContext
{
AVClass
*
av_class
;
int64_t
footer_partition_offset
;
int64_t
footer_partition_offset
;
int
essence_container_count
;
int
essence_container_count
;
AVRational
time_base
;
AVRational
time_base
;
...
@@ -185,10 +187,9 @@ typedef struct MXFContext {
...
@@ -185,10 +187,9 @@ typedef struct MXFContext {
unsigned
body_partitions_count
;
unsigned
body_partitions_count
;
int
last_key_index
;
///< index of last key frame
int
last_key_index
;
///< index of last key frame
uint64_t
duration
;
uint64_t
duration
;
struct
ff_timecode
tc
;
AVStream
*
timecode_track
;
AVStream
*
timecode_track
;
int
timecode_base
;
///< rounded time code base (25 or 30)
int
timecode_base
;
///< rounded time code base (25 or 30)
int
timecode_start
;
///< frame number computed from mpeg-2 gop header timecode
int
timecode_drop_frame
;
///< time code use drop frame method frop mpeg-2 essence gop header
int
edit_unit_byte_count
;
///< fixed edit unit byte count
int
edit_unit_byte_count
;
///< fixed edit unit byte count
uint64_t
body_offset
;
uint64_t
body_offset
;
uint32_t
instance_number
;
uint32_t
instance_number
;
...
@@ -666,7 +667,7 @@ static void mxf_write_timecode_component(AVFormatContext *s, AVStream *st, enum
...
@@ -666,7 +667,7 @@ static void mxf_write_timecode_component(AVFormatContext *s, AVStream *st, enum
// Start Time Code
// Start Time Code
mxf_write_local_tag
(
pb
,
8
,
0x1501
);
mxf_write_local_tag
(
pb
,
8
,
0x1501
);
avio_wb64
(
pb
,
mxf
->
t
imecode_
start
);
avio_wb64
(
pb
,
mxf
->
t
c
.
start
);
// Rounded Time Code Base
// Rounded Time Code Base
mxf_write_local_tag
(
pb
,
2
,
0x1502
);
mxf_write_local_tag
(
pb
,
2
,
0x1502
);
...
@@ -674,7 +675,7 @@ static void mxf_write_timecode_component(AVFormatContext *s, AVStream *st, enum
...
@@ -674,7 +675,7 @@ static void mxf_write_timecode_component(AVFormatContext *s, AVStream *st, enum
// Drop Frame
// Drop Frame
mxf_write_local_tag
(
pb
,
1
,
0x1503
);
mxf_write_local_tag
(
pb
,
1
,
0x1503
);
avio_w8
(
pb
,
mxf
->
t
imecode_drop_frame
);
avio_w8
(
pb
,
mxf
->
t
c
.
drop
);
}
}
static
void
mxf_write_structural_component
(
AVFormatContext
*
s
,
AVStream
*
st
,
enum
MXFMetadataSetType
type
)
static
void
mxf_write_structural_component
(
AVFormatContext
*
s
,
AVStream
*
st
,
enum
MXFMetadataSetType
type
)
...
@@ -1310,7 +1311,6 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
...
@@ -1310,7 +1311,6 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
AVPacket
*
pkt
,
MXFIndexEntry
*
e
)
AVPacket
*
pkt
,
MXFIndexEntry
*
e
)
{
{
MXFStreamContext
*
sc
=
st
->
priv_data
;
MXFStreamContext
*
sc
=
st
->
priv_data
;
MXFContext
*
mxf
=
s
->
priv_data
;
uint32_t
c
=
-
1
;
uint32_t
c
=
-
1
;
int
i
;
int
i
;
...
@@ -1330,21 +1330,6 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
...
@@ -1330,21 +1330,6 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
if
(
e
->
flags
&
0x40
)
// sequence header present
if
(
e
->
flags
&
0x40
)
// sequence header present
e
->
flags
|=
0x80
;
// random access
e
->
flags
|=
0x80
;
// random access
}
}
if
(
!
mxf
->
header_written
)
{
unsigned
hours
=
(
pkt
->
data
[
i
+
1
]
>>
2
)
&
0x1f
;
unsigned
minutes
=
((
pkt
->
data
[
i
+
1
]
&
0x03
)
<<
4
)
|
(
pkt
->
data
[
i
+
2
]
>>
4
);
unsigned
seconds
=
((
pkt
->
data
[
i
+
2
]
&
0x07
)
<<
3
)
|
(
pkt
->
data
[
i
+
3
]
>>
5
);
unsigned
frames
=
((
pkt
->
data
[
i
+
3
]
&
0x1f
)
<<
1
)
|
(
pkt
->
data
[
i
+
4
]
>>
7
);
mxf
->
timecode_drop_frame
=
!!
(
pkt
->
data
[
i
+
1
]
&
0x80
);
mxf
->
timecode_start
=
(
hours
*
3600
+
minutes
*
60
+
seconds
)
*
mxf
->
timecode_base
+
frames
;
if
(
mxf
->
timecode_drop_frame
)
{
unsigned
tminutes
=
60
*
hours
+
minutes
;
mxf
->
timecode_start
-=
2
*
(
tminutes
-
tminutes
/
10
);
}
av_log
(
s
,
AV_LOG_DEBUG
,
"frame %d %d:%d:%d%c%d
\n
"
,
mxf
->
timecode_start
,
hours
,
minutes
,
seconds
,
mxf
->
timecode_drop_frame
?
';'
:
':'
,
frames
);
}
}
else
if
(
c
==
0x1b3
)
{
// seq
}
else
if
(
c
==
0x1b3
)
{
// seq
e
->
flags
|=
0x40
;
e
->
flags
|=
0x40
;
switch
((
pkt
->
data
[
i
+
4
]
>>
4
)
&
0xf
)
{
switch
((
pkt
->
data
[
i
+
4
]
>>
4
)
&
0xf
)
{
...
@@ -1440,6 +1425,12 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -1440,6 +1425,12 @@ static int mxf_write_header(AVFormatContext *s)
return
-
1
;
return
-
1
;
}
}
av_set_pts_info
(
st
,
64
,
mxf
->
time_base
.
num
,
mxf
->
time_base
.
den
);
av_set_pts_info
(
st
,
64
,
mxf
->
time_base
.
num
,
mxf
->
time_base
.
den
);
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
)
return
-
1
;
}
if
(
s
->
oformat
==
&
ff_mxf_d10_muxer
)
{
if
(
s
->
oformat
==
&
ff_mxf_d10_muxer
)
{
if
(
st
->
codec
->
bit_rate
==
50000000
)
if
(
st
->
codec
->
bit_rate
==
50000000
)
if
(
mxf
->
time_base
.
den
==
25
)
sc
->
index
=
3
;
if
(
mxf
->
time_base
.
den
==
25
)
sc
->
index
=
3
;
...
@@ -1554,7 +1545,7 @@ static void mxf_write_system_item(AVFormatContext *s)
...
@@ -1554,7 +1545,7 @@ static void mxf_write_system_item(AVFormatContext *s)
unsigned
frame
;
unsigned
frame
;
uint32_t
time_code
;
uint32_t
time_code
;
frame
=
mxf
->
t
imecode_
start
+
mxf
->
last_indexed_edit_unit
+
mxf
->
edit_units_count
;
frame
=
mxf
->
t
c
.
start
+
mxf
->
last_indexed_edit_unit
+
mxf
->
edit_units_count
;
// write system metadata pack
// write system metadata pack
avio_write
(
pb
,
system_metadata_pack_key
,
16
);
avio_write
(
pb
,
system_metadata_pack_key
,
16
);
...
@@ -1576,7 +1567,7 @@ static void mxf_write_system_item(AVFormatContext *s)
...
@@ -1576,7 +1567,7 @@ static void mxf_write_system_item(AVFormatContext *s)
avio_w8
(
pb
,
0x81
);
// SMPTE 12M time code
avio_w8
(
pb
,
0x81
);
// SMPTE 12M time code
time_code
=
ff_framenum_to_smtpe_timecode
(
frame
,
mxf
->
timecode_base
,
time_code
=
ff_framenum_to_smtpe_timecode
(
frame
,
mxf
->
timecode_base
,
mxf
->
t
imecode_drop_frame
);
mxf
->
t
c
.
drop
);
avio_wb32
(
pb
,
time_code
);
avio_wb32
(
pb
,
time_code
);
avio_wb32
(
pb
,
0
);
// binary group data
avio_wb32
(
pb
,
0
);
// binary group data
avio_wb64
(
pb
,
0
);
avio_wb64
(
pb
,
0
);
...
@@ -1873,6 +1864,16 @@ static int mxf_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int
...
@@ -1873,6 +1864,16 @@ static int mxf_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int
mxf_interleave_get_packet
,
mxf_compare_timestamps
);
mxf_interleave_get_packet
,
mxf_compare_timestamps
);
}
}
static
const
AVClass
class
=
{
.
class_name
=
"mxf"
,
.
item_name
=
av_default_item_name
,
.
version
=
LIBAVUTIL_VERSION_INT
,
.
option
=
(
const
AVOption
[]){
{
TIMECODE_OPT
(
MXFContext
,
AV_OPT_FLAG_ENCODING_PARAM
)},
{
NULL
}
},
};
AVOutputFormat
ff_mxf_muxer
=
{
AVOutputFormat
ff_mxf_muxer
=
{
.
name
=
"mxf"
,
.
name
=
"mxf"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"Material eXchange Format"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"Material eXchange Format"
),
...
@@ -1886,6 +1887,7 @@ AVOutputFormat ff_mxf_muxer = {
...
@@ -1886,6 +1887,7 @@ AVOutputFormat ff_mxf_muxer = {
.
write_trailer
=
mxf_write_footer
,
.
write_trailer
=
mxf_write_footer
,
.
flags
=
AVFMT_NOTIMESTAMPS
,
.
flags
=
AVFMT_NOTIMESTAMPS
,
.
interleave_packet
=
mxf_interleave
,
.
interleave_packet
=
mxf_interleave
,
.
priv_class
=
&
class
,
};
};
AVOutputFormat
ff_mxf_d10_muxer
=
{
AVOutputFormat
ff_mxf_d10_muxer
=
{
...
@@ -1900,4 +1902,5 @@ AVOutputFormat ff_mxf_d10_muxer = {
...
@@ -1900,4 +1902,5 @@ AVOutputFormat ff_mxf_d10_muxer = {
.
write_trailer
=
mxf_write_footer
,
.
write_trailer
=
mxf_write_footer
,
.
flags
=
AVFMT_NOTIMESTAMPS
,
.
flags
=
AVFMT_NOTIMESTAMPS
,
.
interleave_packet
=
mxf_interleave
,
.
interleave_packet
=
mxf_interleave
,
.
priv_class
=
&
class
,
};
};
tests/lavf-regression.sh
View file @
b33ca05b
...
@@ -63,7 +63,7 @@ do_lavf mpg
...
@@ -63,7 +63,7 @@ do_lavf mpg
fi
fi
if
[
-n
"
$do_mxf
"
]
;
then
if
[
-n
"
$do_mxf
"
]
;
then
do_lavf mxf
"-ar 48000 -bf 2 -timecode
_frame_start 26436
3"
do_lavf mxf
"-ar 48000 -bf 2 -timecode
02:56:14:1
3"
fi
fi
if
[
-n
"
$do_mxf_d10
"
]
;
then
if
[
-n
"
$do_mxf_d10
"
]
;
then
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment