diff mbox

[FFmpeg-devel,2/2] avformat/mp3enc: Avoid SEEK_END as it is unsupported

Message ID 20190514110452.31941-2-michael@niedermayer.cc
State Accepted
Commit bf3ee6a13053d37a0c5022a324624e89f0bce8c5
Headers show

Commit Message

Michael Niedermayer May 14, 2019, 11:04 a.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mp3enc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

James Almer May 14, 2019, 12:45 p.m. UTC | #1
On 5/14/2019 8:04 AM, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/mp3enc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
> index dd662f5473..f4814be80e 100644
> --- a/libavformat/mp3enc.c
> +++ b/libavformat/mp3enc.c
> @@ -391,6 +391,7 @@ static void mp3_update_xing(AVFormatContext *s)
>      uint16_t tag_crc;
>      uint8_t *toc;
>      int i, rg_size;
> +    int64_t old_pos = avio_tell(s->pb);
>  
>      /* replace "Xing" identification string with "Info" for CBR files. */
>      if (!mp3->has_variable_bitrate)
> @@ -450,7 +451,7 @@ static void mp3_update_xing(AVFormatContext *s)
>  
>      avio_seek(s->pb,  mp3->xing_frame_offset, SEEK_SET);
>      avio_write(s->pb, mp3->xing_frame, mp3->xing_frame_size);
> -    avio_seek(s->pb, 0, SEEK_END);
> +    avio_seek(s->pb, old_pos, SEEK_SET);

What do you mean unsupported?

>  }
>  
>  static int mp3_write_trailer(struct AVFormatContext *s)
>
Andreas Rheinhardt May 14, 2019, 12:58 p.m. UTC | #2
James Almer:
> On 5/14/2019 8:04 AM, Michael Niedermayer wrote:
>> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>> ---
>>  libavformat/mp3enc.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
>> index dd662f5473..f4814be80e 100644
>> --- a/libavformat/mp3enc.c
>> +++ b/libavformat/mp3enc.c
>> @@ -391,6 +391,7 @@ static void mp3_update_xing(AVFormatContext *s)
>>      uint16_t tag_crc;
>>      uint8_t *toc;
>>      int i, rg_size;
>> +    int64_t old_pos = avio_tell(s->pb);
>>  
>>      /* replace "Xing" identification string with "Info" for CBR files. */
>>      if (!mp3->has_variable_bitrate)
>> @@ -450,7 +451,7 @@ static void mp3_update_xing(AVFormatContext *s)
>>  
>>      avio_seek(s->pb,  mp3->xing_frame_offset, SEEK_SET);
>>      avio_write(s->pb, mp3->xing_frame, mp3->xing_frame_size);
>> -    avio_seek(s->pb, 0, SEEK_END);
>> +    avio_seek(s->pb, old_pos, SEEK_SET);
> 
> What do you mean unsupported?
> 
avio_seek only accepts SEEK_CUR and SEEK_SET (possibly OR'ed with
AVSEEK_FORCE) as whence parameter (everything else is AVERROR(EINVAL)).

- Andreas
Michael Niedermayer May 27, 2019, 4:02 p.m. UTC | #3
On Tue, May 14, 2019 at 01:04:52PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/mp3enc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

will apply

[...]
diff mbox

Patch

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index dd662f5473..f4814be80e 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -391,6 +391,7 @@  static void mp3_update_xing(AVFormatContext *s)
     uint16_t tag_crc;
     uint8_t *toc;
     int i, rg_size;
+    int64_t old_pos = avio_tell(s->pb);
 
     /* replace "Xing" identification string with "Info" for CBR files. */
     if (!mp3->has_variable_bitrate)
@@ -450,7 +451,7 @@  static void mp3_update_xing(AVFormatContext *s)
 
     avio_seek(s->pb,  mp3->xing_frame_offset, SEEK_SET);
     avio_write(s->pb, mp3->xing_frame, mp3->xing_frame_size);
-    avio_seek(s->pb, 0, SEEK_END);
+    avio_seek(s->pb, old_pos, SEEK_SET);
 }
 
 static int mp3_write_trailer(struct AVFormatContext *s)