Commit Graph

41 Commits

Author SHA1 Message Date
Gyan Doshi
93694fe777 avformat/riffenc: correct calculation for extradata size
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.
2020-07-26 11:09:39 +05:30
Gyan Doshi
1ec2b3de5a 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.
2020-07-15 20:52:01 +05:30
Aleksandr Slobodeniuk
0aa8fa963f avformat/riff.h : remove unused function parameter "const AVCodecTag *tags" of "void ff_put_bmp_header()"
Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-02 15:26:25 +02:00
Carl Eugen Hoyos
fe8959bbec lavf/riffenc: Always write unexpected channel_mask.
Allows to write arbitrary channel masks also for 16bit 48kHz pcm.
2016-10-12 12:34:48 +02:00
Florian Diemer
db4c1bee96 avformat/riffenc: added possibility to set first to ninth audio language for RIFF taged files (e.g. avi files)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-10-05 23:38:21 +02:00
Derek Buitenhuis
6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +01:00
Mats Peterson
ed5d295a69 lavf/riffenc: Improve spec compliance; Fix WMP playback of AVI with xxpc chunks
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-13 13:12:13 +01:00
Mats Peterson
698fdc8547 lavf/riffenc: Handle palette for non-raw codecs
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-05 18:05:47 +01:00
Mats Peterson
3ba57bfe8d lavf/riffenc: Handle AV_PIX_FMT_MONOBLACK
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-23 17:58:52 +01:00
Anton Khirnov
9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Michael Niedermayer
0910488a16 avformat/riffenc: Also check codec tag before setting raw_pal_avi
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 13:08:21 +01:00
Mats Peterson
a51d82b85c lavf/avienc: Add palette after BITMAPINFOHEADER
lavf/riffenc: Write space for palette
tests/ref/vsynth: Update 1 bpp files for pal8

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 03:30:50 +01:00
Michael Niedermayer
0b1e94c50a Revert "Merge commit '9f1eccb97bf8894cb18b14f642500686505ef186'"
This unbreaks muxing-encoding
Example:
ffmpeg -i matrixbench_mpeg2.mpg new.avi

-rw-r----- 1 michael michael 226035354 Jan  1 16:27 new.avi
-rw-r----- 1 michael michael  10016802 Jan  1 16:28 ref.avi

Also av_get_audio_frame_duration() itself uses frame_size

This reverts commit 29e6606e9b, reversing
changes made to 53448461a7.
2016-01-01 17:05:46 +01:00
Hendrik Leppkes
29e6606e9b Merge commit '9f1eccb97bf8894cb18b14f642500686505ef186'
* commit '9f1eccb97bf8894cb18b14f642500686505ef186':
  ff_parse_specific_params: do not use AVCodecContext.frame_size

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-01-01 15:52:18 +01:00
Anton Khirnov
9f1eccb97b ff_parse_specific_params: do not use AVCodecContext.frame_size
It will not be set unless the muxing codec context is also the encoding
context, which is discouraged. When the frame size is not known from
av_get_audio_frame_duration(), the fallback should still be good enough.
2015-12-12 21:19:50 +01:00
Tobias Rapp
1416370027 avformat/avienc: add muxer option "write_channel_mask"
Allow writing an empty channel mask into the wave format header. Useful
if the input file contains an unknown channel layout.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-12 14:39:28 +02:00
Juanjo
a213e57cef lavf/riffenc: Set correct block align for mp2.
Rounding by Michael.

Fixes ticket #4565.
2015-06-04 17:03:34 +02:00
Michael Niedermayer
c3671e1d57 avformat/riffenc: Use size_t for strlen in ff_riff_write_info_tag()
Also dont generated corrupted output for larger than 4gb strings

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-12 14:15:31 +02:00
Michael Niedermayer
0a23129bfc avformat: Add prefix to get_codec_guid()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-27 19:25:27 +01:00
Michael Niedermayer
8afaa03c53 avformat/riffenc: move MP3 LSF threshold to the midway point between the 2
No testcase available but this seems more correct

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-06 14:53:21 +01:00
Michael Niedermayer
a51eb6d34c Merge commit '56dc46a1893251e74be1ad63e54fb38d754bb1fe'
* commit '56dc46a1893251e74be1ad63e54fb38d754bb1fe':
  riffenc: do not fall back on AVCodecContext.frame_size for MP3

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-06 13:19:26 +01:00
Anton Khirnov
56dc46a189 riffenc: do not fall back on AVCodecContext.frame_size for MP3
It will not be set unless the codec context is used as the encoding
context, which is discouraged. For MP2, av_get_audio_frame_duration()
will already set the frame size properly. For MP3, set the frame size
explicitly.
2014-11-06 09:02:08 +01:00
Benoit Fouet
6843b9dc78 avformat/riffenc: Filter out "BottomUp" in ff_put_bmp_header()
Fixes Ticket1304

Commit message and extradata size bugfix by commiter
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-23 18:24:40 +02:00
Michael Niedermayer
ac293b6685 Merge commit '194be1f43ea391eb986732707435176e579265aa'
* commit '194be1f43ea391eb986732707435176e579265aa':
  lavf: switch to AVStream.time_base as the hint for the muxer timebase

Conflicts:
	doc/APIchanges
	libavformat/filmstripenc.c
	libavformat/movenc.c
	libavformat/mxfenc.c
	libavformat/oggenc.c
	libavformat/swf.h
	libavformat/version.h
	tests/ref/lavf/mkv

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-18 19:49:17 +02:00
Michael Niedermayer
2d70282254 Merge commit 'd754ed41727b1fcbab335b510248a9758a73320c'
* commit 'd754ed41727b1fcbab335b510248a9758a73320c':
  riffenc: take an AVStream instead of an AVCodecContext

Conflicts:
	libavformat/nutenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-18 17:47:12 +02:00
Anton Khirnov
194be1f43e lavf: switch to AVStream.time_base as the hint for the muxer timebase
Previously, AVStream.codec.time_base was used for that purpose, which
was quite confusing for the callers. This change also opens the path for
removing AVStream.codec.

The change in the lavf-mkv test is due to the native timebase (1/1000)
being used instead of the default one (1/90000), so the packets are now
sent to the crc muxer in the same order in which they are demuxed
(previously some of them got reordered because of inexact timestamp
conversion).
2014-06-18 15:12:34 +02:00
Anton Khirnov
d754ed4172 riffenc: take an AVStream instead of an AVCodecContext
It will be useful in the following commits.

Also, rename the AVCodecContext pointer name from 'stream' to 'codec'.
2014-06-18 15:03:55 +02:00
Michael Niedermayer
43c18fec6e Merge commit '584f88409062f7a134e7391887899e8e723ab6ff'
* commit '584f88409062f7a134e7391887899e8e723ab6ff':
  riff: Pass block_align to estimate frame duration

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-17 20:22:56 +02:00
nu774
584f884090 riff: Pass block_align to estimate frame duration
Fix incorrect wSamplesPerBlock(=0) written for ADPCM_IMA_WAV

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2014-05-17 15:24:20 +02:00
Carl Eugen Hoyos
c2b0ce70ad Initialize riff and wav size fields to -1 instead of 0.
WMP doess not play the output files if the fields are
set to 0 and not overwritten (using pipe output).

Fixes ticket #3346.
2014-05-03 22:21:00 +02:00
Daniel Verkamp
5e7d21c7ad ff_put_wav_header: add flag to force WAVEFORMATEX
Partially undoes commit 2c4e08d893:

    riff: always generate a proper WAVEFORMATEX structure in
    ff_put_wav_header

A new flag, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX, is added to force the
use of WAVEFORMATEX rather than PCMWAVEFORMAT even for PCM codecs.

This flag is used in the Matroska muxer (the cause of the original
change) and in the ASF muxer, because the specifications for
these formats indicate explicitly that WAVEFORMATEX should be used.

Muxers for other formats will return to the original behavior of writing
PCMWAVEFORMAT when writing a header for raw PCM.

In particular, this causes raw PCM in WAV to generate the canonical
44-byte header expected by some tools.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-30 16:41:35 +02:00
Carl Eugen Hoyos
bf87d582b1 Do not allow writing invalid wav channel layouts by default.
Neither WMP nor QT play wav files with too large channel layouts.
Fixes ticket #3543.
2014-04-09 23:21:38 +02:00
Clément Bœsch
235bf1dab5 riff: add ISMP/timecode tag 2014-04-04 00:28:28 +02:00
James Almer
fa570a5548 riff: Add ITRK tag
Some players, like foobar2000 or modern versions of WMP, create WAV
files using the ITRK tag for track instead of IPRT
2014-04-04 00:28:28 +02:00
Daniel Verkamp
cf3fccce06 ff_put_wav_header: remove manual byte counting
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-18 15:54:37 +01:00
Carl Eugen Hoyos
bf9a8d183d Support writing E-AC3 in wav. 2014-01-29 00:48:50 +01:00
Carl Eugen Hoyos
862174ec83 Move GUID-related objects to riffenc.c and riff.c.
This simplifies the following eac3-in-wav patch.
2014-01-29 00:44:59 +01:00
Peter Ross
f93b0abe40 avformat/riffenc: indent
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-23 15:55:47 +01:00
Peter Ross
fcbb94712d riffenc: add option to ff_put_bmp_header to ignore extradata
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-23 15:42:35 +01:00
Michael Niedermayer
508a5349da Merge commit '3dd5c95deef51d7fbf6f4458ba42d1335d2f1472'
* commit '3dd5c95deef51d7fbf6f4458ba42d1335d2f1472':
  riff: Move muxing code to a separate file

Conflicts:
	configure
	libavformat/riff.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-06 18:08:30 +02:00
Diego Biurrun
3dd5c95dee riff: Move muxing code to a separate file 2013-08-06 11:02:35 +02:00