Commit Graph

88 Commits

Author SHA1 Message Date
Limin Wang edd305ed54 avcodec/libopenh264enc: set iEntropyCodingModeFlag by coder option
For high/main profile, user can choose to use cavlc by specify "-coder cavlc",
for default, it'll will use cabac, if it's baseline, we'll use cavlc by specs anyway.

ffmpeg -y -f lavfi -i testsrc -c:v libopenh264 -profile:v main -coder cavlc -frames:v 1 -bsf trace_headers -f null -
before the patch:
entropy_coding_mode_flag                                    0 = 1

after the patch:
entropy_coding_mode_flag                                    0 = 0

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-14 22:00:19 +08:00
Limin Wang f74e90c2a0 avcodec/libopenh264enc: make the profile configuablable correctly
due to the limitations set in d3a7bdd4ac,
you weren't able to use main profile with OpenH264 1.8, or high profile
with older versions

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-14 22:00:19 +08:00
Limin Wang 008cc90d1a avcodec/libopenh264enc: support for colorspace and range information
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-01-14 22:00:19 +08:00
Andreas Rheinhardt 0812a60fee avcodec/libopenh264enc: Allow user-supplied buffers
Here the packet size is known before allocating the packet,
so that supporting user-supplied buffers is trivial.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-05-23 14:43:32 +02:00
Andreas Rheinhardt a247ac640d avcodec: Constify AVCodecs
Given that the AVCodec.next pointer has now been removed, most of the
AVCodecs are not modified at all any more and can therefore be made
const (as this patch does); the only exceptions are the very few codecs
for external libraries that have a init_static_data callback.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:15 -03:00
Andreas Rheinhardt 78ce00428f avcodec: Remove deprecated coder type options
Deprecated in be00ec832c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:01 -03:00
Anton Khirnov 7d09579190 lavc: rename AV_CODEC_CAP_AUTO_THREADS->AV_CODEC_CAP_OTHER_THREADS
This cap is currently used to mark multithreading-capable codecs that
wrap external libraries with their own multithreading code. The name is
highly confusing for our API users, since libavcodec ALWAYS handles
thread_count=0 (see commit message in previous commit). Therefore rename
the cap and update its documentation to make its meaning clear.

The old name is kept deprecated until next+1 major bump.
2021-03-16 10:38:41 +01:00
Anton Khirnov 8a129077cc lavc: replace internal use of AV_CODEC_CAP_AUTO_THREADS with an internal cap
AV_CODEC_CAP_AUTO_THREADS was originally added in b4d44a45f9 to mark
codecs that spawn threads internally and are able to select an optimal
threads count by themselves (all such codecs are wrappers around
external libraries). It is used by lavc generic code to check whether it
should handle thread_count=0 itself or pass the zero directly to the
codec implementation. Within this meaning, it is clearly supposed to be
an internal cap rather than a public one, since from the viewpoint of a
libavcodec user, lavc ALWAYS handles thread_count=0. Whether it happens
in the generic code or within the codec internals is not a meaningful
difference for the caller.

External aspects of this flag will be dealt with in the following
commit.
2021-03-16 10:34:29 +01:00
Jun Zhao becfdaaa09 lavc/libopenh264enc: use framerate if available
Respecting the framerate in the libopenh264enc codec context.

Both the libx264 and libx265 encoders already contain similar logic
to first check the framerate before falling back to the timebase.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-08-05 17:32:16 +08:00
Linjie Fu e4d37abcc1 lavc/libopenh264enc: Add coder option to replace cabac
Set DEPRECATED flag to option cabac, replace with coder. The
priority logic is:
1. s->coder; then
2. avctx->coder_type; then
3. s->cabac.

Change the default option to -1 and allow the default cabac to be
determined by profile.

Add FF_API_OPENH264_CABAC macro for cabac to remove this option after
LIBAVCODEC_VERSION_MAJOR = 59.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-13 09:55:54 +08:00
Linjie Fu e3e2702d40 lavc/libopenh264enc: Allow specifying the profile through AVCodecContext
And determine the profile with following priority:
1. s->profile; then
2. avctx->profile; then
3. s->cabac; then
4. a default profile.

This seems more natural in case user somehow sets both avctx->profile and
s->profile.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-13 09:55:47 +08:00
Linjie Fu d3a7bdd4ac lavc/libopenh264enc: Rewrite profile handling
Support the profiles "constrained_baseline" and "high" for libopenh264
version >= 1.8, support "constrained_baseline" and "main" for earlier
version.

If option not supported with current version, convert to constrained
baseline with a warning for users.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2020-05-13 09:55:29 +08:00
Linjie Fu 59a9204b8a lavc/libopenh264enc: set slice_mode option to deprecated
"slice mode" option seems to be unnecessary since it could be
determined by -slices/max_nal_size.

default:        SM_FIXEDSLCNUM_SLICE mode with cpu-number slices.
-slices N:      SM_FIXEDSLCNUM_SLICE mode with N slices.
-max_nal_size:  SM_SIZELIMITED_SLICE mode with limited size slices.

Add FF_API_OPENH264_SLICE_MODE macro to remove this option after
LIBAVCODEC_VERSION_MAJOR = 59.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu 9310361252 lavc/libopenh264enc: prompt slice number changing inside libopenh264
Libopenh264enc would set the slice according to the number of cpu cores
if uiSliceNum equals to 0 (auto) in SM_FIXEDSLCNUM_SLICE mode.

Prompt a warning for user to catch this.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu 75fc3f97b0 lavc/libopenh264enc: add bit rate control select support
RC_BITRATE_MODE:
    set BITS_EXCEEDED to iCurrentBitsLevel and allows QP adjust
    in RcCalculatePictureQp().

RC_BUFFERBASED_MODE:
    use buffer status to adjust the video quality.

RC_TIMESTAMP_MODE:
    bit rate control based on timestamp, introduced in release 1.4.

Default to use RC_QUALITY_MODE.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu e5f097eca7 lavc/libopenh264enc: add default gop size and bit rate
It would be 200kbps bitrate with gop size = 12 by default
which generated too many IDR frames in rather low bit rate.
The quality would be poor.

Set these default values to -1 to check whether it's specified
by user explicitly.

Use 2Mbps bitrate as nvenc sugguested, and leave gop size
untouched in libopenh264.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu 433ece8c8b lavc/libopenh264enc: Add qmin/qmax support
Clip iMinQp/iMaxQp to (1, 51) for user specified qp range.

If not set, leave iMinQp/iMaxQp untouched and use the values (0, 51)
initialized in FillDefault(), and the QP range would be adjusted to the
defaults inside libopenh264 library according to the iUsageType, (12, 42)
for iUsageType == CAMERA_VIDEO_REAL_TIME which is default.

<https://github.com/cisco/openh264/blob/master/codec/encoder/core/src/encoder_ext.cpp#L375>

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-29 20:58:17 +03:00
Linjie Fu 917d28d5ff lavc/libopenh264enc: fix the if-else coding style
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-04-10 13:50:47 +02:00
Tobias Rapp 7992c2867e avcodec/libopenh264enc: fix class_name
Reverts some accidental change in commit e621b1ca64.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2018-11-13 08:16:22 +01:00
Valery Kot be827e1d38 libopenh264enc: Handle sample_aspect_ratio 2018-11-05 15:46:15 +00:00
Valery Kot 67fd8df419 avcodec/openh264enc.c: generate IDR frame in response to I frame pict_type
Signed-off-by: Valery Kot <valery.kot@gmail.com>
2018-04-05 15:59:18 -03:00
wm4 b945fed629 avcodec: add metadata to identify wrappers and hardware decoders
Explicitly identify decoder/encoder wrappers with a common name. This
saves API users from guessing by the name suffix. For example, they
don't have to guess that "h264_qsv" is the h264 QSV implementation, and
instead they can just check the AVCodec .codec and .wrapper_name fields.

Explicitly mark AVCodec entries that are hardware decoders or most
likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing
API users listing hardware decoders in a more generic way. The proposed
AVCodecHWConfig does not provide this information fully, because it's
concerned with decoder configuration, not information about the fact
whether the hardware is used or not.

AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software
implementations in case the hardware is not capable.

Based on a patch by Philip Langdale <philipl@overt.org>.

Merges Libav commit 47687a2f8a.
2017-12-14 19:37:56 +01:00
James Almer e621b1ca64 Merge commit '97cfe1d8bd1968143e2ba9aa46ebe9504a835e24'
* commit '97cfe1d8bd1968143e2ba9aa46ebe9504a835e24':
  Convert all AVClass struct declarations to designated initializers.

Merged-by: James Almer <jamrial@gmail.com>
2017-11-01 20:05:09 -03:00
Diego Biurrun 97cfe1d8bd Convert all AVClass struct declarations to designated initializers. 2017-06-12 11:01:10 +02:00
James Almer b725b482c6 Merge commit '800d91d348c89fc8ca3fbec7696ab1ec8787acc6'
* commit '800d91d348c89fc8ca3fbec7696ab1ec8787acc6':
  Drop pointless void* casts

Merged-by: James Almer <jamrial@gmail.com>
2017-03-31 16:38:37 -03:00
Hendrik Leppkes 07502e473f Merge commit '7a76371437f9562c3414f985523f883489e3936a'
* commit '7a76371437f9562c3414f985523f883489e3936a':
  libopenh264enc: Simplify init by setting FF_CODEC_CAP_INIT_CLEANUP

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-18 10:47:08 +01:00
Hendrik Leppkes 7e9474ca47 Merge commit '2d097c16b833c532ac974a7f1fd05c0a1f3b7675'
* commit '2d097c16b833c532ac974a7f1fd05c0a1f3b7675':
  libopenh264enc: Return a more sensible error code in some init failure paths

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-18 10:46:02 +01:00
Diego Biurrun 800d91d348 Drop pointless void* casts 2016-11-13 18:44:01 +01:00
Hendrik Leppkes edb4c44511 Merge commit '31aa5335c390c83a6c3ea955b155067c36c4a2c4'
* commit '31aa5335c390c83a6c3ea955b155067c36c4a2c4':
  libopenh264enc: Fix inconsistent whitespace

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-10-07 13:23:49 +02:00
Martin Storsjö 293676c476 libopenh264: Support building with the 1.6 release
This fixes trac issue #5417.

This is cherry-picked from libav commit
d825b1a530.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-07-27 10:19:46 +03:00
Martin Storsjö c5d326f551 Add an OpenH264 decoder wrapper
This is cherrypicked from libav, from commits
82b7525173 and
d0b1e6049b.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-07-27 10:19:40 +03:00
Martin Storsjö 7a76371437 libopenh264enc: Simplify init by setting FF_CODEC_CAP_INIT_CLEANUP
Also set FF_CODEC_CAP_INIT_THREADSAFE while adding internal capabilities.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-07-15 13:36:23 +03:00
Martin Storsjö 2d097c16b8 libopenh264enc: Return a more sensible error code in some init failure paths
Previously they returned the default AVERROR_UNKNOWN.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-07-15 13:36:22 +03:00
Martin Storsjö d825b1a530 libopenh264: Support building with the 1.6 release
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-07-09 22:33:58 +03:00
Martin Storsjö 82b7525173 Add an OpenH264 decoder wrapper
While it is less featureful (and slower) than the built-in H264
decoder, one could potentially want to use it to take advantage
of the cisco patent license offer.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-06-28 14:17:43 +03:00
Martin Storsjö 31aa5335c3 libopenh264enc: Fix inconsistent whitespace
Signed-off-by: Martin Storsjö <martin@martin.st>
2016-06-24 22:30:46 +03:00
Derek Buitenhuis 9d4799c247 Merge commit '8dead2aaca4aa8b84b77b05745755afb56b7d37a'
* commit '8dead2aaca4aa8b84b77b05745755afb56b7d37a':
  Move const qualifier before type name

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-17 19:35:03 +01:00
Diego Biurrun 8dead2aaca Move const qualifier before type name 2016-03-23 09:25:30 +01:00
Derek Buitenhuis 899e19f177 Merge commit '936f0d98f864f9f6bb4f9e5458b78537e146bacd'
* commit '936f0d98f864f9f6bb4f9e5458b78537e146bacd':
  lavc: Move rtp_payload_size to codec private options

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-01-31 13:19:50 +00:00
Vittorio Giovara 936f0d98f8 lavc: Move rtp_payload_size to codec private options
This option is only used by mpegvideoenc and openh264.
It is a very codec-specific option, so deprecate the global variant.

The openh264 option is dropped altogether since it is just a fallback
for -max_nal_size anyway.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-01-21 15:33:19 -05:00
Hendrik Leppkes 4a80f0bdb0 Merge commit '81c95eb8eee856d98d4ac37367dbc761f2faf875'
* commit '81c95eb8eee856d98d4ac37367dbc761f2faf875':
  openh264: Directly include the deprecation guards header

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-18 14:52:18 +01:00
Hendrik Leppkes 2630f7f709 Merge commit 'be00ec832c519427cd92218abac77dafdc1d5487'
* commit 'be00ec832c519427cd92218abac77dafdc1d5487':
  lavc: Deprecate coder_type and its symbols

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-18 14:27:41 +01:00
Hendrik Leppkes f49264a1c5 Merge commit '11c9bd633f635f07a762be1ecd672de55daf4edc'
* commit '11c9bd633f635f07a762be1ecd672de55daf4edc':
  libopenh264enc: export CPB props side data

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-17 13:31:21 +01:00
Stefano Sabatini 6e891d51f4 lavc/libopenh264: apply minor options text consistency fixes 2015-12-16 10:48:28 +01:00
Luca Barbato 81c95eb8ee openh264: Directly include the deprecation guards header
Make easier to avoid compile failure when reworking the internal
headers.
2015-12-08 18:12:33 +01:00
Vittorio Giovara be00ec832c lavc: Deprecate coder_type and its symbols
Most option values are simply unused or ignored and in practice the
majory of codecs only need to check whether to enable rle or not.

Add appropriate codec private options which better expose the allowed
features.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-12-07 11:01:22 -05:00
Anton Khirnov 11c9bd633f libopenh264enc: export CPB props side data 2015-12-06 10:24:21 +01:00
Michael Niedermayer cc96018c79 libopenh264enc: Set AVOption data type
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-11-06 21:55:15 +01:00
Clément Bœsch 953d358462 avcodec/libopenh264enc: use AV_OPT_TYPE_BOOL for allow_skip_frames option 2015-10-31 17:33:22 +01:00
Michael Niedermayer 81d3986d2d avcodec/libopenh264enc: AV_OPT_TYPE_STRING should use .str default
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-31 02:29:01 +01:00