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
27a81469
Commit
27a81469
authored
Feb 28, 2020
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/mxf: get rid of samples per frame array usage
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
aef2016b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
78 deletions
+17
-78
mxf.c
libavformat/mxf.c
+4
-40
mxf.h
libavformat/mxf.h
+0
-6
mxfdec.c
libavformat/mxfdec.c
+3
-20
mxfenc.c
libavformat/mxfenc.c
+10
-12
No files found.
libavformat/mxf.c
View file @
27a81469
...
@@ -131,16 +131,6 @@ int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *
...
@@ -131,16 +131,6 @@ int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *
return
-
1
;
return
-
1
;
}
}
static
const
MXFSamplesPerFrame
mxf_spf
[]
=
{
{
{
1001
,
24000
},
{
2002
,
0
,
0
,
0
,
0
,
0
}
},
// FILM 23.976
{
{
1
,
24
},
{
2000
,
0
,
0
,
0
,
0
,
0
}
},
// FILM 24
{
{
1001
,
30000
},
{
1602
,
1601
,
1602
,
1601
,
1602
,
0
}
},
// NTSC 29.97
{
{
1001
,
60000
},
{
801
,
801
,
800
,
801
,
801
,
0
}
},
// NTSC 59.94
{
{
1
,
25
},
{
1920
,
0
,
0
,
0
,
0
,
0
}
},
// PAL 25
{
{
1
,
50
},
{
960
,
0
,
0
,
0
,
0
,
0
}
},
// PAL 50
{
{
1
,
60
},
{
800
,
0
,
0
,
0
,
0
,
0
}
},
};
static
const
AVRational
mxf_time_base
[]
=
{
static
const
AVRational
mxf_time_base
[]
=
{
{
1001
,
24000
},
{
1001
,
24000
},
{
1
,
24
},
{
1
,
24
},
...
@@ -152,40 +142,14 @@ static const AVRational mxf_time_base[] = {
...
@@ -152,40 +142,14 @@ static const AVRational mxf_time_base[] = {
{
0
,
0
}
{
0
,
0
}
};
};
const
MXFSamplesPerFrame
*
ff_mxf_get_samples_per_frame
(
AVFormatContext
*
s
,
AVRational
time_base
)
{
int
idx
=
av_find_nearest_q_idx
(
time_base
,
mxf_time_base
);
AVRational
diff
=
av_sub_q
(
time_base
,
mxf_time_base
[
idx
]);
diff
.
num
=
FFABS
(
diff
.
num
);
if
(
av_cmp_q
(
diff
,
(
AVRational
){
1
,
1000
})
>=
0
)
return
NULL
;
if
(
av_cmp_q
(
time_base
,
mxf_time_base
[
idx
]))
av_log
(
s
,
AV_LOG_WARNING
,
"%d/%d input time base matched %d/%d container time base
\n
"
,
time_base
.
num
,
time_base
.
den
,
mxf_spf
[
idx
].
time_base
.
num
,
mxf_spf
[
idx
].
time_base
.
den
);
return
&
mxf_spf
[
idx
];
}
static
const
int
mxf_content_package_rates
[]
=
{
static
const
int
mxf_content_package_rates
[]
=
{
3
,
2
,
7
,
13
,
4
,
10
,
12
,
3
,
2
,
7
,
13
,
4
,
10
,
12
,
};
};
int
ff_mxf_get_content_package_rate
(
AVRational
time_base
)
int
ff_mxf_get_content_package_rate
(
AVRational
time_base
)
{
{
int
idx
=
av_find_nearest_q_idx
(
time_base
,
mxf_time_base
);
for
(
int
i
=
0
;
mxf_time_base
[
i
].
num
;
i
++
)
AVRational
diff
=
av_sub_q
(
time_base
,
mxf_time_base
[
idx
]);
if
(
!
av_cmp_q
(
time_base
,
mxf_time_base
[
i
]))
return
mxf_content_package_rates
[
i
];
diff
.
num
=
FFABS
(
diff
.
num
);
return
0
;
if
(
av_cmp_q
(
diff
,
(
AVRational
){
1
,
1000
})
>=
0
)
return
-
1
;
return
mxf_content_package_rates
[
idx
];
}
}
libavformat/mxf.h
View file @
27a81469
...
@@ -82,18 +82,12 @@ typedef struct MXFCodecUL {
...
@@ -82,18 +82,12 @@ typedef struct MXFCodecUL {
MXFWrappingIndicatorType
wrapping_indicator_type
;
MXFWrappingIndicatorType
wrapping_indicator_type
;
}
MXFCodecUL
;
}
MXFCodecUL
;
typedef
struct
{
struct
AVRational
time_base
;
int
samples_per_frame
[
6
];
}
MXFSamplesPerFrame
;
extern
const
MXFCodecUL
ff_mxf_data_definition_uls
[];
extern
const
MXFCodecUL
ff_mxf_data_definition_uls
[];
extern
const
MXFCodecUL
ff_mxf_codec_uls
[];
extern
const
MXFCodecUL
ff_mxf_codec_uls
[];
extern
const
MXFCodecUL
ff_mxf_pixel_format_uls
[];
extern
const
MXFCodecUL
ff_mxf_pixel_format_uls
[];
extern
const
MXFCodecUL
ff_mxf_codec_tag_uls
[];
extern
const
MXFCodecUL
ff_mxf_codec_tag_uls
[];
int
ff_mxf_decode_pixel_layout
(
const
char
pixel_layout
[
16
],
enum
AVPixelFormat
*
pix_fmt
);
int
ff_mxf_decode_pixel_layout
(
const
char
pixel_layout
[
16
],
enum
AVPixelFormat
*
pix_fmt
);
const
MXFSamplesPerFrame
*
ff_mxf_get_samples_per_frame
(
AVFormatContext
*
s
,
AVRational
time_base
);
int
ff_mxf_get_content_package_rate
(
AVRational
time_base
);
int
ff_mxf_get_content_package_rate
(
AVRational
time_base
);
...
...
libavformat/mxfdec.c
View file @
27a81469
...
@@ -3307,20 +3307,17 @@ static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_
...
@@ -3307,20 +3307,17 @@ static int mxf_get_next_track_edit_unit(MXFContext *mxf, MXFTrack *track, int64_
static
int64_t
mxf_compute_sample_count
(
MXFContext
*
mxf
,
AVStream
*
st
,
static
int64_t
mxf_compute_sample_count
(
MXFContext
*
mxf
,
AVStream
*
st
,
int64_t
edit_unit
)
int64_t
edit_unit
)
{
{
int
i
,
total
=
0
,
size
=
0
;
MXFTrack
*
track
=
st
->
priv_data
;
MXFTrack
*
track
=
st
->
priv_data
;
AVRational
time_base
=
av_inv_q
(
track
->
edit_rate
);
AVRational
time_base
=
av_inv_q
(
track
->
edit_rate
);
AVRational
sample_rate
=
av_inv_q
(
st
->
time_base
);
AVRational
sample_rate
=
av_inv_q
(
st
->
time_base
);
const
MXFSamplesPerFrame
*
spf
=
NULL
;
int64_t
sample_count
;
// For non-audio sample_count equals current edit unit
// For non-audio sample_count equals current edit unit
if
(
st
->
codecpar
->
codec_type
!=
AVMEDIA_TYPE_AUDIO
)
if
(
st
->
codecpar
->
codec_type
!=
AVMEDIA_TYPE_AUDIO
)
return
edit_unit
;
return
edit_unit
;
if
((
sample_rate
.
num
/
sample_rate
.
den
)
==
48000
)
if
((
sample_rate
.
num
/
sample_rate
.
den
)
==
48000
)
{
spf
=
ff_mxf_get_samples_per_frame
(
mxf
->
fc
,
time_bas
e
);
return
av_rescale_q
(
edit_unit
,
sample_rate
,
track
->
edit_rat
e
);
if
(
!
spf
)
{
}
else
{
int
remainder
=
(
sample_rate
.
num
*
time_base
.
num
)
%
int
remainder
=
(
sample_rate
.
num
*
time_base
.
num
)
%
(
time_base
.
den
*
sample_rate
.
den
);
(
time_base
.
den
*
sample_rate
.
den
);
if
(
remainder
)
if
(
remainder
)
...
@@ -3331,20 +3328,6 @@ static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st,
...
@@ -3331,20 +3328,6 @@ static int64_t mxf_compute_sample_count(MXFContext *mxf, AVStream *st,
sample_rate
.
num
,
sample_rate
.
den
);
sample_rate
.
num
,
sample_rate
.
den
);
return
av_rescale_q
(
edit_unit
,
sample_rate
,
track
->
edit_rate
);
return
av_rescale_q
(
edit_unit
,
sample_rate
,
track
->
edit_rate
);
}
}
while
(
spf
->
samples_per_frame
[
size
])
{
total
+=
spf
->
samples_per_frame
[
size
];
size
++
;
}
av_assert2
(
size
);
sample_count
=
(
edit_unit
/
size
)
*
(
uint64_t
)
total
;
for
(
i
=
0
;
i
<
edit_unit
%
size
;
i
++
)
{
sample_count
+=
spf
->
samples_per_frame
[
i
];
}
return
sample_count
;
}
}
/**
/**
...
...
libavformat/mxfenc.c
View file @
27a81469
...
@@ -2425,7 +2425,6 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -2425,7 +2425,6 @@ static int mxf_write_header(AVFormatContext *s)
MXFContext
*
mxf
=
s
->
priv_data
;
MXFContext
*
mxf
=
s
->
priv_data
;
int
i
,
ret
;
int
i
,
ret
;
uint8_t
present
[
FF_ARRAY_ELEMS
(
mxf_essence_container_uls
)]
=
{
0
};
uint8_t
present
[
FF_ARRAY_ELEMS
(
mxf_essence_container_uls
)]
=
{
0
};
const
MXFSamplesPerFrame
*
spf
=
NULL
;
int64_t
timestamp
=
0
;
int64_t
timestamp
=
0
;
if
(
!
s
->
nb_streams
)
if
(
!
s
->
nb_streams
)
...
@@ -2479,15 +2478,14 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -2479,15 +2478,14 @@ static int mxf_write_header(AVFormatContext *s)
case
AVCHROMA_LOC_CENTER
:
sc
->
color_siting
=
3
;
break
;
case
AVCHROMA_LOC_CENTER
:
sc
->
color_siting
=
3
;
break
;
}
}
mxf
->
timecode_base
=
(
tbc
.
den
+
tbc
.
num
/
2
)
/
tbc
.
num
;
mxf
->
content_package_rate
=
ff_mxf_get_content_package_rate
(
tbc
);
spf
=
ff_mxf_get_samples_per_frame
(
s
,
tbc
);
if
(
!
mxf
->
content_package_rate
)
{
if
(
!
spf
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Unsupported video frame rate %d/%d
\n
"
,
av_log
(
s
,
AV_LOG_ERROR
,
"Unsupported video frame rate %d/%d
\n
"
,
tbc
.
den
,
tbc
.
num
);
tbc
.
den
,
tbc
.
num
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
mxf
->
content_package_rate
=
ff_mxf_get_content_package_rate
(
tbc
)
;
mxf
->
timecode_base
=
(
tbc
.
den
+
tbc
.
num
/
2
)
/
tbc
.
num
;
mxf
->
time_base
=
spf
->
time_base
;
mxf
->
time_base
=
tbc
;
rate
=
av_inv_q
(
mxf
->
time_base
);
rate
=
av_inv_q
(
mxf
->
time_base
);
avpriv_set_pts_info
(
st
,
64
,
mxf
->
time_base
.
num
,
mxf
->
time_base
.
den
);
avpriv_set_pts_info
(
st
,
64
,
mxf
->
time_base
.
num
,
mxf
->
time_base
.
den
);
if
((
ret
=
mxf_init_timecode
(
s
,
st
,
rate
))
<
0
)
if
((
ret
=
mxf_init_timecode
(
s
,
st
,
rate
))
<
0
)
...
@@ -2552,7 +2550,7 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -2552,7 +2550,7 @@ static int mxf_write_header(AVFormatContext *s)
}
}
sc
->
index
=
INDEX_D10_AUDIO
;
sc
->
index
=
INDEX_D10_AUDIO
;
sc
->
container_ul
=
((
MXFStreamContext
*
)
s
->
streams
[
0
]
->
priv_data
)
->
container_ul
;
sc
->
container_ul
=
((
MXFStreamContext
*
)
s
->
streams
[
0
]
->
priv_data
)
->
container_ul
;
sc
->
frame_size
=
4
+
8
*
spf
[
0
].
samples_per_frame
[
0
]
*
4
;
sc
->
frame_size
=
4
+
8
*
av_rescale_rnd
(
st
->
codecpar
->
sample_rate
,
mxf
->
time_base
.
num
,
mxf
->
time_base
.
den
,
AV_ROUND_UP
)
*
4
;
}
else
if
(
s
->
oformat
==
&
ff_mxf_opatom_muxer
)
{
}
else
if
(
s
->
oformat
==
&
ff_mxf_opatom_muxer
)
{
AVRational
tbc
=
av_inv_q
(
mxf
->
audio_edit_rate
);
AVRational
tbc
=
av_inv_q
(
mxf
->
audio_edit_rate
);
...
@@ -2566,14 +2564,13 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -2566,14 +2564,13 @@ static int mxf_write_header(AVFormatContext *s)
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
spf
=
ff_mxf_get_samples_per_frame
(
s
,
tbc
);
if
(
!
ff_mxf_get_content_package_rate
(
tbc
))
{
if
(
!
spf
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Unsupported timecode frame rate %d/%d
\n
"
,
tbc
.
den
,
tbc
.
num
);
av_log
(
s
,
AV_LOG_ERROR
,
"Unsupported timecode frame rate %d/%d
\n
"
,
tbc
.
den
,
tbc
.
num
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
mxf
->
time_base
=
st
->
time_base
;
mxf
->
time_base
=
st
->
time_base
;
if
((
ret
=
mxf_init_timecode
(
s
,
st
,
av_inv_q
(
spf
->
time_base
)))
<
0
)
if
((
ret
=
mxf_init_timecode
(
s
,
st
,
av_inv_q
(
tbc
)))
<
0
)
return
ret
;
return
ret
;
mxf
->
timecode_base
=
(
tbc
.
den
+
tbc
.
num
/
2
)
/
tbc
.
num
;
mxf
->
timecode_base
=
(
tbc
.
den
+
tbc
.
num
/
2
)
/
tbc
.
num
;
...
@@ -2581,8 +2578,9 @@ static int mxf_write_header(AVFormatContext *s)
...
@@ -2581,8 +2578,9 @@ static int mxf_write_header(AVFormatContext *s)
sc
->
index
=
INDEX_WAV
;
sc
->
index
=
INDEX_WAV
;
}
else
{
}
else
{
mxf
->
slice_count
=
1
;
mxf
->
slice_count
=
1
;
sc
->
frame_size
=
(
st
->
codecpar
->
channels
*
spf
[
0
].
samples_per_frame
[
0
]
*
sc
->
frame_size
=
st
->
codecpar
->
channels
*
av_get_bits_per_sample
(
st
->
codecpar
->
codec_id
))
/
8
;
av_rescale_rnd
(
st
->
codecpar
->
sample_rate
,
mxf
->
time_base
.
num
,
mxf
->
time_base
.
den
,
AV_ROUND_UP
)
*
av_get_bits_per_sample
(
st
->
codecpar
->
codec_id
)
/
8
;
}
}
}
else
if
(
st
->
codecpar
->
codec_type
==
AVMEDIA_TYPE_DATA
)
{
}
else
if
(
st
->
codecpar
->
codec_type
==
AVMEDIA_TYPE_DATA
)
{
AVDictionaryEntry
*
e
=
av_dict_get
(
st
->
metadata
,
"data_type"
,
NULL
,
0
);
AVDictionaryEntry
*
e
=
av_dict_get
(
st
->
metadata
,
"data_type"
,
NULL
,
0
);
...
...
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