Libav
Macros | Functions | Variables
h264dec.c File Reference

H.264 / AVC / MPEG-4 part10 codec. More...

#include "libavutil/display.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/stereo3d.h"
#include "libavutil/timer.h"
#include "internal.h"
#include "bytestream.h"
#include "cabac.h"
#include "cabac_functions.h"
#include "error_resilience.h"
#include "avcodec.h"
#include "h264.h"
#include "h264dec.h"
#include "h2645_parse.h"
#include "h264data.h"
#include "h264chroma.h"
#include "h264_mvpred.h"
#include "h264_ps.h"
#include "golomb.h"
#include "mathops.h"
#include "me_cmp.h"
#include "mpegutils.h"
#include "profiles.h"
#include "rectangle.h"
#include "thread.h"
#include <assert.h>

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(H264Context, x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

Functions

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)
 
void ff_h264_draw_horiz_band (const H264Context *h, H264SliceContext *sl, int y, int height)
 
void ff_h264_free_tables (H264Context *h)
 
int ff_h264_alloc_tables (H264Context *h)
 Allocate tables. More...
 
int ff_h264_slice_context_init (H264Context *h, H264SliceContext *sl)
 Init context Allocate buffers which are not shared amongst multiple threads. More...
 
static int h264_init_context (AVCodecContext *avctx, H264Context *h)
 
static av_cold int h264_decode_end (AVCodecContext *avctx)
 
av_cold int ff_h264_decode_init (AVCodecContext *avctx)
 
static int decode_init_thread_copy (AVCodecContext *avctx)
 
static void idr (H264Context *h)
 instantaneous decoder refresh. More...
 
void ff_h264_flush_change (H264Context *h)
 
static void flush_dpb (AVCodecContext *avctx)
 
static int get_last_needed_nal (H264Context *h)
 
static int decode_nal_units (H264Context *h, const uint8_t *buf, int buf_size)
 
static int get_consumed_bytes (int pos, int buf_size)
 Return the number of bytes consumed for building the current frame. More...
 
static int output_frame (H264Context *h, AVFrame *dst, AVFrame *src)
 
static int h264_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 

Variables

const uint16_t ff_h264_mb_sizes [4] = { 256, 384, 512, 768 }
 
static AVOnce h264_vlc_init = AV_ONCE_INIT
 
static const AVOption h264_options []
 
static const AVClass h264_class
 
AVCodec ff_h264_decoder
 

Detailed Description

H.264 / AVC / MPEG-4 part10 codec.

Author
Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at

Definition in file h264dec.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(H264Context, x)

Definition at line 780 of file h264dec.c.

◆ VD

Definition at line 781 of file h264dec.c.

Function Documentation

◆ h264_er_decode_mb()

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

Definition at line 58 of file h264dec.c.

Referenced by ff_h264_slice_context_init().

◆ ff_h264_draw_horiz_band()

void ff_h264_draw_horiz_band ( const H264Context h,
H264SliceContext sl,
int  y,
int  height 
)

◆ ff_h264_free_tables()

void ff_h264_free_tables ( H264Context h)

◆ ff_h264_alloc_tables()

int ff_h264_alloc_tables ( H264Context h)

Allocate tables.

needs width/height

Definition at line 163 of file h264dec.c.

Referenced by h264_slice_header_init().

◆ ff_h264_slice_context_init()

int ff_h264_slice_context_init ( H264Context h,
H264SliceContext sl 
)

Init context Allocate buffers which are not shared amongst multiple threads.

Definition at line 221 of file h264dec.c.

Referenced by get_dct8x8_allowed(), and h264_slice_header_init().

◆ h264_init_context()

static int h264_init_context ( AVCodecContext avctx,
H264Context h 
)
static

Definition at line 282 of file h264dec.c.

Referenced by decode_init_thread_copy(), and ff_h264_decode_init().

◆ h264_decode_end()

static av_cold int h264_decode_end ( AVCodecContext avctx)
static

Definition at line 331 of file h264dec.c.

Referenced by ff_h264_decode_init().

◆ ff_h264_decode_init()

av_cold int ff_h264_decode_init ( AVCodecContext avctx)

Definition at line 365 of file h264dec.c.

◆ decode_init_thread_copy()

static int decode_init_thread_copy ( AVCodecContext avctx)
static

Definition at line 410 of file h264dec.c.

◆ idr()

static void idr ( H264Context h)
static

instantaneous decoder refresh.

Definition at line 432 of file h264dec.c.

Referenced by decode_nal_units(), ff_h264_flush_change(), and h264_probe().

◆ ff_h264_flush_change()

void ff_h264_flush_change ( H264Context h)

Definition at line 442 of file h264dec.c.

Referenced by flush_dpb(), get_dct8x8_allowed(), and h264_init_ps().

◆ flush_dpb()

static void flush_dpb ( AVCodecContext avctx)
static

Definition at line 458 of file h264dec.c.

◆ get_last_needed_nal()

static int get_last_needed_nal ( H264Context h)
static

Definition at line 479 of file h264dec.c.

Referenced by decode_nal_units().

◆ decode_nal_units()

static int decode_nal_units ( H264Context h,
const uint8_t buf,
int  buf_size 
)
static

< number of NALs that need decoding before the next frame thread starts

Definition at line 516 of file h264dec.c.

Referenced by h264_decode_frame().

◆ get_consumed_bytes()

static int get_consumed_bytes ( int  pos,
int  buf_size 
)
static

Return the number of bytes consumed for building the current frame.

Definition at line 653 of file h264dec.c.

Referenced by h264_decode_frame().

◆ output_frame()

static int output_frame ( H264Context h,
AVFrame dst,
AVFrame src 
)
static

Definition at line 663 of file h264dec.c.

Referenced by h264_decode_frame(), load_encode_and_write(), and scale_vaapi_filter_frame().

◆ h264_decode_frame()

static int h264_decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame,
AVPacket avpkt 
)
static

Definition at line 683 of file h264dec.c.

Variable Documentation

◆ ff_h264_mb_sizes

const uint16_t ff_h264_mb_sizes[4] = { 256, 384, 512, 768 }

Definition at line 56 of file h264dec.c.

Referenced by ff_h264_decode_mb_cabac(), ff_h264_decode_mb_cavlc(), and hl_decode_mb().

◆ h264_vlc_init

AVOnce h264_vlc_init = AV_ONCE_INIT
static

Definition at line 363 of file h264dec.c.

◆ h264_options

const AVOption h264_options[]
static
Initial value:
= {
{ "enable_er", "Enable error resilience on damaged frames (unsafe)", OFFSET(enable_er), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VD },
{ NULL },
}
NULL
Definition: eval.c:55
#define OFFSET(x)
Definition: h264dec.c:780
#define VD
Definition: h264dec.c:781

Definition at line 782 of file h264dec.c.

◆ h264_class

const AVClass h264_class
static
Initial value:
= {
.class_name = "h264",
.item_name = av_default_item_name,
.option = h264_options,
}
static const AVOption h264_options[]
Definition: h264dec.c:782
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
av_default_item_name
Definition: dnxhdenc.c:55

Definition at line 787 of file h264dec.c.

◆ ff_h264_decoder

AVCodec ff_h264_decoder
Initial value:
= {
.name = "h264",
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.priv_data_size = sizeof(H264Context),
.close = h264_decode_end,
.capabilities = AV_CODEC_CAP_DR1 |
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
.priv_class = &h264_class,
}
H264Context.
Definition: h264dec.h:334
static void flush_dpb(AVCodecContext *avctx)
Definition: h264dec.c:458
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Definition: h264_slice.c:313
av_cold int ff_h264_decode_init(AVCodecContext *avctx)
Definition: h264dec.c:365
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:863
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
static const AVClass h264_class
Definition: h264dec.c:787
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
static av_cold int h264_decode_end(AVCodecContext *avctx)
Definition: h264dec.c:331
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:893
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:188
static int decode_init_thread_copy(AVCodecContext *avctx)
Definition: h264dec.c:410
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: avconv.c:1288
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:897
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1797
const AVProfile ff_h264_profiles[]
Definition: profiles.c:48
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:582
static int h264_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: h264dec.c:683
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:838

Definition at line 794 of file h264dec.c.