]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/aac_ac3_parser.c
avcodec/flacenc: Remove always-true check
[ffmpeg] / libavcodec / aac_ac3_parser.c
index 019074b0dd43a88f20dc6767640d2ac05f3ed16a..e84d30aea22ff74963892b997d1939746c8861db 100644 (file)
@@ -60,6 +60,9 @@ get_next:
                     s->remaining_size += i;
                     goto get_next;
                 }
+                else if (i < 0) {
+                    s->remaining_size += i;
+                }
             }
         }
     }
@@ -86,7 +89,7 @@ get_next:
            the frame). */
         if (avctx->codec_id != AV_CODEC_ID_AAC) {
             avctx->sample_rate = s->sample_rate;
-            if (avctx->codec_id != AV_CODEC_ID_EAC3) {
+            if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
                 avctx->channels = s->channels;
                 avctx->channel_layout = s->channel_layout;
             }
@@ -94,8 +97,12 @@ get_next:
             avctx->audio_service_type = s->service_type;
         }
 
-        if (avctx->codec_id != AV_CODEC_ID_EAC3)
-            avctx->bit_rate = s->bit_rate;
+        /* Calculate the average bit rate */
+        s->frame_number++;
+        if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
+            avctx->bit_rate +=
+                (s->bit_rate - avctx->bit_rate) / s->frame_number;
+        }
     }
 
     return i;