Lines Matching refs:klv
194 static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
198 klv->offset = avio_tell(pb) - 4;
199 memcpy(klv->key, mxf_klv_key, 4);
200 avio_read(pb, klv->key + 4, 12);
201 klv->length = klv_decode_ber_length(pb);
202 return klv->length == -1 ? -1 : 0;
205 static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
212 if (!memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number)))
248 static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
253 int64_t end = avio_tell(pb) + klv->length;
272 // source klv key
274 avio_read(pb, klv->key, 16);
275 if (!IS_KLV_KEY(klv, mxf_essence_element_key))
277 index = mxf_get_stream_index(s, klv);
313 KLVPacket klv;
317 if (klv_read_packet(&klv, s->pb) < 0)
319 PRINT_KEY(s, "read packet", klv.key);
320 av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
321 if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
322 ret = mxf_decrypt_triplet(s, pkt, &klv);
329 if (IS_KLV_KEY(klv.key, mxf_essence_element_key)) {
330 int index = mxf_get_stream_index(s, &klv);
332 av_log(s, AV_LOG_ERROR, "error getting stream index %d\n", AV_RB32(klv.key+12));
338 if (klv.key[12] == 0x06 && klv.key[13] == 0x01 && klv.key[14] == 0x10) {
339 if (mxf_get_d10_aes3_packet(s->pb, s->streams[index], pkt, klv.length) < 0) {
344 ret = av_get_packet(s->pb, pkt, klv.length);
349 pkt->pos = klv.offset;
353 avio_skip(s->pb, klv.length);
878 static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
882 uint64_t klv_end = avio_tell(pb) + klv->length;
923 KLVPacket klv;
935 if ((ret = klv_read_packet(&klv, s->pb)) < 0)
937 PRINT_KEY(s, "read header", klv.key);
938 av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
939 if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) ||
940 IS_KLV_KEY(klv.key, mxf_essence_element_key)) {
942 avio_seek(s->pb, klv.offset, SEEK_SET);
947 if (IS_KLV_KEY(klv.key, metadata->key)) {
949 if (klv.key[5] == 0x53) {
950 res = mxf_read_local_tags(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type);
961 avio_skip(s->pb, klv.length);