Nvv4l2decoder error when stream type switch

nvv4l2decoder crash when stream switch from mjpeg to h264.
why occur the error? why this error can’t recover when it occur? can this error recover?
the error print:

NvMMLiteOpen : Block : BlockType = 277
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 277
nvbufsurface: Invalid buffer size=0
nvbufsurface: Error in allocating buffer
ERROR from element vdec-nvv4l2decoder2: Failed to allocate required memory.
Error details: /dvs/git/dirty/git-master_linux/3rdparty/gst/gst-v4l2/gst-v4l2/gstv4l2videodec.c(1581): gst_v4l2_video_dec_handle_frame (): /GstPipeline:media-pipeline/GstBin:vdec_subbin4/nvv4l2decoder:vdec-nvv4l2decoder2:
Buffer pool activation failed

Dynamic format switching is not supported. After the switch, you need to destroy the original pipeline and re-initialize a new pipeline.

we only change stream type, vdec type not change that the setting is nvv4l2decoder and H264parse. only switch from mjpeg stream to h264 stream.

If the decoder is initialized for decoding h264 stream, please send only h264 stream to decoder. And when the stream type is changed, please destroy the current decoder and re-initialize a new decoder.