History

avformat/utils: Move ff_add_param_change to demux_utils.c

Only demuxers have a need to add side-data to a packet.

Andreas Rheinhardt committed 4 years ago

Commit f1043521 parent 92a43ad7 files · +66 −60Browse files

Unified · Split

7 files
  1. libavformat/demux.h +8 −0
  2. libavformat/demux_utils.c +54 −0
  3. libavformat/flvdec.c +1 −0
  4. libavformat/internal.h +0 −8
  5. libavformat/ipmovie.c +1 −0
  6. libavformat/swfdec.c +1 −0
  7. libavformat/utils.c +1 −52
libavformat/demux.h+8−0
@@ -203,4 +203,12 @@ AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_ba · 202 unmodified lines
203203 int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,
204204 AVBufferRef **buf, int size);
205205
206+/**
207+ * Add side data to a packet for changing parameters to the given values.
208+ * Parameters set to 0 aren't included in the change.
209+ */
210+int ff_add_param_change(AVPacket *pkt, int32_t channels,
211+ uint64_t channel_layout, int32_t sample_rate,
212+ int32_t width, int32_t height);
213+
206214 #endif /* AVFORMAT_DEMUX_H */
libavformat/demux_utils.c+54−0
@@ -19,7 +19,10 @@ · 18 unmodified lines
1919 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020 */
2121
22+#include "libavutil/version.h"
23+
2224 #include "libavutil/avassert.h"
25+#include "libavcodec/bytestream.h"
2326 #include "libavcodec/packet_internal.h"
2427 #include "avformat.h"
2528 #include "demux.h"
@@ -143,3 +146,54 @@ fail: · 117 unmodified lines
143146 ff_remove_stream(s, st);
144147 return ret;
145148 }
149+
150+int ff_add_param_change(AVPacket *pkt, int32_t channels,
151+ uint64_t channel_layout, int32_t sample_rate,
152+ int32_t width, int32_t height)
153+{
154+ uint32_t flags = 0;
155+ int size = 4;
156+ uint8_t *data;
157+ if (!pkt)
158+ return AVERROR(EINVAL);
159+
160+#if FF_API_OLD_CHANNEL_LAYOUT
161+FF_DISABLE_DEPRECATION_WARNINGS
162+ if (channels) {
163+ size += 4;
164+ flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT;
165+ }
166+ if (channel_layout) {
167+ size += 8;
168+ flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT;
169+ }
170+FF_ENABLE_DEPRECATION_WARNINGS
171+#endif
172+ if (sample_rate) {
173+ size += 4;
174+ flags |= AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE;
175+ }
176+ if (width || height) {
177+ size += 8;
178+ flags |= AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS;
179+ }
180+ data = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, size);
181+ if (!data)
182+ return AVERROR(ENOMEM);
183+ bytestream_put_le32(&data, flags);
184+#if FF_API_OLD_CHANNEL_LAYOUT
185+FF_DISABLE_DEPRECATION_WARNINGS
186+ if (channels)
187+ bytestream_put_le32(&data, channels);
188+ if (channel_layout)
189+ bytestream_put_le64(&data, channel_layout);
190+FF_ENABLE_DEPRECATION_WARNINGS
191+#endif
192+ if (sample_rate)
193+ bytestream_put_le32(&data, sample_rate);
194+ if (width || height) {
195+ bytestream_put_le32(&data, width);
196+ bytestream_put_le32(&data, height);
197+ }
198+ return 0;
199+}
libavformat/flvdec.c+1−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "libavutil/intreadwrite.h"
3535 #include "libavutil/mathematics.h"
3636 #include "avformat.h"
37+#include "demux.h"
3738 #include "internal.h"
3839 #include "flv.h"
3940
libavformat/internal.h+0−8
@@ -584,14 +584,6 @@ const AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st, · 583 unmodified lines
584584 void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits,
585585 unsigned int pts_num, unsigned int pts_den);
586586
587−/**
588− * Add side data to a packet for changing parameters to the given values.
589− * Parameters set to 0 aren't included in the change.
590− */
591−int ff_add_param_change(AVPacket *pkt, int32_t channels,
592− uint64_t channel_layout, int32_t sample_rate,
593− int32_t width, int32_t height);
594−
595587 /**
596588 * Set the timebase for each stream from the corresponding codec timebase and
597589 * print it.
libavformat/ipmovie.c+1−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include "libavutil/channel_layout.h"
3636 #include "libavutil/intreadwrite.h"
3737 #include "avformat.h"
38+#include "demux.h"
3839 #include "internal.h"
3940
4041 #define CHUNK_PREAMBLE_SIZE 4
libavformat/swfdec.c+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/internal.h"
3333 #include "libavutil/intreadwrite.h"
3434 #include "libavcodec/get_bits.h"
35+#include "demux.h"
3536 #include "swf.h"
3637 #include "flv.h"
3738
libavformat/utils.c+1−52
@@ -28,13 +28,13 @@ · 27 unmodified lines
2828 #include "libavutil/bprint.h"
2929 #include "libavutil/dict.h"
3030 #include "libavutil/internal.h"
31+#include "libavutil/intreadwrite.h"
3132 #include "libavutil/opt.h"
3233 #include "libavutil/pixfmt.h"
3334 #include "libavutil/thread.h"
3435 #include "libavutil/time.h"
3536
3637 #include "libavcodec/bsf.h"
37−#include "libavcodec/bytestream.h"
3838 #include "libavcodec/internal.h"
3939 #include "libavcodec/packet_internal.h"
4040
@@ -1007,57 +1007,6 @@ int avformat_network_deinit(void) · 966 unmodified lines
10071007 return 0;
10081008 }
10091009
1010−int ff_add_param_change(AVPacket *pkt, int32_t channels,
1011− uint64_t channel_layout, int32_t sample_rate,
1012− int32_t width, int32_t height)
1013−{
1014− uint32_t flags = 0;
1015− int size = 4;
1016− uint8_t *data;
1017− if (!pkt)
1018− return AVERROR(EINVAL);
1019−
1020−#if FF_API_OLD_CHANNEL_LAYOUT
1021−FF_DISABLE_DEPRECATION_WARNINGS
1022− if (channels) {
1023− size += 4;
1024− flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT;
1025− }
1026− if (channel_layout) {
1027− size += 8;
1028− flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT;
1029− }
1030−FF_ENABLE_DEPRECATION_WARNINGS
1031−#endif
1032− if (sample_rate) {
1033− size += 4;
1034− flags |= AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE;
1035− }
1036− if (width || height) {
1037− size += 8;
1038− flags |= AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS;
1039− }
1040− data = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, size);
1041− if (!data)
1042− return AVERROR(ENOMEM);
1043− bytestream_put_le32(&data, flags);
1044−#if FF_API_OLD_CHANNEL_LAYOUT
1045−FF_DISABLE_DEPRECATION_WARNINGS
1046− if (channels)
1047− bytestream_put_le32(&data, channels);
1048− if (channel_layout)
1049− bytestream_put_le64(&data, channel_layout);
1050−FF_ENABLE_DEPRECATION_WARNINGS
1051−#endif
1052− if (sample_rate)
1053− bytestream_put_le32(&data, sample_rate);
1054− if (width || height) {
1055− bytestream_put_le32(&data, width);
1056− bytestream_put_le32(&data, height);
1057− }
1058− return 0;
1059−}
1060−
10611010 AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
10621011 {
10631012 AVRational undef = {0, 1};

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