Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
789f8cb0
Commit
789f8cb0
authored
May 27, 2012
by
Matthieu Bouron
Committed by
Michael Niedermayer
Jul 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil: support 50 and 60 frame rates in timecode api
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
3be02afb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
5 deletions
+41
-5
mpeg12enc.c
libavcodec/mpeg12enc.c
+1
-1
timecode.c
libavutil/timecode.c
+25
-3
timecode.h
libavutil/timecode.h
+12
-1
version.h
libavutil/version.h
+3
-0
No files found.
libavcodec/mpeg12enc.c
View file @
789f8cb0
...
...
@@ -300,7 +300,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
s
->
gop_picture_number
=
s
->
current_picture_ptr
->
f
.
coded_picture_number
;
av_assert0
(
s
->
drop_frame_timecode
==
!!
(
s
->
tc
.
flags
&
AV_TIMECODE_FLAG_DROPFRAME
));
if
(
s
->
drop_frame_timecode
)
time_code
=
av_timecode_adjust_ntsc_framenum
(
time_code
);
time_code
=
av_timecode_adjust_ntsc_framenum
2
(
time_code
,
fps
);
put_bits
(
&
s
->
pb
,
5
,
(
uint32_t
)((
time_code
/
(
fps
*
3600
))
%
24
));
put_bits
(
&
s
->
pb
,
6
,
(
uint32_t
)((
time_code
/
(
fps
*
60
))
%
60
));
put_bits
(
&
s
->
pb
,
1
,
1
);
...
...
libavutil/timecode.c
View file @
789f8cb0
...
...
@@ -31,6 +31,7 @@
#include "log.h"
#include "error.h"
#ifdef FF_API_OLD_TC_ADJUST_FRAMENUM
int
av_timecode_adjust_ntsc_framenum
(
int
framenum
)
{
/* only works for NTSC 29.97 */
...
...
@@ -39,6 +40,25 @@ int av_timecode_adjust_ntsc_framenum(int framenum)
//if (m < 2) m += 2; /* not needed since -2,-1 / 1798 in C returns 0 */
return
framenum
+
18
*
d
+
2
*
((
m
-
2
)
/
1798
);
}
#endif
int
av_timecode_adjust_ntsc_framenum2
(
int
framenum
,
int
fps
)
{
/* only works for NTSC 29.97 and 59.94 */
int
drop_frames
=
0
;
int
d
=
framenum
/
17982
;
int
m
=
framenum
%
17982
;
if
(
fps
==
30
)
drop_frames
=
2
;
else
if
(
fps
==
60
)
drop_frames
=
4
;
else
return
framenum
;
//if (m < 2) m += 2; /* not needed since -2,-1 / 1798 in C returns 0 */
return
framenum
+
9
*
drop_frames
*
d
+
drop_frames
*
((
m
-
2
)
/
1798
);
}
uint32_t
av_timecode_get_smpte_from_framenum
(
const
AVTimecode
*
tc
,
int
framenum
)
{
...
...
@@ -48,7 +68,7 @@ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
framenum
+=
tc
->
start
;
if
(
drop
)
framenum
=
av_timecode_adjust_ntsc_framenum
(
framenum
);
framenum
=
av_timecode_adjust_ntsc_framenum
2
(
framenum
,
tc
->
fps
);
ff
=
framenum
%
fps
;
ss
=
framenum
/
fps
%
60
;
mm
=
framenum
/
(
fps
*
60
)
%
60
;
...
...
@@ -77,7 +97,7 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
framenum
+=
tc
->
start
;
if
(
drop
)
framenum
=
av_timecode_adjust_ntsc_framenum
(
framenum
);
framenum
=
av_timecode_adjust_ntsc_framenum
2
(
framenum
,
fps
);
if
(
framenum
<
0
)
{
framenum
=
-
framenum
;
neg
=
tc
->
flags
&
AV_TIMECODE_FLAG_ALLOWNEGATIVE
;
...
...
@@ -139,7 +159,9 @@ static int check_timecode(void *log_ctx, AVTimecode *tc)
switch
(
tc
->
fps
)
{
case
24
:
case
25
:
case
30
:
return
0
;
case
30
:
case
50
:
case
60
:
return
0
;
default:
av_log
(
log_ctx
,
AV_LOG_ERROR
,
"Timecode frame rate not supported
\n
"
);
...
...
libavutil/timecode.h
View file @
789f8cb0
...
...
@@ -51,8 +51,19 @@ typedef struct {
* @param framenum frame number to adjust
* @return adjusted frame number
* @warning adjustment is only valid in NTSC 29.97
* @deprecated use av_timecode_adjust_ntsc_framenum2 instead
*/
int
av_timecode_adjust_ntsc_framenum
(
int
framenum
);
attribute_deprecated
int
av_timecode_adjust_ntsc_framenum
(
int
framenum
);
/**
* Adjust frame number for NTSC drop frame time code.
*
* @param framenum frame number to adjust
* @param fps frame per second, 30 or 60
* @return adjusted frame number
* @warning adjustment is only valid in NTSC 29.97 and 59.94
*/
int
av_timecode_adjust_ntsc_framenum2
(
int
framenum
,
int
fps
);
/**
* Convert frame number to SMPTE 12M binary representation.
...
...
libavutil/version.h
View file @
789f8cb0
...
...
@@ -78,6 +78,9 @@
#ifndef FF_API_OLD_AVOPTIONS
#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 52)
#endif
#ifndef FF_API_OLD_TC_ADJUST_FRAMENUM
#define FF_API_OLD_TC_ADJUST_FRAMENUM (LIBAVUTIL_VERSION_MAJOR < 52)
#endif
/**
* @}
...
...
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