Go to the documentation of this file.
133 .parent_log_context_offset = offsetof(
DecoderPriv, log_parent),
193 if (prev / gcd >= INT_MAX / sr) {
195 "Audio timestamps cannot be represented exactly after "
196 "sample rate change: %d -> %d\n", prev, sr);
284 if (codec_duration > 0 && ts_unreliable)
285 return codec_duration;
296 if (codec_duration > 0)
297 return codec_duration;
332 "output frame: %d.\n", err);
389 "decoder -> pts:%s pts_time:%s "
390 "pkt_dts:%s pkt_dts_time:%s "
391 "duration:%s duration_time:%s "
392 "keyframe:%d frame_type:%d time_base:%d/%d\n",
413 .format =
src->format,
414 .start_display_time =
src->start_display_time,
415 .end_display_time =
src->end_display_time,
427 for (
int i = 0;
i <
src->num_rects;
i++) {
441 dst_rect->
x = src_rect->
x;
442 dst_rect->
y = src_rect->
y;
443 dst_rect->
w = src_rect->
w;
444 dst_rect->
h = src_rect->
h;
459 for (
int j = 0; j < 4; j++) {
467 if (!src_rect->
data[j])
510 sub =
av_memdup(subtitle,
sizeof(*subtitle));
513 memset(subtitle, 0,
sizeof(*subtitle));
541 if (end < sub_prev->end_display_time) {
543 "Subtitle duration reduced from %"PRId32
" to %d%s\n",
545 end <= 0 ?
", dropping it" :
"");
580 !prev_subtitle->
num_rects || signal_pts <= prev_subtitle->
pts)
589 subtitle->pts = signal_pts;
685 "This is a bug, please report it.\n");
714 }
else if (
ret < 0) {
726 "corrupt decoded frame\n");
753 "Error while processing the decoded data\n");
784 memset(&o, 0,
sizeof(o));
808 char name[16] =
"dec";
826 memset(dt, 0,
sizeof(*dt));
831 memset(dt, 0,
sizeof(*dt));
852 int ret = 0, input_status = 0;
860 while (!input_status) {
861 int flush_buffers, have_data;
864 have_data = input_status >= 0 &&
868 flush_buffers = input_status >= 0 && !have_data;
871 flush_buffers ?
"flush" :
"EOF");
877 if (input_status < 0) {
879 "Cannot initialize a standalone decoder\n");
904 flush_buffers ?
"resetting" :
"finishing");
916 }
else if (
ret < 0) {
976 for (
int i = 0;;
i++) {
983 if (
config->pix_fmt == *p)
1000 for (
int i = 0;;
i++) {
1014 const char *hwaccel_device)
1019 int err, auto_device = 0;
1021 if (hwaccel_device) {
1040 "specified for decoder: device %s of type %s is not "
1041 "usable with hwaccel %s.\n", dev->
name,
1082 for (
int i = 0; !dev;
i++) {
1090 "hwaccel type %s with existing device %s.\n",
1094 for (
int i = 0; !dev;
i++) {
1106 if (hwaccel_device) {
1108 "hwaccel type %s with new device created "
1113 "hwaccel type %s with new default device.\n",
1121 "disabled: no device found.\n");
1129 "for decoder: device type %s needed for codec %s.\n",
1199 "Hardware device setup failed for decoder: %s\n",
1284 int of_index, ost_index;
1304 of_index = strtol(
arg, &p, 0);
1311 ost_index = strtol(p + 1,
NULL, 0);
1312 if (ost_index < 0 || ost_index >= of->
nb_streams) {
const uint8_t * subtitle_header
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
@ AV_ROUND_UP
Round toward +infinity.
AVCodecParameters * par_enc
static int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src)
static int fix_sub_duration_heartbeat(DecoderPriv *dp, int64_t signal_pts)
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
AVPixelFormat
Pixel format.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
int dec_filter_add(Decoder *d, InputFilter *ifilter, InputFilterOptions *opts)
static const AVClass dec_class
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
Callback to negotiate the pixel format.
enum AVColorSpace colorspace
YUV colorspace type.
int sample_rate
samples per second
int64_t last_frame_duration_est
static AVRational audio_samplerate_update(DecoderPriv *dp, const AVFrame *frame)
@ DECODER_FLAG_SEND_END_TS
int64_t duration
Duration of the frame, in the same units as pts.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
static void dec_thread_uninit(DecThreadContext *dt)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static int dec_alloc(DecoderPriv **pdec, Scheduler *sch, int send_end_ts)
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
static HWDevice * hw_device_match_by_codec(const AVCodec *codec)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void * opaque
Frame owner's private data.
enum AVColorSpace colorspace
YUV colorspace type.
This structure describes decoded (raw) audio or video data.
static av_cold void cleanup(FlashSV2Context *s)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
@ DECODER_FLAG_FRAMERATE_FORCED
const AVCodecParameters * par
static const char * dec_item_name(void *obj)
static int dec_thread_init(DecThreadContext *dt)
enum AVHWDeviceType hwaccel_device_type
enum AVPixelFormat hwaccel_output_format
enum HWAccelID hwaccel_id
uint8_t * subtitle_header
#define AV_LOG_VERBOSE
Detailed information.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
enum HWAccelID hwaccel_id
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int enc_loopback(Encoder *enc)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void dec_free(Decoder **pdec)
#define DEFAULT_FRAME_THREAD_QUEUE_SIZE
Default size of a frame thread queue.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
enum AVPixelFormat hwaccel_output_format
@ FRAME_OPAQUE_SUB_HEARTBEAT
const struct AVCodec * codec
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
AVChannelLayout ch_layout
Audio channel layout.
int sch_dec_send(Scheduler *sch, unsigned dec_idx, AVFrame *frame)
Called by decoder tasks to send a decoded frame downstream.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts)
int x
top left corner of pict, undefined when pict is not set
void update_benchmark(const char *fmt,...)
AVChannelLayout ch_layout
Channel layout of the audio data.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
char * ass
0 terminated ASS/SSA compatible event line.
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Decode a subtitle message.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int dec_create(const OptionsContext *o, const char *arg, Scheduler *sch)
Create a standalone decoder.
static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
#define FF_ARRAY_ELEMS(a)
AVDictionary * codec_opts
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
This struct describes the properties of a single codec described by an AVCodecID.
AVRational sample_aspect_ratio
Video only.
static int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy)
int y
top left corner of pict, undefined when pict is not set
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static enum AVPixelFormat pix_fmts[]
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int64_t pts
Same as packet pts, in AV_TIME_BASE.
int64_t last_filter_in_rescale_delta
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
void * opaque
for some private data of the user
char * text
0 terminated plain UTF-8 text
int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb)
Rescale a timestamp while preserving known durations.
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the then the processing requires a frame on this link and the filter is expected to make efforts in that direction The status of input links is stored by the fifo and status_out fields
static void audio_ts_process(DecoderPriv *dp, AVFrame *frame)
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int avcodec_parameters_to_context(AVCodecContext *codec, const struct AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
int w
width of pict, undefined when pict is not set
static int hw_device_setup_for_decode(DecoderPriv *dp, const AVCodec *codec, const char *hwaccel_device)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define AV_DICT_MULTIKEY
Allow to store several equal keys in the dictionary.
static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, const DecoderOpts *o, AVFrame *param_out)
static void dec_thread_set_name(const DecoderPriv *dp)
int hw_device_init_from_type(enum AVHWDeviceType type, const char *device, HWDevice **dev_out)
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Rational number (pair of numerator and denominator).
static int transcode_subtitles(DecoderPriv *dp, const AVPacket *pkt, AVFrame *frame)
int subtitle_header_size
Header containing style information for text subtitles.
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
int sch_add_dec(Scheduler *sch, SchThreadFunc func, void *ctx, int send_end_ts)
Add a decoder to the scheduler.
int64_t wallclock[LATENCY_PROBE_NB]
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
enum AVPixelFormat hwaccel_pix_fmt
@ DECODER_FLAG_FIX_SUB_DURATION
int last_frame_sample_rate
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base
enum AVPictureType pict_type
Picture type of the frame.
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static void copy(const float *p1, float *p2, const int length)
int extra_hw_frames
Video decoding only.
int dec_init(Decoder **pdec, Scheduler *sch, AVDictionary **dec_opts, const DecoderOpts *o, AVFrame *param_out)
OutputFile ** output_files
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int sample_rate
Sample rate of the audio data.
enum AVSampleFormat sample_fmt
audio sample format
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int check_avoptions(AVDictionary *m)
AVRational time_base
Time base for the timestamps in this frame.
HWDevice * hw_device_get_by_type(enum AVHWDeviceType type)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
uint32_t end_display_time
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
static int video_frame_process(DecoderPriv *dp, AVFrame *frame)
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
#define AV_LOG_INFO
Standard information.
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
int nb_samples
number of audio samples (per channel) described by this frame
static int64_t video_duration_estimate(const DecoderPriv *dp, const AVFrame *frame)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int process_subtitle(DecoderPriv *dp, AVFrame *frame)
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
int nb_colors
number of colors in pict, undefined when pict is not set
SpecifierOptList codec_names
#define AV_TIME_BASE
Internal time base represented as integer.
static int packet_decode(DecoderPriv *dp, AVPacket *pkt, AVFrame *frame)
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * av_calloc(size_t nmemb, size_t size)
int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst)
int64_t frame_num
Frame counter, set by libavcodec.
int decode_error_flags
decode error flags of the frame, set to a combination of FF_DECODE_ERROR_xxx flags if the decoder pro...
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
int h
height of pict, undefined when pict is not set
int sch_dec_receive(Scheduler *sch, unsigned dec_idx, AVPacket *pkt)
Called by decoder tasks to receive a packet for decoding.
#define FFSWAP(type, a, b)
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
void * opaque
Private data of the user, can be used to carry app specific stuff.
@ DECODER_FLAG_TOP_FIELD_FIRST
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
main external API structure.
@ PKT_OPAQUE_SUB_HEARTBEAT
static DecoderPriv * dp_from_dec(Decoder *d)
static char * output_format
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define GROW_ARRAY(array, nb_elems)
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate a string.
A reference to a data buffer.
@ DECODER_FLAG_TS_UNRELIABLE
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int decoder_thread(void *arg)
#define FFMPEG_ERROR_RATE_EXCEEDED
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
FrameData * packet_data(AVPacket *pkt)
int width
picture width / height.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static void subtitle_free(void *opaque, uint8_t *data)
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
HWDevice * hw_device_get_by_name(const char *name)
@ PKT_OPAQUE_FIX_SUB_DURATION
struct DecoderPriv::@5 standalone_init
enum AVHWDeviceType hwaccel_device_type
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
int repeat_pict
Number of fields in this frame which should be repeated, i.e.
AVRational time_base
Time base of the packet's timestamps.
static int dec_standalone_open(DecoderPriv *dp, const AVPacket *pkt)
static int ff_thread_setname(const char *name)