avformat/riffenc: indicate storage of flipped RGB bitmaps

Some legacy applications such as AVI2MVE expect raw RGB bitmaps
to be stored bottom-up, whereas our RIFF BITMAPINFOHEADER assumes
they are always stored top-down and thus write a negative value
for height. This can prevent reading of these files.

Option flipped_raw_rgb added to AVI and Matroska muxers
which will write positive value for height when enabled.

Note that the user has to flip the bitmaps beforehand using other
means such as the vflip filter.
This commit is contained in:
Gyan Doshi 2020-07-08 17:32:25 +05:30
parent a54b367c78
commit 1ec2b3de5a
7 changed files with 27 additions and 8 deletions

View file

@ -207,10 +207,11 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
/* BITMAPINFOHEADER header */
void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
int for_asf, int ignore_extradata)
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);
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;
enum AVPixelFormat pix_fmt = par->format;
int pal_avi;