28#define UNCHECKED_BITSTREAM_READER 1
30#include "config_components.h"
65 return h &&
h->ps.sps ?
h->ps.sps->num_reorder_frames : 0;
70 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
77 sl->
mb_xy = mb_x + mb_y *
h->mb_stride;
112 const int field_pic =
h->picture_structure !=
PICT_FRAME;
128 vshift =
desc->log2_chroma_h;
132 offset[2] = (y >> vshift) *
src->linesize[1];
139 y,
h->picture_structure,
height);
154 h->slice_table =
NULL;
165#if CONFIG_ERROR_RESILIENCE
172 for (
i = 0;
i <
h->nb_slice_ctx;
i++) {
190 const int big_mb_num =
h->mb_stride * (
h->mb_height + 1);
191 const int row_mb_num = 2*
h->mb_stride*
FFMAX(
h->nb_slice_ctx, 1);
192 const int st_size = big_mb_num +
h->mb_stride;
207 h->slice_ctx[0].intra4x4_pred_mode =
h->intra4x4_pred_mode;
208 h->slice_ctx[0].mvd_table[0] =
h->mvd_table[0];
209 h->slice_ctx[0].mvd_table[1] =
h->mvd_table[1];
210 memset(
h->slice_table_base, -1,
211 st_size *
sizeof(*
h->slice_table_base));
212 h->slice_table =
h->slice_table_base +
h->mb_stride * 2 + 1;
213 for (y = 0; y <
h->mb_height; y++)
214 for (x = 0; x <
h->mb_width; x++) {
215 const int mb_xy = x + y *
h->mb_stride;
216 const int b_xy = 4 * x + 4 * y *
h->b_stride;
218 h->mb2b_xy[mb_xy] = b_xy;
219 h->mb2br_xy[mb_xy] = 8 * (
FMO ? mb_xy : (mb_xy % (2 *
h->mb_stride)));
222 if (CONFIG_ERROR_RESILIENCE) {
223 int y_size = (2 *
h->mb_width + 1) * (2 *
h->mb_height + 1);
224 int yc_size = y_size + 2 * big_mb_num;
243 for (y = 0; y <
h->mb_height; y++)
244 for (x = 0; x <
h->mb_width; x++)
247 er->
mb_index2xy[
h->mb_height *
h->mb_width] = (
h->mb_height - 1) *
248 h->mb_stride +
h->mb_width;
249 er->
dc_val[0] =
h->dc_val_base +
h->mb_width * 2 + 2;
250 er->
dc_val[1] =
h->dc_val_base + y_size +
h->mb_stride + 1;
252 for (
int i = 0;
i < yc_size;
i++)
253 h->dc_val_base[
i] = 1024;
294 h->cur_chroma_format_idc = -1;
296 h->width_from_caller = avctx->
width;
297 h->height_from_caller = avctx->
height;
301 h->poc.prev_poc_msb = 1 << 16;
302 h->recovery_frame = -1;
303 h->frame_recovered = 0;
304 h->poc.prev_frame_num = -1;
305 h->sei.common.frame_packing.arrangement_cancel_flag = -1;
306 h->sei.common.unregistered.x264_build = -1;
308 h->next_outputed_poc = INT_MIN;
310 h->last_pocs[
i] = INT_MIN;
316 if (!
h->decode_error_flags_pool)
321 h->slice_ctx =
av_calloc(
h->nb_slice_ctx,
sizeof(*
h->slice_ctx));
338 for (
i = 0;
i <
h->nb_slice_ctx;
i++)
339 h->slice_ctx[
i].h264 =
h;
362 memset(
h->delayed_pic, 0,
sizeof(
h->delayed_pic));
364 h->cur_pic_ptr =
NULL;
402 &
h->ps, &
h->is_avc, &
h->nal_length_size,
407 "Error decoding the extradata\n");
416 if (
h->ps.sps &&
h->ps.sps->bitstream_restriction_flag &&
417 h->avctx->has_b_frames <
h->ps.sps->num_reorder_frames) {
418 h->avctx->has_b_frames =
h->ps.sps->num_reorder_frames;
428 "Error resilience with slice threads is enabled. It is unsafe and unsupported and may crash. "
429 "Use it at your own risk\n");
442 h->poc.prev_frame_num =
443 h->poc.prev_frame_num_offset = 0;
444 h->poc.prev_poc_msb = 1<<16;
445 h->poc.prev_poc_lsb = -1;
447 h->last_pocs[
i] = INT_MIN;
455 h->next_outputed_poc = INT_MIN;
456 h->prev_interlaced_frame = 1;
459 h->poc.prev_frame_num = -1;
460 if (
h->cur_pic_ptr) {
461 h->cur_pic_ptr->reference = 0;
462 for (j=
i=0;
h->delayed_pic[
i];
i++)
463 if (
h->delayed_pic[
i] !=
h->cur_pic_ptr)
464 h->delayed_pic[j++] =
h->delayed_pic[
i];
465 h->delayed_pic[j] =
NULL;
470 h->recovery_frame = -1;
471 h->frame_recovered = 0;
472 h->current_slice = 0;
481 memset(
h->delayed_pic, 0,
sizeof(
h->delayed_pic));
488 h->cur_pic_ptr =
NULL;
495 h->context_initialized = 0;
505 int picture_intra_only = 1;
509 for (
i = 0;
i <
h->pkt.nb_nals;
i++) {
535 first_slice !=
nal->type)
546 first_slice =
nal->type;
550 h->picture_intra_only = picture_intra_only;
592 while (idx + 1 <
h->pkt.nb_nals) {
606 const uint8_t *buf,
int buf_size)
611 int dp_attached_to = -1;
618 h->current_slice = 0;
619 if (!
h->first_field) {
620 h->cur_pic_ptr =
NULL;
625 if (
h->nal_length_size == 4) {
626 if (buf_size > 8 &&
AV_RB32(buf) == 1 &&
AV_RB32(buf+5) > (
unsigned)buf_size) {
628 }
else if(buf_size > 3 &&
AV_RB32(buf) > 1 &&
AV_RB32(buf) <= (
unsigned)buf_size)
636 "Error splitting the input into NAL units.\n");
645 for (
i = 0;
i <
h->pkt.nb_nals;
i++) {
648 int max_slice_ctx, err;
655 h->nal_ref_idc =
nal->ref_idc;
656 h->nal_unit_type =
nal->type;
661 if ((
nal->data[1] & 0xFC) == 0x98) {
663 h->next_outputed_poc = INT_MIN;
671 h->has_recovery_point = 1;
691 "supported for partitioned slices\n");
706 if (
h->current_slice == 1) {
708 i >= nals_needed && !
h->setup_finished &&
h->cur_pic_ptr) {
710 h->setup_finished = 1;
713 if (
h->avctx->hwaccel &&
719 max_slice_ctx = avctx->
hwaccel ? 1 :
h->nb_slice_ctx;
720 if (
h->nb_slice_ctx_queued == max_slice_ctx) {
721 if (
h->avctx->hwaccel) {
723 h->nb_slice_ctx_queued = 0;
733 if (
i > dp_attached_to)
735 "%c without a matching partition A\n",
739 if (
h->setup_finished) {
744 h->has_recovery_point =
h->has_recovery_point ||
h->sei.recovery_point.recovery_frame_cnt != -1;
754 nal->type,
nal->raw_data,
nal->raw_size);
761 "SPS decoding failure, trying again with the complete NAL\n");
771 nal->type,
nal->raw_data,
nal->raw_size);
789 nal->type,
nal->size_bits);
804 if ((ret < 0 || h->er.error_occurred) &&
h->cur_pic_ptr) {
805 if (
h->cur_pic_ptr->decode_error_flags) {
807 atomic_int *decode_error =
h->cur_pic_ptr->decode_error_flags;
812 memory_order_relaxed);
820#if CONFIG_ERROR_RESILIENCE
836 int use_last_pic =
h->last_pic_for_ec.f->buf[0] && !sl->
ref_count[0];
837 int decode_error_flags = 0;
856 if (decode_error_flags) {
857 if (
h->cur_pic_ptr->decode_error_flags) {
858 atomic_int *decode_error =
h->cur_pic_ptr->decode_error_flags;
860 memory_order_relaxed);
862 h->cur_pic_ptr->f->decode_error_flags |= decode_error_flags;
869 if (
h->cur_pic_ptr && !
h->droppable &&
h->has_slice) {
874 return (ret < 0) ? ret : buf_size;
880 unsigned int nb_mb = p->mb_height * p->mb_width;
887 par->
qp = p->pps->init_qp;
889 par->
delta_qp[1][0] = p->pps->chroma_qp_index_offset[0];
890 par->
delta_qp[1][1] = p->pps->chroma_qp_index_offset[0];
891 par->
delta_qp[2][0] = p->pps->chroma_qp_index_offset[1];
892 par->
delta_qp[2][1] = p->pps->chroma_qp_index_offset[1];
894 for (y = 0; y < p->mb_height; y++)
895 for (x = 0; x < p->mb_width; x++) {
896 const unsigned int block_idx = y * p->mb_width + x;
897 const unsigned int mb_xy = y * p->mb_stride + x;
905 b->delta_qp = p->qscale_table[mb_xy] - par->
qp;
952 int cnt= buf[5]&0x1f;
953 const uint8_t *p= buf+6;
958 if(nalsize > buf_size - (p-buf) || (p[2] & 0x9F) != 7)
967 if(nalsize > buf_size - (p-buf) || (p[2] & 0x9F) != 8)
982 if (
h->skip_gray > 0 &&
983 h->non_gray &&
out->gray &&
988 if (!
h->avctx->hwaccel &&
989 (
out->field_poc[0] == INT_MAX ||
990 out->field_poc[1] == INT_MAX)
994 int field =
out->field_poc[0] == INT_MAX;
995 uint8_t *dst_data[4];
997 const uint8_t *src_data[4];
1001 for (p = 0; p<4; p++) {
1002 dst_data[p] =
f->data[p] + (field^1)*
f->linesize[p];
1003 src_data[p] =
f->data[p] + field *
f->linesize[p];
1004 linesizes[p] = 2*
f->linesize[p];
1008 f->format,
f->width,
f->height>>1);
1017 if (CONFIG_MPEGVIDEODEC) {
1022 out->mb_width,
out->mb_height,
out->mb_stride, 1);
1030 int *got_frame,
int buf_index)
1032 int ret,
i, out_idx;
1035 h->cur_pic_ptr =
NULL;
1038 while (
h->delayed_pic[0]) {
1039 out =
h->delayed_pic[0];
1042 h->delayed_pic[
i] &&
1044 !
h->delayed_pic[
i]->mmco_reset;
1046 if (
h->delayed_pic[
i]->poc <
out->poc) {
1047 out =
h->delayed_pic[
i];
1051 for (
i = out_idx;
h->delayed_pic[
i];
i++)
1052 h->delayed_pic[
i] =
h->delayed_pic[
i + 1];
1055 h->frame_recovered |=
out->recovered;
1073 const uint8_t *buf = avpkt->
data;
1074 int buf_size = avpkt->
size;
1080 h->setup_finished = 0;
1081 h->nb_slice_ctx_queued = 0;
1093 &
h->ps, &
h->is_avc, &
h->nal_length_size,
1096 if (
h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC) {
1099 &
h->ps, &
h->is_avc, &
h->nal_length_size,
1114 buf_size >= 4 && !memcmp(
"Q264", buf, 4))
1121 (
h->mb_y >=
h->mb_height &&
h->mb_height)) {
1126 if (
h->next_output_pic) {
1140#define OFFSET(x) offsetof(H264Context, x)
1141#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1142#define VDX VD | AV_OPT_FLAG_EXPORT
1146 {
"enable_er",
"Enable error resilience on damaged frames (unsafe)",
OFFSET(enable_er),
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
VD },
1147 {
"x264_build",
"Assume this x264 version if no x264 version found in any SEI",
OFFSET(x264_build),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
VD },
1149 {
"noref_gray",
"Avoid using gray gap frames as references",
OFFSET(noref_gray),
AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1,
VD },
1154 .class_name =
"H264 Decoder",
1173#if CONFIG_H264_DXVA2_HWACCEL
1176#if CONFIG_H264_D3D11VA_HWACCEL
1179#if CONFIG_H264_D3D11VA2_HWACCEL
1182#if CONFIG_H264_D3D12VA_HWACCEL
1185#if CONFIG_H264_NVDEC_HWACCEL
1188#if CONFIG_H264_NVDEC_CUARRAY_HWACCEL
1191#if CONFIG_H264_VAAPI_HWACCEL
1194#if CONFIG_H264_VDPAU_HWACCEL
1197#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
1200#if CONFIG_H264_VULKAN_HWACCEL
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_h264_decoder
static av_cold void close(AVCodecParserContext *s)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG-2 field pics)
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define FF_DEBUG_GREEN_MD
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
#define FF_BUG_AUTODETECT
autodetection
#define FF_BUG_H264_DP_NNZ
H.264: JM's nC derivation for partitioned slices.
#define i(width, name, range_min, range_max)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
#define UPDATE_THREAD_CONTEXT(func)
#define UPDATE_THREAD_CONTEXT_FOR_USER(func)
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define AV_EF_EXPLODE
abort decoding on minor error detection
void(* flush)(AVBSFContext *ctx)
int(* init)(AVBSFContext *ctx)
#define atomic_load_explicit(object, order)
#define atomic_fetch_or_explicit(object, operand, order)
av_cold int ff_er_init(ERContext *const s)
void ff_er_frame_end(ERContext *s, int *decode_error_flags)
Indicate that a frame has finished decoding and perform error concealment in case it has been enabled...
static void fill_rectangle(int x, int y, int w, int h)
static int decode_slice(AVCodecContext *c, void *arg)
#define FF_DECODE_ERROR_DECODE_SLICES
#define AV_NUM_DATA_POINTERS
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_CODEC_FLAG2_SHOW_ALL
Show all frames before the first keyframe.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
#define AV_CODEC_FLAG2_CHUNKS
Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
#define AV_CODEC_FLAG_OUTPUT_CORRUPT
Output even those frames that might be corrupted.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS
Decoding only.
@ AVDISCARD_NONREF
discard all non reference
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
@ AV_FRAME_DATA_FILM_GRAIN_PARAMS
Film grain parameters for a frame, described by AVFilmGrainParams.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
void av_image_copy(uint8_t *const dst_data[4], const int dst_linesizes[4], const uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
@ AV_PICTURE_TYPE_I
Intra.
#define LIBAVUTIL_VERSION_INT
H.264 common definitions.
@ H264_NAL_AUXILIARY_SLICE
av_cold void ff_h264_decode_init_vlc(void)
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps, int *is_avc, int *nal_length_size, int err_recognition, void *logctx)
static const uint8_t scan8[16 *3+3]
static av_always_inline uint32_t pack16to32(unsigned a, unsigned b)
void ff_h264_set_erpic(ERPicture *dst, const H264Picture *src)
void ff_h264_unref_picture(H264Picture *pic)
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure.
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int bit_length)
Decode PPS.
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int ignore_truncation)
Decode SPS.
H.264 parameter set handling.
void ff_h264_remove_all_refs(H264Context *h)
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, const H264ParamSets *ps, void *logctx)
const char * ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h)
Get stereo_mode string from the h264 frame_packing_arrangement.
void ff_h264_sei_uninit(H264SEIContext *h)
Reset SEI values at the beginning of the frame.
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
int ff_h264_execute_decode_slices(H264Context *h)
Call decode_slice() for each context.
int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal, H264SliceContext **queued)
Submit a slice for decoding.
int ff_h264_update_thread_context_for_user(AVCodecContext *dst, const AVCodecContext *src)
int ff_h264_attach_slice_partition(const H264Context *h, H264SliceContext *sl, const H2645NAL *nal)
Attach a slice data partition B or C to the slice started by partition A.
const uint8_t ff_h264_golomb_to_pict_type[5]
H.264 / AVC / MPEG-4 part10 codec.
#define H264_MAX_PICTURE_COUNT
#define FRAME_RECOVERED_SEI
Sufficient number of frames have been decoded since a SEI recovery point, so all the following frames...
#define PART_NOT_AVAILABLE
#define FF_HW_HAS_CB(avctx, function)
#define FF_HW_SIMPLE_CALL(avctx, function)
#define FF_HW_CALL(avctx, function,...)
#define HWACCEL_NVDEC_CUARRAY(codec)
#define HWACCEL_DXVA2(codec)
#define HWACCEL_VDPAU(codec)
#define HWACCEL_D3D12VA(codec)
#define HWACCEL_VULKAN(codec)
#define HWACCEL_NVDEC(codec)
#define HWACCEL_VAAPI(codec)
#define HWACCEL_D3D11VA(codec)
#define HWACCEL_VIDEOTOOLBOX(codec)
#define HWACCEL_D3D11VA2(codec)
static const int8_t mv[256][2]
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output.
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int nal_length_size, enum AVCodecID codec_id, int flags)
Split an input packet into NAL units.
static av_cold int h264_decode_end(AVCodecContext *avctx)
static int h264_attach_partitions(const H264Context *h, H264SliceContext *sl, int idx)
Attach the partitions B and C immediately following the partition A at idx.
const uint16_t ff_h264_mb_sizes[4]
int ff_h264_alloc_tables(H264Context *h)
Allocate tables.
static av_cold int h264_decode_init(AVCodecContext *avctx)
static int h264_export_enc_params(AVFrame *f, const H264Picture *p)
static int get_last_needed_nal(H264Context *h)
void ff_h264_free_tables(H264Context *h)
static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *got_frame)
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height)
static const AVOption h264_options[]
static int h264_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
static av_cold void h264_decode_flush(AVCodecContext *avctx)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
static int h264_init_context(AVCodecContext *avctx, H264Context *h)
static void debug_green_metadata(const H264SEIGreenMetaData *gm, void *logctx)
void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
Init slice context.
static int is_avcc_extradata(const uint8_t *buf, int buf_size)
static int h264_init_pic(H264Picture *pic)
static AVOnce h264_vlc_init
static void idr(H264Context *h)
instantaneous decoder refresh.
static void h264_free_pic(H264Context *h, H264Picture *pic)
static const AVClass h264_class
void ff_h264_flush_change(H264Context *h)
static int decode_nal_units(H264Context *h, AVBufferRef *buf_ref, const uint8_t *buf, int buf_size)
static int send_next_delayed_frame(H264Context *h, AVFrame *dst_frame, int *got_frame, int buf_index)
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
common internal api header.
Multithreading API for decoders.
Macro definitions for various function/variable attributes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
static int ff_thread_once(char *control, void(*routine)(void))
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, const uint32_t *mbtype_table, const int8_t *qscale_table, int16_t(*const motion_val[2])[2], int mb_width, int mb_height, int mb_stride, int quarter_sample)
Print debugging info for the given picture.
#define PICT_BOTTOM_FIELD
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
const AVProfile ff_h264_profiles[]
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
useful rectangle filling function
AVRefStructPool * av_refstruct_pool_alloc(size_t size, unsigned flags)
Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL)
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Describe the class of an AVClass context structure.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int flags2
AV_CODEC_FLAG2_*.
int slice_flags
slice flags
int workaround_bugs
Work around bugs in encoders which sometimes cannot be detected automatically.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
int active_thread_type
Which multithreading methods are in use by the codec.
void(* draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], int y, int type, int height)
If non NULL, 'draw_horiz_band' is called by the libavcodec decoder to draw a horizontal band.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
struct AVCodecInternal * internal
Private context used for internal data.
enum AVDiscard skip_frame
Skip decoding for selected frames.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int is_copy
When using frame-threaded decoding, this field is set for the first worker thread (e....
This structure describes decoded (raw) audio or video data.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
This structure stores compressed data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Data structure for storing block-level encoding information.
Video encoding parameters for a given frame.
int32_t delta_qp[4][2]
Quantisation parameter offset from the base (per-frame) qp for a given plane (first index) and AC/DC ...
int32_t qp
Base quantisation parameter for the frame.
void(* decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
atomic_int * decode_error_flags
RefStruct reference; its pointee is shared between decoding threads.
int sei_recovery_frame_cnt
int needs_fg
whether picture needs film grain synthesis (see f_grain)
const H264Picture * parent
int mb_field_decoding_flag
int8_t ref_cache[2][5 *8]
int bipred_scratchpad_allocated
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
uint8_t * edge_emu_buffer
int top_borders_allocated[2]
uint8_t * bipred_scratchpad
uint8_t(*[2] top_borders)[(16 *3) *2]
H264Ref ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
int mb_mbaff
mb_aff_frame && mb_field_decoding_flag
int edge_emu_buffer_allocated
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
#define avpriv_request_sample(...)
static int ref[MAX_W *MAX_W]
AVVideoEncParams * av_video_enc_params_create_side_data(AVFrame *frame, enum AVVideoEncParamsType type, unsigned int nb_blocks)
Allocates memory for AVEncodeInfoFrame plus an array of nb_blocks AVEncodeInfoBlock in the given AVFr...
static av_always_inline AVVideoBlockParams * av_video_enc_params_block(AVVideoEncParams *par, unsigned int idx)
Get the block at the specified idx.
@ AV_VIDEO_ENC_PARAMS_H264
H.264 stores: