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
91a28b0e
Commit
91a28b0e
authored
Feb 07, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: add ff_samples_to_time_base() convenience function to internal.h
parent
41ac9bb2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
15 deletions
+21
-15
internal.h
libavcodec/internal.h
+11
-0
libspeexenc.c
libavcodec/libspeexenc.c
+1
-4
libvorbis.c
libavcodec/libvorbis.c
+3
-2
utils.c
libavcodec/utils.c
+6
-9
No files found.
libavcodec/internal.h
View file @
91a28b0e
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <stdint.h>
#include "libavutil/mathematics.h"
#include "libavutil/pixfmt.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
#include "avcodec.h"
...
@@ -127,4 +128,14 @@ int avpriv_unlock_avformat(void);
...
@@ -127,4 +128,14 @@ int avpriv_unlock_avformat(void);
*/
*/
int
ff_alloc_packet
(
AVPacket
*
avpkt
,
int
size
);
int
ff_alloc_packet
(
AVPacket
*
avpkt
,
int
size
);
/**
* Rescale from sample rate to AVCodecContext.time_base.
*/
static
av_always_inline
int64_t
ff_samples_to_time_base
(
AVCodecContext
*
avctx
,
int64_t
samples
)
{
return
av_rescale_q
(
samples
,
(
AVRational
){
1
,
avctx
->
sample_rate
},
avctx
->
time_base
);
}
#endif
/* AVCODEC_INTERNAL_H */
#endif
/* AVCODEC_INTERNAL_H */
libavcodec/libspeexenc.c
View file @
91a28b0e
...
@@ -67,7 +67,6 @@
...
@@ -67,7 +67,6 @@
#include <speex/speex.h>
#include <speex/speex.h>
#include <speex/speex_header.h>
#include <speex/speex_header.h>
#include <speex/speex_stereo.h>
#include <speex/speex_stereo.h>
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "avcodec.h"
#include "internal.h"
#include "internal.h"
...
@@ -258,9 +257,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size,
...
@@ -258,9 +257,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size,
/* write output if all frames for the packet have been encoded */
/* write output if all frames for the packet have been encoded */
if
(
s
->
pkt_frame_count
==
s
->
frames_per_packet
)
{
if
(
s
->
pkt_frame_count
==
s
->
frames_per_packet
)
{
s
->
pkt_frame_count
=
0
;
s
->
pkt_frame_count
=
0
;
avctx
->
coded_frame
->
pts
=
avctx
->
coded_frame
->
pts
=
ff_samples_to_time_base
(
avctx
,
s
->
next_pts
);
av_rescale_q
(
s
->
next_pts
,
(
AVRational
){
1
,
avctx
->
sample_rate
},
avctx
->
time_base
);
s
->
next_pts
+=
s
->
pkt_sample_count
;
s
->
next_pts
+=
s
->
pkt_sample_count
;
s
->
pkt_sample_count
=
0
;
s
->
pkt_sample_count
=
0
;
if
(
buf_size
>
speex_bits_nbytes
(
&
s
->
bits
))
{
if
(
buf_size
>
speex_bits_nbytes
(
&
s
->
bits
))
{
...
...
libavcodec/libvorbis.c
View file @
91a28b0e
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
#include "libavutil/opt.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "avcodec.h"
#include "bytestream.h"
#include "bytestream.h"
#include "internal.h"
#include "vorbis.h"
#include "vorbis.h"
#include "libavutil/mathematics.h"
#undef NDEBUG
#undef NDEBUG
#include <assert.h>
#include <assert.h>
...
@@ -216,7 +216,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
...
@@ -216,7 +216,8 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
op2
->
packet
=
context
->
buffer
+
sizeof
(
ogg_packet
);
op2
->
packet
=
context
->
buffer
+
sizeof
(
ogg_packet
);
l
=
op2
->
bytes
;
l
=
op2
->
bytes
;
avccontext
->
coded_frame
->
pts
=
av_rescale_q
(
op2
->
granulepos
,
(
AVRational
)
{
1
,
avccontext
->
sample_rate
},
avccontext
->
time_base
);
avccontext
->
coded_frame
->
pts
=
ff_samples_to_time_base
(
avccontext
,
op2
->
granulepos
);
//FIXME we should reorder the user supplied pts and not assume that they are spaced by 1/sample_rate
//FIXME we should reorder the user supplied pts and not assume that they are spaced by 1/sample_rate
if
(
l
>
buf_size
)
{
if
(
l
>
buf_size
)
{
...
...
libavcodec/utils.c
View file @
91a28b0e
...
@@ -886,9 +886,8 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
...
@@ -886,9 +886,8 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
if
(
!
ret
&&
*
got_packet_ptr
)
{
if
(
!
ret
&&
*
got_packet_ptr
)
{
if
(
!
(
avctx
->
codec
->
capabilities
&
CODEC_CAP_DELAY
))
{
if
(
!
(
avctx
->
codec
->
capabilities
&
CODEC_CAP_DELAY
))
{
avpkt
->
pts
=
frame
->
pts
;
avpkt
->
pts
=
frame
->
pts
;
avpkt
->
duration
=
av_rescale_q
(
frame
->
nb_samples
,
avpkt
->
duration
=
ff_samples_to_time_base
(
avctx
,
(
AVRational
){
1
,
avctx
->
sample_rate
},
frame
->
nb_samples
);
avctx
->
time_base
);
}
}
avpkt
->
dts
=
avpkt
->
pts
;
avpkt
->
dts
=
avpkt
->
pts
;
}
else
{
}
else
{
...
@@ -944,9 +943,8 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
...
@@ -944,9 +943,8 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
once all encoders supporting CODEC_CAP_SMALL_LAST_FRAME use
once all encoders supporting CODEC_CAP_SMALL_LAST_FRAME use
encode2() */
encode2() */
if
(
fs_tmp
)
{
if
(
fs_tmp
)
{
avpkt
->
duration
=
av_rescale_q
(
avctx
->
frame_size
,
avpkt
->
duration
=
ff_samples_to_time_base
(
avctx
,
(
AVRational
){
1
,
avctx
->
sample_rate
},
avctx
->
frame_size
);
avctx
->
time_base
);
}
}
}
}
avpkt
->
size
=
ret
;
avpkt
->
size
=
ret
;
...
@@ -1018,9 +1016,8 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
...
@@ -1018,9 +1016,8 @@ int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
/* fabricate frame pts from sample count.
/* fabricate frame pts from sample count.
this is needed because the avcodec_encode_audio() API does not have
this is needed because the avcodec_encode_audio() API does not have
a way for the user to provide pts */
a way for the user to provide pts */
frame
->
pts
=
av_rescale_q
(
avctx
->
internal
->
sample_count
,
frame
->
pts
=
ff_samples_to_time_base
(
avctx
,
(
AVRational
){
1
,
avctx
->
sample_rate
},
avctx
->
internal
->
sample_count
);
avctx
->
time_base
);
avctx
->
internal
->
sample_count
+=
frame
->
nb_samples
;
avctx
->
internal
->
sample_count
+=
frame
->
nb_samples
;
}
else
{
}
else
{
frame
=
NULL
;
frame
=
NULL
;
...
...
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