[FFmpeg-cvslog] r24632 - trunk/libavcodec/flacenc.c

jbr subversion
Sat Jul 31 23:08:54 CEST 2010


Author: jbr
Date: Sat Jul 31 23:08:53 2010
New Revision: 24632

Log:
Simplify verbatim mode fallback by checking the frame size before writing.

Modified:
   trunk/libavcodec/flacenc.c

Modified: trunk/libavcodec/flacenc.c
==============================================================================
--- trunk/libavcodec/flacenc.c	Sat Jul 31 22:52:33 2010	(r24631)
+++ trunk/libavcodec/flacenc.c	Sat Jul 31 23:08:53 2010	(r24632)
@@ -1285,24 +1285,20 @@ static int flac_encode_frame(AVCodecCont
     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;



More information about the ffmpeg-cvslog mailing list