summaryrefslogtreecommitdiff
path: root/libavcodec/flacenc.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2010-07-31 21:08:53 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2010-07-31 21:08:53 +0000
commit3d2cd42f8a19460d1fd44771646b4411c3148383 (patch)
tree0684285db46a21f74e3beedcb07ad93f1d3fc562 /libavcodec/flacenc.c
parent2249a7f3127969b6088e99f9ee224c37b1788bdc (diff)
Simplify verbatim mode fallback by checking the frame size before writing.
Originally committed as revision 24632 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flacenc.c')
-rw-r--r--libavcodec/flacenc.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 9cd65e9ac0..1486c88449 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -1285,24 +1285,20 @@ static int flac_encode_frame(AVCodecContext *avctx, uint8_t *frame,
channel_decorrelation(s);
frame_bytes = encode_frame(s);
- if (buf_size < frame_bytes) {
- av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
- return 0;
- }
- out_bytes = write_frame(s, frame, buf_size);
/* fallback to verbatim mode if the compressed frame is larger than it
would be if encoded uncompressed. */
- if (out_bytes > s->max_framesize) {
+ if (frame_bytes > s->max_framesize) {
s->frame.verbatim_only = 1;
frame_bytes = encode_frame(s);
- if (buf_size < frame_bytes) {
- av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
- return 0;
- }
- out_bytes = write_frame(s, frame, buf_size);
}
+ if (buf_size < frame_bytes) {
+ av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
+ return 0;
+ }
+ out_bytes = write_frame(s, frame, buf_size);
+
s->frame_count++;
avctx->coded_frame->pts = s->sample_count;
s->sample_count += avctx->frame_size;