From c2240e6500f50b630aa33b85c16c706fa9c7ec68 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 21 Oct 2003 22:01:31 +0000 Subject: [PATCH] Adjusted the content encoding handling to the final specs. --- ChangeLog | 5 ++ src/pr_generic.cpp | 4 +- src/r_matroska.cpp | 183 +++++++++++++++++++++++---------------------- 3 files changed, 102 insertions(+), 90 deletions(-) diff --git a/ChangeLog b/ChangeLog index b2a9b4397..901bb77bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-10-22 Moritz Bunkus + + * mkvmerge: Adjusted the compression handling to the final content + encoding specs. + 2003-10-19 Moritz Bunkus * mkvmerge: new feature: Implemented generic support for frame diff --git a/src/pr_generic.cpp b/src/pr_generic.cpp index 39b6755fe..1feca03f4 100644 --- a/src/pr_generic.cpp +++ b/src/pr_generic.cpp @@ -528,10 +528,12 @@ void generic_packetizer_c::set_headers() { hcompression = ti->compression; if ((hcompression != COMPRESSION_UNSPECIFIED) && (hcompression != COMPRESSION_NONE)) { + KaxContentEncodings *c_encodings; KaxContentEncoding *c_encoding; KaxContentCompression *c_comp; - c_encoding = &GetChild(*track_entry); + c_encodings = &GetChild(*track_entry); + c_encoding = &GetChild(*c_encodings); // First modification *static_cast (&GetChild(*c_encoding)) = 0; diff --git a/src/r_matroska.cpp b/src/r_matroska.cpp index c35a05f30..fe7fd8165 100644 --- a/src/r_matroska.cpp +++ b/src/r_matroska.cpp @@ -798,6 +798,7 @@ int kax_reader_c::read_headers() { KaxTrackLanguage *ktlanguage; KaxTrackMinCache *ktmincache; KaxTrackName *ktname; + KaxContentEncodings *kcencodings; int kcenc_idx; vector::iterator ce_ins_it; @@ -1009,104 +1010,108 @@ int kax_reader_c::read_headers() { safefree(tmp); } - for (kcenc_idx = 0; kcenc_idx < ktentry->ListSize(); kcenc_idx++) { - l3 = (*ktentry)[kcenc_idx]; - if (EbmlId(*l3) == KaxContentEncoding::ClassInfos.GlobalId) { - KaxContentEncoding *kcenc; - KaxContentEncodingOrder *ce_order; - KaxContentEncodingType *ce_type; - KaxContentEncodingScope *ce_scope; - KaxContentCompression *ce_comp; - KaxContentEncryption *ce_enc; - kax_content_encoding_t enc; + kcencodings = FINDFIRST(ktentry, KaxContentEncodings); + if (kcencodings != NULL) { + for (kcenc_idx = 0; kcenc_idx < kcencodings->ListSize(); + kcenc_idx++) { + l3 = (*kcencodings)[kcenc_idx]; + if (EbmlId(*l3) == KaxContentEncoding::ClassInfos.GlobalId) { + KaxContentEncoding *kcenc; + KaxContentEncodingOrder *ce_order; + KaxContentEncodingType *ce_type; + KaxContentEncodingScope *ce_scope; + KaxContentCompression *ce_comp; + KaxContentEncryption *ce_enc; + kax_content_encoding_t enc; - memset(&enc, 0, sizeof(kax_content_encoding_t)); - kcenc = static_cast(l3); + memset(&enc, 0, sizeof(kax_content_encoding_t)); + kcenc = static_cast(l3); - ce_order = FINDFIRST(kcenc, KaxContentEncodingOrder); - if (ce_order != NULL) - enc.order = uint32(*ce_order); + ce_order = FINDFIRST(kcenc, KaxContentEncodingOrder); + if (ce_order != NULL) + enc.order = uint32(*ce_order); - ce_type = FINDFIRST(kcenc, KaxContentEncodingType); - if (ce_type != NULL) - enc.type = uint32(*ce_type); + ce_type = FINDFIRST(kcenc, KaxContentEncodingType); + if (ce_type != NULL) + enc.type = uint32(*ce_type); - ce_scope = FINDFIRST(kcenc, KaxContentEncodingScope); - if (ce_scope != NULL) - enc.scope = uint32(*ce_scope); - else - enc.scope = 1; + ce_scope = FINDFIRST(kcenc, KaxContentEncodingScope); + if (ce_scope != NULL) + enc.scope = uint32(*ce_scope); + else + enc.scope = 1; - ce_comp = FINDFIRST(kcenc, KaxContentCompression); - if (ce_comp != NULL) { - KaxContentCompAlgo *cc_algo; - KaxContentCompSettings *cc_settings; + ce_comp = FINDFIRST(kcenc, KaxContentCompression); + if (ce_comp != NULL) { + KaxContentCompAlgo *cc_algo; + KaxContentCompSettings *cc_settings; - cc_algo = FINDFIRST(ce_comp, KaxContentCompAlgo); - if (cc_algo != NULL) - enc.comp_algo = uint32(*cc_algo); + cc_algo = FINDFIRST(ce_comp, KaxContentCompAlgo); + if (cc_algo != NULL) + enc.comp_algo = uint32(*cc_algo); - cc_settings = FINDFIRST(ce_comp, KaxContentCompSettings); - if (cc_settings != NULL) { - enc.comp_settings = - (unsigned char *)safememdup(&binary(*cc_settings), - cc_settings->GetSize()); - enc.comp_settings_len = cc_settings->GetSize(); + cc_settings = FINDFIRST(ce_comp, KaxContentCompSettings); + if (cc_settings != NULL) { + enc.comp_settings = + (unsigned char *)safememdup(&binary(*cc_settings), + cc_settings->GetSize()); + enc.comp_settings_len = cc_settings->GetSize(); + } } + + ce_enc = FINDFIRST(kcenc, KaxContentEncryption); + if (ce_enc != NULL) { + KaxContentEncAlgo *ce_ealgo; + KaxContentEncKeyID *ce_ekeyid; + KaxContentSigAlgo *ce_salgo; + KaxContentSigHashAlgo *ce_shalgo; + KaxContentSigKeyID *ce_skeyid; + KaxContentSignature *ce_signature; + + ce_ealgo = FINDFIRST(ce_enc, KaxContentEncAlgo); + if (ce_ealgo != NULL) + enc.enc_algo = uint32(*ce_ealgo); + + ce_ekeyid = FINDFIRST(ce_enc, KaxContentEncKeyID); + if (ce_ekeyid != NULL) { + enc.enc_keyid = + (unsigned char *)safememdup(&binary(*ce_ekeyid), + ce_ekeyid->GetSize()); + enc.enc_keyid_len = ce_ekeyid->GetSize(); + } + + ce_salgo = FINDFIRST(ce_enc, KaxContentSigAlgo); + if (ce_salgo != NULL) + enc.enc_algo = uint32(*ce_salgo); + + ce_shalgo = FINDFIRST(ce_enc, KaxContentSigHashAlgo); + if (ce_shalgo != NULL) + enc.enc_algo = uint32(*ce_shalgo); + + ce_skeyid = FINDFIRST(ce_enc, KaxContentSigKeyID); + if (ce_skeyid != NULL) { + enc.sig_keyid = + (unsigned char *)safememdup(&binary(*ce_skeyid), + ce_skeyid->GetSize()); + enc.sig_keyid_len = ce_skeyid->GetSize(); + } + + ce_signature = FINDFIRST(ce_enc, KaxContentSignature); + if (ce_signature != NULL) { + enc.signature = + (unsigned char *)safememdup(&binary(*ce_signature), + ce_signature->GetSize()); + enc.signature_len = ce_signature->GetSize(); + } + + } + + ce_ins_it = track->c_encodings->begin(); + while ((ce_ins_it != track->c_encodings->end()) && + (enc.order <= (*ce_ins_it).order)) + ce_ins_it++; + track->c_encodings->insert(ce_ins_it, enc); } - - ce_enc = FINDFIRST(kcenc, KaxContentEncryption); - if (ce_enc != NULL) { - KaxContentEncAlgo *ce_ealgo; - KaxContentEncKeyID *ce_ekeyid; - KaxContentSigAlgo *ce_salgo; - KaxContentSigHashAlgo *ce_shalgo; - KaxContentSigKeyID *ce_skeyid; - KaxContentSignature *ce_signature; - - ce_ealgo = FINDFIRST(ce_enc, KaxContentEncAlgo); - if (ce_ealgo != NULL) - enc.enc_algo = uint32(*ce_ealgo); - - ce_ekeyid = FINDFIRST(ce_enc, KaxContentEncKeyID); - if (ce_ekeyid != NULL) { - enc.enc_keyid = - (unsigned char *)safememdup(&binary(*ce_ekeyid), - ce_ekeyid->GetSize()); - enc.enc_keyid_len = ce_ekeyid->GetSize(); - } - - ce_salgo = FINDFIRST(ce_enc, KaxContentSigAlgo); - if (ce_salgo != NULL) - enc.enc_algo = uint32(*ce_salgo); - - ce_shalgo = FINDFIRST(ce_enc, KaxContentSigHashAlgo); - if (ce_shalgo != NULL) - enc.enc_algo = uint32(*ce_shalgo); - - ce_skeyid = FINDFIRST(ce_enc, KaxContentSigKeyID); - if (ce_skeyid != NULL) { - enc.sig_keyid = - (unsigned char *)safememdup(&binary(*ce_skeyid), - ce_skeyid->GetSize()); - enc.sig_keyid_len = ce_skeyid->GetSize(); - } - - ce_signature = FINDFIRST(ce_enc, KaxContentSignature); - if (ce_signature != NULL) { - enc.signature = - (unsigned char *)safememdup(&binary(*ce_signature), - ce_signature->GetSize()); - enc.signature_len = ce_signature->GetSize(); - } - - } - - ce_ins_it = track->c_encodings->begin(); - while ((ce_ins_it != track->c_encodings->end()) && - (enc.order <= (*ce_ins_it).order)) - ce_ins_it++; - track->c_encodings->insert(ce_ins_it, enc); } }