| 61 | } |
| 62 | |
| 63 | int ff_make_codec_str(void *logctx, const AVCodecParameters *par, |
| 64 | const AVRational *frame_rate, struct AVBPrint *out) |
| 65 | { |
| 66 | int i; |
| 67 | |
| 68 | // common Webm codecs are not part of RFC 6381 |
| 69 | for (i = 0; codecs[i].id != AV_CODEC_ID_NONE; i++) |
| 70 | if (codecs[i].id == par->codec_id) { |
| 71 | if (codecs[i].id == AV_CODEC_ID_VP9) { |
| 72 | set_vp9_codec_str(logctx, par, frame_rate, out); |
| 73 | } else { |
| 74 | av_bprintf(out, "%s", codecs[i].str); |
| 75 | } |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | if (par->codec_id == AV_CODEC_ID_H264) { |
| 80 | // RFC 6381 |
| 81 | uint8_t *data = par->extradata; |
| 82 | if (data) { |
| 83 | const uint8_t *p; |
| 84 | |
| 85 | if (AV_RB32(data) == 0x01 && (data[4] & 0x1F) == 7) |
| 86 | p = &data[5]; |
| 87 | else if (AV_RB24(data) == 0x01 && (data[3] & 0x1F) == 7) |
| 88 | p = &data[4]; |
| 89 | else if (data[0] == 0x01) /* avcC */ |
| 90 | p = &data[1]; |
| 91 | else |
| 92 | return AVERROR(EINVAL); |
| 93 | av_bprintf(out, "avc1.%02x%02x%02x", p[0], p[1], p[2]); |
| 94 | } else { |
| 95 | return AVERROR(EINVAL); |
| 96 | } |
| 97 | } else if (par->codec_id == AV_CODEC_ID_HEVC) { |
| 98 | // 3GPP TS 26.244 |
| 99 | uint8_t *data = par->extradata; |
| 100 | int profile = AV_PROFILE_UNKNOWN; |
| 101 | uint32_t profile_compatibility = AV_PROFILE_UNKNOWN; |
| 102 | char tier = 0; |
| 103 | int level = AV_LEVEL_UNKNOWN; |
| 104 | char constraints[8] = ""; |
| 105 | |
| 106 | if (par->profile != AV_PROFILE_UNKNOWN) |
| 107 | profile = par->profile; |
| 108 | if (par->level != AV_LEVEL_UNKNOWN) |
| 109 | level = par->level; |
| 110 | |
| 111 | /* check the boundary of data which from current position is small than extradata_size */ |
| 112 | while (data && (data - par->extradata + 19) < par->extradata_size) { |
| 113 | /* get HEVC SPS NAL and seek to profile_tier_level */ |
| 114 | if (!(data[0] | data[1] | data[2]) && data[3] == 1 && ((data[4] & 0x7E) == 0x42)) { |
| 115 | uint8_t *rbsp_buf; |
| 116 | int remain_size = 0; |
| 117 | int rbsp_size = 0; |
| 118 | uint32_t profile_compatibility_flags = 0; |
| 119 | uint8_t high_nibble = 0; |
| 120 | /* skip start code + nalu header */ |
no test coverage detected