]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/aac_ac3_parser.c
avcodec/cfhd: check if band encoding is valid
[ffmpeg] / libavcodec / aac_ac3_parser.c
index 54e459844f141c8c176ac64a2be4b360a4c4f56b..0746798dabd86e99b13f217c063631594b2e3863 100644 (file)
@@ -97,8 +97,13 @@ 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 (avctx->codec_id != AV_CODEC_ID_EAC3) {
+            avctx->bit_rate =
+                (s->last_bit_rate * (s->frame_number -1) + s->bit_rate)/s->frame_number;
+            s->last_bit_rate = avctx->bit_rate;
+        }
     }
 
     return i;