Go to the documentation of this file.
36 #define IO_BUFFER_SIZE 32768
43 #define SHORT_SEEK_THRESHOLD 4096
53 return prev ?
NULL :
internal->h;
61 #define OFFSET(x) offsetof(AVIOContext,x)
62 #define E AV_OPT_FLAG_ENCODING_PARAM
63 #define D AV_OPT_FLAG_DECODING_PARAM
65 {
"protocol_whitelist",
"List of protocols that are allowed to be used",
OFFSET(protocol_whitelist),
AV_OPT_TYPE_STRING, { .str =
NULL }, CHAR_MIN, CHAR_MAX,
D },
88 int64_t (*seek)(
void *opaque, int64_t
offset,
int whence))
94 s->buffer_size = buffer_size;
109 s->min_packet_size = 0;
110 s->max_packet_size = 0;
111 s->update_checksum =
NULL;
115 s->pos = buffer_size;
116 s->buf_end =
s->buffer + buffer_size;
118 s->read_pause =
NULL;
121 s->write_data_type =
NULL;
122 s->ignore_boundary_point = 0;
125 s->short_seek_get =
NULL;
138 int64_t (*seek)(
void *opaque, int64_t
offset,
int whence))
157 if (
s->write_data_type)
162 else if (
s->write_packet)
167 if (
s->pos +
len >
s->written)
168 s->written =
s->pos +
len;
176 s->writeout_count ++;
182 s->buf_ptr_max =
FFMAX(
s->buf_ptr,
s->buf_ptr_max);
183 if (
s->write_flag &&
s->buf_ptr_max >
s->buffer) {
185 if (
s->update_checksum) {
186 s->checksum =
s->update_checksum(
s->checksum,
s->checksum_ptr,
187 s->buf_ptr_max -
s->checksum_ptr);
188 s->checksum_ptr =
s->buffer;
191 s->buf_ptr =
s->buf_ptr_max =
s->buffer;
193 s->buf_end =
s->buffer;
200 if (
s->buf_ptr >=
s->buf_end)
208 memset(
s->buf_ptr,
b,
len);
211 if (
s->buf_ptr >=
s->buf_end)
220 if (
s->direct && !
s->update_checksum) {
230 if (
s->buf_ptr >=
s->buf_end)
240 int seekback =
s->write_flag ?
FFMIN(0,
s->buf_ptr -
s->buf_ptr_max) : 0;
258 buffer_size =
s->buf_end -
s->buffer;
260 pos =
s->pos - (
s->write_flag ? 0 : buffer_size);
262 if (whence != SEEK_CUR && whence != SEEK_SET)
265 if (whence == SEEK_CUR) {
266 offset1 = pos + (
s->buf_ptr -
s->buffer);
269 if (
offset > INT64_MAX - offset1)
276 if (
s->short_seek_get) {
277 short_seek =
s->short_seek_get(
s->opaque);
280 short_seek =
s->short_seek_threshold;
282 short_seek =
s->short_seek_threshold;
285 s->buf_ptr_max =
FFMAX(
s->buf_ptr_max,
s->buf_ptr);
286 if ((!
s->direct || !
s->seek) &&
287 offset1 >= 0 && offset1 <= (
s->write_flag ?
s->buf_ptr_max -
s->buffer : buffer_size)) {
289 s->buf_ptr =
s->buffer + offset1;
291 offset1 <= buffer_size + short_seek) &&
292 !
s->write_flag && offset1 >= 0 &&
293 (!
s->direct || !
s->seek) &&
294 (whence != SEEK_END || force)) {
295 while(
s->pos <
offset && !
s->eof_reached)
299 s->buf_ptr =
s->buf_end - (
s->pos -
offset);
300 }
else if(!
s->write_flag && offset1 < 0 && -offset1 < buffer_size>>1 &&
s->seek &&
offset > 0) {
303 pos -=
FFMIN(buffer_size>>1, pos);
304 if ((res =
s->seek(
s->opaque, pos, SEEK_SET)) < 0)
307 s->buf_ptr =
s->buffer;
319 if ((res =
s->seek(
s->opaque,
offset, SEEK_SET)) < 0)
323 s->buf_end =
s->buffer;
324 s->buf_ptr =
s->buf_ptr_max =
s->buffer;
350 if ((
size =
s->seek(
s->opaque, -1, SEEK_END)) < 0)
353 s->seek(
s->opaque,
s->pos, SEEK_SET);
366 return s->eof_reached;
426 #define PUT_STR16(type, big_endian) \
427 int avio_put_str16 ## type(AVIOContext *s, const char *str) \
429 return put_str16(s, str, big_endian); \
496 if (
s->buf_ptr -
s->buffer >=
s->min_packet_size)
500 if (!
s->write_data_type)
517 if (
type ==
s->current_type)
525 s->current_type =
type;
536 #if FF_API_OLD_AVIO_EOF_0
537 if (!
ret && !
s->max_packet_size) {
551 int max_buffer_size =
s->max_packet_size ?
553 uint8_t *dst =
s->buf_end -
s->buffer + max_buffer_size <
s->buffer_size ?
554 s->buf_end :
s->buffer;
555 int len =
s->buffer_size - (dst -
s->buffer);
558 if (!
s->read_packet &&
s->buf_ptr >=
s->buf_end)
565 if (
s->update_checksum && dst ==
s->buffer) {
566 if (
s->buf_end >
s->checksum_ptr)
567 s->checksum =
s->update_checksum(
s->checksum,
s->checksum_ptr,
568 s->buf_end -
s->checksum_ptr);
569 s->checksum_ptr =
s->buffer;
573 if (
s->read_packet &&
s->orig_buffer_size &&
s->buffer_size >
s->orig_buffer_size &&
len >=
s->orig_buffer_size) {
574 if (dst ==
s->buffer &&
s->buf_ptr != dst) {
579 s->checksum_ptr = dst =
s->buffer;
581 len =
s->orig_buffer_size;
589 }
else if (
len < 0) {
595 s->buf_end = dst +
len;
596 s->bytes_read +=
len;
620 s->checksum =
s->update_checksum(
s->checksum,
s->checksum_ptr,
621 s->buf_ptr -
s->checksum_ptr);
622 s->update_checksum =
NULL;
627 unsigned long (*update_checksum)(
unsigned long c,
const uint8_t *p,
unsigned int len),
630 s->update_checksum = update_checksum;
631 if (
s->update_checksum) {
633 s->checksum_ptr =
s->buf_ptr;
640 if (
s->buf_ptr >=
s->buf_end)
642 if (
s->buf_ptr <
s->buf_end)
643 return *
s->buf_ptr++;
654 if (
len == 0 ||
s->write_flag) {
655 if((
s->direct ||
size >
s->buffer_size) && !
s->update_checksum) {
663 }
else if (
len < 0) {
669 s->bytes_read +=
len;
673 s->buf_ptr =
s->buffer;
674 s->buf_end =
s->buffer;
678 len =
s->buf_end -
s->buf_ptr;
690 if (
s->error)
return s->error;
706 if (
s->buf_end -
s->buf_ptr >=
size && !
s->write_flag) {
723 if (
s->read_packet &&
s->write_flag) {
730 len =
s->buf_end -
s->buf_ptr;
738 s->buf_end =
s->buf_ptr =
s->buffer;
740 len =
s->buf_end -
s->buf_ptr;
747 if (
s->error)
return s->error;
815 if (
c &&
i < maxlen-1)
817 }
while (
c !=
'\n' &&
c !=
'\r' &&
c);
844 end = (
c ==
'\r' ||
c ==
'\n' ||
c ==
'\0');
886 buflen =
FFMIN(buflen - 1, maxlen);
887 for (
i = 0;
i < buflen;
i++)
891 for (;
i < maxlen;
i++)
897 #define GET_STR16(type, read) \
898 int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\
903 return AVERROR(EINVAL); \
904 while (ret + 1 < maxlen) {\
907 GET_UTF16(ch, (ret += 2) <= maxlen ? read(pb) : 0, break;)\
910 PUT_UTF8(ch, tmp, if (q - buf < buflen - 1) *q++ = tmp;)\
967 if (!internal->h->prot->url_read_pause)
969 return internal->h->prot->url_read_pause(internal->h, pause);
975 if (!internal->h->prot->url_read_seek)
977 return internal->h->prot->url_read_seek(internal->h, stream_index, timestamp,
flags);
984 int buffer_size, max_packet_size;
986 max_packet_size =
h->max_packet_size;
987 if (max_packet_size) {
988 buffer_size = max_packet_size;
1007 (*s)->protocol_whitelist =
av_strdup(
h->protocol_whitelist);
1008 if (!(*s)->protocol_whitelist &&
h->protocol_whitelist) {
1012 (*s)->protocol_blacklist =
av_strdup(
h->protocol_blacklist);
1013 if (!(*s)->protocol_blacklist &&
h->protocol_blacklist) {
1020 (*s)->max_packet_size = max_packet_size;
1021 (*s)->min_packet_size =
h->min_packet_size;
1026 if (
h->prot->url_read_seek)
1044 internal =
s->opaque;
1054 int max_buffer_size =
s->max_packet_size ?
1056 int filled =
s->buf_end -
s->buffer;
1057 ptrdiff_t checksum_ptr_offset =
s->checksum_ptr ?
s->checksum_ptr -
s->buffer : -1;
1059 buf_size +=
s->buf_ptr -
s->buffer + max_buffer_size;
1061 if (buf_size < filled || s->seekable || !
s->read_packet)
1069 memcpy(
buffer,
s->buffer, filled);
1071 s->buf_ptr =
buffer + (
s->buf_ptr -
s->buffer);
1072 s->buf_end =
buffer + (
s->buf_end -
s->buffer);
1074 s->buffer_size = buf_size;
1075 if (checksum_ptr_offset >= 0)
1076 s->checksum_ptr =
s->buffer + checksum_ptr_offset;
1089 s->orig_buffer_size =
1090 s->buffer_size = buf_size;
1091 s->buf_ptr =
s->buf_ptr_max =
buffer;
1101 s->buf_end =
s->buffer +
s->buffer_size;
1104 s->buf_end =
s->buffer;
1112 int64_t buffer_start;
1114 int overlap, new_size, alloc_size;
1117 if (
s->write_flag) {
1122 buffer_size =
s->buf_end -
s->buffer;
1125 if ((buffer_start =
s->pos - buffer_size) > buf_size) {
1130 overlap = buf_size - buffer_start;
1131 new_size = buf_size + buffer_size - overlap;
1133 alloc_size =
FFMAX(
s->buffer_size, new_size);
1134 if (alloc_size > buf_size)
1138 if (new_size > buf_size) {
1139 memcpy(
buf + buf_size,
s->buffer + overlap, buffer_size - overlap);
1140 buf_size = new_size;
1144 s->buf_ptr =
s->buffer =
buf;
1145 s->buffer_size = alloc_size;
1147 s->buf_end =
s->buf_ptr + buf_size;
1160 const char *whitelist,
const char *blacklist
1194 internal =
s->opaque;
1234 return s->read_pause(
s->opaque, pause);
1238 int64_t timestamp,
int flags)
1243 ret =
s->read_seek(
s->opaque, stream_index, timestamp,
flags);
1246 s->buf_ptr =
s->buf_end;
1247 pos =
s->seek(
s->opaque, 0, SEEK_CUR);
1250 else if (pos !=
AVERROR(ENOSYS))
1305 unsigned new_size, new_allocated_size;
1308 new_size = (unsigned)d->
pos + buf_size;
1310 if (new_size < d->pos || new_size > INT_MAX/2)
1312 while (new_size > new_allocated_size) {
1313 if (!new_allocated_size)
1314 new_allocated_size = new_size;
1316 new_allocated_size += new_allocated_size / 2 + 1;
1337 unsigned char buf1[4];
1354 if (whence == SEEK_CUR)
1356 else if (whence == SEEK_END)
1358 if (offset < 0 || offset > 0x7fffffffLL)
1367 unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
1369 if (
sizeof(
DynBuffer) + io_buffer_size < io_buffer_size)
1382 (*s)->max_packet_size = max_packet_size;
1393 if (max_packet_size <= 0)
1428 if (!
s->max_packet_size) {
1442 return size - padding;
int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen)
Same as ff_get_line but strip the white-space characters in the text tail.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it be(in the first position) for now. Options ------- Then comes the options array. This is what will define the user accessible options. For example
#define AV_LOG_WARNING
Something somehow does not look correct.
static int put_str16(AVIOContext *s, const char *str, const int be)
void ff_put_v(AVIOContext *bc, uint64_t val)
Put val using a variable number of bytes.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
@ AVIO_DATA_MARKER_BOUNDARY_POINT
A point in the output bytestream where a demuxer can start parsing (for non self synchronizing bytest...
static int null_buf_write(void *opaque, uint8_t *buf, int buf_size)
const AVClass ffurl_context_class
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
Change the position that will be used by the next read/write operation on the resource accessed by h.
unsigned int avio_rl24(AVIOContext *s)
static int64_t dyn_buf_seek(void *opaque, int64_t offset, int whence)
#define AVERROR_EOF
End of file.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
void avio_wl24(AVIOContext *s, unsigned int val)
static int io_read_pause(void *opaque, int pause)
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
static int64_t io_read_seek(void *opaque, int stream_index, int64_t timestamp, int flags)
static av_cold int end(AVCodecContext *avctx)
unsigned long ffio_get_checksum(AVIOContext *s)
int ffio_open_null_buf(AVIOContext **s)
Open a write-only fake memory stream.
URLContext * ffio_geturlcontext(AVIOContext *s)
Return the URLContext associated with the AVIOContext.
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
int64_t avio_seek_time(AVIOContext *s, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to some component stream.
#define AV_LOG_VERBOSE
Detailed information.
int avio_accept(AVIOContext *s, AVIOContext **c)
Accept and allocate a client context on a server context.
int ffurl_close(URLContext *h)
int avio_put_str(AVIOContext *s, const char *str)
Write a NULL-terminated string.
void ffio_fill(AVIOContext *s, int b, int count)
void avio_wl32(AVIOContext *s, unsigned int val)
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
unsigned long ff_crcEDB88320_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
AVIODataMarkerType
Different data types that can be returned via the AVIO write_data_type callback.
void avio_w8(AVIOContext *s, int b)
static void fill_buffer(AVIOContext *s)
Callback for checking whether to abort blocking functions.
static const AVClass * ff_avio_child_class_next(const AVClass *prev)
void avio_wb24(AVIOContext *s, unsigned int val)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
void avio_wl16(AVIOContext *s, unsigned int val)
int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
static void * ff_avio_child_next(void *obj, void *prev)
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
static void flush_buffer(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it.
void avio_wb32(AVIOContext *s, unsigned int val)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
const AVClass ff_avio_class
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static int io_read_packet(void *opaque, uint8_t *buf, int buf_size)
int ffio_set_buf_size(AVIOContext *s, int buf_size)
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
Read size bytes from AVIOContext, returning a pointer.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AVIO_FLAG_WRITE
write-only
void avio_context_free(AVIOContext **ps)
Free the supplied IO context and everything associated with it.
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s.
#define av_realloc_f(p, o, n)
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
#define LIBAVUTIL_VERSION_INT
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Describe the class of an AVClass context structure.
static const AVOption ff_avio_options[]
@ AVIO_DATA_MARKER_TRAILER
Trailer data, which doesn't contain actual content, but only for finalizing the output file.
#define PUT_UTF16(val, tmp, PUT_16BIT)
int avio_printf(AVIOContext *s, const char *fmt,...)
const char * av_default_item_name(void *ptr)
Return the context name.
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define SHORT_SEEK_THRESHOLD
Do seeks within this distance ahead of the current buffer by skipping data instead of calling the pro...
static int read_packet_wrapper(AVIOContext *s, uint8_t *buf, int size)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int avio_pause(AVIOContext *s, int pause)
Pause and resume playing - only meaningful if using a network streaming protocol (e....
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
unsigned int avio_rb24(AVIOContext *s)
static int dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size)
const OptionDef options[]
unsigned int avio_rb16(AVIOContext *s)
int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp)
Read a whole line of text from AVIOContext to an AVBPrint buffer overwriting its contents.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
int avio_open(AVIOContext **s, const char *filename, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AVIO_SEEKABLE_TIME
Seeking by timestamp with avio_seek_time() is possible.
static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
unsigned int avio_rl16(AVIOContext *s)
uint64_t avio_rl64(AVIOContext *s)
int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **bufp, int buf_size)
Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file.
const char const char void * val
@ AVIO_DATA_MARKER_SYNC_POINT
A point in the output bytestream where a decoder can start decoding (i.e.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int(* write_packet)(void *opaque, uint8_t *buf, int buf_size)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
unsigned int avio_rl32(AVIOContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int ffurl_get_short_seek(URLContext *h)
Return the current short seek threshold value for this URL.
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
Open a write only packetized memory stream with a maximum packet size of 'max_packet_size'.
#define i(width, name, range_min, range_max)
#define PUT_STR16(type, big_endian)
uint64_t ffio_read_varlen(AVIOContext *bc)
int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp)
Read a whole line of text from AVIOContext to an AVBPrint buffer.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
#define GET_STR16(type, read)
const AVIOInterruptCB int_cb
void avio_wb64(AVIOContext *s, uint64_t val)
@ AVIO_DATA_MARKER_UNKNOWN
This is any, unlabelled data.
int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static volatile int checksum
#define AV_INPUT_BUFFER_PADDING_SIZE
static int io_short_seek(void *opaque)
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
int avio_r8(AVIOContext *s)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
static int url_resetbuf(AVIOContext *s, int flags)
static int64_t io_seek(void *opaque, int64_t offset, int whence)
static int io_write_packet(void *opaque, uint8_t *buf, int buf_size)
@ AVIO_DATA_MARKER_HEADER
Header data; this needs to be present for the stream to be decodeable.
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
#define AVSEEK_FORCE
Passing this flag as the "whence" parameter to a seek function causes it to seek by any means (like r...
#define AVIO_FLAG_DIRECT
Use direct mode.
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
int ffio_fdopen(AVIOContext **s, URLContext *h)
Create and initialize a AVIOContext for accessing the resource referenced by the URLContext h.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void avio_wb16(AVIOContext *s, unsigned int val)
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client.
unsigned int avio_rb32(AVIOContext *s)
int ff_get_v_length(uint64_t val)
Get the length in bytes which is needed to store val as v.
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
int avio_handshake(AVIOContext *c)
Perform one step of the protocol handshake to accept a new client.
static void writeout(AVIOContext *s, const uint8_t *data, int len)
int64_t avio_size(AVIOContext *s)
Get the filesize.
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
void avio_wl64(AVIOContext *s, uint64_t val)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
uint64_t avio_rb64(AVIOContext *s)
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
@ AVIO_DATA_MARKER_FLUSH_POINT
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...