FFmpeg
Data Structures | Macros | Functions | Variables
h264dec.h File Reference
#include "libavutil/buffer.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
#include "cabac.h"
#include "error_resilience.h"
#include "h264_parse.h"
#include "h264_ps.h"
#include "h264_sei.h"
#include "h2645_parse.h"
#include "h264chroma.h"
#include "h264dsp.h"
#include "h264pred.h"
#include "h264qpel.h"
#include "h274.h"
#include "mpegutils.h"
#include "rectangle.h"
#include "videodsp.h"

Go to the source code of this file.

Data Structures

struct  MMCO
 Memory management control operation. More...
 
struct  H264Picture
 
struct  H264Ref
 
struct  H264SliceContext
 
struct  H264Context
 H264Context. More...
 

Macros

#define H264_MAX_PICTURE_COUNT   36
 
#define ALLOW_INTERLACE
 
#define FMO   0
 
#define MAX_SLICES   32
 The maximum number of slices supported by the decoder. More...
 
#define MB_MBAFF(h)   (h)->mb_mbaff
 
#define MB_FIELD(sl)   (sl)->mb_field_decoding_flag
 
#define FRAME_MBAFF(h)   (h)->mb_aff_frame
 
#define FIELD_PICTURE(h)   ((h)->picture_structure != PICT_FRAME)
 
#define LEFT_MBS   2
 
#define LTOP   0
 
#define LBOT   1
 
#define LEFT(i)   (i)
 
#define FIELD_OR_MBAFF_PICTURE(h)   (FRAME_MBAFF(h) || FIELD_PICTURE(h))
 
#define CABAC(h)   (h)->ps.pps->cabac
 
#define CHROMA(h)   ((h)->ps.sps->chroma_format_idc)
 
#define CHROMA422(h)   ((h)->ps.sps->chroma_format_idc == 2)
 
#define CHROMA444(h)   ((h)->ps.sps->chroma_format_idc == 3)
 
#define IS_REF0(a)   ((a) & MB_TYPE_REF0)
 
#define IS_8x8DCT(a)   ((a) & MB_TYPE_8x8DCT)
 
#define DELAYED_PIC_REF   (1 << 2)
 H264Picture.reference has this flag set, when the picture is held for delayed output. More...
 
#define LIST_NOT_USED   -1
 
#define FRAME_RECOVERED_IDR   (1 << 0)
 We have seen an IDR, so all the following frames in coded order are correctly decodable. More...
 
#define FRAME_RECOVERED_SEI   (1 << 1)
 Sufficient number of frames have been decoded since a SEI recovery point, so all the following frames in presentation order are correct. More...
 
#define LUMA_DC_BLOCK_INDEX   48
 
#define CHROMA_DC_BLOCK_INDEX   49
 

Functions

int ff_h264_get_slice_type (const H264SliceContext *sl)
 Reconstruct bitstream slice_type. More...
 
int ff_h264_alloc_tables (H264Context *h)
 Allocate tables. More...
 
int ff_h264_decode_ref_pic_list_reordering (H264SliceContext *sl, void *logctx)
 
int ff_h264_build_ref_list (H264Context *h, H264SliceContext *sl)
 
void ff_h264_remove_all_refs (H264Context *h)
 
int ff_h264_execute_ref_pic_marking (H264Context *h)
 Execute the reference picture marking (memory management control operations). More...
 
int ff_h264_decode_ref_pic_marking (H264SliceContext *sl, GetBitContext *gb, const H2645NAL *nal, void *logctx)
 
void ff_h264_hl_decode_mb (const H264Context *h, H264SliceContext *sl)
 
void ff_h264_decode_init_vlc (void)
 
int ff_h264_decode_mb_cavlc (const H264Context *h, H264SliceContext *sl)
 Decode a macroblock. More...
 
int ff_h264_decode_mb_cabac (const H264Context *h, H264SliceContext *sl)
 Decode a CABAC coded macroblock. More...
 
void ff_h264_init_cabac_states (const H264Context *h, H264SliceContext *sl)
 
void ff_h264_direct_dist_scale_factor (const H264Context *const h, H264SliceContext *sl)
 
void ff_h264_direct_ref_list_init (const H264Context *const h, H264SliceContext *sl)
 
void ff_h264_pred_direct_motion (const H264Context *const h, H264SliceContext *sl, int *mb_type)
 
void ff_h264_filter_mb_fast (const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize)
 
void ff_h264_filter_mb (const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize)
 
static av_always_inline int get_chroma_qp (const PPS *pps, int t, int qscale)
 Get the chroma qp. More...
 
static av_always_inline int pred_intra_mode (const H264Context *h, H264SliceContext *sl, int n)
 Get the predicted intra4x4 prediction mode. More...
 
static av_always_inline void write_back_intra_pred_mode (const H264Context *h, H264SliceContext *sl)
 
static av_always_inline void write_back_non_zero_count (const H264Context *h, H264SliceContext *sl)
 
static av_always_inline void write_back_motion_list (const H264Context *h, H264SliceContext *sl, int b_stride, int b_xy, int b8_xy, int mb_type, int list)
 
static av_always_inline void write_back_motion (const H264Context *h, H264SliceContext *sl, int mb_type)
 
static av_always_inline int get_dct8x8_allowed (const H264Context *h, H264SliceContext *sl)
 
int ff_h264_field_end (H264Context *h, H264SliceContext *sl, int in_setup)
 
int ff_h264_ref_picture (H264Context *h, H264Picture *dst, H264Picture *src)
 
int ff_h264_replace_picture (H264Context *h, H264Picture *dst, const H264Picture *src)
 
void ff_h264_unref_picture (H264Context *h, H264Picture *pic)
 
void ff_h264_slice_context_init (H264Context *h, H264SliceContext *sl)
 Init slice context. More...
 
void ff_h264_draw_horiz_band (const H264Context *h, H264SliceContext *sl, int y, int height)
 
int ff_h264_queue_decode_slice (H264Context *h, const H2645NAL *nal)
 Submit a slice for decoding. More...
 
int ff_h264_execute_decode_slices (H264Context *h)
 Call decode_slice() for each context. More...
 
int ff_h264_update_thread_context (AVCodecContext *dst, const AVCodecContext *src)
 
int ff_h264_update_thread_context_for_user (AVCodecContext *dst, const AVCodecContext *src)
 
void ff_h264_flush_change (H264Context *h)
 
void ff_h264_free_tables (H264Context *h)
 
void ff_h264_set_erpic (ERPicture *dst, H264Picture *src)
 

Variables

const uint16_t ff_h264_mb_sizes [4]
 

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.h.

Macro Definition Documentation

◆ H264_MAX_PICTURE_COUNT

#define H264_MAX_PICTURE_COUNT   36

Definition at line 50 of file h264dec.h.

◆ ALLOW_INTERLACE

#define ALLOW_INTERLACE

Definition at line 54 of file h264dec.h.

◆ FMO

#define FMO   0

Definition at line 56 of file h264dec.h.

◆ MAX_SLICES

#define MAX_SLICES   32

The maximum number of slices supported by the decoder.

must be a power of 2

Definition at line 62 of file h264dec.h.

◆ MB_MBAFF

#define MB_MBAFF (   h)    (h)->mb_mbaff

Definition at line 65 of file h264dec.h.

◆ MB_FIELD

#define MB_FIELD (   sl)    (sl)->mb_field_decoding_flag

Definition at line 66 of file h264dec.h.

◆ FRAME_MBAFF

#define FRAME_MBAFF (   h)    (h)->mb_aff_frame

Definition at line 67 of file h264dec.h.

◆ FIELD_PICTURE

#define FIELD_PICTURE (   h)    ((h)->picture_structure != PICT_FRAME)

Definition at line 68 of file h264dec.h.

◆ LEFT_MBS

#define LEFT_MBS   2

Definition at line 69 of file h264dec.h.

◆ LTOP

#define LTOP   0

Definition at line 70 of file h264dec.h.

◆ LBOT

#define LBOT   1

Definition at line 71 of file h264dec.h.

◆ LEFT

#define LEFT (   i)    (i)

Definition at line 72 of file h264dec.h.

◆ FIELD_OR_MBAFF_PICTURE

#define FIELD_OR_MBAFF_PICTURE (   h)    (FRAME_MBAFF(h) || FIELD_PICTURE(h))

Definition at line 85 of file h264dec.h.

◆ CABAC

#define CABAC (   h)    (h)->ps.pps->cabac

Definition at line 88 of file h264dec.h.

◆ CHROMA

#define CHROMA (   h)    ((h)->ps.sps->chroma_format_idc)

Definition at line 91 of file h264dec.h.

◆ CHROMA422

#define CHROMA422 (   h)    ((h)->ps.sps->chroma_format_idc == 2)

Definition at line 92 of file h264dec.h.

◆ CHROMA444

#define CHROMA444 (   h)    ((h)->ps.sps->chroma_format_idc == 3)

Definition at line 93 of file h264dec.h.

◆ IS_REF0

#define IS_REF0 (   a)    ((a) & MB_TYPE_REF0)

Definition at line 95 of file h264dec.h.

◆ IS_8x8DCT

#define IS_8x8DCT (   a)    ((a) & MB_TYPE_8x8DCT)

Definition at line 96 of file h264dec.h.

◆ DELAYED_PIC_REF

#define DELAYED_PIC_REF   (1 << 2)

H264Picture.reference has this flag set, when the picture is held for delayed output.

Definition at line 145 of file h264dec.h.

◆ LIST_NOT_USED

#define LIST_NOT_USED   -1

Definition at line 389 of file h264dec.h.

◆ FRAME_RECOVERED_IDR

#define FRAME_RECOVERED_IDR   (1 << 0)

We have seen an IDR, so all the following frames in coded order are correctly decodable.

Definition at line 516 of file h264dec.h.

◆ FRAME_RECOVERED_SEI

#define FRAME_RECOVERED_SEI   (1 << 1)

Sufficient number of frames have been decoded since a SEI recovery point, so all the following frames in presentation order are correct.

Definition at line 521 of file h264dec.h.

◆ LUMA_DC_BLOCK_INDEX

#define LUMA_DC_BLOCK_INDEX   48

Definition at line 641 of file h264dec.h.

◆ CHROMA_DC_BLOCK_INDEX

#define CHROMA_DC_BLOCK_INDEX   49

Definition at line 642 of file h264dec.h.

Function Documentation

◆ ff_h264_get_slice_type()

int ff_h264_get_slice_type ( const H264SliceContext sl)

Reconstruct bitstream slice_type.

Definition at line 2140 of file h264_slice.c.

Referenced by fill_slice_long(), and vaapi_h264_decode_slice().

◆ ff_h264_alloc_tables()

int ff_h264_alloc_tables ( H264Context h)

Allocate tables.

needs width/height

Definition at line 179 of file h264dec.c.

Referenced by h264_slice_header_init().

◆ ff_h264_decode_ref_pic_list_reordering()

int ff_h264_decode_ref_pic_list_reordering ( H264SliceContext sl,
void *  logctx 
)

Definition at line 422 of file h264_refs.c.

Referenced by h264_slice_header_parse().

◆ ff_h264_build_ref_list()

int ff_h264_build_ref_list ( H264Context h,
H264SliceContext sl 
)

Definition at line 298 of file h264_refs.c.

Referenced by h264_slice_init().

◆ ff_h264_remove_all_refs()

void ff_h264_remove_all_refs ( H264Context h)

Definition at line 564 of file h264_refs.c.

Referenced by h264_decode_end(), and idr().

◆ ff_h264_execute_ref_pic_marking()

int ff_h264_execute_ref_pic_marking ( H264Context h)

Execute the reference picture marking (memory management control operations).

Definition at line 609 of file h264_refs.c.

Referenced by ff_h264_field_end(), ff_h264_update_thread_context(), and h264_field_start().

◆ ff_h264_decode_ref_pic_marking()

int ff_h264_decode_ref_pic_marking ( H264SliceContext sl,
GetBitContext gb,
const H2645NAL nal,
void *  logctx 
)

Definition at line 833 of file h264_refs.c.

Referenced by h264_slice_header_parse().

◆ ff_h264_hl_decode_mb()

void ff_h264_hl_decode_mb ( const H264Context h,
H264SliceContext sl 
)

Definition at line 799 of file h264_mb.c.

Referenced by decode_slice(), and h264_er_decode_mb().

◆ ff_h264_decode_init_vlc()

void ff_h264_decode_init_vlc ( void  )

Definition at line 325 of file h264_cavlc.c.

Referenced by h264_decode_init().

◆ ff_h264_decode_mb_cavlc()

int ff_h264_decode_mb_cavlc ( const H264Context h,
H264SliceContext sl 
)

Decode a macroblock.

Returns
0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error

Definition at line 695 of file h264_cavlc.c.

Referenced by decode_slice().

◆ ff_h264_decode_mb_cabac()

int ff_h264_decode_mb_cabac ( const H264Context h,
H264SliceContext sl 
)

Decode a CABAC coded macroblock.

Returns
0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error

Decode a CABAC coded macroblock.

Returns
0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed

Definition at line 1920 of file h264_cabac.c.

Referenced by decode_slice().

◆ ff_h264_init_cabac_states()

void ff_h264_init_cabac_states ( const H264Context h,
H264SliceContext sl 
)

Definition at line 1262 of file h264_cabac.c.

Referenced by decode_slice().

◆ ff_h264_direct_dist_scale_factor()

void ff_h264_direct_dist_scale_factor ( const H264Context *const  h,
H264SliceContext sl 
)

Definition at line 61 of file h264_direct.c.

Referenced by h264_slice_init().

◆ ff_h264_direct_ref_list_init()

void ff_h264_direct_ref_list_init ( const H264Context *const  h,
H264SliceContext sl 
)

Definition at line 120 of file h264_direct.c.

Referenced by h264_slice_init().

◆ ff_h264_pred_direct_motion()

void ff_h264_pred_direct_motion ( const H264Context *const  h,
H264SliceContext sl,
int mb_type 
)

Definition at line 720 of file h264_direct.c.

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

◆ ff_h264_filter_mb_fast()

void ff_h264_filter_mb_fast ( const H264Context h,
H264SliceContext sl,
int  mb_x,
int  mb_y,
uint8_t *  img_y,
uint8_t *  img_cb,
uint8_t *  img_cr,
unsigned int  linesize,
unsigned int  uvlinesize 
)

Definition at line 416 of file h264_loopfilter.c.

Referenced by loop_filter().

◆ ff_h264_filter_mb()

void ff_h264_filter_mb ( const H264Context h,
H264SliceContext sl,
int  mb_x,
int  mb_y,
uint8_t *  img_y,
uint8_t *  img_cb,
uint8_t *  img_cr,
unsigned int  linesize,
unsigned int  uvlinesize 
)

Definition at line 716 of file h264_loopfilter.c.

Referenced by ff_h264_filter_mb_fast(), and loop_filter().

◆ get_chroma_qp()

static av_always_inline int get_chroma_qp ( const PPS pps,
int  t,
int  qscale 
)
static

◆ pred_intra_mode()

static av_always_inline int pred_intra_mode ( const H264Context h,
H264SliceContext sl,
int  n 
)
static

Get the predicted intra4x4 prediction mode.

Definition at line 655 of file h264dec.h.

Referenced by ff_h264_decode_mb_cabac(), and ff_h264_decode_mb_cavlc().

◆ write_back_intra_pred_mode()

static av_always_inline void write_back_intra_pred_mode ( const H264Context h,
H264SliceContext sl 
)
static

Definition at line 671 of file h264dec.h.

Referenced by ff_h264_decode_mb_cabac(), and ff_h264_decode_mb_cavlc().

◆ write_back_non_zero_count()

static av_always_inline void write_back_non_zero_count ( const H264Context h,
H264SliceContext sl 
)
static

Definition at line 683 of file h264dec.h.

Referenced by ff_h264_decode_mb_cabac(), and ff_h264_decode_mb_cavlc().

◆ write_back_motion_list()

static av_always_inline void write_back_motion_list ( const H264Context h,
H264SliceContext sl,
int  b_stride,
int  b_xy,
int  b8_xy,
int  mb_type,
int  list 
)
static

Definition at line 707 of file h264dec.h.

Referenced by write_back_motion().

◆ write_back_motion()

static av_always_inline void write_back_motion ( const H264Context h,
H264SliceContext sl,
int  mb_type 
)
static

Definition at line 743 of file h264dec.h.

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

◆ get_dct8x8_allowed()

static av_always_inline int get_dct8x8_allowed ( const H264Context h,
H264SliceContext sl 
)
static

Definition at line 770 of file h264dec.h.

Referenced by ff_h264_decode_mb_cabac(), and ff_h264_decode_mb_cavlc().

◆ ff_h264_field_end()

int ff_h264_field_end ( H264Context h,
H264SliceContext sl,
int  in_setup 
)

Definition at line 219 of file h264_picture.c.

Referenced by ff_h264_queue_decode_slice(), and h264_decode_frame().

◆ ff_h264_ref_picture()

int ff_h264_ref_picture ( H264Context h,
H264Picture dst,
H264Picture src 
)

Definition at line 92 of file h264_picture.c.

Referenced by ff_h264_remove_all_refs(), and h264_frame_start().

◆ ff_h264_replace_picture()

int ff_h264_replace_picture ( H264Context h,
H264Picture dst,
const H264Picture src 
)

Definition at line 145 of file h264_picture.c.

Referenced by ff_h264_update_thread_context().

◆ ff_h264_unref_picture()

void ff_h264_unref_picture ( H264Context h,
H264Picture pic 
)

◆ ff_h264_slice_context_init()

void ff_h264_slice_context_init ( H264Context h,
H264SliceContext sl 
)

Init slice context.

Definition at line 258 of file h264dec.c.

Referenced by h264_slice_header_init().

◆ ff_h264_draw_horiz_band()

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

◆ ff_h264_queue_decode_slice()

int ff_h264_queue_decode_slice ( H264Context h,
const H2645NAL nal 
)

Submit a slice for decoding.

Parse the slice header, starting a new field/frame if necessary. If any slices are queued for the previous field, they are decoded.

Definition at line 2015 of file h264_slice.c.

Referenced by decode_nal_units().

◆ ff_h264_execute_decode_slices()

int ff_h264_execute_decode_slices ( H264Context h)

Call decode_slice() for each context.

Parameters
hh264 master context

Definition at line 2722 of file h264_slice.c.

Referenced by decode_nal_units(), and ff_h264_queue_decode_slice().

◆ ff_h264_update_thread_context()

int ff_h264_update_thread_context ( AVCodecContext dst,
const AVCodecContext src 
)

Definition at line 308 of file h264_slice.c.

◆ ff_h264_update_thread_context_for_user()

int ff_h264_update_thread_context_for_user ( AVCodecContext dst,
const AVCodecContext src 
)

Definition at line 458 of file h264_slice.c.

◆ ff_h264_flush_change()

void ff_h264_flush_change ( H264Context h)

Definition at line 445 of file h264dec.c.

Referenced by h264_decode_flush(), h264_decode_init(), and h264_init_ps().

◆ ff_h264_free_tables()

void ff_h264_free_tables ( H264Context h)

Definition at line 134 of file h264dec.c.

Referenced by h264_decode_end(), h264_decode_flush(), and h264_slice_header_init().

◆ ff_h264_set_erpic()

void ff_h264_set_erpic ( ERPicture dst,
H264Picture src 
)

Definition at line 196 of file h264_picture.c.

Referenced by decode_nal_units(), and h264_frame_start().

Variable Documentation

◆ ff_h264_mb_sizes

const uint16_t ff_h264_mb_sizes[4]

Definition at line 55 of file h264dec.c.

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