* 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>
... | ... |
@@ -925,6 +925,19 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) |
925 | 925 |
AVCodecContext *avctx = ost->st->codec; |
926 | 926 |
int ret; |
927 | 927 |
|
928 |
+ /* |
|
929 |
+ * Audio encoders may split the packets -- #frames in != #packets out. |
|
930 |
+ * But there is no reordering, so we can limit the number of output packets |
|
931 |
+ * by simply dropping them here. |
|
932 |
+ * Counting encoded video frames needs to be done separately because of |
|
933 |
+ * reordering, see do_video_out() |
|
934 |
+ */ |
|
935 |
+ if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) { |
|
936 |
+ if (ost->frame_number >= ost->max_frames) |
|
937 |
+ return; |
|
938 |
+ ost->frame_number++; |
|
939 |
+ } |
|
940 |
+ |
|
928 | 941 |
while (bsfc) { |
929 | 942 |
AVPacket new_pkt = *pkt; |
930 | 943 |
int a = av_bitstream_filter_filter(bsfc, avctx, NULL, |
... | ... |
@@ -952,7 +965,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) |
952 | 952 |
print_error("av_interleaved_write_frame()", ret); |
953 | 953 |
exit_program(1); |
954 | 954 |
} |
955 |
- ost->frame_number++; |
|
956 | 955 |
} |
957 | 956 |
|
958 | 957 |
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, |
1513 | 1513 |
} |
1514 | 1514 |
} |
1515 | 1515 |
ost->sync_opts++; |
1516 |
+ /* |
|
1517 |
+ * For video, number of frames in == number of packets out. |
|
1518 |
+ * But there may be reordering, so we can't throw away frames on encoder |
|
1519 |
+ * flush, we need to limit them here, before they go into encoder. |
|
1520 |
+ */ |
|
1521 |
+ ost->frame_number++; |
|
1516 | 1522 |
} |
1517 | 1523 |
} |
1518 | 1524 |
|
... | ... |
@@ -987,6 +987,19 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) |
987 | 987 |
AVCodecContext *avctx = ost->st->codec; |
988 | 988 |
int ret; |
989 | 989 |
|
990 |
+ /* |
|
991 |
+ * Audio encoders may split the packets -- #frames in != #packets out. |
|
992 |
+ * But there is no reordering, so we can limit the number of output packets |
|
993 |
+ * by simply dropping them here. |
|
994 |
+ * Counting encoded video frames needs to be done separately because of |
|
995 |
+ * reordering, see do_video_out() |
|
996 |
+ */ |
|
997 |
+ if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) { |
|
998 |
+ if (ost->frame_number >= ost->max_frames) |
|
999 |
+ return; |
|
1000 |
+ ost->frame_number++; |
|
1001 |
+ } |
|
1002 |
+ |
|
990 | 1003 |
while (bsfc) { |
991 | 1004 |
AVPacket new_pkt = *pkt; |
992 | 1005 |
int a = av_bitstream_filter_filter(bsfc, avctx, NULL, |
... | ... |
@@ -1014,7 +1027,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) |
1014 | 1014 |
print_error("av_interleaved_write_frame()", ret); |
1015 | 1015 |
exit_program(1); |
1016 | 1016 |
} |
1017 |
- ost->frame_number++; |
|
1018 | 1017 |
} |
1019 | 1018 |
|
1020 | 1019 |
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, |
1568 | 1568 |
} |
1569 | 1569 |
} |
1570 | 1570 |
ost->sync_opts++; |
1571 |
+ /* |
|
1572 |
+ * For video, number of frames in == number of packets out. |
|
1573 |
+ * But there may be reordering, so we can't throw away frames on encoder |
|
1574 |
+ * flush, we need to limit them here, before they go into encoder. |
|
1575 |
+ */ |
|
1576 |
+ ost->frame_number++; |
|
1571 | 1577 |
} |
1572 | 1578 |
} |
1573 | 1579 |
|
... | ... |
@@ -326,7 +326,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, |
326 | 326 |
|
327 | 327 |
// decode directly to output buffer for 24-bit sample format |
328 | 328 |
if (s->bps == 3) |
329 |
- s->decode_buffer = s->frame.data[0]; |
|
329 |
+ s->decode_buffer = (int32_t *)s->frame.data[0]; |
|
330 | 330 |
|
331 | 331 |
// init per channel states |
332 | 332 |
for (i = 0; i < s->channels; i++) { |