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


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

ffmpeg: remove unused and broken video framerate computation

ffmpeg already provides us with a framerate if it is known at the stream
level. If it is not known at this level, the framerate may not be fixed
througout the video, and so the best thing to do is to leave the media
kit field_rate unset, and let applications handle frames according to
their presentation timestamps as they come (this is what we had been
doing anyway, the code to output the framerate to the media kit had been
commented out for a long time and the computed value was not used)

Since ffmpeg removed the ticks_per_frame field [1], the code would not
compile anymore with later ffmpeg versions.

[1] https: //patchwork.ffmpeg.org/project/ffmpeg/patch/20230507133255.20881-12-anton@khirnov.net/

Change-Id: Icc0988c507965883a1570e46f904ebf235fb71bc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7247
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 5dbf9531 20-Sep-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: remove some asserts in aspect ratio computations

Use a default or undefined aspect ratio when ffmpeg won't tell us the
video size, rather than crashing the whole app.


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


# 64381a7b 14-May-2020 RudolfC <rudolf.cornelissen@gmail.com>

ffmpeg: fixed bytes_per_row calcs: now B_YCbCr422 works OK (video overlay)


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

AVFormatWriter: Move codec to codecpar

* Little cleanup included.


# fbd8cde1 07-Apr-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

ffmpeg: remove overzealous assert.

Fixes #12370.


# 2c499439 31-Dec-2015 Adrien Destugues <pulkomandy@pulkomandy.tk>

Use the existing ffmpeg function to decide if a format is planar.


# 8113bbfe 28-Dec-2015 Jessica Hamilton <jessica.l.hamilton@gmail.com>

ffmpeg addon: only use swresample for planar audio.

Fixes #12547.


# 894640da 14-Nov-2015 Adrien Destugues <pulkomandy@gmail.com>

ffmpeg: recognize planar audio and request packed instead

* Our media kit is designed to work with packed audio: which means the
samples from different channels are interleaved in a single stream
* Old ffmpeg versions also used this, but they now switched to the
planar format, where each channel is stored separately.
* Fortunately, we can request ffmpeg to use the packed format. We
actually already tried to do that, but the API for requesting a sample
format has also changed.
* Finally, we didn't recognize the packed format reported by the codecs,
which in some cases could lead to 16/32 bit mismatches on top of the
planar/packed mixup.

Fixes audio with ffmpeg 2.8 (ticket #12460)


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


# 75bd62e8 20-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Fix playing video files.

- This should fix the bug where video files that played well before the recent
changes to the FFMPEG Plugin didn't play anymore. Now we apply the essential
video container properties (that were passed by with Setup()) to the
AVCodecContext. Some video formats simply store those properties in the
container only (e.g. AVI, WMV) and not in the video frames itself
(e.g. MPEG2).
Tested with several files from samples.ffmpeg.org and from the FATE suite of
FFMPEG.


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

FFMPEG Plugin: Implement video frame rate calculation for decoder.

- The frame rate calculation is purely based on AVCodecContext fields. This way
the frame rate can be calculated by the FFMPEG decoder based on the actual
video data. This is useful for automatically detection of the correct
decoding parameters (not implemented yet but scheduled for a later commit).
- Not used anywhere yet (scheduled for a later commit).
- Also some minor documentation updates.


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

FFMPEG Plugin: Implement and use calculation of bytes per row.


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


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


# 75bd62e8687256d9b89c870c4ea68a5fb4138082 20-Aug-2014 Colin Günther <coling@gmx.de>

FFMPEG Plugin: Fix playing video files.

- This should fix the bug where video files that played well before the recent
changes to the FFMPEG Plugin didn't play anymore. Now we apply the essential
video container properties (that were passed by with Setup()) to the
AVCodecContext. Some video formats simply store those properties in the
container only (e.g. AVI, WMV) and not in the video frames itself
(e.g. MPEG2).
Tested with several files from samples.ffmpeg.org and from the FATE suite of
FFMPEG.


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

FFMPEG Plugin: Implement video frame rate calculation for decoder.

- The frame rate calculation is purely based on AVCodecContext fields. This way
the frame rate can be calculated by the FFMPEG decoder based on the actual
video data. This is useful for automatically detection of the correct
decoding parameters (not implemented yet but scheduled for a later commit).
- Not used anywhere yet (scheduled for a later commit).
- Also some minor documentation updates.


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

FFMPEG Plugin: Implement and use calculation of bytes per row.


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