//--------------------------------------------------------------------------- void File_DtvccTransport::Read_Buffer_Continue() { //Parsing Element_Begin1(Format==Format_DVD?"DVD Captions":"DTVCC Transport"); int8u cc_count; bool process_cc_data_flag, additional_data_flag; BS_Begin(); if (Format==Format_DVD) { //Modified DTVCC Transport from DVD Skip_SB( "field 1 then field 2"); Get_S1 (7, cc_count, "cc_count"); process_cc_data_flag=true; additional_data_flag=false; } else { //Normal DTVCC Transport bool process_em_data_flag; Get_SB (process_em_data_flag, "process_em_data_flag"); Get_SB (process_cc_data_flag, "process_cc_data_flag"); Get_SB (additional_data_flag, "additional_data_flag"); Get_S1 (5, cc_count, "cc_count"); Skip_S1(8, process_em_data_flag?"em_data":"reserved"); //Emergency message } BS_End(); if (process_cc_data_flag) { for (int8u Pos=0; Pos<cc_count; Pos++) { if (Element_Offset+3>Element_Size) break; //Found one stream with bad cc_count, we discard cc_count without flagging the stream as untrusted for the moment Element_Begin1("cc"); int8u cc_type; bool cc_valid; BS_Begin(); Mark_1(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); if (Format==Format_DVD) { //Modified DTVCC Transport from DVD Mark_1(); Mark_1(); Get_S1 (1, cc_type, "cc_type"); Param_Info1(DtvccTransport_cc_type(cc_type)); cc_valid=true; } else { //Normal DTVCC Transport Get_SB ( cc_valid, "cc_valid"); Get_S1 (2, cc_type, "cc_type"); Param_Info1(DtvccTransport_cc_type(cc_type)); } BS_End(); #if MEDIAINFO_ADVANCED if (cc_type>=2 && !Streams[2] && Config->File_Eia708_DisplayEmptyStream_Get()) CreateStream(2); #endif //MEDIAINFO_ADVANCED if (cc_valid) { Element_Begin1("cc_data"); //Calculating the parser position int8u Parser_Pos=cc_type==3?2:cc_type; //cc_type 2 and 3 are for the same text //Stream creation if (Streams[Parser_Pos]==NULL) CreateStream(Parser_Pos); //Parsing #if MEDIAINFO_DEMUX Element_Code=Parser_Pos; Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream); #endif //MEDIAINFO_DEMUX if (!Streams[Parser_Pos]->Parser->Status[IsFinished]) { //Parsing if (Streams[Parser_Pos]->Parser->PTS_DTS_Needed) { Streams[Parser_Pos]->Parser->FrameInfo.PCR=FrameInfo.PCR; Streams[Parser_Pos]->Parser->FrameInfo.PTS=FrameInfo.PTS; Streams[Parser_Pos]->Parser->FrameInfo.DTS=FrameInfo.DTS; } if (Parser_Pos==2) { #if defined(MEDIAINFO_EIA708_YES) ((File_Eia708*)Streams[2]->Parser)->cc_type=cc_type; if (AspectRatio) ((File_Eia708*)Streams[2]->Parser)->AspectRatio=AspectRatio; #endif if (cc_type==3) { ((File_Eia708*)Streams[2]->Parser)->cc_type=4; //Magic value saying that the buffer must be kept (this is only a point of synchro from the undelying layer) Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 0); ((File_Eia708*)Streams[2]->Parser)->cc_type=3; } } else { } #if defined(MEDIAINFO_EIA608_YES) || defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser->ServiceDescriptors=ServiceDescriptors; #endif Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 2); Element_Show(); Element_Offset+=2; } else Skip_XX(2, "Data"); Element_End0(); } else Skip_XX(2, "Junk"); Element_End0(); } FILLING_BEGIN(); if (!Status[IsAccepted]) Accept("DTVCC Transport"); FILLING_END(); } else Skip_XX(cc_count*2, "Junk"); if (Format==Format_A53_4_GA94_03) { //Normal DTVCC Transport BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); BS_End(); if (additional_data_flag) { Skip_XX(Element_Size-Element_Offset, "additional_user_data"); } while (Element_Offset<Element_Size) { Skip_B1( "Zero"); //TODO: test Zero } } Element_End0(); }
//--------------------------------------------------------------------------- void File_DtvccTransport::Read_Buffer_Continue() { //Parsing Element_Begin(Format==Format_DVD?"DVD Captions":"DTVCC Transport"); int8u cc_count; bool process_cc_data_flag, additional_data_flag; BS_Begin(); if (Format==Format_DVD) { //Modified DTVCC Transport from DVD Skip_SB( "field 1 then field 2"); Get_S1 (7, cc_count, "cc_count"); process_cc_data_flag=true; additional_data_flag=false; } else { //Normal DTVCC Transport bool process_em_data_flag; Get_SB (process_em_data_flag, "process_em_data_flag"); Get_SB (process_cc_data_flag, "process_cc_data_flag"); Get_SB (additional_data_flag, "additional_data_flag"); Get_S1 (5, cc_count, "cc_count"); Skip_S1(8, process_em_data_flag?"em_data":"reserved"); //Emergency message } BS_End(); if (process_cc_data_flag) { for (int8u Pos=0; Pos<cc_count; Pos++) { Element_Begin("cc"); int8u cc_type; bool cc_valid; BS_Begin(); Mark_1(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); if (Format==Format_DVD) { //Modified DTVCC Transport from DVD Mark_1(); Mark_1(); Get_S1 (1, cc_type, "cc_type"); Param_Info(DtvccTransport_cc_type(cc_type)); cc_valid=true; } else { //Normal DTVCC Transport Get_SB ( cc_valid, "cc_valid"); Get_S1 (2, cc_type, "cc_type"); Param_Info(DtvccTransport_cc_type(cc_type)); } BS_End(); if (cc_valid) { Element_Begin("cc_data"); //Calculating the parser position int8u Parser_Pos=cc_type==3?2:cc_type; //cc_type 2 and 3 are for the same text //Parsing #if MEDIAINFO_DEMUX Element_Code=Parser_Pos; #endif //MEDIAINFO_DEMUX if (Streams[Parser_Pos]==NULL) Streams[Parser_Pos]=new stream; if (Streams[Parser_Pos]->Parser==NULL) { if (cc_type<2) { #if defined(MEDIAINFO_EIA608_YES) Streams[Parser_Pos]->Parser=new File_Eia608(); #else Streams[Parser_Pos]->Parser=new File__Analyze(); #endif } else { #if defined(MEDIAINFO_EIA708_YES) Streams[Parser_Pos]->Parser=new File_Eia708(); #else Streams[Parser_Pos]->Parser=new File__Analyze(); #endif } Open_Buffer_Init(Streams[Parser_Pos]->Parser); } Demux(Buffer+(size_t)(Buffer_Offset+Element_Offset), 2, ContentType_MainStream); if (!Streams[Parser_Pos]->Parser->Status[IsFinished]) { //Parsing if (Streams[Parser_Pos]->Parser->PTS_DTS_Needed) { Streams[Parser_Pos]->Parser->FrameInfo.PCR=FrameInfo.PCR; Streams[Parser_Pos]->Parser->FrameInfo.PTS=FrameInfo.PTS; Streams[Parser_Pos]->Parser->FrameInfo.DTS=FrameInfo.DTS; } if (Parser_Pos==2) { #if defined(MEDIAINFO_EIA708_YES) ((File_Eia708*)Streams[2]->Parser)->cc_type=cc_type; ((File_Eia708*)Streams[2]->Parser)->AspectRatio=AspectRatio; #endif if (cc_type==3) Streams[2]->Parser->Open_Buffer_Unsynch(); } else { } Open_Buffer_Continue(Streams[Parser_Pos]->Parser, Buffer+(size_t)(Buffer_Offset+Element_Offset), 2); Element_Show(); Element_Offset+=2; //Filled if (!Streams[Parser_Pos]->IsFilled && Streams[Parser_Pos]->Parser->Status[IsFilled]) { if (Count_Get(Stream_General)==0) Accept("DTVCC Transport"); Streams_Count++; if (Streams_Count==3) Fill("DTVCC Transport"); Streams[Parser_Pos]->IsFilled=true; } } else Skip_XX(2, "Data"); Element_End(); } else Skip_XX(2, "Junk"); Element_End(); } } else Skip_XX(cc_count*2, "Junk"); if (Format==Format_A53_4_GA94_03) { //Normal DTVCC Transport BS_Begin(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); Mark_1_NoTrustError(); BS_End(); if (additional_data_flag) { Skip_XX(Element_Size-Element_Offset, "additional_user_data"); } while (Element_Offset<Element_Size) { Skip_B1( "Zero"); //TODO: test Zero } } Element_End(); }