History log of /haiku/src/add-ons/media/plugins/ffmpeg/AVCodecEncoder.h
Revision Date Author Comments
# 7804ba60 29-Dec-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

ffmpeg: use new AVFifo API

Change-Id: I5712acc78087c00d066695eab6b2625316153f41
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7277
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>


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


# 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


# d33bd9ec 26-Nov-2018 Barrett17 <b.vitruvio@gmail.com>

Codec Kit: Introduce BCodecKit namespace


# cd564566 24-Nov-2018 Barrett17 <b.vitruvio@gmail.com>

ffmpeg: Update class names


# 082e4ae4 25-Nov-2018 Barrett17 <b.vitruvio@gmail.com>

Codec Kit: Rename files


# 1da12a78 16-Aug-2018 JackBurton79 <stefano.ceccherini@gmail.com>

Reintroduced keeping the state of failed initialization.
As Stephan said, some apps ignore the return value of Encode(),
and since _OpenCodecIfNeeded() is called from there, this could
cause wasting of cpu cycles.

Change-Id: I80e1464d8532ebf80c514685ef3a25d98d8142fb


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

AVCodecEncoder: avcodec_close() is deprecated.
A codec context cannot be reopened, anymore.
Reorganize code accordingly.
Remove usage of the AVFormat context (which was not enabled, anyway) since it's no longer possible to do that.
Use av_frame_free() instead of av_free()


# f049e59f 09-Aug-2018 JackBurton79 <stefano.ceccherini@gmail.com>

Try to use the ffmpeg api more correctly:
call avcodec_receive_packet() in a loop, drain and flush the internal buffers.
Introduced private method to improve code readability (hopefully).


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

AVCodecEncoder: Rename fContext to fCodecContext


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

ffmpeg: Remove obsolete code


# c3b461d8 03-Dec-2015 Dario Casalinuovo <b.vitruvio@gmail.com>

AVCodecEncoder should not know the format


# 2b514992 02-Dec-2015 Dario Casalinuovo <b.vitruvio@gmail.com>

Initial implementation of BMediaEncoder

* People interested, please review!
* This is based on the patch from Fredrik Moden which was based on
the Oleg Krysenkov one.
* The original patch has been reworked by myself.
* Adapted the code to work with the new PluginManager API which
differently than before doesn't need to contact the media_server.


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


# 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


# 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


# 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


# 6780c24d 05-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

Encoder:
* Fleshed out the Encoder API to support parameter setters/getters and returning
a BView for configuration. (Not yet sure if this is a good idea.)

BMediaTrack:
* Implemented all but one of the unimplemented methods in BMediaTrack. It should
be working as far as that class is concerned, unless I missed some of the
vision. ReplaceFrames() remains a stub, added a comment on why it probably
stays that way.
* Release the Encoder reference in the destructor.

FFmpeg plugin:
* Refactoring to delay opening the AVCodec until encoding the first chunk,
so that we can still adjust parameters.
* Support adjusting parameters via [Set|Get]EncodeParameters(). Currently,
only quality is supported, added TODOs about supporting the bit_rate setup
versus the automatically calculated bit_rate.
* Extended EncoderDescription by a bit_rate scale. The Encoder calculates the
raw bitrate needed by the current media format, and then divides that
number by the specific codec's bit_rate_scale, while taking into account the
desired quality. This seems to work very well already (tested with MPEG4),
although a lot more parameters could be specified for libavcodec, depending
on the desired quality.
* Enabled the ogg muxer in libavformat, although it is currently still disabled
in MuxerTable.cpp, because it rejects unknown codecs. Added TODO to this
effect.


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


# 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


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

* Let the Encoders use the media_codec_info.sub_id field for their own purposes.
* Implemented some of AVCodecEncoder. Maybe video encoding already works, but
we don't know until the AVFormatWriter is more than just stubs... but I doubt
it. :-)


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


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

Stubbed out implementation of an Encoder and EncoderPlugin. This will probably
need to work differently, such that supported media_formats come into play,
I will know soon when I implement some of the stuff from MediaFormats.h.


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


# 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


# 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


# 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


# 6780c24d36ada936c1d3a1095d2ed9730ef1e0c7 05-Aug-2009 Stephan Aßmus <superstippi@gmx.de>

Encoder:
* Fleshed out the Encoder API to support parameter setters/getters and returning
a BView for configuration. (Not yet sure if this is a good idea.)

BMediaTrack:
* Implemented all but one of the unimplemented methods in BMediaTrack. It should
be working as far as that class is concerned, unless I missed some of the
vision. ReplaceFrames() remains a stub, added a comment on why it probably
stays that way.
* Release the Encoder reference in the destructor.

FFmpeg plugin:
* Refactoring to delay opening the AVCodec until encoding the first chunk,
so that we can still adjust parameters.
* Support adjusting parameters via [Set|Get]EncodeParameters(). Currently,
only quality is supported, added TODOs about supporting the bit_rate setup
versus the automatically calculated bit_rate.
* Extended EncoderDescription by a bit_rate scale. The Encoder calculates the
raw bitrate needed by the current media format, and then divides that
number by the specific codec's bit_rate_scale, while taking into account the
desired quality. This seems to work very well already (tested with MPEG4),
although a lot more parameters could be specified for libavcodec, depending
on the desired quality.
* Enabled the ogg muxer in libavformat, although it is currently still disabled
in MuxerTable.cpp, because it rejects unknown codecs. Added TODO to this
effect.


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


# 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


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

* Let the Encoders use the media_codec_info.sub_id field for their own purposes.
* Implemented some of AVCodecEncoder. Maybe video encoding already works, but
we don't know until the AVFormatWriter is more than just stubs... but I doubt
it. :-)


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


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

Stubbed out implementation of an Encoder and EncoderPlugin. This will probably
need to work differently, such that supported media_formats come into play,
I will know soon when I implement some of the stuff from MediaFormats.h.


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