[FFmpeg-cvslog] avformat/utils: Move ff_generate_avci_extradata to demux_utils.c
Andreas Rheinhardt
git at videolan.org
Tue May 10 09:35:34 EEST 2022
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri May 6 21:09:44 2022 +0200| [7803825cfc580be42dcc280582bd6b2a87d83fb4] | committer: Andreas Rheinhardt
avformat/utils: Move ff_generate_avci_extradata to demux_utils.c
Only used by demuxers.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7803825cfc580be42dcc280582bd6b2a87d83fb4
---
libavformat/demux.h | 6 +++
libavformat/demux_utils.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++
libavformat/internal.h | 6 ---
libavformat/utils.c | 135 ----------------------------------------------
4 files changed, 141 insertions(+), 141 deletions(-)
diff --git a/libavformat/demux.h b/libavformat/demux.h
index 03f7c22bdd..64adaff07d 100644
--- a/libavformat/demux.h
+++ b/libavformat/demux.h
@@ -211,4 +211,10 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels,
uint64_t channel_layout, int32_t sample_rate,
int32_t width, int32_t height);
+/**
+ * Generate standard extradata for AVC-Intra based on width/height and field
+ * order.
+ */
+int ff_generate_avci_extradata(AVStream *st);
+
#endif /* AVFORMAT_DEMUX_H */
diff --git a/libavformat/demux_utils.c b/libavformat/demux_utils.c
index 4d9ba9a028..8a1e4ff5c0 100644
--- a/libavformat/demux_utils.c
+++ b/libavformat/demux_utils.c
@@ -215,3 +215,138 @@ int av_read_pause(AVFormatContext *s)
return avio_pause(s->pb, 1);
return AVERROR(ENOSYS);
}
+
+int ff_generate_avci_extradata(AVStream *st)
+{
+ static const uint8_t avci100_1080p_extradata[] = {
+ // SPS
+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
+ 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
+ 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
+ 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
+ 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
+ 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
+ 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
+ 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // PPS
+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
+ 0xd0
+ };
+ static const uint8_t avci100_1080i_extradata[] = {
+ // SPS
+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
+ 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
+ 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
+ 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
+ 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
+ 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
+ 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
+ 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
+ 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
+ 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
+ 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
+ // PPS
+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
+ 0xd0
+ };
+ static const uint8_t avci50_1080p_extradata[] = {
+ // SPS
+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
+ 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
+ 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
+ 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
+ 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
+ 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
+ 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
+ 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
+ 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
+ // PPS
+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
+ 0x11
+ };
+ static const uint8_t avci50_1080i_extradata[] = {
+ // SPS
+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
+ 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
+ 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
+ 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
+ 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
+ 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
+ 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
+ 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
+ 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
+ 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
+ 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
+ // PPS
+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
+ 0x11
+ };
+ static const uint8_t avci100_720p_extradata[] = {
+ // SPS
+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
+ 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
+ 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
+ 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
+ 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
+ 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
+ 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
+ 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
+ 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
+ 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // PPS
+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
+ 0x11
+ };
+ static const uint8_t avci50_720p_extradata[] = {
+ // SPS
+ 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
+ 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
+ 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
+ 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
+ 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
+ 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
+ 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
+ 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
+ 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+ // PPS
+ 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
+ 0x11
+ };
+
+ const uint8_t *data = NULL;
+ int ret, size = 0;
+
+ if (st->codecpar->width == 1920) {
+ if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
+ data = avci100_1080p_extradata;
+ size = sizeof(avci100_1080p_extradata);
+ } else {
+ data = avci100_1080i_extradata;
+ size = sizeof(avci100_1080i_extradata);
+ }
+ } else if (st->codecpar->width == 1440) {
+ if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
+ data = avci50_1080p_extradata;
+ size = sizeof(avci50_1080p_extradata);
+ } else {
+ data = avci50_1080i_extradata;
+ size = sizeof(avci50_1080i_extradata);
+ }
+ } else if (st->codecpar->width == 1280) {
+ data = avci100_720p_extradata;
+ size = sizeof(avci100_720p_extradata);
+ } else if (st->codecpar->width == 960) {
+ data = avci50_720p_extradata;
+ size = sizeof(avci50_720p_extradata);
+ }
+
+ if (!size)
+ return 0;
+
+ if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
+ return ret;
+ memcpy(st->codecpar->extradata, data, size);
+
+ return 0;
+}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index cd6240b0a3..4392f17d71 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -623,12 +623,6 @@ int ff_is_intra_only(enum AVCodecID id);
*/
enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
-/**
- * Generate standard extradata for AVC-Intra based on width/height and field
- * order.
- */
-int ff_generate_avci_extradata(AVStream *st);
-
/**
* Copy side data from source to destination stream
*
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 50e8298241..98113086bd 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1211,141 +1211,6 @@ error:
return ret;
}
-int ff_generate_avci_extradata(AVStream *st)
-{
- static const uint8_t avci100_1080p_extradata[] = {
- // SPS
- 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
- 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
- 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
- 0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
- 0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
- 0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
- 0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
- 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
- 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- // PPS
- 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
- 0xd0
- };
- static const uint8_t avci100_1080i_extradata[] = {
- // SPS
- 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
- 0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
- 0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
- 0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
- 0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
- 0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
- 0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
- 0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
- 0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
- 0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
- 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x20,
- // PPS
- 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
- 0xd0
- };
- static const uint8_t avci50_1080p_extradata[] = {
- // SPS
- 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
- 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
- 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
- 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
- 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
- 0x6e, 0x6c, 0xd3, 0x3c, 0x05, 0xa0, 0x22, 0x7e,
- 0x5f, 0xfc, 0x00, 0x0c, 0x00, 0x13, 0x8c, 0x04,
- 0x04, 0x05, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
- 0x00, 0x03, 0x00, 0x32, 0x84, 0x00, 0x00, 0x00,
- // PPS
- 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
- 0x11
- };
- static const uint8_t avci50_1080i_extradata[] = {
- // SPS
- 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
- 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
- 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
- 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
- 0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
- 0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
- 0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
- 0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
- 0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
- 0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
- 0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
- // PPS
- 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
- 0x11
- };
- static const uint8_t avci100_720p_extradata[] = {
- // SPS
- 0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
- 0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
- 0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
- 0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
- 0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
- 0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
- 0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
- 0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
- 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
- 0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
- // PPS
- 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
- 0x11
- };
- static const uint8_t avci50_720p_extradata[] = {
- // SPS
- 0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x20,
- 0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
- 0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
- 0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6f, 0x37,
- 0xcd, 0xf9, 0xbf, 0x81, 0x6b, 0xf3, 0x7c, 0xde,
- 0x6e, 0x6c, 0xd3, 0x3c, 0x0f, 0x01, 0x6e, 0xff,
- 0xc0, 0x00, 0xc0, 0x01, 0x38, 0xc0, 0x40, 0x40,
- 0x50, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00,
- 0x06, 0x48, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
- // PPS
- 0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
- 0x11
- };
-
- const uint8_t *data = NULL;
- int ret, size = 0;
-
- if (st->codecpar->width == 1920) {
- if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
- data = avci100_1080p_extradata;
- size = sizeof(avci100_1080p_extradata);
- } else {
- data = avci100_1080i_extradata;
- size = sizeof(avci100_1080i_extradata);
- }
- } else if (st->codecpar->width == 1440) {
- if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
- data = avci50_1080p_extradata;
- size = sizeof(avci50_1080p_extradata);
- } else {
- data = avci50_1080i_extradata;
- size = sizeof(avci50_1080i_extradata);
- }
- } else if (st->codecpar->width == 1280) {
- data = avci100_720p_extradata;
- size = sizeof(avci100_720p_extradata);
- } else if (st->codecpar->width == 960) {
- data = avci50_720p_extradata;
- size = sizeof(avci50_720p_extradata);
- }
-
- if (!size)
- return 0;
-
- if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
- return ret;
- memcpy(st->codecpar->extradata, data, size);
-
- return 0;
-}
-
uint8_t *av_stream_get_side_data(const AVStream *st,
enum AVPacketSideDataType type, size_t *size)
{
More information about the ffmpeg-cvslog
mailing list