FFmpeg
Loading...
Searching...
No Matches
error_resilience.c File Reference

Error resilience / concealment. More...

#include <limits.h>
#include "libavutil/avassert.h"
#include "libavutil/attributes.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "error_resilience.h"
#include "mathops.h"
#include "me_cmp.h"
#include "mpegutils.h"
#include "mpegvideo.h"
#include "threadframe.h"
#include "threadprogress.h"

Go to the source code of this file.

Macros

#define MV_FROZEN   8
 
#define MV_CHANGED   4
 
#define MV_UNCHANGED   2
 
#define MV_LISTED   1
 

Functions

av_cold int ff_er_init (ERContext *const s)
 
static void set_mv_strides (ERContext *s, ptrdiff_t *mv_step, ptrdiff_t *stride)
 
static void put_dc (ERContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int mb_x, int mb_y)
 Replace the current MB with a flat dc-only version.
 
static void filter181 (int16_t *data, int width, int height, ptrdiff_t stride)
 
static void guess_dc (ERContext *s, int16_t *dc, int w, int h, ptrdiff_t stride, int is_luma)
 guess the dc of blocks which do not have an undamaged dc
 
static void h_block_filter (ERContext *s, uint8_t *dst, int w, int h, ptrdiff_t stride, int is_luma)
 simple horizontal deblocking filter used for error resilience
 
static void v_block_filter (ERContext *s, uint8_t *dst, int w, int h, ptrdiff_t stride, int is_luma)
 simple vertical deblocking filter used for error resilience
 
static av_always_inline void add_blocklist (int(*blocklist)[2], int *blocklist_length, uint8_t *fixed, int mb_x, int mb_y, int mb_xy)
 
static void guess_mv (ERContext *s)
 
static int is_intra_more_likely (ERContext *s)
 
void ff_er_frame_start (ERContext *s)
 
static int er_supported (ERContext *s)
 
void ff_er_add_slice (ERContext *s, int startx, int starty, int endx, int endy, int status)
 Add a slice.
 
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 and is necessary and supported.
 

Detailed Description

Error resilience / concealment.

Definition in file error_resilience.c.

Macro Definition Documentation

◆ MV_FROZEN

#define MV_FROZEN   8

Definition at line 397 of file error_resilience.c.

Referenced by guess_mv().

◆ MV_CHANGED

#define MV_CHANGED   4

Definition at line 398 of file error_resilience.c.

Referenced by guess_mv().

◆ MV_UNCHANGED

#define MV_UNCHANGED   2

Definition at line 399 of file error_resilience.c.

Referenced by guess_mv().

◆ MV_LISTED

#define MV_LISTED   1

Definition at line 400 of file error_resilience.c.

Referenced by add_blocklist().

Function Documentation

◆ ff_er_init()

av_cold int ff_er_init ( ERContext *const s)

Definition at line 42 of file error_resilience.c.

Referenced by ff_h264_alloc_tables(), and ff_mpeg_er_init().

◆ set_mv_strides()

static void set_mv_strides ( ERContext * s,
ptrdiff_t * mv_step,
ptrdiff_t * stride )
static
Parameters
stridethe number of MVs to get to the next row
mv_stepthe number of MVs per row or column in a macroblock

Definition at line 64 of file error_resilience.c.

Referenced by guess_mv(), h_block_filter(), and v_block_filter().

◆ put_dc()

static void put_dc ( ERContext * s,
uint8_t * dest_y,
uint8_t * dest_cb,
uint8_t * dest_cr,
int mb_x,
int mb_y )
static

Replace the current MB with a flat dc-only version.

Definition at line 79 of file error_resilience.c.

Referenced by ff_er_frame_end().

◆ filter181()

static void filter181 ( int16_t * data,
int width,
int height,
ptrdiff_t stride )
static

Definition at line 117 of file error_resilience.c.

Referenced by ff_er_frame_end().

◆ guess_dc()

static void guess_dc ( ERContext * s,
int16_t * dc,
int w,
int h,
ptrdiff_t stride,
int is_luma )
static

guess the dc of blocks which do not have an undamaged dc

Parameters
wwidth in 8 pixel blocks
hheight in 8 pixel blocks

Definition at line 158 of file error_resilience.c.

Referenced by ff_er_frame_end().

◆ h_block_filter()

static void h_block_filter ( ERContext * s,
uint8_t * dst,
int w,
int h,
ptrdiff_t stride,
int is_luma )
static

simple horizontal deblocking filter used for error resilience

Parameters
wwidth in 8 pixel blocks
hheight in 8 pixel blocks

Definition at line 261 of file error_resilience.c.

Referenced by ff_er_frame_end().

◆ v_block_filter()

static void v_block_filter ( ERContext * s,
uint8_t * dst,
int w,
int h,
ptrdiff_t stride,
int is_luma )
static

simple vertical deblocking filter used for error resilience

Parameters
wwidth in 8 pixel blocks
hheight in 8 pixel blocks

Definition at line 330 of file error_resilience.c.

Referenced by ff_er_frame_end().

◆ add_blocklist()

static av_always_inline void add_blocklist ( int(*) blocklist[2],
int * blocklist_length,
uint8_t * fixed,
int mb_x,
int mb_y,
int mb_xy )
static

Definition at line 401 of file error_resilience.c.

Referenced by guess_mv().

◆ guess_mv()

static void guess_mv ( ERContext * s)
static

Definition at line 410 of file error_resilience.c.

Referenced by ff_er_frame_end().

◆ is_intra_more_likely()

static int is_intra_more_likely ( ERContext * s)
static

Definition at line 743 of file error_resilience.c.

Referenced by ff_er_frame_end().

◆ ff_er_frame_start()

void ff_er_frame_start ( ERContext * s)

Definition at line 812 of file error_resilience.c.

Referenced by ff_mpeg_er_frame_start(), and h264_frame_start().

◆ er_supported()

static int er_supported ( ERContext * s)
static

Definition at line 823 of file error_resilience.c.

Referenced by ff_er_add_slice(), and ff_er_frame_end().

◆ ff_er_add_slice()

void ff_er_add_slice ( ERContext * s,
int startx,
int starty,
int endx,
int endy,
int status )

Add a slice.

Parameters
endxx component of the last macroblock, can be -1 for the last of the previous line
statusthe status at the end (ER_MV_END, ER_AC_ERROR, ...), it is assumed that no earlier end or error of the same type occurred

Definition at line 840 of file error_resilience.c.

Referenced by decode_chunks(), decode_slice(), er_add_slice(), ff_mpeg4_decode_partitions(), ff_vc1_decode_blocks(), ff_wmv2_decode_secondary_picture_header(), rv10_decode_packet(), rv34_decode_slice(), slice_decode_thread(), vc1_decode_b_blocks(), vc1_decode_i_blocks(), vc1_decode_i_blocks_adv(), vc1_decode_p_blocks(), and vc1_decode_skip_blocks().

◆ ff_er_frame_end()

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 and is necessary and supported.

Parameters
sERContext in use
decode_error_flagspointer where updated decode_error_flags are written if supplied; if not, the new flags are directly applied to the AVFrame whose errors are concealed

Definition at line 910 of file error_resilience.c.

Referenced by decode_nal_units(), decode_wmv9(), ff_h263_decode_frame(), ff_rv34_decode_frame(), finish_frame(), rv10_decode_frame(), rv10_decode_packet(), slice_end(), and vc1_decode_frame().