History

avformat/utils: Move ff_generate_avci_extradata to demux_utils.c

Only used by demuxers.

Andreas Rheinhardt committed 4 years ago

Commit 78038251 parent 0b0dfb74 files · +141 −141Browse files

Unified · Split

4 files
  1. libavformat/demux.h +6 −0
  2. libavformat/demux_utils.c +135 −0
  3. libavformat/internal.h +0 −6
  4. libavformat/utils.c +0 −135
libavformat/demux.h+6−0
@@ -211,4 +211,10 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels, · 210 unmodified lines
211211 uint64_t channel_layout, int32_t sample_rate,
212212 int32_t width, int32_t height);
213213
214+/**
215+ * Generate standard extradata for AVC-Intra based on width/height and field
216+ * order.
217+ */
218+int ff_generate_avci_extradata(AVStream *st);
219+
214220 #endif /* AVFORMAT_DEMUX_H */
libavformat/demux_utils.c+135−0
@@ -215,3 +215,138 @@ int av_read_pause(AVFormatContext *s) · 214 unmodified lines
215215 return avio_pause(s->pb, 1);
216216 return AVERROR(ENOSYS);
217217 }
218+
219+int ff_generate_avci_extradata(AVStream *st)
220+{
221+ static const uint8_t avci100_1080p_extradata[] = {
222+ // SPS
223+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
224+ 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
225+ 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
226+ 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
227+ 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
228+ 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
229+ 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
230+ 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
231+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232+ // PPS
233+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
234+ 0xd0
235+ };
236+ static const uint8_t avci100_1080i_extradata[] = {
237+ // SPS
238+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
239+ 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
240+ 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
241+ 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
242+ 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
243+ 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
244+ 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
245+ 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
246+ 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
247+ 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
248+ 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
249+ // PPS
250+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
251+ 0xd0
252+ };
253+ static const uint8_t avci50_1080p_extradata[] = {
254+ // SPS
255+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
256+ 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
257+ 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
258+ 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
259+ 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
260+ 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
261+ 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
262+ 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
263+ 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
264+ // PPS
265+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
266+ 0x11
267+ };
268+ static const uint8_t avci50_1080i_extradata[] = {
269+ // SPS
270+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
271+ 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
272+ 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
273+ 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
274+ 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
275+ 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
276+ 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
277+ 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
278+ 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
279+ 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
280+ 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
281+ // PPS
282+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
283+ 0x11
284+ };
285+ static const uint8_t avci100_720p_extradata[] = {
286+ // SPS
287+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
288+ 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
289+ 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
290+ 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
291+ 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
292+ 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
293+ 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
294+ 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
295+ 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
296+ 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
297+ // PPS
298+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
299+ 0x11
300+ };
301+ static const uint8_t avci50_720p_extradata[] = {
302+ // SPS
303+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
304+ 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
305+ 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
306+ 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
307+ 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
308+ 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
309+ 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
310+ 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
311+ 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
312+ // PPS
313+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
314+ 0x11
315+ };
316+
317+ const uint8_t *data = NULL;
318+ int ret, size = 0;
319+
320+ if (st->codecpar->width == 1920) {
321+ if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
322+ data = avci100_1080p_extradata;
323+ size = sizeof(avci100_1080p_extradata);
324+ } else {
325+ data = avci100_1080i_extradata;
326+ size = sizeof(avci100_1080i_extradata);
327+ }
328+ } else if (st->codecpar->width == 1440) {
329+ if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
330+ data = avci50_1080p_extradata;
331+ size = sizeof(avci50_1080p_extradata);
332+ } else {
333+ data = avci50_1080i_extradata;
334+ size = sizeof(avci50_1080i_extradata);
335+ }
336+ } else if (st->codecpar->width == 1280) {
337+ data = avci100_720p_extradata;
338+ size = sizeof(avci100_720p_extradata);
339+ } else if (st->codecpar->width == 960) {
340+ data = avci50_720p_extradata;
341+ size = sizeof(avci50_720p_extradata);
342+ }
343+
344+ if (!size)
345+ return 0;
346+
347+ if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
348+ return ret;
349+ memcpy(st->codecpar->extradata, data, size);
350+
351+ return 0;
352+}
libavformat/internal.h+0−6
@@ -623,12 +623,6 @@ int ff_is_intra_only(enum AVCodecID id); · 622 unmodified lines
623623 */
624624 enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
625625
626−/**
627− * Generate standard extradata for AVC-Intra based on width/height and field
628− * order.
629− */
630−int ff_generate_avci_extradata(AVStream *st);
631−
632626 /**
633627 * Copy side data from source to destination stream
634628 *
libavformat/utils.c+0−135
@@ -1211,141 +1211,6 @@ error: · 1210 unmodified lines
12111211 return ret;
12121212 }
12131213
1214−int ff_generate_avci_extradata(AVStream *st)
1215−{
1216− static const uint8_t avci100_1080p_extradata[] = {
1217− // SPS
1218− 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
1219− 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
1220− 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
1221− 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
1222− 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
1223− 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
1224− 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
1225− 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
1226− 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1227− // PPS
1228− 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
1229− 0xd0
1230− };
1231− static const uint8_t avci100_1080i_extradata[] = {
1232− // SPS
1233− 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
1234− 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
1235− 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
1236− 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
1237− 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
1238− 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
1239− 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
1240− 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
1241− 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
1242− 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
1243− 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
1244− // PPS
1245− 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
1246− 0xd0
1247− };
1248− static const uint8_t avci50_1080p_extradata[] = {
1249− // SPS
1250− 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
1251− 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
1252− 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
1253− 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
1254− 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
1255− 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
1256− 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
1257− 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
1258− 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
1259− // PPS
1260− 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
1261− 0x11
1262− };
1263− static const uint8_t avci50_1080i_extradata[] = {
1264− // SPS
1265− 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
1266− 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
1267− 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
1268− 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
1269− 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
1270− 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
1271− 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
1272− 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
1273− 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
1274− 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
1275− 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
1276− // PPS
1277− 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
1278− 0x11
1279− };
1280− static const uint8_t avci100_720p_extradata[] = {
1281− // SPS
1282− 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
1283− 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
1284− 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
1285− 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
1286− 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
1287− 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
1288− 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
1289− 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
1290− 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
1291− 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
1292− // PPS
1293− 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
1294− 0x11
1295− };
1296− static const uint8_t avci50_720p_extradata[] = {
1297− // SPS
1298− 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
1299− 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
1300− 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
1301− 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
1302− 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
1303− 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
1304− 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
1305− 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
1306− 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
1307− // PPS
1308− 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
1309− 0x11
1310− };
1311−
1312− const uint8_t *data = NULL;
1313− int ret, size = 0;
1314−
1315− if (st->codecpar->width == 1920) {
1316− if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
1317− data = avci100_1080p_extradata;
1318− size = sizeof(avci100_1080p_extradata);
1319− } else {
1320− data = avci100_1080i_extradata;
1321− size = sizeof(avci100_1080i_extradata);
1322− }
1323− } else if (st->codecpar->width == 1440) {
1324− if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
1325− data = avci50_1080p_extradata;
1326− size = sizeof(avci50_1080p_extradata);
1327− } else {
1328− data = avci50_1080i_extradata;
1329− size = sizeof(avci50_1080i_extradata);
1330− }
1331− } else if (st->codecpar->width == 1280) {
1332− data = avci100_720p_extradata;
1333− size = sizeof(avci100_720p_extradata);
1334− } else if (st->codecpar->width == 960) {
1335− data = avci50_720p_extradata;
1336− size = sizeof(avci50_720p_extradata);
1337− }
1338−
1339− if (!size)
1340− return 0;
1341−
1342− if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
1343− return ret;
1344− memcpy(st->codecpar->extradata, data, size);
1345−
1346− return 0;
1347−}
1348−
13491214 uint8_t *av_stream_get_side_data(const AVStream *st,
13501215 enum AVPacketSideDataType type, size_t *size)
13511216 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t