erc_do_p.c File Reference

Inter (P) frame error concealment algorithms for decoder. More...

#include "global.h"
#include "mbuffer.h"
#include "memalloc.h"
#include "erc_do.h"
#include "image.h"
#include "mc_prediction.h"
#include "macroblock.h"

Include dependency graph for erc_do_p.c:

Go to the source code of this file.

Functions

static int concealByCopy (frame *recfr, int currMBNum, objectBuffer_t *object_list, int picSizeX)
static int concealByTrial (frame *recfr, imgpel *predMB, int currMBNum, objectBuffer_t *object_list, int predBlocks[], int picSizeX, int picSizeY, int *yCondition)
static int edgeDistortion (int predBlocks[], int currYBlockNum, imgpel *predMB, imgpel *recY, int picSizeX, int regionSize)
static void copyBetweenFrames (frame *recfr, int currYBlockNum, int picSizeX, int regionSize)
static void buildPredRegionYUV (ImageParameters *p_Img, int *mv, int x, int y, imgpel *predMB)
static void buildPredblockRegionYUV (ImageParameters *p_Img, int *mv, int x, int y, imgpel *predMB, int list)
static void CopyImgData (imgpel **inputY, imgpel ***inputUV, imgpel **outputY, imgpel ***outputUV, int img_width, int img_height, int img_width_cr, int img_height_cr)
static void copyPredMB (int currYBlockNum, imgpel *predMB, frame *recfr, int picSizeX, int regionSize)
static void add_node (ImageParameters *p_Img, struct concealment_node *concealment_new)
static void delete_node (ImageParameters *p_Img, struct concealment_node *ptr)
int ercConcealInterFrame (frame *recfr, objectBuffer_t *object_list, int picSizeX, int picSizeY, ercVariables_t *errorVar, int chroma_format_idc)
static int compare_pic_by_pic_num_desc (const void *arg1, const void *arg2)
static int compare_pic_by_lt_pic_num_asc (const void *arg1, const void *arg2)
static int compare_pic_by_poc_asc (const void *arg1, const void *arg2)
static int compare_pic_by_poc_desc (const void *arg1, const void *arg2)
static StorablePictureget_last_ref_pic_from_dpb (DecodedPictureBuffer *p_Dpb)
static void copy_to_conceal (StorablePicture *src, StorablePicture *dst, ImageParameters *p_Img)
static void copy_prev_pic_to_concealed_pic (StorablePicture *picture, ImageParameters *p_Img)
void conceal_lost_frames (ImageParameters *p_Img)
void update_ref_list_for_concealment (DecodedPictureBuffer *p_Dpb)
void init_lists_for_non_reference_loss (ImageParameters *p_Img, int currSliceType, PictureStructure currPicStructure)
StorablePictureget_pic_from_dpb (ImageParameters *p_Img, int missingpoc, unsigned int *pos)
int comp (const void *i, const void *j)
struct concealment_node * init_node (StorablePicture *picture, int missingpoc)
void print_node (struct concealment_node *ptr)
void print_list (struct concealment_node *ptr)
void delete_list (ImageParameters *p_Img, struct concealment_node *ptr)
void conceal_non_ref_pics (ImageParameters *p_Img, int diff)
void sliding_window_poc_management (DecodedPictureBuffer *p_Dpb, StorablePicture *p)
void write_lost_non_ref_pic (ImageParameters *p_Img, int poc, int p_out)
void write_lost_ref_after_idr (ImageParameters *p_Img, int pos)

Variables

static const int uv_div [2][4] = {{0, 1, 1, 0}, {0, 1, 0, 0}}


Detailed Description

Inter (P) frame error concealment algorithms for decoder.

erc_do_p.c

Author:

Definition in file erc_do_p.c.


Function Documentation

static void add_node ( ImageParameters *  p_Img,
struct concealment_node *  ptr 
) [static]

Adds a node to the end of the list.

Definition at line 1640 of file erc_do_p.c.

Referenced by conceal_non_ref_pics().

static void buildPredblockRegionYUV ( ImageParameters *  p_Img,
int *  mv,
int  x,
int  y,
imgpel *  predMB,
int  list 
) [static]

The motion prediction pixels are calculated from the given location (in 1/4 pixel units) of the referenced frame. It copies the sub block from the corresponding reference to the frame to be concealed.

Definition at line 855 of file erc_do_p.c.

References free_mem2Dpel(), get_block_luma(), get_mem2Dpel(), macroblock::p_Slice, subblk_offset_x, and YUV400.

Referenced by copy_to_conceal().

Here is the call graph for this function:

static void buildPredRegionYUV ( ImageParameters *  p_Img,
int *  mv,
int  x,
int  y,
imgpel *  predMB 
) [static]

Builds the motion prediction pixels from the given location (in 1/4 pixel units) of the reference frame. It not only copies the pixel values but builds the interpolation when the pixel positions to be copied from is not full pixel (any 1/4 pixel position). It copies the resulting pixel vlaues into predMB.

Parameters:
p_Img The pointer of img_par struture of current frame
mv The pointer of the predicted MV of the current (being concealed) MB
x The x-coordinate of the above-left corner pixel of the current MB
y The y-coordinate of the above-left corner pixel of the current MB
predMB memory area for storing temporary pixel values for a macroblock the Y,U,V planes are concatenated y = predMB, u = predMB+256, v = predMB+320

Definition at line 547 of file erc_do_p.c.

References free_mem2Dpel(), get_block_luma(), get_mem2Dpel(), macroblock::p_Slice, subblk_offset_x, and YUV400.

Referenced by concealByTrial().

Here is the call graph for this function:

int comp ( const void *  i,
const void *  j 
)

Function to sort the POC and find the lowest number in the POC list Compare the integers.

Definition at line 1570 of file erc_do_p.c.

Referenced by conceal_non_ref_pics(), and concealByTrial().

static int compare_pic_by_lt_pic_num_asc ( const void *  arg1,
const void *  arg2 
) [inline, static]

compares two stored pictures by picture number for qsort in descending order

Definition at line 1001 of file erc_do_p.c.

Referenced by init_lists_for_non_reference_loss().

static int compare_pic_by_pic_num_desc ( const void *  arg1,
const void *  arg2 
) [inline, static]

compares two stored pictures by picture number for qsort in descending order

Definition at line 981 of file erc_do_p.c.

Referenced by init_lists_for_non_reference_loss().

static int compare_pic_by_poc_asc ( const void *  arg1,
const void *  arg2 
) [inline, static]

compares two stored pictures by poc for qsort in ascending order

Definition at line 1021 of file erc_do_p.c.

Referenced by init_lists_for_non_reference_loss().

static int compare_pic_by_poc_desc ( const void *  arg1,
const void *  arg2 
) [inline, static]

compares two stored pictures by poc for qsort in descending order

Definition at line 1042 of file erc_do_p.c.

Referenced by init_lists_for_non_reference_loss().

void conceal_lost_frames ( ImageParameters *  p_Img  ) 

This function conceals a missing reference frame. The routine is called based on the difference in frame number. It conceals an IDR frame loss based on the sudden decrease in frame number.

Definition at line 1284 of file erc_do_p.c.

References alloc_storable_picture(), copy_prev_pic_to_concealed_pic(), flush_dpb(), and store_picture_in_dpb().

Referenced by init_picture().

Here is the call graph for this function:

void conceal_non_ref_pics ( ImageParameters *  p_Img,
int  diff 
)

Stores the missing non reference frames in the concealment buffer. The detection is based on the POC difference in the sorted POC array. A missing non reference frame is detected when the dpb is full. A singly linked list is maintained for storing the missing non reference frames.

Definition at line 1720 of file erc_do_p.c.

References add_node(), alloc_storable_picture(), comp(), copy_to_conceal(), get_pic_from_dpb(), init_node(), and update_ref_list_for_concealment().

Referenced by flush_dpb(), and store_picture_in_dpb().

Here is the call graph for this function:

static int concealByCopy ( frame recfr,
int  currMBNum,
objectBuffer_t object_list,
int  picSizeX 
) [static]

It conceals a given MB by simply copying the pixel area from the reference image that is at the same location as the macroblock in the current image. This correcponds to COPY MBs.

Returns:
Always zero (0).
Parameters:
recfr Reconstructed frame buffer
currMBNum current MB index
object_list Motion info for all MBs in the frame
picSizeX Width of the frame in pixels

Definition at line 239 of file erc_do_p.c.

References copyBetweenFrames(), object_buffer::regionMode, REGMODE_INTER_COPY, object_buffer::xMin, and object_buffer::yMin.

Referenced by ercConcealInterFrame().

Here is the call graph for this function:

static int concealByTrial ( frame recfr,
imgpel *  predMB,
int  currMBNum,
objectBuffer_t object_list,
int  predBlocks[],
int  picSizeX,
int  picSizeY,
int *  yCondition 
) [static]

It conceals a given MB by using the motion vectors of one reliable neighbor. That MV of a neighbor is selected wich gives the lowest pixel difference at the edges of the MB (see function edgeDistortion). This corresponds to a spatial smoothness criteria.

Returns:
Always zero (0).
Parameters:
recfr Reconstructed frame buffer
predMB memory area for storing temporary pixel values for a macroblock the Y,U,V planes are concatenated y = predMB, u = predMB+256, v = predMB+320
currMBNum current MB index
object_list array of region structures storing region mode and mv for each region
predBlocks status array of the neighboring blocks (if they are OK, concealed or lost)
picSizeX Width of the frame in pixels
picSizeY Height of the frame in pixels
yCondition array for conditions of Y blocks from ercVariables_t

Definition at line 329 of file erc_do_p.c.

References buildPredRegionYUV(), comp(), copyPredMB(), edgeDistortion(), object_buffer::mv, object_buffer::regionMode, REGMODE_INTER_COPY, REGMODE_INTER_PRED, object_buffer::xMin, and object_buffer::yMin.

Referenced by ercConcealInterFrame().

Here is the call graph for this function:

static void copy_prev_pic_to_concealed_pic ( StorablePicture picture,
ImageParameters *  p_Img 
) [static]

Uses the previous reference pic for concealment of reference frames.

Definition at line 1258 of file erc_do_p.c.

References copy_to_conceal(), and get_last_ref_pic_from_dpb().

Referenced by conceal_lost_frames().

Here is the call graph for this function:

static void copy_to_conceal ( StorablePicture src,
StorablePicture dst,
ImageParameters *  p_Img 
) [static]

Conceals the lost reference or non reference frame by either frame copy or motion vector copy concealment.

Definition at line 1116 of file erc_do_p.c.

References buildPredblockRegionYUV(), CopyImgData(), storable_picture::imgUV, storable_picture::imgY, init_lists(), init_lists_for_non_reference_loss(), storable_picture::motion, pic_motion_params::mv, pic_motion_params::ref_idx, and YUV400.

Referenced by conceal_non_ref_pics(), copy_prev_pic_to_concealed_pic(), and write_lost_ref_after_idr().

Here is the call graph for this function:

static void copyBetweenFrames ( frame recfr,
int  currYBlockNum,
int  picSizeX,
int  regionSize 
) [static]

Copies the co-located pixel values from the reference to the current frame. Used by concealByCopy.

Parameters:
recfr Reconstructed frame buffer
currYBlockNum index of the block (8x8) in the Y plane
picSizeX Width of the frame in pixels
regionSize can be 16 or 8 to tell the dimension of the region to copy

Definition at line 270 of file erc_do_p.c.

References storable_picture::imgUV, and storable_picture::imgY.

Referenced by concealByCopy().

static void CopyImgData ( imgpel **  inputY,
imgpel ***  inputUV,
imgpel **  outputY,
imgpel ***  outputUV,
int  img_width,
int  img_height,
int  img_width_cr,
int  img_height_cr 
) [static]

Copy image data from one array to another array.

Definition at line 1062 of file erc_do_p.c.

Referenced by copy_to_conceal().

static void copyPredMB ( int  currYBlockNum,
imgpel *  predMB,
frame recfr,
int  picSizeX,
int  regionSize 
) [static]

Copies pixel values between a YUV frame and the temporary pixel value storage place. This is used to save some pixel values temporarily before overwriting it, or to copy back to a given location in a frame the saved pixel values.

Parameters:
currYBlockNum index of the block (8x8) in the Y plane
predMB memory area where the temporary pixel values are stored the Y,U,V planes are concatenated y = predMB, u = predMB+256, v = predMB+320
recfr pointer to a YUV frame
picSizeX picture width in pixels
regionSize can be 16 or 8 to tell the dimension of the region to copy

Definition at line 702 of file erc_do_p.c.

References storable_picture::imgUV, storable_picture::imgY, and YUV400.

Referenced by concealByTrial().

void delete_list ( ImageParameters *  p_Img,
struct concealment_node *  ptr 
)

Deletes all nodes from the place specified by ptr.

Definition at line 1681 of file erc_do_p.c.

static void delete_node ( ImageParameters *  p_Img,
struct concealment_node *  ptr 
) [static]

Deletes the specified node pointed to by 'ptr' from the list.

Definition at line 1661 of file erc_do_p.c.

Referenced by write_lost_non_ref_pic().

static int edgeDistortion ( int  predBlocks[],
int  currYBlockNum,
imgpel *  predMB,
imgpel *  recY,
int  picSizeX,
int  regionSize 
) [static]

Calculates a weighted pixel difference between edge Y pixels of the macroblock stored in predMB and the pixels in the given Y plane of a frame (recY) that would become neighbor pixels if predMB was placed at currYBlockNum block position into the frame. This "edge distortion" value is used to determine how well the given macroblock in predMB would fit into the frame when considering spatial smoothness. If there are correctly received neighbor blocks (status stored in predBlocks) only they are used in calculating the edge distorion; otherwise also the already concealed neighbor blocks can also be used.

Returns:
The calculated weighted pixel difference at the edges of the MB.
Parameters:
predBlocks status array of the neighboring blocks (if they are OK, concealed or lost)
currYBlockNum index of the block (8x8) in the Y plane
predMB memory area where the temporary pixel values are stored the Y,U,V planes are concatenated y = predMB, u = predMB+256, v = predMB+320
recY pointer to a Y plane of a YUV frame
picSizeX picture width in pixels
regionSize can be 16 or 8 to tell the dimension of the region to copy

Definition at line 772 of file erc_do_p.c.

Referenced by concealByTrial().

int ercConcealInterFrame ( frame recfr,
objectBuffer_t object_list,
int  picSizeX,
int  picSizeY,
ercVariables_t *  errorVar,
int  chroma_format_idc 
)

The main function for Inter (P) frame concealment.

Returns:
0, if the concealment was not successful and simple concealment should be used 1, otherwise (even if none of the blocks were concealed)
Parameters:
recfr Reconstructed frame buffer
object_list Motion info for all MBs in the frame
picSizeX Width of the frame in pixels
picSizeY Height of the frame in pixels
errorVar Variables for error concealment
chroma_format_idc Chroma format IDC

Definition at line 74 of file erc_do_p.c.

References concealByCopy(), concealByTrial(), ercCollect8PredBlocks(), ercMarkCurrMBConcealed(), no_mem_exit(), and YUV400.

Referenced by exit_picture().

Here is the call graph for this function:

static StorablePicture* get_last_ref_pic_from_dpb ( DecodedPictureBuffer p_Dpb  )  [static]

Copies the last reference frame for concealing reference frame loss.

Definition at line 1086 of file erc_do_p.c.

References frame_store::is_used.

Referenced by copy_prev_pic_to_concealed_pic().

StorablePicture* get_pic_from_dpb ( ImageParameters *  p_Img,
int  missingpoc,
unsigned int *  pos 
)

Get from the dpb the picture corresponding to a POC. The POC varies depending on whether it is a frame copy or motion vector copy concealment. The frame corresponding to the POC is returned.

Definition at line 1538 of file erc_do_p.c.

Referenced by conceal_non_ref_pics().

void init_lists_for_non_reference_loss ( ImageParameters *  p_Img,
int  currSliceType,
PictureStructure  currPicStructure 
)

Initialize the list based on the B frame or non reference 'p' frame to be concealed. The function initialize p_Img->listX[0] and list 1 depending on current picture type.

Definition at line 1400 of file erc_do_p.c.

References compare_pic_by_lt_pic_num_asc(), compare_pic_by_pic_num_desc(), compare_pic_by_poc_asc(), and compare_pic_by_poc_desc().

Referenced by copy_to_conceal().

Here is the call graph for this function:

struct concealment_node* init_node ( StorablePicture picture,
int  missingpoc 
) [read]

Initialises a node, allocates memory for the node, and returns a pointer to the new node.

Definition at line 1584 of file erc_do_p.c.

Referenced by conceal_non_ref_pics().

void print_list ( struct concealment_node *  ptr  ) 

Prints all nodes from the current address passed to it.

Definition at line 1622 of file erc_do_p.c.

References print_node().

Here is the call graph for this function:

void print_node ( struct concealment_node *  ptr  ) 

Prints the details of a node.

Definition at line 1608 of file erc_do_p.c.

Referenced by print_list().

void sliding_window_poc_management ( DecodedPictureBuffer p_Dpb,
StorablePicture p 
)

Perform Sliding window decoded reference picture marking process. It maintains the POC s stored in the dpb at a specific instance.

Definition at line 1786 of file erc_do_p.c.

Referenced by store_picture_in_dpb().

void update_ref_list_for_concealment ( DecodedPictureBuffer p_Dpb  ) 

Updates the reference list for motion vector copy concealment for non- reference frame loss.

Definition at line 1375 of file erc_do_p.c.

Referenced by conceal_non_ref_pics().

void write_lost_non_ref_pic ( ImageParameters *  p_Img,
int  poc,
int  p_out 
)

Outputs the non reference frames. The POCs in the concealment buffer are sorted in ascending order and outputted when the lowest POC in the concealment buffer is lower than the lowest in the p_Dpb-> The linked list entry corresponding to the outputted POC is immediately deleted.

Definition at line 1812 of file erc_do_p.c.

References delete_node(), frame_store::is_reference, frame_store::is_used, and write_stored_frame().

Referenced by output_one_frame_from_dpb().

Here is the call graph for this function:

void write_lost_ref_after_idr ( ImageParameters *  p_Img,
int  pos 
)

Conceals frame loss immediately after the IDR. This special case produces the same result for either frame copy or motion vector copy concealment.

Definition at line 1841 of file erc_do_p.c.

References alloc_storable_picture(), and copy_to_conceal().

Referenced by output_one_frame_from_dpb().

Here is the call graph for this function:


Documentation generated with DoxyGen