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
203int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,203int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb,
204 AVBufferRef **buf, int size);204 AVBufferRef **buf, int size);
205 205
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 */
210int 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
206#endif /* AVFORMAT_DEMUX_H */214#endif /* AVFORMAT_DEMUX_H */
libavformat/demux_utils.c+54−0
@@ -19,7 +19,10 @@ · 18 unmodified lines
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */20 */
21 21
22#include "libavutil/version.h"
23
22#include "libavutil/avassert.h"24#include "libavutil/avassert.h"
25#include "libavcodec/bytestream.h"
23#include "libavcodec/packet_internal.h"26#include "libavcodec/packet_internal.h"
24#include "avformat.h"27#include "avformat.h"
25#include "demux.h"28#include "demux.h"
@@ -143,3 +146,54 @@ fail: · 117 unmodified lines
143 ff_remove_stream(s, st);146 ff_remove_stream(s, st);
144 return ret;147 return ret;
145}148}
149
150int 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
161FF_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 }
170FF_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
185FF_DISABLE_DEPRECATION_WARNINGS
186 if (channels)
187 bytestream_put_le32(&data, channels);
188 if (channel_layout)
189 bytestream_put_le64(&data, channel_layout);
190FF_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
34#include "libavutil/intreadwrite.h"34#include "libavutil/intreadwrite.h"
35#include "libavutil/mathematics.h"35#include "libavutil/mathematics.h"
36#include "avformat.h"36#include "avformat.h"
37#include "demux.h"
37#include "internal.h"38#include "internal.h"
38#include "flv.h"39#include "flv.h"
39 40
libavformat/internal.h+0−8
@@ -584,14 +584,6 @@ const AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st, · 583 unmodified lines
584void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits,584void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits,
585 unsigned int pts_num, unsigned int pts_den);585 unsigned int pts_num, unsigned int pts_den);
586 586
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 */
591int 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
595/**587/**
596 * Set the timebase for each stream from the corresponding codec timebase and588 * Set the timebase for each stream from the corresponding codec timebase and
597 * print it.589 * print it.
libavformat/ipmovie.c+1−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
35#include "libavutil/channel_layout.h"35#include "libavutil/channel_layout.h"
36#include "libavutil/intreadwrite.h"36#include "libavutil/intreadwrite.h"
37#include "avformat.h"37#include "avformat.h"
38#include "demux.h"
38#include "internal.h"39#include "internal.h"
39 40
40#define CHUNK_PREAMBLE_SIZE 441#define CHUNK_PREAMBLE_SIZE 4
libavformat/swfdec.c+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
32#include "libavutil/internal.h"32#include "libavutil/internal.h"
33#include "libavutil/intreadwrite.h"33#include "libavutil/intreadwrite.h"
34#include "libavcodec/get_bits.h"34#include "libavcodec/get_bits.h"
35#include "demux.h"
35#include "swf.h"36#include "swf.h"
36#include "flv.h"37#include "flv.h"
37 38
libavformat/utils.c+1−52
@@ -28,13 +28,13 @@ · 27 unmodified lines
28#include "libavutil/bprint.h"28#include "libavutil/bprint.h"
29#include "libavutil/dict.h"29#include "libavutil/dict.h"
30#include "libavutil/internal.h"30#include "libavutil/internal.h"
31#include "libavutil/intreadwrite.h"
31#include "libavutil/opt.h"32#include "libavutil/opt.h"
32#include "libavutil/pixfmt.h"33#include "libavutil/pixfmt.h"
33#include "libavutil/thread.h"34#include "libavutil/thread.h"
34#include "libavutil/time.h"35#include "libavutil/time.h"
35 36
36#include "libavcodec/bsf.h"37#include "libavcodec/bsf.h"
37#include "libavcodec/bytestream.h"
38#include "libavcodec/internal.h"38#include "libavcodec/internal.h"
39#include "libavcodec/packet_internal.h"39#include "libavcodec/packet_internal.h"
40 40
@@ -1007,57 +1007,6 @@ int avformat_network_deinit(void) · 966 unmodified lines
1007 return 0;1007 return 0;
1008}1008}
1009 1009
1010int 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
1021FF_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 }
1030FF_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
1045FF_DISABLE_DEPRECATION_WARNINGS
1046 if (channels)
1047 bytestream_put_le32(&data, channels);
1048 if (channel_layout)
1049 bytestream_put_le64(&data, channel_layout);
1050FF_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
1061AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)1010AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
1062{1011{
1063 AVRational undef = {0, 1};1012 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