aboutsummaryrefslogtreecommitdiffstats
path: root/test/ffmpeg_structs/find_avtypes
blob: c13672f505d096001c710c675054add49426f319 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

SRC_DIR='../../src'
PAS='ffmpeg_pas.pas'
C='ffmpeg_c.c'

types=$(find $SRC_DIR -path "$SRC_DIR/lib" -prune -o -name "*.pas" -print0|xargs -0 grep --files-with-match '\bavcodec\b'|xargs grep --no-filename --only-matching '\b[PT]AV\w\+'|sed 's/^P/T/'|sort|uniq)

# swscale doesn't seem to contain noteworthy types, thus it's not considered

cat >$PAS <<EOL
program ffmpeg_pas;

uses
  avcodec  in '$SRC_DIR/lib/ffmpeg-$FFMPEG_VERSION/avcodec.pas',
  avformat in '$SRC_DIR/lib/ffmpeg-$FFMPEG_VERSION/avformat.pas',
  avutil   in '$SRC_DIR/lib/ffmpeg-$FFMPEG_VERSION/avutil.pas',
  rational in '$SRC_DIR/lib/ffmpeg-$FFMPEG_VERSION/rational.pas',
  avio     in '$SRC_DIR/lib/ffmpeg-$FFMPEG_VERSION/avio.pas',
  UConfig  in '$SRC_DIR/base/UConfig',
  SysUtils;

begin
EOL

for t in $types
do
	echo "  WriteLn('$t: ' + IntToStr(SizeOf($t)));" >>$PAS
done

cat >>$PAS <<EOL
end.
EOL

cat >$C <<EOL
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/samplefmt.h"
#include "libavutil/avutil.h"
#include "libavformat/avio.h"

// workaround for enum
typedef enum AVSampleFormat AVSampleFormat;

int main(int argc, char *argv[]) {
EOL

for t in $types
do
	tt=$(echo $t|sed 's/^T//')
	echo "   printf(\"$t: %ld\\n\", sizeof($tt));" >>$C
done

cat >>$C <<EOL
   return 0;
}
EOL