60 int mb_x,
int mb_y,
int mb_intra,
int mb_skipped)
109 offset[2] = (y >> vshift) * src->
linesize[1];
178 big_mb_num *
sizeof(uint16_t),
fail)
198 big_mb_num *
sizeof(uint32_t),
fail);
200 big_mb_num *
sizeof(uint32_t),
fail);
204 const int b_xy = 4 * x + 4 * y * h->
b_stride;
227 int yc_size = y_size + 2 * c_size;
268 yc_size *
sizeof(int16_t),
fail);
272 for (i = 0; i < yc_size; i++)
403 "Error resilience is enabled. It is unsafe and unsupported and may crash. " 404 "Use it at your own risk\n");
418 memset(h, 0,
sizeof(*h));
534 "Error splitting the input into NAL units.\n");
544 "The stream seems to contain AVCC extradata with Annex B " 545 "formatted data, which is invalid.");
560 int max_slice_ctx, err;
647 return (ret < 0) ? ret : buf_size;
657 if (pos + 10 > buf_size)
673 for (i = 0; i < 3; i++) {
687 int buf_size = avpkt->
size;
693 int new_extradata_size;
733 new_extradata_size = 0;
735 &new_extradata_size);
736 if (new_extradata_size > 0 && new_extradata) {
775 assert(pict->
buf[0] || !*got_frame);
780 #define OFFSET(x) offsetof(H264Context, x) 781 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM 783 {
"enable_er",
"Enable error resilience on damaged frames (unsafe)",
OFFSET(enable_er),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VD },
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int bit_length)
Decode PPS.
struct H264Context * h264
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_NUM_DATA_POINTERS
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG-2 field pics)
int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal)
Submit a slice for decoding.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
int edge_emu_buffer_allocated
#define AV_LOG_WARNING
Something somehow does not look correct.
AVBufferRef * sps_list[MAX_SPS_COUNT]
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int bitstream_restriction_flag
int bipred_scratchpad_allocated
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
AVBufferPool * mb_type_pool
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id)
Split an input packet into NAL units.
static void idr(H264Context *h)
instantaneous decoder refresh.
void ff_h264_flush_change(H264Context *h)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
H264Picture * delayed_pic[MAX_DELAYED_PIC_COUNT+2]
int is_avc
Used to parse AVC variant of H.264.
AVBufferPool * ref_index_pool
void ff_h264_sei_uninit(H264SEIContext *h)
Reset SEI values at the beginning of the frame.
#define AV_CODEC_FLAG2_CHUNKS
Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries...
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...
static void flush_dpb(AVCodecContext *avctx)
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
int size_bits
Size, in bits, of just the data, excluding the stop bit and any trailing padding. ...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
uint8_t * chroma_pred_mode_table
void ff_h264_remove_all_refs(H264Context *h)
av_cold int ff_h264_decode_init(AVCodecContext *avctx)
enum AVDiscard skip_frame
int ff_h264_execute_decode_slices(H264Context *h)
Call decode_slice() for each context.
struct AVHWAccel * hwaccel
Hardware accelerator in use.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
unsigned int crop_top
frame_cropping_rect_top_offset
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static int get_consumed_bytes(int pos, int buf_size)
Return the number of bytes consumed for building the current frame.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
unsigned int crop_left
frame_cropping_rect_left_offset
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
Multithreading support functions.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static int get_last_needed_nal(H264Context *h)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
int frame_recovered
Initial frame has been completely recovered.
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)
#define PICT_BOTTOM_FIELD
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
static int h264_init_context(AVCodecContext *avctx, H264Context *h)
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...
high precision timer, useful to profile code
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int last_pocs[MAX_DELAYED_PIC_COUNT]
static int output_frame(H264Context *h, AVFrame *dst, AVFrame *src)
H.264 common definitions.
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height)
H.264 parameter set handling.
H264Picture DPB[H264_MAX_PICTURE_COUNT]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static const AVClass h264_class
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const AVOption h264_options[]
int active_thread_type
Which multithreading methods are in use by the codec.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint8_t(*[2] mvd_table)[2]
static av_cold int h264_decode_end(AVCodecContext *avctx)
int prev_interlaced_frame
Complement sei_pic_struct SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced...
int flags
AV_CODEC_FLAG_*.
uint8_t(*[2] top_borders)[(16 *3) *2]
const char * name
Name of the codec implementation.
uint8_t * list_counts
Array of list_count per MB specifying the slice type.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
int crop
frame_cropping_flag
uint8_t * error_status_table
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
useful rectangle filling function
int prev_poc_msb
poc_msb of the last reference pic for POC type 0
static int decode_init_thread_copy(AVCodecContext *avctx)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define FF_THREAD_FRAME
Decode more than one frame at once.
uint16_t * slice_table
slice_table_base + 2*mb_stride + 1
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 decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
static void fill_rectangle(SDL_Surface *screen, int x, int y, int w, int h, int color)
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
Context Adaptive Binary Arithmetic Coder inline functions.
H.264 / AVC / MPEG-4 part10 codec.
H264SliceContext * slice_ctx
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int top_borders_allocated[2]
int ref_idc
H.264 only, nal_ref_idc.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
uint8_t * edge_emu_buffer
if(ac->has_optimized_func)
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
static const int8_t mv[256][2]
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Libavcodec external API header.
#define MAX_DELAYED_PIC_COUNT
AVBufferRef * pps_list[MAX_PPS_COUNT]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int recovery_frame
recovery_frame is the frame_num at which the next frame should be fully constructed.
main external API structure.
static av_always_inline uint32_t pack16to32(int a, int b)
static AVOnce h264_vlc_init
static const uint8_t scan8[16 *3+3]
int slice_flags
slice flags
Describe the class of an AVClass context structure.
int prev_frame_num
frame_num of the last pic for POC type 1/2
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
av_cold void ff_h264_decode_init_vlc(void)
int pixel_shift
0 for 8-bit H.264, 1 for high-bit-depth H.264
int mmco_reset
MMCO_RESET set this 1.
H264Picture * cur_pic_ptr
int allocate_progress
Whether to allocate progress for frame threading.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int prev_poc_lsb
poc_lsb of the last reference pic for POC type 0
int ff_h264_alloc_tables(H264Context *h)
Allocate tables.
#define CONFIG_ERROR_RESILIENCE
discard all non reference
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
AVBufferPool * qscale_table_pool
AVBufferPool * motion_val_pool
common internal api header.
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
uint16_t * slice_table_base
H.264 / AVC / MPEG-4 part10 motion vector prediction.
int workaround_bugs
Work around bugs in encoders which sometimes cannot be detected automatically.
const AVProfile ff_h264_profiles[]
int8_t * intra4x4_pred_mode
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static av_cold int init(AVCodecParserContext *s)
static int h264_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void ff_h264_free_tables(H264Context *h)
int8_t ref_cache[2][5 *8]
struct AVCodecInternal * internal
Private context used for internal data.
static int ff_thread_once(char *control, void(*routine)(void))
#define PART_NOT_AVAILABLE
int key_frame
1 -> keyframe, 0-> not
int current_slice
current slice number, used to initialize slice_num of each thread/context
int flags2
AV_CODEC_FLAG2_*.
static void * av_mallocz_array(size_t nmemb, size_t size)
uint8_t(*[2] mvd_table)[2]
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, const H264ParamSets *ps, void *logctx)
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int prev_frame_num_offset
for POC type 2
int8_t * intra4x4_pred_mode
int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
Init context Allocate buffers which are not shared amongst multiple threads.
uint8_t(* non_zero_count)[48]
uint8_t * bipred_scratchpad
void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
const uint16_t ff_h264_mb_sizes[4]
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps)
Decode SPS.
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)
Context Adaptive Binary Arithmetic Coder.
#define H264_MAX_PICTURE_COUNT