]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libspeexenc.c
h264: fix mmxext chroma deblock to use correct TC values.
[ffmpeg] / libavcodec / libspeexenc.c
index 290718c5f124704ff5345479f3ffe0590c6e16a7..99fe2fe8e1e11b9feb4dac566959cd4c0854e74a 100644 (file)
@@ -67,7 +67,6 @@
 #include <speex/speex.h>
 #include <speex/speex_header.h>
 #include <speex/speex_stereo.h>
-#include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "internal.h"
@@ -82,7 +81,6 @@ typedef struct {
     int cbr_quality;            ///< CBR quality 0 to 10
     int abr;                    ///< flag to enable ABR
     int pkt_frame_count;        ///< frame count for the current packet
-    int lookahead;              ///< encoder delay
     int64_t next_pts;           ///< next pts, in sample_rate time base
     int pkt_sample_count;       ///< sample count in the current packet
 } LibSpeexEncContext;
@@ -201,8 +199,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
     s->header.frames_per_packet = s->frames_per_packet;
 
     /* set encoding delay */
-    speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &s->lookahead);
-    s->next_pts = -s->lookahead;
+    speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &avctx->delay);
 
     /* create header packet bytes from header struct */
     /* note: libspeex allocates the memory for header_data, which is freed
@@ -258,9 +255,8 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size,
     /* write output if all frames for the packet have been encoded */
     if (s->pkt_frame_count == s->frames_per_packet) {
         s->pkt_frame_count = 0;
-        avctx->coded_frame->pts =
-            av_rescale_q(s->next_pts, (AVRational){ 1, avctx->sample_rate },
-                         avctx->time_base);
+        avctx->coded_frame->pts = ff_samples_to_time_base(avctx, s->next_pts -
+                                                          avctx->delay);
         s->next_pts += s->pkt_sample_count;
         s->pkt_sample_count = 0;
         if (buf_size > speex_bits_nbytes(&s->bits)) {
@@ -319,7 +315,7 @@ AVCodec ff_libspeex_encoder = {
     .encode         = encode_frame,
     .close          = encode_close,
     .capabilities   = CODEC_CAP_DELAY,
-    .sample_fmts    = (const enum SampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
+    .sample_fmts    = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE },
     .long_name      = NULL_IF_CONFIG_SMALL("libspeex Speex"),
     .priv_class     = &class,
     .defaults       = defaults,