FFmpeg
|
#include <stdint.h>
#include <string.h>
#include "config.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/emms.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "avcodec.h"
#include "avcodec_internal.h"
#include "bytestream.h"
#include "bsf.h"
#include "codec_desc.h"
#include "codec_internal.h"
#include "decode.h"
#include "hwaccel_internal.h"
#include "hwconfig.h"
#include "internal.h"
#include "packet_internal.h"
#include "refstruct.h"
#include "thread.h"
Go to the source code of this file.
Data Structures | |
struct | DecodeContext |
Macros | |
#define | UTF8_MAX_BYTES 4 /* 5 and 6 bytes sequences should not be used */ |
Functions | |
static DecodeContext * | decode_ctx (AVCodecInternal *avci) |
static int | apply_param_change (AVCodecContext *avctx, const AVPacket *avpkt) |
static int | extract_packet_props (AVCodecInternal *avci, const AVPacket *pkt) |
static int | decode_bsfs_init (AVCodecContext *avctx) |
static int | decode_get_packet (AVCodecContext *avctx, AVPacket *pkt) |
int | ff_decode_get_packet (AVCodecContext *avctx, AVPacket *pkt) |
Called by decoders to get the next packet for decoding. More... | |
static int64_t | guess_correct_pts (AVCodecContext *ctx, int64_t reordered_pts, int64_t dts) |
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect times. More... | |
static int | discard_samples (AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples) |
static int | decode_simple_internal (AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples) |
static int | detect_colorspace (av_unused AVCodecContext *c, av_unused AVFrame *f) |
static int | fill_frame_props (const AVCodecContext *avctx, AVFrame *frame) |
static int | decode_simple_receive_frame (AVCodecContext *avctx, AVFrame *frame) |
static int | decode_receive_frame_internal (AVCodecContext *avctx, AVFrame *frame) |
int attribute_align_arg | avcodec_send_packet (AVCodecContext *avctx, const AVPacket *avpkt) |
Supply raw packet data as input to a decoder. More... | |
static int | apply_cropping (AVCodecContext *avctx, AVFrame *frame) |
static int | frame_validate (AVCodecContext *avctx, AVFrame *frame) |
int | ff_decode_receive_frame (AVCodecContext *avctx, AVFrame *frame) |
avcodec_receive_frame() implementation for decoders. More... | |
static void | get_subtitle_defaults (AVSubtitle *sub) |
static int | recode_subtitle (AVCodecContext *avctx, const AVPacket **outpkt, const AVPacket *inpkt, AVPacket *buf_pkt) |
static int | utf8_check (const uint8_t *str) |
int | avcodec_decode_subtitle2 (AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt) |
Decode a subtitle message. More... | |
enum AVPixelFormat | avcodec_default_get_format (struct AVCodecContext *avctx, const enum AVPixelFormat *fmt) |
int | ff_decode_get_hw_frames_ctx (AVCodecContext *avctx, enum AVHWDeviceType dev_type) |
Make sure avctx.hw_frames_ctx is set. More... | |
int | avcodec_get_hw_frames_parameters (AVCodecContext *avctx, AVBufferRef *device_ref, enum AVPixelFormat hw_pix_fmt, AVBufferRef **out_frames_ref) |
Create and return a AVHWFramesContext with values adequate for hardware decoding. More... | |
static int | hwaccel_init (AVCodecContext *avctx, const FFHWAccel *hwaccel) |
void | ff_hwaccel_uninit (AVCodecContext *avctx) |
int | ff_get_format (AVCodecContext *avctx, const enum AVPixelFormat *fmt) |
Select the (possibly hardware accelerated) pixel format. More... | |
const AVPacketSideData * | ff_get_coded_side_data (const AVCodecContext *avctx, enum AVPacketSideDataType type) |
Get side data of the given type from a decoding context. More... | |
static int | add_metadata_from_side_data (const AVPacket *avpkt, AVFrame *frame) |
int | ff_decode_frame_props_from_pkt (const AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt) |
Set various frame properties from the provided packet. More... | |
int | ff_decode_frame_props (AVCodecContext *avctx, AVFrame *frame) |
Set various frame properties from the codec context / packet data. More... | |
static void | validate_avframe_allocation (AVCodecContext *avctx, AVFrame *frame) |
static void | decode_data_free (void *opaque, uint8_t *data) |
int | ff_attach_decode_data (AVFrame *frame) |
int | ff_get_buffer (AVCodecContext *avctx, AVFrame *frame, int flags) |
Get a buffer for a frame. More... | |
static int | reget_buffer_internal (AVCodecContext *avctx, AVFrame *frame, int flags) |
int | ff_reget_buffer (AVCodecContext *avctx, AVFrame *frame, int flags) |
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available. More... | |
int | ff_decode_preinit (AVCodecContext *avctx) |
Perform decoder initialization and validation. More... | |
int | ff_copy_palette (void *dst, const AVPacket *src, void *logctx) |
Check whether the side-data of src contains a palette of size AVPALETTE_SIZE; if so, copy it to dst and return 1; else return 0. More... | |
int | ff_hwaccel_frame_priv_alloc (AVCodecContext *avctx, void **hwaccel_picture_private) |
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it. More... | |
void | ff_decode_flush_buffers (AVCodecContext *avctx) |
AVCodecInternal * | ff_decode_internal_alloc (void) |
Variables | |
struct { | |
enum AVPacketSideDataType packet | |
enum AVFrameSideDataType frame | |
} | sd_global_map [] |
|
static |
Definition at line 65 of file decode.c.
Referenced by avcodec_send_packet(), decode_simple_internal(), ff_decode_flush_buffers(), and ff_decode_get_packet().
|
static |
Definition at line 70 of file decode.c.
Referenced by decode_get_packet().
|
static |
Definition at line 164 of file decode.c.
Referenced by decode_get_packet().
|
static |
Definition at line 179 of file decode.c.
Referenced by ff_decode_preinit().
|
static |
Definition at line 214 of file decode.c.
Referenced by ff_decode_get_packet().
int ff_decode_get_packet | ( | AVCodecContext * | avctx, |
AVPacket * | pkt | ||
) |
Called by decoders to get the next packet for decoding.
pkt | An empty packet to be filled with data. |
Definition at line 241 of file decode.c.
Referenced by av1_receive_frame(), binkaudio_receive_frame(), crystalhd_receive_frame(), cuvid_output_frame(), decode_simple_internal(), ffmmal_receive_frame(), libdav1d_receive_frame_internal(), libjxl_receive_frame(), mediacodec_receive_frame(), osq_receive_frame(), and v4l2_receive_frame().
|
static |
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect times.
Input timestamps may wrap around, in which case the output will as well.
pts | the pts field of the decoded AVPacket, as passed through AVFrame.pts |
dts | the dts field of the decoded AVPacket |
Definition at line 276 of file decode.c.
Referenced by decode_receive_frame_internal().
|
static |
Definition at line 302 of file decode.c.
Referenced by decode_receive_frame_internal(), and decode_simple_internal().
|
inlinestatic |
Definition at line 400 of file decode.c.
Referenced by decode_simple_receive_frame().
|
static |
Definition at line 553 of file decode.c.
Referenced by decode_receive_frame_internal().
|
static |
Definition at line 559 of file decode.c.
Referenced by decode_receive_frame_internal(), and ff_decode_frame_props().
|
static |
Definition at line 601 of file decode.c.
Referenced by decode_receive_frame_internal().
|
static |
Definition at line 617 of file decode.c.
Referenced by avcodec_send_packet(), and ff_decode_receive_frame().
|
static |
Definition at line 742 of file decode.c.
Referenced by ff_decode_receive_frame().
|
static |
Definition at line 770 of file decode.c.
Referenced by ff_decode_receive_frame().
int ff_decode_receive_frame | ( | AVCodecContext * | avctx, |
AVFrame * | frame | ||
) |
avcodec_receive_frame() implementation for decoders.
Definition at line 796 of file decode.c.
Referenced by avcodec_receive_frame().
|
static |
Definition at line 882 of file decode.c.
Referenced by avcodec_decode_subtitle2().
|
static |
Definition at line 889 of file decode.c.
Referenced by avcodec_decode_subtitle2().
|
static |
Definition at line 950 of file decode.c.
Referenced by avcodec_decode_subtitle2().
int ff_decode_get_hw_frames_ctx | ( | AVCodecContext * | avctx, |
enum AVHWDeviceType | dev_type | ||
) |
Make sure avctx.hw_frames_ctx is set.
If it's not set, the function will try to allocate it from hw_device_ctx. If that is not possible, an error message is printed, and an error code is returned.
Definition at line 1108 of file decode.c.
Referenced by ff_dxva2_decode_init(), ff_vaapi_decode_init(), ff_vdpau_common_init(), and ff_vk_decode_init().
|
static |
Definition at line 1217 of file decode.c.
Referenced by ff_get_format().
void ff_hwaccel_uninit | ( | AVCodecContext * | avctx | ) |
Definition at line 1252 of file decode.c.
Referenced by avcodec_close(), ff_frame_thread_free(), ff_get_format(), and update_context_from_thread().
int ff_get_format | ( | AVCodecContext * | avctx, |
const enum AVPixelFormat * | fmt | ||
) |
Select the (possibly hardware accelerated) pixel format.
This is a wrapper around AVCodecContext.get_format() and should be used instead of calling get_format() directly.
The list of pixel formats must contain at least one valid entry, and is terminated with AV_PIX_FMT_NONE. If it is possible to decode to software, the last entry in the list must be the most accurate software format. If it is not possible to decode to software, AVCodecContext.sw_pix_fmt must be set before calling this function.
Definition at line 1264 of file decode.c.
Referenced by cuvid_decode_init(), decode_frame_header(), ff_mediacodec_dec_init(), ff_mjpeg_decode_sof(), ffmmal_init_decoder(), get_format(), get_pixel_format(), h263_get_format(), mpeg_get_pixelformat(), qsv_decode_preinit(), update_size(), vc1_decode_init(), and vc1_get_format().
const AVPacketSideData* ff_get_coded_side_data | ( | const AVCodecContext * | avctx, |
enum AVPacketSideDataType | type | ||
) |
Get side data of the given type from a decoding context.
Definition at line 1402 of file decode.c.
Referenced by ff_decode_frame_props(), and hevc_decode_init().
Definition at line 1412 of file decode.c.
Referenced by ff_decode_frame_props_from_pkt().
int ff_decode_frame_props_from_pkt | ( | const AVCodecContext * | avctx, |
AVFrame * | frame, | ||
const AVPacket * | pkt | ||
) |
Set various frame properties from the provided packet.
Definition at line 1439 of file decode.c.
Referenced by ff_decode_frame_props(), and libdav1d_receive_frame().
int ff_decode_frame_props | ( | AVCodecContext * | avctx, |
AVFrame * | frame | ||
) |
Set various frame properties from the codec context / packet data.
Definition at line 1504 of file decode.c.
Referenced by cuvid_output_frame(), ff_get_buffer(), ff_h263_decode_frame(), ffmal_copy_frame(), libdav1d_receive_frame(), qsv_get_continuous_buffer(), qtrle_decode_frame(), raw_decode(), reget_buffer_internal(), vpx_decode(), and wrapped_avframe_decode().
|
static |
Definition at line 1559 of file decode.c.
Referenced by ff_get_buffer().
|
static |
Definition at line 1580 of file decode.c.
Referenced by ff_attach_decode_data().
Definition at line 1593 of file decode.c.
Referenced by ff_get_buffer(), ff_videotoolbox_alloc_frame(), and qsv_get_continuous_buffer().
int ff_get_buffer | ( | AVCodecContext * | avctx, |
AVFrame * | frame, | ||
int | flags | ||
) |
Get a buffer for a frame.
This is a wrapper around AVCodecContext.get_buffer() and should be used instead calling get_buffer() directly.
Definition at line 1617 of file decode.c.
Referenced by ac3_decode_frame(), adpcm_decode_frame(), adx_decode_frame(), alloc_frame(), amrnb_decode_frame(), amrwb_decode_frame(), aom_decode(), apac_decode(), ape_decode_frame(), aptx_decode_frame(), atrac1_decode_frame(), atrac3_decode_frame(), atrac3al_decode_frame(), atrac3p_decode_frame(), atrac9_decode_frame(), aura_decode_frame(), avui_decode_frame(), bfi_decode_frame(), binkaudio_receive_frame(), bmp_decode_frame(), bmv_aud_decode_frame(), bonk_decode(), cdg_decode_frame(), cdxl_decode_frame(), cinaudio_decode_frame(), cmv_decode_frame(), cng_decode_frame(), cook_decode_frame(), copy_frame(), copy_output(), cuvid_output_frame(), cyuv_decode_frame(), dds_decode(), decode_frame(), decode_pic(), decode_tag(), dfa_decode_frame(), dfpwm_dec_frame(), dpcm_decode_frame(), dss_sp_decode_frame(), eightsvx_decode_frame(), escape124_decode_frame(), escape130_decode_frame(), evrc_decode_frame(), execute_code(), fastaudio_decode(), fdk_aac_decode_frame(), ff_dca_lbr_filter_frame(), ff_dca_xll_filter_frame(), ff_ivi_decode_frame(), ff_mjpeg_decode_sof(), ff_thread_get_buffer(), ff_thread_get_ext_buffer(), ff_twinvq_decode_frame(), ff_vp56_decode_frame(), ffat_decode(), ffmal_copy_frame(), filter_frame(), filter_frame_fixed(), filter_frame_float(), fits_decode_frame(), frame_configure_elements(), ftr_decode_frame(), g2m_decode_frame(), g722_decode_frame(), g723_1_decode_frame(), gdv_decode_frame(), gem_decode_frame(), get_buffer(), get_buffer_with_edge(), gsm_decode_frame(), hcom_decode(), hnm_decode_frame(), hq_decode_frame(), hqa_decode_frame(), idcin_decode_frame(), ilbc_decode_frame(), imc_decode_frame(), init_frames(), ipu_decode_frame(), ipvideo_decode_frame(), libcelt_dec_decode(), libcodec2_decode(), libgsm_decode_frame(), libjxl_receive_frame(), libopus_decode(), librsvg_decode_frame(), libspeex_decode_frame(), libuavs3d_decode_frame(), m101_decode_frame(), mace_decode_frame(), mediacodec_wrap_sw_buffer(), misc4_decode(), mp_decode_frame(), mpc7_decode_frame(), mpc8_decode_frame(), msp2_decode_frame(), mss2_decode_frame(), mvc_decode_frame(), mxpeg_decode_frame(), oggvorbis_decode_frame(), on2avc_decode_frame(), opus_decode_packet(), osq_receive_frame(), output_data(), paf_audio_decode(), pcm_bluray_decode_frame(), pcm_decode_frame(), pcm_dvd_decode_frame(), pcx_decode_frame(), pgx_decode_frame(), pix_decode_frame(), pnm_decode_frame(), ptx_decode_frame(), qcelp_decode_frame(), qdm2_decode_frame(), qdmc_decode_frame(), ra144_decode_frame(), ra288_decode_frame(), reget_buffer_internal(), rka_decode_frame(), rl2_decode_frame(), s302m_decode_frame(), sbc_decode_frame(), sga_decode_frame(), sgirle_decode_frame(), shorten_decode_frame(), sipr_decode_frame(), siren_decode(), smka_decode_frame(), speedhq_decode_frame(), speex_decode_frame(), sunrast_decode_frame(), svc_decode_frame(), svq1_decode_frame(), synth_superframe(), tdsc_decode_frame(), tgq_decode_frame(), tgv_decode_frame(), thread_get_buffer_internal(), tmv_decode_frame(), tqi_decode_frame(), truemotion2rt_decode_frame(), truespeech_decode_frame(), txd_decode_frame(), v308_decode_frame(), v408_decode_frame(), vbn_decode_frame(), vcr1_decode_frame(), vmdaudio_decode_frame(), vmdvideo_decode_frame(), vorbis_decode_frame(), vpx_decode(), wavarc_decode(), wavesynth_decode(), wma_decode_superframe(), wmapro_decode_packet(), ws_snd_decode_frame(), xan_decode_frame(), xbm_decode_frame(), xface_decode_frame(), xma_decode_packet(), xpm_decode_frame(), xwd_decode_frame(), y216_decode_frame(), y41p_decode_frame(), yuv4_decode_frame(), zero12v_decode_frame(), and zerocodec_decode_frame().
|
static |
Definition at line 1698 of file decode.c.
Referenced by ff_reget_buffer().
int ff_reget_buffer | ( | AVCodecContext * | avctx, |
AVFrame * | frame, | ||
int | flags | ||
) |
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
Definition at line 1735 of file decode.c.
Referenced by aasc_decode_frame(), avs_decode_frame(), bethsoftvid_decode_frame(), cdg_decode_frame(), cdtoons_decode_frame(), cinepak_decode_frame(), cinvideo_decode_frame(), clv_decode_frame(), cpia_decode_frame(), decode_frame(), decode_frame_lscr(), fic_decode_frame(), flashsv_decode_frame(), flic_decode_frame_15_16BPP(), flic_decode_frame_1BPP(), flic_decode_frame_24BPP(), flic_decode_frame_8BPP(), gif_decode_frame(), imx_decode_frame(), ir2_decode_frame(), mm_decode_frame(), mobiclip_decode(), mp_decode_frame(), msrle_decode_frame(), mss1_decode_frame(), mss2_decode_frame(), mss3_decode_frame(), mss4_decode_frame(), msvideo1_decode_frame(), paf_video_decode(), qtrle_decode_frame(), roq_decode_frame(), rpza_decode_stream(), rscc_decode_frame(), screenpresso_decode_frame(), seqvideo_decode_frame(), smc_decode_frame(), truemotion1_decode_frame(), tscc2_decode_frame(), ulti_decode_frame(), vqa_decode_frame(), vqc_decode_frame(), xan_decode_frame(), and yop_decode_frame().
int ff_decode_preinit | ( | struct AVCodecContext * | avctx | ) |
Perform decoder initialization and validation.
Called when opening the decoder, before the FFCodec.init() call.
Definition at line 1743 of file decode.c.
Referenced by avcodec_open2().
Check whether the side-data of src contains a palette of size AVPALETTE_SIZE; if so, copy it to dst and return 1; else return 0.
Also emit an error message upon encountering a palette with invalid size.
Definition at line 1823 of file decode.c.
Referenced by cinepak_decode_frame(), decode_frame(), gdv_decode_frame(), idcin_decode_frame(), imx_decode_frame(), ipvideo_decode_frame(), msrle_decode_frame(), msvideo1_decode_frame(), qtrle_decode_frame(), raw_decode(), rscc_decode_frame(), and smc_decode_frame().
int ff_hwaccel_frame_priv_alloc | ( | AVCodecContext * | avctx, |
void ** | hwaccel_picture_private | ||
) |
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
The returned data is a RefStruct reference (if allocated).
avctx | The codec context |
hwaccel_picture_private | Pointer to return hwaccel_picture_private |
Definition at line 1838 of file decode.c.
Referenced by alloc_frame(), alloc_picture(), av1_frame_alloc(), vp8_alloc_frame(), and vp9_frame_alloc().
void ff_decode_flush_buffers | ( | AVCodecContext * | avctx | ) |
Definition at line 1867 of file decode.c.
Referenced by avcodec_flush_buffers().
AVCodecInternal* ff_decode_internal_alloc | ( | void | ) |
Definition at line 1884 of file decode.c.
Referenced by avcodec_open2(), and init_thread().
enum AVPacketSideDataType packet |
Definition at line 1425 of file decode.c.
Referenced by apng_write_packet(), cbs_h2645_fragment_add_nals(), concatenate_packet(), decode_write(), dfpwm_dec_frame(), dfpwm_enc_frame(), enqueue_packet(), ff_decode_frame_props(), ff_decode_frame_props_from_pkt(), flush_packet(), handle_klv(), handle_packet(), handle_packets(), iec61883_callback(), iec61883_close(), iec61883_parse_queue_dv(), iec61883_parse_queue_hdv(), init_packet(), main(), moflex_read_packet(), mpegts_read_header(), mpegts_write_section(), opus_header(), opus_packet(), parse_pcr(), qdm2_decode_fft_packets(), qdm2_decode_super_block(), rkmpp_write_data(), sbg_read_packet(), section_write_packet(), stream_seek(), stream_skip(), stream_write(), tedcaptions_read_packet(), wavesynth_decode(), write_packet(), xma_parse(), xmv_process_packet_header(), xmv_read_header(), and xvid_encode_init().
enum AVFrameSideDataType frame |
Definition at line 1426 of file decode.c.
Referenced by add_metadata_from_side_data(), apply_cropping(), decode_receive_frame_internal(), decode_simple_internal(), decode_simple_receive_frame(), discard_samples(), ff_attach_decode_data(), ff_decode_frame_props(), ff_decode_frame_props_from_pkt(), ff_decode_receive_frame(), ff_get_buffer(), ff_reget_buffer(), fill_frame_props(), frame_validate(), reget_buffer_internal(), and validate_avframe_allocation().
const { ... } sd_global_map[] |
Referenced by ff_decode_frame_props(), and ff_decode_frame_props_from_pkt().