/*!
 ************************************************************************
 * \brief
 *    Generates MapUnitToSliceGroupMap
 *    Has to be called every time a new Picture Parameter Set is used
 *
 * \param pps
 *    Picture Parameter set to be used for map generation
 * \param sps
 *    Sequence Parameter set to be used for map generation
 *
 ************************************************************************
 */
static int FmoGenerateMapUnitToSliceGroupMap (pic_parameter_set_rbsp_t* pps, seq_parameter_set_rbsp_t* sps)
{
  unsigned int NumSliceGroupMapUnits;

  NumSliceGroupMapUnits = (sps->pic_height_in_map_units_minus1+1)* (sps->pic_width_in_mbs_minus1+1);

  if (pps->slice_group_map_type == 6)
  {
    if ((pps->num_slice_group_map_units_minus1+1) != NumSliceGroupMapUnits)
    {
      error ("wrong pps->num_slice_group_map_units_minus1 for used SPS and FMO type 6", 500);
    }
  }

  // allocate memory for MapUnitToSliceGroupMap
  if (MapUnitToSliceGroupMap)
    free (MapUnitToSliceGroupMap);
  if ((MapUnitToSliceGroupMap = malloc ((NumSliceGroupMapUnits) * sizeof (int))) == NULL)
  {
    printf ("cannot allocated %d bytes for MapUnitToSliceGroupMap, exit\n", (int) ( (pps->num_slice_group_map_units_minus1+1) * sizeof (int)));
    exit (-1);
  }

  if (pps->num_slice_groups_minus1 == 0)    // only one slice group
  {
    memset (MapUnitToSliceGroupMap, 0, NumSliceGroupMapUnits * sizeof (int));
    return 0;
  }

  switch (pps->slice_group_map_type)
  {
  case 0:
    FmoGenerateType0MapUnitMap (pps, sps, NumSliceGroupMapUnits);
    break;
  case 1:
    FmoGenerateType1MapUnitMap (pps, sps, NumSliceGroupMapUnits);
    break;
  case 2:
    FmoGenerateType2MapUnitMap (pps, sps, NumSliceGroupMapUnits);
    break;
  case 3:
    FmoGenerateType3MapUnitMap (pps, sps, NumSliceGroupMapUnits);
    break;
  case 4:
    FmoGenerateType4MapUnitMap (pps, sps, NumSliceGroupMapUnits);
    break;
  case 5:
    FmoGenerateType5MapUnitMap (pps, sps, NumSliceGroupMapUnits);
    break;
  case 6:
    FmoGenerateType6MapUnitMap (pps, sps, NumSliceGroupMapUnits);
    break;
  default:
    printf ("Illegal slice_group_map_type %d , exit \n", (int) pps->slice_group_map_type);
    exit (-1);
  }
  return 0;
}
/*!
 ************************************************************************
 * \brief
 *    Generates p_Vid->MapUnitToSliceGroupMap 
 *
 * \param p_Vid
 *    Image Parameter to be used for map generation
 * \param pps
 *    Picture Parameter set to be used for map generation
 *
 ************************************************************************
 */
static int FmoGenerateMapUnitToSliceGroupMap (VideoParameters * p_Vid, pic_parameter_set_rbsp_t * pps)
{
  p_Vid->PicSizeInMapUnits = p_Vid->PicHeightInMapUnits * p_Vid->PicWidthInMbs;


  if (pps->slice_group_map_type == 6)
  {
    if ((pps->pic_size_in_map_units_minus1+1) != p_Vid->PicSizeInMapUnits)
    {
      error ("wrong pps->pic_size_in_map_units_minus1 for used SPS and FMO type 6", 500);
    }
  }

  // allocate memory for p_Vid->MapUnitToSliceGroupMap 
  if (p_Vid->MapUnitToSliceGroupMap)
    free (p_Vid->MapUnitToSliceGroupMap);

  if ((p_Vid->MapUnitToSliceGroupMap = malloc ((p_Vid->PicSizeInMapUnits) * sizeof (byte))) == NULL)
  {
    printf ("cannot allocated %d bytes for p_Vid->MapUnitToSliceGroupMap , exit\n", (int) ( p_Vid->PicSizeInMapUnits * sizeof (byte)));
    exit (-1);
  }

  if (pps->num_slice_groups_minus1 == 0)    // only one slice group
  {
    memset (p_Vid->MapUnitToSliceGroupMap, 0,  p_Vid->PicSizeInMapUnits * sizeof (byte));
    return 0;
  }

  switch (pps->slice_group_map_type)
  {
  case 0:
    FmoGenerateType0MapUnitMap (p_Vid, pps);
    break;
  case 1:
    FmoGenerateType1MapUnitMap (p_Vid, pps);
    break;
  case 2:
    FmoGenerateType2MapUnitMap (p_Vid, pps);
    break;
  case 3:
    FmoGenerateType3MapUnitMap (p_Vid, pps);
    break;
  case 4:
    FmoGenerateType4MapUnitMap (p_Vid, pps);
    break;
  case 5:
    FmoGenerateType5MapUnitMap (p_Vid, pps);
    break;
  case 6:
    FmoGenerateType6MapUnitMap (p_Vid, pps);
    break;
  default:
    printf ("Illegal slice_group_map_type %d , exit \n", pps->slice_group_map_type);
    exit (-1);
  }
  return 0;
}
Exemple #3
0
/* see subclause 8.2.2 Decoding process for macroblock to slice group map */
AVCStatus FMOInit(AVCCommonObj *video)
{
    AVCPicParamSet *currPPS = video->currPicParams;
    int *MbToSliceGroupMap = video->MbToSliceGroupMap;
    int PicSizeInMapUnits = video->PicSizeInMapUnits;
    int PicWidthInMbs = video->PicWidthInMbs;

    if (currPPS->num_slice_groups_minus1 == 0)
    {
        oscl_memset(video->MbToSliceGroupMap, 0, video->PicSizeInMapUnits*sizeof(uint));
    }
    else
    {
        switch (currPPS->slice_group_map_type)
        {
            case 0:
                FmoGenerateType0MapUnitMap(MbToSliceGroupMap, currPPS->run_length_minus1, currPPS->num_slice_groups_minus1, PicSizeInMapUnits);
                break;
            case 1:
                FmoGenerateType1MapUnitMap(MbToSliceGroupMap, PicWidthInMbs, currPPS->num_slice_groups_minus1, PicSizeInMapUnits);
                break;
            case 2:
                FmoGenerateType2MapUnitMap(currPPS, MbToSliceGroupMap, PicWidthInMbs, currPPS->num_slice_groups_minus1, PicSizeInMapUnits);
                break;
            case 3:
                FmoGenerateType3MapUnitMap(video, currPPS, MbToSliceGroupMap, PicWidthInMbs);
                break;
            case 4:
                FmoGenerateType4MapUnitMap(MbToSliceGroupMap, video->MapUnitsInSliceGroup0, currPPS->slice_group_change_direction_flag, PicSizeInMapUnits);
                break;
            case 5:
                FmoGenerateType5MapUnitMap(MbToSliceGroupMap, video, currPPS->slice_group_change_direction_flag, PicSizeInMapUnits);
                break;
            case 6:
                FmoGenerateType6MapUnitMap(MbToSliceGroupMap, (int*)currPPS->slice_group_id, PicSizeInMapUnits);
                break;
            default:
                return AVC_FAIL; /* out of range, shouldn't come this far */
        }
    }

    return AVC_SUCCESS;
}