[3d8280]: src / demuxers / demux_iff.c  Maximize  Restore  History

Download this file

1255 lines (1137 with data), 53.6 kB

   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
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
/*
* Copyright (C) 2004 the xine project
*
* This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* xine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
* IFF File Demuxer by Manfred Tremmel (Manfred.Tremmel@iiv.de)
* Based on the AIFF demuxer and the information of the Amiga Developer CD
*
* currently supported iff-formats:
* * 8SVX (uncompressed, deltacompression fibonacci and exponential)
* + volume rescaling is supported
* + multiple channels using CHAN and PAN Chunks are supported
* - SEQN and FADE chunks are not supported at the moment
* (I do understand what to do, but I hate the work behind it ;-) )
* - the optional data chunks ATAK and RLSE are not supported at the moment
* (no examples found and description isn't as clear as it should)
* * 16SV, the same support as 8SVX
* * ILBM (Bitmap Picturs)
* - simple pictures work, nothing more (most work is done in bitmap-decoder)
* * ANIM (Animations)
* - Animation works fine, without seeking.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
#include <xine/demux.h>
#include <xine/buffer.h>
#include "bswap.h"
#include "iff.h"
typedef struct {
demux_plugin_t demux_plugin;
xine_stream_t *stream;
fifo_buffer_t *video_fifo;
fifo_buffer_t *audio_fifo;
input_plugin_t *input;
xine_bmiheader bih;
int status;
uint32_t iff_type; /* Type of iff-file */
uint32_t iff_sub_type; /* Type of iff-sub-file */
/* Sound chunks */
Voice8Header *vhdr; /* vhdr chunk */
EGPoint *atak; /* atak chunk */
EGPoint *rlse; /* rlse chunk */
uint32_t chan_settings; /* Mono, Stereo, Left or Right Channel */
uint32_t pan_sposition; /* */
/* picture chunks */
BitMapHeader *bmhd; /* BITMAP-Header-Date (IFF-ILBM/ANIM */
ColorRegister *cmap; /* colors of the bitmap picture */
uint32_t cmap_num; /* number of the bitmap colors */
Point2D *grab; /* grab chunk */
DestMerge *dest; /* dest chunk */
SpritePrecedence sprt; /* sprt chunk */
CamgChunk *camg; /* camg chunk */
CRange crng[256]; /* color range infos for color cycling */
uint32_t crng_used; /* number of color range fields used */
CcrtChunk *ccrt; /* ccrt chunk */
DPIHeader *dpi; /* dpi chunk */
/* anim chunks */
AnimHeader *anhd; /* anhd chunk */
DPAnimChunk *dpan; /* dpan chunk */
/* some common informations */
char *title; /* Name of the stream from NAME-Tag*/
char *copyright; /* Copyright entry */
char *author; /* author entry */
char *annotations; /* comment of the author, maybe authoring tool */
char *version; /* version information of the file */
char *text; /* anny other text information */
/* audio information */
unsigned int audio_type;
unsigned int audio_frames;
unsigned int audio_bits;
unsigned int audio_channels;
unsigned int audio_block_align;
unsigned int audio_bytes_per_second;
unsigned char *audio_interleave_buffer;
uint32_t audio_interleave_buffer_size;
unsigned char *audio_read_buffer;
uint32_t audio_read_buffer_size;
int audio_buffer_filled;
uint32_t audio_volume_left;
uint32_t audio_volume_right;
uint32_t audio_position;
int audio_compression_factor;
/* picture information */
int video_send_palette;
unsigned int video_type;
int64_t video_pts;
int64_t video_pts_inc;
unsigned int running_time;
off_t data_start;
off_t data_size;
int seek_flag; /* this is set when a seek just occurred */
} demux_iff_t;
typedef struct {
demux_class_t demux_class;
} demux_iff_class_t;
/* Decode delta encoded data from n byte source
* buffer into double as long dest buffer, given initial data
* value x. The value x is also returned for incrementally
* decompression. With different decoding tables you can use
* different decoding deltas
*/
static int8_t delta_decode_block(const int8_t *source, int32_t n, int8_t *dest, int8_t x, const int8_t *table) {
int32_t i;
int lim = n * 2;
for (i=0; i < lim; i++) {
/* Decode a data nibble, high nibble then low nibble */
x += (i & 1) ?
table[((uint8_t)(source[i >> 1]) & 0xf)] :
table[((uint8_t)(source[i >> 1]) >> 4)];
dest[i] = x; /* store a 1 byte sample */
}
return(x);
}
/* Decode a complete delta encoded array */
static void delta_decode(int8_t *dest, const int8_t *source, int32_t n, const int8_t *table){
delta_decode_block(&source[2], n-2, dest, source[1], table);
}
/* returns 1 if the IFF file was opened successfully, 0 otherwise */
static int read_iff_chunk(demux_iff_t *this) {
unsigned char signature[IFF_SIGNATURE_SIZE];
unsigned char buffer[512];
unsigned int keep_on_reading = 1;
uint32_t junk_size;
while ( keep_on_reading == 1 ) {
if (this->input->read(this->input, signature, IFF_JUNK_SIZE) == IFF_JUNK_SIZE) {
if( signature[0] == 0 && signature[1] > 0 ) {
signature[0] = signature[1];
signature[1] = signature[2];
signature[2] = signature[3];
signature[3] = signature[4];
signature[4] = signature[5];
signature[5] = signature[6];
signature[6] = signature[7];
if (this->input->read(this->input, &signature[7], 1) != 1)
return 0;
}
junk_size = _X_BE_32(&signature[4]);
switch( _X_BE_32(&signature[0]) ) {
case IFF_CMAP_CHUNK:
case IFF_BODY_CHUNK:
case IFF_DLTA_CHUNK:
case IFF_FORM_CHUNK:
/* don't read this chunks, will be done later */
break;
default:
if ( junk_size < 512 ) {
if (this->input->read(this->input, buffer, junk_size) != junk_size)
return 0;
} else {
this->input->seek(this->input, junk_size, SEEK_SET);
buffer[0] = 0;
}
break;
}
switch( _X_BE_32(&signature[0]) ) {
case IFF_FORM_CHUNK:
if (this->input->read(this->input, buffer, 4) != 4)
return 0;
this->iff_sub_type = _X_BE_32(&buffer[0]);
break;
case IFF_VHDR_CHUNK:
if( this->vhdr == NULL )
this->vhdr = (Voice8Header *)xine_xmalloc(sizeof(Voice8Header));
this->vhdr->oneShotHiSamples = _X_BE_32(&buffer[0]);
this->vhdr->repeatHiSamples = _X_BE_32(&buffer[4]);
this->vhdr->samplesPerHiCycle = _X_BE_32(&buffer[8]);
this->vhdr->samplesPerSec = _X_BE_16(&buffer[12]);
this->vhdr->ctOctave = buffer[14];
this->vhdr->sCompression = buffer[15];
this->audio_channels = 1;
this->chan_settings = MONO;
switch( this->vhdr->sCompression ) {
case SND_COMPRESSION_NONE: /* uncompressed */
case SND_COMPRESSION_FIBONACCI: /* Fibonacci */
case SND_COMPRESSION_EXPONENTIAL: /* Exponential*/
this->audio_block_align = PCM_BLOCK_ALIGN;
this->audio_type = BUF_AUDIO_LPCM_BE;
break;
default: /* unknown codec */
xine_log(this->stream->xine, XINE_LOG_MSG,
_("iff-8svx/16sv: unknown compression: %d\n"),
this->vhdr->sCompression);
return 0;
break;
}
this->vhdr->volume = _X_BE_32(&buffer[16]);
if (this->vhdr->volume > max_volume)
this->vhdr->volume = max_volume;
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->oneShotHiSamples %d\n",
this->vhdr->oneShotHiSamples);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->repeatHiSamples %d\n",
this->vhdr->repeatHiSamples);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->samplesPerHiCycle %d\n",
this->vhdr->samplesPerHiCycle);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->samplesPerSec %d\n",
this->vhdr->samplesPerSec);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->ctOctave %d\n",
this->vhdr->ctOctave);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->sCompression %d\n",
this->vhdr->sCompression);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "vhdr->volume %d\n",
this->vhdr->volume);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "chan_settings %d\n",
this->chan_settings);
break;
case IFF_NAME_CHUNK:
if (this->title == NULL)
this->title = strndup( (const char *)buffer, (size_t)junk_size);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "title %s\n",
this->title);
break;
case IFF_COPY_CHUNK:
if (this->copyright == NULL)
this->copyright = strndup( (const char *)buffer, (size_t)junk_size);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "copyright %s\n",
this->copyright);
break;
case IFF_AUTH_CHUNK:
if (this->author == NULL)
this->author = strndup( (const char *)buffer, (size_t)junk_size);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "author %s\n",
this->author);
break;
case IFF_ANNO_CHUNK:
if (this->annotations == NULL)
this->annotations = strndup( (const char *)buffer, (size_t)junk_size);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "annotations %s\n",
this->annotations);
break;
case IFF_FVER_CHUNK:
if (this->version == NULL)
this->version = strndup( (const char *)buffer, (size_t)junk_size);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "version %s\n",
this->version);
break;
case IFF_TEXT_CHUNK:
if (this->text == NULL)
this->text = strndup( (const char *)buffer, (size_t)junk_size);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "text %s\n",
this->text);
break;
case IFF_ATAK_CHUNK:
/* not yet implemented */
break;
case IFF_RLSE_CHUNK:
/* not yet implemented */
break;
case IFF_CHAN_CHUNK:
this->chan_settings = _X_BE_32(&buffer[0]);
switch( this->chan_settings ) {
case STEREO:
this->audio_volume_left = this->vhdr->volume;
this->audio_volume_right = this->vhdr->volume;
this->audio_channels = 2;
break;
case LEFT:
this->audio_volume_left = this->vhdr->volume;
this->audio_volume_right = 0;
this->audio_channels = 2;
break;
case RIGHT:
this->audio_volume_left = 0;
this->audio_volume_right = this->vhdr->volume;
this->audio_channels = 2;
break;
default:
this->chan_settings = MONO;
this->audio_channels = 1;
break;
}
break;
case IFF_PAN_CHUNK:
this->chan_settings = PAN;
this->pan_sposition = _X_BE_32(&buffer[0]);
this->audio_channels = 2;
this->audio_volume_left = this->vhdr->volume / (max_volume / this->pan_sposition);
this->audio_volume_right = this->vhdr->volume - this->audio_volume_left;
break;
case IFF_BMHD_CHUNK:
if( this->bmhd == NULL )
this->bmhd = (BitMapHeader *)xine_xmalloc(sizeof(BitMapHeader));
this->bmhd->w = _X_BE_16(&buffer[0]);
this->bmhd->h = _X_BE_16(&buffer[2]);
this->bmhd->x = _X_BE_16(&buffer[4]);
this->bmhd->y = _X_BE_16(&buffer[6]);
this->bmhd->nplanes = buffer[8];
this->bmhd->masking = buffer[9];
this->bmhd->compression = buffer[10];
this->bmhd->pad1 = buffer[11];
this->bmhd->transparentColor = _X_BE_16(&buffer[12]);
this->bmhd->xaspect = buffer[14];
this->bmhd->yaspect = buffer[15];
this->bmhd->pagewidth = _X_BE_16(&buffer[16]);
this->bmhd->pageheight = _X_BE_16(&buffer[18]);
if (this->bmhd->w > 0)
this->bih.biWidth = this->bmhd->w;
else
this->bih.biWidth = this->bmhd->pagewidth;
if (this->bmhd->h > 0)
this->bih.biHeight = this->bmhd->h;
else
this->bih.biHeight = this->bmhd->pageheight;
this->bih.biPlanes = this->bmhd->nplanes;
this->bih.biBitCount = this->bmhd->nplanes;
switch( this->bmhd->compression ) {
case PIC_COMPRESSION_NONE: /* uncompressed */
this->video_type = BUF_VIDEO_BITPLANE;
break;
case PIC_COMPRESSION_BYTERUN1:
this->video_type = BUF_VIDEO_BITPLANE_BR1;
break;
default:
xine_log(this->stream->xine, XINE_LOG_MSG,
_("iff-ilbm: unknown compression: %d\n"),
this->bmhd->compression);
return 0;
break;
}
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->w %d\n",
this->bmhd->w);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->h %d\n",
this->bmhd->h);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->x %d\n",
this->bmhd->x);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->y %d\n",
this->bmhd->y);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->nplanes %d\n",
this->bmhd->nplanes);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->masking %d\n",
this->bmhd->masking);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->compression %d\n",
this->bmhd->compression);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->pad1 %d\n",
this->bmhd->pad1);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->transparentColor %d\n",
this->bmhd->transparentColor);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->xaspect %d\n",
this->bmhd->xaspect);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->yaspect %d\n",
this->bmhd->yaspect);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->pagewidth %d\n",
this->bmhd->pagewidth);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "bmhd->pageheight %d\n",
this->bmhd->pageheight);
break;
case IFF_CMAP_CHUNK:
/* every color contains red, green and blue componente using 8Bit */
this->cmap_num = junk_size / PIC_SIZE_OF_COLOR_REGISTER;
this->cmap = (ColorRegister *)xine_xmalloc(junk_size);
this->video_send_palette = 1;
if (!this->cmap || this->input->read(this->input, (char *)this->cmap, junk_size) != junk_size)
return 0;
break;
case IFF_GRAB_CHUNK:
if( this->grab == NULL )
this->grab = (Point2D *)xine_xmalloc(sizeof(Point2D));
this->grab->x = _X_BE_16(&buffer[0]);
this->grab->y = _X_BE_16(&buffer[2]);
break;
case IFF_DEST_CHUNK:
if( this->dest == NULL )
this->dest = (DestMerge *)xine_xmalloc(sizeof(DestMerge));
this->dest->depth = buffer[0];
this->dest->pad1 = buffer[1];
this->dest->plane_pick = _X_BE_16(&buffer[2]);
this->dest->plane_onoff = _X_BE_16(&buffer[4]);
this->dest->plane_mask = _X_BE_16(&buffer[6]);
break;
case IFF_SPRT_CHUNK:
this->sprt = _X_BE_16(&buffer[0]);
break;
case IFF_CAMG_CHUNK:
if( this->camg == NULL )
this->camg = (CamgChunk *)xine_xmalloc(sizeof(CamgChunk));
this->camg->view_modes = _X_BE_32(&buffer[0]);
this->bih.biCompression = this->camg->view_modes;
if( this->camg->view_modes & CAMG_PAL &&
this->video_pts_inc == 4500 )
this->video_pts_inc = 5400;
break;
case IFF_CRNG_CHUNK:
if (this->crng_used < 256) {
this->crng[this->crng_used].pad1 = _X_BE_16(&buffer[0]);
this->crng[this->crng_used].rate = _X_BE_16(&buffer[2]);
this->crng[this->crng_used].active = _X_BE_16(&buffer[4]);
this->crng[this->crng_used].low = buffer[6];
this->crng[this->crng_used].high = buffer[7];
this->crng_used++;
}
break;
case IFF_CCRT_CHUNK:
if( this->ccrt == NULL )
this->ccrt = (CcrtChunk *)xine_xmalloc(sizeof(CcrtChunk));
this->ccrt->direction = _X_BE_16(&buffer[0]);
this->ccrt->start = buffer[2];
this->ccrt->end = buffer[3];
this->ccrt->seconds = _X_BE_32(&buffer[4]);
this->ccrt->microseconds = _X_BE_32(&buffer[8]);
this->ccrt->pad = _X_BE_16(&buffer[12]);
break;
case IFF_DPI_CHUNK:
if( this->dpi == NULL )
this->dpi = (DPIHeader *)xine_xmalloc(sizeof(DPIHeader));
this->dpi->x = _X_BE_16(&buffer[0]);
this->dpi->y = _X_BE_16(&buffer[0]);
break;
case IFF_ANHD_CHUNK:
if( this->anhd == NULL )
this->anhd = (AnimHeader *)xine_xmalloc(sizeof(AnimHeader));
this->anhd->operation = buffer[0];
this->anhd->mask = buffer[1];
this->anhd->w = _X_BE_16(&buffer[2]);
this->anhd->h = _X_BE_16(&buffer[4]);
this->anhd->x = _X_BE_16(&buffer[6]);
this->anhd->y = _X_BE_16(&buffer[8]);
this->anhd->abs_time = _X_BE_32(&buffer[10]);
this->anhd->rel_time = _X_BE_32(&buffer[14]);
this->anhd->interleave = buffer[18];
this->anhd->pad0 = buffer[19];
this->anhd->bits = _X_BE_32(&buffer[20]);
/* Using rel_time deaktivated, seems to be broken in most animations */
/*if( this->dpan == NULL )
this->video_pts += this->video_pts_inc *
((this->anhd->rel_time > 0) ? this->anhd->rel_time : 1);
else*/
this->video_pts += this->video_pts_inc;
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->operation %d\n",
this->anhd->operation);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->mask %d\n",
this->anhd->mask);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->w %d\n",
this->anhd->w);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->h %d\n",
this->anhd->h);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->x %d\n",
this->anhd->x);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->y %d\n",
this->anhd->y);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->abs_time %d\n",
this->anhd->abs_time);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->rel_time %d\n",
this->anhd->rel_time);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->interleave %d\n",
this->anhd->interleave);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "anhd->bits %d\n",
this->anhd->bits);
break;
case IFF_DPAN_CHUNK:
if( this->dpan == NULL )
this->dpan = (DPAnimChunk *)xine_xmalloc(sizeof(DPAnimChunk));
this->dpan->version = _X_BE_16(&buffer[0]);
this->dpan->nframes = _X_BE_16(&buffer[2]);
this->dpan->fps = buffer[4];
this->dpan->unused1 = buffer[5];
this->dpan->unused2 = buffer[6];
this->dpan->unused3 = buffer[7];
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "dpan->version %d\n",
this->dpan->version);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "dpan->nframes %d\n",
this->dpan->nframes);
xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "dpan->fps %d\n",
this->dpan->fps);
break;
case IFF_DPPS_CHUNK:
/* DPPS contains DeluxePaint specific information, no documentation available */
break;
case IFF_JUNK_CHUNK:
/* JUNK contains garbage and should be ignored */
break;
case IFF_BODY_CHUNK:
case IFF_DLTA_CHUNK:
this->data_start = this->input->get_current_pos(this->input);
this->data_size = junk_size;
switch( this->iff_type )
{
case IFF_8SVX_CHUNK:
case IFF_16SV_CHUNK:
if( this->vhdr->sCompression > SND_COMPRESSION_NONE ) {
this->audio_interleave_buffer_size = this->data_size * 2;
this->audio_read_buffer_size = this->data_size;
} else {
this->audio_interleave_buffer_size = this->data_size;
this->audio_read_buffer_size = 0;
}
if( this->chan_settings == MONO)
this->audio_volume_left = this->vhdr->volume;
this->audio_bytes_per_second = this->audio_channels *
(this->audio_bits / 8) *
this->vhdr->samplesPerSec;
this->running_time = ((this->vhdr->oneShotHiSamples +
this->vhdr->repeatHiSamples) *
1000 / this->vhdr->samplesPerSec) /
this->audio_channels;
break;
case IFF_ILBM_CHUNK:
this->bih.biSize = this->data_size;
this->bih.biSizeImage = this->data_size;
break;
case IFF_ANIM_CHUNK:
this->bih.biSize = this->data_size;
this->bih.biSizeImage = this->data_size;
if( this->dpan ) {
if( this->dpan->fps > 0 && this->dpan->fps <= 60)
this->video_pts_inc = 90000 / this->dpan->fps;
this->running_time = (this->video_pts_inc * this->dpan->nframes) / 90;
}
break;
default:
break;
}
keep_on_reading = 0;
break;
default:
signature[4] = 0;
xine_log(this->stream->xine, XINE_LOG_MSG, _("iff: unknown Chunk: %s\n"), signature);
break;
}
} else
return 0;
}
return 1;
}
/* returns 1 if the IFF file was opened successfully, 0 otherwise */
static int open_iff_file(demux_iff_t *this) {
unsigned char signature[IFF_SIGNATURE_SIZE];
if (_x_demux_read_header(this->input, signature, IFF_SIGNATURE_SIZE) != IFF_SIGNATURE_SIZE)
return 0;
this->title = NULL;
this->copyright = NULL;
this->author = NULL;
this->annotations = NULL;
this->version = NULL;
this->text = NULL;
this->vhdr = NULL;
this->atak = NULL;
this->rlse = NULL;
this->chan_settings = 0;
this->audio_type = 0;
this->audio_frames = 0;
this->audio_bits = 0;
this->audio_channels = 0;
this->audio_block_align = 0;
this->audio_bytes_per_second = 0;
this->running_time = 0;
this->data_start = 0;
this->data_size = 0;
this->seek_flag = 0;
this->audio_interleave_buffer = 0;
this->audio_interleave_buffer_size = 0;
this->audio_read_buffer = 0;
this->audio_read_buffer_size = 0;
this->audio_buffer_filled = 0;
this->audio_compression_factor = 1;
this->audio_position = 0;
this->bmhd = NULL;
this->cmap = NULL;
this->cmap_num = 0;
this->grab = NULL;
this->dest = NULL;
this->sprt = 0;
this->camg = NULL;
this->crng_used = 0;
this->ccrt = NULL;
this->dpi = NULL;
this->anhd = NULL;
this->dpan = NULL;
this->iff_type = _X_BE_32(&signature[8]);
this->iff_sub_type = this->iff_type;
this->video_type = 0;
this->video_pts = 0;
this->video_pts_inc = 0;
this->video_send_palette = 0;
this->bih.biSize = 0;
this->bih.biWidth = 0;
this->bih.biHeight = 0;
this->bih.biPlanes = 0;
this->bih.biBitCount = 0;
this->bih.biCompression = 0;
this->bih.biSizeImage = 0;
this->bih.biXPelsPerMeter = 0;
this->bih.biYPelsPerMeter = 0;
this->bih.biClrUsed = 0;
this->bih.biClrImportant = 0;
/* check the signature */
if (_X_BE_32(&signature[0]) == IFF_FORM_CHUNK)
{
switch( this->iff_type )
{
case IFF_8SVX_CHUNK:
this->audio_bits = 8;
break;
case IFF_16SV_CHUNK:
this->audio_bits = 16;
break;
case IFF_ILBM_CHUNK:
this->video_pts_inc = 10000000;
break;
case IFF_ANIM_CHUNK:
this->video_pts_inc = 4500;
break;
default:
return 0;
break;
}
} else
return 0;
/* file is qualified; skip over the header bytes in the stream */
this->input->seek(this->input, IFF_SIGNATURE_SIZE, SEEK_SET);
return read_iff_chunk( this );
}
static int demux_iff_send_chunk(demux_plugin_t *this_gen) {
demux_iff_t *this = (demux_iff_t *) this_gen;
buf_element_t *buf = NULL;
unsigned int remaining_sample_bytes = 0;
off_t current_file_pos;
int16_t *pointer16_from;
int16_t *pointer16_to;
int16_t zw_16;
int32_t input_length;
int64_t zw_pts;
int64_t zw_rescale;
int j, k;
int first_buf;
int interleave_index;
int size;
/* when audio is available and it's a stereo, left or right stream
* at iff 8svx, the complete left stream at the beginning and the
* right channel at the end of the stream. Both have to be inter-
* leaved, the same way as in the sega film demuxer. I've copied
* it out there
*/
switch( this->iff_sub_type ) {
case IFF_8SVX_CHUNK:
case IFF_16SV_CHUNK:
/* just load data chunks from wherever the stream happens to be
* pointing; issue a DEMUX_FINISHED status if EOF is reached */
current_file_pos = this->audio_position;
/* load the whole chunk into the buffer */
if (this->audio_buffer_filled == 0) {
if (this->audio_interleave_buffer_size > 0)
{
this->audio_interleave_buffer =
xine_xmalloc(this->audio_interleave_buffer_size);
if (!this->audio_interleave_buffer)
return this->status = DEMUX_FINISHED;
}
if (this->audio_read_buffer_size > 0)
{
this->audio_read_buffer =
xine_xmalloc(this->audio_read_buffer_size);
if (!this->audio_read_buffer)
return this->status = DEMUX_FINISHED;
}
if (this->audio_read_buffer) {
if (this->input->read(this->input, this->audio_read_buffer,
this->data_size) != this->data_size) {
this->status = DEMUX_FINISHED;
return this->status;
}
switch( this->vhdr->sCompression ) {
case SND_COMPRESSION_FIBONACCI:
if (this->chan_settings == STEREO) {
delta_decode((int8_t *)(this->audio_interleave_buffer),
(int8_t *)(this->audio_read_buffer),
(this->data_size/2),
fibonacci);
delta_decode((int8_t *)(&(this->audio_interleave_buffer[this->data_size])),
(int8_t *)(&(this->audio_read_buffer[(this->data_size/2)])),
(this->data_size/2),
fibonacci);
} else
delta_decode((int8_t *)(this->audio_interleave_buffer),
(int8_t *)(this->audio_read_buffer),
this->data_size,
fibonacci);
this->audio_compression_factor = 2;
break;
case SND_COMPRESSION_EXPONENTIAL:
if (this->chan_settings == STEREO) {
delta_decode((int8_t *)(this->audio_interleave_buffer),
(int8_t *)(this->audio_read_buffer),
(this->data_size/2),
exponential);
delta_decode((int8_t *)(&(this->audio_interleave_buffer[this->data_size])),
(int8_t *)(&(this->audio_read_buffer[(this->data_size/2)])),
(this->data_size/2),
exponential);
} else
delta_decode((int8_t *)(this->audio_interleave_buffer),
(int8_t *)(this->audio_read_buffer),
this->data_size,
exponential);
this->audio_compression_factor = 2;
break;
default:
break;
}
free( this->audio_read_buffer );
this->audio_read_buffer = NULL;
} else {
if (this->input->read(this->input, this->audio_interleave_buffer,
this->data_size) != this->data_size) {
this->status = DEMUX_FINISHED;
return this->status;
}
}
this->audio_buffer_filled = 1;
}
/* proceed to de-interleave into individual buffers */
if (this->chan_settings == STEREO) {
remaining_sample_bytes = ((this->data_size - current_file_pos) *
this->audio_compression_factor) / 2;
interleave_index = (current_file_pos *
this->audio_compression_factor) / 2;
} else {
remaining_sample_bytes = ((this->data_size - current_file_pos) *
this->audio_compression_factor);
interleave_index = (current_file_pos *
this->audio_compression_factor);
}
first_buf = 1;
zw_pts = current_file_pos;
if (this->chan_settings == STEREO)
input_length = this->data_size *
this->audio_compression_factor;
else
input_length = this->data_size *
this->audio_compression_factor *
this->audio_channels;
while (remaining_sample_bytes) {
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = this->audio_type;
if( input_length )
buf->extra_info->input_normpos = (int)((double)zw_pts * 65535 / input_length);
buf->pts = zw_pts * 90000 / this->audio_bytes_per_second;
buf->extra_info->input_time = buf->pts / 90;
if (remaining_sample_bytes > buf->max_size / this->audio_channels)
buf->size = buf->max_size;
else
buf->size = remaining_sample_bytes * this->audio_channels;
remaining_sample_bytes -= buf->size / this->audio_channels;
zw_pts += buf->size;
/* 16 bit sound */
if (this->audio_bits == 16) {
pointer16_from = (int16_t *)this->audio_interleave_buffer;
pointer16_to = (int16_t *)buf->content;
if (this->chan_settings == STEREO ||
this->chan_settings == LEFT ||
this->chan_settings == PAN ||
this->chan_settings == MONO) {
if( this->audio_volume_left == max_volume ) {
for (j = 0, k = (interleave_index / 2); j < (buf->size / 2); j += this->audio_channels) {
pointer16_to[j] = pointer16_from[k++];
}
} else {
for (j = 0, k = (interleave_index / 2); j < (buf->size / 2); j += this->audio_channels) {
zw_16 = _X_BE_16(&pointer16_from[k]);
k++;
zw_rescale = zw_16;
zw_rescale *= this->audio_volume_left;
zw_rescale /= max_volume;
zw_16 = (zw_rescale>32767) ? 32767 : ((zw_rescale<-32768) ? -32768 : zw_rescale);
pointer16_to[j] = _X_BE_16(&zw_16);
}
}
} else {
for (j = 0; j < (buf->size / 2); j += this->audio_channels) {
pointer16_to[j] = 0;
}
}
if (this->chan_settings == STEREO ||
this->chan_settings == RIGHT ||
this->chan_settings == PAN) {
if (this->chan_settings == STEREO)
k = (interleave_index +
(this->data_size *
this->audio_compression_factor / 2)) / 2;
else
k = interleave_index / 2;
if( this->audio_volume_right == max_volume ) {
for (j = 1; j < (buf->size / 2); j += this->audio_channels) {
pointer16_to[j] = pointer16_from[k++];
}
} else {
for (j = 1; j < (buf->size / 2); j += this->audio_channels) {
zw_16 = _X_BE_16(&pointer16_from[k]);
k++;
zw_rescale = zw_16;
zw_rescale *= this->audio_volume_left;
zw_rescale /= max_volume;
zw_16 = (zw_rescale>32767) ? 32767 : ((zw_rescale<-32768) ? -32768 : zw_rescale);
pointer16_to[j] = _X_BE_16(&zw_16);
}
}
} else if (this->chan_settings == LEFT) {
for (j = 1; j < (buf->size / 2); j += this->audio_channels) {
pointer16_to[j] = 0;
}
}
/* 8 bit sound */
} else {
if (this->chan_settings == STEREO ||
this->chan_settings == LEFT ||
this->chan_settings == PAN ||
this->chan_settings == MONO) {
if( this->audio_volume_left == max_volume ) {
for (j = 0, k = interleave_index; j < buf->size; j += this->audio_channels) {
buf->content[j] = this->audio_interleave_buffer[k++] + 0x80;
}
} else {
for (j = 0, k = interleave_index; j < buf->size; j += this->audio_channels) {
zw_rescale = this->audio_interleave_buffer[k++];
zw_rescale *= this->audio_volume_left;
zw_rescale /= max_volume;
zw_rescale += 0x80;
buf->content[j] = (zw_rescale>255) ? 255 : ((zw_rescale<0) ? 0 : zw_rescale);
}
}
} else {
for (j = 0; j < buf->size; j += 2) {
buf->content[j] = 0;
}
}
if (this->chan_settings == STEREO ||
this->chan_settings == RIGHT ||
this->chan_settings == PAN) {
if (this->chan_settings == STEREO)
k = interleave_index +
(this->data_size *
this->audio_compression_factor / 2);
else
k = interleave_index;
if( this->audio_volume_right == max_volume ) {
for (j = 1; j < buf->size; j += this->audio_channels) {
buf->content[j] = this->audio_interleave_buffer[k++] + 0x80;
}
} else {
for (j = 1; j < buf->size; j += this->audio_channels) {
zw_rescale = this->audio_interleave_buffer[k++];
zw_rescale *= this->audio_volume_right;
zw_rescale /= max_volume;
zw_rescale += 0x80;
buf->content[j] = (zw_rescale>255) ? 255 : ((zw_rescale<0) ? 0 : zw_rescale);
}
}
} else if (this->chan_settings == LEFT) {
for (j = 1; j < buf->size; j += this->audio_channels) {
buf->content[j] = 0;
}
}
}
interleave_index += buf->size / this->audio_channels;
if (!remaining_sample_bytes)
buf->decoder_flags |= BUF_FLAG_FRAME_END;
xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
"sending audio buf with %" PRId32 " bytes, %" PRId64 " pts, %" PRId32 " duration\n",
buf->size, buf->pts, buf->decoder_info[0]);
this->audio_fifo->put(this->audio_fifo, buf);
}
break;
case IFF_ILBM_CHUNK:
/* send off the palette, if there is one */
if ( this->video_send_palette == 1 ) {
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->decoder_flags = BUF_FLAG_SPECIAL|BUF_FLAG_HEADER;
buf->decoder_info[1] = BUF_SPECIAL_PALETTE;
buf->decoder_info[2] = this->cmap_num;
buf->decoder_info_ptr[2] = this->cmap;
buf->size = 0;
buf->type = this->video_type;
this->video_fifo->put (this->video_fifo, buf);
this->video_send_palette = 0;
}
/* And now let's start with the picture */
size = this->data_size;
while (size > 0) {
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->content = buf->mem;
buf->type = this->video_type;
buf->decoder_flags = BUF_FLAG_FRAMERATE;
if( this->anhd == NULL )
buf->decoder_info[0] = 0;
else
buf->decoder_info[0] = this->video_pts_inc;
buf->decoder_info_ptr[0] = this->anhd;
if( this->input->get_length (this->input) )
buf->extra_info->input_normpos = (int)( (double) this->input->get_current_pos (this->input) *
65535 / this->input->get_length (this->input) );
buf->pts = this->video_pts;
buf->extra_info->input_time = buf->pts / 90;
if (size > buf->max_size) {
buf->size = buf->max_size;
} else {
buf->size = size;
}
size -= buf->size;
if (this->input->read(this->input, buf->content, buf->size) != buf->size) {
buf->free_buffer(buf);
this->status = DEMUX_FINISHED;
}
if (size <= 0)
{
buf->decoder_flags |= BUF_FLAG_FRAME_END;
if (this->iff_type == IFF_ILBM_CHUNK )
buf->decoder_info[1] = this->video_pts_inc; /* initial video_step */
}
this->video_fifo->put(this->video_fifo, buf);
}
break;
}
/* look for other multimedia parts */
if( read_iff_chunk( this ) )
this->status = DEMUX_OK;
else
this->status = DEMUX_FINISHED;
return this->status;
}
static void demux_iff_send_headers(demux_plugin_t *this_gen) {
demux_iff_t *this = (demux_iff_t *) this_gen;
buf_element_t *buf;
this->video_fifo = this->stream->video_fifo;
this->audio_fifo = this->stream->audio_fifo;
this->status = DEMUX_OK;
if( this->title )
_x_meta_info_set(this->stream, XINE_META_INFO_TITLE, this->title);
if( this->author )
_x_meta_info_set(this->stream, XINE_META_INFO_ARTIST, this->author);
if( this->annotations )
_x_meta_info_set(this->stream, XINE_META_INFO_COMMENT, this->annotations);
/* load stream information */
switch( this->iff_type ) {
case IFF_8SVX_CHUNK:
case IFF_16SV_CHUNK:
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 0);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS,
this->audio_channels);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE,
this->vhdr->samplesPerSec);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS,
this->audio_bits);
/* send start buffers */
_x_demux_control_start(this->stream);
/* send init info to decoders */
if (this->audio_fifo && this->audio_type) {
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = this->audio_type;
buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAME_END;
buf->decoder_info[0] = 0;
buf->decoder_info[1] = this->vhdr->samplesPerSec;
buf->decoder_info[2] = this->audio_bits;
buf->decoder_info[3] = this->audio_channels;
this->audio_fifo->put (this->audio_fifo, buf);
}
break;
case IFF_ILBM_CHUNK:
case IFF_ANIM_CHUNK:
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 0);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, this->bih.biWidth);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, this->bih.biHeight);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION,
this->video_pts_inc);
/* send start buffers */
_x_demux_control_start(this->stream);
buf = this->video_fifo->buffer_pool_alloc(this->video_fifo);
buf->type = this->video_type;
buf->size = sizeof(xine_bmiheader);
buf->decoder_flags = BUF_FLAG_HEADER|BUF_FLAG_STDHEADER|BUF_FLAG_FRAMERATE|BUF_FLAG_FRAME_END;
buf->decoder_info[0] = this->video_pts_inc; /* initial video_step */
buf->decoder_info[1] = 0;
buf->decoder_info[2] = this->bmhd->xaspect;
buf->decoder_info[3] = this->bmhd->yaspect;
memcpy(buf->content, &this->bih, sizeof(this->bih));
this->video_fifo->put(this->video_fifo, buf);
break;
default:
break;
}
}
static int demux_iff_seek (demux_plugin_t *this_gen,
off_t start_pos, int start_time, int playing) {
demux_iff_t *this = (demux_iff_t *) this_gen;
start_pos = (off_t) ( (double) start_pos / 65535 *
this->data_size );
switch( this->iff_type ) {
case IFF_8SVX_CHUNK:
case IFF_16SV_CHUNK:
this->seek_flag = 1;
this->status = DEMUX_OK;
_x_demux_flush_engine (this->stream);
/* if input is non-seekable, do not proceed with the rest of this
* seek function */
if (!INPUT_IS_SEEKABLE(this->input))
return this->status;
/* check the boundary offsets */
this->audio_position = (start_pos < 0) ? 0 :
((start_pos >= this->data_size) ?
this->data_size : start_pos);
case IFF_ILBM_CHUNK:
case IFF_ANIM_CHUNK:
/* disable seeking for ILBM and ANIM */
this->seek_flag = 0;
if( !playing ) {
this->status = DEMUX_OK;
}
break;
default:
break;
}
return this->status;
}
static void demux_iff_dispose (demux_plugin_t *this_gen) {
demux_iff_t *this = (demux_iff_t *) this_gen;
free(this->bmhd);
free(this->cmap);
free(this->grab);
free(this->dest);
free(this->camg);
free(this->ccrt);
free(this->dpi);
free(this->vhdr);
free(this->atak);
free(this->rlse);
free(this->anhd);
free(this->dpan);
free(this->title);
free(this->copyright);
free(this->author);
free(this->annotations);
free(this->version);
free(this->text);
free (this->audio_interleave_buffer);
free (this->audio_read_buffer);
this->audio_buffer_filled = 0;
free(this);
}
static int demux_iff_get_status (demux_plugin_t *this_gen) {
demux_iff_t *this = (demux_iff_t *) this_gen;
return this->status;
}
/* return the approximate length in miliseconds */
static int demux_iff_get_stream_length (demux_plugin_t *this_gen) {
demux_iff_t *this = (demux_iff_t *) this_gen;
return this->running_time;
}
static uint32_t demux_iff_get_capabilities(demux_plugin_t *this_gen){
return DEMUX_CAP_NOCAP;
}
static int demux_iff_get_optional_data(demux_plugin_t *this_gen,
void *data, int data_type){
return DEMUX_OPTIONAL_UNSUPPORTED;
}
static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *stream,
input_plugin_t *input) {
demux_iff_t *this;
this = xine_xmalloc (sizeof (demux_iff_t));
this->stream = stream;
this->input = input;
this->demux_plugin.send_headers = demux_iff_send_headers;
this->demux_plugin.send_chunk = demux_iff_send_chunk;
this->demux_plugin.seek = demux_iff_seek;
this->demux_plugin.dispose = demux_iff_dispose;
this->demux_plugin.get_status = demux_iff_get_status;
this->demux_plugin.get_stream_length = demux_iff_get_stream_length;
this->demux_plugin.get_capabilities = demux_iff_get_capabilities;
this->demux_plugin.get_optional_data = demux_iff_get_optional_data;
this->demux_plugin.demux_class = class_gen;
this->status = DEMUX_FINISHED;
switch (stream->content_detection_method) {
case METHOD_BY_MRL:
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
if (!open_iff_file(this)) {
free (this);
return NULL;
}
break;
default:
free (this);
return NULL;
}
return &this->demux_plugin;
}
static void *init_plugin (xine_t *xine, void *data) {
demux_iff_class_t *this;
this = xine_xmalloc (sizeof (demux_iff_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("IFF demux plugin");
this->demux_class.identifier = "IFF";
this->demux_class.mimetypes =
"audio/x-8svx: 8svx: IFF-8SVX Audio;"
"audio/8svx: 8svx: IFF-8SVX Audio;"
"audio/x-16sv: 16sv: IFF-16SV Audio;"
"audio/168sv: 16sv: IFF-16SV Audio;"
"image/x-ilbm: ilbm: IFF-ILBM Picture;"
"image/ilbm: ilbm: IFF-ILBM Picture;"
"video/x-anim: anim: IFF-ANIM Video;"
"video/anim: anim: IFF-ANIM Video;";
this->demux_class.extensions = "iff svx 8svx 16sv ilbm ham ham6 ham8 anim anim3 anim5 anim7 anim8";
this->demux_class.dispose = default_demux_class_dispose;
return this;
}
/*
* exported plugin catalog entry
*/
static const demuxer_info_t demux_info_iff = {
10 /* priority */
};
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
{ PLUGIN_DEMUX, 27, "iff", XINE_VERSION_CODE, &demux_info_iff, init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks