📄 rtp.c
字号:
destin = &ParSet[ps].PixAspectRatioX;
break;
}
if (!strncmp (s, "PixAspectRatioY", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].PixAspectRatioY;
break;
}
if (!strncmp (s, "DisplayWindowOffsetTop", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].DisplayWindowOffsetTop;
break;
}
if (!strncmp (s, "DisplayWindowOffsetBottom", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].DisplayWindowOffsetBottom;
break;
}
if (!strncmp (s, "DisplayWindowOffsetRight", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].DisplayWindowOffsetRight;
break;
}
if (!strncmp (s, "DisplayWindowOffsetLeft", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].DisplayWindowOffsetLeft;
break;
}
if (!strncmp (s, "XSizeMB", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].XSizeMB;
break;
}
if (!strncmp (s, "YSizeMB", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].YSizeMB;
break;
}
if (!strncmp (s, "FilterParametersFlag", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].FilterParametersFlag;
break;
}
if (!strncmp (s, "EntropyCoding", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_STRING;
interpreter = INTERPRET_ENTROPY_CODING;
destin = &ParSet[ps].EntropyCoding;
break;
}
if (!strncmp (s, "PartitioningType", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_STRING;
interpreter = INTERPRET_PARTITIONING_TYPE;
destin = &ParSet[ps].PartitioningType;
break;
}
if (!strncmp (s, "IntraPredictionType", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_STRING;
interpreter = INTERPRET_INTRA_PREDICTION;
destin = &ParSet[ps].IntraPredictionType;
break;
}
if (!strncmp (s, "HRCParameters", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].HRCParameters;
break;
}
if (!strncmp (s, "FramesToBeEncoded", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &InfoSet.FramesToBeEncoded;
break;
}
if (!strncmp (s, "FrameSkip", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &InfoSet.FrameSkip;
break;
}
if (!strncmp (s, "SequenceFileName", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_STRING;
interpreter = INTERPRET_COPY;
destin = &InfoSet.SequenceFileName;
break;
}
if (!strncmp (s, "NumberBFrames", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &InfoSet.NumberBFrames;
break;
}
// The FMOmap requires a special handling,because it contains more than one integer
if (!strncmp (s, "FMOmap", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT_LIST;
interpreter = INTERPRET_FMOMAP;
destin = &ParSet[ps].MBAmap;
break;
}
// JVT-D095, JVT-D097
if (!strncmp (s, "num_slice_groups_minus1", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].num_slice_groups_minus1;
break;
}
if (!strncmp (s, "mb_allocation_map_type", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].mb_allocation_map_type;
break;
}
if (!strncmp (s, "top_left_mb", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].top_left_mb;
break;
}
if (!strncmp (s, "bottom_right_mb", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].bottom_right_mb;
break;
}
if (!strncmp (s, "slice_group_change_direction", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].slice_group_change_direction;
break;
}
if (!strncmp (s, "slice_group_change_rate_minus1", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].slice_group_change_rate_minus1;
break;
}
// End JVT-D095, JVT-D097
// JVT-D101: redundant_slice_flag
if (!strncmp (s, "redundant_slice_flag", MAX_PARAMETER_STRINGLEN))
{
state = EXPECT_STRUCTVAL_INT;
interpreter = INTERPRET_COPY;
destin = &ParSet[ps].redundant_slice_flag;
break;
}
// End JVT-D101
// Here, all defined Parameter names are checked. Anything else is a syntax error
printf ("Syntax Error: unknown Parameter %s\n", s);
printf ("Parsing error in Header Packet: position %d, packet %s\n",
bufp, buf);
return -3;
break; // to make lint happy
case EXPECT_STRUCTVAL_INT:
if (1!=sscanf (&buf[bufp], "%d", (int *)destin))
{
printf ("Parsing error EXPECT STRUCTVAL INT in Header Packet: position %d, packet %s\n",
bufp, &buf[bufp]);
return -4;
}
// printf ("EXPECT_STRCUTVAL_INT: write %d\n", * (int *)destin);
while (bufp < buflen && buf[bufp] != '\n') // Skip any trailing whitespace and \n
bufp++;
bufp++;
state=EXPECT_ATTR;
break;
case EXPECT_STRUCTVAL_STRING:
if (1 != sscanf (&buf[bufp], "%100s", s))
{
printf ("Parsing error EXPECT STRUCTVAL STRING in Header Packet: position %d, packet %s\n",
bufp, &buf[bufp]);
return -5;
}
while (bufp < buflen && buf[bufp] != '\n') // Skip any trailing whitespace and \n
bufp++;
bufp++;
state=EXPECT_ATTR;
switch (interpreter)
{
case INTERPRET_COPY:
// nothing -- handled where it occurs
break;
case INTERPRET_ENTROPY_CODING:
if (!strncmp (s, "UVLC", 4))
* (int *)destin = 0;
else
* (int *)destin = 1;
// printf ("in Interpret, Entropy Coding :%s: results in %d\n", s, *(int *)destin);
break;
case INTERPRET_MOTION_RESOLUTION:
if (!strncmp (s, "quater", 6))
* (int *)destin = 0;
else
* (int *)destin = 1;
break;
case INTERPRET_INTRA_PREDICTION:
if (!strncmp (s, "Unconstrained", 14))
* (int *)destin = 0;
else
* (int *)destin = 1;
// printf ("Interpret Intra prediction returns %d\n", *(int*)destin);
break;
case INTERPRET_PARTITIONING_TYPE:
if (!strncmp (s, "one", 3))
* (int *)destin = 0;
else
* (int *)destin = 1;
break;
default:
assert (0==1);
}
break;
case EXPECT_STRUCTVAL_INT_LIST:
switch (interpreter)
{
case INTERPRET_FMOMAP:
{
int mb = 0;
// printf ("Interpret Parameterset: Getting the FMOmap, expected %d ints\n", ParSet[ps].XSizeMB*ParSet[ps].YSizeMB);
//! The FMOmap in the ParSet cosists of whitespace and backslash-
//! separated, single-digit integers. With this (and only this)
//! format the following code can deal.
if (ParSet[ps].MBAmap == NULL)
ParSet[ps].MBAmap = malloc (sizeof (int) * ParSet[ps].XSizeMB * ParSet[ps].YSizeMB);
assert (ParSet[ps].MBAmap != NULL);
while (bufp<buflen && buf[bufp] != '\004' && buf[bufp] != 'a')
{
if (isdigit (buf[bufp]))
{
if (mb >= ParSet[ps].XSizeMB*ParSet[ps].YSizeMB)
{
printf ("Interpret Parameterset: too many FMOmap entries, overwriting last entry\n");
mb--;
}
ParSet[ps].MBAmap[mb++] = (int) buf[bufp] - (int) '0';
}
bufp++;
}
state=EXPECT_ATTR;
}
break;
default:
printf ("Unknown Int List (not FMOmap??\?)\n");
assert (0==1);
}
break;
default:
printf ("Parsing error UNDEFINED SYNTAX in Header Packet: position %d, packet %s\n",
bufp, &buf[bufp]);
return -1;
}
// printf ("\t\t%d\n", bufp);
}
/*
printf ("CurrentParameterSet %d, ps %d\n", CurrentParameterSet, ps);
printf ("RTPInterpretParameterPacket: xsize x Ysize, %d x %d, Entropy %d, Motion %d MaxPicId %d\n",
ParSet[ps].XSizeMB, ParSet[ps].YSizeMB, ParSet[ps].EntropyCoding, ParSet[ps].MotionResolution, ParSet[ps].MaxPicID);
*/
ParSet[ps].Valid = 1;
return 0;
}
/*!
************************************************************************
* \brief
* Update img->xxx with the content of a parameter set, called for
* every slice
************************************************************************
*/
void RTPUseParameterSet (int n, struct img_par *img, struct inp_par *inp)
{
int status;
if (n == CurrentParameterSet)
return; // no change
// printf ("Use a new parameter set: old %d, new %d\n", CurrentParameterSet, n);
CurrentParameterSet = n;
status = RTP_PARAMETER_SET_OK;
if (CurrentParameterSet < 0 || (CurrentParameterSet > RTP_MAX_PARAMETER_SET))
{
printf ("Parameter Set %d out of range, conceal to 0\n", CurrentParameterSet);
CurrentParameterSet = 0; // and pray that it works...
status = RTP_PARAMETER_SET_OUT_OF_RANGE;
}
if (!ParSet[CurrentParameterSet].Valid)
{
printf ("Try to use uninitialized Parameter Set %d, conceal to 0\n", CurrentParameterSet);
CurrentParameterSet = 0;
status = RTP_PARAMETER_SET_INVALID;
}
// Now updates global decoder variables with the appropriate parameter set.
// A full-fledged decoder would make some consistency checks. For example,
// it makes sense to change the MotionResolution or the EntropyCode within
// a picture (img->current_mb_nr != 0). It doesn't make sense to change
// the pixel aspect ratio.
// There is no need to do those checks in an error free environment -- an
// encoder is simply not supposed to do so. In error prone environments,
// however, this is an additional means for error detection.
// Note: Many parameters are available in both the input-> and img-> structures.
// Some people seem to use the input-> parameters, others the img-> parameters.
// This should be cleaned up one day.
// For now simply copy any updated variables into both structures.
// MaxPicID: doesn't exist in pinput-> or img->
inp->buf_cycle = ParSet[CurrentParameterSet].BufCycle;
img->buf_cycle = inp->buf_cycle+1; // see init_global_buffers()
// PixAspectRatioX: doesn't exist
// PixAspectRatioY: doesn't exist
// DisplayWindowOffset*: doesn't exist
// XSizeMB
img->width = ParSet[CurrentParameterSet].XSizeMB*16;
img->width_cr = ParSet[CurrentParameterSet].XSizeMB*8;
//YSizeMB
img->height = ParSet[CurrentParameterSet].YSizeMB*16;
img->height_cr = ParSet[CurrentParameterSet].YSizeMB*8;
// FilterParamtersFlag
inp->LFParametersFlag = ParSet[CurrentParameterSet].FilterParametersFlag;
// EntropyCoding: nothing to do, all info is taken from active_pps->entropy_coding
/* if (ParSet[CurrentParameterSet].EntropyCoding == 0)
inp->symbol_mode = UVLC;
else
inp->symbol_mode = CABAC;
*/
// PartitioningType
// Nothing to do, info is taken from the first byte of the NALU
// inp->partition_mode = ParSet[CurrentParameterSet].PartitioningType;
// IntraPredictionType
//! inp->UseConstrainedIntraPred = img->UseConstrainedIntraPred = ParSet[CurrentParameterSet].IntraPredictionType;
//! img->type: This is calculated by using ParSet[CurrentParameterSet].UseMultpred
//! and the slice type from the slice header. It is set in RTPSetImgInp()
// HRCParameters: Doesn't exist
// FMO: MBAmap
FmoInit (img, inp, ParSet[CurrentParameterSet].XSizeMB,
ParSet[CurrentParameterSet].YSizeMB,
ParSet[CurrentParameterSet].MBAmap,
ParSet[CurrentParameterSet].XSizeMB * ParSet[CurrentParameterSet].YSizeMB);
// JVT-D095, JVT-D097
img->num_slice_groups_minus1 = ParSet[CurrentParameterSet].num_slice_groups_minus1;
img->mb_allocation_map_type = ParSet[CurrentParameterSet].mb_allocation_map_type;
img->top_left_mb = ParSet[CurrentParameterSet].top_left_mb;
img->bottom_right_mb = ParSet[CurrentParameterSet].bottom_right_mb;
img->slice_group_change_direction = ParSet[CurrentParameterSet].slice_group_change_direction;
img->slice_group_change_rate_minus1 = ParSet[CurrentParameterSet].slice_group_change_rate_minus1;
// End JVT-D095, JVT-D097
img->redundant_slice_flag = ParSet[CurrentParameterSet].redundant_slice_flag; // JVT-D101
}
/*!
*****************************************************************************
*
* \brief
* RTPReadDataPartitionedSlice collects all partitiobnss of the slice
*
*
* \return
* sequence number of the last pac
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -