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
b401a4ab
Commit
b401a4ab
authored
Oct 18, 2018
by
Baptiste Coudurier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/mxfenc: support XAVC long gop
parent
3c0bfa7d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
204 additions
and
36 deletions
+204
-36
Makefile
libavformat/Makefile
+1
-1
avc.c
libavformat/avc.c
+186
-0
avc.h
libavformat/avc.h
+15
-0
hevc.c
libavformat/hevc.c
+1
-35
mxf.h
libavformat/mxf.h
+1
-0
mxfenc.c
libavformat/mxfenc.c
+0
-0
No files found.
libavformat/Makefile
View file @
b401a4ab
...
@@ -339,7 +339,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER) += musx.o
...
@@ -339,7 +339,7 @@ OBJS-$(CONFIG_MUSX_DEMUXER) += musx.o
OBJS-$(CONFIG_MV_DEMUXER)
+=
mvdec.o
OBJS-$(CONFIG_MV_DEMUXER)
+=
mvdec.o
OBJS-$(CONFIG_MVI_DEMUXER)
+=
mvi.o
OBJS-$(CONFIG_MVI_DEMUXER)
+=
mvi.o
OBJS-$(CONFIG_MXF_DEMUXER)
+=
mxfdec.o
mxf.o
OBJS-$(CONFIG_MXF_DEMUXER)
+=
mxfdec.o
mxf.o
OBJS-$(CONFIG_MXF_MUXER)
+=
mxfenc.o
mxf.o
audiointerleave.o
OBJS-$(CONFIG_MXF_MUXER)
+=
mxfenc.o
mxf.o
audiointerleave.o
avc.o
OBJS-$(CONFIG_MXG_DEMUXER)
+=
mxg.o
OBJS-$(CONFIG_MXG_DEMUXER)
+=
mxg.o
OBJS-$(CONFIG_NC_DEMUXER)
+=
ncdec.o
OBJS-$(CONFIG_NC_DEMUXER)
+=
ncdec.o
OBJS-$(CONFIG_NISTSPHERE_DEMUXER)
+=
nistspheredec.o
pcm.o
OBJS-$(CONFIG_NISTSPHERE_DEMUXER)
+=
nistspheredec.o
pcm.o
...
...
libavformat/avc.c
View file @
b401a4ab
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "libavutil/intreadwrite.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/h264.h"
#include "libavcodec/h264.h"
#include "libavcodec/get_bits.h"
#include "avformat.h"
#include "avformat.h"
#include "avio.h"
#include "avio.h"
#include "avc.h"
#include "avc.h"
...
@@ -241,3 +242,188 @@ const uint8_t *ff_avc_mp4_find_startcode(const uint8_t *start,
...
@@ -241,3 +242,188 @@ const uint8_t *ff_avc_mp4_find_startcode(const uint8_t *start,
return
start
+
res
;
return
start
+
res
;
}
}
uint8_t
*
ff_nal_unit_extract_rbsp
(
const
uint8_t
*
src
,
uint32_t
src_len
,
uint32_t
*
dst_len
,
int
header_len
)
{
uint8_t
*
dst
;
uint32_t
i
,
len
;
dst
=
av_malloc
(
src_len
+
AV_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
dst
)
return
NULL
;
/* NAL unit header */
i
=
len
=
0
;
while
(
i
<
header_len
&&
i
<
src_len
)
dst
[
len
++
]
=
src
[
i
++
];
while
(
i
+
2
<
src_len
)
if
(
!
src
[
i
]
&&
!
src
[
i
+
1
]
&&
src
[
i
+
2
]
==
3
)
{
dst
[
len
++
]
=
src
[
i
++
];
dst
[
len
++
]
=
src
[
i
++
];
i
++
;
// remove emulation_prevention_three_byte
}
else
dst
[
len
++
]
=
src
[
i
++
];
while
(
i
<
src_len
)
dst
[
len
++
]
=
src
[
i
++
];
memset
(
dst
+
len
,
0
,
AV_INPUT_BUFFER_PADDING_SIZE
);
*
dst_len
=
len
;
return
dst
;
}
static
const
AVRational
avc_sample_aspect_ratio
[
17
]
=
{
{
0
,
1
},
{
1
,
1
},
{
12
,
11
},
{
10
,
11
},
{
16
,
11
},
{
40
,
33
},
{
24
,
11
},
{
20
,
11
},
{
32
,
11
},
{
80
,
33
},
{
18
,
11
},
{
15
,
11
},
{
64
,
33
},
{
160
,
99
},
{
4
,
3
},
{
3
,
2
},
{
2
,
1
},
};
static
inline
int
get_ue_golomb
(
GetBitContext
*
gb
)
{
int
i
;
for
(
i
=
0
;
i
<
32
&&
!
get_bits1
(
gb
);
i
++
)
;
return
get_bitsz
(
gb
,
i
)
+
(
1
<<
i
)
-
1
;
}
static
inline
int
get_se_golomb
(
GetBitContext
*
gb
)
{
int
v
=
get_ue_golomb
(
gb
)
+
1
;
int
sign
=
-
(
v
&
1
);
return
((
v
>>
1
)
^
sign
)
-
sign
;
}
H264SequenceParameterSet
*
ff_avc_decode_sps
(
const
uint8_t
*
buf
,
int
buf_size
)
{
int
i
,
j
,
ret
,
rbsp_size
,
aspect_ratio_idc
,
pic_order_cnt_type
;
int
num_ref_frames_in_pic_order_cnt_cycle
;
int
delta_scale
,
lastScale
=
8
,
nextScale
=
8
;
int
sizeOfScalingList
;
H264SequenceParameterSet
*
sps
=
NULL
;
GetBitContext
gb
;
uint8_t
*
rbsp_buf
;
rbsp_buf
=
ff_nal_unit_extract_rbsp
(
buf
,
buf_size
,
&
rbsp_size
,
0
);
if
(
!
rbsp_buf
)
return
NULL
;
ret
=
init_get_bits8
(
&
gb
,
rbsp_buf
,
rbsp_size
);
if
(
ret
<
0
)
goto
end
;
sps
=
av_mallocz
(
sizeof
(
*
sps
));
if
(
!
sps
)
goto
end
;
sps
->
profile_idc
=
get_bits
(
&
gb
,
8
);
sps
->
constraint_set_flags
|=
get_bits1
(
&
gb
)
<<
0
;
// constraint_set0_flag
sps
->
constraint_set_flags
|=
get_bits1
(
&
gb
)
<<
1
;
// constraint_set1_flag
sps
->
constraint_set_flags
|=
get_bits1
(
&
gb
)
<<
2
;
// constraint_set2_flag
sps
->
constraint_set_flags
|=
get_bits1
(
&
gb
)
<<
3
;
// constraint_set3_flag
sps
->
constraint_set_flags
|=
get_bits1
(
&
gb
)
<<
4
;
// constraint_set4_flag
sps
->
constraint_set_flags
|=
get_bits1
(
&
gb
)
<<
5
;
// constraint_set5_flag
skip_bits
(
&
gb
,
2
);
// reserved_zero_2bits
sps
->
level_idc
=
get_bits
(
&
gb
,
8
);
sps
->
id
=
get_ue_golomb
(
&
gb
);
if
(
sps
->
profile_idc
==
100
||
sps
->
profile_idc
==
110
||
sps
->
profile_idc
==
122
||
sps
->
profile_idc
==
244
||
sps
->
profile_idc
==
44
||
sps
->
profile_idc
==
83
||
sps
->
profile_idc
==
86
||
sps
->
profile_idc
==
118
||
sps
->
profile_idc
==
128
||
sps
->
profile_idc
==
138
||
sps
->
profile_idc
==
139
||
sps
->
profile_idc
==
134
)
{
sps
->
chroma_format_idc
=
get_ue_golomb
(
&
gb
);
// chroma_format_idc
if
(
sps
->
chroma_format_idc
==
3
)
{
skip_bits1
(
&
gb
);
// separate_colour_plane_flag
}
sps
->
bit_depth_luma
=
get_ue_golomb
(
&
gb
)
+
8
;
get_ue_golomb
(
&
gb
);
// bit_depth_chroma_minus8
skip_bits1
(
&
gb
);
// qpprime_y_zero_transform_bypass_flag
if
(
get_bits1
(
&
gb
))
{
// seq_scaling_matrix_present_flag
for
(
i
=
0
;
i
<
((
sps
->
chroma_format_idc
!=
3
)
?
8
:
12
);
i
++
)
{
if
(
!
get_bits1
(
&
gb
))
// seq_scaling_list_present_flag
continue
;
lastScale
=
8
;
nextScale
=
8
;
sizeOfScalingList
=
i
<
6
?
16
:
64
;
for
(
j
=
0
;
j
<
sizeOfScalingList
;
j
++
)
{
if
(
nextScale
!=
0
)
{
delta_scale
=
get_se_golomb
(
&
gb
);
nextScale
=
(
lastScale
+
delta_scale
)
&
0xff
;
}
lastScale
=
nextScale
==
0
?
lastScale
:
nextScale
;
}
}
}
}
else
{
sps
->
chroma_format_idc
=
1
;
sps
->
bit_depth_luma
=
8
;
}
get_ue_golomb
(
&
gb
);
// log2_max_frame_num_minus4
pic_order_cnt_type
=
get_ue_golomb
(
&
gb
);
if
(
pic_order_cnt_type
==
0
)
{
get_ue_golomb
(
&
gb
);
// log2_max_pic_order_cnt_lsb_minus4
}
else
if
(
pic_order_cnt_type
==
1
)
{
skip_bits1
(
&
gb
);
// delta_pic_order_always_zero
get_se_golomb
(
&
gb
);
// offset_for_non_ref_pic
get_se_golomb
(
&
gb
);
// offset_for_top_to_bottom_field
num_ref_frames_in_pic_order_cnt_cycle
=
get_ue_golomb
(
&
gb
);
for
(
i
=
0
;
i
<
num_ref_frames_in_pic_order_cnt_cycle
;
i
++
)
get_se_golomb
(
&
gb
);
// offset_for_ref_frame
}
get_ue_golomb
(
&
gb
);
// max_num_ref_frames
skip_bits1
(
&
gb
);
// gaps_in_frame_num_value_allowed_flag
get_ue_golomb
(
&
gb
);
// pic_width_in_mbs_minus1
get_ue_golomb
(
&
gb
);
// pic_height_in_map_units_minus1
sps
->
frame_mbs_only_flag
=
get_bits1
(
&
gb
);
if
(
!
sps
->
frame_mbs_only_flag
)
skip_bits1
(
&
gb
);
// mb_adaptive_frame_field_flag
skip_bits1
(
&
gb
);
// direct_8x8_inference_flag
if
(
get_bits1
(
&
gb
))
{
// frame_cropping_flag
get_ue_golomb
(
&
gb
);
// frame_crop_left_offset
get_ue_golomb
(
&
gb
);
// frame_crop_right_offset
get_ue_golomb
(
&
gb
);
// frame_crop_top_offset
get_ue_golomb
(
&
gb
);
// frame_crop_bottom_offset
}
if
(
get_bits1
(
&
gb
))
{
// vui_parameters_present_flag
if
(
get_bits1
(
&
gb
))
{
// aspect_ratio_info_present_flag
aspect_ratio_idc
=
get_bits
(
&
gb
,
8
);
if
(
aspect_ratio_idc
==
0xff
)
{
sps
->
sar
.
num
=
get_bits
(
&
gb
,
16
);
sps
->
sar
.
den
=
get_bits
(
&
gb
,
16
);
}
else
if
(
aspect_ratio_idc
<
FF_ARRAY_ELEMS
(
avc_sample_aspect_ratio
))
{
sps
->
sar
=
avc_sample_aspect_ratio
[
aspect_ratio_idc
];
}
}
}
if
(
!
sps
->
sar
.
den
)
{
sps
->
sar
.
num
=
1
;
sps
->
sar
.
den
=
1
;
}
end:
av_free
(
rbsp_buf
);
return
sps
;
}
libavformat/avc.h
View file @
b401a4ab
...
@@ -33,5 +33,20 @@ int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size);
...
@@ -33,5 +33,20 @@ int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size);
const
uint8_t
*
ff_avc_mp4_find_startcode
(
const
uint8_t
*
start
,
const
uint8_t
*
ff_avc_mp4_find_startcode
(
const
uint8_t
*
start
,
const
uint8_t
*
end
,
const
uint8_t
*
end
,
int
nal_length_size
);
int
nal_length_size
);
uint8_t
*
ff_nal_unit_extract_rbsp
(
const
uint8_t
*
src
,
uint32_t
src_len
,
uint32_t
*
dst_len
,
int
header_len
);
typedef
struct
{
uint8_t
id
;
uint8_t
profile_idc
;
uint8_t
level_idc
;
uint8_t
constraint_set_flags
;
uint8_t
chroma_format_idc
;
uint8_t
bit_depth_luma
;
uint8_t
frame_mbs_only_flag
;
AVRational
sar
;
}
H264SequenceParameterSet
;
H264SequenceParameterSet
*
ff_avc_decode_sps
(
const
uint8_t
*
src
,
int
src_len
);
#endif
/* AVFORMAT_AVC_H */
#endif
/* AVFORMAT_AVC_H */
libavformat/hevc.c
View file @
b401a4ab
...
@@ -643,40 +643,6 @@ static int hvcc_parse_pps(GetBitContext *gb,
...
@@ -643,40 +643,6 @@ static int hvcc_parse_pps(GetBitContext *gb,
return
0
;
return
0
;
}
}
static
uint8_t
*
nal_unit_extract_rbsp
(
const
uint8_t
*
src
,
uint32_t
src_len
,
uint32_t
*
dst_len
)
{
uint8_t
*
dst
;
uint32_t
i
,
len
;
dst
=
av_malloc
(
src_len
+
AV_INPUT_BUFFER_PADDING_SIZE
);
if
(
!
dst
)
return
NULL
;
/* NAL unit header (2 bytes) */
i
=
len
=
0
;
while
(
i
<
2
&&
i
<
src_len
)
dst
[
len
++
]
=
src
[
i
++
];
while
(
i
+
2
<
src_len
)
if
(
!
src
[
i
]
&&
!
src
[
i
+
1
]
&&
src
[
i
+
2
]
==
3
)
{
dst
[
len
++
]
=
src
[
i
++
];
dst
[
len
++
]
=
src
[
i
++
];
i
++
;
// remove emulation_prevention_three_byte
}
else
dst
[
len
++
]
=
src
[
i
++
];
while
(
i
<
src_len
)
dst
[
len
++
]
=
src
[
i
++
];
memset
(
dst
+
len
,
0
,
AV_INPUT_BUFFER_PADDING_SIZE
);
*
dst_len
=
len
;
return
dst
;
}
static
void
nal_unit_parse_header
(
GetBitContext
*
gb
,
uint8_t
*
nal_type
)
static
void
nal_unit_parse_header
(
GetBitContext
*
gb
,
uint8_t
*
nal_type
)
{
{
skip_bits1
(
gb
);
// forbidden_zero_bit
skip_bits1
(
gb
);
// forbidden_zero_bit
...
@@ -753,7 +719,7 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
...
@@ -753,7 +719,7 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
uint8_t
*
rbsp_buf
;
uint8_t
*
rbsp_buf
;
uint32_t
rbsp_size
;
uint32_t
rbsp_size
;
rbsp_buf
=
nal_unit_extract_rbsp
(
nal_buf
,
nal_size
,
&
rbsp_size
);
rbsp_buf
=
ff_nal_unit_extract_rbsp
(
nal_buf
,
nal_size
,
&
rbsp_size
,
2
);
if
(
!
rbsp_buf
)
{
if
(
!
rbsp_buf
)
{
ret
=
AVERROR
(
ENOMEM
);
ret
=
AVERROR
(
ENOMEM
);
goto
end
;
goto
end
;
...
...
libavformat/mxf.h
View file @
b401a4ab
...
@@ -48,6 +48,7 @@ enum MXFMetadataSetType {
...
@@ -48,6 +48,7 @@ enum MXFMetadataSetType {
EssenceGroup
,
EssenceGroup
,
TaggedValue
,
TaggedValue
,
TapeDescriptor
,
TapeDescriptor
,
AVCSubDescriptor
,
};
};
enum
MXFFrameLayout
{
enum
MXFFrameLayout
{
...
...
libavformat/mxfenc.c
View file @
b401a4ab
This diff is collapsed.
Click to expand it.
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