Go to the documentation of this file.
158 "Failed to inject frame into filter network: %s\n",
av_err2str(
ret));
168 const int prev =
d->last_frame_tb.den;
179 if (prev / gcd >= INT_MAX / sr) {
181 "Audio timestamps cannot be represented exactly after "
182 "sample rate change: %d -> %d\n", prev, sr);
197 d->last_frame_tb, tb_new);
198 d->last_frame_duration_est =
av_rescale_q(
d->last_frame_duration_est,
199 d->last_frame_tb, tb_new);
201 d->last_frame_tb = tb_new;
205 return d->last_frame_tb;
219 d->last_frame_pts +
d->last_frame_duration_est;
233 &
d->last_filter_in_rescale_delta,
tb);
249 int64_t codec_duration = 0;
271 return codec_duration;
282 if (codec_duration > 0)
283 return codec_duration;
294 return FFMAX(
d->last_frame_duration_est, 1);
308 "video_delay is larger in decoder than demuxer %d > %d.\n"
309 "If you want to help, upload a sample "
310 "of this file to https://streams.videolan.org/upload/ "
311 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n",
353 d->last_frame_pts +
d->last_frame_duration_est;
362 "decoder -> pts:%s pts_time:%s "
363 "pkt_dts:%s pkt_dts_time:%s "
364 "duration:%s duration_time:%s "
365 "keyframe:%d frame_type:%d time_base:%d/%d\n",
404 if (end < sub_prev->end_display_time) {
406 "Subtitle duration reduced from %"PRId32
" to %d%s\n",
408 end <= 0 ?
", dropping it" :
"");
441 for (
int oidx = 0; oidx < ist->
nb_outputs; oidx++) {
458 AVSubtitle *prev_subtitle =
d->sub_prev[0]->buf[0] ?
463 !prev_subtitle->
num_rects || signal_pts <= prev_subtitle->
pts)
471 subtitle = (
AVSubtitle*)
d->sub_heartbeat->buf[0]->data;
472 subtitle->pts = signal_pts;
535 d->last_frame_pts +
d->last_frame_duration_est;
571 "This is a bug, please report it.\n");
601 }
else if (
ret < 0) {
613 "corrupt decoded frame\n");
667 memset(dt, 0,
sizeof(*dt));
672 memset(dt, 0,
sizeof(*dt));
695 int ret = 0, input_status = 0;
703 while (!input_status) {
704 int dummy, flush_buffers;
707 flush_buffers = input_status >= 0 && !dt.
pkt->
buf;
710 flush_buffers ?
"flush" :
"EOF");
719 flush_buffers ?
"resetting" :
"finishing");
737 }
else if (
ret < 0) {
769 return (
void*)(intptr_t)
ret;
775 int ret = 0, thread_ret;
806 if (!
d->frame->buf[0])
822 if (thread_ret < 0) {
912 if (
config->pix_fmt == *p)
917 d->hwaccel_pix_fmt = *p;
947 int err, auto_device = 0;
968 "specified for decoder: device %s of type %s is not "
969 "usable with hwaccel %s.\n", dev->
name,
1011 for (
i = 0; !dev;
i++) {
1019 "hwaccel type %s with existing device %s.\n",
1023 for (
i = 0; !dev;
i++) {
1037 "hwaccel type %s with new device created "
1042 "hwaccel type %s with new default device.\n",
1050 "disabled: no device found.\n");
1058 "for decoder: device type %s needed for codec %s.\n",
1078 "Decoding requested, but no decoder found for: %s\n",
1091 if (!
d->sub_prev[
i])
1095 if (!
d->sub_heartbeat)
1106 av_log(
NULL,
AV_LOG_WARNING,
"Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n");
1122 "Hardware device setup failed for decoder: %s\n",
static int process_subtitle(InputStream *ist, AVFrame *frame)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
static int send_filter_eof(InputStream *ist)
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
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.
static AVRational audio_samplerate_update(void *logctx, Decoder *d, const AVFrame *frame)
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)
static void audio_ts_process(void *logctx, Decoder *d, AVFrame *frame)
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.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int dec_thread_init(DecThreadContext *dt)
AVRational avg_frame_rate
Average framerate.
void objpool_free(ObjPool **pop)
#define AV_LOG_VERBOSE
Detailed information.
static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *frame)
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
ObjPool * objpool_alloc_packets(void)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
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)
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
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.
AVBufferRef * opaque_ref
Frame owner's private data.
static int hw_device_setup_for_decode(InputStream *ist)
const struct AVCodec * codec
#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)
void update_benchmark(const char *fmt,...)
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
@ AV_ROUND_UP
Round toward +infinity.
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
static int dec_alloc(Decoder **pdec)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
@ AV_CODEC_ID_DVB_SUBTITLE
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Decode a subtitle message.
int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
int av_thread_message_queue_send(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Send a message on the queue.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
Submit a packet for decoding.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int last_frame_sample_rate
ThreadQueue * queue_in
Queue for sending coded packets from the main thread to the decoder thread.
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy)
int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
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.
static void dec_thread_set_name(const InputStream *ist)
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.
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
ObjPool * objpool_alloc_frames(void)
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.
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
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
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
void tq_free(ThreadQueue **ptq)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
void tq_receive_finish(ThreadQueue *tq, unsigned int stream_idx)
Mark the given stream finished from the receiving side.
int hw_device_init_from_type(enum AVHWDeviceType type, const char *device, HWDevice **dev_out)
Rational number (pair of numerator and denominator).
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
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.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
static void frame_move(void *dst, void *src)
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base
int tq_send(ThreadQueue *tq, unsigned int stream_idx, void *data)
Send an item for the given stream to the queue.
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...
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.
int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference)
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)
int dec_open(InputStream *ist)
AVRational time_base
Time base for the timestamps in this frame.
HWDevice * hw_device_get_by_type(enum AVHWDeviceType type)
static void * decoder_thread(void *arg)
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.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
uint32_t end_display_time
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts)
static void pkt_move(void *dst, void *src)
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
ThreadQueue * tq_alloc(unsigned int nb_streams, size_t queue_size, ObjPool *obj_pool, void(*obj_move)(void *dst, void *src))
Allocate a queue for sending data between threads.
static int dec_thread_stop(Decoder *d)
#define AV_LOG_INFO
Standard information.
static void sub2video_flush(InputStream *ist)
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
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
#define DECODING_FOR_FILTER
#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...
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
#define AV_TIME_BASE
Internal time base represented as integer.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
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...
int64_t last_frame_duration_est
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.
int tq_receive(ThreadQueue *tq, int *stream_idx, void *data)
Read the next item from the queue.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int transcode_subtitles(InputStream *ist, const AVPacket *pkt, AVFrame *frame)
int64_t frame_num
Frame counter, set by libavcodec.
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
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.
#define FFSWAP(type, a, b)
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
void * opaque
Private data of the user, can be used to carry app specific stuff.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
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.
static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
static int video_frame_process(InputStream *ist, AVFrame *frame)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb)
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
enum AVMediaType codec_type
int video_delay
Video only.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int64_t last_filter_in_rescale_delta
This structure stores compressed data.
int ifilter_sub2video(InputFilter *ifilter, const AVFrame *frame)
ThreadQueue * queue_out
Queue for sending decoded frames from the decoder thread to the main thread.
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 width
picture width / height.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
#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...
static int err_merge(int err0, int err1)
Merge two return codes - return one of the error codes if at least one of them was negative,...
static int dec_thread_start(InputStream *ist)
HWDevice * hw_device_get_by_name(const char *name)
enum AVPixelFormat hwaccel_pix_fmt
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.
static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
static int ff_thread_setname(const char *name)
void tq_send_finish(ThreadQueue *tq, unsigned int stream_idx)
Mark the given stream finished from the sending side.