summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-18 02:07:42 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-18 02:08:12 +0100
commite191f1f4141aec6b40d12af4835844deca134a1e (patch)
treef50a57ec102a0c0902512b1535124515510baf0a
parent140a9afcf284123f3967060c6c7ef8105484bca6 (diff)
parent01ed1c390d8376ba5fac278ceee044bb03a58804 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: tta: cast output data pointer to the correct type avconv: fix -frames for video encoders with delay. Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--avconv.c20
-rw-r--r--ffmpeg.c20
-rw-r--r--libavcodec/tta.c2
3 files changed, 39 insertions, 3 deletions
diff --git a/avconv.c b/avconv.c
index 7566a42027..adb6414d9a 100644
--- a/avconv.c
+++ b/avconv.c
@@ -925,6 +925,19 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
AVCodecContext *avctx = ost->st->codec;
int ret;
+ /*
+ * Audio encoders may split the packets -- #frames in != #packets out.
+ * But there is no reordering, so we can limit the number of output packets
+ * by simply dropping them here.
+ * Counting encoded video frames needs to be done separately because of
+ * reordering, see do_video_out()
+ */
+ if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) {
+ if (ost->frame_number >= ost->max_frames)
+ return;
+ ost->frame_number++;
+ }
+
while (bsfc) {
AVPacket new_pkt = *pkt;
int a = av_bitstream_filter_filter(bsfc, avctx, NULL,
@@ -952,7 +965,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
print_error("av_interleaved_write_frame()", ret);
exit_program(1);
}
- ost->frame_number++;
}
static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size)
@@ -1513,6 +1525,12 @@ static void do_video_out(AVFormatContext *s,
}
}
ost->sync_opts++;
+ /*
+ * For video, number of frames in == number of packets out.
+ * But there may be reordering, so we can't throw away frames on encoder
+ * flush, we need to limit them here, before they go into encoder.
+ */
+ ost->frame_number++;
}
}
diff --git a/ffmpeg.c b/ffmpeg.c
index ba8dfc98fa..d6a243d8db 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -987,6 +987,19 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
AVCodecContext *avctx = ost->st->codec;
int ret;
+ /*
+ * Audio encoders may split the packets -- #frames in != #packets out.
+ * But there is no reordering, so we can limit the number of output packets
+ * by simply dropping them here.
+ * Counting encoded video frames needs to be done separately because of
+ * reordering, see do_video_out()
+ */
+ if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) {
+ if (ost->frame_number >= ost->max_frames)
+ return;
+ ost->frame_number++;
+ }
+
while (bsfc) {
AVPacket new_pkt = *pkt;
int a = av_bitstream_filter_filter(bsfc, avctx, NULL,
@@ -1014,7 +1027,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
print_error("av_interleaved_write_frame()", ret);
exit_program(1);
}
- ost->frame_number++;
}
static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size)
@@ -1568,6 +1580,12 @@ static void do_video_out(AVFormatContext *s,
}
}
ost->sync_opts++;
+ /*
+ * For video, number of frames in == number of packets out.
+ * But there may be reordering, so we can't throw away frames on encoder
+ * flush, we need to limit them here, before they go into encoder.
+ */
+ ost->frame_number++;
}
}
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index 42cbc01db5..8d49bc80d2 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -326,7 +326,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
// decode directly to output buffer for 24-bit sample format
if (s->bps == 3)
- s->decode_buffer = s->frame.data[0];
+ s->decode_buffer = (int32_t *)s->frame.data[0];
// init per channel states
for (i = 0; i < s->channels; i++) {