296 changes: 184 additions & 112 deletions mythtv/external/FFmpeg/configure

Large diffs are not rendered by default.

128 changes: 128 additions & 0 deletions mythtv/external/FFmpeg/doc/APIchanges
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,134 @@ libavutil: 2017-10-21

API changes, most recent first:

-------- 8< --------- FFmpeg 4.4 was cut here -------- 8< ---------

2021-03-19 - e8c0bca6bd - lavu 56.69.100 - adler32.h
Added a typedef for the type of the Adler-32 checksums
used by av_adler32_update(). It will be changed to uint32_t
at the next major bump.
The type of the parameter for the length of the input buffer
will also be changed to size_t at the next major bump.

2021-03-19 - e318438f2f - lavf 58.75.100 - avformat.h
AVChapter.id will be changed from int to int64_t
on the next major version bump.

2021-03-17 - f7db77bd87 - lavc 58.133.100 - codec.h
Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will
no longer be a part of the public ABI.
Deprecated AVPacketList.

2021-03-16 - 7d09579190 - lavc 58.132.100 - codec.h
Add AV_CODEC_CAP_OTHER_THREADS as a new name for
AV_CODEC_CAP_AUTO_THREADS. AV_CODEC_CAP_AUTO_THREADS
is now deprecated.

2021-03-12 - 6e7e3a3820 - lavc 58.131.100 - avcodec.h codec.h
Add a get_encode_buffer callback to AVCodecContext, similar to
get_buffer2 but for encoders.
Add avcodec_default_get_encode_buffer().
Add AV_GET_ENCODE_BUFFER_FLAG_REF.
Encoders may now be flagged as AV_CODEC_CAP_DR1 capable.

2021-03-10 - 42e68fe015 - lavf 58.72.100 - avformat.h
Change AVBufferRef related AVStream function and struct size
parameter and fields type to size_t at next major bump.

2021-03-10 - d79e0fe65c - lavc 58.130.100 - packet.h
Change AVBufferRef related AVPacket function and struct size
parameter and fields type to size_t at next major bump.

2021-03-10 - 14040a1d91 - lavu 56.68.100 - buffer.h frame.h
Change AVBufferRef and relevant AVFrame function and struct size
parameter and fields type to size_t at next major bump.

2021-03-04 - a0eec776b6 - lavc 58.128.101 - avcodec.h
Enable err_recognition to be set for encoders.

2021-03-03 - 2ff40b98ec - lavf 58.70.100 - avformat.h
Deprecate AVFMT_FLAG_PRIV_OPT. It will do nothing
as soon as av_demuxer_open() is removed.

2021-02-27 - dd9227e48f - lavc 58.126.100 - avcodec.h
Deprecated avcodec_get_frame_class().

2021-02-21 - 5ca40d6d94 - lavu 56.66.100 - tx.h
Add enum AVTXFlags and AVTXFlags.AV_TX_INPLACE

2021-02-14 - 4f49ca7bbc - lavd 58.12.100 - avdevice.h
Deprecated avdevice_capabilities_create() and
avdevice_capabilities_free().

2021-02-10 - 1bda9bb68a - lavu 56.65.100 - common.h
Add FFABS64U()

2021-01-26 - 5dd9567080 - lavu 56.64.100 - common.h
Add FFABSU()

2021-01-25 - 56709ca8aa - lavc 58.119.100 - avcodec.h
Deprecate AVCodecContext.debug_mv, FF_DEBUG_VIS_MV_P_FOR, FF_DEBUG_VIS_MV_B_FOR,
FF_DEBUG_VIS_MV_B_BACK

2021-01-11 - ebdd33086a - lavc 58.116.100 - avcodec.h
Add FF_PROFILE_VVC_MAIN_10 and FF_PROFILE_VVC_MAIN_10_444.

2020-01-01 - baecaa16c1 - lavu 56.63.100 - video_enc_params.h
Add AV_VIDEO_ENC_PARAMS_MPEG2

2020-12-03 - eca12f4d5a - lavu 56.62.100 - timecode.h
Add av_timecode_init_from_components.

2020-11-27 - a83098ab03 - lavc 58.114.100 - avcodec.h
Deprecate AVCodecContext.thread_safe_callbacks. Starting with
LIBAVCODEC_VERSION_MAJOR=60, user callbacks must always be
thread-safe when frame threading is used.

2020-11-25 - d243dd540a - lavc 58.113.100 - avcodec.h
Adds a new flag AV_CODEC_EXPORT_DATA_FILM_GRAIN for export_side_data.

2020-11-25 - 4f9ee87253 - lavu 56.61.100 - film_grain_params.h
Adds a new API for extracting codec film grain parameters as side data.
Adds a new AVFrameSideDataType entry AV_FRAME_DATA_FILM_GRAIN_PARAMS for it.

2020-10-28 - f95d9510ff - lavf 58.64.100 - avformat.h
Add AVSTREAM_EVENT_FLAG_NEW_PACKETS.

2020-09-28 - 68918d3b7f - lavu 56.60.100 - buffer.h
Add a av_buffer_replace() convenience function.

2020-09-13 - 837b6eb90e - lavu 56.59.100 - timecode.h
Add av_timecode_make_smpte_tc_string2.

2020-08-21 - 06f2651204 - lavu 56.58.100 - avstring.h
Deprecate av_d2str(). Use av_asprintf() instead.

2020-08-04 - 34de0abbe7 - lavu 56.58.100 - channel_layout.h
Add AV_CH_LAYOUT_22POINT2 together with its newly required pieces:
AV_CH_TOP_SIDE_LEFT, AV_CH_TOP_SIDE_RIGHT, AV_CH_BOTTOM_FRONT_CENTER,
AV_CH_BOTTOM_FRONT_LEFT, AV_CH_BOTTOM_FRONT_RIGHT.

2020-07-23 - 84655b7101 - lavu 56.57.100 - cpu.h
Add AV_CPU_FLAG_MMI and AV_CPU_FLAG_MSA.

2020-07-22 - 3a8e927176 - lavu 56.56.100 - imgutils.h
Add av_image_fill_plane_sizes().

2020-07-15 - 448a9aaa78 - lavc 58.96.100 - packet.h
Add AV_PKT_DATA_S12M_TIMECODE.

2020-06-12 - b09fb030c1 - lavu 56.55.100 - pixdesc.h
Add AV_PIX_FMT_X2RGB10.

2020-06-11 - bc8ab084fb - lavu 56.54.100 - frame.h
Add AV_FRAME_DATA_SEI_UNREGISTERED.

2020-06-10 - 1b4a98b029 - lavu 56.53.100 - log.h opt.h
Add av_opt_child_class_iterate() and AVClass.child_class_iterate().
Deprecate av_opt_child_class_next() and AVClass.child_class_next().

-------- 8< --------- FFmpeg 4.3 was cut here -------- 8< ---------

2020-06-05 - ec39c2276a - lavu 56.50.100 - buffer.h
Passing NULL as alloc argument to av_buffer_pool_init2() is now allowed.

Expand Down
2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = FFmpeg
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 4.3.2
PROJECT_NUMBER = 4.4.1

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
57 changes: 57 additions & 0 deletions mythtv/external/FFmpeg/doc/bitstream_filters.texi
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,63 @@ Remove extradata from all frames.
@end table
@end table

@section setts
Set PTS and DTS in packets.

It accepts the following parameters:
@table @option
@item ts
@item pts
@item dts
Set expressions for PTS, DTS or both.
@end table

The expressions are evaluated through the eval API and can contain the following
constants:

@table @option
@item N
The count of the input packet. Starting from 0.

@item TS
The demux timestamp in input in case of @code{ts} or @code{dts} option or presentation
timestamp in case of @code{pts} option.

@item POS
The original position in the file of the packet, or undefined if undefined
for the current packet

@item DTS
The demux timestamp in input.

@item PTS
The presentation timestamp in input.

@item STARTDTS
The DTS of the first packet.

@item STARTPTS
The PTS of the first packet.

@item PREV_INDTS
The previous input DTS.

@item PREV_INPTS
The previous input PTS.

@item PREV_OUTDTS
The previous output DTS.

@item PREV_OUTPTS
The previous output PTS.

@item TB
The timebase of stream packet belongs.

@item SR
The sample rate of stream packet belongs.
@end table

@anchor{text2movsub}
@section text2movsub

Expand Down
134 changes: 13 additions & 121 deletions mythtv/external/FFmpeg/doc/codecs.texi
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ Use internal 2pass ratecontrol in first pass mode.
Use internal 2pass ratecontrol in second pass mode.
@item gray
Only decode/encode grayscale.
@item emu_edge
Do not draw edges.
@item psnr
Set error[?] variables during encoding.
@item truncated
Expand All @@ -72,10 +70,6 @@ This ensures that file and data checksums are reproducible and match between
platforms. Its primary use is for regression testing.
@item aic
Apply H263 advanced intra coding / mpeg4 ac prediction.
@item cbp
Deprecated, use mpegvideo private options instead.
@item qprd
Deprecated, use mpegvideo private options instead.
@item ilme
Apply interlaced motion estimation.
@item cgop
Expand All @@ -84,40 +78,6 @@ Use closed gop.
Output even potentially corrupted frames.
@end table

@item me_method @var{integer} (@emph{encoding,video})
Set motion estimation method.

Possible values:
@table @samp
@item zero
zero motion estimation (fastest)
@item full
full motion estimation (slowest)
@item epzs
EPZS motion estimation (default)
@item esa
esa motion estimation (alias for full)
@item tesa
tesa motion estimation
@item dia
dia motion estimation (alias for epzs)
@item log
log motion estimation
@item phods
phods motion estimation
@item x1
X1 motion estimation
@item hex
hex motion estimation
@item umh
umh motion estimation
@item iter
iter motion estimation
@end table

@item extradata_size @var{integer}
Set extradata size.

@item time_base @var{rational number}
Set codec time base.

Expand Down Expand Up @@ -184,9 +144,6 @@ Default value is 0.
@item b_qfactor @var{float} (@emph{encoding,video})
Set qp factor between P and B frames.

@item rc_strategy @var{integer} (@emph{encoding,video})
Set ratecontrol method.

@item b_strategy @var{integer} (@emph{encoding,video})
Set strategy to choose between I/P/B-frames.

Expand All @@ -210,8 +167,6 @@ Possible values:
@table @samp
@item autodetect

@item old_msmpeg4
some old lavc generated msmpeg4v3 files (no autodetection)
@item xvid_ilace
Xvid interlacing bug (autodetected if fourcc==XVIX)
@item ump4
Expand All @@ -220,8 +175,6 @@ Xvid interlacing bug (autodetected if fourcc==XVIX)
padding bug (autodetected)
@item amv

@item ac_vlc
illegal vlc bug (autodetected per fourcc)
@item qpel_chroma

@item std_qpel
Expand All @@ -242,14 +195,6 @@ Workaround various bugs in microsoft broken decoders.
trancated frames
@end table

@item lelim @var{integer} (@emph{encoding,video})
Set single coefficient elimination threshold for luminance (negative
values also consider DC coefficient).

@item celim @var{integer} (@emph{encoding,video})
Set single coefficient elimination threshold for chrominance (negative
values also consider dc coefficient)

@item strict @var{integer} (@emph{decoding/encoding,audio,video})
Specify how strictly to follow the standards.

Expand Down Expand Up @@ -306,26 +251,8 @@ consider things that a sane encoder should not do as an error
@item mpeg_quant @var{integer} (@emph{encoding,video})
Use MPEG quantizers instead of H.263.

@item qsquish @var{float} (@emph{encoding,video})
How to keep quantizer between qmin and qmax (0 = clip, 1 = use
differentiable function).

@item rc_qmod_amp @var{float} (@emph{encoding,video})
Set experimental quantizer modulation.

@item rc_qmod_freq @var{integer} (@emph{encoding,video})
Set experimental quantizer modulation.

@item rc_override_count @var{integer}

@item rc_eq @var{string} (@emph{encoding,video})
Set rate control equation. When computing the expression, besides the
standard functions defined in the section 'Expression Evaluation', the
following functions are available: bits2qp(bits), qp2bits(qp). Also
the following constants are available: iTex pTex tex mv fCode iCount
mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex
avgTex.

@item maxrate @var{integer} (@emph{encoding,audio,video})
Set max bitrate tolerance (in bits/s). Requires bufsize to be set.

Expand All @@ -336,18 +263,12 @@ encode. It is of little use elsewise.
@item bufsize @var{integer} (@emph{encoding,audio,video})
Set ratecontrol buffer size (in bits).

@item rc_buf_aggressivity @var{float} (@emph{encoding,video})
Currently useless.

@item i_qfactor @var{float} (@emph{encoding,video})
Set QP factor between P and I frames.

@item i_qoffset @var{float} (@emph{encoding,video})
Set QP offset between P and I frames.

@item rc_init_cplx @var{float} (@emph{encoding,video})
Set initial complexity for 1-pass encoding.

@item dct @var{integer} (@emph{encoding,video})
Set DCT algorithm.

Expand Down Expand Up @@ -412,11 +333,7 @@ Automatically pick a IDCT compatible with the simple one

@item simpleneon

@item simplealpha

@item ipp

@item xvidmmx
@item xvid

@item faani
floating point AAN IDCT
Expand Down Expand Up @@ -714,19 +631,9 @@ Set diamond type & size for motion estimation pre-pass.
@item subq @var{integer} (@emph{encoding,video})
Set sub pel motion estimation quality.

@item dtg_active_format @var{integer}

@item me_range @var{integer} (@emph{encoding,video})
Set limit motion vectors range (1023 for DivX player).

@item ibias @var{integer} (@emph{encoding,video})
Set intra quant bias.

@item pbias @var{integer} (@emph{encoding,video})
Set inter quant bias.

@item color_table_id @var{integer}

@item global_quality @var{integer} (@emph{encoding,audio,video})

@item coder @var{integer} (@emph{encoding,video})
Expand All @@ -741,8 +648,6 @@ arithmetic coder
raw (no encoding)
@item rle
run-length coder
@item deflate
deflate-based coder
@end table

@item context @var{integer} (@emph{encoding,video})
Expand All @@ -763,17 +668,9 @@ use fewest bits
use best rate distortion
@end table

@item stream_codec_tag @var{integer}

@item sc_threshold @var{integer} (@emph{encoding,video})
Set scene change threshold.

@item lmin @var{integer} (@emph{encoding,video})
Set min lagrange factor (VBR).

@item lmax @var{integer} (@emph{encoding,video})
Set max lagrange factor (VBR).

@item nr @var{integer} (@emph{encoding,video})
Set noise reduction.

Expand Down Expand Up @@ -816,13 +713,14 @@ for codecs that support it. See also @file{doc/examples/export_mvs.c}.
@item prft
Export encoder Producer Reference Time into packet side-data (see @code{AV_PKT_DATA_PRFT})
for codecs that support it.
@item venc_params
Export video encoding parameters through frame side data (see @code{AV_FRAME_DATA_VIDEO_ENC_PARAMS})
for codecs that support it. At present, those are H.264 and VP9.
@item film_grain
Export film grain parameters through frame side data (see @code{AV_FRAME_DATA_FILM_GRAIN_PARAMS}).
Supported at present by AV1 decoders.
@end table

@item error @var{integer} (@emph{encoding,video})

@item qns @var{integer} (@emph{encoding,video})
Deprecated, use mpegvideo private options instead.

@item threads @var{integer} (@emph{decoding/encoding,video})
Set the number of threads to be used, in case the selected codec
implementation supports multi-threading.
Expand All @@ -835,12 +733,6 @@ automatically select the number of threads to set

Default value is @samp{auto}.

@item me_threshold @var{integer} (@emph{encoding,video})
Set motion estimation threshold.

@item mb_threshold @var{integer} (@emph{encoding,video})
Set macroblock threshold.

@item dc @var{integer} (@emph{encoding,video})
Set intra_dc_precision.

Expand Down Expand Up @@ -918,9 +810,6 @@ noise preserving sum of squared differences

@end table

@item border_mask @var{float} (@emph{encoding,video})
Increase the quantizer for macroblocks close to borders.

@item mblmin @var{integer} (@emph{encoding,video})
Set min macroblock lagrange factor (VBR).

Expand Down Expand Up @@ -994,9 +883,6 @@ Adjust sensitivity of b_frame_strategy 1.
@item timecode_frame_start @var{integer} (@emph{encoding,video})
Set GOP timecode frame start number, in non drop frame format.

@item request_channels @var{integer} (@emph{decoding,audio})
Set desired number of audio channels.

@item bits_per_raw_sample @var{integer}
@item channel_layout @var{integer} (@emph{decoding/encoding,audio})

Expand Down Expand Up @@ -1110,6 +996,12 @@ BT.2020 NCL
BT.2020 CL
@item smpte2085
SMPTE 2085
@item chroma-derived-nc
Chroma-derived NCL
@item chroma-derived-c
Chroma-derived CL
@item ictcp
ICtCp
@end table

@item color_range @var{integer} (@emph{decoding/encoding,video})
Expand Down
36 changes: 35 additions & 1 deletion mythtv/external/FFmpeg/doc/decoders.texi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ enabled decoders.
A description of some of the currently available video decoders
follows.

@section av1

AOMedia Video 1 (AV1) decoder.

@subsection Options

@table @option

@item operating_point
Select an operating point of a scalable AV1 bitstream (0 - 31). Default is 0.

@end table

@section rawvideo

Raw video decoder.
Expand Down Expand Up @@ -88,6 +101,27 @@ This decoder allows libavcodec to decode AVS2 streams with davs2 library.

@c man end VIDEO DECODERS

@section libuavs3d

AVS3-P2/IEEE1857.10 video decoder.

libuavs3d allows libavcodec to decode AVS3 streams.
Requires the presence of the libuavs3d headers and library during configuration.
You need to explicitly configure the build with @code{--enable-libuavs3d}.

@subsection Options

The following option is supported by the libuavs3d wrapper.

@table @option

@item frame_threads
Set amount of frame threads to use during decoding. The default value is 0 (autodetect).

@end table

@c man end VIDEO DECODERS

@chapter Audio Decoders
@c man begin AUDIO DECODERS

Expand All @@ -107,7 +141,7 @@ the undocumented RealAudio 3 (a.k.a. dnet).

@item -drc_scale @var{value}
Dynamic Range Scale Factor. The factor to apply to dynamic range values
from the AC-3 stream. This factor is applied exponentially.
from the AC-3 stream. This factor is applied exponentially. The default value is 1.
There are 3 notable scale factor ranges:
@table @option
@item drc_scale == 0
Expand Down
79 changes: 79 additions & 0 deletions mythtv/external/FFmpeg/doc/dev_community/community.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# FFmpeg project

## Organisation

The FFmpeg project is organized through a community working on global consensus.

Decisions are taken by the ensemble of active members, through voting and
are aided by two committees.

## General Assembly

The ensemble of active members is called the General Assembly (GA).

The General Assembly is sovereign and legitimate for all its decisions
regarding the FFmpeg project.

The General Assembly is made up of active contributors.

Contributors are considered "active contributors" if they have pushed more
than 20 patches in the last 36 months in the main FFmpeg repository, or
if they have been voted in by the GA.

Additional members are added to the General Assembly through a vote after
proposal by a member of the General Assembly.
They are part of the GA for two years, after which they need a confirmation by
the GA.

## Voting

Voting is done using a ranked voting system, currently running on https://vote.ffmpeg.org/ .

Majority vote means more than 50% of the expressed ballots.

## Technical Committee

The Technical Committee (TC) is here to arbitrate and make decisions when
technical conflicts occur in the project.
They will consider the merits of all the positions, judge them and make a
decision.

The TC resolves technical conflicts but is not a technical steering committee.

Decisions by the TC are binding for all the contributors.

Decisions made by the TC can be re-opened after 1 year or by a majority vote
of the General Assembly, requested by one of the member of the GA.

The TC is elected by the General Assembly for a duration of 1 year, and
is composed of 5 members.
Members can be re-elected if they wish. A majority vote in the General Assembly
can trigger a new election of the TC.

The members of the TC can be elected from outside of the GA.
Candidates for election can either be suggested or self-nominated.

The conflict resolution process is detailed in the [resolution process](resolution_process.md) document.

## Community committee

The Community Committee (CC) is here to arbitrage and make decisions when
inter-personal conflicts occur in the project. It will decide quickly and
take actions, for the sake of the project.

The CC can remove privileges of offending members, including removal of
commit access and temporary ban from the community.

Decisions made by the CC can be re-opened after 1 year or by a majority vote
of the General Assembly. Indefinite bans from the community must be confirmed
by the General Assembly, in a majority vote.

The CC is elected by the General Assembly for a duration of 1 year, and is
composed of 5 members.
Members can be re-elected if they wish. A majority vote in the General Assembly
can trigger a new election of the CC.

The members of the CC can be elected from outside of the GA.
Candidates for election can either be suggested or self-nominated.

The CC is governed by and responsible for enforcing the Code of Conduct.
91 changes: 91 additions & 0 deletions mythtv/external/FFmpeg/doc/dev_community/resolution_process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Technical Committee

_This document only makes sense with the rules from [the community document](community)_.

The Technical Committee (**TC**) is here to arbitrate and make decisions when
technical conflicts occur in the project.

The TC main role is to resolve technical conflicts.
It is therefore not a technical steering committee, but it is understood that
some decisions might impact the future of the project.

# Process

## Seizing

The TC can take possession of any technical matter that it sees fit.

To involve the TC in a matter, email tc@ or CC them on an ongoing discussion.

As members of TC are developers, they also can email tc@ to raise an issue.

## Announcement

The TC, once seized, must announce itself on the main mailing list, with a _[TC]_ tag.

The TC has 2 modes of operation: a RFC one and an internal one.

If the TC thinks it needs the input from the larger community, the TC can call
for a RFC. Else, it can decide by itself.

If the disagreement involves a member of the TC, that member should recuse
themselves from the decision.

The decision to use a RFC process or an internal discussion is a discretionary
decision of the TC.

The TC can also reject a seizure for a few reasons such as:
the matter was not discussed enough previously; it lacks expertise to reach a
beneficial decision on the matter; or the matter is too trivial.

### RFC call

In the RFC mode, one person from the TC posts on the mailing list the
technical question and will request input from the community.

The mail will have the following specification:
* a precise title
* a specific tag [TC RFC]
* a top-level email
* contain a precise question that does not exceed 100 words and that is answerable by developers
* may have an extra description, or a link to a previous discussion, if deemed necessary,
* contain a precise end date for the answers.

The answers from the community must be on the main mailing list and must have
the following specification:
* keep the tag and the title unchanged
* limited to 400 words
* a first-level, answering directly to the main email
* answering to the question.

Further replies to answers are permitted, as long as they conform to the
community standards of politeness, they are limited to 100 words, and are not
nested more than once. (max-depth=2)

After the end-date, mails on the thread will be ignored.

Violations of those rules will be escalated through the Community Committee.

After all the emails are in, the TC has 96 hours to give its final decision.
Exceptionally, the TC can request an extra delay, that will be notified on the
mailing list.

### Within TC

In the internal case, the TC has 96 hours to give its final decision.
Exceptionally, the TC can request an extra delay.


## Decisions

The decisions from the TC will be sent on the mailing list, with the _[TC]_ tag.

Internally, the TC should take decisions with a majority, or using
ranked-choice voting.

The decision from the TC should be published with a summary of the reasons that
lead to this decision.

The decisions from the TC are final, until the matters are reopened after
no less than one year.

369 changes: 305 additions & 64 deletions mythtv/external/FFmpeg/doc/encoders.texi

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/doc/examples/decode_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize,
FILE *f;
int i;

f = fopen(filename,"w");
f = fopen(filename,"wb");
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
for (i = 0; i < ysize; i++)
fwrite(buf + i * wrap, 1, xsize, f);
Expand Down
25 changes: 14 additions & 11 deletions mythtv/external/FFmpeg/doc/examples/demuxing_decoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int video_dst_bufsize;

static int video_stream_idx = -1, audio_stream_idx = -1;
static AVFrame *frame = NULL;
static AVPacket pkt;
static AVPacket *pkt = NULL;
static int video_frame_count = 0;
static int audio_frame_count = 0;

Expand Down Expand Up @@ -303,25 +303,27 @@ int main (int argc, char **argv)
goto end;
}

/* initialize packet, set data to NULL, let the demuxer fill it */
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
pkt = av_packet_alloc();
if (!pkt) {
fprintf(stderr, "Could not allocate packet\n");
ret = AVERROR(ENOMEM);
goto end;
}

if (video_stream)
printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename);
if (audio_stream)
printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename);

/* read frames from the file */
while (av_read_frame(fmt_ctx, &pkt) >= 0) {
while (av_read_frame(fmt_ctx, pkt) >= 0) {
// check if the packet belongs to a stream we are interested in, otherwise
// skip it
if (pkt.stream_index == video_stream_idx)
ret = decode_packet(video_dec_ctx, &pkt);
else if (pkt.stream_index == audio_stream_idx)
ret = decode_packet(audio_dec_ctx, &pkt);
av_packet_unref(&pkt);
if (pkt->stream_index == video_stream_idx)
ret = decode_packet(video_dec_ctx, pkt);
else if (pkt->stream_index == audio_stream_idx)
ret = decode_packet(audio_dec_ctx, pkt);
av_packet_unref(pkt);
if (ret < 0)
break;
}
Expand Down Expand Up @@ -372,6 +374,7 @@ int main (int argc, char **argv)
fclose(video_dst_file);
if (audio_dst_file)
fclose(audio_dst_file);
av_packet_free(&pkt);
av_frame_free(&frame);
av_free(video_dst_data[0]);

Expand Down
2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/doc/examples/hw_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ int main(int argc, char *argv[])
}

/* open the file to dump raw data */
output_file = fopen(argv[3], "w+");
output_file = fopen(argv[3], "w+b");

/* actual decoding and dump the raw data */
while (ret >= 0) {
Expand Down
47 changes: 23 additions & 24 deletions mythtv/external/FFmpeg/doc/examples/muxing.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static void add_stream(OutputStream *ost, AVFormatContext *oc,
* the motion of the chroma plane does not match the luma plane. */
c->mb_decision = 2;
}
break;
break;

default:
break;
Expand Down Expand Up @@ -284,25 +284,25 @@ static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
}

/* create resampler context */
ost->swr_ctx = swr_alloc();
if (!ost->swr_ctx) {
fprintf(stderr, "Could not allocate resampler context\n");
exit(1);
}
ost->swr_ctx = swr_alloc();
if (!ost->swr_ctx) {
fprintf(stderr, "Could not allocate resampler context\n");
exit(1);
}

/* set options */
av_opt_set_int (ost->swr_ctx, "in_channel_count", c->channels, 0);
av_opt_set_int (ost->swr_ctx, "in_sample_rate", c->sample_rate, 0);
av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
av_opt_set_int (ost->swr_ctx, "out_channel_count", c->channels, 0);
av_opt_set_int (ost->swr_ctx, "out_sample_rate", c->sample_rate, 0);
av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt", c->sample_fmt, 0);

/* initialize the resampling context */
if ((ret = swr_init(ost->swr_ctx)) < 0) {
fprintf(stderr, "Failed to initialize the resampling context\n");
exit(1);
}
/* set options */
av_opt_set_int (ost->swr_ctx, "in_channel_count", c->channels, 0);
av_opt_set_int (ost->swr_ctx, "in_sample_rate", c->sample_rate, 0);
av_opt_set_sample_fmt(ost->swr_ctx, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
av_opt_set_int (ost->swr_ctx, "out_channel_count", c->channels, 0);
av_opt_set_int (ost->swr_ctx, "out_sample_rate", c->sample_rate, 0);
av_opt_set_sample_fmt(ost->swr_ctx, "out_sample_fmt", c->sample_fmt, 0);

/* initialize the resampling context */
if ((ret = swr_init(ost->swr_ctx)) < 0) {
fprintf(stderr, "Failed to initialize the resampling context\n");
exit(1);
}
}

/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
Expand Down Expand Up @@ -349,10 +349,10 @@ static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)

if (frame) {
/* convert samples from native format to destination codec format, using the resampler */
/* compute destination number of samples */
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
c->sample_rate, c->sample_rate, AV_ROUND_UP);
av_assert0(dst_nb_samples == frame->nb_samples);
/* compute destination number of samples */
dst_nb_samples = av_rescale_rnd(swr_get_delay(ost->swr_ctx, c->sample_rate) + frame->nb_samples,
c->sample_rate, c->sample_rate, AV_ROUND_UP);
av_assert0(dst_nb_samples == frame->nb_samples);

/* when we pass a frame to the encoder, it may keep a reference to it
* internally;
Expand Down Expand Up @@ -519,7 +519,6 @@ static AVFrame *get_video_frame(OutputStream *ost)
static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
{
return write_frame(oc, ost->enc, ost->st, get_video_frame(ost));

}

static void close_stream(AVFormatContext *oc, OutputStream *ost)
Expand Down
46 changes: 27 additions & 19 deletions mythtv/external/FFmpeg/doc/examples/transcode_aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,16 @@ static int open_output_file(const char *filename,

/**
* Initialize one data packet for reading or writing.
* @param packet Packet to be initialized
* @param[out] packet Packet to be initialized
* @return Error code (0 if successful)
*/
static void init_packet(AVPacket *packet)
static int init_packet(AVPacket **packet)
{
av_init_packet(packet);
/* Set the packet data and size so that it is recognized as being empty. */
packet->data = NULL;
packet->size = 0;
if (!(*packet = av_packet_alloc())) {
fprintf(stderr, "Could not allocate packet\n");
return AVERROR(ENOMEM);
}
return 0;
}

/**
Expand Down Expand Up @@ -371,28 +373,31 @@ static int decode_audio_frame(AVFrame *frame,
int *data_present, int *finished)
{
/* Packet used for temporary storage. */
AVPacket input_packet;
AVPacket *input_packet;
int error;
init_packet(&input_packet);

error = init_packet(&input_packet);
if (error < 0)
return error;

/* Read one audio frame from the input file into a temporary packet. */
if ((error = av_read_frame(input_format_context, &input_packet)) < 0) {
if ((error = av_read_frame(input_format_context, input_packet)) < 0) {
/* If we are at the end of the file, flush the decoder below. */
if (error == AVERROR_EOF)
*finished = 1;
else {
fprintf(stderr, "Could not read frame (error '%s')\n",
av_err2str(error));
return error;
goto cleanup;
}
}

/* Send the audio frame stored in the temporary packet to the decoder.
* The input audio stream decoder is used to do this. */
if ((error = avcodec_send_packet(input_codec_context, &input_packet)) < 0) {
if ((error = avcodec_send_packet(input_codec_context, input_packet)) < 0) {
fprintf(stderr, "Could not send packet for decoding (error '%s')\n",
av_err2str(error));
return error;
goto cleanup;
}

/* Receive one frame from the decoder. */
Expand All @@ -418,7 +423,7 @@ static int decode_audio_frame(AVFrame *frame,
}

cleanup:
av_packet_unref(&input_packet);
av_packet_free(&input_packet);
return error;
}

Expand Down Expand Up @@ -661,9 +666,12 @@ static int encode_audio_frame(AVFrame *frame,
int *data_present)
{
/* Packet used for temporary storage. */
AVPacket output_packet;
AVPacket *output_packet;
int error;
init_packet(&output_packet);

error = init_packet(&output_packet);
if (error < 0)
return error;

/* Set a timestamp based on the sample rate for the container. */
if (frame) {
Expand All @@ -681,11 +689,11 @@ static int encode_audio_frame(AVFrame *frame,
} else if (error < 0) {
fprintf(stderr, "Could not send packet for encoding (error '%s')\n",
av_err2str(error));
return error;
goto cleanup;
}

/* Receive one encoded frame from the encoder. */
error = avcodec_receive_packet(output_codec_context, &output_packet);
error = avcodec_receive_packet(output_codec_context, output_packet);
/* If the encoder asks for more data to be able to provide an
* encoded frame, return indicating that no data is present. */
if (error == AVERROR(EAGAIN)) {
Expand All @@ -706,14 +714,14 @@ static int encode_audio_frame(AVFrame *frame,

/* Write one audio frame from the temporary packet to the output file. */
if (*data_present &&
(error = av_write_frame(output_format_context, &output_packet)) < 0) {
(error = av_write_frame(output_format_context, output_packet)) < 0) {
fprintf(stderr, "Could not write frame (error '%s')\n",
av_err2str(error));
goto cleanup;
}

cleanup:
av_packet_unref(&output_packet);
av_packet_free(&output_packet);
return error;
}

Expand Down
163 changes: 82 additions & 81 deletions mythtv/external/FFmpeg/doc/examples/transcoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ typedef struct FilteringContext {
AVFilterContext *buffersink_ctx;
AVFilterContext *buffersrc_ctx;
AVFilterGraph *filter_graph;

AVPacket *enc_pkt;
AVFrame *filtered_frame;
} FilteringContext;
static FilteringContext *filter_ctx;

typedef struct StreamContext {
AVCodecContext *dec_ctx;
AVCodecContext *enc_ctx;

AVFrame *dec_frame;
} StreamContext;
static StreamContext *stream_ctx;

Expand Down Expand Up @@ -102,6 +107,10 @@ static int open_input_file(const char *filename)
}
}
stream_ctx[i].dec_ctx = codec_ctx;

stream_ctx[i].dec_frame = av_frame_alloc();
if (!stream_ctx[i].dec_frame)
return AVERROR(ENOMEM);
}

av_dump_format(ifmt_ctx, 0, filename, 0);
Expand Down Expand Up @@ -398,54 +407,63 @@ static int init_filters(void)
stream_ctx[i].enc_ctx, filter_spec);
if (ret)
return ret;

filter_ctx[i].enc_pkt = av_packet_alloc();
if (!filter_ctx[i].enc_pkt)
return AVERROR(ENOMEM);

filter_ctx[i].filtered_frame = av_frame_alloc();
if (!filter_ctx[i].filtered_frame)
return AVERROR(ENOMEM);
}
return 0;
}

static int encode_write_frame(AVFrame *filt_frame, unsigned int stream_index, int *got_frame) {
static int encode_write_frame(unsigned int stream_index, int flush)
{
StreamContext *stream = &stream_ctx[stream_index];
FilteringContext *filter = &filter_ctx[stream_index];
AVFrame *filt_frame = flush ? NULL : filter->filtered_frame;
AVPacket *enc_pkt = filter->enc_pkt;
int ret;
int got_frame_local;
AVPacket enc_pkt;
int (*enc_func)(AVCodecContext *, AVPacket *, const AVFrame *, int *) =
(ifmt_ctx->streams[stream_index]->codecpar->codec_type ==
AVMEDIA_TYPE_VIDEO) ? avcodec_encode_video2 : avcodec_encode_audio2;

if (!got_frame)
got_frame = &got_frame_local;

av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
/* encode filtered frame */
enc_pkt.data = NULL;
enc_pkt.size = 0;
av_init_packet(&enc_pkt);
ret = enc_func(stream_ctx[stream_index].enc_ctx, &enc_pkt,
filt_frame, got_frame);
av_frame_free(&filt_frame);
av_packet_unref(enc_pkt);

ret = avcodec_send_frame(stream->enc_ctx, filt_frame);

if (ret < 0)
return ret;
if (!(*got_frame))
return 0;

/* prepare packet for muxing */
enc_pkt.stream_index = stream_index;
av_packet_rescale_ts(&enc_pkt,
stream_ctx[stream_index].enc_ctx->time_base,
ofmt_ctx->streams[stream_index]->time_base);
while (ret >= 0) {
ret = avcodec_receive_packet(stream->enc_ctx, enc_pkt);

if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return 0;

/* prepare packet for muxing */
enc_pkt->stream_index = stream_index;
av_packet_rescale_ts(enc_pkt,
stream->enc_ctx->time_base,
ofmt_ctx->streams[stream_index]->time_base);

av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
/* mux encoded frame */
ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt);
}

av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
/* mux encoded frame */
ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
return ret;
}

static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
{
FilteringContext *filter = &filter_ctx[stream_index];
int ret;
AVFrame *filt_frame;

av_log(NULL, AV_LOG_INFO, "Pushing decoded frame to filters\n");
/* push the decoded frame into the filtergraph */
ret = av_buffersrc_add_frame_flags(filter_ctx[stream_index].buffersrc_ctx,
ret = av_buffersrc_add_frame_flags(filter->buffersrc_ctx,
frame, 0);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
Expand All @@ -454,27 +472,22 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)

/* pull filtered frames from the filtergraph */
while (1) {
filt_frame = av_frame_alloc();
if (!filt_frame) {
ret = AVERROR(ENOMEM);
break;
}
av_log(NULL, AV_LOG_INFO, "Pulling filtered frame from filters\n");
ret = av_buffersink_get_frame(filter_ctx[stream_index].buffersink_ctx,
filt_frame);
ret = av_buffersink_get_frame(filter->buffersink_ctx,
filter->filtered_frame);
if (ret < 0) {
/* if no more frames for output - returns AVERROR(EAGAIN)
* if flushed and no more frames for output - returns AVERROR_EOF
* rewrite retcode to 0 to show it as normal procedure completion
*/
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
ret = 0;
av_frame_free(&filt_frame);
break;
}

filt_frame->pict_type = AV_PICTURE_TYPE_NONE;
ret = encode_write_frame(filt_frame, stream_index, NULL);
filter->filtered_frame->pict_type = AV_PICTURE_TYPE_NONE;
ret = encode_write_frame(stream_index, 0);
av_frame_unref(filter->filtered_frame);
if (ret < 0)
break;
}
Expand All @@ -484,34 +497,20 @@ static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)

static int flush_encoder(unsigned int stream_index)
{
int ret;
int got_frame;

if (!(stream_ctx[stream_index].enc_ctx->codec->capabilities &
AV_CODEC_CAP_DELAY))
return 0;

while (1) {
av_log(NULL, AV_LOG_INFO, "Flushing stream #%u encoder\n", stream_index);
ret = encode_write_frame(NULL, stream_index, &got_frame);
if (ret < 0)
break;
if (!got_frame)
return 0;
}
return ret;
av_log(NULL, AV_LOG_INFO, "Flushing stream #%u encoder\n", stream_index);
return encode_write_frame(stream_index, 1);
}

int main(int argc, char **argv)
{
int ret;
AVPacket packet = { .data = NULL, .size = 0 };
AVFrame *frame = NULL;
enum AVMediaType type;
AVPacket *packet = NULL;
unsigned int stream_index;
unsigned int i;
int got_frame;
int (*dec_func)(AVCodecContext *, AVFrame *, int *, const AVPacket *);

if (argc != 3) {
av_log(NULL, AV_LOG_ERROR, "Usage: %s <input file> <output file>\n", argv[0]);
Expand All @@ -524,56 +523,54 @@ int main(int argc, char **argv)
goto end;
if ((ret = init_filters()) < 0)
goto end;
if (!(packet = av_packet_alloc()))
goto end;

/* read all packets */
while (1) {
if ((ret = av_read_frame(ifmt_ctx, &packet)) < 0)
if ((ret = av_read_frame(ifmt_ctx, packet)) < 0)
break;
stream_index = packet.stream_index;
type = ifmt_ctx->streams[packet.stream_index]->codecpar->codec_type;
stream_index = packet->stream_index;
av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n",
stream_index);

if (filter_ctx[stream_index].filter_graph) {
StreamContext *stream = &stream_ctx[stream_index];

av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n");
frame = av_frame_alloc();
if (!frame) {
ret = AVERROR(ENOMEM);
break;
}
av_packet_rescale_ts(&packet,

av_packet_rescale_ts(packet,
ifmt_ctx->streams[stream_index]->time_base,
stream_ctx[stream_index].dec_ctx->time_base);
dec_func = (type == AVMEDIA_TYPE_VIDEO) ? avcodec_decode_video2 :
avcodec_decode_audio4;
ret = dec_func(stream_ctx[stream_index].dec_ctx, frame,
&got_frame, &packet);
stream->dec_ctx->time_base);
ret = avcodec_send_packet(stream->dec_ctx, packet);
if (ret < 0) {
av_frame_free(&frame);
av_log(NULL, AV_LOG_ERROR, "Decoding failed\n");
break;
}

if (got_frame) {
frame->pts = frame->best_effort_timestamp;
ret = filter_encode_write_frame(frame, stream_index);
av_frame_free(&frame);
while (ret >= 0) {
ret = avcodec_receive_frame(stream->dec_ctx, stream->dec_frame);
if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
break;
else if (ret < 0)
goto end;

stream->dec_frame->pts = stream->dec_frame->best_effort_timestamp;
ret = filter_encode_write_frame(stream->dec_frame, stream_index);
if (ret < 0)
goto end;
} else {
av_frame_free(&frame);
}
} else {
/* remux this frame without reencoding */
av_packet_rescale_ts(&packet,
av_packet_rescale_ts(packet,
ifmt_ctx->streams[stream_index]->time_base,
ofmt_ctx->streams[stream_index]->time_base);

ret = av_interleaved_write_frame(ofmt_ctx, &packet);
ret = av_interleaved_write_frame(ofmt_ctx, packet);
if (ret < 0)
goto end;
}
av_packet_unref(&packet);
av_packet_unref(packet);
}

/* flush filters and encoders */
Expand All @@ -597,14 +594,18 @@ int main(int argc, char **argv)

av_write_trailer(ofmt_ctx);
end:
av_packet_unref(&packet);
av_frame_free(&frame);
av_packet_free(&packet);
for (i = 0; i < ifmt_ctx->nb_streams; i++) {
avcodec_free_context(&stream_ctx[i].dec_ctx);
if (ofmt_ctx && ofmt_ctx->nb_streams > i && ofmt_ctx->streams[i] && stream_ctx[i].enc_ctx)
avcodec_free_context(&stream_ctx[i].enc_ctx);
if (filter_ctx && filter_ctx[i].filter_graph)
if (filter_ctx && filter_ctx[i].filter_graph) {
avfilter_graph_free(&filter_ctx[i].filter_graph);
av_packet_free(&filter_ctx[i].enc_pkt);
av_frame_free(&filter_ctx[i].filtered_frame);
}

av_frame_free(&stream_ctx[i].dec_frame);
}
av_free(filter_ctx);
av_free(stream_ctx);
Expand Down
16 changes: 8 additions & 8 deletions mythtv/external/FFmpeg/doc/examples/vaapi_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@ static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx)
static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
{
int ret = 0;
AVPacket enc_pkt;
AVPacket *enc_pkt;

av_init_packet(&enc_pkt);
enc_pkt.data = NULL;
enc_pkt.size = 0;
if (!(enc_pkt = av_packet_alloc()))
return AVERROR(ENOMEM);

if ((ret = avcodec_send_frame(avctx, frame)) < 0) {
fprintf(stderr, "Error code: %s\n", av_err2str(ret));
goto end;
}
while (1) {
ret = avcodec_receive_packet(avctx, &enc_pkt);
ret = avcodec_receive_packet(avctx, enc_pkt);
if (ret)
break;

enc_pkt.stream_index = 0;
ret = fwrite(enc_pkt.data, enc_pkt.size, 1, fout);
av_packet_unref(&enc_pkt);
enc_pkt->stream_index = 0;
ret = fwrite(enc_pkt->data, enc_pkt->size, 1, fout);
av_packet_unref(enc_pkt);
}

end:
av_packet_free(&enc_pkt);
ret = ((ret == AVERROR(EAGAIN)) ? 0 : -1);
return ret;
}
Expand Down
42 changes: 22 additions & 20 deletions mythtv/external/FFmpeg/doc/examples/vaapi_transcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,25 @@ static int open_input_file(const char *filename)
return ret;
}

static int encode_write(AVFrame *frame)
static int encode_write(AVPacket *enc_pkt, AVFrame *frame)
{
int ret = 0;
AVPacket enc_pkt;

av_init_packet(&enc_pkt);
enc_pkt.data = NULL;
enc_pkt.size = 0;
av_packet_unref(enc_pkt);

if ((ret = avcodec_send_frame(encoder_ctx, frame)) < 0) {
fprintf(stderr, "Error during encoding. Error code: %s\n", av_err2str(ret));
goto end;
}
while (1) {
ret = avcodec_receive_packet(encoder_ctx, &enc_pkt);
ret = avcodec_receive_packet(encoder_ctx, enc_pkt);
if (ret)
break;

enc_pkt.stream_index = 0;
av_packet_rescale_ts(&enc_pkt, ifmt_ctx->streams[video_stream]->time_base,
enc_pkt->stream_index = 0;
av_packet_rescale_ts(enc_pkt, ifmt_ctx->streams[video_stream]->time_base,
ofmt_ctx->streams[0]->time_base);
ret = av_interleaved_write_frame(ofmt_ctx, &enc_pkt);
ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt);
if (ret < 0) {
fprintf(stderr, "Error during writing data to output file. "
"Error code: %s\n", av_err2str(ret));
Expand Down Expand Up @@ -216,7 +213,7 @@ static int dec_enc(AVPacket *pkt, AVCodec *enc_codec)
initialized = 1;
}

if ((ret = encode_write(frame)) < 0)
if ((ret = encode_write(pkt, frame)) < 0)
fprintf(stderr, "Error during encoding and writing.\n");

fail:
Expand All @@ -230,7 +227,7 @@ static int dec_enc(AVPacket *pkt, AVCodec *enc_codec)
int main(int argc, char **argv)
{
int ret = 0;
AVPacket dec_pkt;
AVPacket *dec_pkt;
AVCodec *enc_codec;

if (argc != 4) {
Expand All @@ -246,6 +243,12 @@ int main(int argc, char **argv)
return -1;
}

dec_pkt = av_packet_alloc();
if (!dec_pkt) {
fprintf(stderr, "Failed to allocate decode packet\n");
goto end;
}

if ((ret = open_input_file(argv[1])) < 0)
goto end;

Expand Down Expand Up @@ -275,23 +278,21 @@ int main(int argc, char **argv)

/* read all packets and only transcoding video */
while (ret >= 0) {
if ((ret = av_read_frame(ifmt_ctx, &dec_pkt)) < 0)
if ((ret = av_read_frame(ifmt_ctx, dec_pkt)) < 0)
break;

if (video_stream == dec_pkt.stream_index)
ret = dec_enc(&dec_pkt, enc_codec);
if (video_stream == dec_pkt->stream_index)
ret = dec_enc(dec_pkt, enc_codec);

av_packet_unref(&dec_pkt);
av_packet_unref(dec_pkt);
}

/* flush decoder */
dec_pkt.data = NULL;
dec_pkt.size = 0;
ret = dec_enc(&dec_pkt, enc_codec);
av_packet_unref(&dec_pkt);
av_packet_unref(dec_pkt);
ret = dec_enc(dec_pkt, enc_codec);

/* flush encoder */
ret = encode_write(NULL);
ret = encode_write(dec_pkt, NULL);

/* write the trailer for output stream */
av_write_trailer(ofmt_ctx);
Expand All @@ -302,5 +303,6 @@ int main(int argc, char **argv)
avcodec_free_context(&decoder_ctx);
avcodec_free_context(&encoder_ctx);
av_buffer_unref(&hw_device_ctx);
av_packet_free(&dec_pkt);
return ret;
}
199 changes: 174 additions & 25 deletions mythtv/external/FFmpeg/doc/ffmpeg.texi
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,102 @@ they do not conflict with the standard, as in:
ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
@end example

The parameters set for each target are as follows.

@strong{VCD}
@example
@var{pal}:
-f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
-s 352x288 -r 25
-codec:v mpeg1video -g 15 -b:v 1150k -maxrate:v 1150v -minrate:v 1150k -bufsize:v 327680
-ar 44100 -ac 2
-codec:a mp2 -b:a 224k
@var{ntsc}:
-f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
-s 352x240 -r 30000/1001
-codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150v -minrate:v 1150k -bufsize:v 327680
-ar 44100 -ac 2
-codec:a mp2 -b:a 224k
@var{film}:
-f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
-s 352x240 -r 24000/1001
-codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150v -minrate:v 1150k -bufsize:v 327680
-ar 44100 -ac 2
-codec:a mp2 -b:a 224k
@end example

@strong{SVCD}
@example
@var{pal}:
-f svcd -packetsize 2324
-s 480x576 -pix_fmt yuv420p -r 25
-codec:v mpeg2video -g 15 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
-ar 44100
-codec:a mp2 -b:a 224k
@var{ntsc}:
-f svcd -packetsize 2324
-s 480x480 -pix_fmt yuv420p -r 30000/1001
-codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
-ar 44100
-codec:a mp2 -b:a 224k
@var{film}:
-f svcd -packetsize 2324
-s 480x480 -pix_fmt yuv420p -r 24000/1001
-codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
-ar 44100
-codec:a mp2 -b:a 224k
@end example

@strong{DVD}
@example
@var{pal}:
-f dvd -muxrate 10080k -packetsize 2048
-s 720x576 -pix_fmt yuv420p -r 25
-codec:v mpeg2video -g 15 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
-ar 48000
-codec:a ac3 -b:a 448k
@var{ntsc}:
-f dvd -muxrate 10080k -packetsize 2048
-s 720x480 -pix_fmt yuv420p -r 30000/1001
-codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
-ar 48000
-codec:a ac3 -b:a 448k
@var{film}:
-f dvd -muxrate 10080k -packetsize 2048
-s 720x480 -pix_fmt yuv420p -r 24000/1001
-codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
-ar 48000
-codec:a ac3 -b:a 448k
@end example

@strong{DV}
@example
@var{pal}:
-f dv
-s 720x576 -pix_fmt yuv420p -r 25
-ar 48000 -ac 2
@var{ntsc}:
-f dv
-s 720x480 -pix_fmt yuv411p -r 30000/1001
-ar 48000 -ac 2
@var{film}:
-f dv
-s 720x480 -pix_fmt yuv411p -r 24000/1001
-ar 48000 -ac 2
@end example
The @code{dv50} target is identical to the @code{dv} target except that the pixel format set is @code{yuv422p} for all three standards.

Any user-set value for a parameter above will override the target preset value. In that case, the output may
not comply with the target standard.

@item -dn (@emph{input/output})
As an input option, blocks all data streams of a file from being filtered or
being automatically selected or mapped for any output. See @code{-discard}
Expand Down Expand Up @@ -675,14 +771,19 @@ Specify the preset for matching stream(s).
Print encoding progress/statistics. It is on by default, to explicitly
disable it you need to specify @code{-nostats}.

@item -stats_period @var{time} (@emph{global})
Set period at which encoding progress/statistics are updated. Default is 0.5 seconds.

@item -progress @var{url} (@emph{global})
Send program-friendly progress information to @var{url}.

Progress information is written approximately every second and at the end of
Progress information is written periodically and at the end of
the encoding process. It is made of "@var{key}=@var{value}" lines. @var{key}
consists of only alphanumeric characters. The last key of a sequence of
progress information is always "progress".

The update period is set using @code{-stats_period}.

@anchor{stdin option}
@item -stdin
Enable interaction on standard input. On by default unless standard input is
Expand Down Expand Up @@ -734,10 +835,6 @@ ffmpeg -dump_attachment:t "" -i INPUT
Technical note -- attachments are implemented as codec extradata, so this
option can actually be used to extract extradata from any stream, not just
attachments.

@item -noautorotate
Disable automatically rotating video based on file metadata.

@end table

@section Video Options
Expand All @@ -758,6 +855,13 @@ If in doubt use @option{-framerate} instead of the input option @option{-r}.
As an output option, duplicate or drop input frames to achieve constant output
frame rate @var{fps}.

@item -fpsmax[:@var{stream_specifier}] @var{fps} (@emph{output,per-stream})
Set maximum frame rate (Hz value, fraction or abbreviation).

Clamps output frame rate when output framerate is auto-set and is higher than this value.
Useful in batch processing or when input framerate is wrongly detected as very high.
It cannot be set together with @code{-r}. It is ignored during streamcopy.

@item -s[:@var{stream_specifier}] @var{size} (@emph{input/output,per-stream})
Set frame size.

Expand Down Expand Up @@ -819,6 +923,18 @@ Create the filtergraph specified by @var{filtergraph} and use it to
filter the stream.

This is an alias for @code{-filter:v}, see the @ref{filter_option,,-filter option}.

@item -autorotate
Automatically rotate the video according to file metadata. Enabled by
default, use @option{-noautorotate} to disable it.

@item -autoscale
Automatically scale the video according to the resolution of first frame.
Enabled by default, use @option{-noautoscale} to disable it. When autoscale is
disabled, all output frames of filter graph might not be in the same resolution
and may be inadequate for some encoder/muxer. Therefore, it is not recommended
to disable it unless you really know what you are doing.
Disable autoscale at your own risk.
@end table

@section Advanced Video options
Expand Down Expand Up @@ -848,8 +964,8 @@ factor if negative.
Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
Use this option if your input file is interlaced and you want
to keep the interlaced format for minimum losses.
The alternative is to deinterlace the input stream with
@option{-deinterlace}, but deinterlacing introduces losses.
The alternative is to deinterlace the input stream by use of a filter
such as @code{yadif} or @code{bwdif}, but deinterlacing introduces losses.
@item -psnr
Calculate PSNR of compressed frames.
@item -vstats
Expand Down Expand Up @@ -1492,6 +1608,17 @@ is enabled.

This option has been deprecated. Use the @code{aresample} audio filter instead.

@item -adrift_threshold @var{time}
Set the minimum difference between timestamps and audio data (in seconds) to trigger
adding/dropping samples to make it match the timestamps. This option effectively is
a threshold to select between hard (add/drop) and soft (squeeze/stretch) compensation.
@code{-async} must be set to a positive value.

@item -apad @var{parameters} (@emph{output,per-stream})
Pad the output audio stream(s). This is the same as applying @code{-af apad}.
Argument is a string of filter parameters composed the same as with the @code{apad} filter.
@code{-shortest} must be set for this output for the option to take effect.

@item -copyts
Do not process input timestamps, but keep their values without trying
to sanitize them. In particular, do not remove the initial start time
Expand Down Expand Up @@ -1646,6 +1773,22 @@ graph will be added to the output file automatically, so we can simply write
ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
@end example

As a special exception, you can use a bitmap subtitle stream as input: it
will be converted into a video with the same size as the largest video in
the file, or 720x576 if no video is present. Note that this is an
experimental and temporary solution. It will be removed once libavfilter has
proper support for subtitles.

For example, to hardcode subtitles on top of a DVB-T recording stored in
MPEG-TS format, delaying the subtitles by 1 second:
@example
ffmpeg -i input.ts -filter_complex \
'[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
-sn -map '#0x2dc' output.mkv
@end example
(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)

To generate 5 seconds of pure red video using lavfi @code{color} source:
@example
ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
Expand Down Expand Up @@ -1681,8 +1824,9 @@ not start from timestamp 0, such as transport streams.
@item -thread_queue_size @var{size} (@emph{input})
This option sets the maximum number of queued packets when reading from the
file or device. With low latency / high rate live streams, packets may be
discarded if they are not read in a timely manner; raising this value can
avoid it.
discarded if they are not read in a timely manner; setting this value can
force ffmpeg to use a separate input thread and read packets as soon as they
arrive. By default ffmpeg only do this if multiple inputs are specified.

@item -sdp_file @var{file} (@emph{global})
Print sdp information for an output stream to @var{file}.
Expand Down Expand Up @@ -1725,6 +1869,11 @@ No packets were passed to the muxer, the output is empty.
No packets were passed to the muxer in some of the output streams.
@end table

@item -max_error_rate (@emph{global})
Set fraction of decoding frame failures across all inputs which when crossed
ffmpeg will return exit code 69. Crossing this threshold does not terminate
processing. Range is a floating-point number between 0 to 1. Default is 2/3.

@item -xerror (@emph{global})
Stop and exit on error

Expand All @@ -1737,23 +1886,22 @@ this buffer, in packets, for the matching output stream.
The default value of this option should be high enough for most uses, so only
touch this option if you are sure that you need it.

@end table

As a special exception, you can use a bitmap subtitle stream as input: it
will be converted into a video with the same size as the largest video in
the file, or 720x576 if no video is present. Note that this is an
experimental and temporary solution. It will be removed once libavfilter has
proper support for subtitles.
@item -muxing_queue_data_threshold @var{bytes} (@emph{output,per-stream})
This is a minimum threshold until which the muxing queue size is not taken into
account. Defaults to 50 megabytes per stream, and is based on the overall size
of packets passed to the muxer.

@item -auto_conversion_filters (@emph{global})
Enable automatically inserting format conversion filters in all filter
graphs, including those defined by @option{-vf}, @option{-af},
@option{-filter_complex} and @option{-lavfi}. If filter format negotiation
requires a conversion, the initialization of the filters will fail.
Conversions can still be performed by inserting the relevant conversion
filter (scale, aresample) in the graph.
On by default, to explicitly disable it you need to specify
@code{-noauto_conversion_filters}.

For example, to hardcode subtitles on top of a DVB-T recording stored in
MPEG-TS format, delaying the subtitles by 1 second:
@example
ffmpeg -i input.ts -filter_complex \
'[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
-sn -map '#0x2dc' output.mkv
@end example
(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
@end table

@section Preset files
A preset file contains a sequence of @var{option}=@var{value} pairs,
Expand Down Expand Up @@ -2031,6 +2179,7 @@ ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
@ifset config-avfilter
@include filters.texi
@end ifset
@include general_contents.texi
@end ifset

@chapter See Also
Expand Down
1 change: 1 addition & 0 deletions mythtv/external/FFmpeg/doc/ffplay.texi
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ Toggle full screen.
@ifset config-avfilter
@include filters.texi
@end ifset
@include general_contents.texi
@end ifset

@chapter See Also
Expand Down
1 change: 1 addition & 0 deletions mythtv/external/FFmpeg/doc/ffprobe.texi
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ DV, GXF and AVI timecodes are available in format metadata
@ifset config-avfilter
@include filters.texi
@end ifset
@include general_contents.texi
@end ifset

@chapter See Also
Expand Down
5 changes: 0 additions & 5 deletions mythtv/external/FFmpeg/doc/ffprobe.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
<xsd:attribute name="dts_time" type="xsd:float" />
<xsd:attribute name="duration" type="xsd:long" />
<xsd:attribute name="duration_time" type="xsd:float" />
<xsd:attribute name="convergence_duration" type="xsd:long" />
<xsd:attribute name="convergence_duration_time" type="xsd:float" />
<xsd:attribute name="size" type="xsd:long" use="required" />
<xsd:attribute name="pos" type="xsd:long" />
<xsd:attribute name="flags" type="xsd:string" use="required" />
Expand Down Expand Up @@ -215,7 +213,6 @@
<xsd:attribute name="codec_long_name" type="xsd:string" />
<xsd:attribute name="profile" type="xsd:string" />
<xsd:attribute name="codec_type" type="xsd:string" />
<xsd:attribute name="codec_time_base" type="xsd:string" use="required"/>
<xsd:attribute name="codec_tag" type="xsd:string" use="required"/>
<xsd:attribute name="codec_tag_string" type="xsd:string" use="required"/>
<xsd:attribute name="extradata" type="xsd:string" />
Expand All @@ -238,7 +235,6 @@
<xsd:attribute name="color_primaries" type="xsd:string"/>
<xsd:attribute name="chroma_location" type="xsd:string"/>
<xsd:attribute name="field_order" type="xsd:string"/>
<xsd:attribute name="timecode" type="xsd:string"/>
<xsd:attribute name="refs" type="xsd:int"/>

<!-- audio attributes -->
Expand Down Expand Up @@ -358,7 +354,6 @@
<xsd:attribute name="hwaccel" type="xsd:int" use="required"/>
<xsd:attribute name="planar" type="xsd:int" use="required"/>
<xsd:attribute name="rgb" type="xsd:int" use="required"/>
<xsd:attribute name="pseudopal" type="xsd:int" use="required"/>
<xsd:attribute name="alpha" type="xsd:int" use="required"/>
</xsd:complexType>

Expand Down
17 changes: 15 additions & 2 deletions mythtv/external/FFmpeg/doc/fftools-common-opts.texi
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,24 @@ Print detailed information about the muxer named @var{muxer_name}. Use the
@option{-formats} option to get a list of all muxers and demuxers.

@item filter=@var{filter_name}
Print detailed information about the filter name @var{filter_name}. Use the
Print detailed information about the filter named @var{filter_name}. Use the
@option{-filters} option to get a list of all filters.

@item bsf=@var{bitstream_filter_name}
Print detailed information about the bitstream filter name @var{bitstream_filter_name}.
Print detailed information about the bitstream filter named @var{bitstream_filter_name}.
Use the @option{-bsfs} option to get a list of all bitstream filters.

@item protocol=@var{protocol_name}
Print detailed information about the protocol named @var{protocol_name}.
Use the @option{-protocols} option to get a list of all protocols.
@end table

@item -version
Show version.

@item -buildconf
Show the build configuration, one option per line.

@item -formats
Show available formats (including devices).

Expand Down Expand Up @@ -345,6 +352,12 @@ Possible flags for this option are:
@item k8
@end table
@end table

@item -max_alloc @var{bytes}
Set the maximum size limit for allocating a block on the heap by ffmpeg's
family of malloc functions. Exercise @strong{extreme caution} when using
this option. Don't use if you do not understand the full consequence of doing so.
Default is INT_MAX.
@end table

@section AVOptions
Expand Down
1,705 changes: 1,629 additions & 76 deletions mythtv/external/FFmpeg/doc/filters.texi

Large diffs are not rendered by default.

1,401 changes: 1 addition & 1,400 deletions mythtv/external/FFmpeg/doc/general.texi

Large diffs are not rendered by default.

1,440 changes: 1,440 additions & 0 deletions mythtv/external/FFmpeg/doc/general_contents.texi

Large diffs are not rendered by default.

61 changes: 56 additions & 5 deletions mythtv/external/FFmpeg/doc/indevs.texi
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,31 @@ supports it.
Set the pixel format of the captured video.
Available values are:
@table @samp
@item auto

This is the default which means 8-bit YUV 422 or 8-bit ARGB if format
autodetection is used, 8-bit YUV 422 otherwise.

@item uyvy422

8-bit YUV 422.

@item yuv422p10

10-bit YUV 422.

@item argb

8-bit RGB.

@item bgra

8-bit RGB.

@item rgb10

10-bit RGB.

@end table

@item teletext_lines
Expand Down Expand Up @@ -335,8 +350,13 @@ Defaults to @samp{unset}.
@item timecode_format
Timecode type to include in the frame and video stream metadata. Must be
@samp{none}, @samp{rp188vitc}, @samp{rp188vitc2}, @samp{rp188ltc},
@samp{rp188any}, @samp{vitc}, @samp{vitc2}, or @samp{serial}. Defaults to
@samp{none} (not included).
@samp{rp188hfr}, @samp{rp188any}, @samp{vitc}, @samp{vitc2}, or @samp{serial}.
Defaults to @samp{none} (not included).

In order to properly support 50/60 fps timecodes, the ordering of the queried
timecode types for @samp{rp188any} is HFR, VITC1, VITC2 and LTC for >30 fps
content. Note that this is slightly different to the ordering used by the
DeckLink API, which is HFR, VITC1, LTC, VITC2.

@item video_input
Sets the video input source. Must be @samp{unset}, @samp{sdi}, @samp{hdmi},
Expand Down Expand Up @@ -398,6 +418,12 @@ are dropped till a frame with timecode is received.
Option @var{timecode_format} must be specified.
Defaults to @option{false}.

@item enable_klv(@emph{bool})
If set to @option{true}, extracts KLV data from VANC and outputs KLV packets.
KLV VANC packets are joined based on MID and PSC fields and aggregated into
one KLV packet.
Defaults to @option{false}.

@end table

@subsection Examples
Expand Down Expand Up @@ -883,11 +909,15 @@ If you don't understand what all of that means, you probably don't want this. L
DRM device to capture on. Defaults to @option{/dev/dri/card0}.

@item format
Pixel format of the framebuffer. Defaults to @option{bgr0}.
Pixel format of the framebuffer. This can be autodetected if you are running Linux 5.7
or later, but needs to be provided for earlier versions. Defaults to @option{bgr0},
which is the most common format used by the Linux console and Xorg X server.

@item format_modifier
Format modifier to signal on output frames. This is necessary to import correctly into
some APIs, but can't be autodetected. See the libdrm documentation for possible values.
some APIs. It can be autodetected if you are running Linux 5.7 or later, but will need
to be provided explicitly when needed in earlier versions. See the libdrm documentation
for possible values.

@item crtc_id
KMS CRTC ID to define the capture source. The first active plane on the given CRTC
Expand Down Expand Up @@ -1478,6 +1508,14 @@ ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0+10,20 out.mpg
@subsection Options

@table @option
@item select_region
Specify whether to select the grabbing area graphically using the pointer.
A value of @code{1} prompts the user to select the grabbing area graphically
by clicking and dragging. A single click with no dragging will select the
whole screen. A region with zero width or height will also select the whole
screen. This option overwrites the @var{video_size}, @var{grab_x}, and
@var{grab_y} options. Default value is @code{0}.

@item draw_mouse
Specify whether to draw the mouse pointer. A value of @code{0} specifies
not to draw the pointer. Default value is @code{1}.
Expand Down Expand Up @@ -1526,8 +1564,21 @@ With @var{follow_mouse}:
ffmpeg -f x11grab -follow_mouse centered -show_region 1 -framerate 25 -video_size cif -i :0.0 out.mpg
@end example

@item window_id
Grab this window, instead of the whole screen. Default value is 0, which maps to
the whole screen (root window).

The id of a window can be found using the @command{xwininfo} program, possibly with options -tree and
-root.

If the window is later enlarged, the new area is not recorded. Video ends when
the window is closed, unmapped (i.e., iconified) or shrunk beyond the video
size (which defaults to the initial window size).

This option disables options @option{follow_mouse} and @option{select_region}.

@item video_size
Set the video frame size. Default is the full desktop.
Set the video frame size. Default is the full desktop or window.

@item grab_x
@item grab_y
Expand Down
3 changes: 1 addition & 2 deletions mythtv/external/FFmpeg/doc/multithreading.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Slice threading -

Frame threading -
* Restrictions with slice threading also apply.
* For best performance, the client should set thread_safe_callbacks if it
provides a thread-safe get_buffer() callback.
* Custom get_buffer2() and get_format() callbacks must be thread-safe.
* There is one frame of delay added for every thread beyond the first one.
Clients must be able to handle this; the pkt_dts and pkt_pts fields in
AVFrame will work as usual.
Expand Down
54 changes: 47 additions & 7 deletions mythtv/external/FFmpeg/doc/muxers.texi
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ specific scenarios, e.g. when merging multiple audio streams into one for
compatibility with software that only supports a single audio stream in AVI
(see @ref{amerge,,the "amerge" section in the ffmpeg-filters manual,ffmpeg-filters}).

@item flipped_raw_rgb
If set to true, store positive height for raw RGB bitmaps, which indicates
bitmap is stored bottom-up. Note that this option does not flip the bitmap
which has to be done manually beforehand, e.g. by using the vflip filter.
Default is @var{false} and indicates bitmap is stored top down.

@end table

@anchor{chromaprint}
Expand Down Expand Up @@ -236,6 +242,8 @@ This is a deprecated option to set the segment length in microseconds, use @var{
@item seg_duration @var{duration}
Set the segment length in seconds (fractional value can be set). The value is
treated as average segment duration when @var{use_template} is enabled and
@var{use_timeline} is disabled and as minimum segment duration for all the other
use cases.
@item frag_duration @var{duration}
Set the length in seconds of fragments within segments (fractional value can be set).
@item frag_type @var{type}
Expand Down Expand Up @@ -267,8 +275,10 @@ Override User-Agent field in HTTP header. Applicable only for HTTP output.
@item http_persistent @var{http_persistent}
Use persistent HTTP connections. Applicable only for HTTP output.
@item hls_playlist @var{hls_playlist}
Generate HLS playlist files as well. The master playlist is generated with the filename master.m3u8.
Generate HLS playlist files as well. The master playlist is generated with the filename @var{hls_master_name}.
One media playlist file is generated for each stream with filenames media_0.m3u8, media_1.m3u8, etc.
@item hls_master_name @var{file_name}
HLS master playlist name. Default is "master.m3u8".
@item streaming @var{streaming}
Enable (1) or disable (0) chunk streaming mode of output. In chunk streaming
mode, each frame will be a moof fragment which forms a chunk.
Expand Down Expand Up @@ -364,6 +374,10 @@ adjusting playback latency and buffer occupancy during normal playback by client
Set the maximum playback rate indicated as appropriate for the purposes of automatically
adjusting playback latency and buffer occupancy during normal playback by clients.

@item update_period @var{update_period}
Set the mpd update period ,for dynamic content.
The unit is second.

@end table

@anchor{framecrc}
Expand Down Expand Up @@ -597,14 +611,21 @@ segmentation.
This muxer supports the following options:

@table @option
@item hls_init_time @var{seconds}
Set the initial target segment length in seconds. Default value is @var{0}.
@item hls_init_time @var{duration}
Set the initial target segment length. Default value is @var{0}.

@var{duration} must be a time duration specification,
see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.

Segment will be cut on the next key frame after this time has passed on the first m3u8 list.
After the initial playlist is filled @command{ffmpeg} will cut segments
at duration equal to @code{hls_time}

@item hls_time @var{seconds}
Set the target segment length in seconds. Default value is 2.
@item hls_time @var{duration}
Set the target segment length. Default value is 2.

@var{duration} must be a time duration specification,
see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
Segment will be cut on the next key frame after this time has passed.

@item hls_list_size @var{size}
Expand Down Expand Up @@ -819,15 +840,15 @@ When enabled every segment generated is encrypted and the encryption key
is saved as @var{playlist name}.key.

@item -hls_enc_key @var{key}
Hex-coded 16byte key to encrypt the segments, by default it
16-octet key to encrypt the segments, by default it
is randomly generated.

@item -hls_enc_key_url @var{keyurl}
If set, @var{keyurl} is prepended instead of @var{baseurl} to the key filename
in the playlist.

@item -hls_enc_iv @var{iv}
Hex-coded 16byte initialization vector for every segment instead
16-octet initialization vector for every segment instead
of the autogenerated ones.

@item hls_segment_type @var{flags}
Expand All @@ -847,6 +868,13 @@ fmp4 files may be used in HLS version 7 and above.
@item hls_fmp4_init_filename @var{filename}
Set filename to the fragment files header file, default filename is @file{init.mp4}.

Use @code{-strftime 1} on @var{filename} to expand the segment filename with localtime.
@example
ffmpeg -i in.nut -hls_segment_type fmp4 -strftime 1 -hls_fmp4_init_filename "%s_init.mp4" out.m3u8
@end example
This will produce init like this
@file{1602678741_init.mp4}

@item hls_fmp4_init_resend
Resend init file after m3u8 file refresh every time, default is @var{0}.

Expand Down Expand Up @@ -1407,6 +1435,13 @@ disposition default exists, no subtitle track will be marked as default.
In this mode the FlagDefault is set if and only if the AV_DISPOSITION_DEFAULT
flag is set in the disposition of the corresponding stream.
@end table

@item flipped_raw_rgb
If set to true, store positive height for raw RGB bitmaps, which indicates
bitmap is stored bottom-up. Note that this option does not flip the bitmap
which has to be done manually beforehand, e.g. by using the vflip filter.
Default is @var{false} and indicates bitmap is stored top down.

@end table

@anchor{md5}
Expand Down Expand Up @@ -2275,6 +2310,11 @@ certain (usually permanent) errors the recovery is not attempted even when
Specify whether to wait for the keyframe after recovering from
queue overflow or failure. This option is set to 0 (false) by default.

@item timeshift @var{duration}
Buffer the specified amount of packets and delay writing the output. Note that
@var{queue_size} must be big enough to store the packets for timeshift. At the
end of the input the fifo buffer is flushed at realtime speed.

@end table

@subsection Examples
Expand Down
46 changes: 46 additions & 0 deletions mythtv/external/FFmpeg/doc/outdevs.texi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,52 @@ ffmpeg -i INPUT -f alsa hw:1,7
@end example
@end itemize

@section AudioToolbox

AudioToolbox output device.

Allows native output to CoreAudio devices on OSX.

The output filename can be empty (or @code{-}) to refer to the default system output device or a number that refers to the device index as shown using: @code{-list_devices true}.

Alternatively, the audio input device can be chosen by index using the
@option{
-audio_device_index <INDEX>
}
, overriding any device name or index given in the input filename.

All available devices can be enumerated by using @option{-list_devices true}, listing
all device names, UIDs and corresponding indices.

@subsection Options

AudioToolbox supports the following options:

@table @option

@item -audio_device_index <INDEX>
Specify the audio device by its index. Overrides anything given in the output filename.

@end table

@subsection Examples

@itemize

@item
Print the list of supported devices and output a sine wave to the default device:
@example
$ ffmpeg -f lavfi -i sine=r=44100 -f audiotoolbox -list_devices true -
@end example

@item
Output a sine wave to the device with the index 2, overriding any output filename:
@example
$ ffmpeg -f lavfi -i sine=r=44100 -f audiotoolbox -audio_device_index 2 -
@end example

@end itemize

@section caca

CACA output device.
Expand Down
126 changes: 116 additions & 10 deletions mythtv/external/FFmpeg/doc/protocols.texi
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ After starting the broker, an FFmpeg client may stream data to the broker using
the command:

@example
ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port]
ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port][/vhost]
@end example

Where hostname and port (default is 5672) is the address of the broker. The
client may also set a user/password for authentication. The default for both
fields is "guest".
fields is "guest". Name of virtual host on broker can be set with vhost. The
default value is "/".

Muliple subscribers may stream from the broker using the command:
@example
ffplay amqp://[[user]:[password]@@]hostname[:port]
ffplay amqp://[[user]:[password]@@]hostname[:port][/vhost]
@end example

In RabbitMQ all data published to the broker flows through a specific exchange,
Expand Down Expand Up @@ -109,6 +110,21 @@ the received message may be truncated causing decoding errors.
The timeout in seconds during the initial connection to the broker. The
default value is rw_timeout, or 5 seconds if rw_timeout is not set.

@item delivery_mode @var{mode}
Sets the delivery mode of each message sent to broker.
The following values are accepted:
@table @samp
@item persistent
Delivery mode set to "persistent" (2). This is the default value.
Messages may be written to the broker's disk depending on its setup.

@item non-persistent
Delivery mode set to "non-persistent" (1).
Messages will stay in broker's memory unless the broker is under memory
pressure.

@end table

@end table

@section async
Expand Down Expand Up @@ -159,6 +175,16 @@ Caching wrapper for input stream.

Cache the input stream to temporary file. It brings seeking capability to live streams.

The accepted options are:
@table @option

@item read_ahead_limit
Amount in bytes that may be read ahead when seeking isn't supported. Range is -1 to INT_MAX.
-1 for unlimited. Default is 65536.

@end table

URL Syntax is
@example
cache:@var{URL}
@end example
Expand Down Expand Up @@ -315,6 +341,12 @@ operation. ff* tools may produce incomplete content due to server limitations.

Gopher protocol.

@section gophers

Gophers protocol.

The Gopher protocol with TLS encapsulation.

@section hls

Read Apple HTTP Live Streaming compliant segmented stream as
Expand Down Expand Up @@ -377,18 +409,20 @@ string describing the libavformat build. ("Lavf/<version>")
@item user-agent
This is a deprecated option, you can use user_agent instead it.

@item timeout
Set timeout in microseconds of socket I/O operations used by the underlying low level
operation. By default it is set to -1, which means that the timeout is
not specified.

@item reconnect_at_eof
If set then eof is treated like an error and causes reconnection, this is useful
for live / endless streams.

@item reconnect_streamed
If set then even streamed/non seekable streams will be reconnected on errors.

@item reconnect_on_network_error
Reconnect automatically in case of TCP/TLS errors during connect.

@item reconnect_on_http_error
A comma separated list of HTTP status codes to reconnect on. The list can
include specific status codes (e.g. '503') or the strings '4xx' / '5xx'.

@item reconnect_delay_max
Sets the maximum delay in seconds after which to give up reconnecting

Expand Down Expand Up @@ -466,6 +500,28 @@ Send an Expect: 100-continue header for POST. If set to 1 it will send, if set
to 0 it won't, if set to -1 it will try to send if it is applicable. Default
value is -1.

@item auth_type

Set HTTP authentication type. No option for Digest, since this method requires
getting nonce parameters from the server first and can't be used straight away like
Basic.

@table @option
@item none
Choose the HTTP authentication type automatically. This is the default.
@item basic

Choose the HTTP basic authentication.

Basic authentication sends a Base64-encoded string that contains a user name and password
for the client. Base64 is not a form of encryption and should be considered the same as
sending the user name and password in clear text (Base64 is a reversible encoding).
If a resource needs to be protected, strongly consider using an authentication scheme
other than basic authentication. HTTPS/TLS should be used with basic authentication.
Without these additional security enhancements, basic authentication should not be used
to protect sensitive or valuable information.
@end table

@end table

@subsection HTTP Cookies
Expand Down Expand Up @@ -520,6 +576,9 @@ audio/mpeg.
This enables support for Icecast versions < 2.4.0, that do not support the
HTTP PUT method but the SOURCE method.

@item tls
Establish a TLS (HTTPS) connection to Icecast.

@end table

@example
Expand Down Expand Up @@ -637,6 +696,42 @@ Example usage:
-f rtp_mpegts -fec prompeg=l=8:d=4 rtp://@var{hostname}:@var{port}
@end example

@section rist

Reliable Internet Streaming Transport protocol

The accepted options are:
@table @option
@item rist_profile
Supported values:
@table @samp
@item simple
@item main
This one is default.
@item advanced
@end table

@item buffer_size
Set internal RIST buffer size in milliseconds for retransmission of data.
Default value is 0 which means the librist default (1 sec). Maximum value is 30
seconds.

@item pkt_size
Set maximum packet size for sending data. 1316 by default.

@item log_level
Set loglevel for RIST logging messages. You only need to set this if you
explicitly want to enable debug level messages or packet loss simulation,
otherwise the regular loglevel is respected.

@item secret
Set override of encryption secret, by default is unset.

@item encryption
Set encryption type, by default is disabled.
Acceptable values are 128 and 256.
@end table

@section rtmp

Real-Time Messaging Protocol.
Expand Down Expand Up @@ -938,6 +1033,9 @@ Set the local RTCP port to @var{n}.
@item pkt_size=@var{n}
Set max packet size (in bytes) to @var{n}.

@item buffer_size=@var{size}
Set the maximum UDP socket buffer size in bytes.

@item connect=0|1
Do a @code{connect()} on the UDP socket (if set to 1) or not (if set
to 0).
Expand All @@ -955,6 +1053,9 @@ set to 1) or to a default remote address (if set to 0).
@item localport=@var{n}
Set the local RTP port to @var{n}.

@item timeout=@var{n}
Set timeout (in microseconds) of socket I/O operations to @var{n}.

This is a deprecated option. Instead, @option{localrtpport} should be
used.

Expand Down Expand Up @@ -1596,8 +1697,9 @@ tcp://@var{hostname}:@var{port}[?@var{options}]
The list of supported options follows.

@table @option
@item listen=@var{1|0}
Listen for an incoming connection. Default value is 0.
@item listen=@var{2|1|0}
Listen for an incoming connection. 0 disables listen, 1 enables listen in
single client mode, 2 enables listen in multi-client mode. Default value is 0.

@item timeout=@var{microseconds}
Set raise error timeout, expressed in microseconds.
Expand Down Expand Up @@ -1673,6 +1775,10 @@ A file containing the private key for the certificate.
If enabled, listen for connections on the provided port, and assume
the server role in the handshake instead of the client role.

@item http_proxy
The HTTP proxy to tunnel through, e.g. @code{http://example.com:1234}.
The proxy must support the CONNECT method.

@end table

Example command lines:
Expand Down
9 changes: 9 additions & 0 deletions mythtv/external/FFmpeg/doc/texi2pod.pl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@
} elsif ($ended =~ /^(?:itemize|enumerate|(?:multi|[fv])?table)$/) {
$_ = "\n=back\n";
$ic = pop @icstack;
} elsif ($ended =~ /^float$/) {
$_ = "\n=back\n";
$ic = pop @icstack;
} else {
die "unknown command \@end $ended at line $.\n";
}
Expand Down Expand Up @@ -297,6 +300,12 @@
$_ = ""; # need a paragraph break
};

/^\@(float)\s+\w+/ and do {
push @endwstack, $endw;
$endw = $1;
$_ = "\n=over 4\n";
};

/^\@item\s+(.*\S)\s*$/ and $endw eq "multitable" and do {
my $columns = $1;
$columns =~ s/\@tab/ : /;
Expand Down
6 changes: 4 additions & 2 deletions mythtv/external/FFmpeg/doc/utils.texi
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ maximum of 2 digits. The @var{m} at the end expresses decimal value for
@emph{or}

@example
[-]@var{S}+[.@var{m}...]
[-]@var{S}+[.@var{m}...][s|ms|us]
@end example

@var{S} expresses the number of seconds, with the optional decimal part
@var{m}.
@var{m}. The optional literal suffixes @samp{s}, @samp{ms} or @samp{us}
indicate to interpret the value as seconds, milliseconds or microseconds,
respectively.

In both expressions, the optional @samp{-} indicates negative duration.

Expand Down
2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/doc/writing_filters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,4 @@ done:

When all of this is done, you can submit your patch to the ffmpeg-devel
mailing-list for review. If you need any help, feel free to come on our IRC
channel, #ffmpeg-devel on irc.freenode.net.
channel, #ffmpeg-devel on irc.libera.chat.
14 changes: 11 additions & 3 deletions mythtv/external/FFmpeg/ffbuild/common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)

define COMPILE
$(call $(1)DEP,$(1))
$($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
$($(1)) $($(1)FLAGS) $($(2)) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<)
endef

COMPILE_C = $(call COMPILE,CC)
Expand All @@ -54,6 +54,14 @@ COMPILE_M = $(call COMPILE,OBJCC)
COMPILE_X86ASM = $(call COMPILE,X86ASM)
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
COMPILE_NVCC = $(call COMPILE,NVCC)
COMPILE_MMI = $(call COMPILE,CC,MMIFLAGS)
COMPILE_MSA = $(call COMPILE,CC,MSAFLAGS)

%_mmi.o: %_mmi.c
$(COMPILE_MMI)

%_msa.o: %_msa.c
$(COMPILE_MSA)

%.o: %.c
$(COMPILE_C)
Expand Down Expand Up @@ -82,7 +90,7 @@ COMPILE_NVCC = $(call COMPILE,NVCC)
-$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@)

%.o: %.rc
$(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $<
$(WINDRES) $(IFLAGS) $(foreach ARG,$(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $<

%.i: %.c
$(CC) $(CCFLAGS) $(CC_E) $<
Expand All @@ -99,7 +107,7 @@ COMPILE_NVCC = $(call COMPILE,NVCC)
%.c %.h %.pc %.ver %.version: TAG = GEN

# Dummy rule to stop make trying to rebuild removed or renamed headers
%.h:
%.h %_template.c:
@:

# Disable suffix rules. Most of the builtin rules are suffix rules,
Expand Down
32 changes: 16 additions & 16 deletions mythtv/external/FFmpeg/fftools/cmdutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,22 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,

void show_help_children(const AVClass *class, int flags)
{
const AVClass *child = NULL;
void *iter = NULL;
const AVClass *child;
if (class->option) {
av_opt_show2(&class, NULL, flags, 0);
printf("\n");
}

while (child = av_opt_child_class_next(class, child))
while (child = av_opt_child_class_iterate(class, &iter))
show_help_children(child, flags);
}

static const OptionDef *find_option(const OptionDef *po, const char *name)
{
const char *p = strchr(name, ':');
int len = p ? p - name : strlen(name);

while (po->name) {
if (!strncmp(name, po->name, len) && strlen(po->name) == len)
const char *end;
if (av_strstart(name, po->name, &end) && (!*end || *end == ':'))
break;
po++;
}
Expand Down Expand Up @@ -1164,13 +1163,13 @@ static void print_buildconf(int flags, int level)
// Change all the ' --' strings to '~--' so that
// they can be identified as tokens.
while ((conflist = strstr(str, " --")) != NULL) {
strncpy(conflist, "~--", 3);
conflist[0] = '~';
}

// Compensate for the weirdness this would cause
// when passing 'pkg-config --static'.
while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) {
strncpy(remove_tilde, "pkg-config ", 11);
remove_tilde[sizeof("pkg-config~") - 2] = ' ';
}

splitconf = strtok(str, "~");
Expand Down Expand Up @@ -1416,7 +1415,7 @@ static void print_codec(const AVCodec *c)
printf("variable ");
if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_AUTO_THREADS))
AV_CODEC_CAP_OTHER_THREADS))
printf("threads ");
if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
printf("avoidprobe ");
Expand All @@ -1433,12 +1432,12 @@ static void print_codec(const AVCodec *c)
printf(" Threading capabilities: ");
switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_AUTO_THREADS)) {
AV_CODEC_CAP_OTHER_THREADS)) {
case AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break;
case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break;
case AV_CODEC_CAP_AUTO_THREADS : printf("auto"); break;
case AV_CODEC_CAP_OTHER_THREADS: printf("other"); break;
default: printf("none"); break;
}
printf("\n");
Expand Down Expand Up @@ -2102,7 +2101,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
}

AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
AVFormatContext *s, AVStream *st, AVCodec *codec)
AVFormatContext *s, AVStream *st, const AVCodec *codec)
{
AVDictionary *ret = NULL;
AVDictionaryEntry *t = NULL;
Expand Down Expand Up @@ -2131,6 +2130,7 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
}

while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) {
const AVClass *priv_class;
char *p = strchr(t->key, ':');

/* check stream specification in opt name */
Expand All @@ -2143,8 +2143,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,

if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) ||
!codec ||
(codec->priv_class &&
av_opt_find(&codec->priv_class, t->key, NULL, flags,
((priv_class = codec->priv_class) &&
av_opt_find(&priv_class, t->key, NULL, flags,
AV_OPT_SEARCH_FAKE_OBJ)))
av_dict_set(&ret, t->key, t->value, 0);
else if (t->key[0] == prefix &&
Expand Down Expand Up @@ -2307,7 +2307,7 @@ int show_sources(void *optctx, const char *opt, const char *arg)
int ret = 0;
int error_level = av_log_get_level();

av_log_set_level(AV_LOG_ERROR);
av_log_set_level(AV_LOG_WARNING);

if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
goto fail;
Expand Down Expand Up @@ -2345,7 +2345,7 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
int ret = 0;
int error_level = av_log_get_level();

av_log_set_level(AV_LOG_ERROR);
av_log_set_level(AV_LOG_WARNING);

if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
goto fail;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/external/FFmpeg/fftools/cmdutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
* @return a pointer to the created dictionary
*/
AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
AVFormatContext *s, AVStream *st, AVCodec *codec);
AVFormatContext *s, AVStream *st, const AVCodec *codec);

/**
* Setup AVCodecContext options for avformat_find_stream_info().
Expand Down
Loading