From 999328479305e317d9fdaeae791a60d299986073 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 2 Jan 2012 09:22:41 +0100 Subject: avconv: fix -frames for video encoders with delay. Frames must be counted when they are passed to the encoder, not when they come out. Fixes Bug 202. --- avconv.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/avconv.c b/avconv.c index 2246851301..e2cc4b0381 100644 --- a/avconv.c +++ b/avconv.c @@ -875,6 +875,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, @@ -902,7 +915,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) @@ -1450,6 +1462,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++; } } -- cgit v1.2.3 From 01ed1c390d8376ba5fac278ceee044bb03a58804 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sat, 7 Jan 2012 10:25:32 -0500 Subject: tta: cast output data pointer to the correct type fixes "warning: assignment from incompatible pointer type" --- libavcodec/tta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/tta.c b/libavcodec/tta.c index bc83bfdf1d..4656ce12e6 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -314,7 +314,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++) { -- cgit v1.2.3