DGL
https://delphigl.com/forum/

Roq Format - Quake3's Video Format
https://delphigl.com/forum/viewtopic.php?f=19&t=3261
Seite 1 von 1

Autor:  Stucuk [ Sa Sep 18, 2004 02:23 ]
Betreff des Beitrags:  Roq Format - Quake3's Video Format

Iv began to convert Tim Ferguson's C code on ROQ files, but my C is well non existant.

- Tim's Decoders source
- Tim's Website

Iv currently converted Roq.h, and mostly converted Roq_read.h.

The following are missing from my convertion:

static void apply_vector_2x2(roq_info *ri, int x, int y, roq_cell *cell)
static void apply_vector_4x4(roq_info *ri, int x, int y, roq_cell *cell)
static void apply_motion_4x4(roq_info *ri, int x, int y, unsigned char mv, char mean_x, char mean_y)
static void apply_motion_8x8(roq_info *ri, int x, int y, unsigned char mv, char mean_x, char mean_y)
int roq_read_frame(roq_info *ri) // Needs procedures above made

Im betting there is quite alot of errors, anyway source attached. Help would b appriciated.

Dateianhänge:
Dateikommentar: Helios_ROQ.pas
Helios_ROQ.zip [2.75 KiB]
333-mal heruntergeladen

Autor:  Stucuk [ Sa Sep 18, 2004 22:35 ]
Betreff des Beitrags: 

2 more procedures converted with the help of a friend:

Code:
  1.  
  2. procedure apply_vector_2x2(var ri:Proq_info; x, y: integer; var cell:Proq_cell);
  3. var
  4.    p : integer;
  5. begin
  6.    p := (y * ri^.width) + x;
  7.    ri^.y[0][p] := cell^.y0;
  8.    inc(p);
  9.    ri^.y[0][p] := cell^.y1;
  10.    inc(p);
  11.    p := p + (ri^.width - 2);
  12.    ri^.y[0][p] := cell^.y2;
  13.    inc(p);
  14.    ri^.y[0][p] := cell^.y3;
  15.    inc(p);
  16.    ri^.u[0][(y div 2) * (ri^.width div 2) + (x div 2)] := cell^.u;
  17.    ri^.v[0][(y div 2) * (ri^.width div 2) + (x div 2)] := cell^.v;
  18. end;
  19.  
  20. procedure apply_vector_4x4(var ri:Proq_info; x, y: integer; var cell:Proq_cell);
  21. var
  22. p,p2,p3 : integer;
  23. row_inc, c_row_inc : longint;
  24. y0, y1, u, v : byte;
  25. begin
  26.  
  27.     P  := (y * ri^.width) + x;
  28.     P2 := (y div 2) * (ri^.width div 2) + x div 2;
  29.     P3 := (y div 2) * (ri^.width div 2) + x div 2;
  30.  
  31.     row_inc   := ri^.width - 4;
  32.     c_row_inc := (ri^.width div 2) - 2;
  33.  
  34.         y0 := cell^.y0;
  35.         y1 := cell^.y1;
  36.         v := cell^.v;
  37.         u := cell^.u;
  38.  
  39.         ri^.y[0][p] := y0;
  40.         Inc(p);
  41.         ri^.y[0][p] := y0;
  42.         Inc(p);
  43.  
  44.         ri^.y[0][p] := y1;
  45.         Inc(p);
  46.         ri^.y[0][p] := y1;
  47.         Inc(p);
  48.  
  49.         p := p + row_inc;
  50.  
  51.         ri^.y[0][p] := y0;
  52.         Inc(p);
  53.         ri^.y[0][p] := y0;
  54.         Inc(p);
  55.         ri^.y[0][p] := y1;
  56.         Inc(p);
  57.         ri^.y[0][p] := y1;
  58.         Inc(p);
  59.  
  60.         p := p + row_inc;
  61.  
  62.         y0 := cell^.y2;
  63.         y1 := cell^.y3;
  64.         ri^.y[0][p] := y0;
  65.         Inc(p);
  66.         ri^.y[0][p] := y0;
  67.         Inc(p);
  68.         ri^.y[0][p] := y1;
  69.         Inc(p);
  70.         ri^.y[0][p] := y1;
  71.         Inc(p);
  72.  
  73.         p := p + row_inc;
  74.  
  75.         ri^.y[0][p] := y0;
  76.         Inc(p);
  77.         ri^.y[0][p] := y0;
  78.         Inc(p);
  79.         ri^.y[0][p] := y1;
  80.         Inc(p);
  81.         ri^.y[0][p] := y1;
  82.         Inc(p);
  83.  
  84.         u := cell^.u;
  85.         v := cell^.v;
  86.  
  87.         ri^.u[0][p2] := u;
  88.         Inc(p2);
  89.         ri^.u[0][p2] := u;
  90.         Inc(p2);
  91.  
  92.         p2 := p2 + c_row_inc;
  93.  
  94.         ri^.u[0][p2] := u;
  95.         Inc(p2);
  96.         ri^.u[0][p2] := u;
  97.         Inc(p2);
  98.  
  99.         ri^.v[0][p3] := v;
  100.         Inc(p3);
  101.         ri^.v[0][p3] := v;
  102.         Inc(p3);
  103.  
  104.         p3 := p3 + c_row_inc;
  105.  
  106.         ri^.v[0][p3] := v;
  107.         Inc(p3);
  108.         ri^.v[0][p3] := v;
  109.         Inc(p3);
  110. end;
  111.  


None of u ever converted c to delphi?

Autor:  Sascha Willems [ Sa Sep 18, 2004 23:10 ]
Betreff des Beitrags: 

I have experience with C/C++/C# and I've also converted things from that to Delphi, but right now I'm busy (bleh, doing HTML is so much less interessting than real coding...). But if you have a specific question concerning a conversion from C to Delphi, then post it here directly and I'll see what I can do.

Autor:  Stucuk [ So Sep 19, 2004 00:36 ]
Betreff des Beitrags: 

im confused with the following:
Code:
  1.  
  2. if((nv1 = chunk_arg >> 8) == 0) nv1 = 256;
  3. if((nv2 = chunk_arg & 0xff) == 0 && nv1 * 6 < chunk_size) nv2 = 256;
  4.  


would it be
Code:
  1.  
  2. nv1 := chunk_arg shr 8;
  3. nv2 := chunk_arg and $ff;
  4.  
  5. if nv1 = 0 then nv1 := 256;
  6. if (nv1 = 0) and (nv1 * 6 < chunk_size) then nv2 := 256;
  7.  


Zitat:
bleh, doing HTML is so much less interessting than real coding..

Your making webpages? Its a shame HTML isn't compatible with opengl :wink:

EDIT:

Section made redundent due to edit2.

EDIT2:

Theres 5 bits in the file(all from roq_read_frame) marked with //ERROR each bit i don't know how to convert. See Attachment.

Dateianhänge:
Dateikommentar: v1.0b
Helios_ROQ.zip [4.57 KiB]
324-mal heruntergeladen

Autor:  Stucuk [ So Okt 03, 2004 17:56 ]
Betreff des Beitrags: 

Finished converting roq_read.h , which leaves sroqplay.c to be converted. Im wondering if anyone knows a quick way to render a frame in opengl(Draw to a texture then render it?)

Dateianhänge:
Dateikommentar: v1.0c
Helios_ROQ.zip [4.52 KiB]
328-mal heruntergeladen

Autor:  rswm [ So Okt 03, 2004 22:05 ]
Betreff des Beitrags: 

render to texture??? im not sure ...

Autor:  Mars [ Mo Okt 04, 2004 12:53 ]
Betreff des Beitrags: 

If you have a lot of pixel data to render (as in a video file), you can use glDrawPixels, if you want to use hardware scale and -rotation, you should probably stick to glTexImage2D and a textured quad (just make sure that your offline pixel format doesn't need too much computations to match the OpenGL pixel format).
Since there is (normally) not much else to do, while rendering videos, speed should be less of an issue - it's another story if you want to use animated textures.

Autor:  Stucuk [ Mo Okt 04, 2004 14:51 ]
Betreff des Beitrags: 

Iv made a test application, unfortunatly the code seems to have quite a few bugs, Image is always green and black lines going down the screen, also on frame 15(or 14) theres accessviolations poping up.

For simplisity the image is rendered to a bitmap and sent to a Timage(no opengl used)

Note: iv been using WolfIntro.roq

Dateianhänge:
ROQ Test.zip [8.42 KiB]
333-mal heruntergeladen

Autor:  Stucuk [ Fr Dez 17, 2004 01:08 ]
Betreff des Beitrags: 

The following is the delphi type definitions:
Code:
  1.  
  2. type
  3. Proq_cell = ^roq_cell;
  4. roq_cell = record
  5.  y0,y1,y2,y3,u,v : Byte;
  6. end;
  7.  
  8. type
  9. Proq_qcell = ^roq_qcell;
  10. roq_qcell = record
  11. idx : array [0..3] of integer;
  12. end;
  13.  
  14. Type
  15. PFile = ^File;
  16.  
  17. type
  18. TArrayByte = array of Byte;
  19.  
  20. type
  21. Proq_info = ^Troq_info;
  22. Troq_info = record
  23.   FP : File;
  24.   Buf_Size : Integer;
  25.   Buf : TArrayByte;
  26.   cells : array [0..255] of roq_cell;
  27.   qcells : array [0..255] of roq_qcell;
  28.   snd_sqr_arr : array [0..259] of Shortint;
  29.   roq_start, aud_pos, vid_pos : Longint;
  30.   Frame_offset : array of Longint;
  31.   num_frames,num_audio_bytes : longword;
  32.   width, height, frame_num, audio_channels : integer;
  33.   y,u,v : array [0..1] of TArrayByte;
  34.   stream_length : longint;
  35.   audio_buf_size, audio_size : integer;
  36.   audio : array of Byte;
  37. end;
  38.  


My question is does the following look like correct convertions based on the type convertion above

Code:
  1. static void apply_vector_2x2(roq_info *ri, int x, int y, roq_cell *cell)
  2. {
  3. unsigned char *yptr;
  4.  
  5.     yptr = ri->y[0] + (y * ri->width) + x;
  6.     *yptr++ = cell->y0;
  7.     *yptr++ = cell->y1;
  8.     yptr += (ri->width - 2);
  9.     *yptr++ = cell->y2;
  10.     *yptr++ = cell->y3;
  11.     ri->u[0][(y/2) * (ri->width/2) + x/2] = cell->u;
  12.     ri->v[0][(y/2) * (ri->width/2) + x/2] = cell->v;
  13. }
  14.  

Code:
  1.  
  2. procedure apply_vector_2x2(var ri:troq_info; x, y: integer; var cell:roq_cell);
  3. var
  4.    p : integer;
  5. begin
  6.    p := (y * ri.width) + x;
  7.    ri.y[0][p] := cell.y0;
  8.    inc(p);
  9.    ri.y[0][p] := cell.y1;
  10.    inc(p);
  11.    p := p + (ri.width - 2);
  12.    ri.y[0][p] := cell.y2;
  13.    inc(p);
  14.    ri.y[0][p] := cell.y3;
  15.    inc(p);
  16.    ri.u[0][(y div 2) * (ri.width div 2) + (x div 2)] := cell.u;
  17.    ri.v[0][(y div 2) * (ri.width div 2) + (x div 2)] := cell.v;
  18. end;
  19.  


Code:
  1.  
  2. static void apply_vector_4x4(roq_info *ri, int x, int y, roq_cell *cell)
  3. {
  4. unsigned long row_inc, c_row_inc;
  5. register unsigned char y0, y1, u, v;
  6. unsigned char *yptr, *uptr, *vptr;
  7.  
  8.     yptr = ri->y[0] + (y * ri->width) + x;
  9.     uptr = ri->u[0] + (y/2) * (ri->width/2) + x/2;
  10.     vptr = ri->v[0] + (y/2) * (ri->width/2) + x/2;
  11.  
  12.     row_inc = ri->width - 4;
  13.     c_row_inc = (ri->width/2) - 2;
  14.     *yptr++ = y0 = cell->y0; *uptr++ = u = cell->u; *vptr++ = v = cell->v;
  15.     *yptr++ = y0;
  16.     *yptr++ = y1 = cell->y1; *uptr++ = u; *vptr++ = v;
  17.     *yptr++ = y1;
  18.  
  19.     yptr += row_inc;
  20.  
  21.     *yptr++ = y0;
  22.     *yptr++ = y0;
  23.     *yptr++ = y1;
  24.     *yptr++ = y1;
  25.  
  26.     yptr += row_inc; uptr += c_row_inc; vptr += c_row_inc;
  27.  
  28.     *yptr++ = y0 = cell->y2; *uptr++ = u; *vptr++ = v;
  29.     *yptr++ = y0;
  30.     *yptr++ = y1 = cell->y3; *uptr++ = u; *vptr++ = v;
  31.     *yptr++ = y1;
  32.  
  33.     yptr += row_inc;
  34.  
  35.     *yptr++ = y0;
  36.     *yptr++ = y0;
  37.     *yptr++ = y1;
  38.     *yptr++ = y1;
  39. }
  40.  

Code:
  1.  
  2. procedure apply_vector_4x4(var ri:troq_info; x, y: integer; var cell:roq_cell);
  3. var
  4. p,p2,p3 : integer;
  5. row_inc, c_row_inc : longint;
  6. y0, y1, u, v : byte;
  7. begin
  8.     P  := (y * ri.width) + x;
  9.     P2 := (y div 2) * (ri.width div 2) + x div 2;
  10.     P3 := (y div 2) * (ri.width div 2) + x div 2;
  11.  
  12.     row_inc   := ri.width - 4;
  13.     c_row_inc := (ri.width div 2) - 2;
  14.  
  15.         y0 := cell.y0;
  16.         y1 := cell.y1;
  17.         v := cell.v;
  18.         u := cell.u;
  19.  
  20.         ri.y[0][p] := y0;
  21.         Inc(p);
  22.         ri.y[0][p] := y0;
  23.         Inc(p);
  24.  
  25.         ri.y[0][p] := y1;
  26.         Inc(p);
  27.         ri.y[0][p] := y1;
  28.         Inc(p);
  29.  
  30.         p := p + row_inc;
  31.  
  32.         ri.y[0][p] := y0;
  33.         Inc(p);
  34.         ri.y[0][p] := y0;
  35.         Inc(p);
  36.         ri.y[0][p] := y1;
  37.         Inc(p);
  38.         ri.y[0][p] := y1;
  39.         Inc(p);
  40.  
  41.         p := p + row_inc;
  42.  
  43.         y0 := cell.y2;
  44.         y1 := cell.y3;
  45.         ri.y[0][p] := y0;
  46.         Inc(p);
  47.         ri.y[0][p] := y0;
  48.         Inc(p);
  49.         ri.y[0][p] := y1;
  50.         Inc(p);
  51.         ri.y[0][p] := y1;
  52.         Inc(p);
  53.  
  54.         p := p + row_inc;
  55.  
  56.         ri.y[0][p] := y0;
  57.         Inc(p);
  58.         ri.y[0][p] := y0;
  59.         Inc(p);
  60.         ri.y[0][p] := y1;
  61.         Inc(p);
  62.         ri.y[0][p] := y1;
  63.         Inc(p);
  64.  
  65.         u := cell.u;
  66.         v := cell.v;
  67.  
  68.         ri.u[0][p2] := u;
  69.         Inc(p2);
  70.         ri.u[0][p2] := u;
  71.         Inc(p2);
  72.  
  73.         p2 := p2 + c_row_inc;
  74.  
  75.         ri.u[0][p2] := u;
  76.         Inc(p2);
  77.         ri.u[0][p2] := u;
  78.         Inc(p2);
  79.  
  80.         ri.v[0][p3] := v;
  81.         Inc(p3);
  82.         ri.v[0][p3] := v;
  83.         Inc(p3);
  84.  
  85.         p3 := p3 + c_row_inc;
  86.  
  87.         ri.v[0][p3] := v;
  88.         Inc(p3);
  89.         ri.v[0][p3] := v;
  90.         Inc(p3);
  91. end;
  92.  


Code:
  1.  
  2. static void apply_motion_4x4(roq_info *ri, int x, int y, unsigned char mv, char mean_x, char mean_y)
  3. {
  4. int i, mx, my;
  5. unsigned char *pa, *pb;
  6.  
  7.     mx = x + 8 - (mv >> 4) - mean_x;
  8.     my = y + 8 - (mv & 0xf) - mean_y;
  9.  
  10.     pa = ri->y[0] + (y * ri->width) + x;
  11.     pb = ri->y[1] + (my * ri->width) + mx;
  12.     for(i = 0; i < 4; i++)
  13.         {
  14.         pa[0] = pb[0];
  15.         pa[1] = pb[1];
  16.         pa[2] = pb[2];
  17.         pa[3] = pb[3];
  18.         pa += ri->width;
  19.         pb += ri->width;
  20.         }
  21.  
  22.     pa = ri->u[0] + (y/2) * (ri->width/2) + x/2;
  23.     pb = ri->u[1] + (my/2) * (ri->width/2) + (mx + 1)/2;
  24.     for(i = 0; i < 2; i++)
  25.         {
  26.         pa[0] = pb[0];
  27.         pa[1] = pb[1];
  28.         pa += ri->width/2;
  29.         pb += ri->width/2;
  30.         }
  31.  
  32.     pa = ri->v[0] + (y/2) * (ri->width/2) + x/2;
  33.     pb = ri->v[1] + (my/2) * (ri->width/2) + (mx + 1)/2;
  34.     for(i = 0; i < 2; i++)
  35.         {
  36.         pa[0] = pb[0];
  37.         pa[1] = pb[1];
  38.         pa += ri->width/2;
  39.         pb += ri->width/2;
  40.         }
  41. }
  42.  

Code:
  1.  
  2. procedure apply_motion_4x4(var ri:troq_info; x, y: integer; mv,mean_x,mean_y : byte);
  3. var
  4. i,mx,my : integer;
  5. pa,pb : integer;
  6. begin
  7.         mx := x + 8 - (mv shr 4) - mean_x;
  8.     my := y + 8 - (mv and $f) - mean_y;
  9.  
  10.         pa  := (y * ri.width) + x; //ri.y[0]
  11.         pb := (my * ri.width) + mx; //ri.y[1]
  12.     for i := 0 to 3 do
  13.     begin
  14.          ri.y[0][pa+0] := ri.y[1][pb+0];
  15.          ri.y[0][pa+1] := ri.y[1][pb+1];
  16.          ri.y[0][pa+2] := ri.y[1][pb+2];
  17.          ri.y[0][pa+3] := ri.y[1][pb+3];
  18.          pa := pa + ri.width;
  19.      pb := pb + ri.width;
  20.         end;
  21.  
  22.         pa := (y div 2) * (ri.width div 2) + x div 2;
  23.     pb := (my div 2) * (ri.width div 2) + (mx + 1) div 2;
  24.     for i := 0 to 1 do
  25.     begin
  26.      ri.u[0][pa+0] := ri.u[1][pb+0];
  27.          ri.u[0][pa+1] := ri.u[1][pb+1];
  28.      pa := pa + ri.width div 2;
  29.      pb := pb + ri.width div 2;
  30.         end;
  31.  
  32.         pa := (y div 2) * (ri.width div 2) + x div 2;
  33.     pb := (my div 2) * (ri.width div 2) + (mx + 1) div 2;
  34.     for i := 0 to 1 do
  35.     begin
  36.      ri.v[0][pa+0] := ri.v[1][pb+0];
  37.          ri.v[0][pa+1] := ri.v[1][pb+1];
  38.      pa := pa + ri.width div 2;
  39.      pb := pb + ri.width div 2;
  40.         end;
  41.  
  42. end;
  43.  


Code:
  1.  
  2. static void apply_motion_8x8(roq_info *ri, int x, int y, unsigned char mv, char mean_x, char mean_y)
  3. {
  4. int mx, my, i;
  5. unsigned char *pa, *pb;
  6.  
  7.     mx = x + 8 - (mv >> 4) - mean_x;
  8.     my = y + 8 - (mv & 0xf) - mean_y;
  9.  
  10.     pa = ri->y[0] + (y * ri->width) + x;
  11.     pb = ri->y[1] + (my * ri->width) + mx;
  12.     for(i = 0; i < 8; i++)
  13.         {
  14.         pa[0] = pb[0];
  15.         pa[1] = pb[1];
  16.         pa[2] = pb[2];
  17.         pa[3] = pb[3];
  18.         pa[4] = pb[4];
  19.         pa[5] = pb[5];
  20.         pa[6] = pb[6];
  21.         pa[7] = pb[7];
  22.         pa += ri->width;
  23.         pb += ri->width;
  24.         }
  25.  
  26.     pa = ri->u[0] + (y/2) * (ri->width/2) + x/2;
  27.     pb = ri->u[1] + (my/2) * (ri->width/2) + (mx + 1)/2;
  28.     for(i = 0; i < 4; i++)
  29.         {
  30.         pa[0] = pb[0];
  31.         pa[1] = pb[1];
  32.         pa[2] = pb[2];
  33.         pa[3] = pb[3];
  34.         pa += ri->width/2;
  35.         pb += ri->width/2;
  36.         }
  37.  
  38.     pa = ri->v[0] + (y/2) * (ri->width/2) + x/2;
  39.     pb = ri->v[1] + (my/2) * (ri->width/2) + (mx + 1)/2;
  40.     for(i = 0; i < 4; i++)
  41.         {
  42.         pa[0] = pb[0];
  43.         pa[1] = pb[1];
  44.         pa[2] = pb[2];
  45.         pa[3] = pb[3];
  46.         pa += ri->width/2;
  47.         pb += ri->width/2;
  48.         }
  49. }
  50.  

Code:
  1.  
  2. procedure apply_motion_8x8(var ri:troq_info; x, y: integer; mv,mean_x,mean_y : byte);
  3. var
  4. mx,my,i : integer;
  5. pa,pb : integer;
  6. begin
  7.  
  8.         mx := x + 8 - (mv shr 4) - mean_x;
  9.     my := y + 8 - (mv and $f) - mean_y;
  10.  
  11.     pa := (y * ri.width) + x; //ri.y[0]
  12.     pb := (my * ri.width) + mx; //ri.y[1]
  13.         for x := 0 to 7 do
  14.     begin
  15.          ri.y[0][pa+0] := ri.y[1][pb+0];
  16.          ri.y[0][pa+1] := ri.y[1][pb+1];
  17.          ri.y[0][pa+2] := ri.y[1][pb+2];
  18.          ri.y[0][pa+3] := ri.y[1][pb+3];
  19.          ri.y[0][pa+4] := ri.y[1][pb+4];
  20.          ri.y[0][pa+5] := ri.y[1][pb+5];
  21.          ri.y[0][pa+6] := ri.y[1][pb+6];
  22.          ri.y[0][pa+7] := ri.y[1][pb+7];
  23.      pa := pa + ri.width;
  24.      pb := pb + ri.width;
  25.     end;
  26.  
  27.         pa := (y div 2) * (ri.width div 2) + x div 2;
  28.     pb := (my div 2) * (ri.width div 2) + (mx + 1) div 2;
  29.         for x := 0 to 3 do
  30.     begin
  31.          ri.u[0][pa+0] := ri.u[1][pb+0];
  32.          ri.u[0][pa+1] := ri.u[1][pb+1];
  33.          ri.u[0][pa+2] := ri.u[1][pb+2];
  34.          ri.u[0][pa+3] := ri.u[1][pb+3];
  35.      pa := pa + ri.width div 2;
  36.      pb := pb + ri.width div 2;
  37.     end;
  38.  
  39.         pa := (y div 2) * (ri.width div 2) + x div 2;
  40.     pb := (my div 2) * (ri.width div 2) + (mx + 1) div 2;
  41.         for x := 0 to 3 do
  42.     begin
  43.          ri.v[0][pa+0] := ri.v[1][pb+0];
  44.          ri.v[0][pa+1] := ri.v[1][pb+1];
  45.          ri.v[0][pa+2] := ri.v[1][pb+2];
  46.          ri.v[0][pa+3] := ri.v[1][pb+3];
  47.      pa := pa + ri.width div 2;
  48.      pb := pb + ri.width div 2;
  49.     end;
  50.  
  51.  
  52. end;
  53.  

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/