Lines Matching refs:klv
296 static int klv_read_packet(KLVPacket *klv, AVIOContext *pb)
300 klv->offset = avio_tell(pb) - 4;
301 memcpy(klv->key, mxf_klv_key, 4);
302 avio_read(pb, klv->key + 4, 12);
303 klv->length = klv_decode_ber_length(pb);
304 return klv->length == -1 ? -1 : 0;
307 static int mxf_get_stream_index(AVFormatContext *s, KLVPacket *klv)
314 if (!memcmp(klv->key + sizeof(mxf_essence_element_key), track->track_number, sizeof(track->track_number)))
350 static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
355 int64_t end = avio_tell(pb) + klv->length;
374 // source klv key
376 avio_read(pb, klv->key, 16);
377 if (!IS_KLV_KEY(klv, mxf_essence_element_key))
379 index = mxf_get_stream_index(s, klv);
1837 static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
1841 uint64_t klv_end = avio_tell(pb) + klv->length;
1881 tag, klv->offset);
2048 KLVPacket klv;
2059 if (klv_read_packet(&klv, s->pb) < 0 ||
2060 !IS_KLV_KEY(klv.key, mxf_random_index_pack_key) ||
2061 klv.length != length - 20)
2064 avio_skip(s->pb, klv.length - 12);
2074 KLVPacket klv;
2101 if (klv_read_packet(&klv, s->pb) < 0) {
2109 PRINT_KEY(s, "read header", klv.key);
2110 av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
2111 if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) ||
2112 IS_KLV_KEY(klv.key, mxf_essence_element_key) ||
2113 IS_KLV_KEY(klv.key, mxf_avid_essence_element_key) ||
2114 IS_KLV_KEY(klv.key, mxf_system_item_key)) {
2138 mxf->current_partition->essence_length = klv.length;
2140 /* NOTE: op1a_essence_offset may be less than to klv.offset (C0023S01.mxf) */
2146 essence_offset = klv.offset;
2152 } else if (!memcmp(klv.key, mxf_header_partition_pack_key, 13) &&
2153 klv.key[13] >= 2 && klv.key[13] <= 4 && mxf->current_partition) {
2163 if (IS_KLV_KEY(klv.key, metadata->key)) {
2165 if (klv.key[5] == 0x53) {
2166 res = mxf_read_local_tags(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type);
2168 uint64_t next = avio_tell(s->pb) + klv.length;
2169 res = metadata->read(mxf, s->pb, 0, klv.length, klv.key, klv.offset);
2174 klv.offset);
2188 avio_skip(s->pb, klv.length);
2326 KLVPacket klv;
2330 while ((ret = klv_read_packet(&klv, s->pb)) == 0) {
2331 PRINT_KEY(s, "read packet", klv.key);
2332 av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
2333 if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
2334 ret = mxf_decrypt_triplet(s, pkt, &klv);
2341 if (IS_KLV_KEY(klv.key, mxf_essence_element_key) ||
2342 IS_KLV_KEY(klv.key, mxf_avid_essence_element_key)) {
2343 int index = mxf_get_stream_index(s, &klv);
2352 AV_RB32(klv.key + 12));
2362 next_klv = avio_tell(s->pb) + klv.length;
2363 next_ofs = mxf_set_current_edit_unit(mxf, klv.offset);
2373 klv.length = next_ofs - avio_tell(s->pb);
2377 if (klv.key[12] == 0x06 && klv.key[13] == 0x01 && klv.key[14] == 0x10) {
2379 pkt, klv.length);
2385 ret = av_get_packet(s->pb, pkt, klv.length);
2390 pkt->pos = klv.offset;
2419 avio_skip(s->pb, klv.length);