Go to the documentation of this file.
29 size_t new_alloc_size;
31 if (
ctx->auxiliary_info_size +
size >
ctx->auxiliary_info_alloc_size) {
32 new_alloc_size =
FFMAX(
ctx->auxiliary_info_size +
size,
ctx->auxiliary_info_alloc_size * 2);
37 ctx->auxiliary_info_alloc_size = new_alloc_size;
52 memcpy(
ctx->auxiliary_info +
ctx->auxiliary_info_size, buf_in,
size);
53 ctx->auxiliary_info_size +=
size;
59 uint16_t clear_bytes, uint32_t encrypted_bytes)
64 if (!
ctx->use_subsamples) {
73 p =
ctx->auxiliary_info +
ctx->auxiliary_info_size;
76 p +=
sizeof(uint16_t);
80 ctx->auxiliary_info_size += 6;
81 ctx->subsample_count++;
93 const uint8_t* cur_pos = buf_in;
97 while (size_left > 0) {
98 cur_size =
FFMIN(size_left,
sizeof(chunk));
102 size_left -= cur_size;
119 if (!
ctx->use_subsamples) {
124 ctx->auxiliary_info_subsample_start =
ctx->auxiliary_info_size;
125 ctx->subsample_count = 0;
139 size_t new_alloc_size;
143 if (!
ctx->use_subsamples) {
144 ctx->auxiliary_info_entries++;
149 if (
ctx->auxiliary_info_entries >=
ctx->auxiliary_info_sizes_alloc_size) {
150 new_alloc_size =
ctx->auxiliary_info_entries * 2 + 1;
155 ctx->auxiliary_info_sizes_alloc_size = new_alloc_size;
157 ctx->auxiliary_info_sizes[
ctx->auxiliary_info_entries] =
159 ctx->auxiliary_info_entries++;
162 AV_WB16(
ctx->auxiliary_info +
ctx->auxiliary_info_subsample_start,
ctx->subsample_count);
197 const uint8_t *nal_start, *nal_end;
208 while (nal_start <
end && !*(nal_start++));
209 if (nal_start ==
end)
220 size += 4 + nal_end - nal_start;
246 if (
size < nal_length_size + 1) {
248 size, nal_length_size + 1);
255 for (j = 0; j < nal_length_size; j++) {
256 nalsize = (nalsize << 8) | *buf_in++;
258 size -= nal_length_size;
261 if (nalsize <= 0 || nalsize >
size) {
293 int64_t* auxiliary_info_offset)
313 version = auxiliary_info_offset > 0xffffffff ? 1 : 0;
333 if (
ctx->use_subsamples) {
341 int64_t auxiliary_info_offset;
389 int use_subsamples,
int bitexact)
407 ctx->use_subsamples = use_subsamples;
static int mov_cenc_write_senc_tag(MOVMuxCencContext *ctx, AVIOContext *pb, int64_t *auxiliary_info_offset)
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
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
static int mov_cenc_write_saio_tag(AVIOContext *pb, int64_t auxiliary_info_offset)
static int auxiliary_info_alloc_size(MOVMuxCencContext *ctx, int size)
static void mov_cenc_write_encrypted(MOVMuxCencContext *ctx, AVIOContext *pb, const uint8_t *buf_in, int size)
Encrypt the input buffer and write using avio_write.
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
static av_cold int end(AVCodecContext *avctx)
const uint8_t * av_aes_ctr_get_iv(struct AVAESCTR *a)
Get the current iv.
static int mov_cenc_end_packet(MOVMuxCencContext *ctx)
Finalize a packet.
static int mov_cenc_start_packet(MOVMuxCencContext *ctx)
Start writing a packet.
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void ff_mov_cenc_free(MOVMuxCencContext *ctx)
Free a CENC context.
static int mov_cenc_write_schi_tag(AVIOContext *pb, uint8_t *kid)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int64_t update_size(AVIOContext *pb, int64_t pos)
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int count)
Process a buffer using a previously initialized context.
void av_aes_ctr_set_random_iv(struct AVAESCTR *a)
Generate a random iv.
int ff_mov_cenc_avc_write_nal_units(AVFormatContext *s, MOVMuxCencContext *ctx, int nal_length_size, AVIOContext *pb, const uint8_t *buf_in, int size)
Write AVC NAL units that are in MP4 format, the nal size and type are written in the clear while the ...
void avio_w8(AVIOContext *s, int b)
int ff_mov_cenc_init(MOVMuxCencContext *ctx, uint8_t *encryption_key, int use_subsamples, int bitexact)
Initialize a CENC context.
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
static int mov_cenc_write_saiz_tag(MOVMuxCencContext *ctx, AVIOContext *pb)
int ff_mov_cenc_write_packet(MOVMuxCencContext *ctx, AVIOContext *pb, const uint8_t *buf_in, int size)
Write a fully encrypted packet.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
void avio_wl32(AVIOContext *s, unsigned int val)
void ff_mov_cenc_write_stbl_atoms(MOVMuxCencContext *ctx, AVIOContext *pb)
Write the cenc atoms that should reside inside stbl.
static int auxiliary_info_write(MOVMuxCencContext *ctx, const uint8_t *buf_in, int size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int ff_mov_cenc_write_sinf_tag(MOVTrack *track, AVIOContext *pb, uint8_t *kid)
Write the sinf atom, contained inside stsd.
static int auxiliary_info_add_subsample(MOVMuxCencContext *ctx, uint16_t clear_bytes, uint32_t encrypted_bytes)
void avio_wb64(AVIOContext *s, uint64_t val)
void avio_wb24(AVIOContext *s, unsigned int val)
void av_aes_ctr_increment_iv(struct AVAESCTR *a)
Increment the top 64 bit of the iv (performed after each frame)
int ff_mov_cenc_avc_parse_nal_units(MOVMuxCencContext *ctx, AVIOContext *pb, const uint8_t *buf_in, int size)
Parse AVC NAL units from annex B format, the nal size and type are written in the clear while the bod...
const uint8_t * ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)