Go to the documentation of this file.
31 size_t new_alloc_size;
33 if (
ctx->auxiliary_info_size +
size >
ctx->auxiliary_info_alloc_size) {
34 new_alloc_size =
FFMAX(
ctx->auxiliary_info_size +
size,
ctx->auxiliary_info_alloc_size * 2);
39 ctx->auxiliary_info_alloc_size = new_alloc_size;
46 const uint8_t *buf_in,
int size)
54 memcpy(
ctx->auxiliary_info +
ctx->auxiliary_info_size, buf_in,
size);
55 ctx->auxiliary_info_size +=
size;
61 uint16_t clear_bytes, uint32_t encrypted_bytes)
66 if (!
ctx->use_subsamples) {
75 p =
ctx->auxiliary_info +
ctx->auxiliary_info_size;
78 p +=
sizeof(uint16_t);
82 ctx->auxiliary_info_size += 6;
83 ctx->subsample_count++;
92 const uint8_t *buf_in,
int size)
95 const uint8_t* cur_pos = buf_in;
99 while (size_left > 0) {
100 cur_size =
FFMIN(size_left,
sizeof(chunk));
104 size_left -= cur_size;
121 if (!
ctx->use_subsamples) {
126 ctx->auxiliary_info_subsample_start =
ctx->auxiliary_info_size;
127 ctx->subsample_count = 0;
141 size_t new_alloc_size;
145 if (!
ctx->use_subsamples) {
146 ctx->auxiliary_info_entries++;
151 if (
ctx->auxiliary_info_entries >=
ctx->auxiliary_info_sizes_alloc_size) {
152 new_alloc_size =
ctx->auxiliary_info_entries * 2 + 1;
157 ctx->auxiliary_info_sizes_alloc_size = new_alloc_size;
159 ctx->auxiliary_info_sizes[
ctx->auxiliary_info_entries] =
161 ctx->auxiliary_info_entries++;
164 AV_WB16(
ctx->auxiliary_info +
ctx->auxiliary_info_subsample_start,
ctx->subsample_count);
170 const uint8_t *buf_in,
int size)
195 const uint8_t *buf_in,
int size)
197 const uint8_t *p = buf_in;
198 const uint8_t *end = p +
size;
199 const uint8_t *nal_start, *nal_end;
210 while (nal_start < end && !*(nal_start++));
211 if (nal_start == end)
222 size += 4 + nal_end - nal_start;
248 if (
size < nal_length_size + 1) {
250 size, nal_length_size + 1);
257 for (j = 0; j < nal_length_size; j++) {
258 nalsize = (nalsize << 8) | *buf_in++;
260 size -= nal_length_size;
263 if (nalsize <= 0 || nalsize >
size) {
295 int64_t* auxiliary_info_offset)
315 version = auxiliary_info_offset > 0xffffffff ? 1 : 0;
335 if (
ctx->use_subsamples) {
391 int use_subsamples,
int bitexact)
409 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.
static int mov_cenc_end_packet(MOVMuxCencContext *ctx)
Finalize a packet.
void av_aes_ctr_set_random_iv(struct AVAESCTR *a)
Generate a random iv.
static int mov_cenc_start_packet(MOVMuxCencContext *ctx)
Start writing a packet.
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)
const uint8_t * av_aes_ctr_get_iv(struct AVAESCTR *a)
Get the current iv.
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
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.
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize 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.
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
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 av_aes_ctr_increment_iv(struct AVAESCTR *a)
Increment the top 64 bit of the iv (performed after each frame)
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 avio_wb64(AVIOContext *s, uint64_t val)
void avio_wb24(AVIOContext *s, unsigned int val)
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_nal_find_startcode(const uint8_t *p, const uint8_t *end)