diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-05 02:03:12 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-05 02:03:12 +0100 |
commit | 7f83db312454b3673a4dfd34745428f61309ab30 (patch) | |
tree | 27c92b052b83e4b3bf95a33fbe6979aaa00f8184 /libavcodec/libspeexenc.c | |
parent | c4eec85a1fa768025f88261995af08f1dba9685d (diff) | |
parent | feb15cee5e19a1e31d075ec08d598d64c2dc38ef (diff) | |
download | ffmpeg-7f83db312454b3673a4dfd34745428f61309ab30.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (46 commits)
mtv: Make sure audio_subsegments is not 0
v4l2: use V4L2_FMT_FLAG_EMULATED only if it is defined
avconv: add symbolic names for -vsync parameters
flvdec: Fix compiler warning for uninitialized variables
rtsp: Fix compiler warning for uninitialized variable
ulti: convert to new bytestream API.
swscale: Use standard multiple inclusion guards in ppc/ header files.
Place some START_TIMER invocations in separate blocks.
v4l2: list available formats
v4l2: set the proper codec_tag
v4l2: refactor device_open
v4l2: simplify away io_method
v4l2: cosmetics
v4l2: uniform and format options
v4l2: do not force interlaced mode
avio: exit early in fill_buffer without read_packet
vc1dec: fix invalid memory access for small video dimensions
rv34: fix invalid memory access for small video dimensions
rv34: joint coefficient decoding and dequantization
avplay: Don't call avio_set_interrupt_cb(NULL)
...
Conflicts:
Changelog
avconv.c
doc/APIchanges
doc/indevs.texi
libavcodec/adxenc.c
libavcodec/dnxhdenc.c
libavcodec/h264.c
libavdevice/v4l2.c
libavformat/flvdec.c
libavformat/mtv.c
libswscale/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libspeexenc.c')
-rw-r--r-- | libavcodec/libspeexenc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index a3176d1388..c89f0748a1 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -83,7 +83,8 @@ typedef struct { int abr; ///< flag to enable ABR int pkt_frame_count; ///< frame count for the current packet int lookahead; ///< encoder delay - int sample_count; ///< total sample count (used for pts) + int64_t next_pts; ///< next pts, in sample_rate time base + int pkt_sample_count; ///< sample count in the current packet } LibSpeexEncContext; static av_cold void print_enc_params(AVCodecContext *avctx, @@ -201,7 +202,7 @@ static av_cold int encode_init(AVCodecContext *avctx) /* set encoding delay */ speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &s->lookahead); - s->sample_count = -s->lookahead; + s->next_pts = -s->lookahead; /* create header packet bytes from header struct */ /* note: libspeex allocates the memory for header_data, which is freed @@ -235,7 +236,6 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, { LibSpeexEncContext *s = avctx->priv_data; int16_t *samples = data; - int sample_count = s->sample_count; if (data) { /* encode Speex frame */ @@ -243,7 +243,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, speex_encode_stereo_int(samples, s->header.frame_size, &s->bits); speex_encode_int(s->enc_state, samples, &s->bits); s->pkt_frame_count++; - s->sample_count += avctx->frame_size; + s->pkt_sample_count += avctx->frame_size; } else { /* handle end-of-stream */ if (!s->pkt_frame_count) @@ -259,8 +259,10 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, if (s->pkt_frame_count == s->frames_per_packet) { s->pkt_frame_count = 0; avctx->coded_frame->pts = - av_rescale_q(sample_count, (AVRational){ 1, avctx->sample_rate }, + av_rescale_q(s->next_pts, (AVRational){ 1, avctx->sample_rate }, avctx->time_base); + s->next_pts += s->pkt_sample_count; + s->pkt_sample_count = 0; if (buf_size > speex_bits_nbytes(&s->bits)) { int ret = speex_bits_write(&s->bits, frame, buf_size); speex_bits_reset(&s->bits); |