History log of /haiku/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
Revision Date Author Comments
# 11ec18db 05-Apr-2024 Máximo Castañeda <antiswen@yahoo.es>

ffmpeg: return AVERROR_EOF instead of 0 on stream end

Fixes: #18877
Change-Id: I1ce8b14089570fa42526819b8cb961a45998020b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7601
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 45bd581b 14-Mar-2024 Augustin Cavalier <waddlesplash@gmail.com>

media/ffmpeg: Pass most packet metadata to decoder.

While AVPacket itself contains other fields, the
important ones are all static, and fit in 64 bytes.
So we can put them into the chunk media header directly
and then grab them again in AVCodecDecoder.

With that passed through, we can then use the
best_effort_timestamp, as it's more likely to be
correct.

Change-Id: Ied82137694f1307d4dcb177f3f9a7cb6b798461a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7525
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 6c05cfc0 14-Mar-2024 Augustin Cavalier <waddlesplash@gmail.com>

media/ffmpeg: Add cast to appease GCC2.


# 3a3b5438 14-Mar-2024 Augustin Cavalier <waddlesplash@gmail.com>

media/ffmpeg: Fix frameCount calculation when the stream duration is unset.

Fixes #18844.


# 35718d84 03-Mar-2024 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: Fix build with tracing enabled

Change-Id: I72cf1ce895baf3380568fbb0f0e8a92e79c5a53b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7500
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: nephele nephele <nep-git@packageloss.eu>


# 1af693a2 21-Feb-2024 Augustin Cavalier <waddlesplash@gmail.com>

ffmpeg: Increase accuracy of frame count computation.

BePac Deluxe checks the reported frame count against the actually
read frames count, and if the two do not match, it considers
this an error and bails out. So, we need to be as accurate as
possible here.

Additionally, fix Duration() for when start_time is nonzero,
and stay in integers where possible.

Fixes BePac Deluxe (again.)

Change-Id: Ic063fc15215dbfe3437d2430358227d7e2fe17fc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7422
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 1774dd5e 29-Dec-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: channels and channel_layout are deprecated

Use ch_layout instead

Change-Id: I6a07870eae42836d3fd993c253613bc0f33b1598
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7252
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 6dd44271 29-Dec-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: use accessors for AVStream indexes

The fields are not publicly exposed directly anymore

Change-Id: I39348116378c11fd3a1c4f08756b5a31f54b8781
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7255
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>


# 4629bc0c 29-Dec-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: stream cur_dts is not publicly available anymore

Change-Id: I613f110978c5859cf4db05824c0345fbd8a992bc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7276
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 90e87426 22-Dec-2022 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: enable Werror and fix all warnings

Warnings fixed include usage of various deprecated functions, structures
and fields of ffmpeg.

Change-Id: I8d6338ad282f214a805b8d746ce22e2f0895fb25
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5954
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# a4436289 21-Dec-2022 PulkoMandy <pulkomandy@pulkomandy.tk>

media plugins: replace strcpy with strlcpy

Fixes a memory corruption: the ffmpeg plugin has a LOT of file
extensions, which goes way past the 8 allowed characters and even past
the 88 reserved bytes at the end of the structure. As a result, memory
after the structure is overwritten, resulting in heap corruption and
crashes.

This is immediately detected by using the guarded heap.

As a short term measure, use strlcpy to avoid overwriting memory, but
now the ffmpeg plugin will be unable to provide any useful info. It
would make sense to make media_format_info store a pointer to a string
instead (similar to entry_ref), but this requires more changes and will
create some incompatibility with existing apps if they use the field.

Change-Id: I8d2b567a179e9f7816b72f48aedac4e8534bc044


# 1c889d23 03-May-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg/MediaPlayer: fix seeking in audio with cover art

MediaPlayer is basing its time on both the audio and video frames. This
doesn't go so well when there is a single video frame, resulting in the
whole file being one single "timepoint".

Avoid this problem by having the video decoder set the frame time to
"infinite" when the video stream is finished, which allows for the audio
timings to be used in this case.

Also improve the framerate handling of ffmpeg further, to avoid
MediaPlayer trying to frameskip at 90000fps (it would give up
frameskipping after a few frames and eventually notice that the next
frame was the end of stream, but still, not very clean). Now we report
an FPS of 0 instead, which should make it clear to applications what to
expect from single-frame files.

It seems the cover art is now hidden by a black screen, I'm not sure
why. But I'll leave debugging this for another day.

Fixes #13622.

Change-Id: Ie1dd1358cbb41c11649103dfce52a0e1317b26f8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2562
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 92290d9b 02-May-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: return B_LAST_BUFFER_ERROR when decoding completes.

Fixes #13622.
Fixes #14773.
Fixes #15220.

Change-Id: I2c20b421d25b450714209f4f4f4205d61145e615
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2551
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# ca93f8fb 20-Dec-2019 Michael Lotz <mmlr@mlotz.ch>

Fix leaking the IO context buffer when opening input fails.

The context buffer needs to be freed manually. This was already done
correctly in the destructor, but was missing from the error case.
This lead to a leak of at least 32K for the initial allocation or
potentially a lot more, depending on how much avformat_open_input
extended it for probing.

Change-Id: Ib4c751c7de9430926ae82b397803ac93ecfffe5d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2038
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 9b3aa126 12-Jul-2019 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg AVFormatReader: some cleanups.

- Stop using deprecated APIs
- Use BMediaFormat::Clear
- Remove hack for Protracker MOD as we have since got a MIME sniffing rule
- Clarify some comments and fix typos

Change-Id: Id495188cc44dc5af2820fe2a5236a983605b53c4
Reviewed-on: https://review.haiku-os.org/c/1586
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 218a8c03 17-May-2019 Augustin Cavalier <waddlesplash@gmail.com>

Revert the Codec Kit.

All of Barrett's individual reverts have been squashed into this
one commit, save a few actual bugfixes.

Change-Id: Ib0a7d0a841d3ac40b1fca7372c58b7f9229bd1f0


# e0a0f130 26-Dec-2018 Barrett17 <b.vitruvio@gmail.com>

ffmpeg: Use unsigned integers for chapter data


# c6a23a58 21-Nov-2018 Barrett17 <b.vitruvio@gmail.com>

ffmpeg: Use new BMetaData API


# ce402e82 04-Nov-2018 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: remove deprecated comment.

This field is deprecated.

Change-Id: I18c3b89ef7438c61b464aaf8bebc1484bf479d6b
Reviewed-on: https://review.haiku-os.org/664
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 5aff790a 24-Aug-2018 JackBurton79 <stefano.ceccherini@gmail.com>

ffmpeg media reader: remove useless avformat_free_context():
avformat_close_input() already calls it.

Change-Id: I45433527459bda430b8f0d15850fdcc019042db3


# 1d404e45 14-Aug-2018 JackBurton79 <stefano.ceccherini@gmail.com>

ffmpeg plugin: use avformat/codec_free_context() where applicable


# af8f2a39 12-Aug-2018 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: do not compute duration for "mutable size" streams.

Fixes #14326 without breaking other things.


# 3bd0b6ec 11-Aug-2018 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: do not compute a duration for streaming streams.

Streaming means the stream is endless, so don't compute a duration.

ffmpeg computes an estimation using what it thinks is the file size, but
is instead some internal buffer size from BAdapterIO.

Fixes second part of #14326.


# b5d0ce85 05-Aug-2018 Barrett17 <b.vitruvio@gmail.com>

AVCodecEncoder/AVFormatReader: Remove kNoPTSValue hack


# 6283eeb2 04-Aug-2018 Barrett17 <b.vitruvio@gmail.com>

AVFormatReader: Move codec to codecpar


# 334b8f3f 03-Aug-2018 Barrett17 <b.vitruvio@gmail.com>

ffmpeg: Remove obsolete code


# d5bff72e 02-Apr-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

Fix use after free.

As pointed by Marcus, FindString returns a pointer to the internal data
of the BMessage, so the message must stay in scope as long as we use the
pointer.

Thanks for reviewing!


# 737e508d 01-Apr-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: give a little hint about the file type.

ffmpeg, especially older versions, is not very good at detecting file
types and relies on us giving it a file extension for a better guess.

Use our MIME sniffing to have a first try at detecting the file we are
about to play, and pass this information to ffmpeg.

Fixes #13150.


# 5d569644 06-Jan-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

AVFormatReader: take the frame size into account

In ffmpeg, an audio frame may be made of multiple samples. We don't
really support that in our plug-in, and assume the frame rate and sample
rate are the same thing.

Adjust the reported frame count by multiplying ffmpeg's frame count by
its frame size (which is the number of samples per frame).

This fixes audio not working or stopping after a short time in
MediaPlayer, which uses the frame count this way.


# 0d7ac5eb 30-Dec-2016 Adrien Destugues <pulkomandy@pulkomandy.tk>

Accidentally left tracing enabled.


# 3a530660 30-Dec-2016 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: use stream frame count, if provided.

Not sure why that was commented out. Computing the frame count back from
the frame duration and stream duration can be inaccurate (especially for
long frame durations and/or short streams). It is important that the
stream ends exactly when expected. If it ends earlier than the announced
frame count, an app may be stuck forever waiting for the end, or would
interpret it as a read error. If it is too long, a buffer overflow may
occur.


# 8c767985 25-Mar-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

Move MediaIO in it's own header


# a6b34a8c 06-Mar-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

ffmpeg: Initial switch to BMediaIO


# f97f2394 19-Feb-2016 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: update build with version 3.0.

* untested.


# 0f7e19ce 30-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: add support for MOD and other "tracked music"

* ffmpeg can handle these through ModPlug
* By default, ffmpoeg will not try these formats because the way to
detect them are a bit unsafe (4 bytes at a particular offset in the file
serve as an identifier). So, hint the sniffing by giving it a filename
of ".mod" to get modplug to be used. This does not affect sniffing in
the regular way for other formats.
* Add some common tracked music formats to the muxer table.
* Fix some tracing to use current (as of ffmpeg 0.10) function names and
because some variables were renamed.


# 84e70401 24-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: update to 0.11.5.


# 377c5aec 22-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

Fix AIFF decoding with ffmpeg.

AIFF files are little endian. ffmpeg detects this just fine, but we
overwrote the endianness in the decoded format info with
B_MEDIA_HOST_ENDIAN right after setting it.

Now we can decode both AIFF and WAV files just fine.

Fixes #7047.


# ffb0f5db 23-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Automatic detection of audio decoding parameters.

- Kudos to Marcus Overhagen for laying out the general idea of automatic
detection by sharing some of his dvb code examples with me.
- Automatically detect the audio frame rate, channel count and sample format.
- Share audio sample format conversion code between AVFormatReader and
AVCodecDecoder.
- Tested with several video and audio files via MediaPlayer.
- Tested also with test case mp3_decoder_test -after- removing the hard coded
audio decoding parameters. Although the test shows that auto detection is
working (via stepping through the auto detection code path) the complete test
is still failing, due to missing implementation of incomplete audio frame
decoding.
- Add and update the documentation accordingly.


# 8516a39e 21-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Small cleanup

- The reason for compiler complaining about "INT64_C is not defined here" is
gone since the addition of the compiler flag "-D__STDC_CONSTANT_MACROS"
to the Jamfile some time ago. This flag allows C++ to use C99 math features.

- No functional change intended.


# 676721d2 10-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Fix video start_time generation.

- Ensure that start times are increased monotonically for video formats that
contain B-frames, too, as expected by the BMediaDecoders.
Previously start times were returned that seemed to go back in time for
videos containing B-frames.
Tested with resolutionchange.mpg (\see http://samples.ffmpeg.org/MPEG2)
Note: Even though start times aren't going back in time anymore there are
times where two consecutive start times are equal. This would need more
research once this exposes a bug in a real application. Further more this
might seem like a new bug, but before this commit the equal start times would
have simply some different start time[s] in between. So at most this is the
same bug just wearing new clothes :)

- Documentation updated accordingly.


# 4f4d9891 03-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Extract video aspect ratio calculation code.

- Also make use of the extracted code in the AVCodecDecoder class.
- Enhance some documentation and fix some coding style violations.
- No functional change intended.


# 626d341c 28-Mar-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg media plugin: merge muxer and demuxer tables

* The media_file_format struct has B_READABLE and B_WRITABLE flags,
allowing us to tell which formats we support decoding and encoding
* This allows application to query for the supported decoding formats.
* Also adjust some of the MIME types to match what's actually used (eg.
in HTML5 audio).

This makes html5test.com detect which formats we declare we can decode.


# 09963134 25-Nov-2013 Adrien Destugues <pulkomandy@pulkomandy.tk>

Style fix.

Sorry, working too much on WebKit code these days.


# 9394e66c 25-Nov-2013 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg plugin: don't crash sniffing unknown files.

The Open method can fail and leave the StreamBase object without an
IOContext, but the destructor tried to dereference it anyway.

This fixes APlayer crashing on many files instead of skipping them.


# 8a1f3038 06-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: release the reader context on destruction.

* avformat_open_input() is to be balanced with a avformat_close_input().
* should help with #9945.


# 51014b9e 14-Aug-2012 Matt Madia <mattmadia@gmail.com>

Revert "ffmpeg: switch to 0.11.1" (hrev44483)

This reverts commit 14b654326dc9c4b4ff38811672eb53e6723eece3.

Unfortunately that changeset causes a regression on GCC 2, which
makes playback of (some?) video impossible. This is due to Libavcodec
being miscompiled, which requires gcc >= 4.2

Resolves the regression of #8856, but does not fix the root issue.


# 14b65432 06-Aug-2012 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: switch to 0.11.1


# c4e5472a 25-Jun-2012 Philippe Saint-Pierre <stpere@gmail.com>

FFMPEG: Remove unnecessary #include statements

They were included because of earlier tests.
Thanks Korli for the heads-up! (and sorry for the noise..)


# 9741d697 25-Jun-2012 Philippe Saint-Pierre <stpere@gmail.com>

FFMPEG Copyright(): Fix memory leak

Fix a memory leak I introduced. Followed Stippi's suggestion. Thanks!


# 4dea247c 24-Jun-2012 Philippe Saint-Pierre <stpere@gmail.com>

ffmpeg: implement Copyright() (resolves TODO) + typo fix


# b95fa248 11-Apr-2012 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: don't use deprecated API in AVCodecDecoder.


# 663a6981 10-Apr-2012 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: switch to 0.10 API

* let ffmpeg handle probing buffer sizes.
* definitely helps with #8458. Noticed less drops for #8393.


# e40d995c 06-Mar-2012 Jérôme Duval <jerome.duval@gmail.com>

FFMpeg plugin: now build against the optional package for 0.10

* added optional feature package for ffmpeg 0.10 gcc4 and gcc2
* increased probe buffer size to 8K for now.
* built the optional packages the default way, it might need adjustments
like dependencies on speex, ogg, theora, vorbis, which I left out for now.


# ebe3c563 20-Nov-2010 Jérôme Duval <korli@users.berlios.de>

Fills frame variable even when not seeking to frame. This fixes bug #6828.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39540 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 801843ae 09-Nov-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Patch by Barrett:
Initialize the stream's IO buffer, otherwise it could crash in ~StreamBase().
It's only initialized when the media format was actually successfully probed.
Fix #6595. Thanks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39374 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1672b85c 31-Oct-2010 Clemens Zeidler <clemens.zeidler@googlemail.com>

Use some more meaningful names in the metadata message. Used the names from the id3v2.c ffmpeg file. Stippi does this really fix the TODO?



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39225 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41457111 29-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Try harder to seek somewhere and fall back to seeking
to the beginning of the stream by bytes, if all else
fails.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38853 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73dcf86f 24-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Don't create Stream cookies for unsupported media formats.
Some test clips with sub-title tracks would hang MediaPlayer
without this fix here.
* Optimize FindKeyFrame() and Seek(), check the range between
last requested/reported frame and bail out early with the
same result. Seems to fix MediaPlayer starting to drop frames
when it got caught up in a keyframe finding party...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38808 a95241bf-73f2-0310-859d-f6bbb57e9c96


# af0f809b 24-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Rewrote finding keyframes and seeking. The problem was that
in many situations, FindKeyframe() was unable to reliably
predict what frame Seek() would be able to seek to.
* Refactored a new base class StreamBase from the old
StreamCookie, renamed StreamCookie to just Stream.
* In FindKeyframe(), Stream will create a "ghost" StreamBase
instance. That one will be used to actually seek in the
stream without modifying the AVFormatContext of the real
Stream. From that we can tell what position we can /really/
seek to. For AVIs mostly, it is important to still use
av_index_search_timestamp(), since for many AVIs I tested,
reading the next packet after seeking did not produce a
timestamp, however the index entry contained just the correct
one. If the next packet does contain a PTS, it will still
override the index timestamp, though.
* Contrary to my previous belief, there was still a locking
problem with how MediaPlayer used the BMediaTracks. The video
decoding thread and the playback manager both used
FindKeyframe() without holding the same lock. We support this
now by using one BLocker per Stream. (The source BDataIO is
still protected by another single lock.) With the new ghost
stream stuff, the locking problem became much more of a problem,
previously the FindKeyframe() had a much rarer race condition
which would only trip when the decoding thread would cause new
index entries to be inserted into the index.
* Use the same ByteIOContext buffer size that avformat would be
using if it initialized the ByteIOContext through other API.
* Don't leak the probe buffer in case of error.
* Don't leak the ByteIOContext buffer in the end.
* Do not discard other stream packets anymore, this makes the
ASF demuxer happy and ASF files can now be seeked as well as
with ffplay itself.

With these changes, all my MPEG test streams work. Some could be seeked
before, but would show bad artifacts. Some streams would completely loose
video after seeking once. My MPEG2 test stream works much better now,
although audio is slightly out of sync, unfortunately. All my test AVIs
work as good as before, MP4 and MKV still work perfectly. The single
test ASF I got is now perfectly seekable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38807 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c1e73fbf 22-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Enabled any and all decoders and demuxers which are currently compiled into
FFmpeg. It's a bit sad, but this obsoletes pretty much all other decoder
and reader plugins. Some of them were built on external libraries as well
(AC3 (not part of default image anyway, since it's GPL), APE, MusePack),
so it's not really a big difference to using FFmpeg as external library.
The format matching is greatly simplified by using B_MISC_FORMAT_FAMILY
for everything but raw audio, and the actual FFmpeg CodecID as codec tag.
The downside of this is that the AVFormatReader can no longer be used with
other decoder plugins, but it would be easy to add special cases for native
decoders we wish to support. Obviously the out of the box support for file
formats and decoders has greatly increased with this change, so there has
to be a pretty good reason now for writing a "native" decoder or reader.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38786 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5051e989 20-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Committed more than I intended to in the last commit. Sorry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38748 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b145959b 20-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Use the same GCC flags for GCC4 that configure in the FFmpeg source
itself generates.
* For GCC2, FFmpeg uses -fPIC instead of -DPIC. Also disable SSE for
GCC2, since that fixes a crash in the SSE version of clear_block().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38747 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6df16a01 18-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Seeking by bytes works mostly correctly now. In some
mpgs, the video does not recover, though.
* Remember the last reported keyframe information, so we
avoid rounding artifacts. Not as effective, since we
cannot use stream time-base for seeking, but have to use
it for finding the keyframes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38706 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3c0f00c5 17-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Theoretically implemented seeking by bytes,
if the input format requires it. Practically,
it does not work.
* Implement the new meta-data API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38686 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a7cbd83 16-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Always ignore found index entries after we detect
the stream is building the index on the fly once.
This allows to seek back to earlier positions, since
then the index will contain entries for later in the
stream and the logic to detect auto-generated indices
was broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38678 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7b61b6b8 16-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Finally: Seeking audio in MKV files works when seeking the
muxer by the "default" stream. When I previously tried this,
I mistakenly remembered AV_TIME_BASE to be 1000, but it's
1000000, the same as the native bigtime_t time representation.
Luckily, we can still set all other streams (including the
"default" stream) to be discarded when obtaining chunks
packets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 51802669 16-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed a warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2baccbd9 15-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fix retrieving the frame rate for real. Apparently
it can be any of these values, hope the priority is right.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38659 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31879da8 15-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Use the correct field of the AVStream for the video
frame rate (perhaps it changed in 0.6?). This fixes
playback of several MP4 clips I have for testing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5021eb24 13-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Removed the "native" ogg, vorbis, theora and speex plugins in favor
of support for these codecs and demuxer in the FFmpeg plugin. The
ogg test streams I downloaded play fine now. For example, Big Buck Bunny
would play without video before and ogg files natively encoded with the
FFmpeg plugin wouldn't play at all. Since the removed plugins were not
maintained and were based on external libs themselves, I didn't see the
point in keeping them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6f766552 07-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed build with tracing enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38560 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1fc294b8 06-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Do not use an I/O buffer which is allocated with a StreamCookie
object. Demuxers may actually resize the I/O context buffer,
which would corrupt memory. This is certainly the case in FFmpeg
0.6, don't know if it was a problem before.
* Do not set the time to the packet PTS in Seek(), if it's the magic
value for "no PTS".
* Don't regard the AVInputFormat flags (generic index), we can detect
this more reliably by the observed behavior: Don't trust the found
keyframe if we are obvioulsy building the keyframe index on the fly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38545 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dc24f856 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Use rounding to avoid the situation, that FindKeyFrame()
returns a frame, and using that very same frame again
for FindKeyFrame() returns a different frame, because
the rounding effects have converted the time to be smaller
than the timestamp that was found for the first call to
FindKeyFrame(). It still happens sometimes, but a lot less
frequently. Ideas appreciated. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38504 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a2e8aee 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38500 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b4560be2 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Found two more places where _ConvertFromStreamTimeBase()
could be used.
* Finding keyframes is unreliable. Sometimes the index
is built on the fly, without us knowing. The file will
become seekable after we have decoded those parts.
This however means that seeking may not have been successful.
To know the seeked to frame, we extract the next packet
and returned the true current frame in the in/out arguments
to seek.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38497 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c1e1525 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Initialize the channel mask of the media_format.
* Enabled the DTS decoder. The codec tag is fake,
but as long as Readers use this, it will work.
Currently only works with the FFmpeg reader, though,
and I tested only with matroska containers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38493 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 22ce5d95 27-Aug-2010 Stephan Aßmus <superstippi@gmx.de>

* Optionally separate tracing output for FindKeyFrame().
* Output more information in AVFormatReader::StreamCookie::Open(),
AVInputFormat flags for example.
* Added CODEC_ID_AAC handling when codecTag is 0. Adds support
for AAC in Matroska containers when the ffmpeg plugin is enabled
to handle those.
* Added some rounding to frame<->time conversions.
* AVFormatReader::StreamCookie::Seek() forgot to pass the seek
flags to av_seek_frame().
* The most important fix is this, though: There are formats which
build the keyframe index on the fly, while parsing the stream!!
These means we can only seek to real keyframes for parts of the
stream that has already been decoded. Handle this situation by
assuming we can seek to the requested frame/time. This change
fixes the use of the AVFormatReader as MP3 reader.
* Anothe important fix is to ignore the nb_frames member of the
stream for the total frame count. This makes MP4 movies
also work perfectly now when the AVFormatReader is used for them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38401 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 303ecf89 24-Aug-2010 Stephan Aßmus <superstippi@gmx.de>

There was some bogus code in the Seek and FindKeyframe methods:
First B_MEDIA_SEEK_TO_FRAME was handled to compute a time, then
it was ignored and frame was used as time stamp. Also the
conversion from frame to time had the num and den members of
the time base swapped in the computation, so it computed
bogus time stamps. Refactored the conversion methods, always
seek based on the time. Needs more testing (perhaps there are rounding
issues), but overriding a lot of native reader implementations with
AVFormatReader holds up very well now with a lot of files I tested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38332 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41175567 23-Jul-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by Adek336: Improve debug output in AVFormatReader for the codec id
returned by libavformat. Style fix by myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37705 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b603b3f 17-May-2010 Stephan Aßmus <superstippi@gmx.de>

Implement a fall-back for calculating the media_header start time when the
packet did not specify a PTS. Made this change long ago, I don't believe it
helped much...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36846 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f947df7d 06-Jan-2010 Stephan Aßmus <superstippi@gmx.de>

Slightly more precise calculations in finding keyframes/seeking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e4459096 19-Oct-2009 Stephan Aßmus <superstippi@gmx.de>

Fixed a few problems with extracting the output audio buffer size and setting
it in the media_format (encoded versus raw).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf383414 29-Sep-2009 Stephan Aßmus <superstippi@gmx.de>

* Use the block-alignment from the codec context as the buffer size suggestion.
The audio decoding in AVDecoder needs this to work at all.
* Set the infoBuffer and infoSize correctly in GetStreamInfo(). At least this
is what I extract from what the AVDecoder expects.
* Use a slightly more precise timeStamp calculation in the Seek() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33358 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0bdc769 21-Aug-2009 Jérôme Duval <korli@users.berlios.de>

* synced with ffmpeg-r19678, keeping gcc2 compiler #ifdef we introduced, build only tested on Haiku gcc2
* activated ac3 audio file format support
* uses format metadata to keep the codec context extra data (now needed for flac)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32597 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 23190db7 07-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

Sorry, reverted r32185, as it was complete bogus and didn't even compile (got
confused about what I already compiled here). The sample format was already
specified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32186 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e4845287 07-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

* In the AVCodecDecoder, use the audio format of the original input format,
but specify it to 16bits/sample if it's still a wildcard. Make sure to
allocate the scrub buffer with the correct sample size (was hardcoded to 2
bytes per sample).
* In the AVFormatReader, specify the sample format for B_MEDIA_ENCODED_AUDIO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32185 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3ca4a7b1 03-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

Implemented audio track encoding. There is something wrong with the PTS
generation for the packets and how I set the time_base in the AVStream and
AVStream->codec structures. This results in the audio streams of the written
files to report a much too long duration.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32064 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 54897d5c 31-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Also pass the media_codec_info to the Writer::AllocateCookie(), since that
info is not part of the media_format otherwise.
* Finished enough in the AVFormatWriter and AVCodecEncoder that we can now
actually create AVIs and MPGs and encode MPEG1, MPEG2 and MPEG4 video.
But no audio as of yet. Also, there is no bit-rate/quality setup, so it seems
libavformat is using the least possible bit-rate/quality.
* Enable some more muxers and encoders in the FFmpeg libs.
* Uses pixel format conversion from libswsscale, need to read the documentation
again, but I think it makes the plugin GPL.
* Fixed includes in libswscale/swscale.h, this is now an unmodified FFmpeg 0.5
header again (AFAICT).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32043 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eeb4be0c 30-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Hack for interlaced video. We cannot know if video is interlaced from the
current libavformat API. FFmpeg is a little inconsistent in this regard. For
interlaced video, it will report a frame rate which is the field rate, but
still decode both fields into a single frame. For the time being, we reduce
the frame rate from 50.0 to 25.0 and handle interlaced video transparently
for the clients. This needs to be fixed later on...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31995 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c854f140 17-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Cleanup
* Added TODO note with regards to BDataIO streams.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31618 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f06ec9ec 17-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Fallback to detecting the stream duration from the AVFormatContext, if the
AVStream does not provide it. For my test Flash Videos, I can at least get
a duration now, although seeking is pretty broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31616 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c3407852 15-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Added support for Flash Video (VP6F video and MP3 audio tested only).
* Seeking does not work, since the duration extraction from libavformat does
not work for this container (maybe there are ways/workarounds but I didn't
look into it).
* Automatic white space cleanup.

TODO: Add MIME type with sniffer rule.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31605 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e94d298 15-Jul-2009 Jérôme Duval <korli@users.berlios.de>

added flac to the codec table and the demuxer table.
audio format is now taken into account by the decoder when negociating the media output format.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31597 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b739c6a8 14-Jul-2009 Jérôme Duval <korli@users.berlios.de>

recognizes the ac3 codec as part of the WAV format family (the one published by ac3_decoder).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ca0ccd1 10-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Fixed compilation with TRACE_IO defined.
* Improved Seek(). If wence is not SEEK_SET, make sure to check the current
source position and adjust it to what the stream points to. Also, return
just -1 on error since this is used for libavformat code. And don't set
the stream position to the error return value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31504 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c85e7735 09-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Forgot to remove invalid TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0f3f344f 09-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Implemented calculating the correct display aspect ratio.
* Removed some dead code.
* Fixed a style violation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31479 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c7ec9670 08-Jul-2009 Jérôme Duval <korli@users.berlios.de>

added raw dv format support. tested with PAL DV, I don't know for NTSC though


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31466 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dec28f85 08-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Better debug output.
* We can actually tell libavformat to discard packets for streams that
we are not interested in. Found this in the ffplay code. This should hopefully
avoid the efficiency impact of using one AVFormatContext per stream.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31458 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 274f43b9 08-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Virtualize the stream index and implement finding streams when the
context has AVPrograms. I gather this feature is for container streams
that contain multiple "groups of streams" like how it would work for
satilite mpeg-ts streams with multiple TV channels in one stream. For this
to be properly supported, we should extend the BMediaFile/Track API. For
now, the AVFormatReader uses the first program, if one is there. This
was also needed to get make mpegts demuxer work, but it is not yet enabled
for other reasons.
* Read more probe data. 1024 bytes were not enough to detect "mpegts" properly
for example.
* For now, I disabled the locking in the AVFormatReader hooks themselves,
this should not be necessary, though I hope libavformat is reentrant as
long as you have your own AVFormatContext for each thread. So far everything
hints that it is the case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31454 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d9b65c4 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Dump the libavformat string again in Sniff().
* Separate TRACE output for seeking related methods.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 922c7be6 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Do not leak the first StreamCookie that we used in Sniff() and do not free
in FreeCookie().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31425 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fcb875cd 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Do no re-use the same packet again if not supposed to. Was not a problem with
how everything currently worked. (Packet peaking was only done once in Init().)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31423 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7965dde0 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Get the AVFormatReader into a usable state. DemuxerTable.cpp controls which
container formats we support. I hope I have turned on only those that don't
have an implementation already (did we support ASF already?). I mostly tested
with AVI and that works reasonably well, but I only tested raw audio so far.
However, the backend for Marcus' avi_reader is much nicer than FFmpeg, so I
think it should stay and have disabled the support for AVI in AVFormatReader.
A big disappointment is that MPG containers only give scrambled video. It may
be a problem of the AVCodecDecoder, but I am not so sure. After all, it works
fine for other container formats. If I am not mistaken, VLC also does not use
the mpeg demuxer from FFmpeg. :-\ On top of that, libavformat detects the
time_base and stream duration wrongly for one of my test MPGs.
As for the implementation: Although seeking in libavformat happens for an
individual stream, in reality, the packets for all other streams need to be
flushed (that's also what happens in the libavformat tutorials I've seen).
Since our MediaKit API allows to seek tracks indivually, this is of course
a no-go, since then all other tracks would be out of sync. My solution is to
simply open the demuxer once for each stream and then completely ignore the
packets of the respective other streams. This also works around the problem
that libavformat is unable to provide packets by stream, requiring the
API user to queue the packets that he needs not now, but later for other
streams. It also means we have to no memory copies, since we can directly
use the packet buffer until the next call to GetNextChunk().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 827faf77 03-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Fleshed out some more of the format detection.
* Moved stuff from testing in Sniff() into class members.
* Added function to gfx_utils() that converts an FFmpeg pix_fmt to color_space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31402 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a244fc3a 02-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* It actually helps a lot to turn on all the demuxers if you want to use any.
* The URLProtocol idea seems not to work out, so I removed that code, but
the other idea of setting up a ByteIOContext actually works, once I seek
back to the beginning of the stream after reading the initial probe buffer,
we may also offset the buffer pointer in the ByteIOContext to where we
have already read, but I am not sure of possible side effects of that.

We can now probe for the correct demuxer and detect streams.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31379 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b4ef5741 02-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Work in Progress of trying to get libavformat to detect anything...
unsuccessful so far.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31369 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 668ed70b 01-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Use a static global object to initialize libavformat and libavcodec.
* Turn off tracing in the AVCodecDecoder which I accidentally turned on in
a previous commit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31366 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 27f6fb6c 01-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Renamed avcodec folder to ffmpeg.
* Cleaned up plugins Jamfile.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31359 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0f7e19ce7ec4dfe4d0a4e0b21eb22c4392637568 30-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: add support for MOD and other "tracked music"

* ffmpeg can handle these through ModPlug
* By default, ffmpoeg will not try these formats because the way to
detect them are a bit unsafe (4 bytes at a particular offset in the file
serve as an identifier). So, hint the sniffing by giving it a filename
of ".mod" to get modplug to be used. This does not affect sniffing in
the regular way for other formats.
* Add some common tracked music formats to the muxer table.
* Fix some tracing to use current (as of ffmpeg 0.10) function names and
because some variables were renamed.


# 84e70401cd02f134e87d758785d5a5f252b3b1ab 24-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: update to 0.11.5.


# 377c5aecf01baba11af910c37c753aa445be181b 22-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

Fix AIFF decoding with ffmpeg.

AIFF files are little endian. ffmpeg detects this just fine, but we
overwrote the endianness in the decoded format info with
B_MEDIA_HOST_ENDIAN right after setting it.

Now we can decode both AIFF and WAV files just fine.

Fixes #7047.


# ffb0f5db8e4976139e53bf333d4af7052b26167c 23-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Automatic detection of audio decoding parameters.

- Kudos to Marcus Overhagen for laying out the general idea of automatic
detection by sharing some of his dvb code examples with me.
- Automatically detect the audio frame rate, channel count and sample format.
- Share audio sample format conversion code between AVFormatReader and
AVCodecDecoder.
- Tested with several video and audio files via MediaPlayer.
- Tested also with test case mp3_decoder_test -after- removing the hard coded
audio decoding parameters. Although the test shows that auto detection is
working (via stepping through the auto detection code path) the complete test
is still failing, due to missing implementation of incomplete audio frame
decoding.
- Add and update the documentation accordingly.


# 8516a39e5da22f10f8a42c47f03c5313b2024be9 21-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Small cleanup

- The reason for compiler complaining about "INT64_C is not defined here" is
gone since the addition of the compiler flag "-D__STDC_CONSTANT_MACROS"
to the Jamfile some time ago. This flag allows C++ to use C99 math features.

- No functional change intended.


# 676721d2670c65224c895e196f121dceafc047d2 10-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Fix video start_time generation.

- Ensure that start times are increased monotonically for video formats that
contain B-frames, too, as expected by the BMediaDecoders.
Previously start times were returned that seemed to go back in time for
videos containing B-frames.
Tested with resolutionchange.mpg (\see http://samples.ffmpeg.org/MPEG2)
Note: Even though start times aren't going back in time anymore there are
times where two consecutive start times are equal. This would need more
research once this exposes a bug in a real application. Further more this
might seem like a new bug, but before this commit the equal start times would
have simply some different start time[s] in between. So at most this is the
same bug just wearing new clothes :)

- Documentation updated accordingly.


# 4f4d98911a40a7683106c644fec459c9dd115df2 03-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Extract video aspect ratio calculation code.

- Also make use of the extracted code in the AVCodecDecoder class.
- Enhance some documentation and fix some coding style violations.
- No functional change intended.


# 626d341c24c92e58a4143ec615e12d20b28e2091 28-Mar-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg media plugin: merge muxer and demuxer tables

* The media_file_format struct has B_READABLE and B_WRITABLE flags,
allowing us to tell which formats we support decoding and encoding
* This allows application to query for the supported decoding formats.
* Also adjust some of the MIME types to match what's actually used (eg.
in HTML5 audio).

This makes html5test.com detect which formats we declare we can decode.


# 09963134af548f3dda552f08d2a0f703cb2b4fb8 25-Nov-2013 Adrien Destugues <pulkomandy@pulkomandy.tk>

Style fix.

Sorry, working too much on WebKit code these days.


# 9394e66cbceb75f1f29c62224ced948d62ffda94 25-Nov-2013 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg plugin: don't crash sniffing unknown files.

The Open method can fail and leave the StreamBase object without an
IOContext, but the destructor tried to dereference it anyway.

This fixes APlayer crashing on many files instead of skipping them.


# 8a1f3038407f37a3e212c77e86630533dce8c705 06-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: release the reader context on destruction.

* avformat_open_input() is to be balanced with a avformat_close_input().
* should help with #9945.


# 51014b9eb6b27a1311bccc52eadc8265bfb15ae6 14-Aug-2012 Matt Madia <mattmadia@gmail.com>

Revert "ffmpeg: switch to 0.11.1" (hrev44483)

This reverts commit 14b654326dc9c4b4ff38811672eb53e6723eece3.

Unfortunately that changeset causes a regression on GCC 2, which
makes playback of (some?) video impossible. This is due to Libavcodec
being miscompiled, which requires gcc >= 4.2

Resolves the regression of #8856, but does not fix the root issue.


# 14b654326dc9c4b4ff38811672eb53e6723eece3 06-Aug-2012 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: switch to 0.11.1


# c4e5472a71bd1b62643effe55abf6ac674b3255b 25-Jun-2012 Philippe Saint-Pierre <stpere@gmail.com>

FFMPEG: Remove unnecessary #include statements

They were included because of earlier tests.
Thanks Korli for the heads-up! (and sorry for the noise..)


# 9741d697e80af3e3023d59243bb61f6029eb9c37 25-Jun-2012 Philippe Saint-Pierre <stpere@gmail.com>

FFMPEG Copyright(): Fix memory leak

Fix a memory leak I introduced. Followed Stippi's suggestion. Thanks!


# 4dea247ceeec0a4022010cf476acf4ee23e390cb 24-Jun-2012 Philippe Saint-Pierre <stpere@gmail.com>

ffmpeg: implement Copyright() (resolves TODO) + typo fix


# b95fa2488ad09133ca040fde61914b132680a079 11-Apr-2012 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: don't use deprecated API in AVCodecDecoder.


# 663a69816574ce4b356bc9fe68b626ee860aa546 10-Apr-2012 Jérôme Duval <jerome.duval@gmail.com>

ffmpeg: switch to 0.10 API

* let ffmpeg handle probing buffer sizes.
* definitely helps with #8458. Noticed less drops for #8393.


# e40d995cf452857204748974431023cf2e78cec2 06-Mar-2012 Jérôme Duval <jerome.duval@gmail.com>

FFMpeg plugin: now build against the optional package for 0.10

* added optional feature package for ffmpeg 0.10 gcc4 and gcc2
* increased probe buffer size to 8K for now.
* built the optional packages the default way, it might need adjustments
like dependencies on speex, ogg, theora, vorbis, which I left out for now.


# ebe3c563dab18f7d5310e6b19fa985fa2cc0bccb 20-Nov-2010 Jérôme Duval <korli@users.berlios.de>

Fills frame variable even when not seeking to frame. This fixes bug #6828.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39540 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 801843aed6020556a6b3c7fe2a4a7063b93e16ca 09-Nov-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Patch by Barrett:
Initialize the stream's IO buffer, otherwise it could crash in ~StreamBase().
It's only initialized when the media format was actually successfully probed.
Fix #6595. Thanks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39374 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1672b85c406e30714085a76f072dc080f1eb0782 31-Oct-2010 Clemens Zeidler <clemens.zeidler@googlemail.com>

Use some more meaningful names in the metadata message. Used the names from the id3v2.c ffmpeg file. Stippi does this really fix the TODO?



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39225 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41457111ecc1f436210d66d4b89c74fae9c152ab 29-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Try harder to seek somewhere and fall back to seeking
to the beginning of the stream by bytes, if all else
fails.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38853 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 73dcf86fdc524271eca87af715ab2b6f7a6d63c6 24-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Don't create Stream cookies for unsupported media formats.
Some test clips with sub-title tracks would hang MediaPlayer
without this fix here.
* Optimize FindKeyFrame() and Seek(), check the range between
last requested/reported frame and bail out early with the
same result. Seems to fix MediaPlayer starting to drop frames
when it got caught up in a keyframe finding party...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38808 a95241bf-73f2-0310-859d-f6bbb57e9c96


# af0f809b75bff62bf8d44a15021727085474e86c 24-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Rewrote finding keyframes and seeking. The problem was that
in many situations, FindKeyframe() was unable to reliably
predict what frame Seek() would be able to seek to.
* Refactored a new base class StreamBase from the old
StreamCookie, renamed StreamCookie to just Stream.
* In FindKeyframe(), Stream will create a "ghost" StreamBase
instance. That one will be used to actually seek in the
stream without modifying the AVFormatContext of the real
Stream. From that we can tell what position we can /really/
seek to. For AVIs mostly, it is important to still use
av_index_search_timestamp(), since for many AVIs I tested,
reading the next packet after seeking did not produce a
timestamp, however the index entry contained just the correct
one. If the next packet does contain a PTS, it will still
override the index timestamp, though.
* Contrary to my previous belief, there was still a locking
problem with how MediaPlayer used the BMediaTracks. The video
decoding thread and the playback manager both used
FindKeyframe() without holding the same lock. We support this
now by using one BLocker per Stream. (The source BDataIO is
still protected by another single lock.) With the new ghost
stream stuff, the locking problem became much more of a problem,
previously the FindKeyframe() had a much rarer race condition
which would only trip when the decoding thread would cause new
index entries to be inserted into the index.
* Use the same ByteIOContext buffer size that avformat would be
using if it initialized the ByteIOContext through other API.
* Don't leak the probe buffer in case of error.
* Don't leak the ByteIOContext buffer in the end.
* Do not discard other stream packets anymore, this makes the
ASF demuxer happy and ASF files can now be seeked as well as
with ffplay itself.

With these changes, all my MPEG test streams work. Some could be seeked
before, but would show bad artifacts. Some streams would completely loose
video after seeking once. My MPEG2 test stream works much better now,
although audio is slightly out of sync, unfortunately. All my test AVIs
work as good as before, MP4 and MKV still work perfectly. The single
test ASF I got is now perfectly seekable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38807 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c1e73fbf52c01d51df5e4e9e2ac0e4839bc2b0b3 22-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Enabled any and all decoders and demuxers which are currently compiled into
FFmpeg. It's a bit sad, but this obsoletes pretty much all other decoder
and reader plugins. Some of them were built on external libraries as well
(AC3 (not part of default image anyway, since it's GPL), APE, MusePack),
so it's not really a big difference to using FFmpeg as external library.
The format matching is greatly simplified by using B_MISC_FORMAT_FAMILY
for everything but raw audio, and the actual FFmpeg CodecID as codec tag.
The downside of this is that the AVFormatReader can no longer be used with
other decoder plugins, but it would be easy to add special cases for native
decoders we wish to support. Obviously the out of the box support for file
formats and decoders has greatly increased with this change, so there has
to be a pretty good reason now for writing a "native" decoder or reader.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38786 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5051e989f6be0936482bfbe0968ffb33c8a2b2fb 20-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Committed more than I intended to in the last commit. Sorry.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38748 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b145959bddcc9b9ab7cd8acb380531a6f98f3a69 20-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Use the same GCC flags for GCC4 that configure in the FFmpeg source
itself generates.
* For GCC2, FFmpeg uses -fPIC instead of -DPIC. Also disable SSE for
GCC2, since that fixes a crash in the SSE version of clear_block().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38747 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6df16a01edba3bb82c6b4fae10d9d4153715f801 18-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Seeking by bytes works mostly correctly now. In some
mpgs, the video does not recover, though.
* Remember the last reported keyframe information, so we
avoid rounding artifacts. Not as effective, since we
cannot use stream time-base for seeking, but have to use
it for finding the keyframes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38706 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3c0f00c5ec52b9dd9f275e3c19c5edb8d9cfbd77 17-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Theoretically implemented seeking by bytes,
if the input format requires it. Practically,
it does not work.
* Implement the new meta-data API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38686 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a7cbd83505405effcebba48a1539aa80ae065de 16-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Always ignore found index entries after we detect
the stream is building the index on the fly once.
This allows to seek back to earlier positions, since
then the index will contain entries for later in the
stream and the logic to detect auto-generated indices
was broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38678 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7b61b6b8e4223498b4825af3f672e42fd3a8da80 16-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Finally: Seeking audio in MKV files works when seeking the
muxer by the "default" stream. When I previously tried this,
I mistakenly remembered AV_TIME_BASE to be 1000, but it's
1000000, the same as the native bigtime_t time representation.
Luckily, we can still set all other streams (including the
"default" stream) to be discarded when obtaining chunks
packets.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38677 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 51802669a5137c4d4ed35b6ca07fcf36d00f6c5d 16-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed a warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38673 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2baccbd9fbf9ad06915a3dce358bafc3611be49f 15-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fix retrieving the frame rate for real. Apparently
it can be any of these values, hope the priority is right.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38659 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 31879da81c4c0a91770307ab045b43ffaeb0921e 15-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Use the correct field of the AVStream for the video
frame rate (perhaps it changed in 0.6?). This fixes
playback of several MP4 clips I have for testing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38658 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5021eb2421d20af3419b37cd9f647e01d40a223f 13-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Removed the "native" ogg, vorbis, theora and speex plugins in favor
of support for these codecs and demuxer in the FFmpeg plugin. The
ogg test streams I downloaded play fine now. For example, Big Buck Bunny
would play without video before and ogg files natively encoded with the
FFmpeg plugin wouldn't play at all. Since the removed plugins were not
maintained and were based on external libs themselves, I didn't see the
point in keeping them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6f76655240d2cb266c6d86b72c7488207f3bc5af 07-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed build with tracing enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38560 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1fc294b86a16ac7f96abee057244953a4020d65f 06-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Do not use an I/O buffer which is allocated with a StreamCookie
object. Demuxers may actually resize the I/O context buffer,
which would corrupt memory. This is certainly the case in FFmpeg
0.6, don't know if it was a problem before.
* Do not set the time to the packet PTS in Seek(), if it's the magic
value for "no PTS".
* Don't regard the AVInputFormat flags (generic index), we can detect
this more reliably by the observed behavior: Don't trust the found
keyframe if we are obvioulsy building the keyframe index on the fly.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38545 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dc24f856915208d5e2417cc822509d4c177b809f 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Use rounding to avoid the situation, that FindKeyFrame()
returns a frame, and using that very same frame again
for FindKeyFrame() returns a different frame, because
the rounding effects have converted the time to be smaller
than the timestamp that was found for the first call to
FindKeyFrame(). It still happens sometimes, but a lot less
frequently. Ideas appreciated. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38504 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a2e8aeeaf2c82635e34625ca159806c3948112e 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38500 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b4560be2997eeeb8f3eab7003121492db2e6a2b4 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Found two more places where _ConvertFromStreamTimeBase()
could be used.
* Finding keyframes is unreliable. Sometimes the index
is built on the fly, without us knowing. The file will
become seekable after we have decoded those parts.
This however means that seeking may not have been successful.
To know the seeked to frame, we extract the next packet
and returned the true current frame in the in/out arguments
to seek.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38497 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2c1e15255e2e8714dab0df0936864f1faa366dfe 01-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

* Initialize the channel mask of the media_format.
* Enabled the DTS decoder. The codec tag is fake,
but as long as Readers use this, it will work.
Currently only works with the FFmpeg reader, though,
and I tested only with matroska containers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38493 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 22ce5d9517784a8429de497035cabd3ffdd40710 27-Aug-2010 Stephan Aßmus <superstippi@gmx.de>

* Optionally separate tracing output for FindKeyFrame().
* Output more information in AVFormatReader::StreamCookie::Open(),
AVInputFormat flags for example.
* Added CODEC_ID_AAC handling when codecTag is 0. Adds support
for AAC in Matroska containers when the ffmpeg plugin is enabled
to handle those.
* Added some rounding to frame<->time conversions.
* AVFormatReader::StreamCookie::Seek() forgot to pass the seek
flags to av_seek_frame().
* The most important fix is this, though: There are formats which
build the keyframe index on the fly, while parsing the stream!!
These means we can only seek to real keyframes for parts of the
stream that has already been decoded. Handle this situation by
assuming we can seek to the requested frame/time. This change
fixes the use of the AVFormatReader as MP3 reader.
* Anothe important fix is to ignore the nb_frames member of the
stream for the total frame count. This makes MP4 movies
also work perfectly now when the AVFormatReader is used for them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38401 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 303ecf89ec6b9d4a1cef8cf4aa27c90f2fdb2f16 24-Aug-2010 Stephan Aßmus <superstippi@gmx.de>

There was some bogus code in the Seek and FindKeyframe methods:
First B_MEDIA_SEEK_TO_FRAME was handled to compute a time, then
it was ignored and frame was used as time stamp. Also the
conversion from frame to time had the num and den members of
the time base swapped in the computation, so it computed
bogus time stamps. Refactored the conversion methods, always
seek based on the time. Needs more testing (perhaps there are rounding
issues), but overriding a lot of native reader implementations with
AVFormatReader holds up very well now with a lot of files I tested.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38332 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4117556768f762e80c198381986e607b11c647d6 23-Jul-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by Adek336: Improve debug output in AVFormatReader for the codec id
returned by libavformat. Style fix by myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37705 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b603b3f393962f0cf607ff32236cdc4cae7cc72 17-May-2010 Stephan Aßmus <superstippi@gmx.de>

Implement a fall-back for calculating the media_header start time when the
packet did not specify a PTS. Made this change long ago, I don't believe it
helped much...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36846 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f947df7deda47f65d8e1dcbb2830e072e4dda9ab 06-Jan-2010 Stephan Aßmus <superstippi@gmx.de>

Slightly more precise calculations in finding keyframes/seeking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34928 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e44590963150208d61a2341aa598274670663cdf 19-Oct-2009 Stephan Aßmus <superstippi@gmx.de>

Fixed a few problems with extracting the output audio buffer size and setting
it in the media_format (encoded versus raw).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf3834148818c986500033c3581f527a58d1d1a9 29-Sep-2009 Stephan Aßmus <superstippi@gmx.de>

* Use the block-alignment from the codec context as the buffer size suggestion.
The audio decoding in AVDecoder needs this to work at all.
* Set the infoBuffer and infoSize correctly in GetStreamInfo(). At least this
is what I extract from what the AVDecoder expects.
* Use a slightly more precise timeStamp calculation in the Seek() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33358 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f0bdc7699c590eb99f05b6eb5a048bee73966335 21-Aug-2009 Jérôme Duval <korli@users.berlios.de>

* synced with ffmpeg-r19678, keeping gcc2 compiler #ifdef we introduced, build only tested on Haiku gcc2
* activated ac3 audio file format support
* uses format metadata to keep the codec context extra data (now needed for flac)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32597 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 23190db7217b0167f8e9a163a0a5441233e0cc7b 07-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

Sorry, reverted r32185, as it was complete bogus and didn't even compile (got
confused about what I already compiled here). The sample format was already
specified.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32186 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e48452878e24d88c23a3ff59243ce3bc6daabca2 07-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

* In the AVCodecDecoder, use the audio format of the original input format,
but specify it to 16bits/sample if it's still a wildcard. Make sure to
allocate the scrub buffer with the correct sample size (was hardcoded to 2
bytes per sample).
* In the AVFormatReader, specify the sample format for B_MEDIA_ENCODED_AUDIO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32185 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3ca4a7b1beb866ba584816103f66031d22b7c003 03-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

Implemented audio track encoding. There is something wrong with the PTS
generation for the packets and how I set the time_base in the AVStream and
AVStream->codec structures. This results in the audio streams of the written
files to report a much too long duration.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32064 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 54897d5c06df0e0384e0b59b23a1d926762cc078 31-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Also pass the media_codec_info to the Writer::AllocateCookie(), since that
info is not part of the media_format otherwise.
* Finished enough in the AVFormatWriter and AVCodecEncoder that we can now
actually create AVIs and MPGs and encode MPEG1, MPEG2 and MPEG4 video.
But no audio as of yet. Also, there is no bit-rate/quality setup, so it seems
libavformat is using the least possible bit-rate/quality.
* Enable some more muxers and encoders in the FFmpeg libs.
* Uses pixel format conversion from libswsscale, need to read the documentation
again, but I think it makes the plugin GPL.
* Fixed includes in libswscale/swscale.h, this is now an unmodified FFmpeg 0.5
header again (AFAICT).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32043 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eeb4be0c7f793acc78eeb035a52900abc7ee9d18 30-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Hack for interlaced video. We cannot know if video is interlaced from the
current libavformat API. FFmpeg is a little inconsistent in this regard. For
interlaced video, it will report a frame rate which is the field rate, but
still decode both fields into a single frame. For the time being, we reduce
the frame rate from 50.0 to 25.0 and handle interlaced video transparently
for the clients. This needs to be fixed later on...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31995 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c854f1402973a2288895a0fd5548b92f2fa99b01 17-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Cleanup
* Added TODO note with regards to BDataIO streams.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31618 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f06ec9ec92b0ec8f2961f34a4f047b5d4c225636 17-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Fallback to detecting the stream duration from the AVFormatContext, if the
AVStream does not provide it. For my test Flash Videos, I can at least get
a duration now, although seeking is pretty broken.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31616 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c340785238fd87316163954e2dc11c42535190c4 15-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Added support for Flash Video (VP6F video and MP3 audio tested only).
* Seeking does not work, since the duration extraction from libavformat does
not work for this container (maybe there are ways/workarounds but I didn't
look into it).
* Automatic white space cleanup.

TODO: Add MIME type with sniffer rule.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31605 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e94d298821f62c72c18cc1e0421bbe9465c5dc4 15-Jul-2009 Jérôme Duval <korli@users.berlios.de>

added flac to the codec table and the demuxer table.
audio format is now taken into account by the decoder when negociating the media output format.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31597 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b739c6a8661036563144ebe57f83b301e82bbf07 14-Jul-2009 Jérôme Duval <korli@users.berlios.de>

recognizes the ac3 codec as part of the WAV format family (the one published by ac3_decoder).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31575 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8ca0ccd187c969e14925dcc8a0933d074dbf683e 10-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Fixed compilation with TRACE_IO defined.
* Improved Seek(). If wence is not SEEK_SET, make sure to check the current
source position and adjust it to what the stream points to. Also, return
just -1 on error since this is used for libavformat code. And don't set
the stream position to the error return value.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31504 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c85e773511139070282fd62595c6ea3e0185dcae 09-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Forgot to remove invalid TODO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31480 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0f3f344fb41f8334ba4837f1905d3bffa4c5d30b 09-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Implemented calculating the correct display aspect ratio.
* Removed some dead code.
* Fixed a style violation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31479 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c7ec9670192f04b39f30a36bbfa6beff7df301f2 08-Jul-2009 Jérôme Duval <korli@users.berlios.de>

added raw dv format support. tested with PAL DV, I don't know for NTSC though


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31466 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dec28f85e053283227b83e480e5ad36b33bf1ac2 08-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Better debug output.
* We can actually tell libavformat to discard packets for streams that
we are not interested in. Found this in the ffplay code. This should hopefully
avoid the efficiency impact of using one AVFormatContext per stream.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31458 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 274f43b917082062ba007d691d634a5c76a7fb52 08-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Virtualize the stream index and implement finding streams when the
context has AVPrograms. I gather this feature is for container streams
that contain multiple "groups of streams" like how it would work for
satilite mpeg-ts streams with multiple TV channels in one stream. For this
to be properly supported, we should extend the BMediaFile/Track API. For
now, the AVFormatReader uses the first program, if one is there. This
was also needed to get make mpegts demuxer work, but it is not yet enabled
for other reasons.
* Read more probe data. 1024 bytes were not enough to detect "mpegts" properly
for example.
* For now, I disabled the locking in the AVFormatReader hooks themselves,
this should not be necessary, though I hope libavformat is reentrant as
long as you have your own AVFormatContext for each thread. So far everything
hints that it is the case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31454 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5d9b65c488c3b643bcf930984ddea8227702eb55 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Dump the libavformat string again in Sniff().
* Separate TRACE output for seeking related methods.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 922c7be61c3fbafffbc2dae99f9f8c37bd057d51 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Do not leak the first StreamCookie that we used in Sniff() and do not free
in FreeCookie().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31425 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fcb875cdf423a76eca5908055d949a7838f372da 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Do no re-use the same packet again if not supposed to. Was not a problem with
how everything currently worked. (Packet peaking was only done once in Init().)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31423 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7965dde0ca126d8cc33f3800ccaa993afdc7c447 06-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Get the AVFormatReader into a usable state. DemuxerTable.cpp controls which
container formats we support. I hope I have turned on only those that don't
have an implementation already (did we support ASF already?). I mostly tested
with AVI and that works reasonably well, but I only tested raw audio so far.
However, the backend for Marcus' avi_reader is much nicer than FFmpeg, so I
think it should stay and have disabled the support for AVI in AVFormatReader.
A big disappointment is that MPG containers only give scrambled video. It may
be a problem of the AVCodecDecoder, but I am not so sure. After all, it works
fine for other container formats. If I am not mistaken, VLC also does not use
the mpeg demuxer from FFmpeg. :-\ On top of that, libavformat detects the
time_base and stream duration wrongly for one of my test MPGs.
As for the implementation: Although seeking in libavformat happens for an
individual stream, in reality, the packets for all other streams need to be
flushed (that's also what happens in the libavformat tutorials I've seen).
Since our MediaKit API allows to seek tracks indivually, this is of course
a no-go, since then all other tracks would be out of sync. My solution is to
simply open the demuxer once for each stream and then completely ignore the
packets of the respective other streams. This also works around the problem
that libavformat is unable to provide packets by stream, requiring the
API user to queue the packets that he needs not now, but later for other
streams. It also means we have to no memory copies, since we can directly
use the packet buffer until the next call to GetNextChunk().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 827faf77a469d9bbefec9a0618bd22daa38aec6c 03-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Fleshed out some more of the format detection.
* Moved stuff from testing in Sniff() into class members.
* Added function to gfx_utils() that converts an FFmpeg pix_fmt to color_space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31402 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a244fc3ac7ccad9577d8ab9c364698fc03458eaa 02-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* It actually helps a lot to turn on all the demuxers if you want to use any.
* The URLProtocol idea seems not to work out, so I removed that code, but
the other idea of setting up a ByteIOContext actually works, once I seek
back to the beginning of the stream after reading the initial probe buffer,
we may also offset the buffer pointer in the ByteIOContext to where we
have already read, but I am not sure of possible side effects of that.

We can now probe for the correct demuxer and detect streams.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31379 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b4ef57412c8544a8d487a8b0d97b953d1cd45d71 02-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Work in Progress of trying to get libavformat to detect anything...
unsuccessful so far.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31369 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 668ed70bd09305b90b04bfbaee6db847ca5c3d8f 01-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Use a static global object to initialize libavformat and libavcodec.
* Turn off tracing in the AVCodecDecoder which I accidentally turned on in
a previous commit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31366 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 27f6fb6ce7c1050d845a500e26018ff97c5d573e 01-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

* Renamed avcodec folder to ffmpeg.
* Cleaned up plugins Jamfile.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31359 a95241bf-73f2-0310-859d-f6bbb57e9c96