- if (cat->auto_convert && st->codecpar->codec_id == AV_CODEC_ID_H264 &&
- (st->codecpar->extradata_size < 4 || AV_RB32(st->codecpar->extradata) != 1)) {
+ if (cat->auto_convert && st->codecpar->codec_id == AV_CODEC_ID_H264) {
+ if (!st->codecpar->extradata_size ||
+ (st->codecpar->extradata_size >= 3 && AV_RB24(st->codecpar->extradata) == 1) ||
+ (st->codecpar->extradata_size >= 4 && AV_RB32(st->codecpar->extradata) == 1))
+ return 0;