Chun-Min Chang 774332a868 Bug 1860899 - Implement Drain based on modern APIs r=media-playback-reviewers,padenot
This patch implements drain function based on avcodec_send_frame and
avcodec_receive_packet, similar to what Encode function did.
Thus, it only works when ffmpeg version is at least 58.

It's worth mentioning that the encoder cannot continue encoding once it
enters draining mode, due to API limitation. Users need to encode data
after draining are encouraged to create a new encoder.

Still, the alternative does exist. If AV_CODEC_CAP_ENCODER_FLUSH is set
in the AVCodec's capabilities of the AVCodecContext, then
`avcodec_flush_buffers` can be used to flush or drain all the encoded
data without explicitly entering draining mode, instead of sending a
NULL to the `avcodec_send_frame`. However, since this flag is not set
when using the libvpx encoder (at least on my machine), this approach is
put to the backlog.

With the Drain implementation, the patches so far can be tested with the
additional tests below:
1. MediaDataEncoderTest.VP8Encodes
2. MediaDataEncoderTest.VP9Encodes

via the following command:
```
MOZ_LOG="FFmpegVideo:5" ./mach gtest MediaDataEncoderTest.*
```

Those tests can check the sanity of Encode() and Drain().

Depends on D195378

Differential Revision: https://phabricator.services.mozilla.com/D195379
2023-12-08 06:17:14 +00:00

An explanation of the Firefox Source Code Directory Structure and links to
project pages with documentation can be found at:

    https://firefox-source-docs.mozilla.org/contributing/directory_structure.html

For information on how to build Firefox from the source code and create the patch see:

    https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html

If you have a question about developing Firefox, and can't find the solution
on https://firefox-source-docs.mozilla.org/, you can try asking your question on Matrix at chat.mozilla.org in `Introduction` (https://chat.mozilla.org/#/room/#introduction:mozilla.org) channel.


Nightly development builds can be downloaded from:

    https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/
            - or -
    https://www.mozilla.org/firefox/channel/desktop/#nightly

Keep in mind that nightly builds, which are used by Firefox developers for
testing, may be buggy.
Description
Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org. How to contribute: https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
Readme 6.1 GiB
Languages
JavaScript 32.3%
C++ 25.4%
HTML 21%
C 10.8%
Python 2.8%
Other 7.2%