[2/3] amr: Set the pkt->pos field properly to the start of the packet

Message ID 1300699787-55604-2-git-send-email-martin@martin.st
State Committed
Commit 026fa81de4cf4f1af742245fa9e750a38040f9fd
Headers show

Commit Message

Martin Storsjö March 21, 2011, 9:29 a.m.
Previously, the field pointed to the second byte of the packet
(which is the first byte of the actual AMR payload).
---
 libavformat/amr.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Benoit Fouet March 21, 2011, 9:44 a.m. | #1
On Mon, 21 Mar 2011 11:29:46 +0200 Martin Storsjö wrote:
> Previously, the field pointed to the second byte of the packet
> (which is the first byte of the actual AMR payload).
> ---
>  libavformat/amr.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/amr.c b/libavformat/amr.c
> index f2fecf3..76136e6 100644
> --- a/libavformat/amr.c
> +++ b/libavformat/amr.c
> @@ -121,6 +121,7 @@ static int amr_read_packet(AVFormatContext *s,
>  {
>      AVCodecContext *enc = s->streams[0]->codec;
>      int read, size = 0, toc, mode;
> +    int64_t pos = avio_tell(s->pb);
>  
>      if (s->pb->eof_reached)
>      {
> @@ -157,7 +158,7 @@ static int amr_read_packet(AVFormatContext *s,
>      s->streams[0]->codec->bit_rate = size*8*50;
>  
>      pkt->stream_index = 0;
> -    pkt->pos= avio_tell(s->pb);
> +    pkt->pos = pos;
>      pkt->data[0]=toc;
>      pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
>      read = avio_read(s->pb, pkt->data+1, size-1);

OK for me too.

Patch

diff --git a/libavformat/amr.c b/libavformat/amr.c
index f2fecf3..76136e6 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -121,6 +121,7 @@  static int amr_read_packet(AVFormatContext *s,
 {
     AVCodecContext *enc = s->streams[0]->codec;
     int read, size = 0, toc, mode;
+    int64_t pos = avio_tell(s->pb);
 
     if (s->pb->eof_reached)
     {
@@ -157,7 +158,7 @@  static int amr_read_packet(AVFormatContext *s,
     s->streams[0]->codec->bit_rate = size*8*50;
 
     pkt->stream_index = 0;
-    pkt->pos= avio_tell(s->pb);
+    pkt->pos = pos;
     pkt->data[0]=toc;
     pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
     read = avio_read(s->pb, pkt->data+1, size-1);