diff mbox series

[FFmpeg-devel] avformat/riffenc: correct calculation for extradata size

Message ID 20200725051444.183-1-ffmpeg@gyani.pro
State Accepted
Commit 93694fe777d12a9432b5ceeb564631da6311ae26
Headers show
Series [FFmpeg-devel] avformat/riffenc: correct calculation for extradata size
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Gyan Doshi July 25, 2020, 5:14 a.m. UTC
In 1ec2b3de5a, the extradata size was affected when the raster was
signaled as flipped due to user-set option rather than via extradata.
This resulted in a wrong header size being written. Fixed.
---
 libavformat/riffenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Gyan Doshi July 25, 2020, 5:30 p.m. UTC | #1
Will push in 12 hours.

On 25-07-2020 10:44 am, Gyan Doshi wrote:
> In 1ec2b3de5a, the extradata size was affected when the raster was
> signaled as flipped due to user-set option rather than via extradata.
> This resulted in a wrong header size being written. Fixed.
> ---
>   libavformat/riffenc.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
> index d0ee98bfcc..04a21fcffa 100644
> --- a/libavformat/riffenc.c
> +++ b/libavformat/riffenc.c
> @@ -209,10 +209,10 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
>   void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
>                          int for_asf, int ignore_extradata, int rgb_frame_is_flipped)
>   {
> -    int keep_height = (par->extradata_size >= 9 &&
> -                      !memcmp(par->extradata + par->extradata_size - 9, "BottomUp", 9)) ||
> -                      rgb_frame_is_flipped;
> -    int extradata_size = par->extradata_size - 9*keep_height;
> +    int flipped_extradata = (par->extradata_size >= 9 &&
> +                            !memcmp(par->extradata + par->extradata_size - 9, "BottomUp", 9));
> +    int keep_height = flipped_extradata || rgb_frame_is_flipped;
> +    int extradata_size = par->extradata_size - 9*flipped_extradata;
>       enum AVPixelFormat pix_fmt = par->format;
>       int pal_avi;
>
Gyan Doshi July 26, 2020, 5:41 a.m. UTC | #2
On 25-07-2020 11:00 pm, Gyan Doshi wrote:
> Will push in 12 hours.

Pushed as 93694fe777d12a9432b5ceeb564631da6311ae26
Gyan

>
> On 25-07-2020 10:44 am, Gyan Doshi wrote:
>> In 1ec2b3de5a, the extradata size was affected when the raster was
>> signaled as flipped due to user-set option rather than via extradata.
>> This resulted in a wrong header size being written. Fixed.
>> ---
>>   libavformat/riffenc.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
>> index d0ee98bfcc..04a21fcffa 100644
>> --- a/libavformat/riffenc.c
>> +++ b/libavformat/riffenc.c
>> @@ -209,10 +209,10 @@ int ff_put_wav_header(AVFormatContext *s, 
>> AVIOContext *pb,
>>   void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
>>                          int for_asf, int ignore_extradata, int 
>> rgb_frame_is_flipped)
>>   {
>> -    int keep_height = (par->extradata_size >= 9 &&
>> -                      !memcmp(par->extradata + par->extradata_size - 
>> 9, "BottomUp", 9)) ||
>> -                      rgb_frame_is_flipped;
>> -    int extradata_size = par->extradata_size - 9*keep_height;
>> +    int flipped_extradata = (par->extradata_size >= 9 &&
>> +                            !memcmp(par->extradata + 
>> par->extradata_size - 9, "BottomUp", 9));
>> +    int keep_height = flipped_extradata || rgb_frame_is_flipped;
>> +    int extradata_size = par->extradata_size - 9*flipped_extradata;
>>       enum AVPixelFormat pix_fmt = par->format;
>>       int pal_avi;
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index d0ee98bfcc..04a21fcffa 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -209,10 +209,10 @@  int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
 void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
                        int for_asf, int ignore_extradata, int rgb_frame_is_flipped)
 {
-    int keep_height = (par->extradata_size >= 9 &&
-                      !memcmp(par->extradata + par->extradata_size - 9, "BottomUp", 9)) ||
-                      rgb_frame_is_flipped;
-    int extradata_size = par->extradata_size - 9*keep_height;
+    int flipped_extradata = (par->extradata_size >= 9 &&
+                            !memcmp(par->extradata + par->extradata_size - 9, "BottomUp", 9));
+    int keep_height = flipped_extradata || rgb_frame_is_flipped;
+    int extradata_size = par->extradata_size - 9*flipped_extradata;
     enum AVPixelFormat pix_fmt = par->format;
     int pal_avi;