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
ea55a11c
Commit
ea55a11c
authored
Mar 21, 2018
by
Baptiste Coudurier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/mxfenc: add mpeg-2 specific metadata, fix compatibility with sony content browser
parent
3d38e45e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
12 deletions
+50
-12
mxfenc.c
libavformat/mxfenc.c
+42
-4
mxf
tests/ref/lavf/mxf
+3
-3
mxf_d10
tests/ref/lavf/mxf_d10
+1
-1
mxf_dv25
tests/ref/lavf/mxf_dv25
+1
-1
mxf_dvcpro50
tests/ref/lavf/mxf_dvcpro50
+1
-1
mxf_opatom
tests/ref/lavf/mxf_opatom
+1
-1
mxf_opatom_audio
tests/ref/lavf/mxf_opatom_audio
+1
-1
No files found.
libavformat/mxfenc.c
View file @
ea55a11c
...
@@ -95,6 +95,10 @@ typedef struct MXFStreamContext {
...
@@ -95,6 +95,10 @@ typedef struct MXFStreamContext {
int
video_bit_rate
;
int
video_bit_rate
;
int
slice_offset
;
int
slice_offset
;
int
frame_size
;
///< frame size in bytes
int
frame_size
;
///< frame size in bytes
int
seq_closed_gop
;
///< all gops in sequence are closed, used in mpeg-2 descriptor
int
max_gop
;
///< maximum gop size, used by mpeg-2 descriptor
int
b_picture_count
;
///< maximum number of consecutive b pictures, used in mpeg-2 descriptor
int
low_delay
;
///< low delay, used in mpeg-2 descriptor
}
MXFStreamContext
;
}
MXFStreamContext
;
typedef
struct
MXFContainerEssenceEntry
{
typedef
struct
MXFContainerEssenceEntry
{
...
@@ -558,7 +562,11 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
...
@@ -558,7 +562,11 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
{
0x3F0A
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x04
,
0x04
,
0x02
,
0x05
,
0x00
,
0x00
,
0x00
}},
/* Index Entry Array */
{
0x3F0A
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x04
,
0x04
,
0x02
,
0x05
,
0x00
,
0x00
,
0x00
}},
/* Index Entry Array */
// MPEG video Descriptor
// MPEG video Descriptor
{
0x8000
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x0B
,
0x00
,
0x00
}},
/* BitRate */
{
0x8000
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x0B
,
0x00
,
0x00
}},
/* BitRate */
{
0x8003
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x05
,
0x00
,
0x00
}},
/* LowDelay */
{
0x8004
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x06
,
0x00
,
0x00
}},
/* ClosedGOP */
{
0x8006
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x08
,
0x00
,
0x00
}},
/* MaxGOP */
{
0x8007
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x0A
,
0x00
,
0x00
}},
/* ProfileAndLevel */
{
0x8007
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x0A
,
0x00
,
0x00
}},
/* ProfileAndLevel */
{
0x8008
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x01
,
0x06
,
0x02
,
0x01
,
0x09
,
0x00
,
0x00
}},
/* BPictureCount */
// Wave Audio Essence Descriptor
// Wave Audio Essence Descriptor
{
0x3D09
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x02
,
0x03
,
0x03
,
0x05
,
0x00
,
0x00
,
0x00
}},
/* Average Bytes Per Second */
{
0x3D09
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x02
,
0x03
,
0x03
,
0x05
,
0x00
,
0x00
,
0x00
}},
/* Average Bytes Per Second */
{
0x3D0A
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x02
,
0x03
,
0x02
,
0x01
,
0x00
,
0x00
,
0x00
}},
/* Block Align */
{
0x3D0A
,
{
0x06
,
0x0E
,
0x2B
,
0x34
,
0x01
,
0x01
,
0x01
,
0x05
,
0x04
,
0x02
,
0x03
,
0x02
,
0x01
,
0x00
,
0x00
,
0x00
}},
/* Block Align */
...
@@ -1294,10 +1302,8 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
...
@@ -1294,10 +1302,8 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID
avio_wb32
(
pb
,
sc
->
h_chroma_sub_sample
);
avio_wb32
(
pb
,
sc
->
h_chroma_sub_sample
);
// vertical subsampling
// vertical subsampling
if
(
sc
->
v_chroma_sub_sample
)
{
mxf_write_local_tag
(
pb
,
4
,
0x3308
);
mxf_write_local_tag
(
pb
,
4
,
0x3308
);
avio_wb32
(
pb
,
sc
->
v_chroma_sub_sample
);
avio_wb32
(
pb
,
sc
->
v_chroma_sub_sample
);
}
// color siting
// color siting
mxf_write_local_tag
(
pb
,
1
,
0x3303
);
mxf_write_local_tag
(
pb
,
1
,
0x3303
);
...
@@ -1409,6 +1415,22 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
...
@@ -1409,6 +1415,22 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
if
(
!
st
->
codecpar
->
profile
)
if
(
!
st
->
codecpar
->
profile
)
profile_and_level
|=
0x80
;
// escape bit
profile_and_level
|=
0x80
;
// escape bit
avio_w8
(
pb
,
profile_and_level
);
avio_w8
(
pb
,
profile_and_level
);
// low delay
mxf_write_local_tag
(
pb
,
1
,
0x8003
);
avio_w8
(
pb
,
sc
->
low_delay
);
// closed gop
mxf_write_local_tag
(
pb
,
1
,
0x8004
);
avio_w8
(
pb
,
sc
->
seq_closed_gop
);
// max gop
mxf_write_local_tag
(
pb
,
2
,
0x8006
);
avio_wb16
(
pb
,
sc
->
max_gop
);
// b picture count
mxf_write_local_tag
(
pb
,
2
,
0x8008
);
avio_wb16
(
pb
,
sc
->
b_picture_count
);
}
}
mxf_update_klv_size
(
pb
,
pos
);
mxf_update_klv_size
(
pb
,
pos
);
...
@@ -1729,6 +1751,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
...
@@ -1729,6 +1751,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
AVIOContext
*
pb
=
s
->
pb
;
AVIOContext
*
pb
=
s
->
pb
;
int
i
,
j
,
temporal_reordering
=
0
;
int
i
,
j
,
temporal_reordering
=
0
;
int
key_index
=
mxf
->
last_key_index
;
int
key_index
=
mxf
->
last_key_index
;
int
prev_non_b_picture
=
0
;
int64_t
pos
;
int64_t
pos
;
av_log
(
s
,
AV_LOG_DEBUG
,
"edit units count %d
\n
"
,
mxf
->
edit_units_count
);
av_log
(
s
,
AV_LOG_DEBUG
,
"edit units count %d
\n
"
,
mxf
->
edit_units_count
);
...
@@ -1807,6 +1830,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
...
@@ -1807,6 +1830,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
}
}
if
(
!
mxf
->
edit_unit_byte_count
)
{
if
(
!
mxf
->
edit_unit_byte_count
)
{
MXFStreamContext
*
sc
=
s
->
streams
[
0
]
->
priv_data
;
mxf_write_local_tag
(
pb
,
8
+
mxf
->
edit_units_count
*
15
,
0x3F0A
);
mxf_write_local_tag
(
pb
,
8
+
mxf
->
edit_units_count
*
15
,
0x3F0A
);
avio_wb32
(
pb
,
mxf
->
edit_units_count
);
// num of entries
avio_wb32
(
pb
,
mxf
->
edit_units_count
);
// num of entries
avio_wb32
(
pb
,
15
);
// size of one entry
avio_wb32
(
pb
,
15
);
// size of one entry
...
@@ -1815,6 +1839,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
...
@@ -1815,6 +1839,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
int
temporal_offset
=
0
;
int
temporal_offset
=
0
;
if
(
!
(
mxf
->
index_entries
[
i
].
flags
&
0x33
))
{
// I-frame
if
(
!
(
mxf
->
index_entries
[
i
].
flags
&
0x33
))
{
// I-frame
sc
->
max_gop
=
FFMAX
(
sc
->
max_gop
,
i
-
mxf
->
last_key_index
);
mxf
->
last_key_index
=
key_index
;
mxf
->
last_key_index
=
key_index
;
key_index
=
i
;
key_index
=
i
;
}
}
...
@@ -1834,11 +1859,13 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
...
@@ -1834,11 +1859,13 @@ static void mxf_write_index_table_segment(AVFormatContext *s)
avio_w8
(
pb
,
temporal_offset
);
avio_w8
(
pb
,
temporal_offset
);
if
((
mxf
->
index_entries
[
i
].
flags
&
0x30
)
==
0x30
)
{
// back and forward prediction
if
((
mxf
->
index_entries
[
i
].
flags
&
0x30
)
==
0x30
)
{
// back and forward prediction
sc
->
b_picture_count
=
FFMAX
(
sc
->
b_picture_count
,
i
-
prev_non_b_picture
);
avio_w8
(
pb
,
mxf
->
last_key_index
-
i
);
avio_w8
(
pb
,
mxf
->
last_key_index
-
i
);
}
else
{
}
else
{
avio_w8
(
pb
,
key_index
-
i
);
// key frame offset
avio_w8
(
pb
,
key_index
-
i
);
// key frame offset
if
((
mxf
->
index_entries
[
i
].
flags
&
0x20
)
==
0x20
)
// only forward
if
((
mxf
->
index_entries
[
i
].
flags
&
0x20
)
==
0x20
)
// only forward
mxf
->
last_key_index
=
key_index
;
mxf
->
last_key_index
=
key_index
;
prev_non_b_picture
=
i
;
}
}
if
(
!
(
mxf
->
index_entries
[
i
].
flags
&
0x33
)
&&
// I-frame
if
(
!
(
mxf
->
index_entries
[
i
].
flags
&
0x33
)
&&
// I-frame
...
@@ -2285,6 +2312,7 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
...
@@ -2285,6 +2312,7 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
if
((
pkt
->
data
[
i
+
1
]
&
0xf0
)
==
0x10
)
{
// seq ext
if
((
pkt
->
data
[
i
+
1
]
&
0xf0
)
==
0x10
)
{
// seq ext
st
->
codecpar
->
profile
=
pkt
->
data
[
i
+
1
]
&
0x07
;
st
->
codecpar
->
profile
=
pkt
->
data
[
i
+
1
]
&
0x07
;
st
->
codecpar
->
level
=
pkt
->
data
[
i
+
2
]
>>
4
;
st
->
codecpar
->
level
=
pkt
->
data
[
i
+
2
]
>>
4
;
sc
->
low_delay
=
pkt
->
data
[
i
+
6
]
>>
7
;
}
else
if
(
i
+
5
<
pkt
->
size
&&
(
pkt
->
data
[
i
+
1
]
&
0xf0
)
==
0x80
)
{
// pict coding ext
}
else
if
(
i
+
5
<
pkt
->
size
&&
(
pkt
->
data
[
i
+
1
]
&
0xf0
)
==
0x80
)
{
// pict coding ext
sc
->
interlaced
=
!
(
pkt
->
data
[
i
+
5
]
&
0x80
);
// progressive frame
sc
->
interlaced
=
!
(
pkt
->
data
[
i
+
5
]
&
0x80
);
// progressive frame
if
(
sc
->
interlaced
)
if
(
sc
->
interlaced
)
...
@@ -2293,9 +2321,14 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
...
@@ -2293,9 +2321,14 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
}
}
}
else
if
(
c
==
0x1b8
)
{
// gop
}
else
if
(
c
==
0x1b8
)
{
// gop
if
(
pkt
->
data
[
i
+
4
]
>>
6
&
0x01
)
{
// closed
if
(
pkt
->
data
[
i
+
4
]
>>
6
&
0x01
)
{
// closed
if
(
sc
->
seq_closed_gop
==
-
1
)
sc
->
seq_closed_gop
=
1
;
sc
->
closed_gop
=
1
;
sc
->
closed_gop
=
1
;
if
(
e
->
flags
&
0x40
)
// sequence header present
if
(
e
->
flags
&
0x40
)
// sequence header present
e
->
flags
|=
0x80
;
// random access
e
->
flags
|=
0x80
;
// random access
}
else
{
sc
->
seq_closed_gop
=
0
;
sc
->
closed_gop
=
0
;
}
}
}
else
if
(
c
==
0x1b3
)
{
// seq
}
else
if
(
c
==
0x1b3
)
{
// seq
e
->
flags
|=
0x40
;
e
->
flags
|=
0x40
;
...
@@ -2407,6 +2440,7 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -2407,6 +2440,7 @@ static int mxf_write_header(AVFormatContext *s)
// Default component depth to 8
// Default component depth to 8
sc
->
component_depth
=
8
;
sc
->
component_depth
=
8
;
sc
->
h_chroma_sub_sample
=
2
;
sc
->
h_chroma_sub_sample
=
2
;
sc
->
v_chroma_sub_sample
=
2
;
sc
->
color_siting
=
0xFF
;
sc
->
color_siting
=
0xFF
;
if
(
pix_desc
)
{
if
(
pix_desc
)
{
...
@@ -2434,6 +2468,10 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -2434,6 +2468,10 @@ static int mxf_write_header(AVFormatContext *s)
if
((
ret
=
mxf_init_timecode
(
s
,
st
,
rate
))
<
0
)
if
((
ret
=
mxf_init_timecode
(
s
,
st
,
rate
))
<
0
)
return
ret
;
return
ret
;
if
(
st
->
codecpar
->
codec_id
==
AV_CODEC_ID_MPEG2VIDEO
)
{
sc
->
seq_closed_gop
=
-
1
;
// unknown yet
}
sc
->
video_bit_rate
=
st
->
codecpar
->
bit_rate
;
sc
->
video_bit_rate
=
st
->
codecpar
->
bit_rate
;
if
(
s
->
oformat
==
&
ff_mxf_d10_muxer
||
if
(
s
->
oformat
==
&
ff_mxf_d10_muxer
||
...
...
tests/ref/lavf/mxf
View file @
ea55a11c
96c0f82082eb420ecbddf7810f3b3943
*./tests/data/lavf/lavf.mxf
eea31259441d909fedb9a0e0eb9bbdb2
*./tests/data/lavf/lavf.mxf
526393 ./tests/data/lavf/lavf.mxf
526393 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
072d0f1f4a2859a3416535beb3d33531
*./tests/data/lavf/lavf.mxf
7524e7319a64b639d6ef49446d46320e
*./tests/data/lavf/lavf.mxf
561721 ./tests/data/lavf/lavf.mxf
561721 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x96ff1b48
./tests/data/lavf/lavf.mxf CRC=0x96ff1b48
8376d69f7eccfc268041dffd82db1a61
*./tests/data/lavf/lavf.mxf
e547b44d71cd5871582522a31511ae9c
*./tests/data/lavf/lavf.mxf
526393 ./tests/data/lavf/lavf.mxf
526393 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
./tests/data/lavf/lavf.mxf CRC=0x8dddfaab
tests/ref/lavf/mxf_d10
View file @
ea55a11c
ad3f0da2f77e5269e896b367f2a5b0b0
*./tests/data/lavf/lavf.mxf_d10
9f299fd4da6a20ef93adad7fe6a9f481
*./tests/data/lavf/lavf.mxf_d10
5332013 ./tests/data/lavf/lavf.mxf_d10
5332013 ./tests/data/lavf/lavf.mxf_d10
./tests/data/lavf/lavf.mxf_d10 CRC=0x6c74d488
./tests/data/lavf/lavf.mxf_d10 CRC=0x6c74d488
tests/ref/lavf/mxf_dv25
View file @
ea55a11c
cd1ea9497444b0b43d930b0dc56aecf7
*./tests/data/lavf/lavf.mxf_dv25
358791c5468c39673239e038fb64a734
*./tests/data/lavf/lavf.mxf_dv25
3834413 ./tests/data/lavf/lavf.mxf_dv25
3834413 ./tests/data/lavf/lavf.mxf_dv25
./tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52
./tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52
tests/ref/lavf/mxf_dvcpro50
View file @
ea55a11c
ce601c92f0e2d7f07cbf6263a8a18ea5
*./tests/data/lavf/lavf.mxf_dvcpro50
fac7c59ea81c752d769335ddaa818f90
*./tests/data/lavf/lavf.mxf_dvcpro50
7431213 ./tests/data/lavf/lavf.mxf_dvcpro50
7431213 ./tests/data/lavf/lavf.mxf_dvcpro50
./tests/data/lavf/lavf.mxf_dvcpro50 CRC=0xe3bbe4b4
./tests/data/lavf/lavf.mxf_dvcpro50 CRC=0xe3bbe4b4
tests/ref/lavf/mxf_opatom
View file @
ea55a11c
76093fef1ac42587cc374012dc1945db
*./tests/data/lavf/lavf.mxf_opatom
49b0b3dfeb6a9ec024b047fc627b66fd
*./tests/data/lavf/lavf.mxf_opatom
4717625 ./tests/data/lavf/lavf.mxf_opatom
4717625 ./tests/data/lavf/lavf.mxf_opatom
./tests/data/lavf/lavf.mxf_opatom CRC=0xf55aa22a
./tests/data/lavf/lavf.mxf_opatom CRC=0xf55aa22a
tests/ref/lavf/mxf_opatom_audio
View file @
ea55a11c
8
524f908a6fa8750a4755ab79cc1516c
*./tests/data/lavf/lavf.mxf_opatom_audio
8
62dc5c9f2c94bd2c545ca64f923d1a1
*./tests/data/lavf/lavf.mxf_opatom_audio
102969 ./tests/data/lavf/lavf.mxf_opatom_audio
102969 ./tests/data/lavf/lavf.mxf_opatom_audio
./tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff
./tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff
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