]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/flacenc.c
aacenc: cosmetics: Swap spreading_hi/low name to match the 3GPP spec.
[ffmpeg] / libavcodec / flacenc.c
index 9cd65e9ac0373df268df8761afd77ded8b67f87c..824e63994595c7ad59e9ac585eb0d924754ba28d 100644 (file)
@@ -288,7 +288,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
     s->options.max_partition_order = ((int[]){  2,  2,  3,  3,  3,  8,  8,  8,  8,  8,  8,  8,  8})[level];
 
     /* set compression option overrides from AVCodecContext */
-#if LIBAVCODEC_VERSION_MAJOR < 53
+#if FF_API_USE_LPC
     /* for compatibility with deprecated AVCodecContext.use_lpc */
     if (avctx->use_lpc == 0) {
         s->options.lpc_type = AV_LPC_TYPE_FIXED;
@@ -1125,7 +1125,7 @@ static void write_utf8(PutBitContext *pb, uint32_t val)
 }
 
 
-static void output_frame_header(FlacEncodeContext *s)
+static void write_frame_header(FlacEncodeContext *s)
 {
     FlacFrame *frame;
     int crc;
@@ -1162,7 +1162,7 @@ static void output_frame_header(FlacEncodeContext *s)
 }
 
 
-static void output_subframes(FlacEncodeContext *s)
+static void write_subframes(FlacEncodeContext *s)
 {
     int ch;
 
@@ -1220,7 +1220,7 @@ static void output_subframes(FlacEncodeContext *s)
 }
 
 
-static void output_frame_footer(FlacEncodeContext *s)
+static void write_frame_footer(FlacEncodeContext *s)
 {
     int crc;
     flush_put_bits(&s->pb);
@@ -1234,9 +1234,9 @@ static void output_frame_footer(FlacEncodeContext *s)
 static int write_frame(FlacEncodeContext *s, uint8_t *frame, int buf_size)
 {
     init_put_bits(&s->pb, frame, buf_size);
-    output_frame_header(s);
-    output_subframes(s);
-    output_frame_footer(s);
+    write_frame_header(s);
+    write_subframes(s);
+    write_frame_footer(s);
     return put_bits_count(&s->pb) >> 3;
 }
 
@@ -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;