[FFmpeg-devel] [PATCH 02/18] h264: Add stream constraint values to the common header

Mark Thompson sw at jkqxz.net
Mon Aug 21 13:56:11 EEST 2017


On 21/08/17 02:09, Michael Niedermayer wrote:
> On Sun, Aug 20, 2017 at 11:41:30PM +0100, Mark Thompson wrote:
>> With comments describing the derivation of each value.
>>
>> (cherry picked from commit aaf441465080b9bc57f5ca8dea656f9b2c5dc821)
>> ---
>>  libavcodec/h264.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 45 insertions(+)
>>
>> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
>> index 86df5eb9b3..650580bf3a 100644
>> --- a/libavcodec/h264.h
>> +++ b/libavcodec/h264.h
>> @@ -44,4 +44,49 @@ enum {
>>      H264_NAL_AUXILIARY_SLICE = 19,
>>  };
>>  
>> +
>> +enum {
> 
> why is this a enum ?

I believe that compile-time symbolic constants are preferable to preprocessor string replacement.

>> +    // 7.4.2.1.1: seq_parameter_set_id is in [0, 31].
>> +    H264_MAX_SPS_COUNT = 32,
> 
> Could be doxygen comment compatible

Would that have any value?  The comments are explaining the derivation for verification purposes rather than anything to do with the actual use.

>> +    // A.3: in table A-1 the highest level allows a MaxFS of 139264.
>> +    H264_MAX_MB_PIC_SIZE = 139264,
>> +    // A.3.1, A.3.2: PicWidthInMbs and PicHeightInMbs are constrained
>> +    // to be not greater than sqrt(MaxFS * 8).  Hence height/width are
>> +    // bounded above by sqrt(139264 * 8) = 1055.5 macroblocks.
>> +    H264_MAX_MB_WIDTH    = 1055,
>> +    H264_MAX_MB_HEIGHT   = 1055,
>> +    H264_MAX_WIDTH       = H264_MAX_MB_WIDTH  * 16,
>> +    H264_MAX_HEIGHT      = H264_MAX_MB_HEIGHT * 16,
> 
> There should be no problem with files outside these limits. They would
> be valid H.264 files, just not within the level and profile constraints
> of the currently defined profiles and levels.
> or do i miss something ?
Currently these values are used for some fixed-size tables in cbs (e.g. H264_MAX_MB_PIC_SIZE is needed for slice_group_id[]).  More generally, I don't want to consider files which don't conform to some level limits - once you allow MaxDPBFrames to exceed 16 the world is a terrible place.

(I am not intending to add this constraint to the existing decoder.)

Thanks,

- Mark


More information about the ffmpeg-devel mailing list