Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi HEX und String (Bit 6 auslesen) (https://www.delphipraxis.net/65616-hex-und-string-bit-6-auslesen.html)

Amnon82 18. Mär 2006 21:31


HEX und String (Bit 6 auslesen)
 
Ich hab ein Problem.

Ich code grad an einem kleinen Tool um D2V-Dateien in Delphi zu prasen.

Hier mal die relevanten Auszüge aus dem D2V-Handbuch:

Zitat:

Following is a typical data section (real ones will typically be much longer):
d00 6 0 0 0 0 b0 b0 90 b0 b0 a0 b0 b0 a0 b0 b0 a0 b0 b0 a0
d00 6 0 384035 0 0 b0 b0 90 b0 b0 a0 b0 b0 a0 b0 b0 a0 b0 b0 a0
d00 6 0 768034 0 0 b0 b0 90 b0 b0 a0 b0 b0 a0 b0 b0 a0 b0 b0 a0
d00 6 0 1152609 0 0 b0 b0 90 b0 b0 a0 b0 b0 a0 b0 b0 a0 b0 b0 a0
d00 6 0 1537064 0 0 b0 b0 90 b0 b0 a0 b0 b0 a0 b0 b0 a0 b0 b0 a0

Therefore, the second line in the typical data section given above would break down as follows:

info matrix file position vob cell flags
d00 6 0 384035 0 0 b0 b0 90 b0 b0 a0 b0 b0 a0 b0 b0 a0 b0 b0 a0

The info field is a 12-bit hex number bit-mapped as follows:

bit 11 1 (Always 1 to signal start of data line)
bit 10 1 (This line's pictures are part of a closed GOP)
0 (Open GOP)
bit 9 1 (This line's pictures are part of a progressive sequence)
0 (Otherwise)
bit 8 1 (This I picture starts a new GOP)
0 (Otherwise)
bits 7-0 0 (Reserved)

The sequence of Flags fields contains per-picture data corresponding to the pictures in display order, that is, the Flags fields are re-ordered into display order. End Of Stream is signaled with a Flags field value of ff. Each per-picture Flags field is an 8-bit hex number bit-mapped as follows:

bit 7 1 (Picture is decodable without the previous GOP)
0 (Otherwise)
bit 6 Progressive_Frame Flag (See notes below)
0 (Interlaced)
1 (Progressive)
bits 5-4 Picture_Coding_Type Flag
00 (Reserved)
01 (I-Frame)
10 (P-Frame)
11 (B-Frame)
bits 3-2 00 (Reserved)
01 (Reserved)
10 (Reserved)
11 (Reserved)
bit 1 TFF Flag
bit 0 RFF Flag
Ich möchte nun gerne den Wert für Bit 6 herausfinden:

bit 6 Progressive_Frame Flag (See notes below)
0 (Interlaced)
1 (Progressive)

Nur wie?

D2VParse Thread @ doom9.org

jfheins 18. Mär 2006 21:56

Re: HEX und String (Bit 6 auslesen)
 
Delphi-Quellcode:
if (value and $00100000) <> 0 then
// Bit gesetzt
;)

Dax 18. Mär 2006 22:01

Re: HEX und String (Bit 6 auslesen)
 
Bit 6? Julius? :shock: War Bit 6 in Hex nicht $40? :gruebel:

Edit: so wie ich das sehe meinst du Bit 1 von Nibble 6 ;)

Amnon82 18. Mär 2006 22:16

Re: HEX und String (Bit 6 auslesen)
 
Delphi-Quellcode:
if pos(uppercase(' '),uppercase(listbox1.items[i])) > 0 then
if (strtoint(listbox1.items[i]) and $00100000) <> 0 then checkbox1.checked:=true else checkbox1.checked:=false;
... bringt mich nicht weiter, da Delphi jedes Zeichen einzeln sieht.

Wie komme ich z.B. auf b0? b0 ist doch HEX oder? Mit Copy?

Tempstring > Copy > Value und dann den Code ...

Amnon82 18. Mär 2006 22:44

Re: HEX und String (Bit 6 auslesen)
 
Mit folgenden Codes kann ich nun die Werte in grün auslesen:

d00 1 0 2048 1 1 92 b2 a2 b2 b2 a2 b2 b2 a2 b2 b2 a2

Delphi-Quellcode:
function GetTok(const Str: string; const Idx: Integer; const Sep: Char): string;
var
  StrLen: Integer;
  StrIdx: Integer;
  ResLen: Integer;
  TokIdx: Integer;
begin
  Result := '';
  if Idx > 0 then
  begin
    StrLen := Length(Str);
    SetLength(Result, StrLen);
    ResLen := 0;
    TokIdx := 0;
    for StrIdx := 1 to StrLen do
    begin
      if (Str[StrIdx] <> Sep) and ((StrIdx = 1) or (Str[StrIdx-1] = Sep)) then
        Inc(TokIdx);
      if TokIdx > Idx then
        Break
      else if (TokIdx = Idx) and (Str[StrIdx] <> Sep) then
      begin
        Inc(ResLen);
        Result[ResLen] := Str[StrIdx];
      end;
    end;
    SetLength(Result, ResLen);
  end;
end;
Delphi-Quellcode:
if pos(uppercase(' '),uppercase(listbox1.items[i])) > 0 then
begin
temp:=listbox1.Items[i];
for tempi := 7 to length(temp) do
begin
value:=GetTok(temp, tempi, ' ');
//Showmessage(value);
if (strtoint(value) and $00100000) <> 0 then checkbox1.checked:=true else checkbox1.checked:=false;
end;
end;
nur value währe kein gültiger integer:

if (strtoint(value) and $00100000) <> 0 then checkbox1.checked:=true else checkbox1.checked:=false;

jfheins 18. Mär 2006 22:51

Re: HEX und String (Bit 6 auslesen)
 
Zitat:

Zitat von Dax
Bit 6? Julius? :shock: War Bit 6 in Hex nicht $40? :gruebel:

Edit: so wie ich das sehe meinst du Bit 1 von Nibble 6 ;)

Verdammt, warum kann man nicht in Binär coden ? :mrgreen:

Aber Bit 6 ist imho $20 und nicht $40 (Bit 7 ...) :mrgreen:

Btw.: Was ist ein Nibble ? :gruebel:

Dax 18. Mär 2006 23:10

Re: HEX und String (Bit 6 auslesen)
 
Zitat:

Zitat von jfheins
Aber Bit 6 ist imho $20 und nicht $40 (Bit 7 ...) :mrgreen:

Jetzt auf einmal kannstes, oder wie? :stupid:

Zitat:

Zitat von jfheins
Btw.: Was ist ein Nibble ? :gruebel:

Ein Nibble ist ein Halbbyte, steht im Wiki ;)

Amnon82 19. Mär 2006 08:13

Re: HEX und String (Bit 6 auslesen)
 
Ich will euch ja nicht unterbrechen ;), aber könnte mir einer von Euch "Gurus" ein Beispiel posten?
Es könnte ja sein, dass ich mit meinem Ansatz total falsch liege ...

Delphi-Quellcode:
if pos(uppercase(' '),uppercase(listbox1.items[i])) > 0 then
begin
temp:=listbox1.Items[i];
for tempi := 7 to length(temp) do
begin
value:=GetTok(temp, tempi, ' ');
//Showmessage(value);
i2:=strtoint(Inttohex(strtoint('x'+value),2));
showmessage(inttostr(i2));
if (i2 and $20) <> 0 then checkbox1.checked:=true else checkbox1.checked:=false;
end;
end;
... damit kommt immer noch ne Fehlermeldung alla 'b2' ist ein gülter Integer Wert.

Amnon82 19. Mär 2006 08:42

Re: HEX und String (Bit 6 auslesen)
 
Dann müsste das ja die Lösung sein:

Delphi-Quellcode:
if pos(uppercase(' '),uppercase(listbox1.items[i])) > 0 then
begin
temp:=listbox1.Items[i];
for tempi := 7 to length(temp) do
begin
value:=GetTok(temp, tempi, ' ');
Showmessage(value+'-'+inttostr($20));
//i2:=strtoint(Inttohex(strtoint('x'+value),2));
//showmessage(inttostr(i2));
//if (i2 and $20) <> 0 then
if value = inttostr($20) then thirtytwo:=thirtytwo+1;
if thirtytwo > 0 then
checkbox1.checked:=true else checkbox1.checked:=false;
end;
end;
Da ja mein zu prasender Text so aussieht:

Code:
d00 1 0 2048 1 1 92 b2 a2 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 53248 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 133120 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 423936 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 712704 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 917504 1 1 32 32 92 b2 b2 a2 a2 b2 b2 a2
900 1 0 1273856 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 1644544 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 1910784 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 2201600 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 2516992 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2
900 1 0 2838528 1 1 32 32 92 b2 b2 a2 b2 b2 a2 b2 b2 a2

Amnon82 19. Mär 2006 20:12

Re: HEX und String (Bit 6 auslesen)
 
Hmm, stimmt jetzt doch nicht, da folgender Code auch progressiv ist:

Code:
d00 1 0 2048 1 1 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2 f2 e2
900 1 0 65536 1 1 72 72 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2
900 1 0 176128 1 1 72 72 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2
900 1 0 284672 1 1 72 72 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2
900 1 0 391168 1 1 72 72 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2
900 1 0 505856 1 1 72 72 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2
900 1 0 630784 1 1 72 72 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2
900 1 0 794624 1 1 72 d2 f2 f2 e2 e2 f2 f2 e2 f2 f2 e2
900 1 0 1011712 1 1 72 72 d2 f2 f2 e2 f2 e2 f2 f2 e2 e2
900 1 0 1280000 1 1 72 72 d2 f2 e2 f2 f2 e2 e2 f2 f2 e2
900 1 0 1585152 1 1 72 d2 f2 f2 e2 e2 f2 f2 e2 f2 f2 e2
900 1 0 1943552 1 1 72 72 d2 f2 f2 e2 f2 f2 e2 f2 f2 e2
900 1 0 2318336 1 1 72 72 d2 e2 f2 f2 e2 f2 e2 f2 f2 e2


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:58 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz