ffmpeg h264 dynamic resolution decoding process

1. Background

When measuring ffmpeg init 264 decode, the configuration is 1080p resolution, and the 360p data can be parsed normally. On the contrary, init is configured with 360p resolution, and the actual 1080p data can be parsed normally.

2. Analysis

To analyze the source code, every time the decoder receives SPS data, it will re-update and initialize the decoder parameters.

h264_decode_frame  
->ff_h264_decode_extradata
->decode_nal_units
->ff_h264_decode_seq_parameter_set 
Get the encoding parameters in SPS, such as resolution, etc.

h264_decode_frame  
->decode_nal_units 
-> ff_h264_decode_slice_header (according to SPS parameters, update new encoding parameters, such as resolution) 
->h264_slice_header_init 
->ff_h264_alloc_tables apply for macro block memory according to the new resolution

ff_h264_decode_slice_header (according to SPS parameters, update new encoding parameters, such as resolution) 

ff_h264_alloc_tables apply for macro block memory according to the new resolution

3. Conclusion

The decoder can re-initialize the decoder every time it receives the SPS of the IDR frame, and can adaptively decode data of different resolutions.

Guess you like

Origin blog.csdn.net/CrystalShaw/article/details/129619305