[1/3] amr: Set the codec->bit_rate field based on the last packet

Message ID 1300699787-55604-1-git-send-email-martin@martin.st
State Committed
Commit 2890cba8b50cc8c6656bc5f5cd0ebb5fd80fb5e4
Headers show

Commit Message

Martin Storsjö March 21, 2011, 9:29 a.m.
This allows libavformat to guess an estimated duration for
amr files.

For streams with varying bit rates (or with silence descriptors
or "no frame" blocks) the guess is, of course, inaccurate.
---
 libavformat/amr.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Comments

Benoit Fouet March 21, 2011, 9:39 a.m. | #1
On Mon, 21 Mar 2011 11:29:45 +0200 Martin Storsjö wrote:
> This allows libavformat to guess an estimated duration for
> amr files.
> 
> For streams with varying bit rates (or with silence descriptors
> or "no frame" blocks) the guess is, of course, inaccurate.
> ---
>  libavformat/amr.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/amr.c b/libavformat/amr.c
> index ba2ed4f..f2fecf3 100644
> --- a/libavformat/amr.c
> +++ b/libavformat/amr.c
> @@ -153,6 +153,9 @@ static int amr_read_packet(AVFormatContext *s,
>          return AVERROR(EIO);
>      }
>  
> +    /* Both AMR formats have 50 frames per second */
> +    s->streams[0]->codec->bit_rate = size*8*50;
> +
>      pkt->stream_index = 0;
>      pkt->pos= avio_tell(s->pb);
>      pkt->data[0]=toc;

Fine by me.

Patch

diff --git a/libavformat/amr.c b/libavformat/amr.c
index ba2ed4f..f2fecf3 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -153,6 +153,9 @@  static int amr_read_packet(AVFormatContext *s,
         return AVERROR(EIO);
     }
 
+    /* Both AMR formats have 50 frames per second */
+    s->streams[0]->codec->bit_rate = size*8*50;
+
     pkt->stream_index = 0;
     pkt->pos= avio_tell(s->pb);
     pkt->data[0]=toc;