History log of /haiku/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp
Revision Date Author Comments
# 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>


# 926289d3 29-Dec-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: missing const

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


# 9bf436a2 29-Dec-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: av_init_packet is deprecated

https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=3189

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


# 83e06e62 21-Jan-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: remove use of deprecated fields in tracing

Change-Id: Id4f1e342bae8dd4a12b3f6647d60b238f98324e6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6014
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 9a6a570a 05-Sep-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: fix memory leak if writer is initialized multiple times.


# a8ea8cd1 05-Aug-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: fix memory leak in error case


# 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


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

ffmpeg: Move AVCodecWriter to BMetaData


# 59125d3c 28-Oct-2018 Barrett17 <b.vitruvio@gmail.com>

MediaWriter: Private stuff should stay private


# 8d721650 16-Aug-2018 JackBurton79 <stefano.ceccherini@gmail.com>

Check for NULL before dereferencing fStream pointer.

Change-Id: Ic1c21b24a3a1c02b478d1e8b2e395cc8a4e7adab


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

AVFormatWriter: free the context with the correct function


# 7c423844 13-Aug-2018 JackBurton79 <stefano.ceccherini@gmail.com>

Spacing style


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

ffmpeg: Fix typo and copyright notice


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

AVFormatWriter: Set packet stream index to current


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

AVFormatWriter: Fix debug build


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

AVFormatWriter: Correctly set DTS

* Fixes timestamp warning from ffmpeg.
* Fixes #13407 AFAICT. But please test.


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

AVFormatWriter: Cleanup GET_CONTEXT_DEFAULTS macro

* av_get_context_default(1,2,3) are deprecated. The functions are supposed
to "reset" a codec context to a clean state so that it can be opened again.
It was used to allow using AVStream.codec as a decoding context
That behaviour is now deprecated, so that's why the function is too.
* hint: The code is probably still doing something bad in that regard.
* Unfortunately the macro removal did end up in the codecparam diff,
but was originally intended to be a commit alone I can't rewrite history
unfortunately, at least an explanation is given here. In any case the
code wasn't used so no functional change, this is mostly educated cleanup.


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

AVFormatWriter: Remove OPEN_CODEC_CONTEXT hack


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

AVFormatWriter: Rename fContext to fFormatContext

* Seriously, this naming is bad.


# 428d87c5 04-Aug-2018 Barrett17 <b.vitruvio@gmail.com>

AVFormatWriter: Move codec to codecpar

* Little cleanup included.


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

ffmpeg: Remove obsolete code


# d1c51097 02-Jul-2018 Augustin Cavalier <waddlesplash@gmail.com>

Upgrade FFmpeg to 4.0.1 across the board (including GCC2.)

This was accomplished by adding some pretty nasty hacks to the FFmpeg recipe
so that we can compile it for the GCC2 ABI using GCC7. This works because
GCC's C ABI has not changed between GCC2 and GCC7.

As a consequence of this, pretty much all the longstanding issues of the
ancient-and-still-miscompiled FFmpeg 0.10 are now completely gone.

Fixes #5080, #8461, #12696, #12436, #13981 #13410, #13337.
Closes (possibly fixed earlier) #8605, #8511, #6984.
Probably fixes (couldn't test) #13989, #11974.


# 5ba361f8 05-Apr-2018 Barrett17 <b.vitruvio@gmail.com>

ffmpeg: Fix warning about setting stream timebase

Spotted by jackburton, doesn't fix #13407.


# ec2c5619 10-Apr-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

AVFormatWriter: Add more error checking

* Check before to write chunks if the header was correctly
written, the same happens for track infos, even if the code
doesn't support it.


# 6266cf35 07-Apr-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

AVFormatWriter: Fix bad error checking

* Review by Markus Overhagen, Thanks!
* Renamed fHeaderWritten variable to fCodecOpened too


# cbada661 05-Apr-2016 Dario Casalinuovo <b.vitruvio@gmail.com>

AVFormatWriter: Safeness after avformat_write_header fails

* The ffmpeg documentation explicit forbid to write the trailer
when the header write failed.
* Fixes #12678.


# 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.


# 278af8e2 30-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg: check against correct version constants.

54.23.x is ffmpeg 0.11, which still has "CodecID" (and x>0).


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

ffmpeg: detect the library version the right way.

* Fixes the build by detecting the library version using the provided
constants, instead of guessing from the compiler version.


# 9e5c6946 30-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: remove more deprecated functions.

These were all deprecated between releases 0.6 and 0.10 of ffmpeg,
except for one change (renaming of CodecID to AVCodecID) which we can
work around with a typedef. The deprecated functions were still
available in 0.11, but were removed later on after several years of
deprecation.

This makes it possible to build our plugin with any ffmpeg version
between 0.10 and 2.7, so we can now experiment with updating to 2.7 at
least for the gcc4 builds.


# 5e0e1689 23-Dec-2014 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: improve encoding format negociation

The ffmpeg encoders are restricted on which raw formats they accept
(each with different constraints). When asked to encode something, the
ffmpeg encoder now checks the codec capabilities and if the suggested
input format does not match, modifies it to something the codec can
actually handle.

Enable "experimental" codecs, as this is needed for AAC support in ffmpeg 0.10.

This allows format negociation to work properly, and as a result we can
enable several new audio formats: AAC (for MPEG family only), AC3, and
raw audio. Declare MKV as B_ANY_FORMAT_FAMILY since it is designed to be
a generic container (so it is possible to put AAC in MKV). Also remove
duplicate entries for AC3.


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

ffmpeg plugin: update to 0.11.5.


# 7e75e564 03-Jan-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Use av_alloc_put_byte() instead of ffio_init_context() since the
latter expects an already allocated AVIOContext.
BeScreenCapture works again, and should fix also #8299.


# 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


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

ffmpeg: don't use deprecated API in AVCodecDecoder.


# 657983b8 21-Oct-2010 Stephan Aßmus <superstippi@gmx.de>

* Introduce some currently disabled code to store the AVCodecContext
pointer in the media_format user data section.
* In the AVCodecEncoder, optionally use the AVCodecContext pointer
from the AVFormatWriter instead of its own instance. The problems
I am investigating are not improved by this, but it may be needed
anyway.
* Map the bitrate for audio to a fixed table. Certain encoders will
refuse to use a non-standard bitrate, like the currently enabled
AC-3 encoder.
* Fixed tracing output in _EncodeAudio().


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


# bb188e4d 20-Oct-2010 Stephan Aßmus <superstippi@gmx.de>

Fix crash introduced as a last minute change... need to
find a way to do this properly, though. The pixel format
selected by AVCodecEncoder should match here.


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


# 69372b55 20-Oct-2010 Stephan Aßmus <superstippi@gmx.de>

* Change the signature of the Writer plugins setup methods such
that they can modify the media_format passed in. For example they
can store information in the user_data section. I don't actually
use this anymore, but it may come in handy again.

AVFormatWriter:
* Adjust the AVCodecContext flags not only for video, but also
for audio streams (as the API example does). This mechanism
may not yet work, since the AVCodecEncoder actually uses a
different AVCodecContext instance.
* Use the encodeInfo->flags and specify the key frame flag
for the AVPacket. This finally makes videos encoded on Haiku
seekable.


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


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

* Do no manually allocate the buffer for the
ByteIOContext. libavformat may reallocate it
on demand, we need to use the matching allocation
methods.
* Init the ByteIOContext with the proper "write flag".
This solves a busy loop when writing the trailer of
MKV files, since the first buffer was initially skipped
and the MKV muxer can not seek back in the stream
where it wants.
* Get rid of the fCalculatePTS member, and calculate
PTS of audio packets as well. I don't remember why
I prevented that, however VLC complains about audio
packets having wrong PTS (with or without this change)
Our own MediaPlayer plays videos generated by (a modified)
Clockwerk at least once, but seeking subsequently fails.


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


# eb01f516 30-Aug-2010 Stephan Aßmus <superstippi@gmx.de>

The CodecID for raw-audio actually depends on the sample format
and can't be hard-coded in the EncoderTable.


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


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

Disabled tracing.


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


# fac8f830 30-Oct-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Don't call avcodec_close() on an unopened codec, as that causes a crash.
Happens for example when you create a BMediaFile and close it without
committing the header


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


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

Now supports encoded audio. Added Dolby Digital (AC-3) encoding to test this.


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


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

* AVWriter::StreamCookie::~StreamCookie() incorrectly freed packet data that it
didn't own.
* We are supposed to open the AVCodecContext in the writer, even though we never
use it. According to libav-users mailing list, this is necessary, since that
will allocate and initialize some structures that are later needed in
av_write_header(). How this is supposed to work for encoders that libavcodec
does not support, or which we don't know how to map, I do not yet know. For
now it doesn't matter and resolves the problem that audio tracks report the
wrong stream duration.
* Some more improvements with regards to what information we need to fill out
and which we don't.
* Use more sensible defaults for the stream bitrate, so that we get better
quality video by default. This and other parameters can be calculated when
we implement setting the quality.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32103 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


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

This should fix the GCC 4 build. The avformat code expects a non-const buffer
for the write() hook.


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


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

* Tweaked the Writer API. Basically, we need an Init() method that takes the
media_file_format as input, so that the Writer knows what kind of file is
needed.
* Also, since information about the stream format is going to be needed at the
Writer level as well, the AllocateCookie() method gets the stream
media_format.
* Fleshed out some aspects of AVFormatWriter, many TODOs are left.


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


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

Implemented static Write and Seek hooks to be passed to libavformat...


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


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

* Writer::WriteChunk() takes media_encode_info* instead of flags.
* Improved Encoder API towards what we need for the get_next_encoder() variants
and the BMediaTrack API.
* Implemented the rest of MediaWriter. Still undecided what to make of
AddTrackInfo(). BMediaEncoder has that as well, which hints that this is
something the Encoder needs to support. But it could also be that this is
only possible to support in Writer.
* Wired a lot of previously unimplemented methods in BMediaFile and BMediaTrack
needed for write support. If I have not overlooked anything, only the
parameter stuff is still unimplemented now.

This is all untested, since the FFMpeg Encoder and Writer are still only stubs.


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


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

Let's call it WriteChunk() instead of WriteNextChunk() and make the signature
consistent everywhere (according to BMediaTracker::WriteChunk()).


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


# 6ac391b3 29-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Stubbed out Writer and WriterPlugin implementation. So far, Clockwerk shows
"AVI (Audio Video Interleave)" in the available output formats popup... :-)


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


# 278af8e281390a344b2271a27dffc4a6798200eb 30-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg: check against correct version constants.

54.23.x is ffmpeg 0.11, which still has "CodecID" (and x>0).


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

ffmpeg: detect the library version the right way.

* Fixes the build by detecting the library version using the provided
constants, instead of guessing from the compiler version.


# 9e5c694668556b60e49a49e6708bfb550fc6ce1b 30-Aug-2015 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: remove more deprecated functions.

These were all deprecated between releases 0.6 and 0.10 of ffmpeg,
except for one change (renaming of CodecID to AVCodecID) which we can
work around with a typedef. The deprecated functions were still
available in 0.11, but were removed later on after several years of
deprecation.

This makes it possible to build our plugin with any ffmpeg version
between 0.10 and 2.7, so we can now experiment with updating to 2.7 at
least for the gcc4 builds.


# 5e0e16894d67e220b4684809b154b85db4229381 23-Dec-2014 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg plugin: improve encoding format negociation

The ffmpeg encoders are restricted on which raw formats they accept
(each with different constraints). When asked to encode something, the
ffmpeg encoder now checks the codec capabilities and if the suggested
input format does not match, modifies it to something the codec can
actually handle.

Enable "experimental" codecs, as this is needed for AAC support in ffmpeg 0.10.

This allows format negociation to work properly, and as a result we can
enable several new audio formats: AAC (for MPEG family only), AC3, and
raw audio. Declare MKV as B_ANY_FORMAT_FAMILY since it is designed to be
a generic container (so it is possible to put AAC in MKV). Also remove
duplicate entries for AC3.


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

ffmpeg plugin: update to 0.11.5.


# 7e75e564f8bc5090428814ca44f7885c6ed8c79d 03-Jan-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Use av_alloc_put_byte() instead of ffio_init_context() since the
latter expects an already allocated AVIOContext.
BeScreenCapture works again, and should fix also #8299.


# 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


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

ffmpeg: don't use deprecated API in AVCodecDecoder.


# 657983b8c215b60694fad0f469a15ae2d84f343b 21-Oct-2010 Stephan Aßmus <superstippi@gmx.de>

* Introduce some currently disabled code to store the AVCodecContext
pointer in the media_format user data section.
* In the AVCodecEncoder, optionally use the AVCodecContext pointer
from the AVFormatWriter instead of its own instance. The problems
I am investigating are not improved by this, but it may be needed
anyway.
* Map the bitrate for audio to a fixed table. Certain encoders will
refuse to use a non-standard bitrate, like the currently enabled
AC-3 encoder.
* Fixed tracing output in _EncodeAudio().


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


# bb188e4d731305e2ad63ce0e3d21149fbd21a696 20-Oct-2010 Stephan Aßmus <superstippi@gmx.de>

Fix crash introduced as a last minute change... need to
find a way to do this properly, though. The pixel format
selected by AVCodecEncoder should match here.


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


# 69372b55450310f3f82caebdd5b9f87a4f4edad9 20-Oct-2010 Stephan Aßmus <superstippi@gmx.de>

* Change the signature of the Writer plugins setup methods such
that they can modify the media_format passed in. For example they
can store information in the user_data section. I don't actually
use this anymore, but it may come in handy again.

AVFormatWriter:
* Adjust the AVCodecContext flags not only for video, but also
for audio streams (as the API example does). This mechanism
may not yet work, since the AVCodecEncoder actually uses a
different AVCodecContext instance.
* Use the encodeInfo->flags and specify the key frame flag
for the AVPacket. This finally makes videos encoded on Haiku
seekable.


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


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

* Do no manually allocate the buffer for the
ByteIOContext. libavformat may reallocate it
on demand, we need to use the matching allocation
methods.
* Init the ByteIOContext with the proper "write flag".
This solves a busy loop when writing the trailer of
MKV files, since the first buffer was initially skipped
and the MKV muxer can not seek back in the stream
where it wants.
* Get rid of the fCalculatePTS member, and calculate
PTS of audio packets as well. I don't remember why
I prevented that, however VLC complains about audio
packets having wrong PTS (with or without this change)
Our own MediaPlayer plays videos generated by (a modified)
Clockwerk at least once, but seeking subsequently fails.


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


# eb01f516a3b44adfda231e814b65ddb79fe11d64 30-Aug-2010 Stephan Aßmus <superstippi@gmx.de>

The CodecID for raw-audio actually depends on the sample format
and can't be hard-coded in the EncoderTable.


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


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

Disabled tracing.


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


# fac8f83095f6d9ac931cfa9e7deb3e9d2edca55c 30-Oct-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Don't call avcodec_close() on an unopened codec, as that causes a crash.
Happens for example when you create a BMediaFile and close it without
committing the header


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


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

Now supports encoded audio. Added Dolby Digital (AC-3) encoding to test this.


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


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

* AVWriter::StreamCookie::~StreamCookie() incorrectly freed packet data that it
didn't own.
* We are supposed to open the AVCodecContext in the writer, even though we never
use it. According to libav-users mailing list, this is necessary, since that
will allocate and initialize some structures that are later needed in
av_write_header(). How this is supposed to work for encoders that libavcodec
does not support, or which we don't know how to map, I do not yet know. For
now it doesn't matter and resolves the problem that audio tracks report the
wrong stream duration.
* Some more improvements with regards to what information we need to fill out
and which we don't.
* Use more sensible defaults for the stream bitrate, so that we get better
quality video by default. This and other parameters can be calculated when
we implement setting the quality.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32103 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


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

This should fix the GCC 4 build. The avformat code expects a non-const buffer
for the write() hook.


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


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

* Tweaked the Writer API. Basically, we need an Init() method that takes the
media_file_format as input, so that the Writer knows what kind of file is
needed.
* Also, since information about the stream format is going to be needed at the
Writer level as well, the AllocateCookie() method gets the stream
media_format.
* Fleshed out some aspects of AVFormatWriter, many TODOs are left.


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


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

Implemented static Write and Seek hooks to be passed to libavformat...


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


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

* Writer::WriteChunk() takes media_encode_info* instead of flags.
* Improved Encoder API towards what we need for the get_next_encoder() variants
and the BMediaTrack API.
* Implemented the rest of MediaWriter. Still undecided what to make of
AddTrackInfo(). BMediaEncoder has that as well, which hints that this is
something the Encoder needs to support. But it could also be that this is
only possible to support in Writer.
* Wired a lot of previously unimplemented methods in BMediaFile and BMediaTrack
needed for write support. If I have not overlooked anything, only the
parameter stuff is still unimplemented now.

This is all untested, since the FFMpeg Encoder and Writer are still only stubs.


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


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

Let's call it WriteChunk() instead of WriteNextChunk() and make the signature
consistent everywhere (according to BMediaTracker::WriteChunk()).


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


# 6ac391b3eaaeb2cd188ad7e47b3b9f74299857cc 29-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Stubbed out Writer and WriterPlugin implementation. So far, Clockwerk shows
"AVI (Audio Video Interleave)" in the available output formats popup... :-)


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