MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_make_codec_str

Function ff_make_codec_str

libavformat/codecstring.c:63–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63int 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 */

Callers 4

write_codec_attrFunction · 0.85
av_mime_codec_strFunction · 0.85
dash_initFunction · 0.85
update_stream_extradataFunction · 0.85

Calls 6

set_vp9_codec_strFunction · 0.85
av_bprintfFunction · 0.85
ff_nal_unit_extract_rbspFunction · 0.85
av_freepFunction · 0.85
ff_av1_parse_seq_headerFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected