| Previous | 15994 Revisions | Next |
| r14261 Sunday 29th January, 2012 at 18:25:58 UTC by Miodrag Milanović |
|---|
| Sync with MAME r15230 excluding diimage and softlist changes (no whatsnew) |
| [src] | version.c |
| [src/emu] | audit.c device.c device.h emutempl.h machine.c machine.h mconfig.c memory.c render.h romload.c screen.c tilemap.c tilemap.h validity.c validity.h |
| [src/emu/cpu/arm7] | arm7ops.h |
| [src/emu/cpu/i386] | i386.c i386op16.c i386op32.c i386priv.h i486ops.c x87ops.c |
| [src/emu/cpu/unsp] | unspdasm.c |
| [src/emu/debug] | dvmemory.c |
| [src/emu/imagedev] | floppy.c |
| [src/emu/machine] | 6522via.c generic.c im6402.c im6402.h scsihd.c |
| [src/emu/sound] | okim6295.c samples.c |
| [src/emu/video] | pc_vga.c |
| [src/lib] | lib.mak |
| [src/lib/formats] | flopimg.c flopimg.h |
| [src/lib/libflac/include/flac] | format.h metadata.h stream_decoder.h stream_encoder.h |
| [src/lib/libflac/include/flac++] | decoder.h encoder.h metadata.h |
| [src/lib/libflac/include/private] | fixed.h float.h lpc.h window.h |
| [src/lib/libflac/libflac] | bitreader.c bitwriter.c cpu.c fixed.c float.c lpc.c md5.c metadata_iterators.c metadata_object.c stream_decoder.c stream_encoder.c stream_encoder_framing.c |
| [src/lib/libjpeg] | jcapimin.c jcarith.c jccolor.c jcdctmgr.c jchuff.c jcmainct.c jcmarker.c jcmaster.c jcparam.c jctrans.c jdapimin.c jdarith.c jdcoefct.c jdcolor.c jdct.h jddctmgr.c jdhuff.c jdinput.c jdmarker.c jdmaster.c jdmerge.c jdsample.c jerror.c jidctflt.c jidctfst.c jidctint.c jmemmgr.c jpeglib.h jpegtran.c jquant1.c jquant2.c |
| [src/lib/util] | cdrom.h chd.c tagmap.h |
| [src/mame] | mame.lst |
| [src/mame/drivers] | bnstars.c boogwing.c chihiro.c cntsteer.c cps3.c cybertnk.c dassault.c dreamwld.c eolithsp.c gberet.c konamigq.c konamigv.c multfish.c naomi.c nemesis.c neodrvr.c nexus3d.c pluto5.c pntnpuzl.c popobear.c rocnrope.c rohga.c segaorun.c sliver.c taitowlf.c triforce.c twincobr.c |
| [src/mame/includes] | boogwing.h dassault.h metro.h rohga.h |
| [src/mame/machine] | steppers.c |
| [src/mame/video] | boogwing.c dassault.c deco16ic.c decospr.c decospr.h f1gp.c konicdev.c macrossp.c mermaid.c ms32.c namcona1.c namcos2.c ppu2c0x.c ppu2c0x.h psikyo.c punchout.c rohga.c simpl156.c skyraid.c |
| [src/osd/sdl] | sdlmain.c |
| [src/tools] | chdman.c |
| r14260 | r14261 | |
|---|---|---|
| 11250 | 11250 | fcockt_10 // (c) 2003 |
| 11251 | 11251 | fcockt_11 // (c) 2003 |
| 11252 | 11252 | fcockt_12 // (c) 2003 |
| 11253 | fcockt2_3 | |
| 11254 | fcockt2_4 | |
| 11255 | fcockt2_4a | |
| 11256 | fcockt2_4b | |
| 11257 | fcockt2_4d | |
| 11258 | fcockt2_4f | |
| 11259 | fcockt2_5 | |
| 11253 | 11260 | |
| 11254 | 11261 | // Lucky Haunter |
| 11255 | 11262 | //lhaunt // (c) 2003 |
| r14260 | r14261 | |
| 16827 | 16834 | m1coro21n |
| 16828 | 16835 | m1coro21np |
| 16829 | 16836 | m1coro12n |
| 16837 | m1coro12np | |
| 16830 | 16838 | m1coro11n |
| 16831 | 16839 | m1coro11np |
| 16832 | 16840 | m1coro31 |
| r14260 | r14261 | |
|---|---|---|
| 62 | 62 | STARPOINT_48STEP_REEL, |
| 63 | 63 | 16, |
| 64 | 64 | 24, |
| 65 | 0x09,//Starpoint tech specs say that the only coil pattern guaranteed to line up the opto is this one | |
| 65 | 0x09,//Starpoint tech specs say that the only coil pattern guaranteed to line up the opto is this one | |
| 66 | 66 | 0 |
| 67 | 67 | }; |
| 68 | 68 | |
| r14260 | r14261 | |
| 90 | 90 | step[which].index_patt = intf->index_patt; /* hex value of coil pattern (0 if not needed)*/ |
| 91 | 91 | step[which].reverse = intf->reverse; |
| 92 | 92 | |
| 93 | ||
| 93 | ||
| 94 | 94 | step[which].phase = 0; |
| 95 | 95 | step[which].pattern = 0; |
| 96 | 96 | step[which].old_pattern = 0; |
| r14260 | r14261 | |
| 108 | 108 | //Dice reels are 48 step motors, but complete three full cycles between opto updates |
| 109 | 109 | step[which].max_steps = ((48*3)*2); |
| 110 | 110 | break; |
| 111 | ||
| 111 | ||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | state_save_register_item(machine, "stepper", NULL, which, step[which].index_start); |
| r14260 | r14261 | |
| 209 | 209 | int changed = 0; |
| 210 | 210 | |
| 211 | 211 | /* This code probably makes more sense if you visualise what is being emulated, namely |
| 212 | a spinning drum with two electromagnets inside. Essentially, the CPU | |
| 213 | activates a pair of windings on these magnets leads as necessary to attract and repel the drum to pull it round and | |
| 214 | display as appropriate. To attempt to visualise the rotation effect, take a look at the compass rose below, representing a side on view of the reel, | |
| 215 | the numbers indicate the phase information as used | |
| 212 | a spinning drum with two electromagnets inside. Essentially, the CPU | |
| 213 | activates a pair of windings on these magnets leads as necessary to attract and repel the drum to pull it round and | |
| 214 | display as appropriate. To attempt to visualise the rotation effect, take a look at the compass rose below, representing a side on view of the reel, | |
| 215 | the numbers indicate the phase information as used | |
| 216 | 216 | |
| 217 | 7 | |
| 218 | N | |
| 219 | 1 W E 5 | |
| 220 | S | |
| 221 | 3 | |
| 217 | 7 | |
| 218 | N | |
| 219 | 1 W E 5 | |
| 220 | S | |
| 221 | 3 | |
| 222 | 222 | |
| 223 | For sake of accuracy, we're representing all possible phases of the motor, effectively moving the motor one half step at a time, so a 48 step motor becomes | |
| 224 | 96 half steps. This is necessary because of some programs running the wiring in series with a distinct delay between the pair being completed. This causes | |
| 225 | a small movement that may trigger the optic tab. | |
| 226 | */ | |
| 223 | For sake of accuracy, we're representing all possible phases of the motor, effectively moving the motor one half step at a time, so a 48 step motor becomes | |
| 224 | 96 half steps. This is necessary because of some programs running the wiring in series with a distinct delay between the pair being completed. This causes | |
| 225 | a small movement that may trigger the optic tab. | |
| 226 | */ | |
| 227 | 227 | |
| 228 | 228 | int pos,steps=0; |
| 229 | 229 | step[which].pattern = pattern; |
| r14260 | r14261 | |
| 288 | 288 | break; |
| 289 | 289 | } |
| 290 | 290 | break; |
| 291 | ||
| 291 | ||
| 292 | 292 | case BARCREST_48STEP_REEL : |
| 293 | 293 | //Standard drive table is 1,3,2,6,4,C,8,9 |
| 294 | 294 | //this runs through the stator patterns in such a way as to drive the reel forward (downwards from the player's view) |
| r14260 | r14261 | |
| 321 | 321 | break; |
| 322 | 322 | |
| 323 | 323 | // The below values should not be used by anything sane, as they effectively ignore one stator side entirely |
| 324 | ||
| 324 | ||
| 325 | 325 | case 0x05:// 0 1 0 1 |
| 326 | 326 | { |
| 327 | 327 | if ((step[which].old_phase ==6)||(step[which].old_phase == 0)) // if the previous pattern had the drum in the northern quadrant, it will point north now |
| r14260 | r14261 | |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | break; |
| 337 | ||
| 337 | ||
| 338 | 338 | case 0x0A:// 1 0 1 0 |
| 339 | 339 | { |
| 340 | 340 | if ((step[which].old_phase ==6)||(step[which].old_phase == 4)) // if the previous pattern had the drum in the eastern quadrant, it will point east now |
| r14260 | r14261 | |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | break; |
| 350 | } | |
| 350 | } | |
| 351 | 351 | break; |
| 352 | ||
| 352 | ||
| 353 | 353 | case MPU3_48STEP_REEL : |
| 354 | 354 | /* The MPU3 interface is actually the same as the MPU4 setup, but with two active lines instead of four |
| 355 | Inverters are used so if a pin is low, the higher bit of the pair is activated, and if high the lower bit is activated. | |
| 356 | TODO:Check this, 2 and 1 could be switched over. | |
| 357 | */ | |
| 355 | Inverters are used so if a pin is low, the higher bit of the pair is activated, and if high the lower bit is activated. | |
| 356 | TODO:Check this, 2 and 1 could be switched over. | |
| 357 | */ | |
| 358 | 358 | switch (pattern) |
| 359 | 359 | { |
| 360 | 360 | // Yellow(2) Black(1) Orange(!2) Brown(!1) |
| r14260 | r14261 | |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | steps = step[which].old_phase - step[which].phase; |
| 378 | ||
| 378 | ||
| 379 | 379 | if (steps < -4) |
| 380 | 380 | { |
| 381 | 381 | steps = steps +8; |
| r14260 | r14261 | |
| 384 | 384 | { |
| 385 | 385 | steps = steps -8; |
| 386 | 386 | } |
| 387 | ||
| 387 | ||
| 388 | 388 | step[which].old_phase = step[which].phase; |
| 389 | 389 | step[which].old_pattern = step[which].pattern; |
| 390 | 390 |
| r14260 | r14261 | |
|---|---|---|
| 54 | 54 | int m_has_zoom; |
| 55 | 55 | int m_sprite_xoffs; |
| 56 | 56 | int m_sprite_yoffs; |
| 57 | ||
| 57 | ||
| 58 | 58 | UINT8 * m_expanded_gfx1; |
| 59 | 59 | |
| 60 | 60 | /* blitter */ |
| r14260 | r14261 | |
|---|---|---|
| 45 | 45 | WRITE16_HANDLER( rohga_buffer_spriteram16_w ); |
| 46 | 46 | |
| 47 | 47 | VIDEO_START( rohga ); |
| 48 | VIDEO_START( schmeisr ); | |
| 49 | VIDEO_START( wizdfire ); | |
| 48 | 50 | |
| 51 | ||
| 49 | 52 | SCREEN_UPDATE_IND16( rohga ); |
| 50 | SCREEN_UPDATE_IND16( schmeisr ); | |
| 51 | 53 | SCREEN_UPDATE_RGB32( wizdfire ); |
| 52 | 54 | SCREEN_UPDATE_RGB32( nitrobal ); |
| 55 | ||
| 56 | UINT16 rohga_pri_callback(UINT16 x); | |
| 57 | UINT16 schmeisr_col_callback(UINT16 x); | |
| 58 | UINT16 rohga_col_callback(UINT16 x); |
| r14260 | r14261 | |
|---|---|---|
| 42 | 42 | |
| 43 | 43 | /*----------- defined in video/dassault.c -----------*/ |
| 44 | 44 | |
| 45 | VIDEO_START(dassault); | |
| 45 | 46 | SCREEN_UPDATE_RGB32( dassault ); |
| r14260 | r14261 | |
|---|---|---|
| 40 | 40 | |
| 41 | 41 | /*----------- defined in video/boogwing.c -----------*/ |
| 42 | 42 | |
| 43 | VIDEO_START( boogwing ); | |
| 43 | 44 | SCREEN_UPDATE_RGB32( boogwing ); |
| 44 | 45 |
| r14260 | r14261 | |
|---|---|---|
| 17 | 17 | state->m_pf2_rowscroll = auto_alloc_array_clear(machine, UINT16, 0x800/2); |
| 18 | 18 | state->m_spriteram = auto_alloc_array_clear(machine, UINT16, 0x2000/2); |
| 19 | 19 | machine.generic.paletteram.u16 = auto_alloc_array_clear(machine, UINT16, 0x1000/2); |
| 20 | ||
| 20 | ||
| 21 | 21 | memset(state->m_spriteram, 0xff, 0x2000); |
| 22 | 22 | |
| 23 | 23 | /* and register the allocated ram so that save states still work */ |
| r14260 | r14261 | |
|---|---|---|
| 240 | 240 | |
| 241 | 241 | state->m_spr1_tilemap->set_palette_offset(0x100 * palette); |
| 242 | 242 | |
| 243 | state->m_spr1_tilemap->draw_roz(bitmap, cliprect, | |
| 243 | state->m_spr1_tilemap->draw_roz(bitmap, cliprect, | |
| 244 | 244 | startx,starty + 0x200*(2) * zoom, |
| 245 | 245 | incxx,0,0,incyy, /* zoom, no rotation */ |
| 246 | 246 | 0, /* no wraparound */ |
| r14260 | r14261 | |
| 288 | 288 | |
| 289 | 289 | _tilemap->set_palette_offset(0x100 * palette); |
| 290 | 290 | |
| 291 | _tilemap->draw_roz(bitmap, cliprect, | |
| 291 | _tilemap->draw_roz(bitmap, cliprect, | |
| 292 | 292 | startx,starty + 0x200*(2) * zoom, |
| 293 | 293 | incxx,0,0,incyy, /* zoom, no rotation */ |
| 294 | 294 | 0, /* no wraparound */ |
| r14260 | r14261 | |
| 321 | 321 | incxx = 1; |
| 322 | 322 | |
| 323 | 323 | // this tilemap doesn't actually zoom, but draw_roz is the only way to draw it without wraparound |
| 324 | state->m_spr2_tilemap->draw_roz(bitmap, cliprect, | |
| 324 | state->m_spr2_tilemap->draw_roz(bitmap, cliprect, | |
| 325 | 325 | sx, sy, incxx << 16, 0, 0, 1 << 16, |
| 326 | 326 | 0, 0, 0); |
| 327 | 327 | } |
| r14260 | r14261 | |
|---|---|---|
| 621 | 621 | int dy = -8; /* vertical adjust */ |
| 622 | 622 | UINT32 startx = (xoffset<<12)+incxx*dx+incyx*dy; |
| 623 | 623 | UINT32 starty = (yoffset<<12)+incxy*dx+incyy*dy; |
| 624 | state->m_roz_tilemap->draw_roz(bitmap, clip, | |
| 624 | state->m_roz_tilemap->draw_roz(bitmap, clip, | |
| 625 | 625 | startx, starty, incxx, incxy, incyx, incyy, 0, 0, primask, 0); |
| 626 | 626 | } |
| 627 | 627 | else |
| r14260 | r14261 | |
|---|---|---|
| 141 | 141 | |
| 142 | 142 | rectangle helper_clip = cliprect; |
| 143 | 143 | helper_clip &= state->m_helper.cliprect(); |
| 144 | ||
| 144 | ||
| 145 | 145 | draw_terrain(screen.machine(), state->m_helper, helper_clip); |
| 146 | 146 | draw_sprites(screen.machine(), state->m_helper, helper_clip); |
| 147 | 147 | draw_missiles(screen.machine(), state->m_helper, helper_clip); |
| r14260 | r14261 | |
|---|---|---|
| 315 | 315 | if (incxx & 0x10000) incxx |= ~0x1ffff; |
| 316 | 316 | if (incxy & 0x10000) incxy |= ~0x1ffff; |
| 317 | 317 | |
| 318 | state->m_roz_tilemap->draw_roz(bitmap, my_clip, | |
| 318 | state->m_roz_tilemap->draw_roz(bitmap, my_clip, | |
| 319 | 319 | (start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16, |
| 320 | 320 | incxx<<8, incxy<<8, 0, 0, |
| 321 | 321 | 1, // Wrap |
| r14260 | r14261 | |
| 346 | 346 | if (incyy & 0x10000) incyy |= ~0x1ffff; |
| 347 | 347 | if (incyx & 0x10000) incyx |= ~0x1ffff; |
| 348 | 348 | |
| 349 | state->m_roz_tilemap->draw_roz(bitmap, cliprect, | |
| 349 | state->m_roz_tilemap->draw_roz(bitmap, cliprect, | |
| 350 | 350 | (startx+offsx)<<16, (starty+offsy)<<16, |
| 351 | 351 | incxx<<8, incxy<<8, incyx<<8, incyy<<8, |
| 352 | 352 | 1, // Wrap |
| r14260 | r14261 | |
|---|---|---|
| 501 | 501 | rect.max_y = sy + screen.machine().gfx[1]->height - 1; |
| 502 | 502 | |
| 503 | 503 | rect &= visarea; |
| 504 | ||
| 504 | ||
| 505 | 505 | // check collision sprite - sprite |
| 506 | 506 | |
| 507 | 507 | state->m_helper.fill(0, rect); |
| r14260 | r14261 | |
|---|---|---|
| 1 | 1 | /* Data East Sprite Chip |
| 2 | 2 | DECO 52 |
| 3 | 3 | |
| 4 | note, we have pri callbacks and checks to drop back to plain drawgfx because not all drivers are using pdrawgfx yet, they probably should be... | |
| 5 | some games have different visible areas, but are confirmed as the same sprite chip. | |
| 4 | This is a flexible implementation of the Data East Spite chip 52 emulation, used in a large number of drivers. | |
| 6 | 5 | |
| 7 | games with alpha aren't supported here yet, in most cases they need better mixing anyway, probably rendering to screen buffers and manual mixing. | |
| 8 | see m_sprite_bitmap... (note, if using that you must also use BITMAP_FORMAT_RGB32 in the machine config) | |
| 6 | Both list formats are supported (how is this selected on HW, external pin?) | |
| 9 | 7 | |
| 8 | Support for rendering to a raw indexed 16-bitmap is available allowing you to do complex mixing, which is required | |
| 9 | if a game uses alpha blending at the mixing stage. | |
| 10 | ||
| 11 | Basic callbacks priority and colour are supported for use with pdrawgfx if render-to-bitmap mode isn't being used. | |
| 12 | ||
| 13 | There is also a very simply 'drawgfx' path for games where the sprites are only of one priority level. | |
| 14 | ||
| 15 | ||
| 10 | 16 | used by: |
| 11 | 17 | |
| 12 | 18 | dblewing.c |
| r14260 | r14261 | |
| 24 | 30 | cninja.c |
| 25 | 31 | lemmings.c |
| 26 | 32 | deco32.c |
| 33 | rohga.c | |
| 34 | dassault.c | |
| 27 | 35 | |
| 28 | partially converted: | |
| 29 | ||
| 30 | difficult to convert: | |
| 31 | rohga.c - complex video mixing, 6bpp gfx.. | |
| 32 | dassault.c - complex video mixing | |
| 36 | to convert: | |
| 37 | ||
| 33 | 38 | boogwing.c - complex video mixing |
| 34 | 39 | |
| 35 | 40 | notes: |
| 36 | 41 | does the chip natively support 5bpp (tattass / nslasher) in hw, or is it done with doubled up chips? |
| 37 | 42 | the information in deco_tilegen1 lists 3x sprite chips on those games, but there are only 2 spritelists. |
| 38 | 43 | |
| 44 | likewise Rohga appears to have 2x DECO52 for 1 list of 6bpp gfx. | |
| 45 | ||
| 39 | 46 | */ |
| 40 | 47 | |
| 41 | 48 | |
| r14260 | r14261 | |
| 116 | 123 | #include "emu.h" |
| 117 | 124 | #include "decospr.h" |
| 118 | 125 | |
| 126 | UINT16 decospr_default_colour_callback(UINT16 col) | |
| 127 | { | |
| 128 | return (col >> 9) & 0x1f; | |
| 129 | } | |
| 119 | 130 | |
| 120 | 131 | void decospr_device::set_gfx_region(device_t &device, int gfxregion) |
| 121 | 132 | { |
| r14260 | r14261 | |
| 128 | 139 | { |
| 129 | 140 | decospr_device &dev = downcast<decospr_device &>(device); |
| 130 | 141 | dev.m_pricallback = callback; |
| 131 | // printf("decospr_device::set_pri_callback()\n"); | |
| 132 | 142 | } |
| 133 | 143 | |
| 144 | void decospr_device::set_col_callback(device_t &device, decospr_colour_callback_func callback) | |
| 145 | { | |
| 146 | decospr_device &dev = downcast<decospr_device &>(device); | |
| 147 | dev.m_colcallback = callback; | |
| 148 | } | |
| 134 | 149 | |
| 150 | ||
| 135 | 151 | const device_type DECO_SPRITE = &device_creator<decospr_device>; |
| 136 | 152 | |
| 137 | 153 | decospr_device::decospr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 138 | 154 | : device_t(mconfig, DECO_SPRITE, "decospr_device", tag, owner, clock), |
| 139 | 155 | m_gfxregion(0), |
| 140 | m_pricallback(NULL) | |
| 156 | m_pricallback(NULL), | |
| 157 | m_colcallback(decospr_default_colour_callback) | |
| 141 | 158 | { |
| 142 | 159 | } |
| 143 | 160 | |
| r14260 | r14261 | |
| 173 | 190 | m_pricallback = callback; |
| 174 | 191 | } |
| 175 | 192 | |
| 193 | void decospr_device::set_col_callback(decospr_priority_callback_func callback) | |
| 194 | { | |
| 195 | m_colcallback = callback; | |
| 196 | } | |
| 176 | 197 | |
| 177 | 198 | |
| 178 | 199 | template<class _BitmapClass> |
| r14260 | r14261 | |
| 227 | 248 | x = spriteram[offs + 2]; |
| 228 | 249 | |
| 229 | 250 | if (!m_sprite_bitmap.valid()) |
| 230 | colour = (x >> 9) & 0x1f; | |
| 251 | { | |
| 252 | colour = m_colcallback(x); | |
| 253 | } | |
| 231 | 254 | else |
| 232 | 255 | { |
| 233 | 256 | colour = (x >> 9) & 0x7f; |
| r14260 | r14261 | |
|---|---|---|
| 1 | 1 | |
| 2 | 2 | typedef UINT16 (*decospr_priority_callback_func)(UINT16 pri); |
| 3 | typedef UINT16 (*decospr_colour_callback_func)(UINT16 col); | |
| 3 | 4 | |
| 4 | 5 | class decospr_device : public device_t |
| 5 | 6 | { |
| r14260 | r14261 | |
| 7 | 8 | decospr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 8 | 9 | static void set_gfx_region(device_t &device, int gfxregion); |
| 9 | 10 | static void set_pri_callback(device_t &device, decospr_priority_callback_func callback); |
| 11 | static void set_col_callback(device_t &device, decospr_colour_callback_func callback); | |
| 10 | 12 | //void decospr_sprite_kludge(int x, int y); |
| 11 | 13 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16* spriteram, int sizewords, bool invert_flip = false ); |
| 12 | 14 | void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16* spriteram, int sizewords, bool invert_flip = false ); |
| 13 | 15 | void set_pri_callback(decospr_priority_callback_func callback); |
| 16 | void set_col_callback(decospr_colour_callback_func callback); | |
| 14 | 17 | void set_gfxregion(int region) { m_gfxregion = region; }; |
| 15 | 18 | void set_alt_format(bool alt) { m_alt_format = alt; }; |
| 16 | 19 | void set_pix_mix_mask(UINT16 mask) { m_pixmask = mask; }; |
| r14260 | r14261 | |
| 24 | 27 | virtual void device_reset(); |
| 25 | 28 | UINT8 m_gfxregion; |
| 26 | 29 | decospr_priority_callback_func m_pricallback; |
| 30 | decospr_colour_callback_func m_colcallback; | |
| 27 | 31 | bitmap_ind16 m_sprite_bitmap;// optional sprite bitmap (should be INDEXED16) |
| 28 | 32 | bool m_alt_format; |
| 29 | 33 | UINT16 m_pixmask; |
| r14260 | r14261 | |
|---|---|---|
| 637 | 637 | x0 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x000/2 + i)]; |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | ||
| 640 | ||
| 641 | 641 | tmptilemap0->set_scrollx( |
| 642 | 642 | (i + layer0_scrolly) % tilemap_width(tm0size), |
| 643 | 643 | layer0_scrollx + x0 ); |
| r14260 | r14261 | |
| 654 | 654 | x1 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x200/2 + i)]; |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | ||
| 657 | ||
| 658 | 658 | tmptilemap1->set_scrollx( |
| 659 | 659 | (i + layer1_scrolly) % tilemap_width(tm1size), |
| 660 | 660 | layer1_scrollx + x1 ); |
| r14260 | r14261 | |
| 811 | 811 | x0 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x000/2 + i)]; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | ||
| 814 | ||
| 815 | 815 | tmptilemap0->set_scrollx( |
| 816 | 816 | (i + layer0_scrolly) % tilemap_width(tm0size), |
| 817 | 817 | layer0_scrollx + x0 ); |
| r14260 | r14261 | |
| 828 | 828 | x1 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x200/2 + i)]; |
| 829 | 829 | } |
| 830 | 830 | |
| 831 | ||
| 831 | ||
| 832 | 832 | tmptilemap1->set_scrollx( |
| 833 | 833 | (i + layer1_scrolly) % tilemap_width(tm1size), |
| 834 | 834 | layer1_scrollx + x1 ); |
| r14260 | r14261 | |
|---|---|---|
| 7 | 7 | #include "emu.h" |
| 8 | 8 | #include "includes/rohga.h" |
| 9 | 9 | #include "video/deco16ic.h" |
| 10 | #include "video/decospr.h" | |
| 10 | 11 | |
| 11 | ||
| 12 | 12 | WRITE16_HANDLER( rohga_buffer_spriteram16_w ) |
| 13 | 13 | { |
| 14 | 14 | // Spriteram seems to be triple buffered (no sprite lag on real pcb, but there |
| r14260 | r14261 | |
| 23 | 23 | rohga_state *state = machine.driver_data<rohga_state>(); |
| 24 | 24 | state->m_spriteram = auto_alloc_array(machine, UINT16, 0x800/2); |
| 25 | 25 | state->save_pointer(NAME(state->m_spriteram), 0x800/2); |
| 26 | machine.device<decospr_device>("spritegen1")->set_col_callback(rohga_col_callback); | |
| 27 | machine.device<decospr_device>("spritegen1")->set_pri_callback(rohga_pri_callback); | |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | /******************************************************************************/ | |
| 29 | ||
| 30 | static void rohga_draw_sprites( running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, const UINT16 *spriteptr, int is_schmeisr ) | |
| 30 | VIDEO_START( schmeisr ) | |
| 31 | 31 | { |
| 32 | int offs; | |
| 32 | VIDEO_START_CALL( rohga ); | |
| 33 | // wire mods on pcb.. | |
| 34 | machine.device<decospr_device>("spritegen1")->set_col_callback(schmeisr_col_callback); | |
| 35 | } | |
| 33 | 36 | |
| 34 | for (offs = 0x400 - 4; offs >= 0; offs -= 4) | |
| 35 | { | |
| 36 | int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri = 0; | |
| 37 | sprite = spriteptr[offs + 1]; | |
| 38 | if (!sprite) | |
| 39 | continue; | |
| 40 | 37 | |
| 41 | x = spriteptr[offs + 2]; | |
| 42 | ||
| 43 | /* Sprite/playfield priority */ | |
| 44 | switch (x & 0x6000) | |
| 45 | { | |
| 46 | case 0x0000: pri = 0; break; | |
| 47 | case 0x4000: pri = 0xf0; break; | |
| 48 | case 0x6000: pri = 0xf0 | 0xcc; break; | |
| 49 | case 0x2000: pri = 0;//0xf0|0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */ | |
| 50 | } | |
| 51 | ||
| 52 | y = spriteptr[offs]; | |
| 53 | flash = y & 0x1000; | |
| 54 | if (flash && (machine.primary_screen->frame_number() & 1)) | |
| 55 | continue; | |
| 56 | ||
| 57 | // Sprite colour is different between Rohga (6bpp) and Schmeisr (4bpp plus wire mods on pcb) | |
| 58 | if (is_schmeisr) | |
| 59 | { | |
| 60 | colour = ((x >> 9) & 0xf) << 2; | |
| 61 | if (x & 0x8000) | |
| 62 | colour++; | |
| 63 | } | |
| 64 | else | |
| 65 | { | |
| 66 | colour = (x >> 9) & 0xf; | |
| 67 | } | |
| 68 | ||
| 69 | fx = y & 0x2000; | |
| 70 | fy = y & 0x4000; | |
| 71 | multi = (1 << ((y & 0x0600) >> 9)) - 1; /* 1x, 2x, 4x, 8x height */ | |
| 72 | ||
| 73 | x = x & 0x01ff; | |
| 74 | y = y & 0x01ff; | |
| 75 | if (x >= 320) x -= 512; | |
| 76 | if (y >= 256) y -= 512; | |
| 77 | ||
| 78 | sprite &= ~multi; | |
| 79 | if (fy) | |
| 80 | inc = -1; | |
| 81 | else | |
| 82 | { | |
| 83 | sprite += multi; | |
| 84 | inc = 1; | |
| 85 | } | |
| 86 | ||
| 87 | if (flip_screen_get(machine)) | |
| 88 | { | |
| 89 | x = 304 - x; | |
| 90 | y = 240 - y; | |
| 91 | if (fx) fx = 0; else fx = 1; | |
| 92 | if (fy) fy = 0; else fy = 1; | |
| 93 | mult = -16; | |
| 94 | } | |
| 95 | else | |
| 96 | mult = +16; | |
| 97 | ||
| 98 | while (multi >= 0) | |
| 99 | { | |
| 100 | pdrawgfx_transpen(bitmap,cliprect,machine.gfx[3], | |
| 101 | sprite - multi * inc, | |
| 102 | colour, | |
| 103 | fx,fy, | |
| 104 | x,y + mult * multi, | |
| 105 | machine.priority_bitmap,pri,0); | |
| 106 | ||
| 107 | multi--; | |
| 108 | } | |
| 38 | UINT16 rohga_pri_callback(UINT16 x) | |
| 39 | { | |
| 40 | switch (x & 0x6000) | |
| 41 | { | |
| 42 | case 0x0000: return 0; | |
| 43 | case 0x4000: return 0xf0; | |
| 44 | case 0x6000: return 0xf0 | 0xcc; | |
| 45 | case 0x2000: return 0;//0xf0|0xcc; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */ | |
| 109 | 46 | } |
| 47 | ||
| 48 | return 0; | |
| 110 | 49 | } |
| 111 | 50 | |
| 112 | ||
| 51 | UINT16 | |
| 113 | 52 | { |
| 114 | int offs; | |
| 53 | UINT16 colour = ((x >> 9) & 0xf) << 2; | |
| 54 | if (x & 0x8000) | |
| 55 | colour++; | |
| 115 | 56 | |
| 116 | for (offs = 0; offs < 0x400; offs += 4) | |
| 117 | { | |
| 118 | int x, y, sprite, colour, multi, fx, fy, inc, flash, mult; | |
| 119 | int alpha = 0xff; | |
| 120 | ||
| 121 | sprite = spriteptr[offs + 1]; | |
| 122 | if (!sprite) | |
| 123 | continue; | |
| 124 | ||
| 125 | x = spriteptr[offs + 2]; | |
| 126 | ||
| 127 | /* | |
| 128 | Sprite/playfield priority - we can't use pdrawgfx because we need alpha'd sprites overlaid | |
| 129 | over non-alpha'd sprites, plus sprites underneath and above an alpha'd background layer. | |
| 130 | ||
| 131 | Hence, we rely on the hardware sorting everything correctly and not relying on any orthoganality | |
| 132 | effects (it doesn't seem to), and instead draw separate passes for each sprite priority. :( | |
| 133 | */ | |
| 134 | switch (mode) | |
| 135 | { | |
| 136 | case 4: | |
| 137 | if ((x & 0xc000) != 0xc000) | |
| 138 | continue; | |
| 139 | break; | |
| 140 | case 3: | |
| 141 | if ((x & 0xc000) != 0x8000) | |
| 142 | continue; | |
| 143 | break; | |
| 144 | case 2: | |
| 145 | if ((x & 0x8000) != 0x8000) | |
| 146 | continue; | |
| 147 | break; | |
| 148 | case 1: | |
| 149 | case 0: | |
| 150 | default: | |
| 151 | if ((x & 0x8000) != 0) | |
| 152 | continue; | |
| 153 | break; | |
| 154 | } | |
| 155 | ||
| 156 | y = spriteptr[offs]; | |
| 157 | flash = y & 0x1000; | |
| 158 | if (flash && (machine.primary_screen->frame_number() & 1)) | |
| 159 | continue; | |
| 160 | colour = (x >> 9) & 0x1f; | |
| 161 | ||
| 162 | if (bank == 4 && colour & 0x10) | |
| 163 | { | |
| 164 | alpha = 0x80; | |
| 165 | colour &= 0xf; | |
| 166 | } | |
| 167 | ||
| 168 | fx = y & 0x2000; | |
| 169 | fy = y & 0x4000; | |
| 170 | multi = (1 << ((y & 0x0600) >> 9)) - 1; /* 1x, 2x, 4x, 8x height */ | |
| 171 | ||
| 172 | x = x & 0x01ff; | |
| 173 | y = y & 0x01ff; | |
| 174 | if (x >= 320) x -= 512; | |
| 175 | if (y >= 256) y -= 512; | |
| 176 | ||
| 177 | sprite &= ~multi; | |
| 178 | if (fy) | |
| 179 | inc = -1; | |
| 180 | else | |
| 181 | { | |
| 182 | sprite += multi; | |
| 183 | inc = 1; | |
| 184 | } | |
| 185 | ||
| 186 | if (flip_screen_get(machine)) | |
| 187 | { | |
| 188 | x = 304 - x; | |
| 189 | y = 240 - y; | |
| 190 | if (fx) fx = 0; else fx = 1; | |
| 191 | if (fy) fy = 0; else fy = 1; | |
| 192 | mult = -16; | |
| 193 | } | |
| 194 | else | |
| 195 | mult = +16; | |
| 196 | ||
| 197 | if (fx) fx = 0; else fx = 1; | |
| 198 | if (fy) fy = 0; else fy = 1; | |
| 199 | ||
| 200 | while (multi >= 0) | |
| 201 | { | |
| 202 | drawgfx_alpha(bitmap,cliprect,machine.gfx[bank], | |
| 203 | sprite - multi * inc, | |
| 204 | colour, | |
| 205 | fx,fy, | |
| 206 | x,y + mult * multi, | |
| 207 | 0,alpha); | |
| 208 | ||
| 209 | multi--; | |
| 210 | } | |
| 211 | } | |
| 57 | return colour; | |
| 212 | 58 | } |
| 213 | 59 | |
| 214 | ||
| 60 | UINT16 | |
| 215 | 61 | { |
| 216 | rohga_state *state = machine.driver_data<rohga_state>(); | |
| 217 | int offs, end, inc; | |
| 218 | UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff); | |
| 62 | return (x >> 9) & 0xf; | |
| 63 | } | |
| 219 | 64 | |
| 220 | /* | |
| 221 | Alternate format from most 16 bit games - same as Captain America and Mutant Fighter | |
| 222 | 65 | |
| 223 | Word 0: | |
| 224 | 0x8000: Y flip | |
| 225 | 0x4000: X flip | |
| 226 | 0x2000: Flash (Sprite toggles on/off every frame) | |
| 227 | 0x1fff: Y value | |
| 228 | Word 1: | |
| 229 | 0xffff: X value | |
| 230 | Word 2: | |
| 231 | 0xf000: Block height | |
| 232 | 0x0f00: Block width | |
| 233 | 0x00e0: Unused? | |
| 234 | 66 | |
| 235 | sprites1: | |
| 236 | bit 0x40 set for under PF2 | |
| 237 | bit 0x20 set on others... | |
| 238 | bit 0x80 set in game pf3 (split) | |
| 239 | ||
| 240 | Sprites 2: | |
| 241 | bit 0x10 set on alpha sprites.. | |
| 242 | bit 0x80 set is above pf2 else under pf2 | |
| 243 | ||
| 244 | 0x001f: Colour | |
| 245 | Word 3: | |
| 246 | 0xffff: Sprite value | |
| 247 | */ | |
| 248 | ||
| 249 | offs = 0x3fc; | |
| 250 | end = -4; | |
| 251 | inc = -4; | |
| 252 | ||
| 253 | while (offs != end) | |
| 254 | { | |
| 255 | int x, y, sprite, colour, fx, fy, w, h, sx, sy, x_mult, y_mult, tilemap_pri, sprite_pri; | |
| 256 | int alpha = 0xff; | |
| 257 | ||
| 258 | sprite = spriteptr[offs + 3]; | |
| 259 | if (!sprite) | |
| 260 | { | |
| 261 | offs += inc; | |
| 262 | continue; | |
| 263 | } | |
| 264 | ||
| 265 | sx = spriteptr[offs + 1]; | |
| 266 | ||
| 267 | h = (spriteptr[offs + 2] & 0xf000) >> 12; | |
| 268 | w = (spriteptr[offs + 2] & 0x0f00) >> 8; | |
| 269 | ||
| 270 | sy = spriteptr[offs]; | |
| 271 | if ((sy & 0x2000) && (machine.primary_screen->frame_number() & 1)) | |
| 272 | { | |
| 273 | offs += inc; | |
| 274 | continue; | |
| 275 | } | |
| 276 | ||
| 277 | colour = (spriteptr[offs + 2] >> 0) & 0x1f; | |
| 278 | ||
| 279 | // PRIORITIES - TODO | |
| 280 | if (gfxbank == 3) | |
| 281 | { | |
| 282 | /* Sprite chip 1 */ | |
| 283 | switch (spriteptr[offs + 2] & 0xe0) | |
| 284 | { | |
| 285 | // case 0xc0: colour = rand()%0xff; tilemap_pri = 256; break; //todo | |
| 286 | case 0xc0: tilemap_pri = 8; break; //? under other sprites | |
| 287 | case 0x80: tilemap_pri = 32; break; //? under other sprites | |
| 288 | case 0x20: tilemap_pri = 32; break; /* Over pf2 and under other sprite chip */ | |
| 289 | case 0x40: tilemap_pri = 8; break; /* Under pf2 and under other sprite chip */ | |
| 290 | case 0xa0: tilemap_pri = 32; break; | |
| 291 | case 0: | |
| 292 | tilemap_pri = 128; break; | |
| 293 | default: | |
| 294 | tilemap_pri = 128; | |
| 295 | break; | |
| 296 | } | |
| 297 | ||
| 298 | /* | |
| 299 | Intro: | |
| 300 | 0x40 is under pf2 and other sprites | |
| 301 | 0x20 is under pf2 | |
| 302 | ||
| 303 | Level 1 | |
| 304 | 0xa0 means under other sprites and pf2? | |
| 305 | ||
| 306 | Level 2 (tank scene) | |
| 307 | ||
| 308 | Chip 1: | |
| 309 | ||
| 310 | 0x20 set means under pf2 else above?? | |
| 311 | 0x80 set means under other sprites else above | |
| 312 | ||
| 313 | Level 3: | |
| 314 | 0xc0 means under other sprites and pf2 check?? | |
| 315 | 0x40 means under pf2 | |
| 316 | 0xa0 means under pf2.. | |
| 317 | ||
| 318 | always over other sprites..? | |
| 319 | ||
| 320 | ||
| 321 | PRI MODE 2: (Level 4) | |
| 322 | sprite 1: | |
| 323 | mode 0xa0 is under pf2 (sprites unknown) | |
| 324 | mode 0x40 is under pf2 (sprites unknown) | |
| 325 | ||
| 326 | sprite 2: | |
| 327 | ||
| 328 | mode 0x40 is under pf2 | |
| 329 | mode 0 is under pf2 | |
| 330 | ||
| 331 | ||
| 332 | Level 5 (Space, pri mode 1) | |
| 333 | ||
| 334 | sprite 1: | |
| 335 | mode 0x80 is over pf2 and over other sprites | |
| 336 | ||
| 337 | ||
| 338 | ||
| 339 | sprite 2: | |
| 340 | ||
| 341 | mode 0 is over pf2 | |
| 342 | ||
| 343 | */ | |
| 344 | ||
| 345 | sprite_pri = 1; | |
| 346 | } | |
| 347 | else | |
| 348 | { | |
| 349 | /* Sprite chip 2 (with alpha blending) */ | |
| 350 | ||
| 351 | /* Sprite above playfield 2, but still below other sprite chip */ | |
| 352 | // if (spriteptr[offs + 2] & 0x80) | |
| 353 | tilemap_pri = 64; | |
| 354 | // else | |
| 355 | // tilemap_pri = 8; | |
| 356 | ||
| 357 | if (priority) | |
| 358 | tilemap_pri = 8; | |
| 359 | else | |
| 360 | tilemap_pri = 64; | |
| 361 | ||
| 362 | sprite_pri = 2; | |
| 363 | } | |
| 364 | ||
| 365 | if (gfxbank == 4 && colour & 0x10) | |
| 366 | { | |
| 367 | alpha = 0x80; | |
| 368 | colour &= 0xf; | |
| 369 | } | |
| 370 | ||
| 371 | fx = (spriteptr[offs + 0] & 0x4000); | |
| 372 | fy = (spriteptr[offs + 0] & 0x8000); | |
| 373 | ||
| 374 | if (!flip_screen_get(machine)) | |
| 375 | { /* Inverted from Mutant Fighter! */ | |
| 376 | if (fx) fx = 0; else fx = 1; | |
| 377 | if (fy) fy = 0; else fy = 1; | |
| 378 | ||
| 379 | sx = sx & 0x01ff; | |
| 380 | sy = sy & 0x01ff; | |
| 381 | if (sx > 0x180) sx = -(0x200 - sx); | |
| 382 | if (sy > 0x180) sy = -(0x200 - sy); | |
| 383 | ||
| 384 | if (fx) { x_mult = -16; sx += 16 * w; } else { x_mult = 16; sx -= 16; } | |
| 385 | if (fy) { y_mult = -16; sy += 16 * h; } else { y_mult = 16; sy -= 16; } | |
| 386 | } | |
| 387 | else | |
| 388 | { | |
| 389 | sx = sx & 0x01ff; | |
| 390 | sy = sy & 0x01ff; | |
| 391 | if (sx & 0x100) sx = -(0x100 - (sx & 0xff)); | |
| 392 | if (sy & 0x100) sy = -(0x100 - (sy & 0xff)); | |
| 393 | sx = 304 - sx; | |
| 394 | sy = 240 - sy; | |
| 395 | if (sx >= 432) sx -= 512; | |
| 396 | if (sy >= 384) sy -= 512; | |
| 397 | if (fx) { x_mult = -16; sx += 16; } else { x_mult = 16; sx -= 16 * w; } | |
| 398 | if (fy) { y_mult = -16; sy += 16; } else { y_mult = 16; sy -= 16 * h; } | |
| 399 | } | |
| 400 | ||
| 401 | for (x = 0; x < w; x++) | |
| 402 | { | |
| 403 | for (y = 0; y < h; y++) | |
| 404 | { | |
| 405 | decocomn_pdrawgfx( | |
| 406 | state->m_decocomn, | |
| 407 | bitmap,cliprect,machine.gfx[gfxbank], | |
| 408 | sprite + y + h * x, | |
| 409 | colour, | |
| 410 | fx,fy, | |
| 411 | sx + x_mult * (w-x),sy + y_mult * (h-y), | |
| 412 | 0,tilemap_pri,sprite_pri,1,alpha); | |
| 413 | } | |
| 414 | } | |
| 415 | ||
| 416 | offs += inc; | |
| 417 | } | |
| 418 | } | |
| 419 | ||
| 420 | 67 | /******************************************************************************/ |
| 421 | 68 | |
| 422 | ||
| 69 | SCREEN | |
| 423 | 70 | { |
| 424 | 71 | rohga_state *state = screen.machine().driver_data<rohga_state>(); |
| 425 | 72 | UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff); |
| r14260 | r14261 | |
| 462 | 109 | break; |
| 463 | 110 | } |
| 464 | 111 | |
| 465 | r | |
| 112 | screen.machine().device<decospr_device>("spritegen1")->draw_sprites( | |
| 466 | 113 | deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0); |
| 114 | ||
| 115 | return 0; | |
| 467 | 116 | } |
| 468 | 117 | |
| 469 | SCREEN_UPDATE_IND16( rohga ) | |
| 118 | ||
| 119 | ||
| 120 | VIDEO_START(wizdfire) | |
| 470 | 121 | { |
| 471 | update_rohga(screen, bitmap, cliprect, 0); | |
| 472 | return 0; | |
| 122 | machine.device<decospr_device>("spritegen1")->alloc_sprite_bitmap(); | |
| 123 | machine.device<decospr_device>("spritegen2")->alloc_sprite_bitmap(); | |
| 473 | 124 | } |
| 474 | 125 | |
| 475 | SCREEN_UPDATE_IND16( schmeisr ) | |
| 126 | // not amazingly efficient, called multiple times to pull a layer out of the sprite bitmaps, but keeps correct sprite<->sprite priorities | |
| 127 | static void mixwizdfirelayer(running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, int gfxregion, UINT16 pri, UINT16 primask) | |
| 476 | 128 | { |
| 477 | // The Schmeisr pcb has wire mods which seem to remap sprite palette indices. | |
| 478 | // Otherwise video update is the same as Rohga. | |
| 479 | update_rohga(screen, bitmap, cliprect, 1); | |
| 480 | return 0; | |
| 129 | int y, x; | |
| 130 | const pen_t *paldata = machine.pens; | |
| 131 | bitmap_ind16* sprite_bitmap; | |
| 132 | int penbase; | |
| 133 | ||
| 134 | sprite_bitmap = &machine.device<decospr_device>("spritegen2")->get_sprite_temp_bitmap(); | |
| 135 | penbase = 0x600; | |
| 136 | ||
| 137 | UINT16* srcline; | |
| 138 | UINT32* dstline; | |
| 139 | ||
| 140 | ||
| 141 | for (y=cliprect.min_y;y<=cliprect.max_y;y++) | |
| 142 | { | |
| 143 | srcline=&sprite_bitmap->pix16(y,0); | |
| 144 | dstline=&bitmap.pix32(y,0); | |
| 145 | ||
| 146 | for (x=cliprect.min_x;x<=cliprect.max_x;x++) | |
| 147 | { | |
| 148 | UINT16 pix = srcline[x]; | |
| 149 | ||
| 150 | if ((pix & primask) != pri) | |
| 151 | continue; | |
| 152 | ||
| 153 | if (pix&0xf) | |
| 154 | { | |
| 155 | UINT16 pen = pix&0x1ff; | |
| 156 | ||
| 157 | if (pen&0x100) | |
| 158 | { | |
| 159 | UINT32 base = dstline[x]; | |
| 160 | pen &=0xff; | |
| 161 | dstline[x] = alpha_blend_r32(base, paldata[pen+penbase], 0x80); | |
| 162 | } | |
| 163 | else | |
| 164 | { | |
| 165 | dstline[x] = paldata[pen+penbase]; | |
| 166 | } | |
| 167 | } | |
| 168 | } | |
| 169 | } | |
| 481 | 170 | } |
| 482 | 171 | |
| 483 | 172 | SCREEN_UPDATE_RGB32( wizdfire ) |
| r14260 | r14261 | |
| 486 | 175 | UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff); |
| 487 | 176 | UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff); |
| 488 | 177 | |
| 178 | /* draw sprite gfx to temp bitmaps */ | |
| 179 | screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, true); | |
| 180 | screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, true); | |
| 181 | ||
| 489 | 182 | /* Update playfields */ |
| 490 | 183 | flip_screen_set(screen.machine(), BIT(flip, 7)); |
| 491 | 184 | deco16ic_pf_update(state->m_deco_tilegen1, 0, 0); |
| r14260 | r14261 | |
| 495 | 188 | bitmap.fill(screen.machine().pens[512], cliprect); |
| 496 | 189 | |
| 497 | 190 | deco16ic_tilemap_2_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 498 | | |
| 191 | | |
| 499 | 192 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0); |
| 500 | | |
| 193 | | |
| 501 | 194 | |
| 502 | 195 | if ((priority & 0x1f) == 0x1f) /* Wizdfire has bit 0x40 always set, Dark Seal 2 doesn't?! */ |
| 503 | 196 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_ALPHA(0x80), 0); |
| 504 | 197 | else |
| 505 | 198 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 0); |
| 506 | 199 | |
| 507 | /* See notes in wizdfire_draw_sprites about this */ | |
| 508 | wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0, 3); | |
| 509 | wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 2, 4); | |
| 510 | wizdfire_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 1, 4); | |
| 200 | screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0400, 0x400, 0x1ff); // 0x000 and 0x200 of 0x600 | |
| 511 | 201 | |
| 202 | mixwizdfirelayer(screen.machine(), bitmap, cliprect, 4, 0x000, 0x000); | |
| 203 | ||
| 512 | 204 | deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0); |
| 513 | 205 | return 0; |
| 514 | 206 | } |
| r14260 | r14261 | |
| 518 | 210 | rohga_state *state = screen.machine().driver_data<rohga_state>(); |
| 519 | 211 | UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff); |
| 520 | 212 | |
| 213 | /* draw sprite gfx to temp bitmaps */ | |
| 214 | screen.machine().device<decospr_device>("spritegen1")->set_alt_format(true); | |
| 215 | screen.machine().device<decospr_device>("spritegen2")->set_alt_format(true); | |
| 216 | screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, false); | |
| 217 | screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, false); | |
| 218 | ||
| 521 | 219 | /* Update playfields */ |
| 522 | 220 | flip_screen_set(screen.machine(), BIT(flip, 7)); |
| 523 | 221 | deco16ic_pf_update(state->m_deco_tilegen1, state->m_pf1_rowscroll, state->m_pf2_rowscroll); |
| r14260 | r14261 | |
| 532 | 230 | deco16ic_tilemap_12_combine_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| 533 | 231 | |
| 534 | 232 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 16); |
| 535 | nitrobal_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 3); | |
| 536 | nitrobal_draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 4); | |
| 537 | 233 | |
| 234 | /* ToDo reimplement priorities + mixing / alpha, it was busted worse than this before anyway, so no big loss that we don't do it for now ;-) */ | |
| 235 | screen.machine().device<decospr_device>("spritegen2")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x600, 0xff); | |
| 236 | screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x400, 0x1ff); | |
| 237 | ||
| 238 | ||
| 538 | 239 | deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0); |
| 539 | 240 | return 0; |
| 540 | 241 | } |
| r14260 | r14261 | |
|---|---|---|
| 345 | 345 | flags); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | ||
| 348 | 349 | /*****************************************************************************************/ |
| 349 | 350 | |
| 350 | 351 | /* |
| r14260 | r14261 | |
|---|---|---|
| 359 | 359 | |
| 360 | 360 | screen.machine().priority_bitmap.fill(0, cliprect); |
| 361 | 361 | |
| 362 | state->m_roz_tilemap->draw_roz(bitmap, cliprect, | |
| 362 | state->m_roz_tilemap->draw_roz(bitmap, cliprect, | |
| 363 | 363 | startx << 13, starty << 13, |
| 364 | 364 | incxx << 5, incxy << 5, incyx << 5, incyy << 5, |
| 365 | 365 | 1, 0, 0); |
| r14260 | r14261 | |
|---|---|---|
| 236 | 236 | else |
| 237 | 237 | { |
| 238 | 238 | tmap->draw_roz( |
| 239 | bitmap, clip, | |
| 239 | bitmap, clip, | |
| 240 | 240 | rozInfo->startx, rozInfo->starty, |
| 241 | 241 | rozInfo->incxx, rozInfo->incxy, |
| 242 | 242 | rozInfo->incyx, rozInfo->incyy, |
| r14260 | r14261 | |
|---|---|---|
| 2 | 2 | |
| 3 | 3 | Desert Assault Video emulation - Bryan McPhail, mish@tendril.co.uk |
| 4 | 4 | |
| 5 | I'm not sure if one of the alpha blending effects is correct (mode 0x8000, | |
| 6 | the usual mode 0x4000 should be correct). It may be some kind of orthogonal | |
| 7 | priority effect where it should cut a hole in other higher priority sprites | |
| 8 | to reveal a non-alpha'd hole, or alpha against a further back tilemap. | |
| 9 | (is this the helicopter shadow at the end of lv.1 ?) | |
| 10 | ||
| 11 | Also, some priorities are still a little questionable. | |
| 12 | ||
| 13 | ||
| 5 | 14 | ****************************************************************************/ |
| 6 | 15 | |
| 7 | 16 | #include "emu.h" |
| 8 | 17 | #include "video/deco16ic.h" |
| 9 | 18 | #include "includes/dassault.h" |
| 10 | 19 | #include "video/decocomn.h" |
| 20 | #include "video/decospr.h" | |
| 11 | 21 | |
| 12 | 22 | /******************************************************************************/ |
| 13 | 23 | |
| 14 | ||
| 24 | VIDEO_START(d | |
| 15 | 25 | { |
| 16 | dassault_state *state = machine.driver_data<dassault_state>(); | |
| 17 | UINT16 *buffered_spriteram = machine.generic.buffered_spriteram.u16; | |
| 18 | int x, y, sprite, colour, multi, fx, fy, inc, flash, mult; | |
| 19 | int offs, bank, gfxbank; | |
| 20 | const UINT16 *spritebase; | |
| 26 | machine.device<decospr_device>("spritegen1")->alloc_sprite_bitmap(); | |
| 27 | machine.device<decospr_device>("spritegen2")->alloc_sprite_bitmap(); | |
| 28 | } | |
| 21 | 29 | |
| 22 | /* Have to loop over the two sprite sources */ | |
| 23 | for (bank = 0; bank < 2; bank++) | |
| 24 | { | |
| 25 | for (offs = 0x800 - 4; offs >= 0; offs -= 4) | |
| 26 | { | |
| 27 | int alpha = 0xff, pmask = 0; | |
| 30 | static void mixdassaultlayer(running_machine &machine, bitmap_rgb32 &bitmap, bitmap_ind16* sprite_bitmap, const rectangle &cliprect, UINT16 pri, UINT16 primask, UINT16 penbase, UINT8 alpha) | |
| 31 | { | |
| 32 | int y, x; | |
| 33 | const pen_t *paldata = machine.pens; | |
| 28 | 34 | |
| 29 | /* Draw the main spritebank after the other one */ | |
| 30 | if (bank == 0) | |
| 31 | { | |
| 32 | spritebase = buffered_spriteram; | |
| 33 | gfxbank = 3; | |
| 34 | } | |
| 35 | else | |
| 36 | { | |
| 37 | spritebase = machine.generic.buffered_spriteram2.u16; | |
| 38 | gfxbank = 4; | |
| 39 | } | |
| 35 | UINT16* srcline; | |
| 36 | UINT32* dstline; | |
| 40 | 37 | |
| 41 | sprite = spritebase[offs + 1] & 0x7fff; | |
| 42 | if (!sprite) | |
| 43 | continue; | |
| 38 | for (y=cliprect.min_y;y<=cliprect.max_y;y++) | |
| 39 | { | |
| 40 | srcline=&sprite_bitmap->pix16(y,0); | |
| 41 | dstline=&bitmap.pix32(y,0); | |
| 44 | 42 | |
| 45 | x = spritebase[offs + 2]; | |
| 43 | for (x=cliprect.min_x;x<=cliprect.max_x;x++) | |
| 44 | { | |
| 45 | UINT16 pix = srcline[x]; | |
| 46 | 46 | |
| 47 | /* Alpha on chip 2 only */ | |
| 48 | if (bank == 1 && x & 0xc000) | |
| 49 | alpha = 0x80; | |
| 50 | ||
| 51 | y = spritebase[offs]; | |
| 52 | flash = y & 0x1000; | |
| 53 | if (flash && (machine.primary_screen->frame_number() & 1)) | |
| 47 | if ((pix & primask) != pri) | |
| 54 | 48 | continue; |
| 55 | colour = (x >> 9) & 0x1f; | |
| 56 | if (y & 0x8000) | |
| 57 | colour += 32; | |
| 58 | 49 | |
| 59 | fx = y & 0x2000; | |
| 60 | fy = y & 0x4000; | |
| 61 | multi = (1 << ((y & 0x0600) >> 9)) - 1; /* 1x, 2x, 4x, 8x height */ | |
| 62 | ||
| 63 | x = x & 0x01ff; | |
| 64 | y = y & 0x01ff; | |
| 65 | if (x >= 320) x -= 512; | |
| 66 | if (y >= 256) y -= 512; | |
| 67 | x = 304 - x; | |
| 68 | y = 240 - y; | |
| 69 | ||
| 70 | if (x > 320) | |
| 71 | continue; /* Speedup */ | |
| 72 | ||
| 73 | sprite &= ~multi; | |
| 74 | if (fy) | |
| 75 | inc = -1; | |
| 76 | else | |
| 50 | if (pix&0xf) | |
| 77 | 51 | { |
| 78 | sprite += multi; | |
| 79 | inc = 1; | |
| 80 | } | |
| 52 | UINT16 pen = pix&0x1ff; | |
| 53 | if (pix & 0x800) pen += 0x200; | |
| 81 | 54 | |
| 82 | if (flip_screen_get(machine)) | |
| 83 | { | |
| 84 | y = 240 - y; | |
| 85 | x = 304 - x; | |
| 86 | if (fx) fx = 0; else fx = 1; | |
| 87 | if (fy) fy = 0; else fy = 1; | |
| 88 | mult = 16; | |
| 89 | } | |
| 90 | else mult = -16; | |
| 91 | ||
| 92 | /* Priority */ | |
| 93 | switch (pf_priority & 3) | |
| 94 | { | |
| 95 | case 0: | |
| 96 | if (bank == 0) | |
| 55 | if (alpha!=0xff) | |
| 97 | 56 | { |
| 98 | | |
| 57 | | |
| 99 | 58 | { |
| 100 | case 0xc000: pmask = 1; break; | |
| 101 | case 0x8000: pmask = 8; break; | |
| 102 | case 0x4000: pmask = 32; break; | |
| 103 | case 0x0000: pmask = 128; break; | |
| 59 | UINT32 base = dstline[x]; | |
| 60 | dstline[x] = alpha_blend_r32(base, paldata[pen+penbase], alpha); | |
| 104 | 61 | } |
| 105 | } | |
| 106 | else | |
| 107 | { | |
| 108 | if (spritebase[offs + 2] & 0x8000) | |
| 109 | pmask = 64; /* Check */ | |
| 110 | 62 | else |
| 111 | pmask = 64; | |
| 112 | } | |
| 113 | break; | |
| 114 | ||
| 115 | case 1: | |
| 116 | if (bank == 0) | |
| 117 | { | |
| 118 | switch (spritebase[offs + 2] & 0xc000) | |
| 119 | 63 | { |
| 120 | case 0xc000: pmask = 1; break; | |
| 121 | case 0x8000: pmask = 8; break; | |
| 122 | case 0x4000: pmask = 32; break; | |
| 123 | case 0x0000: pmask = 128; break; | |
| 64 | dstline[x] = paldata[pen+penbase]; | |
| 124 | 65 | } |
| 125 | 66 | } |
| 126 | 67 | else |
| 127 | 68 | { |
| 128 | if (spritebase[offs + 2] & 0x8000) | |
| 129 | pmask = 16; /* Check */ | |
| 130 | else | |
| 131 | pmask = 16; | |
| 69 | dstline[x] = paldata[pen+penbase]; | |
| 132 | 70 | } |
| 133 | break; | |
| 134 | ||
| 135 | case 2: /* Unused */ | |
| 136 | case 3: | |
| 137 | if (bank == 0) | |
| 138 | { | |
| 139 | switch (spritebase[offs + 2] & 0xc000) | |
| 140 | { | |
| 141 | case 0xc000: pmask = 1; break; | |
| 142 | case 0x8000: pmask = 8; break; | |
| 143 | case 0x4000: pmask = 32; break; | |
| 144 | case 0x0000: pmask = 128; break; | |
| 145 | } | |
| 146 | } | |
| 147 | else | |
| 148 | { | |
| 149 | if (spritebase[offs + 2] & 0x8000) | |
| 150 | pmask = 64; /* Check */ | |
| 151 | else | |
| 152 | pmask = 64; | |
| 153 | } | |
| 154 | break; | |
| 155 | 71 | } |
| 156 | ||
| 157 | while (multi >= 0) | |
| 158 | { | |
| 159 | decocomn_pdrawgfx( | |
| 160 | state->m_decocomn, | |
| 161 | bitmap,cliprect,machine.gfx[gfxbank], | |
| 162 | sprite - multi * inc, | |
| 163 | colour, | |
| 164 | fx, fy, | |
| 165 | x, y + mult * multi, | |
| 166 | 0, pmask, 1 << bank, 1, alpha); | |
| 167 | ||
| 168 | multi--; | |
| 169 | } | |
| 170 | 72 | } |
| 171 | 73 | } |
| 172 | 74 | } |
| 173 | 75 | |
| 174 | /******************************************************************************/ | |
| 175 | ||
| 76 | /* are the priorities 100% correct? they're the same as they were before conversion to DECO52 sprite device, but if (for example) you walk to the side of the crates in the first part of the game you appear over them... */ | |
| 176 | 77 | SCREEN_UPDATE_RGB32( dassault ) |
| 177 | 78 | { |
| 178 | 79 | dassault_state *state = screen.machine().driver_data<dassault_state>(); |
| 179 | 80 | UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff); |
| 180 | 81 | UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff); |
| 181 | 82 | |
| 83 | screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, false); | |
| 84 | screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, false); | |
| 85 | bitmap_ind16* sprite_bitmap1 = &screen.machine().device<decospr_device>("spritegen1")->get_sprite_temp_bitmap(); | |
| 86 | bitmap_ind16* sprite_bitmap2 = &screen.machine().device<decospr_device>("spritegen2")->get_sprite_temp_bitmap(); | |
| 87 | ||
| 182 | 88 | /* Update tilemaps */ |
| 183 | 89 | flip_screen_set(screen.machine(), BIT(flip, 7)); |
| 184 | 90 | deco16ic_pf_update(state->m_deco_tilegen1, 0, state->m_pf2_rowscroll); |
| 185 | 91 | deco16ic_pf_update(state->m_deco_tilegen2, 0, state->m_pf4_rowscroll); |
| 186 | 92 | |
| 187 | 93 | /* Draw playfields/update priority bitmap */ |
| 188 | decocomn_clear_sprite_priority_bitmap(state->m_decocomn); | |
| 189 | 94 | screen.machine().priority_bitmap.fill(0, cliprect); |
| 190 | 95 | bitmap.fill(screen.machine().pens[3072], cliprect); |
| 191 | 96 | deco16ic_tilemap_2_draw(state->m_deco_tilegen2, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); |
| r14260 | r14261 | |
| 193 | 98 | /* The middle playfields can be swapped priority-wise */ |
| 194 | 99 | if ((priority & 3) == 0) |
| 195 | 100 | { |
| 196 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 2); | |
| 197 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 16); | |
| 101 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 | |
| 102 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 2); // 2 | |
| 103 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 | |
| 104 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 16); // 16 | |
| 105 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 | |
| 106 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 64? | |
| 107 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 | |
| 108 | ||
| 198 | 109 | } |
| 199 | 110 | else if ((priority & 3) == 1) |
| 200 | 111 | { |
| 201 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2); | |
| 202 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 64); | |
| 112 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 | |
| 113 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2); // 2 | |
| 114 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 | |
| 115 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 16? | |
| 116 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 | |
| 117 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 64); // 64 | |
| 118 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 | |
| 203 | 119 | } |
| 204 | 120 | else if ((priority & 3) == 3) |
| 205 | 121 | { |
| 206 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2); | |
| 207 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 16); | |
| 122 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0600, 0x0600, 0x400, 0xff); // 1 | |
| 123 | deco16ic_tilemap_1_draw(state->m_deco_tilegen2, bitmap, cliprect, 0, 2); // 2 | |
| 124 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0400, 0x0600, 0x400, 0xff); // 8 | |
| 125 | deco16ic_tilemap_2_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 16); // 16 | |
| 126 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0200, 0x0600, 0x400, 0xff); // 32 | |
| 127 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap2, cliprect, 0x0000, 0x0000, 0x800, 0x80); // 64? | |
| 128 | mixdassaultlayer(screen.machine(), bitmap, sprite_bitmap1, cliprect, 0x0000, 0x0600, 0x400, 0xff); // 128 | |
| 208 | 129 | } |
| 209 | 130 | else |
| 210 | 131 | { |
| 211 | 132 | /* Unused */ |
| 212 | 133 | } |
| 213 | 134 | |
| 214 | /* Draw sprites - two sprite generators, with selectable priority */ | |
| 215 | draw_sprites(screen.machine(), bitmap, cliprect, priority); | |
| 216 | 135 | deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0); |
| 217 | 136 | return 0; |
| 218 | 137 | } |
| r14260 | r14261 | |
|---|---|---|
| 2 | 2 | #include "includes/boogwing.h" |
| 3 | 3 | #include "video/deco16ic.h" |
| 4 | 4 | #include "video/decocomn.h" |
| 5 | #include "video/decospr.h" | |
| 5 | 6 | |
| 6 | 7 | static void draw_sprites( running_machine &machine, bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16* spriteram_base, int gfx_region ) |
| 7 | 8 | { |
| r14260 | r14261 | |
| 138 | 139 | } |
| 139 | 140 | } |
| 140 | 141 | |
| 142 | VIDEO_START( boogwing ) | |
| 143 | { | |
| 144 | machine.device<decospr_device>("spritegen1")->alloc_sprite_bitmap(); | |
| 145 | machine.device<decospr_device>("spritegen2")->alloc_sprite_bitmap(); | |
| 146 | } | |
| 147 | ||
| 141 | 148 | SCREEN_UPDATE_RGB32( boogwing ) |
| 142 | 149 | { |
| 143 | 150 | boogwing_state *state = screen.machine().driver_data<boogwing_state>(); |
| 144 | 151 | UINT16 flip = deco16ic_pf_control_r(state->m_deco_tilegen1, 0, 0xffff); |
| 145 | 152 | UINT16 priority = decocomn_priority_r(state->m_decocomn, 0, 0xffff); |
| 146 | 153 | |
| 154 | screen.machine().device<decospr_device>("spritegen2")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 0x400, true); | |
| 155 | screen.machine().device<decospr_device>("spritegen1")->draw_sprites(bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 0x400, true); | |
| 156 | ||
| 147 | 157 | flip_screen_set(screen.machine(), BIT(flip, 7)); |
| 148 | 158 | deco16ic_pf_update(state->m_deco_tilegen1, state->m_pf1_rowscroll, state->m_pf2_rowscroll); |
| 149 | 159 | deco16ic_pf_update(state->m_deco_tilegen2, state->m_pf3_rowscroll, state->m_pf4_rowscroll); |
| r14260 | r14261 | |
| 184 | 194 | |
| 185 | 195 | draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram.u16, 3); |
| 186 | 196 | draw_sprites(screen.machine(), bitmap, cliprect, screen.machine().generic.buffered_spriteram2.u16, 4); |
| 197 | // screen.machine().device<decospr_device>("spritegen1")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x500, 0x1ff); | |
| 198 | // screen.machine().device<decospr_device>("spritegen2")->inefficient_copy_sprite_bitmap(bitmap, cliprect, 0x0000, 0x0000, 0x700, 0xff); | |
| 187 | 199 | |
| 188 | 200 | deco16ic_tilemap_1_draw(state->m_deco_tilegen1, bitmap, cliprect, 0, 0); |
| 189 | 201 | return 0; |
| r14260 | r14261 | |
|---|---|---|
| 9738 | 9738 | |
| 9739 | 9739 | if ((k001604->reg[0x6c / 4] & (0x08 >> layer)) != 0) |
| 9740 | 9740 | { |
| 9741 | k001604->layer_roz[layer]->draw_roz(bitmap, cliprect, | |
| 9741 | k001604->layer_roz[layer]->draw_roz(bitmap, cliprect, | |
| 9742 | 9742 | x << 5, y << 5, xx << 5, xy << 5, yx << 5, yy << 5, 1, 0, 0); |
| 9743 | 9743 | } |
| 9744 | 9744 | } |
| r14260 | r14261 | |
|---|---|---|
| 87 | 87 | static ADDRESS_MAP_START( ppu2c0x, AS_0, 8, ppu2c0x_device ) |
| 88 | 88 | AM_RANGE(0x0000, 0x3eff) AM_RAM |
| 89 | 89 | AM_RANGE(0x3f00, 0x3fff) AM_READWRITE(palette_read, palette_write) |
| 90 | // | |
| 90 | // AM_RANGE(0x0000, 0x3fff) AM_RAM | |
| 91 | 91 | ADDRESS_MAP_END |
| 92 | 92 | |
| 93 | 93 | //------------------------------------------------- |
| r14260 | r14261 | |
| 109 | 109 | { |
| 110 | 110 | const ppu2c0x_interface *config = reinterpret_cast<const ppu2c0x_interface *>(static_config()); |
| 111 | 111 | assert(config); |
| 112 | ||
| 112 | ||
| 113 | 113 | /* reset the callbacks */ |
| 114 | 114 | m_latch = NULL; |
| 115 | 115 | m_scanline_callback_proc = NULL; |
| r14260 | r14261 | |
| 143 | 143 | { |
| 144 | 144 | for (int i = 0; i < PPU_MAX_REG; i++) |
| 145 | 145 | m_regs[i] = 0; |
| 146 | ||
| 146 | ||
| 147 | 147 | memset(m_palette_ram, 0, ARRAY_LENGTH(m_palette_ram)); |
| 148 | ||
| 148 | ||
| 149 | 149 | m_scanlines_per_frame = PPU_NTSC_SCANLINES_PER_FRAME; |
| 150 | ||
| 150 | ||
| 151 | 151 | /* usually, no security value... */ |
| 152 | 152 | m_security_value = 0; |
| 153 | 153 | } |
| r14260 | r14261 | |
| 207 | 207 | m_cpu = machine().device<cpu_device>( m_cpu_tag ); |
| 208 | 208 | |
| 209 | 209 | assert(m_screen && m_cpu); |
| 210 | ||
| 210 | ||
| 211 | 211 | // allocate timers |
| 212 | 212 | m_hblank_timer = timer_alloc(TIMER_HBLANK); |
| 213 | 213 | m_nmi_timer = timer_alloc(TIMER_NMI); |
| 214 | 214 | m_scanline_timer = timer_alloc(TIMER_SCANLINE); |
| 215 | ||
| 215 | ||
| 216 | 216 | /* initialize the scanline handling portion */ |
| 217 | 217 | m_scanline_timer->adjust(m_screen->time_until_pos(1)); |
| 218 | 218 | m_hblank_timer->adjust(m_cpu->cycles_to_attotime(86.67)); // ??? FIXME - hardcoding NTSC, need better calculation |
| r14260 | r14261 | |
| 229 | 229 | { |
| 230 | 230 | /* monochromatic table */ |
| 231 | 231 | m_colortable_mono[i] = default_colortable_mono[i] + m_color_base; |
| 232 | ||
| 232 | ||
| 233 | 233 | /* color table */ |
| 234 | 234 | m_colortable[i] = default_colortable[i] + m_color_base; |
| 235 | 235 | } |
| r14260 | r14261 | |
| 468 | 468 | case TIMER_HBLANK: |
| 469 | 469 | blanked = (m_regs[PPU_CONTROL1] & (PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES)) == 0; |
| 470 | 470 | vblank = ((m_scanline >= PPU_VBLANK_FIRST_SCANLINE - 1) && (m_scanline < m_scanlines_per_frame - 1)) ? 1 : 0; |
| 471 | ||
| 471 | ||
| 472 | 472 | //update_scanline(); |
| 473 | ||
| 473 | ||
| 474 | 474 | if (m_hblank_callback_proc) |
| 475 | 475 | (*m_hblank_callback_proc) (this, m_scanline, vblank, blanked); |
| 476 | ||
| 476 | ||
| 477 | 477 | m_hblank_timer->adjust(attotime::never); |
| 478 | 478 | break; |
| 479 | ||
| 480 | case TIMER_NMI: | |
| 479 | ||
| 480 | case TIMER_NMI: | |
| 481 | 481 | // Actually fire the VMI |
| 482 | 482 | if (m_nmi_callback_proc) |
| 483 | 483 | (*m_nmi_callback_proc) (this, regs); |
| 484 | ||
| 484 | ||
| 485 | 485 | m_nmi_timer->adjust(attotime::never); |
| 486 | 486 | break; |
| 487 | ||
| 487 | ||
| 488 | 488 | case TIMER_SCANLINE: |
| 489 | 489 | blanked = (m_regs[PPU_CONTROL1] & (PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES)) == 0; |
| 490 | 490 | vblank = ((m_scanline >= PPU_VBLANK_FIRST_SCANLINE - 1) && (m_scanline < m_scanlines_per_frame - 1)) ? 1 : 0; |
| 491 | 491 | int next_scanline; |
| 492 | ||
| 492 | ||
| 493 | 493 | /* if a callback is available, call it */ |
| 494 | 494 | if (m_scanline_callback_proc) |
| 495 | 495 | (*m_scanline_callback_proc)(this, m_scanline, vblank, blanked); |
| 496 | ||
| 496 | ||
| 497 | 497 | /* update the scanline that just went by */ |
| 498 | 498 | update_scanline(); |
| 499 | ||
| 499 | ||
| 500 | 500 | /* increment our scanline count */ |
| 501 | 501 | m_scanline++; |
| 502 | ||
| 502 | ||
| 503 | 503 | // logerror("starting scanline %d (MAME %d, beam %d)\n", m_scanline, device->machine().primary_screen->vpos(), device->machine().primary_screen->hpos()); |
| 504 | ||
| 504 | ||
| 505 | 505 | /* Note: this is called at the _end_ of each scanline */ |
| 506 | 506 | if (m_scanline == PPU_VBLANK_FIRST_SCANLINE) |
| 507 | 507 | { |
| 508 | 508 | // logerror("vblank starting\n"); |
| 509 | 509 | /* We just entered VBLANK */ |
| 510 | 510 | m_regs[PPU_STATUS] |= PPU_STATUS_VBLANK; |
| 511 | ||
| 511 | ||
| 512 | 512 | /* If NMI's are set to be triggered, go for it */ |
| 513 | 513 | if (m_regs[PPU_CONTROL0] & PPU_CONTROL0_NMI) |
| 514 | 514 | { |
| r14260 | r14261 | |
| 519 | 519 | m_nmi_timer->adjust(m_cpu->cycles_to_attotime(4)); |
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | ||
| 522 | ||
| 523 | 523 | if (m_scanline == m_scanlines_per_frame - 1) |
| 524 | 524 | { |
| 525 | 525 | // logerror("vblank ending\n"); |
| 526 | 526 | /* clear the vblank & sprite hit flag */ |
| 527 | 527 | m_regs[PPU_STATUS] &= ~(PPU_STATUS_VBLANK | PPU_STATUS_SPRITE0_HIT | PPU_STATUS_8SPRITES); |
| 528 | 528 | } |
| 529 | ||
| 529 | ||
| 530 | 530 | /* see if we rolled */ |
| 531 | 531 | else if (m_scanline == m_scanlines_per_frame) |
| 532 | 532 | { |
| 533 | 533 | /* if background or sprites are enabled, copy the ppu address latch */ |
| 534 | 534 | if (!blanked) |
| 535 | 535 | m_refresh_data = m_refresh_latch; |
| 536 | ||
| 536 | ||
| 537 | 537 | /* reset the scanline count */ |
| 538 | 538 | m_scanline = 0; |
| 539 | 539 | //logerror("sprite 0 x: %d y: %d num: %d\n", m_spriteram[3], m_spriteram[0] + 1, m_spriteram[1]); |
| 540 | 540 | } |
| 541 | ||
| 541 | ||
| 542 | 542 | next_scanline = m_scanline + 1; |
| 543 | 543 | if (next_scanline == m_scanlines_per_frame) |
| 544 | 544 | next_scanline = 0; |
| 545 | ||
| 545 | ||
| 546 | 546 | // Call us back when the hblank starts for this scanline |
| 547 | 547 | m_hblank_timer->adjust(m_cpu->cycles_to_attotime(86.67)); // ??? FIXME - hardcoding NTSC, need better calculation |
| 548 | ||
| 548 | ||
| 549 | 549 | // trigger again at the start of the next scanline |
| 550 | 550 | m_scanline_timer->adjust(m_screen->time_until_pos(next_scanline * m_scan_scale)); |
| 551 | 551 | break; |
| r14260 | r14261 | |
| 1043 | 1043 | { |
| 1044 | 1044 | if (m_regs[PPU_CONTROL1] & PPU_CONTROL1_DISPLAY_MONO) |
| 1045 | 1045 | return (m_palette_ram[offset & 0x1f] & 0x30); |
| 1046 | ||
| 1046 | ||
| 1047 | 1047 | else |
| 1048 | 1048 | return (m_palette_ram[offset & 0x1f]); |
| 1049 | 1049 | } |
| r14260 | r14261 | |
|---|---|---|
| 144 | 144 | public: |
| 145 | 145 | // construction/destruction |
| 146 | 146 | ppu2c0x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); |
| 147 | ||
| 147 | ||
| 148 | 148 | DECLARE_READ8_MEMBER( read ); |
| 149 | 149 | DECLARE_WRITE8_MEMBER( write ); |
| 150 | 150 | DECLARE_READ8_MEMBER( palette_read ); |
| r14260 | r14261 | |
| 157 | 157 | virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; |
| 158 | 158 | // address space configurations |
| 159 | 159 | const address_space_config m_space_config; |
| 160 | ||
| 161 | ||
| 160 | ||
| 161 | ||
| 162 | 162 | /* routines */ |
| 163 | 163 | void init_palette( running_machine &machine, int first_entry ); |
| 164 | 164 | void init_palette_rgb( running_machine &machine, int first_entry ); |
| 165 | ||
| 165 | ||
| 166 | 166 | void draw_background( UINT8 *line_priority ); |
| 167 | 167 | void draw_sprites( UINT8 *line_priority ); |
| 168 | 168 | void render_scanline(); |
| r14260 | r14261 | |
| 179 | 179 | void set_hblank_callback( ppu2c0x_scanline_cb cb ) { if (cb != NULL) m_hblank_callback_proc = cb; }; |
| 180 | 180 | void set_vidaccess_callback( ppu2c0x_vidaccess_cb cb ) { if (cb != NULL) m_vidaccess_callback_proc = cb; }; |
| 181 | 181 | void set_scanlines_per_frame( int scanlines ) { m_scanlines_per_frame = scanlines; }; |
| 182 | ||
| 182 | ||
| 183 | 183 | //27/12/2002 (HACK!) |
| 184 | 184 | void set_latch( void (*ppu_latch_t)( device_t *device, offs_t offset ) ); |
| 185 | ||
| 186 | // void update_screen(bitmap_t &bitmap, const rectangle &cliprect); | |
| 187 | ||
| 185 | ||
| 186 | // void update_screen(bitmap_t &bitmap, const rectangle &cliprect); | |
| 187 | ||
| 188 | 188 | cpu_device *m_cpu; |
| 189 | 189 | screen_device *m_screen; |
| 190 | bitmap_ind16 | |
| 190 | bitmap_ind16 | |
| 191 | 191 | UINT8 *m_spriteram; /* sprite ram */ |
| 192 | 192 | pen_t *m_colortable; /* color table modified at run time */ |
| 193 | 193 | pen_t *m_colortable_mono; /* monochromatic color table modified at run time */ |
| r14260 | r14261 | |
| 214 | 214 | int m_scanlines_per_frame; /* number of scanlines per frame */ |
| 215 | 215 | int m_security_value; /* 2C05 protection */ |
| 216 | 216 | void (*m_latch)( device_t *device, offs_t offset ); |
| 217 | ||
| 217 | ||
| 218 | 218 | // timers |
| 219 | 219 | emu_timer *m_hblank_timer; /* hblank period at end of each scanline */ |
| 220 | 220 | emu_timer *m_nmi_timer; /* NMI timer */ |
| r14260 | r14261 | |
|---|---|---|
| 358 | 358 | startx -= (368/2) * inc; |
| 359 | 359 | starty -= (240/2) * inc; |
| 360 | 360 | |
| 361 | tm->draw_roz(bitmap, cliprect, | |
| 361 | tm->draw_roz(bitmap, cliprect, | |
| 362 | 362 | startx,starty,inc,0,0,inc, |
| 363 | 363 | 1, /* wraparound */ |
| 364 | 364 | 0,0); |
| r14260 | r14261 | |
|---|---|---|
| 290 | 290 | x = -256 - (state->m_scrollx | state->m_scrollx_hi); |
| 291 | 291 | y = 256 + (state->m_scrolly | state->m_scrolly_hi); |
| 292 | 292 | |
| 293 | state->m_bg_tilemap->draw_roz(bitmap, cliprect, | |
| 293 | state->m_bg_tilemap->draw_roz(bitmap, cliprect, | |
| 294 | 294 | (x << 16), (y << 16), |
| 295 | 295 | p1, p2, |
| 296 | 296 | p3, p4, |
| r14260 | r14261 | |
| 339 | 339 | x = 256 + (state->m_scrollx | state->m_scrollx_hi); |
| 340 | 340 | y = 256 - (state->m_scrolly | state->m_scrolly_hi); |
| 341 | 341 | |
| 342 | state->m_bg_tilemap->draw_roz(bitmap, cliprect, | |
| 342 | state->m_bg_tilemap->draw_roz(bitmap, cliprect, | |
| 343 | 343 | (x << 16), (y << 16), |
| 344 | 344 | p1, p2, |
| 345 | 345 | p3, p4, |
| r14260 | r14261 | |
|---|---|---|
| 127 | 127 | |
| 128 | 128 | //static READ32_HANDLER( nexus3d_unk2_r ) |
| 129 | 129 | //{ |
| 130 | // | |
| 130 | // return 0x00000000;//space->machine().rand() ^ (space->machine().rand() << 16); | |
| 131 | 131 | //} |
| 132 | 132 | // |
| 133 | 133 | //static READ32_HANDLER( nexus3d_unk3_r ) |
| 134 | 134 | //{ |
| 135 | // | |
| 135 | // return 0x00000000;//space->machine().rand() ^ (space->machine().rand() << 16); | |
| 136 | 136 | //} |
| 137 | 137 | // |
| 138 | 138 | //static WRITE32_HANDLER( nexus3d_unk2_w ) |
| r14260 | r14261 | |
| 156 | 156 | AM_RANGE(0x9C000018, 0x9C00001b) AM_WRITE8( n3d_flash_addr_w, 0xffffffff) |
| 157 | 157 | |
| 158 | 158 | // lots of accesses in this range |
| 159 | // AM_RANGE(0xC0000F44, 0xC0000F47) AM_READWRITE( nexus3d_unk2_r, nexus3d_unk2_w ) // often | |
| 160 | // AM_RANGE(0xC0000F4C, 0xC0000F4f) AM_READWRITE( nexus3d_unk3_r, nexus3d_unk3_w ) // often | |
| 159 | // AM_RANGE(0xC0000F44, 0xC0000F47) AM_READWRITE( nexus3d_unk2_r, nexus3d_unk2_w ) // often | |
| 160 | // AM_RANGE(0xC0000F4C, 0xC0000F4f) AM_READWRITE( nexus3d_unk3_r, nexus3d_unk3_w ) // often | |
| 161 | 161 | |
| 162 | 162 | AM_RANGE(0xE0000014, 0xE0000017) AM_READ( nexus3d_unk_r ) // sits waiting for this |
| 163 | 163 |
| r14260 | r14261 | |
|---|---|---|
| 851 | 851 | { 0 }, |
| 852 | 852 | 1024*4, |
| 853 | 853 | xoffsets |
| 854 | }; | |
| 854 | }; | |
| 855 | 855 | |
| 856 | 856 | static GFXDECODE_START( cybertnk ) |
| 857 | 857 | GFXDECODE_ENTRY( "gfx1", 0, tile_8x8x4, 0x1400, 16 ) /*Pal offset???*/ |
| r14260 | r14261 | |
|---|---|---|
| 319 | 319 | { |
| 320 | 320 | 1, /* 1 SCSI device */ |
| 321 | 321 | { |
| 322 | { SCSI_ID_0, "disk", SCSI_DEVICE_HARDDISK } /* SCSI ID 0, using CHD 0, and it's a HDD */ | |
| 322 | { SCSI_ID_0, ":disk", SCSI_DEVICE_HARDDISK } /* SCSI ID 0, using CHD 0, and it's a HDD */ | |
| 323 | 323 | } |
| 324 | 324 | }; |
| 325 | 325 |
| r14260 | r14261 | |
|---|---|---|
| 1145 | 1145 | MACHINE_CONFIG_END |
| 1146 | 1146 | |
| 1147 | 1147 | static MACHINE_CONFIG_DERIVED( chihirogd, chihiro_base ) |
| 1148 | MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "pic", NULL, "maincpu", NULL) | |
| 1148 | MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", "pic", NULL, "maincpu", NULL) | |
| 1149 | 1149 | MACHINE_CONFIG_END |
| 1150 | 1150 | |
| 1151 | 1151 | #define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \ |
| r14260 | r14261 | |
|---|---|---|
| 2560 | 2560 | */ |
| 2561 | 2561 | |
| 2562 | 2562 | static MACHINE_CONFIG_DERIVED( naomigd, naomi_base ) |
| 2563 | MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "pic", "naomibd_eeprom", "maincpu", naomi_g1_irq) | |
| 2563 | MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", "pic", "naomibd_eeprom", "maincpu", naomi_g1_irq) | |
| 2564 | 2564 | MACHINE_CONFIG_END |
| 2565 | 2565 | |
| 2566 | 2566 | /* |
| r14260 | r14261 | |
| 3954 | 3954 | NAOMI_DEFAULT_EEPROM |
| 3955 | 3955 | |
| 3956 | 3956 | ROM_REGION( 0x4000000, "rom_board", ROMREGION_ERASEFF) |
| 3957 | ROM_LOAD( "epr-24217.ic11", 0x0000000, 0x0400000, CRC(5ecf807b) SHA1(f91d03a68a44d02970e360789b746bec9289275f) ) | |
| 3958 | ROM_LOAD32_WORD( "mpr-24218.ic17s", 0x1000000, 0x0800000, CRC(e8c51e1d) SHA1(e81f0580e144aa7a7e8c9399ffa09227b6e93675) ) | |
| 3959 | ROM_LOAD32_WORD( "mpr-24219.ic18", 0x1000002, 0x0800000, CRC(b0a5709f) SHA1(993f7a99d59a924641c37a549208723342007e5a) ) | |
| 3960 | ROM_LOAD32_WORD( "mpr-24220.ic19s", 0x2000000, 0x0800000, CRC(9f6cefe2) SHA1(499e17d2c284b340db6b124b63a23c7fa5045d0f) ) | |
| 3961 | ROM_LOAD32_WORD( "mpr-24221.ic20", 0x2000002, 0x0800000, CRC(73bf9cc6) SHA1(ab187cc0babd1435f5e8636331818d81de23636f) ) | |
| 3962 | ROM_LOAD32_WORD( "mpr-24222.ic21s", 0x3000000, 0x0800000, CRC(7098e728) SHA1(82f4f57efcee3063467c24758cefd406dccb1ea4) ) | |
| 3963 | ROM_LOAD32_WORD( "mpr-24223.ic22", 0x3000002, 0x0800000, CRC(eca13c90) SHA1(26a66906bf4ebda8697140d89eb5e493e941e8b2) ) | |
| 3957 | ROM_LOAD( "epr-24217.ic11", 0x0000000, 0x0400000, CRC(5ecf807b) SHA1(f91d03a68a44d02970e360789b746bec9289275f) ) | |
| 3958 | ROM_LOAD32_WORD( "mpr-24218.ic17s", 0x1000000, 0x0800000, CRC(e8c51e1d) SHA1(e81f0580e144aa7a7e8c9399ffa09227b6e93675) ) | |
| 3959 | ROM_LOAD32_WORD( "mpr-24219.ic18", 0x1000002, 0x0800000, CRC(b0a5709f) SHA1(993f7a99d59a924641c37a549208723342007e5a) ) | |
| 3960 | ROM_LOAD32_WORD( "mpr-24220.ic19s", 0x2000000, 0x0800000, CRC(9f6cefe2) SHA1(499e17d2c284b340db6b124b63a23c7fa5045d0f) ) | |
| 3961 | ROM_LOAD32_WORD( "mpr-24221.ic20", 0x2000002, 0x0800000, CRC(73bf9cc6) SHA1(ab187cc0babd1435f5e8636331818d81de23636f) ) | |
| 3962 | ROM_LOAD32_WORD( "mpr-24222.ic21s", 0x3000000, 0x0800000, CRC(7098e728) SHA1(82f4f57efcee3063467c24758cefd406dccb1ea4) ) | |
| 3963 | ROM_LOAD32_WORD( "mpr-24223.ic22", 0x3000002, 0x0800000, CRC(eca13c90) SHA1(26a66906bf4ebda8697140d89eb5e493e941e8b2) ) | |
| 3964 | 3964 | |
| 3965 | 3965 | ROM_REGION( 4, "rom_key", 0 ) |
| 3966 | ROM_LOAD( "mtkob2-key.bin", 0x000000, 0x000004, CRC(db088208) SHA1(14d65ad2555183a445abcd93907c85df4032b41d) ) | |
| 3966 | ROM_LOAD( "mtkob2-key.bin", 0x000000, 0x000004, CRC(db088208) SHA1(14d65ad2555183a445abcd93907c85df4032b41d) ) | |
| 3967 | 3967 | ROM_END |
| 3968 | 3968 | |
| 3969 | 3969 | ROM_START( crackndj ) |
| r14260 | r14261 | |
| 5135 | 5135 | NAOMI_DEFAULT_EEPROM |
| 5136 | 5136 | |
| 5137 | 5137 | ROM_REGION( 0xb000000, "rom_board", ROMREGION_ERASEFF) |
| 5138 | ROM_LOAD("vnbaearly.ic22",0x0000000, 0x0400000, CRC(5bbf7a45) SHA1(ad71ae8e9e08d7e0a9a60d1ba51bc5dcfeb0f50c) ) | |
| 5138 | ROM_LOAD("vnbaearly.ic22",0x0000000, 0x0400000, CRC(5bbf7a45) SHA1(ad71ae8e9e08d7e0a9a60d1ba51bc5dcfeb0f50c) ) | |
| 5139 | 5139 | ROM_LOAD("mpr-22928.ic1", 0x0800000, 0x0800000, CRC(63245c98) SHA1(a5a542244f07c6c8b66961a231fb56c89d2cf20c) ) |
| 5140 | 5140 | ROM_LOAD("mpr-22929.ic2", 0x1000000, 0x0800000, CRC(eea89d21) SHA1(5fe184267e637f155d767f8d931462d9593eff5a) ) |
| 5141 | 5141 | ROM_LOAD("mpr-22930.ic3", 0x1800000, 0x0800000, CRC(2fbefa9a) SHA1(a6df46cb8742022e436cdc6a9a50490c7a551421) ) |
| r14260 | r14261 | |
| 7793 | 7793 | /* 0126 */ GAME( 2003, oinori, naomi, naomi, naomi, naomi, ROT0, "Sega", "Oinori-daimyoujin Matsuri", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7794 | 7794 | /* 0128 */ GAME( 2002, shootpl, naomi, naomim1, naomi, naomi, ROT0, "Sega", "Shootout Pool (JPN, USA, KOR, AUS) / Shootout Pool Prize (EXP)", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7795 | 7795 | /* 0140 */ GAME( 2004, kick4csh, naomi, naomim1, naomi, kick4csh, ROT0, "Sega", "Kick '4' Cash", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) |
| 7796 | /* 0150 */ GAME( 2003, mtkob2, naomi, naomim1, naomi, naomi, ROT0, "Sega", "Mushiking The King Of Beetle 2K3 2nd", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) | |
| 7796 | /* 0150 */ GAME( 2003, mtkob2, naomi, naomim1, naomi, naomi, ROT0, "Sega", "Mushiking The King Of Beetle 2K3 2nd", GAME_UNEMULATED_PROTECTION|GAME_FLAGS ) | |
| 7797 | 7797 | // 0164 MushiKing The King Of Beetle II ENG |
| 7798 | 7798 | // 0166 Touch De Zunou (Japan) |
| 7799 | 7799 | // 0166 Touch De Zunou (Japan) (Rev A) |
| r14260 | r14261 | |
|---|---|---|
| 245 | 245 | if (incxx & 0x10000) incxx |= ~0x1ffff; |
| 246 | 246 | if (incxy & 0x10000) incxy |= ~0x1ffff; |
| 247 | 247 | |
| 248 | state->m_ms32_roz_tilemap->draw_roz(bitmap, &my_clip, | |
| 248 | state->m_ms32_roz_tilemap->draw_roz(bitmap, &my_clip, | |
| 249 | 249 | (start2x+startx+offsx)<<16, (start2y+starty+offsy)<<16, |
| 250 | 250 | incxx<<8, incxy<<8, 0, 0, |
| 251 | 251 | 1, // Wrap |
| r14260 | r14261 | |
| 277 | 277 | if (incyy & 0x10000) incyy |= ~0x1ffff; |
| 278 | 278 | if (incyx & 0x10000) incyx |= ~0x1ffff; |
| 279 | 279 | |
| 280 | state->m_ms32_roz_tilemap[chip]->draw_roz(bitmap, cliprect, | |
| 280 | state->m_ms32_roz_tilemap[chip]->draw_roz(bitmap, cliprect, | |
| 281 | 281 | (startx+offsx)<<16, (starty+offsy)<<16, |
| 282 | 282 | incxx<<8, incxy<<8, incyx<<8, incyy<<8, |
| 283 | 283 | 1, // Wrap |
| r14260 | r14261 | |
|---|---|---|
| 4 | 4 | Desert Assault (c) 1991 Data East Corporation (USA 4 players) |
| 5 | 5 | Desert Assault (c) 1991 Data East Corporation (USA 2 players) |
| 6 | 6 | |
| 7 | I'm not sure if one of the alpha blending effects is correct (mode 0x8000, | |
| 8 | the usual mode 0x4000 should be correct). It may be some kind of orthogonal | |
| 9 | priority effect where it should cut a hole in other higher priority sprites | |
| 10 | to reveal a non-alpha'd hole, or alpha against a further back tilemap. | |
| 11 | ||
| 12 | 7 | Emulation by Bryan McPhail, mish@tendril.co.uk |
| 13 | 8 | |
| 14 | 9 | |
| r14260 | r14261 | |
| 130 | 125 | #include "sound/okim6295.h" |
| 131 | 126 | #include "video/deco16ic.h" |
| 132 | 127 | #include "video/decocomn.h" |
| 128 | #include "video/decospr.h" | |
| 133 | 129 | |
| 134 | 130 | /**********************************************************************************/ |
| 135 | 131 | |
| r14260 | r14261 | |
| 505 | 501 | GFXDECODE_ENTRY( "gfx2", 0, charlayout, 0, 32 ) /* Characters 8x8 */ |
| 506 | 502 | GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0, 32 ) /* Tiles 16x16 */ |
| 507 | 503 | GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 512, 32 ) /* Tiles 16x16 */ |
| 508 | GFXDECODE_ENTRY( "gfx4", 0, tilelayout, 1024, 64 ) /* Sprites 16x16 */ | |
| 509 | GFXDECODE_ENTRY( "gfx5", 0, tilelayout, 2048, 64 ) /* Sprites 16x16 */ | |
| 504 | GFXDECODE_ENTRY( "gfx4", 0, tilelayout, 0/*1024*/, 64 ) /* Sprites 16x16 */ | |
| 505 | GFXDECODE_ENTRY( "gfx5", 0, tilelayout, 0/*2048*/, 64 ) /* Sprites 16x16 */ | |
| 510 | 506 | GFXDECODE_END |
| 511 | 507 | |
| 512 | 508 | /**********************************************************************************/ |
| r14260 | r14261 | |
| 582 | 578 | MCFG_CPU_ADD("audiocpu", H6280,32220000/8) /* Accurate */ |
| 583 | 579 | MCFG_CPU_PROGRAM_MAP(sound_map) |
| 584 | 580 | |
| 585 | MCFG_QUANTUM_TIME(attotime::from_hz(8400)) /* 140 CPU slices per frame */ | |
| 581 | // MCFG_QUANTUM_TIME(attotime::from_hz(8400)) /* 140 CPU slices per frame */ | |
| 582 | MCFG_QUANTUM_PERFECT_CPU("maincpu") // I was seeing random lockups.. let's see if this helps | |
| 586 | 583 | |
| 587 | 584 | /* video hardware */ |
| 588 | 585 | MCFG_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) |
| r14260 | r14261 | |
| 594 | 591 | MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1) |
| 595 | 592 | MCFG_SCREEN_UPDATE_STATIC(dassault) |
| 596 | 593 | |
| 594 | MCFG_VIDEO_START(dassault) | |
| 595 | ||
| 597 | 596 | MCFG_GFXDECODE(dassault) |
| 598 | 597 | MCFG_PALETTE_LENGTH(4096) |
| 599 | 598 | |
| r14260 | r14261 | |
| 602 | 601 | MCFG_DECO16IC_ADD("tilegen1", dassault_deco16ic_tilegen1_intf) |
| 603 | 602 | MCFG_DECO16IC_ADD("tilegen2", dassault_deco16ic_tilegen2_intf) |
| 604 | 603 | |
| 604 | MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0) | |
| 605 | decospr_device::set_gfx_region(*device, 3); | |
| 606 | ||
| 607 | MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0) | |
| 608 | decospr_device::set_gfx_region(*device, 4); | |
| 609 | ||
| 610 | ||
| 605 | 611 | /* sound hardware */ |
| 606 | 612 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 607 | 613 | |
| r14260 | r14261 | |
| 825 | 831 | |
| 826 | 832 | /**********************************************************************************/ |
| 827 | 833 | |
| 828 | static READ16_HANDLER( dassault_main_skip ) | |
| 829 | { | |
| 830 | dassault_state *state = space->machine().driver_data<dassault_state>(); | |
| 831 | int ret = state->m_ram[0]; | |
| 832 | 834 | |
| 833 | if (cpu_get_previouspc(&space->device()) == 0x1170 && ret & 0x8000) | |
| 834 | device_spin_until_interrupt(&space->device()); | |
| 835 | ||
| 836 | return ret; | |
| 837 | } | |
| 838 | ||
| 839 | static READ16_HANDLER( thndzone_main_skip ) | |
| 840 | { | |
| 841 | dassault_state *state = space->machine().driver_data<dassault_state>(); | |
| 842 | int ret = state->m_ram[0]; | |
| 843 | ||
| 844 | if (cpu_get_pc(&space->device()) == 0x114c && ret & 0x8000) | |
| 845 | device_spin_until_interrupt(&space->device()); | |
| 846 | ||
| 847 | return ret; | |
| 848 | } | |
| 849 | ||
| 850 | 835 | static DRIVER_INIT( dassault ) |
| 851 | 836 | { |
| 852 | 837 | const UINT8 *src = machine.region("gfx1")->base(); |
| r14260 | r14261 | |
| 862 | 847 | memcpy(dst + 0x110000, src + 0x10000, 0x10000); |
| 863 | 848 | |
| 864 | 849 | auto_free(machine, tmp); |
| 865 | ||
| 866 | /* Save time waiting on vblank bit */ | |
| 867 | machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x3f8000, 0x3f8001, FUNC(dassault_main_skip)); | |
| 868 | 850 | } |
| 869 | 851 | |
| 870 | 852 | static DRIVER_INIT( thndzone ) |
| r14260 | r14261 | |
| 882 | 864 | memcpy(dst + 0x110000, src + 0x10000, 0x10000); |
| 883 | 865 | |
| 884 | 866 | auto_free(machine, tmp); |
| 885 | ||
| 886 | /* Save time waiting on vblank bit */ | |
| 887 | machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x3f8000, 0x3f8001, FUNC(thndzone_main_skip)); | |
| 888 | 867 | } |
| 889 | 868 | |
| 890 | 869 | /**********************************************************************************/ |
| r14260 | r14261 | |
|---|---|---|
| 88 | 88 | #include "sound/okim6295.h" |
| 89 | 89 | #include "video/deco16ic.h" |
| 90 | 90 | #include "video/decocomn.h" |
| 91 | #include "video/decospr.h" | |
| 91 | 92 | |
| 92 | 93 | static ADDRESS_MAP_START( boogwing_map, AS_PROGRAM, 16 ) |
| 93 | 94 | AM_RANGE(0x000000, 0x0fffff) AM_ROM |
| r14260 | r14261 | |
| 361 | 362 | MCFG_PALETTE_LENGTH(2048) |
| 362 | 363 | MCFG_GFXDECODE(boogwing) |
| 363 | 364 | |
| 365 | MCFG_VIDEO_START(boogwing) | |
| 366 | ||
| 364 | 367 | MCFG_DECOCOMN_ADD("deco_common", boogwing_decocomn_intf) |
| 365 | 368 | |
| 366 | 369 | MCFG_DECO16IC_ADD("tilegen1", boogwing_deco16ic_tilegen1_intf) |
| 367 | 370 | MCFG_DECO16IC_ADD("tilegen2", boogwing_deco16ic_tilegen2_intf) |
| 368 | 371 | |
| 372 | MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0) | |
| 373 | decospr_device::set_gfx_region(*device, 3); | |
| 374 | ||
| 375 | MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0) | |
| 376 | decospr_device::set_gfx_region(*device, 4); | |
| 377 | ||
| 369 | 378 | /* sound hardware */ |
| 370 | 379 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 371 | 380 |
| r14260 | r14261 | |
|---|---|---|
| 8882 | 8882 | ROM_IGNORE(0x20000) |
| 8883 | 8883 | |
| 8884 | 8884 | ROM_REGION( 0x20000, "fixedbios", 0 ) |
| 8885 | ROM_LOAD( "sfix.sfix", 0x000000, 0x20000, CRC(c2ea0cfd) SHA1(fd4a618cdcdbf849374f0a50dd8efe9dbab706c3) ) | |
| 8885 | ROM_LOAD( "sfix.sfix", 0x000000, 0x20000, CRC(c2ea0cfd) SHA1(fd4a618cdcdbf849374f0a50dd8efe9dbab706c3) ) | |
| 8886 | 8886 | ROM_Y_ZOOM |
| 8887 | 8887 | |
| 8888 | 8888 | NEO_BIOS_AUDIO_512K( "1b.bin", CRC(7b1f86f7) SHA1(15b6af7f9fbd0f1f6a1ecd912200ca8d0af2da2a) ) |
| r14260 | r14261 | |
|---|---|---|
| 101 | 101 | CUSTOM_INPUT( eolith_speedup_getvblank ) |
| 102 | 102 | { |
| 103 | 103 | |
| 104 | // printf("%s:eolith speedup_read data %02x\n",field.machine().describe_context(), eolith_vblank); | |
| 105 | ||
| 104 | // printf("%s:eolith speedup_read data %02x\n",field.machine().describe_context(), eolith_vblank); | |
| 106 | 105 | |
| 106 | ||
| 107 | 107 | return (field.machine().primary_screen->vpos() >= 240); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | // StealSee doesn't use interrupts, just the vblank | |
| 110 | // StealSee doesn't use interrupts, just the vblank | |
| 111 | 111 | CUSTOM_INPUT( stealsee_speedup_getvblank ) |
| 112 | 112 | { |
| 113 | 113 | eolith_state *state = field.machine().driver_data<eolith_state>(); |
| 114 | 114 | |
| 115 | 115 | int pc = cpu_get_pc(state->m_maincpu); |
| 116 | ||
| 116 | ||
| 117 | 117 | if (pc==0x400081ec) |
| 118 | 118 | if(!eolith_vblank) |
| 119 | 119 | device_eat_cycles(state->m_maincpu, 500); |
| 120 | ||
| 120 | ||
| 121 | 121 | return (field.machine().primary_screen->vpos() >= 240); |
| 122 | 122 | } |
| r14260 | r14261 | |
|---|---|---|
| 121 | 121 | |
| 122 | 122 | PORT_START("DSW3") |
| 123 | 123 | PORT_DIPNAME( 0x07, 0x06, "First Bonus" ) PORT_DIPLOCATION("SW3:1,2,3") |
| 124 | // | |
| 124 | // PORT_DIPSETTING( 0x07, "20000" ) // unused | |
| 125 | 125 | PORT_DIPSETTING( 0x06, "20000" ) |
| 126 | 126 | PORT_DIPSETTING( 0x05, "30000" ) |
| 127 | 127 | PORT_DIPSETTING( 0x04, "40000" ) |
| r14260 | r14261 | |
|---|---|---|
| 6 | 6 | Flying Shark details: Carl-Henrik Skarstedt & Magnus Danielsson |
| 7 | 7 | Flying Shark bootleg info: Ruben Panossian |
| 8 | 8 | |
| 9 | Both bootlegs, while sharing a lot of code with the original sets | |
| 10 | are probably based off undumped versions. | |
| 9 | Both bootlegs, while sharing a lot of code with the original sets | |
| 10 | are probably based off undumped versions. | |
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | Supported games: |
| r14260 | r14261 | |
|---|---|---|
| 94 | 94 | Revision information comes from Igrosoft's website, not all of them can be |
| 95 | 95 | tested because some program rom revisions don't seem to be dumped. |
| 96 | 96 | |
| 97 | For sets where the program rom hasn't been verified, the | |
| 97 | For sets where the program rom hasn't been verified, the SHA1 hash is given | |
| 98 | 98 | but not the CRC32 hash. |
| 99 | 99 | |
| 100 | 100 | Banking addresses are likely controlled via a GAL/PAL and was added at some |
| r14260 | r14261 | |
| 1451 | 1451 | ROM_LOAD( "crazymonkey_m.008", 0x380000, 0x80000, CRC(6fdb6fd5) SHA1(f40916112365de258956ec033aff79aae1f58690) ) |
| 1452 | 1452 | ROM_END |
| 1453 | 1453 | |
| 1454 | ROM_START( crzmon_10 ) // 081027 lottery | |
| 1455 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 1456 | ROM_LOAD( "cm_l_081027.rom", 0x00000, 0x40000, SHA1(11a1523bc0ce5cf43534b34201f59784283693f0) ) | |
| 1454 | 1457 | |
| 1458 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 1459 | ROM_LOAD( "crazymonkey_loto.001", 0x000000, 0x80000, SHA1(bf953dc53ec85f4841fe7ada7e480520b3bce1d7) ) | |
| 1460 | ROM_LOAD( "crazymonkey_loto.002", 0x100000, 0x80000, SHA1(57db2212b690a8a92034ba4993526c34cbf48c09) ) | |
| 1461 | ROM_LOAD( "crazymonkey_loto.003", 0x200000, 0x80000, SHA1(4551494b883f8076931bb22fd0541b193039dfdc) ) | |
| 1462 | ROM_LOAD( "crazymonkey_loto.004", 0x300000, 0x80000, SHA1(b33d5007b649661a3d811139c2b40d036863343d) ) | |
| 1463 | ROM_LOAD( "crazymonkey_m.005", 0x080000, 0x80000, CRC(9d4d2a94) SHA1(c714e110de628b343dfc7fff23befaa1276056a9) ) | |
| 1464 | ROM_LOAD( "crazymonkey_m.006", 0x180000, 0x80000, CRC(a15f0fee) SHA1(3f06d5a1a41e1335bcc7586a5ea95b9b734155c0) ) | |
| 1465 | ROM_LOAD( "crazymonkey_m.007", 0x280000, 0x80000, CRC(715a2528) SHA1(6c4c72592568ecbaa9518fb7271d2714dd22dbbb) ) | |
| 1466 | ROM_LOAD( "crazymonkey_m.008", 0x380000, 0x80000, CRC(6fdb6fd5) SHA1(f40916112365de258956ec033aff79aae1f58690) ) | |
| 1467 | ROM_END | |
| 1468 | ||
| 1469 | ROM_START( crzmon_11 ) // 081113 lottery | |
| 1470 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 1471 | ROM_LOAD( "cm_l_081113.rom", 0x00000, 0x40000, SHA1(7196c301691b47a572cefc090888db550f10998c) ) | |
| 1472 | ||
| 1473 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 1474 | ROM_LOAD( "crazymonkey_loto.001", 0x000000, 0x80000, SHA1(bf953dc53ec85f4841fe7ada7e480520b3bce1d7) ) | |
| 1475 | ROM_LOAD( "crazymonkey_loto.002", 0x100000, 0x80000, SHA1(57db2212b690a8a92034ba4993526c34cbf48c09) ) | |
| 1476 | ROM_LOAD( "crazymonkey_loto.003", 0x200000, 0x80000, SHA1(4551494b883f8076931bb22fd0541b193039dfdc) ) | |
| 1477 | ROM_LOAD( "crazymonkey_loto.004", 0x300000, 0x80000, SHA1(b33d5007b649661a3d811139c2b40d036863343d) ) | |
| 1478 | ROM_LOAD( "crazymonkey_m.005", 0x080000, 0x80000, CRC(9d4d2a94) SHA1(c714e110de628b343dfc7fff23befaa1276056a9) ) | |
| 1479 | ROM_LOAD( "crazymonkey_m.006", 0x180000, 0x80000, CRC(a15f0fee) SHA1(3f06d5a1a41e1335bcc7586a5ea95b9b734155c0) ) | |
| 1480 | ROM_LOAD( "crazymonkey_m.007", 0x280000, 0x80000, CRC(715a2528) SHA1(6c4c72592568ecbaa9518fb7271d2714dd22dbbb) ) | |
| 1481 | ROM_LOAD( "crazymonkey_m.008", 0x380000, 0x80000, CRC(6fdb6fd5) SHA1(f40916112365de258956ec033aff79aae1f58690) ) | |
| 1482 | ROM_END | |
| 1483 | ||
| 1455 | 1484 | /********************************************************* |
| 1456 | 1485 | Fruit Cocktail |
| 1457 | 1486 | |
| r14260 | r14261 | |
| 1640 | 1669 | ROM_LOAD( "fruitcocktail.008", 0x380000, 0x80000, CRC(8384e4d4) SHA1(83d0bbbd7cca7328a66a69cf802632fd8d22d5b8) ) |
| 1641 | 1670 | ROM_END |
| 1642 | 1671 | |
| 1672 | ROM_START( fcockt_13 ) // 081124 lottery | |
| 1673 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 1674 | ROM_LOAD( "fc_l_081124.rom", 0x00000, 0x40000, SHA1(896252194f32842f784463668e6416cbfe9687a0) ) | |
| 1643 | 1675 | |
| 1676 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 1677 | ROM_LOAD( "fruitcocktail_loto.001", 0x000000, 0x80000, SHA1(bb2b518dc166836f7cedd4ec443b50687e8927e1) ) /* Only this set is listed as official hashes */ | |
| 1678 | ROM_LOAD( "fruitcocktail_loto.002", 0x100000, 0x80000, SHA1(2621e2644ebec3959c49905c54eb20a83d5a7bd6) ) | |
| 1679 | ROM_LOAD( "fruitcocktail_loto.003", 0x200000, 0x80000, SHA1(ffe11deef6b3b86b4b78e2e4d96c30f820e77971) ) | |
| 1680 | ROM_LOAD( "fruitcocktail_loto.004", 0x300000, 0x80000, SHA1(fa88d113721ce7c0b3418614cd6bb974c20df644) ) | |
| 1681 | ROM_LOAD( "fruitcocktail_m.005", 0x080000, 0x80000, CRC(f0176b60) SHA1(f764aea00ed306a28cacc62f8d2db9cc42895db8) ) | |
| 1682 | ROM_LOAD( "fruitcocktail_m.006", 0x180000, 0x80000, CRC(ef24f255) SHA1(6ff924627c179868a25f180f79cd57182b72d9d4) ) | |
| 1683 | ROM_LOAD( "fruitcocktail_m.007", 0x280000, 0x80000, CRC(20f87a15) SHA1(cb60866a3543668f3592c270b445dee881d78128) ) | |
| 1684 | ROM_LOAD( "fruitcocktail_m.008", 0x380000, 0x80000, CRC(d282e42e) SHA1(eac9c3eaef39b1805f863ade5da47d6274d20a55) ) | |
| 1685 | ROM_END | |
| 1686 | ||
| 1644 | 1687 | /********************************************************* |
| 1645 | 1688 | Lucky Haunter |
| 1646 | 1689 | |
| r14260 | r14261 | |
| 1769 | 1812 | ROM_LOAD( "luckyhaunter_m.008", 0x380000, 0x80000, CRC(1bdf6252) SHA1(7b5ae82a95a744b236e109024d47b526dccf9c14) ) |
| 1770 | 1813 | ROM_END |
| 1771 | 1814 | |
| 1815 | ROM_START( lhaunt_9 ) // 081208 lottery | |
| 1816 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 1817 | ROM_LOAD( "lh_l_081208.rom", 0x00000, 0x40000, SHA1(4962bfc9c3aadd45fdb30bb159aaaed463e4d06b) ) | |
| 1772 | 1818 | |
| 1819 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 1820 | ROM_LOAD( "luckyhaunter_loto.001", 0x000000, 0x80000, SHA1(961f832654f2cdb844e36a1a9034b87b5e3750f5) ) | |
| 1821 | ROM_LOAD( "luckyhaunter_loto.002", 0x100000, 0x80000, SHA1(20ac980f4f8b502773845d2e1350b960ea707d83) ) | |
| 1822 | ROM_LOAD( "luckyhaunter_loto.003", 0x200000, 0x80000, SHA1(e4cf08104e7717d9706105ad52ade6bf9a782d76) ) | |
| 1823 | ROM_LOAD( "luckyhaunter_loto.004", 0x300000, 0x80000, SHA1(ceb4a5e9912f5d98483cb75e871c925dffbb8e72) ) | |
| 1824 | ROM_LOAD( "luckyhaunter_m.005", 0x080000, 0x80000, CRC(b50c90a3) SHA1(74749f4ffb5b0630631b511fc3230c6e7b50dc3b) ) | |
| 1825 | ROM_LOAD( "luckyhaunter_m.006", 0x180000, 0x80000, CRC(4eaaab64) SHA1(9fed16f8e0308200fd16c4b1e511e1bf6c22ae66) ) | |
| 1826 | ROM_LOAD( "luckyhaunter_m.007", 0x280000, 0x80000, CRC(64d16ba9) SHA1(3b897183d6e0f1256be7657441f234fc72077682) ) | |
| 1827 | ROM_LOAD( "luckyhaunter_m.008", 0x380000, 0x80000, CRC(1bdf6252) SHA1(7b5ae82a95a744b236e109024d47b526dccf9c14) ) | |
| 1828 | ROM_END | |
| 1829 | ||
| 1773 | 1830 | /********************************************************* |
| 1774 | 1831 | Garage |
| 1775 | 1832 | |
| r14260 | r14261 | |
| 1883 | 1940 | ROM_LOAD( "garage_m.008", 0x380000, 0x80000, CRC(90c5416b) SHA1(583bfb517bc2e30d7b7903aa19fc3b4b5188d7d2) ) |
| 1884 | 1941 | ROM_END |
| 1885 | 1942 | |
| 1943 | ROM_START( garage_8 ) // 081229 lottery | |
| 1944 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 1945 | ROM_LOAD( "gg_l_081229.rom", 0x00000, 0x40000, SHA1(6bc22aeb6d8d5ffbc556d9056a25e6506bb8f118) ) | |
| 1886 | 1946 | |
| 1947 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 1948 | ROM_LOAD( "garage_loto.001", 0x000000, 0x80000, SHA1(50de46c4ae28f70c96da03391446cca0cb91f43b) ) | |
| 1949 | ROM_LOAD( "garage_loto.002", 0x100000, 0x80000, SHA1(df5c1684f1a29f77a3fa79b35a9a0b9371c1b8a3) ) | |
| 1950 | ROM_LOAD( "garage_loto.003", 0x200000, 0x80000, SHA1(47e81aa034c1ac717b1715c521cbaa8ff4d336c5) ) | |
| 1951 | ROM_LOAD( "garage_loto.004", 0x300000, 0x80000, SHA1(71dbcd71ee5bddeda77a012c243981e0960e0c9e) ) | |
| 1952 | ROM_LOAD( "garage_m.005", 0x080000, 0x80000, CRC(5bf85bc5) SHA1(ff9d2b9cbcd2af6f5fda972e387820d830c196a9) ) | |
| 1953 | ROM_LOAD( "garage_m.006", 0x180000, 0x80000, CRC(e5082b26) SHA1(6547409d39dd51498ce8e3f82ff813a8ac3c6522) ) | |
| 1954 | ROM_LOAD( "garage_m.007", 0x280000, 0x80000, CRC(dfa2ceb1) SHA1(ec7de8a8f6e7785a563df973841cc1f1603f79fc) ) | |
| 1955 | ROM_LOAD( "garage_m.008", 0x380000, 0x80000, CRC(90c5416b) SHA1(583bfb517bc2e30d7b7903aa19fc3b4b5188d7d2) ) | |
| 1956 | ROM_END | |
| 1887 | 1957 | |
| 1888 | 1958 | /********************************************************* |
| 1889 | 1959 | Rock Climber |
| r14260 | r14261 | |
| 2499 | 2569 | ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) ) |
| 2500 | 2570 | ROM_END |
| 2501 | 2571 | |
| 2572 | ROM_START( fcockt2_2 ) // 080904 | |
| 2573 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 2574 | ROM_LOAD( "fc2_080904.rom", 0x00000, 0x40000, SHA1(d8f1034753274aed874ee552ab78e660ddaba939) ) | |
| 2502 | 2575 | |
| 2576 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 2577 | ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) ) | |
| 2578 | ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) ) | |
| 2579 | ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) ) | |
| 2580 | ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) ) | |
| 2581 | ROM_LOAD( "fruitcocktail2_old.005", 0x080000, 0x80000, CRC(6b9e6b43) SHA1(c7fb17e91ec62b22da42f110d68b4f37e39de3ce) ) | |
| 2582 | ROM_LOAD( "fruitcocktail2_old.006", 0x180000, 0x80000, CRC(2c9f712e) SHA1(c3118154eafca74b66b3325a2e07c85f86f3544d) ) | |
| 2583 | ROM_LOAD( "fruitcocktail2_old.007", 0x280000, 0x80000, CRC(85ba9a86) SHA1(aa9b6170135e9e420509e8f7c1702c9896bc5d8e) ) | |
| 2584 | ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) ) | |
| 2585 | ROM_END | |
| 2586 | ||
| 2587 | ROM_START( fcockt2_3 ) // 080909 | |
| 2588 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 2589 | ROM_LOAD( "fc2_m_080909.rom", 0x00000, 0x40000, CRC(6de0353c) SHA1(7a827a172cdd593f8b37a7737304a5a2e145d52d) ) | |
| 2590 | ||
| 2591 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 2592 | ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) ) | |
| 2593 | ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) ) | |
| 2594 | ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) ) | |
| 2595 | ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) ) | |
| 2596 | ROM_LOAD( "fruitcocktail2_old.005", 0x080000, 0x80000, CRC(6b9e6b43) SHA1(c7fb17e91ec62b22da42f110d68b4f37e39de3ce) ) | |
| 2597 | ROM_LOAD( "fruitcocktail2_old.006", 0x180000, 0x80000, CRC(2c9f712e) SHA1(c3118154eafca74b66b3325a2e07c85f86f3544d) ) | |
| 2598 | ROM_LOAD( "fruitcocktail2_old.007", 0x280000, 0x80000, CRC(85ba9a86) SHA1(aa9b6170135e9e420509e8f7c1702c9896bc5d8e) ) | |
| 2599 | ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) ) | |
| 2600 | ROM_END | |
| 2601 | ||
| 2602 | ROM_START( fcockt2_4 ) // 081105 | |
| 2603 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 2604 | ROM_LOAD( "fc2_m_081105.rom", 0x00000, 0x40000, CRC(2cc5313d) SHA1(b5e55acbb5936f49130758947ae22d1847800333) ) | |
| 2605 | ||
| 2606 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 2607 | ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) ) | |
| 2608 | ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) ) | |
| 2609 | ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) ) | |
| 2610 | ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) ) | |
| 2611 | ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) ) | |
| 2612 | ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) ) | |
| 2613 | ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) ) | |
| 2614 | ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) ) | |
| 2615 | ROM_END | |
| 2616 | ||
| 2617 | ROM_START( fcockt2_5 ) // 081106 | |
| 2618 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 2619 | ROM_LOAD( "fc2_081106.rom", 0x00000, 0x40000, CRC(d23347b3) SHA1(2d7d00af182c61fa166a8f3fd6fd830cf5eb78c6) ) | |
| 2620 | ||
| 2621 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 2622 | ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) ) | |
| 2623 | ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) ) | |
| 2624 | ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) ) | |
| 2625 | ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) ) | |
| 2626 | ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) ) | |
| 2627 | ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) ) | |
| 2628 | ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) ) | |
| 2629 | ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) ) | |
| 2630 | ROM_END | |
| 2631 | ||
| 2503 | 2632 | /********************************************************* |
| 2504 | 2633 | Crazy Monkey 2 |
| 2505 | 2634 | **********************************************************/ |
| r14260 | r14261 | |
| 2561 | 2690 | */ |
| 2562 | 2691 | |
| 2563 | 2692 | |
| 2564 | #define mfish_parent mfish_3 | |
| 2693 | #define mfish_parent mfish_13 | |
| 2565 | 2694 | GAME( 2002, goldfish, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Gold Fish (020903, prototype)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2566 | 2695 | //GAME( 2002, mfish, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (021120)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2567 | 2696 | //GAME( 2002, mfish_2, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (021121)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2568 | GAME( 2002, mfish_3, | |
| 2697 | GAME( 2002, mfish_3, mfish_parent, | |
| 2569 | 2698 | //GAME( 2002, mfish_4, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (021219)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2570 | 2699 | //GAME( 2002, mfish_5, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (021227)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2571 | 2700 | GAME( 2002, mfish_6, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (030124)", GAME_SUPPORTS_SAVE ) /* World */ |
| r14260 | r14261 | |
| 2575 | 2704 | //GAME( 2002, mfish_10, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (031117)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2576 | 2705 | GAME( 2002, mfish_11, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (031124)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2577 | 2706 | GAME( 2002, mfish_12, mfish_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Multi Fish (040308)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2578 | GAME( 2002, mfish_13, | |
| 2707 | GAME( 2002, mfish_13, 0 | |
| 2579 | 2708 | |
| 2580 | #define crzmon_parent crzmon_ | |
| 2709 | #define crzmon_parent crzmon_8 | |
| 2581 | 2710 | //GAME( 2003, crzmon, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (030217 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2582 | 2711 | //GAME( 2003, crzmon_2, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (030225 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2583 | 2712 | //GAME( 2003, crzmon_3, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (030227 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2584 | 2713 | //GAME( 2003, crzmon_4, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (030404 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2585 | GAME( 2003, crzmon_5, | |
| 2714 | GAME( 2003, crzmon_5, crzmon_parent, | |
| 2586 | 2715 | //GAME( 2003, crzmon_6, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (031016 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2587 | 2716 | GAME( 2003, crzmon_7, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (031110 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2588 | GAME( 2003, crzmon_8, | |
| 2717 | GAME( 2003, crzmon_8, 0 | |
| 2589 | 2718 | GAME( 2003, crzmon_9, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (070315 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2719 | //GAME( 2003, crzmon_10, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (081027 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */ | |
| 2720 | //GAME( 2003, crzmon_11, crzmon_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Crazy Monkey (081113 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */ | |
| 2590 | 2721 | |
| 2591 | 2722 | |
| 2592 | #define fcockt_parent fcockt_ | |
| 2723 | #define fcockt_parent fcockt_8 | |
| 2593 | 2724 | //GAME( 2003, fcockt, fcockt_parent multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (030505 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2594 | 2725 | //GAME( 2003, fcockt_2, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (030512 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2595 | GAME( 2003, fcockt_3, | |
| 2726 | GAME( 2003, fcockt_3, fcockt_parent, | |
| 2596 | 2727 | //GAME( 2003, fcockt_4, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (031028 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2597 | 2728 | GAME( 2003, fcockt_5, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (031111 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2598 | 2729 | GAME( 2003, fcockt_6, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (040216 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2599 | 2730 | GAME( 2003, fcockt_7, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (050118 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2600 | GAME( 2003, fcockt_8, | |
| 2731 | GAME( 2003, fcockt_8, 0 | |
| 2601 | 2732 | GAME( 2003, fcockt_9, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (070305 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2602 | 2733 | GAME( 2003, fcockt_10, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (070517 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2603 | 2734 | GAME( 2003, fcockt_11, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (070822 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2604 | 2735 | GAME( 2003, fcockt_12, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (070911 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2736 | //GAME( 2003, fcockt_13, fcockt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail (081124 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */ | |
| 2605 | 2737 | |
| 2606 | #define lhaunt_parent lhaunt_ | |
| 2738 | #define lhaunt_parent lhaunt_6 | |
| 2607 | 2739 | //GAME( 2003, lhaunt, lhaunt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Lucky Haunter (030707 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2608 | GAME( 2003, lhaunt_2, | |
| 2740 | GAME( 2003, lhaunt_2, lhaunt_parent, | |
| 2609 | 2741 | //GAME( 2003, lhaunt_3, lhaunt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Lucky Haunter (031027 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2610 | 2742 | GAME( 2003, lhaunt_4, lhaunt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Lucky Haunter (031111 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2611 | 2743 | GAME( 2003, lhaunt_5, lhaunt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Lucky Haunter (040216 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2612 | GAME( 2003, lhaunt_6, | |
| 2744 | GAME( 2003, lhaunt_6, 0 | |
| 2613 | 2745 | GAME( 2003, lhaunt_7, lhaunt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Lucky Haunter (070402 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2614 | 2746 | GAME( 2003, lhaunt_8, lhaunt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Lucky Haunter (070604 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2747 | //GAME( 2003, lhaunt_9, lhaunt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Lucky Haunter (081208 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */ | |
| 2615 | 2748 | |
| 2616 | 2749 | |
| 2617 | #define rollfr_parent rollfr_ | |
| 2750 | #define rollfr_parent rollfr_4 | |
| 2618 | 2751 | //GAME( 2003, rollfr, rollfr_parent, rollfr, rollfr, 0, ROT0, "Igrosoft", "Roll Fruit (030821)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2619 | GAME( 2003, rollfr_2, | |
| 2752 | GAME( 2003, rollfr_2, rollfr_parent, | |
| 2620 | 2753 | GAME( 2003, rollfr_3, rollfr_parent, rollfr, rollfr, 0, ROT0, "Igrosoft", "Roll Fruit (080327)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2621 | GAME( 2003, rollfr_4, | |
| 2754 | GAME( 2003, rollfr_4, 0 | |
| 2622 | 2755 | |
| 2623 | #define garage_parent garage_ | |
| 2756 | #define garage_parent garage_5 | |
| 2624 | 2757 | //GAME( 2004, garage, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (040122 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2625 | 2758 | //GAME( 2004, garage_2, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (040123 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2626 | 2759 | //GAME( 2004, garage_3, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (040216 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2627 | GAME( 2004, garage_4, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (040219 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2628 | GAME( 2004, garage_5, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (050311 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2760 | GAME( 2004, garage_4, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (040219 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2761 | GAME( 2004, garage_5, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (050311 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2629 | 2762 | GAME( 2004, garage_6, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (070213 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2630 | 2763 | GAME( 2004, garage_7, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (070329 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2764 | //GAME( 2004, garage_8, garage_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Garage (081229 Lottery)", GAME_SUPPORTS_SAVE ) /* Lottery */ | |
| 2631 | 2765 | |
| 2632 | 2766 | |
| 2633 | #define rclimb_parent rclimb | |
| 2634 | GAME( 2004, rclimb, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Rock Climber (040815 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2767 | #define rclimb_parent rclimb_3 | |
| 2768 | GAME( 2004, rclimb, rclimb_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Rock Climber (040815 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2635 | 2769 | //GAME( 2004, rclimb_2, rclimb_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Rock Climber (040823 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2636 | GAME( 2004, rclimb_3, | |
| 2770 | GAME( 2004, rclimb_3, 0 | |
| 2637 | 2771 | GAME( 2004, rclimb_4, rclimb_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Rock Climber (070322 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2638 | 2772 | GAME( 2004, rclimb_5, rclimb_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Rock Climber (070621 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2639 | 2773 | |
| r14260 | r14261 | |
| 2642 | 2776 | GAME( 2004, sweetl, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Sweet Life (041220 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2643 | 2777 | GAME( 2004, sweetl_2, sweetl_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Sweet Life (070412 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2644 | 2778 | |
| 2645 | #define resdnt_parent resdnt | |
| 2646 | GAME( 2004, resdnt, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Resident (040415 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2647 | GAME( 2004, resdnt_2, resdnt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Resident (040513 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2779 | #define resdnt_parent resdnt_2 | |
| 2780 | GAME( 2004, resdnt, resdnt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Resident (040415 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2781 | GAME( 2004, resdnt_2, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Resident (040513 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2648 | 2782 | GAME( 2004, resdnt_3, resdnt_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Resident (070222 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2649 | 2783 | |
| 2650 | 2784 | |
| r14260 | r14261 | |
| 2652 | 2786 | GAME( 2005, island, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Island (050713 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2653 | 2787 | GAME( 2005, island_2, island_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Island (070409 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2654 | 2788 | |
| 2655 | #define pirate_parent pirate_ | |
| 2789 | #define pirate_parent pirate_3 | |
| 2656 | 2790 | //GAME( 2005, pirate, pirate_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Pirate (051229 World)", GAME_SUPPORTS_SAVE ) /* World */ |
| 2657 | GAME( 2005, pirate_2, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Pirate (060210 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2658 | GAME( 2005, pirate_3, pirate_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Pirate (060803 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2791 | GAME( 2005, pirate_2, pirate_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Pirate (060210 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2792 | GAME( 2005, pirate_3, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Pirate (060803 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2659 | 2793 | GAME( 2005, pirate_4, pirate_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Pirate (070412 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2660 | 2794 | |
| 2661 | 2795 | #define island2_parent island2 |
| r14260 | r14261 | |
| 2670 | 2804 | GAME( 2006, pirate2_2, pirate2_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Pirate 2 (070126 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2671 | 2805 | |
| 2672 | 2806 | |
| 2673 | #define keks_parent keks | |
| 2674 | GAME( 2006, keks, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Keks (060328 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2675 | GAME( 2006, keks_2, keks_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Keks (060403 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2807 | #define keks_parent keks_2 | |
| 2808 | GAME( 2006, keks, keks_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Keks (060328 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2809 | GAME( 2006, keks_2, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Keks (060403 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2676 | 2810 | GAME( 2006, keks_3, keks_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Keks (070119 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2677 | 2811 | |
| 2678 | 2812 | |
| 2679 | #define gnome_parent gnome | |
| 2680 | GAME( 2007, gnome, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Gnome (070906 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ | |
| 2813 | #define gnome_parent gnome_3 | |
| 2814 | GAME( 2007, gnome, gnome_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Gnome (070906 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ | |
| 2681 | 2815 | GAME( 2007, gnome_2, gnome_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Gnome (071115 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2682 | GAME( 2007, gnome_3, | |
| 2816 | GAME( 2007, gnome_3, 0 | |
| 2683 | 2817 | |
| 2684 | 2818 | |
| 2685 | 2819 | #define sweetl2_parent sweetl2 |
| r14260 | r14261 | |
| 2688 | 2822 | |
| 2689 | 2823 | #define fcockt2_parent fcockt2 |
| 2690 | 2824 | GAME( 2008, fcockt2, 0, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail 2 (080707 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ |
| 2825 | //GAME( 2008, fcockt2_2, fcockt2_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail 2 (080904 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ | |
| 2826 | GAME( 2008, fcockt2_3, fcockt2_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail 2 (080909 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2827 | GAME( 2008, fcockt2_4, fcockt2_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail 2 (081105 World)", GAME_SUPPORTS_SAVE ) /* World */ | |
| 2828 | GAME( 2008, fcockt2_5, fcockt2_parent, multfish, multfish, 0, ROT0, "Igrosoft", "Fruit Cocktail 2 (081106 Russia)", GAME_SUPPORTS_SAVE ) /* Russia */ | |
| 2691 | 2829 | |
| 2692 | 2830 | |
| 2693 | 2831 | |
| r14260 | r14261 | |
| 4233 | 4371 | ROM_LOAD( "fruitcocktail2_old.008", 0x380000, 0x80000, CRC(a27c49a2) SHA1(7c9ee0e01f76ca3ab6716579f5dde7036050970b) ) |
| 4234 | 4372 | ROM_END |
| 4235 | 4373 | |
| 4374 | ROM_START( fcockt2_4a ) // 081105 bank F9 | |
| 4375 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 4376 | ROM_LOAD( "bootleg_fc2_m_081105a.rom", 0x00000, 0x40000, CRC(411ad706) SHA1(4d29a6b1927241efdcdb3224b9ebe0eb6af92533) ) /* Not officially listed on Igrosoft's web site hash page */ | |
| 4236 | 4377 | |
| 4378 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 4379 | ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) ) | |
| 4380 | ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) ) | |
| 4381 | ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) ) | |
| 4382 | ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) ) | |
| 4383 | ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) ) | |
| 4384 | ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) ) | |
| 4385 | ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) ) | |
| 4386 | ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) ) | |
| 4387 | ROM_END | |
| 4388 | ||
| 4389 | ROM_START( fcockt2_4b ) // 081105 bank F9, no credit limit, "MaxVin" signature | |
| 4390 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 4391 | ROM_LOAD( "bootleg_fc2_m_081105_cm.rom", 0x00000, 0x40000, CRC(f0c702b9) SHA1(89121ddd325aac567ebd443eb443c4db0549236c) ) /* Not officially listed on Igrosoft's web site hash page */ | |
| 4392 | ||
| 4393 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 4394 | ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) ) | |
| 4395 | ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) ) | |
| 4396 | ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) ) | |
| 4397 | ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) ) | |
| 4398 | ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) ) | |
| 4399 | ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) ) | |
| 4400 | ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) ) | |
| 4401 | ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) ) | |
| 4402 | ROM_END | |
| 4403 | ||
| 4404 | ROM_START( fcockt2_4c ) // 081105 custom alteras, modified graphics, bank F9, many texts changed, changed version text to "VIDEO GAME-1 FR02" | |
| 4405 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 4406 | ROM_LOAD( "bootleg_fc2_m_081105b.rom", 0x00000, 0x40000, CRC(b627f7d6) SHA1(0bcdb1cd808055d0a9e965f2c6ff522ac3fe6949) ) /* Not officially listed on Igrosoft's web site hash page */ | |
| 4407 | ||
| 4408 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 4409 | ROM_LOAD( "bootleg_1b", 0x000000, 0x80000, CRC(68b62355) SHA1(387da330fddaa685cb7aca32bf861e44d5cdbe58) ) | |
| 4410 | ROM_LOAD( "bootleg_2b", 0x100000, 0x80000, CRC(d36e8704) SHA1(80a84a24b3a43a0110a00ed3b01c7156218ccbf3) ) | |
| 4411 | ROM_LOAD( "bootleg_3b", 0x200000, 0x80000, CRC(57d87c5b) SHA1(6bc28e5c34a7e76d0e601b970ab922e5ad28ae85) ) | |
| 4412 | ROM_LOAD( "bootleg_4b", 0x300000, 0x80000, CRC(3de30bab) SHA1(c4c4c549ad980f562238054cd0e3ef6b0977f7b7) ) | |
| 4413 | ROM_LOAD( "bootleg_5b", 0x080000, 0x80000, CRC(b47d65aa) SHA1(71c642ea7887ea35c6d7d985502082d2424c035a) ) | |
| 4414 | ROM_LOAD( "bootleg_6b", 0x180000, 0x80000, CRC(aa982f4e) SHA1(edf75d4ddd60532ac0ca2e17e3fd9004aa768973) ) | |
| 4415 | ROM_LOAD( "bootleg_7b", 0x280000, 0x80000, CRC(b9b1ead7) SHA1(111e505fce8fe75043ff7cc5dc68e81ce4f98d06) ) | |
| 4416 | ROM_LOAD( "bootleg_8b", 0x380000, 0x80000, CRC(8e49d1c1) SHA1(4735503335cf499895d1b2d9a405be50f21a2d68) ) | |
| 4417 | ROM_END | |
| 4418 | ||
| 4419 | ROM_START( fcockt2_4d ) // 081105 bank F9, no credit limit, "MaxVin" signature, payout percentage 70% | |
| 4420 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 4421 | ROM_LOAD( "bootleg_fc2_m_081105c.rom", 0x00000, 0x40000, CRC(b6d88fcc) SHA1(337a59accfbc229be05aff84ba70fc135fde09de) ) /* Not officially listed on Igrosoft's web site hash page */ | |
| 4422 | ||
| 4423 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 4424 | ROM_LOAD( "fruitcocktail2.001", 0x000000, 0x80000, CRC(d1b9416d) SHA1(4d3cb0a6dbcf02bbd20d5c43df358882b2ad794d) ) | |
| 4425 | ROM_LOAD( "fruitcocktail2.002", 0x100000, 0x80000, CRC(69236be1) SHA1(9a2e6c8f279714f79a606c0b118b6bf1d8442cda) ) | |
| 4426 | ROM_LOAD( "fruitcocktail2.003", 0x200000, 0x80000, CRC(29aade8c) SHA1(bef42f8a25c90e3a1cccd13872a10eb8b2b2e276) ) | |
| 4427 | ROM_LOAD( "fruitcocktail2.004", 0x300000, 0x80000, CRC(4b9646e7) SHA1(26548a018401f4e07383eb145f8f0847677f3272) ) | |
| 4428 | ROM_LOAD( "fruitcocktail2.005", 0x080000, 0x80000, CRC(3fc13d72) SHA1(ba0727138ef03d576d190cbce04b9eb0bba88a9a) ) | |
| 4429 | ROM_LOAD( "fruitcocktail2.006", 0x180000, 0x80000, CRC(8fc75fd7) SHA1(3b7cd8a3e04ca9d4494b37c801e21d1293f094e8) ) | |
| 4430 | ROM_LOAD( "fruitcocktail2.007", 0x280000, 0x80000, CRC(d37fcc0f) SHA1(57c2ea5dc747f16e2233305f2c73cb4b632aae2c) ) | |
| 4431 | ROM_LOAD( "fruitcocktail2.008", 0x380000, 0x80000, CRC(e3a9442c) SHA1(cbaba182e858b0f158756118e5da873e3ddfc0b9) ) | |
| 4432 | ROM_END | |
| 4433 | ||
| 4434 | ROM_START( fcockt2_4e ) // 081105 bank F9, modified graphics, changed version text to "MDS_is_the_best_ LOTTOGAME (I)" | |
| 4435 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 4436 | ROM_LOAD( "bootleg_fc2_m_081105d.rom", 0x00000, 0x40000, CRC(37b1a159) SHA1(52c8e825ebb85a59803a6d14c766892e56a72c9e) ) /* Not officially listed on Igrosoft's web site hash page */ | |
| 4437 | ||
| 4438 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 4439 | ROM_LOAD( "bootleg_1c", 0x000000, 0x80000, CRC(9fe02e19) SHA1(dec48a0990d2341ae86a3a4acd5972844b93fccb) ) | |
| 4440 | ROM_LOAD( "bootleg_2c", 0x100000, 0x80000, CRC(734bd656) SHA1(e44124fd60675cfc8319bca5bbd90f99d73f4896) ) | |
| 4441 | ROM_LOAD( "bootleg_3c", 0x200000, 0x80000, CRC(36ff74dc) SHA1(7df93e4fa1c240adf33ef910efb8397abfa1a106) ) | |
| 4442 | ROM_LOAD( "bootleg_4c", 0x300000, 0x80000, CRC(b88356c9) SHA1(fbdcfc0d30f2a9b1364863d7a06b32f94113e865) ) | |
| 4443 | ROM_LOAD( "bootleg_5c", 0x080000, 0x80000, CRC(14053302) SHA1(adf0a1493074d16797e8d19dc98f2d5d2cb26e43) ) | |
| 4444 | ROM_LOAD( "bootleg_6c", 0x180000, 0x80000, CRC(21a91970) SHA1(6f4832c743469171cd0efe4554f243c4bed21e88) ) | |
| 4445 | ROM_LOAD( "bootleg_7c", 0x280000, 0x80000, CRC(3a8a7340) SHA1(9408791686926dd13216352ffcb04ad9f8954b3e) ) | |
| 4446 | ROM_LOAD( "bootleg_8c", 0x380000, 0x80000, CRC(fbf48ebd) SHA1(04917e613d9a3f0caeab71c78b9f77c4b5b84988) ) | |
| 4447 | ROM_END | |
| 4448 | ||
| 4449 | ROM_START( fcockt2_4f ) // 081105 custom alteras, modified graphics, bank F9, many texts changed, changed version text to "LOTOS FR02" | |
| 4450 | ROM_REGION( 0x40000, "maincpu", 0 ) // z80 code, banked | |
| 4451 | ROM_LOAD( "bootleg_fc2_m_081105f.rom", 0x00000, 0x40000, CRC(b4fa0663) SHA1(aee3cb980fc7d9fbba1a4e9fe80e6be8df58bb3b) ) /* Not officially listed on Igrosoft's web site hash page */ | |
| 4452 | ||
| 4453 | ROM_REGION( 0x400000, "gfx", 0 ) | |
| 4454 | ROM_LOAD( "bootleg_1e", 0x000000, 0x80000, CRC(3c72a5e2) SHA1(15e07d64a0d633ccdadea9eb55556e6aa239c0e5) ) | |
| 4455 | ROM_LOAD( "bootleg_2e", 0x100000, 0x80000, CRC(017a61f7) SHA1(023cec2be1cfe885c562415d18fc32edf3c61346) ) | |
| 4456 | ROM_LOAD( "bootleg_3e", 0x200000, 0x80000, CRC(8ea5532f) SHA1(498991cfb7a92c3a6342e824a310c7edc5577cff) ) | |
| 4457 | ROM_LOAD( "bootleg_4e", 0x300000, 0x80000, CRC(c879025f) SHA1(93f77787ded2a4353320dcb9d4d1b1f5dd7a3b13) ) | |
| 4458 | ROM_LOAD( "bootleg_5b", 0x080000, 0x80000, CRC(b47d65aa) SHA1(71c642ea7887ea35c6d7d985502082d2424c035a) ) | |
| 4459 | ROM_LOAD( "bootleg_6b", 0x180000, 0x80000, CRC(aa982f4e) SHA1(edf75d4ddd60532ac0ca2e17e3fd9004aa768973) ) | |
| 4460 | ROM_LOAD( "bootleg_7b", 0x280000, 0x80000, CRC(b9b1ead7) SHA1(111e505fce8fe75043ff7cc5dc68e81ce4f98d06) ) | |
| 4461 | ROM_LOAD( "bootleg_8b", 0x380000, 0x80000, CRC(8e49d1c1) SHA1(4735503335cf499895d1b2d9a405be50f21a2d68) ) | |
| 4462 | ROM_END | |
| 4463 | ||
| 4464 | ||
| 4237 | 4465 | GAME( 2002, mfish_3a, mfish_parent, multfish, multfish, 0, ROT0, "bootleg", "Multi Fish (bootleg, 021124, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9 |
| 4238 | 4466 | GAME( 2002, mfish_12a, mfish_parent, multfish, multfish, 0, ROT0, "bootleg", "Multi Fish (bootleg, 040308, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9 |
| 4239 | 4467 | |
| r14260 | r14261 | |
| 4348 | 4576 | GAME( 2007, sweetl2_2d, sweetl2_parent, multfish, multfish, 0, ROT0, "bootleg", "Sweet Life 2 (bootleg, 080320, LOTTOGAME (I))", GAME_SUPPORTS_SAVE ) // bank F9, modified graphics, changed version text to "MDS_is_the_best_ LOTTOGAME (I)" |
| 4349 | 4577 | |
| 4350 | 4578 | GAME( 2008, fcockt2a, fcockt2_parent, multfish, multfish, 0, ROT0, "bootleg", "Fruit Cocktail 2 (bootleg, 080707, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9 |
| 4579 | GAME( 2008, fcockt2_4a, fcockt2_parent, multfish, multfish, 0, ROT0, "bootleg", "Fruit Cocktail 2 (bootleg, 081105, banking address hack)", GAME_SUPPORTS_SAVE ) // bank F9 | |
| 4580 | GAME( 2008, fcockt2_4b, fcockt2_parent, multfish, multfish, 0, ROT0, "bootleg", "Fruit Cocktail 2 (bootleg, 081105, banking address hack, no credit limit)", GAME_SUPPORTS_SAVE ) // bank F9, no credit limit, "MaxVin" signature | |
| 4581 | GAME( 2008, fcockt2_4c, fcockt2_parent, multfish, multfish, customl, ROT0, "bootleg", "Fruit Cocktail 2 (bootleg, 081105, VIDEO GAME-1 FR02)", GAME_SUPPORTS_SAVE ) // custom alteras, modified graphics, bank F9, many texts changed, changed version text to "VIDEO GAME-1 FR02" | |
| 4582 | GAME( 2008, fcockt2_4d, fcockt2_parent, multfish, multfish, 0, ROT0, "bootleg", "Fruit Cocktail 2 (bootleg, 081105, banking address hack, payout percentage 70)", GAME_SUPPORTS_SAVE ) // bank F9, no credit limit, "MaxVin" signature, payout percentage 70% | |
| 4583 | GAME( 2008, fcockt2_4e, fcockt2_parent, multfish, multfish, 0, ROT0, "bootleg", "Fruit Cocktail 2 (bootleg, 081105, LOTTOGAME (I))", GAME_SUPPORTS_SAVE ) // bank F9, modified graphics, changed version text to "MDS_is_the_best_ LOTTOGAME (I)" | |
| 4584 | GAME( 2008, fcockt2_4f, fcockt2_parent, multfish, multfish, customl, ROT0, "bootleg", "Fruit Cocktail 2 (bootleg, 081105, LOTOS FR02)", GAME_SUPPORTS_SAVE ) // custom alteras, modified graphics, bank F9, many texts changed, changed version text to "LOTOS FR02" | |
| 4351 | 4585 | |
| 4352 | 4586 | |
| 4353 | 4587 | /* 0x000000 - 0x03ffff Crazy Monkey V03-1110 |
| r14260 | r14261 | |
|---|---|---|
| 2 | 2 | (c) 2000 - Bao Ma Technology Co., LTD |
| 3 | 3 | |
| 4 | 4 | |-----------------------------------------| |
| 5 | | DIP2 DIP4 UM3567(YM2413) |J | |
| 6 | | DIP1 DIP3 |A | |
| 5 | | DIP2 DIP4 UM3567(YM2413) |J | |
| 6 | | DIP1 DIP3 |A | |
| 7 | 7 | | TA-A-901 |M |
| 8 | | EN-A-701 EN-A-801 U6295(OKI) |M | |
| 8 | | EN-A-701 EN-A-801 U6295(OKI) |M | |
| 9 | 9 | | EN-A-501 EN-A-601 |A |
| 10 | 10 | | EN-A-301 EN-A-401 | |
| 11 | 11 | | |C |
| 12 | 12 | | AIA90610 |O |
| 13 | 13 | | BMC-68pin AIA90423 |N |
| 14 | | plcc (68k) BMC-160pin |N | |
| 15 | | |E | |
| 14 | | plcc (68k) BMC-160pin |N | |
| 15 | | |E | |
| 16 | 16 | | OSC |C |
| 17 | | 42.000 |T | |
| 17 | | 42.000 |T | |
| 18 | 18 | |-----------------------------------------| |
| 19 | 19 | |
| 20 | 20 | 1 - BMC AIA90423 - 160-Pin ASIC, FGPA, Video? |
| r14260 | r14261 | |
| 111 | 111 | static ADDRESS_MAP_START( popobear_mem, AS_PROGRAM, 16 ) |
| 112 | 112 | AM_RANGE(0x000000, 0x03ffff) AM_ROM |
| 113 | 113 | AM_RANGE(0x210000, 0x21ffff) AM_RAM |
| 114 | AM_RANGE(0x3E0000, 0x3EFFFF) AM_RAM AM_BASE_MEMBER(popobear_state, popobear_vram) | |
| 114 | AM_RANGE(0x3E0000, 0x3EFFFF) AM_RAM AM_BASE_MEMBER(popobear_state, popobear_vram) | |
| 115 | 115 | |
| 116 | 116 | /* Blitter stuff? */ |
| 117 | 117 | AM_RANGE(0x480000, 0x480001) AM_READ(popo_480001_r) AM_WRITE(popo_480001_w) |
| r14260 | r14261 | |
| 125 | 125 | AM_RANGE(0x48003a, 0x48003b) AM_READ(popo_48003a_r) AM_WRITE(popo_48003a_w) |
| 126 | 126 | |
| 127 | 127 | AM_RANGE(0x480400, 0x48041f) AM_RAM AM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) // looks palette like at least |
| 128 | ||
| 128 | ||
| 129 | 129 | /* I/O maybe? */ |
| 130 | 130 | AM_RANGE(0x500000, 0x500001) AM_READ(popo_500000_r) |
| 131 | 131 | AM_RANGE(0x520000, 0x520001) AM_READ(popo_520000_r) |
| r14260 | r14261 | |
| 315 | 315 | |
| 316 | 316 | static MACHINE_CONFIG_START( popobear, popobear_state ) |
| 317 | 317 | MCFG_CPU_ADD("maincpu", M68000, XTAL_42MHz/4) // XTAL CORRECT, DIVISOR GUESSED |
| 318 | MCFG_CPU_PROGRAM_MAP(popobear_mem) | |
| 318 | MCFG_CPU_PROGRAM_MAP(popobear_mem) | |
| 319 | 319 | // levels 2,3,5 look interesting |
| 320 | 320 | //MCFG_CPU_VBLANK_INT("screen",irq3_line_hold) |
| 321 | 321 | MCFG_TIMER_ADD_SCANLINE("scantimer", popobear_irq, "screen", 0, 1) |
| r14260 | r14261 | |
|---|---|---|
| 1596 | 1596 | |
| 1597 | 1597 | /************************************************************************************************************************** |
| 1598 | 1598 | Turbo Outrun (Upright version?? According to service mode dipswitch screen it's a Cockpit) |
| 1599 | CPU: FD1094 (317-????) | |
| 1600 | GAME BD 834-6919 | |
| 1599 | CPU: FD1094 (317-0107) | |
| 1600 | GAME BD 834-6919-02 | |
| 1601 | 1601 | CPU BD 837-6905 |
| 1602 | 1602 | VIDEO BD 837-6906 |
| 1603 | 1603 | |
| r14260 | r14261 | |
| 1614 | 1614 | ROM_LOAD16_BYTE( "epr-12292.116", 0x040001, 0x10000, CRC(51d98af0) SHA1(6e7115706bfafb687faa23d55d4a8c8e498a4df2) ) |
| 1615 | 1615 | |
| 1616 | 1616 | ROM_REGION( 0x2000, "user1", 0 ) /* decryption key */ |
| 1617 | ROM_LOAD( "317- | |
| 1617 | ROM_LOAD( "317-0107 | |
| 1618 | 1618 | |
| 1619 | 1619 | ROM_REGION( 0x60000, "sub", 0 ) /* second 68000 CPU */ |
| 1620 | 1620 | ROM_LOAD16_BYTE( "opr-12295.76", 0x000000, 0x10000, CRC(d43a3a84) SHA1(362c98f62c205b6b40b7e8a4ba107745b547b984) ) |
| r14260 | r14261 | |
| 1681 | 1681 | ROM_LOAD16_BYTE( "epr-12292.116", 0x040001, 0x10000, CRC(51d98af0) SHA1(6e7115706bfafb687faa23d55d4a8c8e498a4df2) ) |
| 1682 | 1682 | |
| 1683 | 1683 | ROM_REGION( 0x2000, "user1", 0 ) /* decryption key */ |
| 1684 | ROM_LOAD( "317-unknown-toutrun | |
| 1684 | ROM_LOAD( "317-unknown-toutrun2.key", 0x0000, 0x2000, NO_DUMP ) /* FD1094 number unknown and not dumped */ | |
| 1685 | 1685 | |
| 1686 | 1686 | ROM_REGION( 0x60000, "sub", 0 ) /* second 68000 CPU */ |
| 1687 | 1687 | ROM_LOAD16_BYTE( "opr-12295.76", 0x000000, 0x10000, CRC(d43a3a84) SHA1(362c98f62c205b6b40b7e8a4ba107745b547b984) ) |
| r14260 | r14261 | |
| 1795 | 1795 | ************************************************************************************************************************** |
| 1796 | 1796 | Super Hangon |
| 1797 | 1797 | CPU: 68000 (317-????) |
| 1798 | GAME BD SUPER HANG-ON 834-6277-07 | |
| 1798 | 1799 | CPU BD SUPER HANG-ON 837-6278-01 (or 837-6278-03) |
| 1799 | 1800 | VIDEO BD SUPER HANG-ON 837-6279-01 |
| 1800 | 1801 | */ |
| r14260 | r14261 | |
| 1848 | 1849 | /************************************************************************************************************************** |
| 1849 | 1850 | Super Hangon |
| 1850 | 1851 | CPU: FD1089B (317-0034) |
| 1852 | GAME BD SUPER HANG-ON 834-6277-02 | |
| 1851 | 1853 | CPU BD SUPER HANG-ON 837-6278-01 (or 837-6278-03) |
| 1852 | 1854 | VIDEO BD SUPER HANG-ON 837-6279 (or 837-6279-02, roms would be "OPR") |
| 1855 | ||
| 1856 | Manual states for this set: | |
| 1857 | 834-6277-01 (Object data (sprits) EPR type AKA EP-ROM type) | |
| 1858 | 834-6277-03 (Object data (sprits) MPR type AKA Mask-ROM type) | |
| 1859 | 834-6277-05 (Object data (sprits) OPR type AKA One Time ROM type) | |
| 1860 | ||
| 1853 | 1861 | */ |
| 1854 | 1862 | ROM_START( shangon3 ) |
| 1855 | 1863 | ROM_REGION( 0x60000, "maincpu", 0 ) /* 68000 code - protected */ |
| r14260 | r14261 | |
| 2188 | 2196 | GAME( 1987, shangon1, shangon, shangon, shangon, shangon3, ROT0, "Sega", "Super Hang-On (mini ride-on?, FD1089B 317-0034)", GAME_NOT_WORKING ) /* bad program rom */ |
| 2189 | 2197 | GAME( 1991, shangonle,shangon, shangon, shangon, shangon, ROT0, "Sega", "Limited Edition Hang-On", 0 ) |
| 2190 | 2198 | GAMEL(1989, toutrun, 0, outrun, toutrun, outrun, ROT0, "Sega", "Turbo Out Run (Out Run upgrade, FD1094 317-0118)", 0, layout_outrun ) /* Cabinet determined by dipswitch settings */ |
| 2191 | GAMEL(1989, toutrun3, toutrun, outrun, toutrunc, outrun, ROT0, "Sega", "Turbo Out Run (upright, FD1094 317- | |
| 2199 | GAMEL(1989, toutrun3, toutrun, outrun, toutrunc, outrun, ROT0, "Sega", "Turbo Out Run (upright, FD1094 317-0107 | |
| 2192 | 2200 | GAMEL(1989, toutrun2, toutrun, outrun, toutrun, outrun, ROT0, "Sega", "Turbo Out Run (cockpit, FD1094 317-unknown)", GAME_NOT_WORKING, layout_outrun ) /* FD1094 CPU not decrypted */ |
| 2193 | 2201 | GAMEL(1989, toutrun1, toutrun, outrun, toutrunm, outrun, ROT0, "Sega", "Turbo Out Run (deluxe cockpit, FD1094 317-0109)", 0, layout_outrun ) |
| r14260 | r14261 | |
|---|---|---|
| 107 | 107 | |
| 108 | 108 | static void plot_pixel_rgb(sliver_state *state, int x, int y, UINT32 r, UINT32 g, UINT32 b) |
| 109 | 109 | { |
| 110 | // | |
| 110 | // printf("plot %d %d %d\n", r,g,b); | |
| 111 | 111 | |
| 112 | 112 | if (y < 0 || x < 0 || x > 383 || y > 255) |
| 113 | 113 | return; |
| r14260 | r14261 | |
| 228 | 228 | |
| 229 | 229 | struct jpeg_decompress_struct cinfo; |
| 230 | 230 | struct jpeg_error_mgr jerr; |
| 231 | JSAMPARRAY buffer; | |
| 231 | JSAMPARRAY buffer; | |
| 232 | 232 | |
| 233 | 233 | cinfo.err = jpeg_std_error(&jerr); |
| 234 | 234 | jpeg_create_decompress(&cinfo); |
| r14260 | r14261 | |
| 239 | 239 | jpeg_start_decompress(&cinfo); |
| 240 | 240 | |
| 241 | 241 | int row_stride = cinfo.output_width * cinfo.output_components; |
| 242 | ||
| 242 | ||
| 243 | 243 | buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); |
| 244 | 244 | |
| 245 | 245 | while (cinfo.output_scanline < cinfo.output_height) |
| r14260 | r14261 | |
| 253 | 253 | UINT8 g = buffer[0][(x*3)+1]; |
| 254 | 254 | UINT8 r = buffer[0][(x*3)+2]; |
| 255 | 255 | plot_pixel_rgb(state, x - x_offset + state->m_jpeg_x, y - y_offset - state->m_jpeg_y, r, g, b); |
| 256 | ||
| 256 | ||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | } |
| r14260 | r14261 | |
|---|---|---|
| 2317 | 2317 | static const SCSIConfigTable dev_table = |
| 2318 | 2318 | { |
| 2319 | 2319 | 1, /* 1 SCSI device */ |
| 2320 | { { SCSI_ID_1, "cdrom", SCSI_DEVICE_CDROM } } /* SCSI ID 2, using CD 0, and it's a CD-ROM */ | |
| 2320 | { { SCSI_ID_1, ":cdrom", SCSI_DEVICE_CDROM } } /* SCSI ID 2, using CD 0, and it's a CD-ROM */ | |
| 2321 | 2321 | }; |
| 2322 | 2322 | |
| 2323 | 2323 | static const struct WD33C93interface scsi_intf = |
| r14260 | r14261 | |
|---|---|---|
| 27 | 27 | |
| 28 | 28 | --------------------------------------------------------------------- |
| 29 | 29 | |
| 30 | Pluto 5 Technical Notes.... | |
| 30 | Pluto 5 Technical Notes.... | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | * Clocks... |
| r14260 | r14261 | |
|---|---|---|
| 113 | 113 | #include "sound/2151intf.h" |
| 114 | 114 | #include "sound/okim6295.h" |
| 115 | 115 | #include "video/decocomn.h" |
| 116 | #include "video/decospr.h" | |
| 116 | 117 | |
| 117 | 118 | static READ16_HANDLER( rohga_irq_ack_r ) |
| 118 | 119 | { |
| r14260 | r14261 | |
| 663 | 664 | 4096*8, |
| 664 | 665 | 6, |
| 665 | 666 | { 0x400000*8+8, 0x400000*8, 0x200000*8+8, 0x200000*8, 8, 0 }, |
| 666 | { 7,6,5,4,3,2,1,0, | |
| 667 | 32*8+7, 32*8+6, 32*8+5, 32*8+4, 32*8+3, 32*8+2, 32*8+1, 32*8+0 }, | |
| 668 | { 15*16, 14*16, 13*16, 12*16, 11*16, 10*16, 9*16, 8*16, | |
| 669 | 7*16, 6*16, 5*16, 4*16, 3*16, 2*16, 1*16, 0*16 }, | |
| 667 | { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7, 0,1,2,3,4,5,6,7 }, | |
| 668 | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, | |
| 669 | 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, | |
| 670 | 670 | 64*8 |
| 671 | 671 | }; |
| 672 | 672 | |
| r14260 | r14261 | |
| 676 | 676 | 4096*8, |
| 677 | 677 | 4, |
| 678 | 678 | { 0x200000*8+8, 0x200000*8, 8, 0 }, |
| 679 | { 7,6,5,4,3,2,1,0, | |
| 680 | 32*8+7, 32*8+6, 32*8+5, 32*8+4, 32*8+3, 32*8+2, 32*8+1, 32*8+0 }, | |
| 681 | { 15*16, 14*16, 13*16, 12*16, 11*16, 10*16, 9*16, 8*16, | |
| 682 | 7*16, 6*16, 5*16, 4*16, 3*16, 2*16, 1*16, 0*16 }, | |
| 679 | { 32*8+0, 32*8+1, 32*8+2, 32*8+3, 32*8+4, 32*8+5, 32*8+6, 32*8+7, 0,1,2,3,4,5,6,7 }, | |
| 680 | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, | |
| 681 | 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, | |
| 683 | 682 | 64*8 |
| 684 | 683 | }; |
| 685 | 684 | |
| r14260 | r14261 | |
| 707 | 706 | GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 32 ) /* Gfx chip 1 as 8x8 */ |
| 708 | 707 | GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0, 32 ) /* Gfx chip 1 as 16x16 */ |
| 709 | 708 | GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 512, 32 ) /* Gfx chip 2 as 16x16 */ |
| 710 | GFXDECODE_ENTRY( "gfx4", 0, spritelayout, 1024, 32 ) /* Sprites 16x16 */ | |
| 711 | GFXDECODE_ENTRY( "gfx5", 0, spritelayout, 1536, 32 ) | |
| 709 | GFXDECODE_ENTRY( "gfx4", 0, spritelayout, 0, 32 ) /* Sprites 16x16 */ | |
| 710 | GFXDECODE_ENTRY( "gfx5", 0, spritelayout, 0, 32 ) | |
| 712 | 711 | GFXDECODE_END |
| 713 | 712 | |
| 714 | 713 | static GFXDECODE_START( schmeisr ) |
| r14260 | r14261 | |
| 829 | 828 | MCFG_DECO16IC_ADD("tilegen1", rohga_deco16ic_tilegen1_intf) |
| 830 | 829 | MCFG_DECO16IC_ADD("tilegen2", rohga_deco16ic_tilegen2_intf) |
| 831 | 830 | |
| 831 | MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0) | |
| 832 | decospr_device::set_gfx_region(*device, 3); | |
| 833 | ||
| 832 | 834 | /* sound hardware */ |
| 833 | 835 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 834 | 836 | |
| r14260 | r14261 | |
| 874 | 876 | MCFG_DECO16IC_ADD("tilegen1", rohga_deco16ic_tilegen1_intf) |
| 875 | 877 | MCFG_DECO16IC_ADD("tilegen2", rohga_deco16ic_tilegen2_intf) |
| 876 | 878 | |
| 879 | MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0) | |
| 880 | decospr_device::set_gfx_region(*device, 3); | |
| 881 | ||
| 882 | MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0) | |
| 883 | decospr_device::set_gfx_region(*device, 4); | |
| 884 | ||
| 885 | MCFG_VIDEO_START(wizdfire) | |
| 886 | ||
| 877 | 887 | /* sound hardware */ |
| 878 | 888 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 879 | 889 | |
| r14260 | r14261 | |
| 919 | 929 | MCFG_DECO16IC_ADD("tilegen1", nitrobal_deco16ic_tilegen1_intf) |
| 920 | 930 | MCFG_DECO16IC_ADD("tilegen2", nitrobal_deco16ic_tilegen2_intf) |
| 921 | 931 | |
| 932 | MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0) | |
| 933 | decospr_device::set_gfx_region(*device, 3); | |
| 934 | ||
| 935 | MCFG_DEVICE_ADD("spritegen2", DECO_SPRITE, 0) | |
| 936 | decospr_device::set_gfx_region(*device, 4); | |
| 937 | ||
| 938 | MCFG_VIDEO_START(wizdfire) | |
| 939 | ||
| 922 | 940 | /* sound hardware */ |
| 923 | 941 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 924 | 942 | |
| r14260 | r14261 | |
| 954 | 972 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529)) |
| 955 | 973 | MCFG_SCREEN_SIZE(40*8, 32*8) |
| 956 | 974 | MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1) |
| 957 | MCFG_SCREEN_UPDATE_STATIC( | |
| 975 | MCFG_SCREEN_UPDATE_STATIC( | |
| 958 | 976 | |
| 959 | 977 | MCFG_GFXDECODE(schmeisr) |
| 960 | 978 | MCFG_PALETTE_LENGTH(2048) |
| 961 | 979 | |
| 962 | MCFG_VIDEO_START( | |
| 980 | MCFG_VIDEO_START(schmeisr) | |
| 963 | 981 | |
| 964 | 982 | MCFG_DECOCOMN_ADD("deco_common", rohga_decocomn_intf) |
| 965 | 983 | |
| 966 | 984 | MCFG_DECO16IC_ADD("tilegen1", rohga_deco16ic_tilegen1_intf) |
| 967 | 985 | MCFG_DECO16IC_ADD("tilegen2", rohga_deco16ic_tilegen2_intf) |
| 968 | 986 | |
| 987 | MCFG_DEVICE_ADD("spritegen1", DECO_SPRITE, 0) | |
| 988 | decospr_device::set_gfx_region(*device, 3); | |
| 989 | ||
| 990 | ||
| 969 | 991 | /* sound hardware */ |
| 970 | 992 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 971 | 993 |
| r14260 | r14261 | |
|---|---|---|
| 814 | 814 | |
| 815 | 815 | PORT_START("DSW1") |
| 816 | 816 | PORT_BIT( 0x4f, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 817 | ||
| 817 | ||
| 818 | 818 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:5,6") |
| 819 | 819 | PORT_DIPSETTING( 0x30, DEF_STR( Easy ) ) |
| 820 | 820 | PORT_DIPSETTING( 0x20, DEF_STR( Medium ) ) |
| r14260 | r14261 | |
| 1216 | 1216 | |
| 1217 | 1217 | PORT_START("DSW1") |
| 1218 | 1218 | PORT_DIPUNUSED_DIPLOC( 0x01, IP_ACTIVE_LOW, "SW2:1" ) |
| 1219 | PORT_DIPUNUSED_DIPLOC( 0x02, IP_ACTIVE_LOW, "SW2:2" ) | |
| 1219 | PORT_DIPUNUSED_DIPLOC( 0x02, IP_ACTIVE_LOW, "SW2:2" ) | |
| 1220 | 1220 | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW2:3") |
| 1221 | 1221 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) |
| 1222 | 1222 | PORT_DIPSETTING( 0x04, DEF_STR( Cocktail ) ) |
| r14260 | r14261 | |
|---|---|---|
| 340 | 340 | x0 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x000/2 + ((i + layer0_scrolly)&0xff))]; // different handling to psikyo.c? ( + scrolly ) |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | ||
| 343 | ||
| 344 | 344 | tmptilemap0->set_scrollx( |
| 345 | 345 | (i + layer0_scrolly) % 256 /*tilemap_width(tm0size) */, |
| 346 | 346 | layer0_scrollx + x0 ); |
| r14260 | r14261 | |
| 357 | 357 | x1 = ((UINT16 *)state->m_vregs)[BYTE_XOR_BE(0x200/2 + ((i + layer1_scrolly)&0xff))]; // different handling to psikyo.c? ( + scrolly ) |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | ||
| 360 | ||
| 361 | 361 | tmptilemap1->set_scrollx( |
| 362 | 362 | (i + layer1_scrolly) % 256 /* tilemap_width(tm1size) */, |
| 363 | 363 | layer1_scrollx + x1 ); |
| r14260 | r14261 | |
|---|---|---|
| 274 | 274 | { |
| 275 | 275 | 1, /* 1 SCSI device */ |
| 276 | 276 | { |
| 277 | { SCSI_ID_4, "cdrom", SCSI_DEVICE_CDROM } /* SCSI ID 4, using CHD 0, and it's a CD-ROM */ | |
| 277 | { SCSI_ID_4, ":cdrom", SCSI_DEVICE_CDROM } /* SCSI ID 4, using CHD 0, and it's a CD-ROM */ | |
| 278 | 278 | } |
| 279 | 279 | }; |
| 280 | 280 |
| r14260 | r14261 | |
|---|---|---|
| 713 | 713 | kbdc8042_init(machine, &at8042); |
| 714 | 714 | #if ENABLE_VGA |
| 715 | 715 | pc_vga_init(machine, vga_setting, NULL); |
| 716 | pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0xa0000, machine.device("maincpu")->memory().space(AS_IO), 0x0000); | |
| 716 | pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0xa0000, machine.device("maincpu")->memory().space(AS_IO), 0x0000); | |
| 717 | 717 | #endif |
| 718 | 718 | } |
| 719 | 719 |
| r14260 | r14261 | |
|---|---|---|
| 381 | 381 | // rom[0x2696/2] = 0x4e71; |
| 382 | 382 | // rom[0x26a0/2] = 0x4e71; |
| 383 | 383 | pc_vga_init(machine, vga_setting, NULL); |
| 384 | pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3a0000, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3c0000); | |
| 385 | ||
| 384 | pc_vga_io_init(machine, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3a0000, machine.device("maincpu")->memory().space(AS_PROGRAM), 0x3c0000); | |
| 385 | ||
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | GAME( 199?, pntnpuzl, 0, pntnpuzl, pntnpuzl, pip, ROT90, "Century?", "Paint & Puzzle",GAME_NO_SOUND|GAME_NOT_WORKING ) |
| r14260 | r14261 | |
|---|---|---|
| 447 | 447 | MACHINE_CONFIG_END |
| 448 | 448 | |
| 449 | 449 | static MACHINE_CONFIG_DERIVED( triforcegd, triforce_base ) |
| 450 | MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", "gdrom", "picreturn", NULL, "maincpu", NULL) | |
| 450 | MCFG_NAOMI_GDROM_BOARD_ADD("rom_board", ":gdrom", "picreturn", NULL, "maincpu", NULL) | |
| 451 | 451 | MACHINE_CONFIG_END |
| 452 | 452 | |
| 453 | 453 | #define ROM_LOAD16_WORD_SWAP_BIOS(bios,name,offset,length,hash) \ |
| r14260 | r14261 | |
|---|---|---|
| 91 | 91 | // NMI on d0 |
| 92 | 92 | if (ticks_mask & state->m_interrupt_mask & 1) |
| 93 | 93 | cputag_set_input_line(timer.machine(), "maincpu", INPUT_LINE_NMI, ASSERT_LINE); |
| 94 | ||
| 94 | ||
| 95 | 95 | // IRQ on d3 (used by mrgoemon) |
| 96 | 96 | if (ticks_mask & state->m_interrupt_mask<<2 & 8) |
| 97 | 97 | cputag_set_input_line(timer.machine(), "maincpu", 0, ASSERT_LINE); |
| r14260 | r14261 | |
|---|---|---|
| 3410 | 3410 | { "-createuncomphd", do_createhd_uncomp, 0 }, |
| 3411 | 3411 | { "-createraw", do_createraw, 0 }, |
| 3412 | 3412 | { "-createcd", do_createcd, 0 }, |
| 3413 | // | |
| 3413 | // { "-createcdflac", do_createcd, 1 }, | |
| 3414 | 3414 | { "-createblankhd", do_createblankhd, 0 }, |
| 3415 | 3415 | { "-createav", do_createav, 0 }, |
| 3416 | 3416 | { "-copydata", do_copydata, 0 }, |
| r14260 | r14261 | |
|---|---|---|
| 851 | 851 | return TTF_OpenFont(name.cstr(), POINT_SIZE); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | static bool BDF_Check_Magic(astring name) | |
| 855 | { | |
| 856 | emu_file file(OPEN_FLAG_READ); | |
| 857 | if (file.open(name) == FILERR_NONE) | |
| 858 | { | |
| 859 | unsigned char buffer[9]; | |
| 860 | unsigned char magic[9] = { 'S', 'T', 'A', 'R', 'T', 'F', 'O', 'N', 'T' }; | |
| 861 | file.read(buffer, 9); | |
| 862 | file.close(); | |
| 863 | if (!memcmp(buffer, magic, 9)) | |
| 864 | return true; | |
| 865 | } | |
| 866 | ||
| 867 | return false; | |
| 868 | } | |
| 869 | ||
| 854 | 870 | static TTF_Font *search_font_config(astring name, bool bold, bool italic, bool underline, bool &bakedstyles) |
| 855 | 871 | { |
| 856 | 872 | TTF_Font *font = (TTF_Font *)NULL; |
| r14260 | r14261 | |
| 1009 | 1025 | |
| 1010 | 1026 | if (!font) |
| 1011 | 1027 | { |
| 1012 | printf("WARNING: Couldn't find/open TrueType font %s, using MAME default\n", name.cstr()); | |
| 1028 | if (!BDF_Check_Magic(name)) | |
| 1029 | { | |
| 1030 | printf("WARNING: font %s, is not TrueType or BDF, using MAME default\n", name.cstr()); | |
| 1031 | } | |
| 1013 | 1032 | return NULL; |
| 1014 | 1033 | } |
| 1015 | 1034 |
| r14260 | r14261 | |
|---|---|---|
| 182 | 182 | break; |
| 183 | 183 | |
| 184 | 184 | // if this is a single-entry global, add it |
| 185 | ||
| 185 | ||
| 186 | 186 | { |
| 187 | 187 | name.cpy(strrchr(itemname, '/') + 1); |
| 188 | 188 | m_source_list.append(*auto_alloc(machine(), debug_view_memory_source(name, base, valsize, valcount))); |
| r14260 | r14261 | |
|---|---|---|
| 207 | 207 | |
| 208 | 208 | // Far Jump |
| 209 | 209 | case 0x2f: case 0x3f: case 0x6f: case 0x7f: |
| 210 | if (OPA == 7 && OP | |
| 210 | if (OPA == 7 && OP1 == 2) | |
| 211 | 211 | { |
| 212 | 212 | print("goto %06x", ((OPIMM << 16) | imm16) << 1); |
| 213 | 213 | } |
| r14260 | r14261 | |
|---|---|---|
| 3277 | 3277 | case 2: /* LGDT */ |
| 3278 | 3278 | { |
| 3279 | 3279 | if(PROTECTED_MODE && cpustate->CPL) |
| 3280 | FAULT(FAULT_GP,0) | |
| 3280 | FAULT(FAULT_GP,0) | |
| 3281 | 3281 | if( modrm >= 0xc0 ) { |
| 3282 | 3282 | address = LOAD_RM16(modrm); |
| 3283 | 3283 | ea = i386_translate(cpustate, CS, address, 0 ); |
| r14260 | r14261 | |
| 3292 | 3292 | case 3: /* LIDT */ |
| 3293 | 3293 | { |
| 3294 | 3294 | if(PROTECTED_MODE && cpustate->CPL) |
| 3295 | FAULT(FAULT_GP,0) | |
| 3295 | FAULT(FAULT_GP,0) | |
| 3296 | 3296 | if( modrm >= 0xc0 ) { |
| 3297 | 3297 | address = LOAD_RM16(modrm); |
| 3298 | 3298 | ea = i386_translate(cpustate, CS, address, 0 ); |
| r14260 | r14261 | |
|---|---|---|
| 458 | 458 | if(!(page_dir & 0x40) && (rwn == 1)) |
| 459 | 459 | cpustate->program->write_dword(pdbr + directory * 4, page_dir | 0x60); |
| 460 | 460 | else if(!(page_dir & 0x20) && (rwn != -1)) |
| 461 | cpustate->program->write_dword(pdbr + directory * 4, page_dir | 0x20); | |
| 461 | cpustate->program->write_dword(pdbr + directory * 4, page_dir | 0x20); | |
| 462 | 462 | *address = (page_dir & 0xffc00000) | (a & 0x003fffff); |
| 463 | 463 | } |
| 464 | 464 | } |
| r14260 | r14261 | |
|---|---|---|
| 2 | 2 | |
| 3 | 3 | x87 FPU emulation |
| 4 | 4 | |
| 5 | TODO: | |
| 6 | - 80-bit precision for F2XM1, FYL2X, FPATAN | |
| 7 | - Figure out why SoftFloat trig extensions produce bad values | |
| 8 | - Cycle counts for all processors (currently using 486 counts) | |
| 9 | - Precision-dependent cycle counts for divide instructions | |
| 10 | - Last instruction, operand pointers etc. | |
| 11 | - Fix FLDENV, FSTENV, FSAVE, FRSTOR and FPREM | |
| 12 | - Status word C2 updates to reflect round up/down | |
| 13 | - Handling of invalid and denormal numbers | |
| 14 | - Remove redundant operand checks | |
| 15 | - Exceptions | |
| 5 | TODO: | |
| 6 | - 80-bit precision for F2XM1, FYL2X, FPATAN | |
| 7 | - Figure out why SoftFloat trig extensions produce bad values | |
| 8 | - Cycle counts for all processors (currently using 486 counts) | |
| 9 | - Precision-dependent cycle counts for divide instructions | |
| 10 | - Last instruction, operand pointers etc. | |
| 11 | - Fix FLDENV, FSTENV, FSAVE, FRSTOR and FPREM | |
| 12 | - Status word C2 updates to reflect round up/down | |
| 13 | - Handling of invalid and denormal numbers | |
| 14 | - Remove redundant operand checks | |
| 15 | - Exceptions | |
| 16 | 16 | |
| 17 | 17 | ***************************************************************************/ |
| 18 | 18 | |
| r14260 | r14261 | |
| 2167 | 2167 | double x = fx80_to_double(result1); |
| 2168 | 2168 | x = tan(x); |
| 2169 | 2169 | result1 = double_to_fx80(x); |
| 2170 | ||
| 2170 | ||
| 2171 | 2171 | cpustate->x87_sw &= ~X87_SW_C2; |
| 2172 | 2172 | #endif |
| 2173 | 2173 | } |
| r14260 | r14261 | |
| 2229 | 2229 | double x = fx80_to_double(result); |
| 2230 | 2230 | x = sin(x); |
| 2231 | 2231 | result = double_to_fx80(x); |
| 2232 | ||
| 2232 | ||
| 2233 | 2233 | cpustate->x87_sw &= ~X87_SW_C2; |
| 2234 | 2234 | #endif |
| 2235 | 2235 | } |
| r14260 | r14261 | |
| 2262 | 2262 | double x = fx80_to_double(result); |
| 2263 | 2263 | x = cos(x); |
| 2264 | 2264 | result = double_to_fx80(x); |
| 2265 | ||
| 2265 | ||
| 2266 | 2266 | cpustate->x87_sw &= ~X87_SW_C2; |
| 2267 | 2267 | #endif |
| 2268 | 2268 | } |
| r14260 | r14261 | |
| 2300 | 2300 | cpustate->x87_sw |= X87_SW_C2; |
| 2301 | 2301 | #else |
| 2302 | 2302 | double s = fx80_to_double(s_result); |
| 2303 | double c = fx80_to_double(c_result); | |
| 2303 | double c = fx80_to_double(c_result); | |
| 2304 | 2304 | s = sin(s); |
| 2305 | 2305 | c = cos(c); |
| 2306 | ||
| 2306 | ||
| 2307 | 2307 | s_result = double_to_fx80(s); |
| 2308 | 2308 | c_result = double_to_fx80(c); |
| 2309 | ||
| 2309 | ||
| 2310 | 2310 | cpustate->x87_sw &= ~X87_SW_C2; |
| 2311 | 2311 | #endif |
| 2312 | 2312 | } |
| r14260 | r14261 | |
| 4023 | 4023 | WRITE16(cpustate, ea + 0, cpustate->x87_cw); |
| 4024 | 4024 | WRITE16(cpustate, ea + 2, cpustate->x87_sw); |
| 4025 | 4025 | WRITE16(cpustate, ea + 4, cpustate->x87_tw); |
| 4026 | // WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4027 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4028 | // WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4029 | // WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4026 | // WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4027 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4028 | // WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4029 | // WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4030 | 4030 | break; |
| 4031 | 4031 | case 1: // 16-bit protected mode |
| 4032 | 4032 | WRITE16(cpustate,ea + 0, cpustate->x87_cw); |
| 4033 | 4033 | WRITE16(cpustate,ea + 2, cpustate->x87_sw); |
| 4034 | 4034 | WRITE16(cpustate,ea + 4, cpustate->x87_tw); |
| 4035 | // WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4036 | // WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4037 | // WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4038 | // WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4035 | // WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4036 | // WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4037 | // WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4038 | // WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4039 | 4039 | break; |
| 4040 | 4040 | case 2: // 32-bit real mode |
| 4041 | 4041 | WRITE16(cpustate, ea + 0, cpustate->x87_cw); |
| 4042 | 4042 | WRITE16(cpustate, ea + 4, cpustate->x87_sw); |
| 4043 | 4043 | WRITE16(cpustate, ea + 8, cpustate->x87_tw); |
| 4044 | // WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff); | |
| 4045 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4046 | // WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff); | |
| 4047 | // WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4048 | // WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12); | |
| 4044 | // WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff); | |
| 4045 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4046 | // WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff); | |
| 4047 | // WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4048 | // WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12); | |
| 4049 | 4049 | break; |
| 4050 | 4050 | case 3: // 32-bit protected mode |
| 4051 | 4051 | WRITE16(cpustate, ea + 0, cpustate->x87_cw); |
| 4052 | 4052 | WRITE16(cpustate, ea + 4, cpustate->x87_sw); |
| 4053 | 4053 | WRITE16(cpustate, ea + 8, cpustate->x87_tw); |
| 4054 | // WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr); | |
| 4055 | // WRITE32(cpustate, ea + 16, cpustate->fpu_opcode); | |
| 4056 | // WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr); | |
| 4057 | // WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr); | |
| 4054 | // WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr); | |
| 4055 | // WRITE32(cpustate, ea + 16, cpustate->fpu_opcode); | |
| 4056 | // WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr); | |
| 4057 | // WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr); | |
| 4058 | 4058 | break; |
| 4059 | 4059 | } |
| 4060 | 4060 | |
| r14260 | r14261 | |
| 4072 | 4072 | WRITE16(cpustate, ea + 0, cpustate->x87_cw); |
| 4073 | 4073 | WRITE16(cpustate, ea + 2, cpustate->x87_sw); |
| 4074 | 4074 | WRITE16(cpustate, ea + 4, cpustate->x87_tw); |
| 4075 | // WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4076 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4077 | // WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4078 | // WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4075 | // WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4076 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4077 | // WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4078 | // WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4079 | 4079 | ea += 14; |
| 4080 | 4080 | break; |
| 4081 | 4081 | case 1: // 16-bit protected mode |
| 4082 | 4082 | WRITE16(cpustate,ea + 0, cpustate->x87_cw); |
| 4083 | 4083 | WRITE16(cpustate,ea + 2, cpustate->x87_sw); |
| 4084 | 4084 | WRITE16(cpustate,ea + 4, cpustate->x87_tw); |
| 4085 | // WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4086 | // WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4087 | // WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4088 | // WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4085 | // WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4086 | // WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4087 | // WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4088 | // WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4089 | 4089 | ea += 14; |
| 4090 | 4090 | break; |
| 4091 | 4091 | case 2: // 32-bit real mode |
| 4092 | 4092 | WRITE16(cpustate, ea + 0, cpustate->x87_cw); |
| 4093 | 4093 | WRITE16(cpustate, ea + 4, cpustate->x87_sw); |
| 4094 | 4094 | WRITE16(cpustate, ea + 8, cpustate->x87_tw); |
| 4095 | // WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff); | |
| 4096 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4097 | // WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff); | |
| 4098 | // WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4099 | // WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12); | |
| 4095 | // WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff); | |
| 4096 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4097 | // WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff); | |
| 4098 | // WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4099 | // WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12); | |
| 4100 | 4100 | ea += 28; |
| 4101 | 4101 | break; |
| 4102 | 4102 | case 3: // 32-bit protected mode |
| 4103 | 4103 | WRITE16(cpustate, ea + 0, cpustate->x87_cw); |
| 4104 | 4104 | WRITE16(cpustate, ea + 4, cpustate->x87_sw); |
| 4105 | 4105 | WRITE16(cpustate, ea + 8, cpustate->x87_tw); |
| 4106 | // WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr); | |
| 4107 | // WRITE32(cpustate, ea + 16, cpustate->fpu_opcode); | |
| 4108 | // WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr); | |
| 4109 | // WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr); | |
| 4106 | // WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr); | |
| 4107 | // WRITE32(cpustate, ea + 16, cpustate->fpu_opcode); | |
| 4108 | // WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr); | |
| 4109 | // WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr); | |
| 4110 | 4110 | ea += 28; |
| 4111 | 4111 | break; |
| 4112 | 4112 | } |
| r14260 | r14261 | |
| 4128 | 4128 | x87_write_cw(cpustate, READ16(cpustate, ea)); |
| 4129 | 4129 | cpustate->x87_sw = READ16(cpustate, ea + 2); |
| 4130 | 4130 | cpustate->x87_tw = READ16(cpustate, ea + 4); |
| 4131 | // WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4132 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4133 | // WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4134 | // WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4131 | // WRITE16(cpustate, ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4132 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4133 | // WRITE16(cpustate, ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4134 | // WRITE16(cpustate, ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4135 | 4135 | ea += 14; |
| 4136 | 4136 | break; |
| 4137 | 4137 | case 1: // 16-bit protected mode |
| 4138 | 4138 | x87_write_cw(cpustate, READ16(cpustate, ea)); |
| 4139 | 4139 | cpustate->x87_sw = READ16(cpustate, ea + 2); |
| 4140 | 4140 | cpustate->x87_tw = READ16(cpustate, ea + 4); |
| 4141 | // WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4142 | // WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4143 | // WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4144 | // WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4141 | // WRITE16(cpustate,ea + 6, cpustate->fpu_inst_ptr & 0xffff); | |
| 4142 | // WRITE16(cpustate,ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4143 | // WRITE16(cpustate,ea + 10, cpustate->fpu_data_ptr & 0xffff); | |
| 4144 | // WRITE16(cpustate,ea + 12, (cpustate->fpu_inst_ptr & 0x0f0000) >> 4); | |
| 4145 | 4145 | ea += 14; |
| 4146 | 4146 | break; |
| 4147 | 4147 | case 2: // 32-bit real mode |
| 4148 | 4148 | x87_write_cw(cpustate, READ16(cpustate, ea)); |
| 4149 | 4149 | cpustate->x87_sw = READ16(cpustate, ea + 4); |
| 4150 | 4150 | cpustate->x87_tw = READ16(cpustate, ea + 8); |
| 4151 | // WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff); | |
| 4152 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4153 | // WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff); | |
| 4154 | // WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4155 | // WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12); | |
| 4151 | // WRITE16(cpustate, ea + 12, cpustate->fpu_inst_ptr & 0xffff); | |
| 4152 | // WRITE16(cpustate, ea + 8, (cpustate->fpu_opcode & 0x07ff) | ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4153 | // WRITE16(cpustate, ea + 20, cpustate->fpu_data_ptr & 0xffff); | |
| 4154 | // WRITE16(cpustate, ea + 12, ((cpustate->fpu_inst_ptr & 0x0f0000) >> 4)); | |
| 4155 | // WRITE32(cpustate, ea + 24, (cpustate->fpu_data_ptr >> 16) << 12); | |
| 4156 | 4156 | ea += 28; |
| 4157 | 4157 | break; |
| 4158 | 4158 | case 3: // 32-bit protected mode |
| 4159 | 4159 | x87_write_cw(cpustate, READ16(cpustate, ea)); |
| 4160 | 4160 | cpustate->x87_sw = READ16(cpustate, ea + 4); |
| 4161 | 4161 | cpustate->x87_tw = READ16(cpustate, ea + 8); |
| 4162 | // WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr); | |
| 4163 | // WRITE32(cpustate, ea + 16, cpustate->fpu_opcode); | |
| 4164 | // WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr); | |
| 4165 | // WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr); | |
| 4162 | // WRITE32(cpustate, ea + 12, cpustate->fpu_inst_ptr); | |
| 4163 | // WRITE32(cpustate, ea + 16, cpustate->fpu_opcode); | |
| 4164 | // WRITE32(cpustate, ea + 20, cpustate->fpu_data_ptr); | |
| 4165 | // WRITE32(cpustate, ea + 24, cpustate->fpu_inst_ptr); | |
| 4166 | 4166 | ea += 28; |
| 4167 | 4167 | break; |
| 4168 | 4168 | } |
| r14260 | r14261 | |
|---|---|---|
| 1062 | 1062 | CHANGE_PC(cpustate,cpustate->eip); |
| 1063 | 1063 | |
| 1064 | 1064 | cpustate->CPL = cpustate->sreg[CS].selector & 0x03; |
| 1065 | // | |
| 1065 | // printf("286 Task Switch from selector %04x to %04x\n",old_task,selector); | |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | static void i386_task_switch(i386_state *cpustate, UINT16 selector, UINT8 nested) |
| r14260 | r14261 | |
| 1177 | 1177 | CHANGE_PC(cpustate,cpustate->eip); |
| 1178 | 1178 | |
| 1179 | 1179 | cpustate->CPL = cpustate->sreg[CS].selector & 0x03; |
| 1180 | // | |
| 1180 | // printf("386 Task Switch from selector %04x to %04x\n",old_task,selector); | |
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | static void i386_check_irq_line(i386_state *cpustate) |
| r14260 | r14261 | |
|---|---|---|
| 241 | 241 | case 2: /* LGDT */ |
| 242 | 242 | { |
| 243 | 243 | if(PROTECTED_MODE && cpustate->CPL) |
| 244 | FAULT(FAULT_GP,0) | |
| 244 | FAULT(FAULT_GP,0) | |
| 245 | 245 | if( modrm >= 0xc0 ) { |
| 246 | 246 | address = LOAD_RM16(modrm); |
| 247 | 247 | ea = i386_translate( cpustate, CS, address, 0 ); |
| r14260 | r14261 | |
| 256 | 256 | case 3: /* LIDT */ |
| 257 | 257 | { |
| 258 | 258 | if(PROTECTED_MODE && cpustate->CPL) |
| 259 | FAULT(FAULT_GP,0) | |
| 259 | FAULT(FAULT_GP,0) | |
| 260 | 260 | if( modrm >= 0xc0 ) { |
| 261 | 261 | address = LOAD_RM16(modrm); |
| 262 | 262 | ea = i386_translate( cpustate, CS, address, 0 ); |
| r14260 | r14261 | |
|---|---|---|
| 3123 | 3123 | case 2: /* LGDT */ |
| 3124 | 3124 | { |
| 3125 | 3125 | if(PROTECTED_MODE && cpustate->CPL) |
| 3126 | FAULT(FAULT_GP,0) | |
| 3126 | FAULT(FAULT_GP,0) | |
| 3127 | 3127 | if( modrm >= 0xc0 ) { |
| 3128 | 3128 | address = LOAD_RM32(modrm); |
| 3129 | 3129 | ea = i386_translate(cpustate, CS, address, 0 ); |
| r14260 | r14261 | |
| 3138 | 3138 | case 3: /* LIDT */ |
| 3139 | 3139 | { |
| 3140 | 3140 | if(PROTECTED_MODE && cpustate->CPL) |
| 3141 | FAULT(FAULT_GP,0) | |
| 3141 | FAULT(FAULT_GP,0) | |
| 3142 | 3142 | if( modrm >= 0xc0 ) { |
| 3143 | 3143 | address = LOAD_RM32(modrm); |
| 3144 | 3144 | ea = i386_translate(cpustate, CS, address, 0 ); |
| r14260 | r14261 | |
|---|---|---|
| 5 | 5 | const void arm7ops_ab(arm_state *cpustate, UINT32 insn); |
| 6 | 6 | const void arm7ops_cd(arm_state *cpustate, UINT32 insn); |
| 7 | 7 | const void arm7ops_e(arm_state *cpustate, UINT32 insn); |
| 8 | const void arm7ops_f(arm_state *cpustate, UINT32 insn); | |
| 8 | const void arm7ops_f(arm_state *cpustate, UINT32 insn); |
| r14260 | r14261 | |
|---|---|---|
| 20 | 20 | - modernize |
| 21 | 21 | - add emulated mc6845 hook-up |
| 22 | 22 | - fix video update. |
| 23 | - rewrite video drawing functions (they are horrible) | |
| 24 | - add VESA etc. | |
| 25 | - "System Information" UI currently crashes the emulation | |
| 23 | - rewrite video drawing functions (they are horrible) | |
| 24 | - add VESA etc. | |
| 25 | - "System Information" UI currently crashes the emulation | |
| 26 | 26 | - (and many more ...) |
| 27 | 27 | |
| 28 | per-game issues: | |
| 29 | - The Incredible Machine: fix partial updates | |
| 30 | - MAME 0.01: fix 92 Hz refresh rate bug (uses VESA register?). | |
| 31 | - Bio Menace: jerky H scrolling (uses EGA mode) | |
| 28 | per-game issues: | |
| 29 | - The Incredible Machine: fix partial updates | |
| 30 | - MAME 0.01: fix 92 Hz refresh rate bug (uses VESA register?). | |
| 31 | - Bio Menace: jerky H scrolling (uses EGA mode) | |
| 32 | 32 | - Virtual Pool: ET4k unrecognized; |
| 33 | 33 | - California Chase (calchase): init bug causes messed up chars at POST |
| 34 | 34 | (gfxs works if you soft reset). |
| r14260 | r14261 | |
| 728 | 728 | |
| 729 | 729 | /* TODO: 10b and 11b settings aren't known */ |
| 730 | 730 | pixel_clock = (vga.miscellaneous_output & 0xc) ? XTAL_28_63636MHz : XTAL_25_1748MHz; |
| 731 | pixel_clock /= | |
| 731 | pixel_clock /= | |
| 732 | 732 | |
| 733 | 733 | refresh = HZ_TO_ATTOSECONDS(pixel_clock) * (hblank_period) * vblank_period; |
| 734 | 734 | |
| 735 | 735 | machine.primary_screen->configure((hblank_period), (vblank_period), visarea, refresh ); |
| 736 | // | |
| 736 | // popmessage("%d %d\n",vga.crtc.horz_total * 8,vga.crtc.vert_total); | |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | static void crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data) |
| 740 | 740 | { |
| 741 | 741 | /* Doom does this */ |
| 742 | // if(vga.crtc.protect_enable && index <= 0x07) | |
| 743 | // printf("write to protected address %02x\n",index); | |
| 742 | // if(vga.crtc.protect_enable && index <= 0x07) | |
| 743 | // printf("write to protected address %02x\n",index); | |
| 744 | 744 | |
| 745 | 745 | switch(index) |
| 746 | 746 | { |
| r14260 | r14261 | |
| 878 | 878 | break; |
| 879 | 879 | case 0x03: |
| 880 | 880 | /* --2- 84-- character select A |
| 881 | ||
| 881 | ---2 --84 character select B */ | |
| 882 | 882 | vga.sequencer.char_sel.A = (((data & 0xc) >> 2)<<1) | ((data & 0x20) >> 5); |
| 883 | 883 | vga.sequencer.char_sel.B = (((data & 0x3) >> 0)<<1) | ((data & 0x10) >> 4); |
| 884 | 884 | if(data) |
| r14260 | r14261 | |
| 1266 | 1266 | |
| 1267 | 1267 | READ8_HANDLER(vga_mem_r) |
| 1268 | 1268 | { |
| 1269 | #if 0 | |
| 1269 | 1270 | switch((vga.gc.data[6] >> 2) & 0x03) |
| 1270 | 1271 | { |
| 1271 | 1272 | case 0: break; |
| r14260 | r14261 | |
| 1273 | 1274 | case 2: offset -= 0x10000; offset &= 0x07fff; break; |
| 1274 | 1275 | case 3: offset -= 0x18000; offset &= 0x07fff; break; |
| 1275 | 1276 | } |
| 1277 | #endif | |
| 1276 | 1278 | |
| 1277 | 1279 | if(vga.sequencer.data[4] & 4) |
| 1278 | 1280 | { |
| r14260 | r14261 | |
| 1319 | 1321 | |
| 1320 | 1322 | WRITE8_HANDLER(vga_mem_w) |
| 1321 | 1323 | { |
| 1324 | //Inside each case must prevent writes to non-mapped VGA memory regions, not only mask the offset. | |
| 1322 | 1325 | switch((vga.gc.data[6] >> 2) & 0x03) |
| 1323 | 1326 | { |
| 1324 | 1327 | case 0: break; |
| 1325 | case 1: offset &= 0x0ffff; break; | |
| 1326 | case 2: offset -= 0x10000; offset &= 0x07fff; break; | |
| 1327 | case 3: offset -= 0x18000; offset &= 0x07fff; break; | |
| 1328 | case 1: | |
| 1329 | if(offset & 0x10000) | |
| 1330 | return; | |
| 1331 | ||
| 1332 | offset &= 0x0ffff; | |
| 1333 | break; | |
| 1334 | case 2: | |
| 1335 | if((offset & 0x18000) != 0x10000) | |
| 1336 | return; | |
| 1337 | ||
| 1338 | offset &= 0x07fff; | |
| 1339 | break; | |
| 1340 | case 3: | |
| 1341 | if((offset & 0x18000) != 0x18000) | |
| 1342 | return; | |
| 1343 | ||
| 1344 | offset &= 0x07fff; | |
| 1345 | break; | |
| 1328 | 1346 | } |
| 1329 | 1347 | |
| 1330 | 1348 | { |
| r14260 | r14261 | |
|---|---|---|
| 446 | 446 | |
| 447 | 447 | |
| 448 | 448 | //------------------------------------------------- |
| 449 | // mark_tile_dirty - mark a single tile dirty | |
| 449 | // mark_tile_dirty - mark a single tile dirty | |
| 450 | 450 | // based on its memory index |
| 451 | 451 | //------------------------------------------------- |
| 452 | 452 | |
| r14260 | r14261 | |
| 467 | 467 | |
| 468 | 468 | |
| 469 | 469 | //------------------------------------------------- |
| 470 | // map_pens_to_layer - specify the mapping of one | |
| 471 | // or more pens (where (<pen> & mask) == pen) to | |
| 470 | // map_pens_to_layer - specify the mapping of one | |
| 471 | // or more pens (where (<pen> & mask) == pen) to | |
| 472 | 472 | // a layer |
| 473 | 473 | //------------------------------------------------- |
| 474 | 474 | |
| r14260 | r14261 | |
| 503 | 503 | |
| 504 | 504 | |
| 505 | 505 | //------------------------------------------------- |
| 506 | // set_transparent_pen - set a single transparent | |
| 507 | // pen into the tilemap, mapping all other pens | |
| 506 | // set_transparent_pen - set a single transparent | |
| 507 | // pen into the tilemap, mapping all other pens | |
| 508 | 508 | // to layer 0 |
| 509 | 509 | //------------------------------------------------- |
| 510 | 510 | |
| r14260 | r14261 | |
| 519 | 519 | |
| 520 | 520 | |
| 521 | 521 | //------------------------------------------------- |
| 522 | // set_transmask - set up the first 32 pens using | |
| 523 | // a foreground mask (mapping to layer 0) and a | |
| 522 | // set_transmask - set up the first 32 pens using | |
| 523 | // a foreground mask (mapping to layer 0) and a | |
| 524 | 524 | // background mask (mapping to layer 1) |
| 525 | 525 | //------------------------------------------------- |
| 526 | 526 | |
| r14260 | r14261 | |
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | //------------------------------------------------- |
| 604 | // postload - after loading a save state | |
| 604 | // postload - after loading a save state | |
| 605 | 605 | // invalidate everything |
| 606 | 606 | //------------------------------------------------- |
| 607 | 607 | |
| r14260 | r14261 | |
| 918 | 918 | |
| 919 | 919 | |
| 920 | 920 | //------------------------------------------------- |
| 921 | // draw_common - draw a tilemap to the | |
| 921 | // draw_common - draw a tilemap to the | |
| 922 | 922 | // destination with clipping; pixels apply |
| 923 | 923 | // priority/priority_mask to the priority bitmap |
| 924 | 924 | //------------------------------------------------- |
| r14260 | r14261 | |
| 1037 | 1037 | |
| 1038 | 1038 | |
| 1039 | 1039 | //------------------------------------------------- |
| 1040 | // draw_roz - draw a tilemap to the destination | |
| 1041 | // with clipping and arbitrary rotate/zoom; pixels | |
| 1042 | // apply priority/priority_mask to the priority | |
| 1040 | // draw_roz - draw a tilemap to the destination | |
| 1041 | // with clipping and arbitrary rotate/zoom; pixels | |
| 1042 | // apply priority/priority_mask to the priority | |
| 1043 | 1043 | // bitmap |
| 1044 | 1044 | //------------------------------------------------- |
| 1045 | 1045 | |
| r14260 | r14261 | |
| 1090 | 1090 | |
| 1091 | 1091 | |
| 1092 | 1092 | //------------------------------------------------- |
| 1093 | // draw_instance - draw a single instance of the | |
| 1094 | // tilemap to the internal pixmap at the given | |
| 1093 | // draw_instance - draw a single instance of the | |
| 1094 | // tilemap to the internal pixmap at the given | |
| 1095 | 1095 | // xpos,ypos |
| 1096 | 1096 | //------------------------------------------------- |
| 1097 | 1097 | |
| r14260 | r14261 | |
| 1481 | 1481 | |
| 1482 | 1482 | |
| 1483 | 1483 | //------------------------------------------------- |
| 1484 | // set_flip_all - set a global flip for all the | |
| 1484 | // set_flip_all - set a global flip for all the | |
| 1485 | 1485 | // tilemaps |
| 1486 | 1486 | //------------------------------------------------- |
| 1487 | 1487 | |
| r14260 | r14261 | |
| 1497 | 1497 | |
| 1498 | 1498 | |
| 1499 | 1499 | //------------------------------------------------- |
| 1500 | // set_flip_all - set a global flip for all the | |
| 1500 | // set_flip_all - set a global flip for all the | |
| 1501 | 1501 | // tilemaps |
| 1502 | 1502 | //------------------------------------------------- |
| 1503 | 1503 | |
| r14260 | r14261 | |
| 1509 | 1509 | |
| 1510 | 1510 | |
| 1511 | 1511 | //------------------------------------------------- |
| 1512 | // mark_all_dirty - mark all the tiles in all the | |
| 1512 | // mark_all_dirty - mark all the tiles in all the | |
| 1513 | 1513 | // tilemaps dirty |
| 1514 | 1514 | //------------------------------------------------- |
| 1515 | 1515 |
| r14260 | r14261 | |
|---|---|---|
| 419 | 419 | class tilemap_t |
| 420 | 420 | { |
| 421 | 421 | DISABLE_COPYING(tilemap_t); |
| 422 | ||
| 422 | ||
| 423 | 423 | friend class tilemap_manager; |
| 424 | 424 | friend class simple_list<tilemap_t>; |
| 425 | 425 | friend resource_pool_object<tilemap_t>::~resource_pool_object(); |
| r14260 | r14261 | |
| 455 | 455 | bitmap_ind8 &flagsmap() { pixmap_update(); return m_flagsmap; } |
| 456 | 456 | UINT8 *tile_flags() { pixmap_update(); return m_tileflags; } |
| 457 | 457 | tilemap_memory_index memory_index(UINT32 col, UINT32 row) { return m_mapper(col, row, m_cols, m_rows); } |
| 458 | ||
| 458 | ||
| 459 | 459 | // setters |
| 460 | 460 | void enable(bool enable = true) { m_enable = enable; } |
| 461 | 461 | void set_user_data(void *user_data) { m_user_data = user_data; } |
| r14260 | r14261 | |
| 505 | 505 | UINT8 value; |
| 506 | 506 | UINT8 alpha; |
| 507 | 507 | }; |
| 508 | ||
| 508 | ||
| 509 | 509 | // inline helpers |
| 510 | 510 | INT32 effective_rowscroll(int index, UINT32 screen_width); |
| 511 | 511 | INT32 effective_colscroll(int index, UINT32 screen_height); |
| 512 | 512 | bool gfx_elements_changed(); |
| 513 | ||
| 513 | ||
| 514 | 514 | // inline scanline rasterizers |
| 515 | 515 | void scanline_draw_opaque_null(int count, UINT8 *pri, UINT32 pcode); |
| 516 | 516 | void scanline_draw_masked_null(const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode); |
| r14260 | r14261 | |
| 600 | 600 | public: |
| 601 | 601 | // construction/destuction |
| 602 | 602 | tilemap_manager(running_machine &machine); |
| 603 | ||
| 603 | ||
| 604 | 604 | // getters |
| 605 | 605 | running_machine &machine() const { return m_machine; } |
| 606 | ||
| 606 | ||
| 607 | 607 | // tilemap creation |
| 608 | 608 | tilemap_t &create(tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, int tilewidth, int tileheight, int cols, int rows); |
| 609 | 609 | tilemap_t &create(tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); |
| r14260 | r14261 | |
| 622 | 622 | |
| 623 | 623 | // internal state |
| 624 | 624 | running_machine & m_machine; |
| 625 | simple_list<tilemap_t> | |
| 625 | simple_list<tilemap_t> | |
| 626 | 626 | int m_instance; |
| 627 | 627 | }; |
| 628 | 628 | |
| r14260 | r14261 | |
| 643 | 643 | // function definition for a logical-to-memory mapper |
| 644 | 644 | #define TILEMAP_MAPPER(_name) tilemap_memory_index _name(running_machine &machine, UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows) |
| 645 | 645 | |
| 646 | // useful macro inside of a TILE_GET_INFO callback to set tile information | |
| 646 | // useful macro inside of a TILE_GET_INFO callback to set tile information | |
| 647 | 647 | #define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS) tileinfo.set(machine, GFX, CODE, COLOR, FLAGS) |
| 648 | 648 | #define SET_TILE_INFO_DEVICE(GFX,CODE,COLOR,FLAGS) tileinfo.set(device->machine(), GFX, CODE, COLOR, FLAGS) |
| 649 | 649 |
| r14260 | r14261 | |
|---|---|---|
| 915 | 915 | failed_starts++; |
| 916 | 916 | } |
| 917 | 917 | } |
| 918 | ||
| 918 | ||
| 919 | 919 | // each iteration should reduce the number of failed starts; error if |
| 920 | 920 | // this doesn't happen |
| 921 | 921 | if (failed_starts == last_failed_starts) |
| r14260 | r14261 | |
| 954 | 954 | device->stop(); |
| 955 | 955 | |
| 956 | 956 | // then nuke the device tree |
| 957 | // | |
| 957 | // global_free(m_root_device); | |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | |
| 961 | 961 | //------------------------------------------------- |
| 962 | // presave_all_devices - tell all the devices we | |
| 962 | // presave_all_devices - tell all the devices we | |
| 963 | 963 | // are about to save |
| 964 | 964 | //------------------------------------------------- |
| 965 | 965 | |
| r14260 | r14261 | |
| 972 | 972 | |
| 973 | 973 | |
| 974 | 974 | //------------------------------------------------- |
| 975 | // postload_all_devices - tell all the devices we | |
| 975 | // postload_all_devices - tell all the devices we | |
| 976 | 976 | // just completed a load |
| 977 | 977 | //------------------------------------------------- |
| 978 | 978 | |
| r14260 | r14261 | |
| 1266 | 1266 | |
| 1267 | 1267 | |
| 1268 | 1268 | //------------------------------------------------- |
| 1269 | // device_reset_after_children - device override | |
| 1269 | // device_reset_after_children - device override | |
| 1270 | 1270 | // which calls the various helpers; must happen |
| 1271 | 1271 | // after all child devices are reset |
| 1272 | 1272 | //------------------------------------------------- |
| r14260 | r14261 | |
|---|---|---|
| 124 | 124 | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | FLAC__StreamDecoderWriteStatus my_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) | |
| 127 | FLAC__StreamDecoderWriteStatus my_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) | |
| 128 | 128 | { |
| 129 | 129 | //printf("my_write_callback\n"); |
| 130 | 130 | //printf("array size %d\n",frame->header.blocksize); |
| r14260 | r14261 | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | flacrd->write_position += frame->header.blocksize; |
| 143 | ||
| 143 | ||
| 144 | 144 | return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; |
| 145 | 145 | } |
| 146 | 146 | |
| r14260 | r14261 | |
| 328 | 328 | return 0; |
| 329 | 329 | |
| 330 | 330 | int size = flacread.total_samples * (flacread.bits_per_sample/8); |
| 331 | ||
| 331 | ||
| 332 | 332 | sample->data = auto_alloc_array(machine, INT16, size); |
| 333 | 333 | flacread.write_position = 0; |
| 334 | 334 | flacread.write_data = sample->data; |
| r14260 | r14261 | |
| 342 | 342 | FLAC__stream_decoder_delete(decoder); |
| 343 | 343 | |
| 344 | 344 | /* fill in the sample data */ |
| 345 | ||
| 345 | ||
| 346 | 346 | sample->frequency = flacread.sample_rate; |
| 347 | 347 | sample->length = size; |
| 348 | 348 |
| r14260 | r14261 | |
|---|---|---|
| 130 | 130 | m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() / divisor); |
| 131 | 131 | |
| 132 | 132 | save_item(NAME(m_command)); |
| 133 | save_item(NAME(m_bank_installed)); | |
| 134 | 133 | save_item(NAME(m_bank_offs)); |
| 135 | 134 | save_item(NAME(m_pin7_state)); |
| 136 | 135 |
| r14260 | r14261 | |
|---|---|---|
| 444 | 444 | void fill_systime(system_time &systime, time_t t); |
| 445 | 445 | void handle_saveload(); |
| 446 | 446 | void soft_reset(void *ptr = NULL, INT32 param = 0); |
| 447 | ||
| 447 | ||
| 448 | 448 | // internal callbacks |
| 449 | 449 | static void logfile_callback(running_machine &machine, const char *buffer); |
| 450 | 450 |
| r14260 | r14261 | |
|---|---|---|
| 59 | 59 | |
| 60 | 60 | public: |
| 61 | 61 | // construction/destruction |
| 62 | simple_list(resource_pool &pool = global_resource_pool()) | |
| 62 | simple_list(resource_pool &pool = global_resource_pool()) | |
| 63 | 63 | : m_head(NULL), |
| 64 | 64 | m_tail(NULL), |
| 65 | 65 | m_pool(pool), |
| r14260 | r14261 | |
|---|---|---|
| 190 | 190 | float y0; // topmost Y coordinate |
| 191 | 191 | float x1; // rightmost X coordinate |
| 192 | 192 | float y1; // bottommost Y coordinate |
| 193 | ||
| 193 | ||
| 194 | 194 | float width() const { return x1 - x0; } |
| 195 | 195 | float height() const { return y1 - y0; } |
| 196 | 196 | }; |
| r14260 | r14261 | |
|---|---|---|
| 72 | 72 | //************************************************************************** |
| 73 | 73 | |
| 74 | 74 | //------------------------------------------------- |
| 75 | // ioport_string_from_index - return an indexed | |
| 75 | // ioport_string_from_index - return an indexed | |
| 76 | 76 | // string from the I/O port system |
| 77 | 77 | //------------------------------------------------- |
| 78 | 78 | |
| r14260 | r14261 | |
| 200 | 200 | { |
| 201 | 201 | // initialize |
| 202 | 202 | validate_begin(); |
| 203 | ||
| 203 | ||
| 204 | 204 | // then iterate over all drivers and check the ones that share the same source file |
| 205 | 205 | m_drivlist.reset(); |
| 206 | 206 | while (m_drivlist.next()) |
| 207 | 207 | if (strcmp(driver.source_file, m_drivlist.driver().source_file) == 0) |
| 208 | 208 | validate_one(m_drivlist.driver()); |
| 209 | ||
| 209 | ||
| 210 | 210 | // cleanup |
| 211 | 211 | validate_end(); |
| 212 | 212 | } |
| r14260 | r14261 | |
| 222 | 222 | validate_begin(); |
| 223 | 223 | validate_core(); |
| 224 | 224 | validate_inlines(); |
| 225 | ||
| 225 | ||
| 226 | 226 | // then iterate over all drivers and check them |
| 227 | 227 | m_drivlist.reset(); |
| 228 | 228 | while (m_drivlist.next()) |
| 229 | 229 | validate_one(m_drivlist.driver()); |
| 230 | ||
| 230 | ||
| 231 | 231 | // cleanup |
| 232 | 232 | validate_end(); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | //------------------------------------------------- |
| 237 | // validate_begin - prepare for validation by | |
| 238 | // taking over the output callbacks and resetting | |
| 237 | // validate_begin - prepare for validation by | |
| 238 | // taking over the output callbacks and resetting | |
| 239 | 239 | // our internal state |
| 240 | 240 | //------------------------------------------------- |
| 241 | 241 | |
| r14260 | r14261 | |
| 244 | 244 | // take over error and warning outputs |
| 245 | 245 | m_saved_error_output = mame_set_output_channel(OUTPUT_CHANNEL_ERROR, output_delegate(FUNC(validity_checker::error_output), this)); |
| 246 | 246 | m_saved_warning_output = mame_set_output_channel(OUTPUT_CHANNEL_WARNING, output_delegate(FUNC(validity_checker::warning_output), this)); |
| 247 | ||
| 247 | ||
| 248 | 248 | // reset all our maps |
| 249 | 249 | m_names_map.reset(); |
| 250 | 250 | m_descriptions_map.reset(); |
| 251 | 251 | m_roms_map.reset(); |
| 252 | 252 | m_defstr_map.reset(); |
| 253 | 253 | m_region_map.reset(); |
| 254 | ||
| 254 | ||
| 255 | 255 | // reset internal state |
| 256 | 256 | m_errors = 0; |
| 257 | 257 | m_warnings = 0; |
| 258 | ||
| 258 | ||
| 259 | 259 | // reset some special case state |
| 260 | 260 | software_list_device::reset_checked_lists(); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | |
| 264 | 264 | //------------------------------------------------- |
| 265 | // validate_end - restore output callbacks and | |
| 265 | // validate_end - restore output callbacks and | |
| 266 | 266 | // clean up |
| 267 | 267 | //------------------------------------------------- |
| 268 | 268 | |
| r14260 | r14261 | |
| 286 | 286 | m_current_device = NULL; |
| 287 | 287 | m_current_ioport = NULL; |
| 288 | 288 | m_region_map.reset(); |
| 289 | ||
| 289 | ||
| 290 | 290 | // reset error/warning state |
| 291 | 291 | int start_errors = m_errors; |
| 292 | 292 | int start_warnings = m_warnings; |
| r14260 | r14261 | |
| 314 | 314 | mame_printf_error("Fatal error %s", err.string()); |
| 315 | 315 | } |
| 316 | 316 | m_current_config = NULL; |
| 317 | ||
| 317 | ||
| 318 | 318 | // if we had warnings or errors, output |
| 319 | 319 | if (m_errors > start_errors || m_warnings > start_warnings) |
| 320 | 320 | { |
| r14260 | r14261 | |
| 625 | 625 | { |
| 626 | 626 | // for non-root devices, track the current device |
| 627 | 627 | m_current_device = (source == &m_current_config->root_device()) ? NULL : source; |
| 628 | ||
| 628 | ||
| 629 | 629 | // scan the ROM entries for this device |
| 630 | 630 | const char *last_region_name = "???"; |
| 631 | 631 | const char *last_name = "???"; |
| r14260 | r14261 | |
| 660 | 660 | // generate the full tag |
| 661 | 661 | astring fulltag; |
| 662 | 662 | rom_region_name(fulltag, m_current_driver, source, romp); |
| 663 | ||
| 663 | ||
| 664 | 664 | // attempt to add it to the map, reporting duplicates as errors |
| 665 | 665 | current_length = ROMREGION_GETLENGTH(romp); |
| 666 | 666 | if (m_region_map.add(fulltag, current_length, false) == TMERR_DUPLICATE) |
| r14260 | r14261 | |
| 807 | 807 | |
| 808 | 808 | int xscale = (m_current_config->m_gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : m_current_config->m_gfxdecodeinfo[gfxnum].xscale; |
| 809 | 809 | int yscale = (m_current_config->m_gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : m_current_config->m_gfxdecodeinfo[gfxnum].yscale; |
| 810 | ||
| 810 | ||
| 811 | 811 | // verify raw decode, which can only be full-region and have no scaling |
| 812 | 812 | if (layout.planeoffset[0] == GFX_RAW) |
| 813 | 813 | { |
| r14260 | r14261 | |
| 816 | 816 | if (xscale != 1 || yscale != 1) |
| 817 | 817 | mame_printf_error("gfx[%d] with unsupported xscale/yscale\n", gfxnum); |
| 818 | 818 | } |
| 819 | ||
| 819 | ||
| 820 | 820 | // verify traditional decode doesn't have too many planes or is not too large |
| 821 | 821 | else |
| 822 | 822 | { |
| r14260 | r14261 | |
| 989 | 989 | // resolve the tag |
| 990 | 990 | astring porttag; |
| 991 | 991 | device.subtag(porttag, condition.tag); |
| 992 | ||
| 992 | ||
| 993 | 993 | // then find a matching port |
| 994 | 994 | if (port_map.find(porttag) == 0) |
| 995 | 995 | mame_printf_error("Condition referencing non-existent ioport tag '%s'\n", condition.tag); |
| r14260 | r14261 | |
| 1019 | 1019 | ioport_list portlist; |
| 1020 | 1020 | astring errorbuf; |
| 1021 | 1021 | input_port_list_init(*device, portlist, errorbuf); |
| 1022 | ||
| 1022 | ||
| 1023 | 1023 | // report any errors during construction |
| 1024 | 1024 | if (errorbuf) |
| 1025 | 1025 | mame_printf_error("I/O port error during construction:\n%s\n", errorbuf.cstr()); |
| r14260 | r14261 | |
| 1084 | 1084 | if (setting->condition.tag != NULL) |
| 1085 | 1085 | validate_condition(setting->condition, *device, port_map); |
| 1086 | 1086 | } |
| 1087 | ||
| 1087 | ||
| 1088 | 1088 | // done with this port |
| 1089 | 1089 | m_current_ioport = NULL; |
| 1090 | 1090 | } |
| r14260 | r14261 | |
| 1149 | 1149 | // instantiate the device |
| 1150 | 1150 | device_t *dev = (*intf[j].devtype)(*m_current_config, "dummy", &m_current_config->root_device(), 0); |
| 1151 | 1151 | dev->config_complete(); |
| 1152 | ||
| 1152 | ||
| 1153 | 1153 | // if a ROM region is present |
| 1154 | 1154 | if (dev->rom_region() != NULL) |
| 1155 | 1155 | { |
| r14260 | r14261 | |
| 1161 | 1161 | break; |
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | if (has_romfiles) | |
| 1164 | if (has_romfiles) | |
| 1165 | 1165 | { |
| 1166 | 1166 | // scan the list of devices for this device type |
| 1167 | 1167 | bool found = false; |
| r14260 | r14261 | |
| 1184 | 1184 | |
| 1185 | 1185 | |
| 1186 | 1186 | //------------------------------------------------- |
| 1187 | // build_output_prefix - create a prefix | |
| 1187 | // build_output_prefix - create a prefix | |
| 1188 | 1188 | // indicating the current source file, driver, |
| 1189 | 1189 | // and device |
| 1190 | 1190 | //------------------------------------------------- |
| r14260 | r14261 | |
| 1193 | 1193 | { |
| 1194 | 1194 | // start empty |
| 1195 | 1195 | string.reset(); |
| 1196 | ||
| 1196 | ||
| 1197 | 1197 | // if we have a current device, indicate that |
| 1198 | 1198 | if (m_current_device != NULL) |
| 1199 | 1199 | string.cat(m_current_device->name()).cat(" device '").cat(m_current_device->tag()).cat("': "); |
| 1200 | ||
| 1200 | ||
| 1201 | 1201 | // if we have a current port, indicate that as well |
| 1202 | 1202 | if (m_current_ioport != NULL) |
| 1203 | 1203 | string.cat("ioport '").cat(m_current_ioport).cat("': "); |
| r14260 | r14261 | |
| 1212 | 1212 | { |
| 1213 | 1213 | // count the error |
| 1214 | 1214 | m_errors++; |
| 1215 | ||
| 1215 | ||
| 1216 | 1216 | // output the source(driver) device 'tag' |
| 1217 | 1217 | astring output; |
| 1218 | 1218 | build_output_prefix(output); |
| r14260 | r14261 | |
| 1224 | 1224 | |
| 1225 | 1225 | |
| 1226 | 1226 | //------------------------------------------------- |
| 1227 | // warning_output - warning message output | |
| 1227 | // warning_output - warning message output | |
| 1228 | 1228 | // override |
| 1229 | 1229 | //------------------------------------------------- |
| 1230 | 1230 | |
| r14260 | r14261 | |
| 1232 | 1232 | { |
| 1233 | 1233 | // count the error |
| 1234 | 1234 | m_warnings++; |
| 1235 | ||
| 1235 | ||
| 1236 | 1236 | // output the source(driver) device 'tag' |
| 1237 | 1237 | astring output; |
| 1238 | 1238 | build_output_prefix(output); |
| r14260 | r14261 | |
|---|---|---|
| 63 | 63 | public: |
| 64 | 64 | validity_checker(emu_options &options); |
| 65 | 65 | |
| 66 | // getters | |
| 66 | // getters | |
| 67 | 67 | int errors() const { return m_errors; } |
| 68 | 68 | int warnings() const { return m_warnings; } |
| 69 | 69 | |
| 70 | // operations | |
| 70 | // operations | |
| 71 | 71 | void check_driver(const game_driver &driver); |
| 72 | 72 | void check_shared_source(const game_driver &driver); |
| 73 | 73 | void check_all(); |
| 74 | 74 | |
| 75 | 75 | // helpers for devices |
| 76 | 76 | void validate_tag(const char *tag); |
| 77 | ||
| 77 | ||
| 78 | 78 | private: |
| 79 | 79 | // internal helpers |
| 80 | 80 | const char *ioport_string_from_index(UINT32 index); |
| r14260 | r14261 | |
| 84 | 84 | void validate_begin(); |
| 85 | 85 | void validate_end(); |
| 86 | 86 | void validate_one(const game_driver &driver); |
| 87 | ||
| 87 | ||
| 88 | 88 | // internal sub-checks |
| 89 | 89 | void validate_core(); |
| 90 | 90 | void validate_inlines(); |
| r14260 | r14261 | |
| 106 | 106 | void output_via_delegate(output_delegate &delegate, const char *format, ...); |
| 107 | 107 | |
| 108 | 108 | // internal driver list |
| 109 | driver_enumerator m_drivlist; | |
| 110 | ||
| 109 | driver_enumerator m_drivlist; | |
| 110 | ||
| 111 | 111 | // error tracking |
| 112 | 112 | int m_errors; |
| 113 | 113 | int m_warnings; |
| r14260 | r14261 | |
| 128 | 128 | int_map m_region_map; |
| 129 | 129 | |
| 130 | 130 | // callbacks |
| 131 | output_delegate m_saved_error_output; | |
| 132 | output_delegate m_saved_warning_output; | |
| 131 | output_delegate m_saved_error_output; | |
| 132 | output_delegate m_saved_warning_output; | |
| 133 | 133 | }; |
| 134 | 134 | |
| 135 | 135 | #endif |
| r14260 | r14261 | |
|---|---|---|
| 154 | 154 | |
| 155 | 155 | chd_file *get_disk_handle(running_machine &machine, const char *region) |
| 156 | 156 | { |
| 157 | ||
| 157 | ||
| 158 | 158 | if (strcmp(curdisk->region(), region) == 0) |
| 159 | 159 | return curdisk->chd(); |
| 160 | 160 | return NULL; |
| r14260 | r14261 | |
|---|---|---|
| 203 | 203 | fd = fopen(filename.cstr(), "r"); |
| 204 | 204 | if(!fd) |
| 205 | 205 | return 0; |
| 206 | ||
| 206 | ||
| 207 | 207 | io_generic io; |
| 208 | 208 | io.file = fd; |
| 209 | 209 | io.procs = &stdio_ioprocs_noclose; |
| r14260 | r14261 | |
| 610 | 610 | |
| 611 | 611 | ui_menu_control_floppy_image::ui_menu_control_floppy_image(running_machine &machine, render_container *container, device_image_interface *_image) : ui_menu_control_device_image(machine, container, _image) |
| 612 | 612 | { |
| 613 | floppy_image_device *fd = static_cast<floppy_image_device *>(image); | |
| 613 | floppy_image_device *fd = static_cast<floppy_image_device *>(image); | |
| 614 | 614 | const floppy_image_format_t *fif_list = fd->get_formats(); |
| 615 | 615 | int fcnt = 0; |
| 616 | 616 | for(const floppy_image_format_t *i = fif_list; i; i = i->next) |
| 617 | 617 | fcnt++; |
| 618 | ||
| 618 | ||
| 619 | 619 | format_array = global_alloc_array(floppy_image_format_t *, fcnt); |
| 620 | 620 | input_format = output_format = 0; |
| 621 | 621 | input_filename = output_filename = ""; |
| r14260 | r14261 | |
| 628 | 628 | |
| 629 | 629 | void ui_menu_control_floppy_image::do_load_create() |
| 630 | 630 | { |
| 631 | floppy_image_device *fd = static_cast<floppy_image_device *>(image); | |
| 631 | floppy_image_device *fd = static_cast<floppy_image_device *>(image); | |
| 632 | 632 | if(input_filename == "") { |
| 633 | 633 | int err = fd->create(output_filename, 0, NULL); |
| 634 | 634 | if (err != 0) { |
| r14260 | r14261 | |
| 678 | 678 | |
| 679 | 679 | void ui_menu_control_floppy_image::handle() |
| 680 | 680 | { |
| 681 | floppy_image_device *fd = static_cast<floppy_image_device *>(image); | |
| 681 | floppy_image_device *fd = static_cast<floppy_image_device *>(image); | |
| 682 | 682 | switch(state) { |
| 683 | 683 | case DO_CREATE: { |
| 684 | 684 | floppy_image_format_t *fif_list = fd->get_formats(); |
| r14260 | r14261 | |
|---|---|---|
| 110 | 110 | m_clock(clock), |
| 111 | 111 | m_clock_scale(1.0), |
| 112 | 112 | m_attoseconds_per_clock((clock == 0) ? 0 : HZ_TO_ATTOSECONDS(clock)), |
| 113 | ||
| 113 | ||
| 114 | 114 | m_debug(NULL), |
| 115 | 115 | m_region(NULL), |
| 116 | 116 | m_machine_config(mconfig), |
| r14260 | r14261 | |
| 148 | 148 | m_clock(clock), |
| 149 | 149 | m_clock_scale(1.0), |
| 150 | 150 | m_attoseconds_per_clock((clock == 0) ? 0 : HZ_TO_ATTOSECONDS(clock)), |
| 151 | ||
| 151 | ||
| 152 | 152 | m_debug(NULL), |
| 153 | 153 | m_region(NULL), |
| 154 | 154 | m_machine_config(mconfig), |
| r14260 | r14261 | |
| 262 | 262 | |
| 263 | 263 | // reset the device |
| 264 | 264 | device_reset(); |
| 265 | ||
| 265 | ||
| 266 | 266 | // reset all child devices |
| 267 | 267 | for (device_t *child = m_subdevice_list.first(); child != NULL; child = child->next()) |
| 268 | 268 | child->reset(); |
| 269 | ||
| 269 | ||
| 270 | 270 | // now allow for some post-child reset action |
| 271 | 271 | device_reset_after_children(); |
| 272 | 272 | |
| r14260 | r14261 | |
| 695 | 695 | if (part == curdevice->m_basetag) |
| 696 | 696 | break; |
| 697 | 697 | } |
| 698 | ||
| 698 | ||
| 699 | 699 | // if we got a match, add to the fast map |
| 700 | 700 | if (curdevice != NULL) |
| 701 | 701 | { |
| r14260 | r14261 | |
| 719 | 719 | tag++; |
| 720 | 720 | result.cpy(":"); |
| 721 | 721 | } |
| 722 | ||
| 722 | ||
| 723 | 723 | // otherwise, start with our path |
| 724 | 724 | else |
| 725 | 725 | { |
| r14260 | r14261 | |
| 735 | 735 | // copy everything up to there |
| 736 | 736 | result.cat(tag, caret - tag); |
| 737 | 737 | tag = caret + 1; |
| 738 | ||
| 738 | ||
| 739 | 739 | // strip trailing colons |
| 740 | 740 | int len = result.len(); |
| 741 | 741 | while (result[--len] == ':') |
| 742 | 742 | result.substr(0, len); |
| 743 | ||
| 743 | ||
| 744 | 744 | // remove the last path part, leaving the last colon |
| 745 | 745 | if (result != ":") |
| 746 | 746 | { |
| r14260 | r14261 | |
| 792 | 792 | for (device_t *scan = iter.first(); scan != NULL; scan = iter.next()) |
| 793 | 793 | scan->m_device_map.remove(&old); |
| 794 | 794 | |
| 795 | // create a new device, and substitute it for the old one | |
| 795 | // create a new device, and substitute it for the old one | |
| 796 | 796 | device_t *device = (*type)(mconfig(), tag, this, clock); |
| 797 | 797 | m_subdevice_list.replace_and_remove(*device, old); |
| 798 | 798 |
| r14260 | r14261 | |
|---|---|---|
| 470 | 470 | m_current(NULL), |
| 471 | 471 | m_curdepth(0), |
| 472 | 472 | m_maxdepth(maxdepth) { } |
| 473 | ||
| 473 | ||
| 474 | 474 | // getters |
| 475 | 475 | device_t *current() const { return m_current; } |
| 476 | 476 | |
| r14260 | r14261 | |
| 480 | 480 | // reset and return first item |
| 481 | 481 | device_t *first() |
| 482 | 482 | { |
| 483 | m_current = m_root; | |
| 483 | m_current = m_root; | |
| 484 | 484 | return m_current; |
| 485 | 485 | } |
| 486 | 486 | |
| r14260 | r14261 | |
| 502 | 502 | return m_current; |
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | ||
| 505 | ||
| 506 | 506 | // search next for neighbors up the ownership chain |
| 507 | 507 | while (m_curdepth > 0) |
| 508 | 508 | { |
| r14260 | r14261 | |
| 511 | 511 | if (m_current != NULL) |
| 512 | 512 | return m_current; |
| 513 | 513 | |
| 514 | // no? try our parent | |
| 514 | // no? try our parent | |
| 515 | 515 | start = start->owner(); |
| 516 | 516 | m_curdepth--; |
| 517 | 517 | } |
| 518 | ||
| 518 | ||
| 519 | 519 | // returned to the top; we're done |
| 520 | 520 | return m_current = NULL; |
| 521 | 521 | } |
| 522 | ||
| 522 | ||
| 523 | 523 | // return the number of items available |
| 524 | 524 | int count() |
| 525 | 525 | { |
| 526 | int result = 0; | |
| 526 | int result = 0; | |
| 527 | 527 | for (device_t *item = first(); item != NULL; item = next()) |
| 528 | 528 | result++; |
| 529 | 529 | return result; |
| 530 | 530 | } |
| 531 | ||
| 531 | ||
| 532 | 532 | // return the index of a given item in the virtual list |
| 533 | 533 | int indexof(device_t &device) |
| 534 | 534 | { |
| r14260 | r14261 | |
| 591 | 591 | return downcast<_DeviceClass *>(device); |
| 592 | 592 | return NULL; |
| 593 | 593 | } |
| 594 | ||
| 594 | ||
| 595 | 595 | // return the number of items available |
| 596 | 596 | int count() |
| 597 | 597 | { |
| 598 | int result = 0; | |
| 598 | int result = 0; | |
| 599 | 599 | for (_DeviceClass *item = first(); item != NULL; item = next()) |
| 600 | 600 | result++; |
| 601 | 601 | return result; |
| 602 | 602 | } |
| 603 | ||
| 603 | ||
| 604 | 604 | // return the index of a given item in the virtual list |
| 605 | 605 | int indexof(_DeviceClass &device) |
| 606 | 606 | { |
| r14260 | r14261 | |
| 641 | 641 | |
| 642 | 642 | // getters |
| 643 | 643 | _InterfaceClass *current() const { return m_current; } |
| 644 | ||
| 644 | ||
| 645 | 645 | // setters |
| 646 | 646 | void set_current(_InterfaceClass ¤t) { m_current = ¤t; m_iterator.set_current(current.device()); } |
| 647 | 647 | |
| r14260 | r14261 | |
| 662 | 662 | return m_current; |
| 663 | 663 | return NULL; |
| 664 | 664 | } |
| 665 | ||
| 665 | ||
| 666 | 666 | // return the number of items available |
| 667 | 667 | int count() |
| 668 | 668 | { |
| 669 | int result = 0; | |
| 669 | int result = 0; | |
| 670 | 670 | for (_InterfaceClass *item = first(); item != NULL; item = next()) |
| 671 | 671 | result++; |
| 672 | 672 | return result; |
| 673 | 673 | } |
| 674 | ||
| 674 | ||
| 675 | 675 | // return the index of a given item in the virtual list |
| 676 | 676 | int indexof(_InterfaceClass &intrf) |
| 677 | 677 | { |
| r14260 | r14261 | |
| 755 | 755 | |
| 756 | 756 | |
| 757 | 757 | //------------------------------------------------- |
| 758 | // siblingdevice - given a tag, find the device | |
| 758 | // siblingdevice - given a tag, find the device | |
| 759 | 759 | // by name relative to this device's parent |
| 760 | 760 | //------------------------------------------------- |
| 761 | 761 | |
| r14260 | r14261 | |
| 768 | 768 | // empty string or NULL means this device |
| 769 | 769 | if (tag == NULL || *tag == 0) |
| 770 | 770 | return const_cast<device_t *>(this); |
| 771 | ||
| 771 | ||
| 772 | 772 | // leading caret implies the owner, just skip it |
| 773 | 773 | if (tag[0] == '^') tag++; |
| 774 | 774 |
| r14260 | r14261 | |
|---|---|---|
| 234 | 234 | int found = 0; |
| 235 | 235 | |
| 236 | 236 | // iterate over sample entries |
| 237 | samples_device_iterator iter(m_enumerator.config().root_device()); | |
| 237 | samples_device_iterator iter(m_enumerator.config().root_device()); | |
| 238 | 238 | for (samples_device *device = iter.first(); device != NULL; device = iter.next()) |
| 239 | 239 | { |
| 240 | 240 | const samples_interface *intf = reinterpret_cast<const samples_interface *>(device->static_config()); |
| r14260 | r14261 | |
|---|---|---|
| 2233 | 2233 | // determine full tag |
| 2234 | 2234 | astring fulltag; |
| 2235 | 2235 | device().siblingtag(fulltag, entry->m_region); |
| 2236 | ||
| 2236 | ||
| 2237 | 2237 | // set the memory address |
| 2238 | 2238 | entry->m_memory = machine().region(fulltag.cstr())->base() + entry->m_rgnoffs; |
| 2239 | 2239 | } |
| r14260 | r14261 | |
|---|---|---|
| 257 | 257 | // Attempt to register save state entry after state registration is closed! |
| 258 | 258 | state_save_register_item( machine, "scsihd", diskregion, 0, our_this->lba ); |
| 259 | 259 | state_save_register_item( machine, "scsihd", diskregion, 0, our_this->blocks ); |
| 260 | ||
| 260 | ||
| 261 | 261 | // try to locate the CHD from a DISK_REGION |
| 262 | 262 | our_this->handle = get_disk_handle(machine, diskregion); |
| 263 | 263 | our_this->disk = hard_disk_open(our_this->handle); |
| 264 | 264 | our_this->is_image_device = false; |
| 265 | ||
| 265 | ||
| 266 | 266 | if (our_this->disk == NULL) |
| 267 | 267 | { |
| 268 | 268 | // try to locate the CHD from an image device |
| 269 | 269 | harddisk_image_device *image_device = machine.device<harddisk_image_device>(diskregion); |
| 270 | ||
| 270 | ||
| 271 | 271 | if (image_device != NULL) |
| 272 | 272 | { |
| 273 | 273 | our_this->handle = image_device->get_chd_file(); |
| r14260 | r14261 | |
| 275 | 275 | our_this->is_image_device = true; |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | ||
| 278 | ||
| 279 | 279 | if (our_this->disk == NULL) |
| 280 | 280 | { |
| 281 | 281 | // try to locate the CHD from an image subdevice |
| r14260 | r14261 | |
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | ||
| 293 | ||
| 294 | 294 | if (our_this->disk != NULL) |
| 295 | 295 | { |
| 296 | 296 | // get hard disk sector size from CHD metadata |
| r14260 | r14261 | |
|---|---|---|
| 27 | 27 | #include "devhelpr.h" |
| 28 | 28 | |
| 29 | 29 | /*************************************************************************** |
| 30 | ||
| 30 | PARAMETERS | |
| 31 | 31 | ***************************************************************************/ |
| 32 | 32 | |
| 33 | 33 | #define TRACE_VIA 0 |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /*************************************************************************** |
| 37 | ||
| 37 | MACROS | |
| 38 | 38 | ***************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | /* Macros for PCR */ |
| r14260 | r14261 | |
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | /*************************************************************************** |
| 109 | ||
| 109 | INLINE FUNCTIONS | |
| 110 | 110 | ***************************************************************************/ |
| 111 | 111 | |
| 112 | 112 | inline void via6522_device::set_irq_line(int state) |
| r14260 | r14261 | |
| 578 | 578 | CLR_PA_INT(); |
| 579 | 579 | |
| 580 | 580 | /* If CA2 is configured as output and in pulse or handshake mode, |
| 581 | ||
| 581 | CA2 is set now */ | |
| 582 | 582 | if (CA2_PULSE_OUTPUT(m_pcr)) |
| 583 | 583 | { |
| 584 | 584 | /* call the CA2 output function */ |
| r14260 | r14261 | |
| 742 | 742 | CLR_PB_INT(); |
| 743 | 743 | |
| 744 | 744 | /* If CB2 is configured as output and in pulse or handshake mode, |
| 745 | ||
| 745 | CB2 is set now */ | |
| 746 | 746 | if (CB2_AUTO_HS(m_pcr)) |
| 747 | 747 | { |
| 748 | 748 | if (m_out_cb2) |
| r14260 | r14261 | |
| 1015 | 1015 | set_int(INT_CA1); |
| 1016 | 1016 | |
| 1017 | 1017 | /* CA2 is configured as output and in pulse or handshake mode, |
| 1018 | ||
| 1018 | CA2 is cleared now */ | |
| 1019 | 1019 | if (CA2_AUTO_HS(m_pcr)) |
| 1020 | 1020 | { |
| 1021 | 1021 | if (!m_out_ca2) |
| r14260 | r14261 | |
| 1089 | 1089 | set_int(INT_CB1); |
| 1090 | 1090 | |
| 1091 | 1091 | /* CB2 is configured as output and in pulse or handshake mode, |
| 1092 | ||
| 1092 | CB2 is cleared now */ | |
| 1093 | 1093 | if (CB2_AUTO_HS(m_pcr)) |
| 1094 | 1094 | { |
| 1095 | 1095 | if (!m_out_cb2) |
| r14260 | r14261 | |
|---|---|---|
| 320 | 320 | { |
| 321 | 321 | running_machine &machine = device.machine(); |
| 322 | 322 | |
| 323 | // start with either basename or basename_biosnum | |
| 323 | // start with either basename or basename_biosnum | |
| 324 | 324 | result.cpy(machine.basename()); |
| 325 | 325 | if (rom_system_bios(machine) != 0 && rom_default_bios(machine) != rom_system_bios(machine)) |
| 326 | 326 | result.catprintf("_%d", rom_system_bios(machine) - 1); |
| r14260 | r14261 | |
|---|---|---|
| 38 | 38 | inline void im6402_device::set_dr(int state) |
| 39 | 39 | { |
| 40 | 40 | m_dr = state; |
| 41 | ||
| 41 | ||
| 42 | 42 | m_out_dr_func(state); |
| 43 | 43 | } |
| 44 | 44 | |
| r14260 | r14261 | |
| 50 | 50 | inline void im6402_device::set_tbre(int state) |
| 51 | 51 | { |
| 52 | 52 | m_tbre = state; |
| 53 | ||
| 53 | ||
| 54 | 54 | m_out_tbre_func(state); |
| 55 | 55 | } |
| 56 | 56 | |
| r14260 | r14261 | |
| 62 | 62 | inline void im6402_device::set_tre(int state) |
| 63 | 63 | { |
| 64 | 64 | m_tre = state; |
| 65 | ||
| 65 | ||
| 66 | 66 | m_out_tre_func(state); |
| 67 | 67 | } |
| 68 | 68 | |
| r14260 | r14261 | |
| 86 | 86 | { |
| 87 | 87 | receive_register_extract(); |
| 88 | 88 | m_rbr = get_received_char(); |
| 89 | ||
| 89 | ||
| 90 | 90 | if (m_dr) |
| 91 | 91 | { |
| 92 | 92 | m_oe = 1; |
| 93 | 93 | } |
| 94 | ||
| 94 | ||
| 95 | 95 | set_dr(ASSERT_LINE); |
| 96 | 96 | } |
| 97 | 97 | } |
| r14260 | r14261 | |
| 106 | 106 | if (is_transmit_register_empty() && !m_tbre) |
| 107 | 107 | { |
| 108 | 108 | transmit_register_setup(m_tbr); |
| 109 | ||
| 109 | ||
| 110 | 110 | set_tbre(ASSERT_LINE); |
| 111 | 111 | set_tre(CLEAR_LINE); |
| 112 | 112 | } |
| 113 | ||
| 113 | ||
| 114 | 114 | if (!is_transmit_register_empty()) |
| 115 | 115 | { |
| 116 | 116 | int bit = transmit_register_get_data_bit(); |
| 117 | ||
| 117 | ||
| 118 | 118 | m_out_tro_func(bit); |
| 119 | 119 | serial_connection_out(); |
| 120 | ||
| 120 | ||
| 121 | 121 | if (is_transmit_register_empty()) |
| 122 | 122 | { |
| 123 | 123 | set_tre(ASSERT_LINE); |
| r14260 | r14261 | |
| 226 | 226 | m_pe = 0; |
| 227 | 227 | m_fe = 0; |
| 228 | 228 | m_oe = 0; |
| 229 | ||
| 229 | ||
| 230 | 230 | set_dr(CLEAR_LINE); |
| 231 | 231 | set_tbre(ASSERT_LINE); |
| 232 | 232 | set_tre(ASSERT_LINE); |
| r14260 | r14261 | |
| 292 | 292 | if (state) |
| 293 | 293 | { |
| 294 | 294 | m_rrc_count++; |
| 295 | ||
| 295 | ||
| 296 | 296 | if (m_rrc_count == 16) |
| 297 | 297 | { |
| 298 | 298 | receive(); |
| r14260 | r14261 | |
| 311 | 311 | if (state) |
| 312 | 312 | { |
| 313 | 313 | m_trc_count++; |
| 314 | ||
| 314 | ||
| 315 | 315 | if (m_trc_count == 16) |
| 316 | 316 | { |
| 317 | 317 | transmit(); |
| 318 | 318 | m_trc_count = 0; |
| 319 | 319 | } |
| 320 | } | |
| 320 | } | |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | |
| r14260 | r14261 | |
| 436 | 436 | int word_length = 5 + ((m_cls2 << 1) | m_cls1); |
| 437 | 437 | int stop_bits = 1 + m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0; |
| 438 | 438 | int parity_code; |
| 439 | ||
| 440 | if (m_pi) parity_code = SERIAL_PARITY_NONE; | |
| 441 | else if (m_epe) parity_code = SERIAL_PARITY_EVEN; | |
| 439 | ||
| 440 | if (m_pi) parity_code = SERIAL_PARITY_NONE; | |
| 441 | else if (m_epe) parity_code = SERIAL_PARITY_EVEN; | |
| 442 | 442 | else parity_code = SERIAL_PARITY_ODD; |
| 443 | ||
| 443 | ||
| 444 | 444 | set_data_frame(word_length, stop_bits, parity_code); |
| 445 | 445 | } |
| 446 | 446 | } |
| r14260 | r14261 | |
|---|---|---|
| 29 | 29 | RRI 20 |_____________| 21 MR |
| 30 | 30 | |
| 31 | 31 | |
| 32 | NOTE: PIN IM6402 IM6403 | |
| 33 | --------------------------- | |
| 34 | 2 N/C CONTROL | |
| 35 | 17 RRC OSC IN | |
| 36 | 40 TRC OSC OUT | |
| 37 | ||
| 32 | NOTE: PIN IM6402 IM6403 | |
| 33 | --------------------------- | |
| 34 | 2 N/C CONTROL | |
| 35 | 17 RRC OSC IN | |
| 36 | 40 TRC OSC OUT | |
| 37 | ||
| 38 | 38 | ***************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | #pragma once |
| r14260 | r14261 | |
| 70 | 70 | { |
| 71 | 71 | int m_rrc; |
| 72 | 72 | int m_trc; |
| 73 | ||
| 73 | ||
| 74 | 74 | devcb_read_line m_in_rri_cb; |
| 75 | 75 | devcb_write_line m_out_tro_cb; |
| 76 | 76 | devcb_write_line m_out_dr_cb; |
| r14260 | r14261 | |
| 81 | 81 | |
| 82 | 82 | // ======================> im6402_device |
| 83 | 83 | |
| 84 | class im6402_device : public device_t, | |
| 84 | class im6402_device : public device_t, | |
| 85 | 85 | public device_serial_interface, |
| 86 | 86 | public im6402_interface |
| 87 | 87 | { |
| r14260 | r14261 | |
| 91 | 91 | |
| 92 | 92 | DECLARE_READ8_MEMBER( read ); |
| 93 | 93 | DECLARE_WRITE8_MEMBER( write ); |
| 94 | ||
| 94 | ||
| 95 | 95 | DECLARE_READ_LINE_MEMBER( dr_r ); |
| 96 | 96 | DECLARE_READ_LINE_MEMBER( tbre_r ); |
| 97 | 97 | DECLARE_READ_LINE_MEMBER( tre_r ); |
| r14260 | r14261 | |
| 118 | 118 | virtual void device_start(); |
| 119 | 119 | virtual void device_reset(); |
| 120 | 120 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 121 | ||
| 121 | ||
| 122 | 122 | // device_serial_interface overrides |
| 123 | 123 | virtual void input_callback(UINT8 state); |
| 124 | 124 | |
| r14260 | r14261 | |
| 128 | 128 | inline void set_tre(int state); |
| 129 | 129 | inline void receive(); |
| 130 | 130 | inline void transmit(); |
| 131 | ||
| 131 | ||
| 132 | 132 | static const device_timer_id TIMER_RX = 0; |
| 133 | 133 | static const device_timer_id TIMER_TX = 1; |
| 134 | 134 | |
| r14260 | r14261 | |
| 145 | 145 | int m_pe; |
| 146 | 146 | int m_fe; |
| 147 | 147 | int m_oe; |
| 148 | ||
| 148 | ||
| 149 | 149 | // control |
| 150 | 150 | int m_cls1; |
| 151 | 151 | int m_cls2; |
| r14260 | r14261 | |
| 153 | 153 | int m_sfd; |
| 154 | 154 | int m_epe; |
| 155 | 155 | int m_pi; |
| 156 | ||
| 156 | ||
| 157 | 157 | // receiver |
| 158 | 158 | UINT8 m_rbr; |
| 159 | 159 | int m_rrc_count; |
| 160 | ||
| 160 | ||
| 161 | 161 | // transmitter |
| 162 | 162 | UINT8 m_tbr; |
| 163 | 163 | int m_trc_count; |
| 164 | ||
| 164 | ||
| 165 | 165 | // timers |
| 166 | 166 | emu_timer *m_rx_timer; |
| 167 | 167 | emu_timer *m_tx_timer; |
| r14260 | r14261 | |
|---|---|---|
| 430 | 430 | assert(height > 0); |
| 431 | 431 | assert(visarea.min_x >= 0); |
| 432 | 432 | assert(visarea.min_y >= 0); |
| 433 | // assert(visarea.max_x < width); | |
| 434 | // assert(visarea.max_y < height); | |
| 433 | // assert(visarea.max_x < width); | |
| 434 | // assert(visarea.max_y < height); | |
| 435 | 435 | assert(m_type == SCREEN_TYPE_VECTOR || visarea.min_x < width); |
| 436 | 436 | assert(m_type == SCREEN_TYPE_VECTOR || visarea.min_y < height); |
| 437 | 437 | assert(frame_period > 0); |
| r14260 | r14261 | |
| 509 | 509 | // doesn't apply for vector games |
| 510 | 510 | if (m_type == SCREEN_TYPE_VECTOR) |
| 511 | 511 | return; |
| 512 | ||
| 512 | ||
| 513 | 513 | // determine effective size to allocate |
| 514 | 514 | INT32 effwidth = MAX(m_width, m_visarea.max_x + 1); |
| 515 | 515 | INT32 effheight = MAX(m_height, m_visarea.max_y + 1); |
| r14260 | r14261 | |
|---|---|---|
| 80 | 80 | if (!options.exists(owner.tag()+1)) |
| 81 | 81 | selval = slot->get_default_card(*this, options); |
| 82 | 82 | |
| 83 | if (selval != NULL && strlen(selval) != 0) | |
| 83 | if (selval != NULL && strlen(selval) != 0) | |
| 84 | 84 | { |
| 85 | 85 | bool found = false; |
| 86 | for (int i = 0; intf[i].name != NULL; i++) | |
| 86 | for (int i = 0; intf[i].name != NULL; i++) | |
| 87 | 87 | { |
| 88 | 88 | if (strcmp(selval, intf[i].name) == 0) |
| 89 | 89 | { |
| r14260 | r14261 | |
| 143 | 143 | // if there's an owner, let the owner do the work |
| 144 | 144 | if (owner != NULL) |
| 145 | 145 | return owner->add_subdevice(type, tag, clock); |
| 146 | ||
| 146 | ||
| 147 | 147 | // otherwise, allocate the device directly |
| 148 | 148 | assert(m_root_device == NULL); |
| 149 | 149 | m_root_device = (*type)(*this, tag, owner, clock); |
| r14260 | r14261 | |
| 171 | 171 | mame_printf_warning("Warning: attempting to replace non-existent device '%s'\n", tag); |
| 172 | 172 | return device_add(owner, tag, type, clock); |
| 173 | 173 | } |
| 174 | ||
| 174 | ||
| 175 | 175 | // let the device's owner do the work |
| 176 | 176 | return device->owner()->replace_subdevice(*device, type, tag, clock); |
| 177 | 177 | } |
| r14260 | r14261 | |
|---|---|---|
| 940 | 940 | |
| 941 | 941 | /*************************************************************************** |
| 942 | 942 | |
| 943 | ||
| 943 | New implementation | |
| 944 | 944 | |
| 945 | 945 | **************************************************************************** |
| 946 | 946 |
| r14260 | r14261 | |
|---|---|---|
| 226 | 226 | public: |
| 227 | 227 | floppy_image_format_t(); |
| 228 | 228 | virtual ~floppy_image_format_t(); |
| 229 | ||
| 229 | ||
| 230 | 230 | /*! @brief Identify an image. |
| 231 | The identify function tests if the image is valid | |
| 232 | for this particular format. | |
| 233 | @param io buffer containing the image data. | |
| 234 | @param form_factor Physical form factor of disk, from the enum | |
| 235 | in floppy_image | |
| 236 | @return 1 if image valid, 0 otherwise. | |
| 237 | */ | |
| 231 | The identify function tests if the image is valid | |
| 232 | for this particular format. | |
| 233 | @param io buffer containing the image data. | |
| 234 | @param form_factor Physical form factor of disk, from the enum | |
| 235 | in floppy_image | |
| 236 | @return 1 if image valid, 0 otherwise. | |
| 237 | */ | |
| 238 | 238 | virtual int identify(io_generic *io, UINT32 form_factor) = 0; |
| 239 | ||
| 239 | ||
| 240 | 240 | /*! @brief Load an image. |
| 241 | The load function opens an image file and converts it to the | |
| 242 | internal MESS floppy representation. | |
| 243 | @param io source buffer containing the image data. | |
| 244 | @param form_factor Physical form factor of disk, from the enum | |
| 245 | in floppy_image | |
| 246 | @param image output buffer for data in MESS internal format. | |
| 247 | @return true on success, false otherwise. | |
| 248 | */ | |
| 241 | The load function opens an image file and converts it to the | |
| 242 | internal MESS floppy representation. | |
| 243 | @param io source buffer containing the image data. | |
| 244 | @param form_factor Physical form factor of disk, from the enum | |
| 245 | in floppy_image | |
| 246 | @param image output buffer for data in MESS internal format. | |
| 247 | @return true on success, false otherwise. | |
| 248 | */ | |
| 249 | 249 | virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) = 0; |
| 250 | ||
| 250 | ||
| 251 | 251 | /*! @brief Save an image. |
| 252 | 252 | The save function writes back an image from the MESS internal |
| 253 | 253 | floppy representation to the appropriate format on disk. |
| 254 | 254 | @param io output buffer for the data in the on-disk format. |
| 255 | 255 | @param image source buffer containing data in MESS internal format. |
| 256 | ||
| 256 | @return true on success, false otherwise. | |
| 257 | 257 | */ |
| 258 | 258 | virtual bool save(io_generic *io, floppy_image *image); |
| 259 | 259 | |
| r14260 | r14261 | |
| 275 | 275 | //! @param file_name |
| 276 | 276 | //! @returns true if file matches the extension. |
| 277 | 277 | bool extension_matches(const char *file_name) const; |
| 278 | ||
| 278 | ||
| 279 | 279 | protected: |
| 280 | 280 | //! Input for convert_to_edge |
| 281 | 281 | enum { |
| r14260 | r14261 | |
| 289 | 289 | // **** Reader helpers **** |
| 290 | 290 | |
| 291 | 291 | //! Struct designed for easy track data description. Contains an opcode and two params. |
| 292 | ||
| 292 | ||
| 293 | 293 | //! Optional, you can always do things by hand, but useful nevertheless. |
| 294 | 294 | //! A vector of these structures describes one track. |
| 295 | ||
| 295 | ||
| 296 | 296 | struct desc_e { |
| 297 | 297 | int type, //!< An opcode |
| 298 | p1, //!< first param | |
| 299 | p2; //!< second param | |
| 298 | p1, //!< first param | |
| 299 | p2; //!< second param | |
| 300 | 300 | }; |
| 301 | ||
| 301 | ||
| 302 | 302 | //! Opcodes of the format description language used by generate_track() |
| 303 | 303 | enum { |
| 304 | 304 | END, //!< End of description |
| r14260 | r14261 | |
| 347 | 347 | |
| 348 | 348 | |
| 349 | 349 | /*! @brief Generate one track according to the description vector. |
| 350 | @param desc track data description | |
| 351 | @param track | |
| 352 | @param head | |
| 353 | @param sect a vector indexed by sector id. | |
| 354 | @param sect_count number of sectors. | |
| 355 | @param track_size in _cells_, i.e. 100000 for a usual 2us-per-cell track at 300rpm. | |
| 356 | @param image | |
| 357 | */ | |
| 350 | @param desc track data description | |
| 351 | @param track | |
| 352 | @param head | |
| 353 | @param sect a vector indexed by sector id. | |
| 354 | @param sect_count number of sectors. | |
| 355 | @param track_size in _cells_, i.e. 100000 for a usual 2us-per-cell track at 300rpm. | |
| 356 | @param image | |
| 357 | */ | |
| 358 | 358 | void generate_track(const desc_e *desc, int track, int head, const desc_s *sect, int sect_count, int track_size, floppy_image *image); |
| 359 | 359 | |
| 360 | 360 | /*! @brief Generate a track from cell binary values, MSB-first. |
| 361 | @param track | |
| 362 | @param head | |
| 363 | @param trackbuf track input buffer. | |
| 364 | @param track_size in cells, not bytes. | |
| 365 | @param image | |
| 366 | */ | |
| 361 | @param track | |
| 362 | @param head | |
| 363 | @param trackbuf track input buffer. | |
| 364 | @param track_size in cells, not bytes. | |
| 365 | @param image | |
| 366 | */ | |
| 367 | 367 | void generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image); |
| 368 | 368 | |
| 369 | 369 | //! @brief Generate a track from cell level values (0/1/W/D/N). |
| 370 | ||
| 370 | ||
| 371 | 371 | /*! Note that this function needs to be able to split cells in two, |
| 372 | so no time value should be less than 2, and even values are a | |
| 373 | good idea. | |
| 374 | */ | |
| 372 | so no time value should be less than 2, and even values are a | |
| 373 | good idea. | |
| 374 | */ | |
| 375 | 375 | /*! @param track |
| 376 | @param head | |
| 377 | @param trackbuf track input buffer. | |
| 378 | @param track_size in cells, not bytes. | |
| 379 | @param splice_pos is the position of the track splice. For normal | |
| 380 | formats, use -1. For protected formats, you're supposed to | |
| 381 | know. trackbuf may be modified at that position or after. | |
| 382 | @param image | |
| 383 | */ | |
| 376 | @param head | |
| 377 | @param trackbuf track input buffer. | |
| 378 | @param track_size in cells, not bytes. | |
| 379 | @param splice_pos is the position of the track splice. For normal | |
| 380 | formats, use -1. For protected formats, you're supposed to | |
| 381 | know. trackbuf may be modified at that position or after. | |
| 382 | @param image | |
| 383 | */ | |
| 384 | 384 | void generate_track_from_levels(int track, int head, UINT32 *trackbuf, int track_size, int splice_pos, floppy_image *image); |
| 385 | 385 | |
| 386 | 386 | //! Normalize the times in a cell buffer to sum up to 200000000 |
| r14260 | r14261 | |
| 401 | 401 | |
| 402 | 402 | // Fastcopy Pro optimized formats, with fake sector header for |
| 403 | 403 | // faster verify and skew/interleave where appropriate |
| 404 | static const desc_e atari_st_fcp_9[]; | |
| 404 | static const desc_e atari_st_fcp_9[]; | |
| 405 | 405 | static const desc_e *const atari_st_fcp_10[10]; |
| 406 | 406 | static const desc_e atari_st_fcp_11[]; |
| 407 | 407 | |
| r14260 | r14261 | |
| 422 | 422 | // **** Writer helpers **** |
| 423 | 423 | |
| 424 | 424 | /*! @brief Rebuild a cell bitstream for a track. |
| 425 | Takes the cell standard | |
| 426 | angular size as a parameter, gives out a msb-first bitstream. | |
| 425 | Takes the cell standard | |
| 426 | angular size as a parameter, gives out a msb-first bitstream. | |
| 427 | 427 | |
| 428 | Beware that fuzzy bits will always give out the same value. | |
| 429 | @param track | |
| 430 | @param head | |
| 431 | @param cell_size | |
| 432 | @param trackbuf Output buffer size should be 34% more than the nominal number | |
| 433 | of cells (the dpll tolerates a cell size down to 75% of the | |
| 434 | nominal one, with gives a cell count of 1/0.75=1.333... times | |
| 435 | the nominal one). | |
| 436 | @param track_size Output size is given in bits (cells). | |
| 437 | @param image | |
| 438 | */ | |
| 428 | Beware that fuzzy bits will always give out the same value. | |
| 429 | @param track | |
| 430 | @param head | |
| 431 | @param cell_size | |
| 432 | @param trackbuf Output buffer size should be 34% more than the nominal number | |
| 433 | of cells (the dpll tolerates a cell size down to 75% of the | |
| 434 | nominal one, with gives a cell count of 1/0.75=1.333... times | |
| 435 | the nominal one). | |
| 436 | @param track_size Output size is given in bits (cells). | |
| 437 | @param image | |
| 438 | */ | |
| 439 | 439 | /*! @verbatim |
| 440 | Computing the standard angular size of a cell is | |
| 441 | simple. Noting: | |
| 442 | d = standard cell duration in microseconds | |
| 443 | r = motor rotational speed in rpm | |
| 444 | then: | |
| 445 | a = r * d * 10 / 3. | |
| 446 | Some values: | |
| 447 | Type Cell RPM Size | |
| 440 | Computing the standard angular size of a cell is | |
| 441 | simple. Noting: | |
| 442 | d = standard cell duration in microseconds | |
| 443 | r = motor rotational speed in rpm | |
| 444 | then: | |
| 445 | a = r * d * 10 / 3. | |
| 446 | Some values: | |
| 447 | Type Cell RPM Size | |
| 448 | 448 | |
| 449 | C1541 tr 1-17 3.25 300 3250 | |
| 450 | C1541 tr 18-24 3.50 300 3500 | |
| 451 | C1541 tr 25-30 3.75 300 3750 | |
| 452 | C1541 tr 31+ 4.00 300 4000 | |
| 453 | 5.25" SD 4 300 4000 | |
| 454 | 5.25" DD 2 300 2000 | |
| 455 | 5.25" HD 1 360 1200 | |
| 456 | 3.5" SD 4 300 4000 | |
| 457 | 3.5" DD 2 300 2000 | |
| 458 | 3.5" HD 1 300 1000 | |
| 459 | 3.5" ED 0.5 300 500 | |
| 460 | @endverbatim | |
| 461 | */ | |
| 449 | C1541 tr 1-17 3.25 300 3250 | |
| 450 | C1541 tr 18-24 3.50 300 3500 | |
| 451 | C1541 tr 25-30 3.75 300 3750 | |
| 452 | C1541 tr 31+ 4.00 300 4000 | |
| 453 | 5.25" SD 4 300 4000 | |
| 454 | 5.25" DD 2 300 2000 | |
| 455 | 5.25" HD 1 360 1200 | |
| 456 | 3.5" SD 4 300 4000 | |
| 457 | 3.5" DD 2 300 2000 | |
| 458 | 3.5" HD 1 300 1000 | |
| 459 | 3.5" ED 0.5 300 500 | |
| 460 | @endverbatim | |
| 461 | */ | |
| 462 | 462 | |
| 463 | 463 | void generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image); |
| 464 | ||
| 464 | ||
| 465 | 465 | //! Defines a standard sector for extracting. |
| 466 | 466 | struct desc_xs { |
| 467 | 467 | int track, //!< Track for this sector |
| r14260 | r14261 | |
| 484 | 484 | |
| 485 | 485 | |
| 486 | 486 | //! @brief Get a geometry (including sectors) from an image. |
| 487 | ||
| 487 | ||
| 488 | 488 | //! PC-type sectors with MFM encoding |
| 489 | 489 | void get_geometry_mfm_pc(floppy_image *image, int cell_size, int &track_count, int &head_count, int §or_count); |
| 490 | 490 | |
| r14260 | r14261 | |
| 519 | 519 | private: |
| 520 | 520 | enum { CRC_NONE, CRC_AMIGA, CRC_CCITT, CRC_MACHEAD }; |
| 521 | 521 | enum { MAX_CRC_COUNT = 64 }; |
| 522 | ||
| 522 | ||
| 523 | 523 | //! Holds data used internally for generating CRCs. |
| 524 | 524 | struct gen_crc_info { |
| 525 | 525 | int type, //!< Type of CRC |
| r14260 | r14261 | |
| 598 | 598 | TIME_MASK = 0x0fffffff, |
| 599 | 599 | MG_MASK = 0xf0000000, |
| 600 | 600 | MG_SHIFT = 28, //!< Bitshift constant for magnetic orientation data |
| 601 | MG_A = (0 << MG_SHIFT), | |
| 601 | MG_A = (0 << MG_SHIFT), | |
| 602 | 602 | MG_B = (1 << MG_SHIFT), //!< - 1, MG_B -> Magnetic orientation B |
| 603 | 603 | MG_N = (2 << MG_SHIFT), //!< - 2, MG_N -> Non-magnetized zone (neutral) |
| 604 | 604 | MG_D = (3 << MG_SHIFT) //!< - 3, MG_D -> Damaged zone, reads as neutral but cannot be changed by writing |
| r14260 | r14261 | |
| 626 | 626 | |
| 627 | 627 | //! floppy_image constructor |
| 628 | 628 | /*! |
| 629 | @param _tracks number of tracks. | |
| 630 | @param _heads number of heads. | |
| 631 | @param _form_factor form factor of drive (from enum) | |
| 632 | */ | |
| 629 | @param _tracks number of tracks. | |
| 630 | @param _heads number of heads. | |
| 631 | @param _form_factor form factor of drive (from enum) | |
| 632 | */ | |
| 633 | 633 | floppy_image(int tracks, int heads, UINT32 form_factor); |
| 634 | 634 | virtual ~floppy_image(); |
| 635 | ||
| 635 | ||
| 636 | 636 | //! @return the form factor. |
| 637 | 637 | UINT32 get_form_factor() { return form_factor; } |
| 638 | 638 | //! @return the variant. |
| 639 | 639 | UINT32 get_variant() { return variant; } |
| 640 | 640 | //! @param v the variant. |
| 641 | void set_variant(UINT32 v) { variant = v; } | |
| 641 | void set_variant(UINT32 v) { variant = v; } | |
| 642 | 642 | |
| 643 | 643 | /*! |
| 644 | @param track | |
| 645 | @param head | |
| 646 | @param size size of this track | |
| 647 | */ | |
| 644 | @param track | |
| 645 | @param head | |
| 646 | @param size size of this track | |
| 647 | */ | |
| 648 | 648 | void set_track_size(int track, int head, UINT32 size) { track_size[track][head] = size; ensure_alloc(track, head); } |
| 649 | ||
| 649 | ||
| 650 | 650 | /*! |
| 651 | 651 | @param track track number |
| 652 | @param head head number | |
| 652 | @param head head number | |
| 653 | 653 | @return a pointer to the data buffer for this track and head |
| 654 | 654 | */ |
| 655 | 655 | UINT32 *get_buffer(int track, int head) { return cell_data[track][head]; } |
| r14260 | r14261 | |
| 657 | 657 | //! @param track |
| 658 | 658 | //! @param head |
| 659 | 659 | UINT32 get_track_size(int track, int head) { return track_size[track][head]; } |
| 660 | ||
| 660 | ||
| 661 | 661 | //! Sets the write splice position. |
| 662 | 662 | //! The "track splice" information indicates where to start writing |
| 663 | 663 | //! if you try to rewrite a physical disk with the data. Some |
| r14260 | r14261 | |
| 666 | 666 | //! representation is the angular position relative to the index. |
| 667 | 667 | |
| 668 | 668 | /*! @param track |
| 669 | @param head | |
| 670 | @param pos the position | |
| 671 | */ | |
| 669 | @param head | |
| 670 | @param pos the position | |
| 671 | */ | |
| 672 | 672 | void set_write_splice_position(int track, int head, UINT32 pos) { write_splice[track][head] = pos; } |
| 673 | 673 | //! @return the current write splice position. |
| 674 | 674 | UINT32 get_write_splice_position(int track, int head) const { return write_splice[track][head]; } |
| r14260 | r14261 | |
| 683 | 683 | static const char *get_variant_name(UINT32 form_factor, UINT32 variant); |
| 684 | 684 | |
| 685 | 685 | private: |
| 686 | ||
| 686 | ||
| 687 | 687 | enum { |
| 688 | 688 | MAX_FLOPPY_HEADS = 2, |
| 689 | 689 | MAX_FLOPPY_TRACKS = 84 |
| r14260 | r14261 | |
|---|---|---|
| 244 | 244 | |
| 245 | 245 | FLAC__STREAM_ENCODER_UNINITIALIZED, |
| 246 | 246 | /**< The encoder is in the uninitialized state; one of the |
| 247 | * FLAC__stream_encoder_init_*() functions must be called before samples | |
| 248 | * can be processed. | |
| 249 | */ | |
| 247 | * FLAC__stream_encoder_init_*() functions must be called before samples | |
| 248 | * can be processed. | |
| 249 | */ | |
| 250 | 250 | |
| 251 | 251 | FLAC__STREAM_ENCODER_OGG_ERROR, |
| 252 | 252 | /**< An error occurred in the underlying Ogg layer. */ |
| 253 | 253 | |
| 254 | 254 | FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR, |
| 255 | 255 | /**< An error occurred in the underlying verify stream decoder; |
| 256 | * check FLAC__stream_encoder_get_verify_decoder_state(). | |
| 257 | */ | |
| 256 | * check FLAC__stream_encoder_get_verify_decoder_state(). | |
| 257 | */ | |
| 258 | 258 | |
| 259 | 259 | FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA, |
| 260 | 260 | /**< The verify decoder detected a mismatch between the original |
| 261 | * audio signal and the decoded audio signal. | |
| 262 | */ | |
| 261 | * audio signal and the decoded audio signal. | |
| 262 | */ | |
| 263 | 263 | |
| 264 | 264 | FLAC__STREAM_ENCODER_CLIENT_ERROR, |
| 265 | 265 | /**< One of the callbacks returned a fatal error. */ |
| 266 | 266 | |
| 267 | 267 | FLAC__STREAM_ENCODER_IO_ERROR, |
| 268 | 268 | /**< An I/O error occurred while opening/reading/writing a file. |
| 269 | * Check \c errno. | |
| 270 | */ | |
| 269 | * Check \c errno. | |
| 270 | */ | |
| 271 | 271 | |
| 272 | 272 | FLAC__STREAM_ENCODER_FRAMING_ERROR, |
| 273 | 273 | /**< An error occurred while writing the stream; usually, the |
| 274 | * write_callback returned an error. | |
| 275 | */ | |
| 274 | * write_callback returned an error. | |
| 275 | */ | |
| 276 | 276 | |
| 277 | 277 | FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR |
| 278 | 278 | /**< Memory allocation failed. */ |
| r14260 | r14261 | |
| 299 | 299 | |
| 300 | 300 | FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER, |
| 301 | 301 | /**< The library was not compiled with support for the given container |
| 302 | * format. | |
| 303 | */ | |
| 302 | * format. | |
| 303 | */ | |
| 304 | 304 | |
| 305 | 305 | FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS, |
| 306 | 306 | /**< A required callback was not supplied. */ |
| r14260 | r14261 | |
| 310 | 310 | |
| 311 | 311 | FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE, |
| 312 | 312 | /**< The encoder has an invalid setting for bits-per-sample. |
| 313 | * FLAC supports 4-32 bps but the reference encoder currently supports | |
| 314 | * only up to 24 bps. | |
| 315 | */ | |
| 313 | * FLAC supports 4-32 bps but the reference encoder currently supports | |
| 314 | * only up to 24 bps. | |
| 315 | */ | |
| 316 | 316 | |
| 317 | 317 | FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE, |
| 318 | 318 | /**< The encoder has an invalid setting for the input sample rate. */ |
| r14260 | r14261 | |
| 334 | 334 | |
| 335 | 335 | FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA, |
| 336 | 336 | /**< The metadata input to the encoder is invalid, in one of the following ways: |
| 337 | * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0 | |
| 338 | * - One of the metadata blocks contains an undefined type | |
| 339 | * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal() | |
| 340 | * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal() | |
| 341 | * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block | |
| 342 | */ | |
| 337 | * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0 | |
| 338 | * - One of the metadata blocks contains an undefined type | |
| 339 | * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal() | |
| 340 | * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal() | |
| 341 | * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block | |
| 342 | */ | |
| 343 | 343 | |
| 344 | 344 | FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED |
| 345 | 345 | /**< FLAC__stream_encoder_init_*() was called when the encoder was |
| 346 | * already initialized, usually because | |
| 347 | * FLAC__stream_encoder_finish() was not called. | |
| 348 | */ | |
| 346 | * already initialized, usually because | |
| 347 | * FLAC__stream_encoder_finish() was not called. | |
| 348 | */ | |
| 349 | 349 | |
| 350 | 350 | } FLAC__StreamEncoderInitStatus; |
| 351 | 351 |
| r14260 | r14261 | |
|---|---|---|
| 762 | 762 | |
| 763 | 763 | FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH, |
| 764 | 764 | /**< FLAC__metadata_chain_write() was called on a chain read by |
| 765 | * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), | |
| 766 | * or | |
| 767 | * FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile() | |
| 768 | * was called on a chain read by | |
| 769 | * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). | |
| 770 | * Matching read/write methods must always be used. */ | |
| 765 | * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(), | |
| 766 | * or | |
| 767 | * FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile() | |
| 768 | * was called on a chain read by | |
| 769 | * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(). | |
| 770 | * Matching read/write methods must always be used. */ | |
| 771 | 771 | |
| 772 | 772 | FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL |
| 773 | 773 | /**< FLAC__metadata_chain_write_with_callbacks() was called when the |
| 774 | * chain write requires a tempfile; use | |
| 775 | * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead. | |
| 776 | * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was | |
| 777 | * called when the chain write does not require a tempfile; use | |
| 778 | * FLAC__metadata_chain_write_with_callbacks() instead. | |
| 779 | * Always check FLAC__metadata_chain_check_if_tempfile_needed() | |
| 780 | * before writing via callbacks. */ | |
| 774 | * chain write requires a tempfile; use | |
| 775 | * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead. | |
| 776 | * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was | |
| 777 | * called when the chain write does not require a tempfile; use | |
| 778 | * FLAC__metadata_chain_write_with_callbacks() instead. | |
| 779 | * Always check FLAC__metadata_chain_check_if_tempfile_needed() | |
| 780 | * before writing via callbacks. */ | |
| 781 | 781 | |
| 782 | 782 | } FLAC__Metadata_ChainStatus; |
| 783 | 783 |
| r14260 | r14261 | |
|---|---|---|
| 208 | 208 | |
| 209 | 209 | FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC, |
| 210 | 210 | /**< The decoder is ready to or is in the process of searching for the |
| 211 | * frame sync code. | |
| 212 | */ | |
| 211 | * frame sync code. | |
| 212 | */ | |
| 213 | 213 | |
| 214 | 214 | FLAC__STREAM_DECODER_READ_FRAME, |
| 215 | 215 | /**< The decoder is ready to or is in the process of reading a frame. */ |
| r14260 | r14261 | |
| 222 | 222 | |
| 223 | 223 | FLAC__STREAM_DECODER_SEEK_ERROR, |
| 224 | 224 | /**< An error occurred while seeking. The decoder must be flushed |
| 225 | * with FLAC__stream_decoder_flush() or reset with | |
| 226 | * FLAC__stream_decoder_reset() before decoding can continue. | |
| 227 | */ | |
| 225 | * with FLAC__stream_decoder_flush() or reset with | |
| 226 | * FLAC__stream_decoder_reset() before decoding can continue. | |
| 227 | */ | |
| 228 | 228 | |
| 229 | 229 | FLAC__STREAM_DECODER_ABORTED, |
| 230 | 230 | /**< The decoder was aborted by the read callback. */ |
| 231 | 231 | |
| 232 | 232 | FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR, |
| 233 | 233 | /**< An error occurred allocating memory. The decoder is in an invalid |
| 234 | * state and can no longer be used. | |
| 235 | */ | |
| 234 | * state and can no longer be used. | |
| 235 | */ | |
| 236 | 236 | |
| 237 | 237 | FLAC__STREAM_DECODER_UNINITIALIZED |
| 238 | 238 | /**< The decoder is in the uninitialized state; one of the |
| 239 | * FLAC__stream_decoder_init_*() functions must be called before samples | |
| 240 | * can be processed. | |
| 241 | */ | |
| 239 | * FLAC__stream_decoder_init_*() functions must be called before samples | |
| 240 | * can be processed. | |
| 241 | */ | |
| 242 | 242 | |
| 243 | 243 | } FLAC__StreamDecoderState; |
| 244 | 244 | |
| r14260 | r14261 | |
| 259 | 259 | |
| 260 | 260 | FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER, |
| 261 | 261 | /**< The library was not compiled with support for the given container |
| 262 | * format. | |
| 263 | */ | |
| 262 | * format. | |
| 263 | */ | |
| 264 | 264 | |
| 265 | 265 | FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS, |
| 266 | 266 | /**< A required callback was not supplied. */ |
| r14260 | r14261 | |
| 270 | 270 | |
| 271 | 271 | FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE, |
| 272 | 272 | /**< fopen() failed in FLAC__stream_decoder_init_file() or |
| 273 | ||
| 273 | * FLAC__stream_decoder_init_ogg_file(). */ | |
| 274 | 274 | |
| 275 | 275 | FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED |
| 276 | 276 | /**< FLAC__stream_decoder_init_*() was called when the decoder was |
| 277 | * already initialized, usually because | |
| 278 | * FLAC__stream_decoder_finish() was not called. | |
| 279 | */ | |
| 277 | * already initialized, usually because | |
| 278 | * FLAC__stream_decoder_finish() was not called. | |
| 279 | */ | |
| 280 | 280 | |
| 281 | 281 | } FLAC__StreamDecoderInitStatus; |
| 282 | 282 | |
| r14260 | r14261 | |
| 297 | 297 | |
| 298 | 298 | FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM, |
| 299 | 299 | /**< The read was attempted while at the end of the stream. Note that |
| 300 | * the client must only return this value when the read callback was | |
| 301 | * called when already at the end of the stream. Otherwise, if the read | |
| 302 | * itself moves to the end of the stream, the client should still return | |
| 303 | * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on | |
| 304 | * the next read callback it should return | |
| 305 | * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count | |
| 306 | * of \c 0. | |
| 307 | */ | |
| 300 | * the client must only return this value when the read callback was | |
| 301 | * called when already at the end of the stream. Otherwise, if the read | |
| 302 | * itself moves to the end of the stream, the client should still return | |
| 303 | * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on | |
| 304 | * the next read callback it should return | |
| 305 | * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count | |
| 306 | * of \c 0. | |
| 307 | */ | |
| 308 | 308 | |
| 309 | 309 | FLAC__STREAM_DECODER_READ_STATUS_ABORT |
| 310 | 310 | /**< An unrecoverable error occurred. The decoder will return from the process call. */ |
| r14260 | r14261 | |
|---|---|---|
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | /* |
| 87 | Most of the values described in this file are defined by the FLAC | |
| 88 | format specification. There is nothing to tune here. | |
| 87 | Most of the values described in this file are defined by the FLAC | |
| 88 | format specification. There is nothing to tune here. | |
| 89 | 89 | */ |
| 90 | 90 | |
| 91 | 91 | /** The largest legal metadata type code. */ |
| r14260 | r14261 | |
| 193 | 193 | typedef enum { |
| 194 | 194 | FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0, |
| 195 | 195 | /**< Residual is coded by partitioning into contexts, each with it's own |
| 196 | ||
| 196 | * 4-bit Rice parameter. */ | |
| 197 | 197 | |
| 198 | 198 | FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1 |
| 199 | 199 | /**< Residual is coded by partitioning into contexts, each with it's own |
| 200 | ||
| 200 | * 5-bit Rice parameter. */ | |
| 201 | 201 | } FLAC__EntropyCodingMethodType; |
| 202 | 202 | |
| 203 | 203 | /** Maps a FLAC__EntropyCodingMethodType to a C string. |
| r14260 | r14261 | |
| 217 | 217 | |
| 218 | 218 | unsigned *raw_bits; |
| 219 | 219 | /**< Widths for escape-coded partitions. Will be non-zero for escaped |
| 220 | * partitions and zero for unescaped partitions. | |
| 221 | */ | |
| 220 | * partitions and zero for unescaped partitions. | |
| 221 | */ | |
| 222 | 222 | |
| 223 | 223 | unsigned capacity_by_order; |
| 224 | 224 | /**< The capacity of the \a parameters and \a raw_bits arrays |
| 225 | * specified as an order, i.e. the number of array elements | |
| 226 | * allocated is 2 ^ \a capacity_by_order. | |
| 227 | */ | |
| 225 | * specified as an order, i.e. the number of array elements | |
| 226 | * allocated is 2 ^ \a capacity_by_order. | |
| 227 | */ | |
| 228 | 228 | } FLAC__EntropyCodingMethod_PartitionedRiceContents; |
| 229 | 229 | |
| 230 | 230 | /** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>) |
| r14260 | r14261 | |
| 425 | 425 | |
| 426 | 426 | FLAC__FrameNumberType number_type; |
| 427 | 427 | /**< The numbering scheme used for the frame. As a convenience, the |
| 428 | * decoder will always convert a frame number to a sample number because | |
| 429 | * the rules are complex. */ | |
| 428 | * decoder will always convert a frame number to a sample number because | |
| 429 | * the rules are complex. */ | |
| 430 | 430 | |
| 431 | 431 | union { |
| 432 | 432 | FLAC__uint32 frame_number; |
| 433 | 433 | FLAC__uint64 sample_number; |
| 434 | 434 | } number; |
| 435 | 435 | /**< The frame number or sample number of first sample in frame; |
| 436 | ||
| 436 | * use the \a number_type value to determine which to use. */ | |
| 437 | 437 | |
| 438 | 438 | FLAC__uint8 crc; |
| 439 | 439 | /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) |
| 440 | * of the raw frame header bytes, meaning everything before the CRC byte | |
| 441 | * including the sync code. | |
| 442 | */ | |
| 440 | * of the raw frame header bytes, meaning everything before the CRC byte | |
| 441 | * including the sync code. | |
| 442 | */ | |
| 443 | 443 | } FLAC__FrameHeader; |
| 444 | 444 | |
| 445 | 445 | extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */ |
| r14260 | r14261 | |
| 459 | 459 | typedef struct { |
| 460 | 460 | FLAC__uint16 crc; |
| 461 | 461 | /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with |
| 462 | * 0) of the bytes before the crc, back to and including the frame header | |
| 463 | * sync code. | |
| 464 | */ | |
| 462 | * 0) of the bytes before the crc, back to and including the frame header | |
| 463 | * sync code. | |
| 464 | */ | |
| 465 | 465 | } FLAC__FrameFooter; |
| 466 | 466 | |
| 467 | 467 | extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */ |
| r14260 | r14261 | |
| 551 | 551 | typedef struct { |
| 552 | 552 | int dummy; |
| 553 | 553 | /**< Conceptually this is an empty struct since we don't store the |
| 554 | * padding bytes. Empty structs are not allowed by some C compilers, | |
| 555 | * hence the dummy. | |
| 556 | */ | |
| 554 | * padding bytes. Empty structs are not allowed by some C compilers, | |
| 555 | * hence the dummy. | |
| 556 | */ | |
| 557 | 557 | } FLAC__StreamMetadata_Padding; |
| 558 | 558 | |
| 559 | 559 | |
| r14260 | r14261 | |
| 574 | 574 | |
| 575 | 575 | FLAC__uint64 stream_offset; |
| 576 | 576 | /**< The offset, in bytes, of the target frame with respect to |
| 577 | ||
| 577 | * beginning of the first frame. */ | |
| 578 | 578 | |
| 579 | 579 | unsigned frame_samples; |
| 580 | 580 | /**< The number of samples in the target frame. */ |
| r14260 | r14261 | |
| 644 | 644 | typedef struct { |
| 645 | 645 | FLAC__uint64 offset; |
| 646 | 646 | /**< Offset in samples, relative to the track offset, of the index |
| 647 | * point. | |
| 648 | */ | |
| 647 | * point. | |
| 648 | */ | |
| 649 | 649 | |
| 650 | 650 | FLAC__byte number; |
| 651 | 651 | /**< The index point number. */ |
| r14260 | r14261 | |
| 700 | 700 | typedef struct { |
| 701 | 701 | char media_catalog_number[129]; |
| 702 | 702 | /**< Media catalog number, in ASCII printable characters 0x20-0x7e. In |
| 703 | * general, the media catalog number may be 0 to 128 bytes long; any | |
| 704 | * unused characters should be right-padded with NUL characters. | |
| 705 | */ | |
| 703 | * general, the media catalog number may be 0 to 128 bytes long; any | |
| 704 | * unused characters should be right-padded with NUL characters. | |
| 705 | */ | |
| 706 | 706 | |
| 707 | 707 | FLAC__uint64 lead_in; |
| 708 | 708 | /**< The number of lead-in samples. */ |
| r14260 | r14261 | |
| 769 | 769 | |
| 770 | 770 | char *mime_type; |
| 771 | 771 | /**< Picture data's MIME type, in ASCII printable characters |
| 772 | * 0x20-0x7e, NUL terminated. For best compatibility with players, | |
| 773 | * use picture data of MIME type \c image/jpeg or \c image/png. A | |
| 774 | * MIME type of '-->' is also allowed, in which case the picture | |
| 775 | * data should be a complete URL. In file storage, the MIME type is | |
| 776 | * stored as a 32-bit length followed by the ASCII string with no NUL | |
| 777 | * terminator, but is converted to a plain C string in this structure | |
| 778 | * for convenience. | |
| 779 | */ | |
| 772 | * 0x20-0x7e, NUL terminated. For best compatibility with players, | |
| 773 | * use picture data of MIME type \c image/jpeg or \c image/png. A | |
| 774 | * MIME type of '-->' is also allowed, in which case the picture | |
| 775 | * data should be a complete URL. In file storage, the MIME type is | |
| 776 | * stored as a 32-bit length followed by the ASCII string with no NUL | |
| 777 | * terminator, but is converted to a plain C string in this structure | |
| 778 | * for convenience. | |
| 779 | */ | |
| 780 | 780 | |
| 781 | 781 | FLAC__byte *description; |
| 782 | 782 | /**< Picture's description in UTF-8, NUL terminated. In file storage, |
| 783 | * the description is stored as a 32-bit length followed by the UTF-8 | |
| 784 | * string with no NUL terminator, but is converted to a plain C string | |
| 785 | * in this structure for convenience. | |
| 786 | */ | |
| 783 | * the description is stored as a 32-bit length followed by the UTF-8 | |
| 784 | * string with no NUL terminator, but is converted to a plain C string | |
| 785 | * in this structure for convenience. | |
| 786 | */ | |
| 787 | 787 | |
| 788 | 788 | FLAC__uint32 width; |
| 789 | 789 | /**< Picture's width in pixels. */ |
| r14260 | r14261 | |
| 796 | 796 | |
| 797 | 797 | FLAC__uint32 colors; |
| 798 | 798 | /**< For indexed palettes (like GIF), picture's number of colors (the |
| 799 | * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth). | |
| 800 | */ | |
| 799 | * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth). | |
| 800 | */ | |
| 801 | 801 | |
| 802 | 802 | FLAC__uint32 data_length; |
| 803 | 803 | /**< Length of binary picture data in bytes. */ |
| r14260 | r14261 | |
| 831 | 831 | typedef struct { |
| 832 | 832 | FLAC__MetadataType type; |
| 833 | 833 | /**< The type of the metadata block; used determine which member of the |
| 834 | * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED | |
| 835 | * then \a data.unknown must be used. */ | |
| 834 | * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED | |
| 835 | * then \a data.unknown must be used. */ | |
| 836 | 836 | |
| 837 | 837 | FLAC__bool is_last; |
| 838 | 838 | /**< \c true if this metadata block is the last, else \a false */ |
| r14260 | r14261 | |
| 851 | 851 | FLAC__StreamMetadata_Unknown unknown; |
| 852 | 852 | } data; |
| 853 | 853 | /**< Polymorphic block data; use the \a type value to determine which |
| 854 | ||
| 854 | * to use. */ | |
| 855 | 855 | } FLAC__StreamMetadata; |
| 856 | 856 | |
| 857 | 857 | extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */ |
| r14260 | r14261 | |
|---|---|---|
| 42 | 42 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| 43 | 43 | |
| 44 | 44 | /* |
| 45 | * FLAC__lpc_window_data() | |
| 46 | * -------------------------------------------------------------------- | |
| 47 | * Applies the given window to the data. | |
| 45 | * FLAC__lpc_window_data() | |
| 46 | * -------------------------------------------------------------------- | |
| 47 | * Applies the given window to the data. | |
| 48 | 48 | * OPT: asm implementation |
| 49 | 49 | * |
| 50 | * IN in[0,data_len-1] | |
| 51 | * IN window[0,data_len-1] | |
| 52 | * OUT out[0,lag-1] | |
| 53 | * IN data_len | |
| 50 | * IN in[0,data_len-1] | |
| 51 | * IN window[0,data_len-1] | |
| 52 | * OUT out[0,lag-1] | |
| 53 | * IN data_len | |
| 54 | 54 | */ |
| 55 | 55 | void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len); |
| 56 | 56 | |
| 57 | 57 | /* |
| 58 | * FLAC__lpc_compute_autocorrelation() | |
| 59 | * -------------------------------------------------------------------- | |
| 60 | * Compute the autocorrelation for lags between 0 and lag-1. | |
| 61 | * Assumes data[] outside of [0,data_len-1] == 0. | |
| 62 | * Asserts that lag > 0. | |
| 58 | * FLAC__lpc_compute_autocorrelation() | |
| 59 | * -------------------------------------------------------------------- | |
| 60 | * Compute the autocorrelation for lags between 0 and lag-1. | |
| 61 | * Assumes data[] outside of [0,data_len-1] == 0. | |
| 62 | * Asserts that lag > 0. | |
| 63 | 63 | * |
| 64 | * IN data[0,data_len-1] | |
| 65 | * IN data_len | |
| 66 | * IN 0 < lag <= data_len | |
| 67 | * OUT autoc[0,lag-1] | |
| 64 | * IN data[0,data_len-1] | |
| 65 | * IN data_len | |
| 66 | * IN 0 < lag <= data_len | |
| 67 | * OUT autoc[0,lag-1] | |
| 68 | 68 | */ |
| 69 | 69 | void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); |
| 70 | 70 | #ifndef FLAC__NO_ASM |
| r14260 | r14261 | |
| 80 | 80 | #endif |
| 81 | 81 | |
| 82 | 82 | /* |
| 83 | * FLAC__lpc_compute_lp_coefficients() | |
| 84 | * -------------------------------------------------------------------- | |
| 85 | * Computes LP coefficients for orders 1..max_order. | |
| 86 | * Do not call if autoc[0] == 0.0. This means the signal is zero | |
| 87 | * and there is no point in calculating a predictor. | |
| 83 | * FLAC__lpc_compute_lp_coefficients() | |
| 84 | * -------------------------------------------------------------------- | |
| 85 | * Computes LP coefficients for orders 1..max_order. | |
| 86 | * Do not call if autoc[0] == 0.0. This means the signal is zero | |
| 87 | * and there is no point in calculating a predictor. | |
| 88 | 88 | * |
| 89 | * IN autoc[0,max_order] autocorrelation values | |
| 90 | * IN 0 < max_order <= FLAC__MAX_LPC_ORDER max LP order to compute | |
| 91 | * OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order | |
| 92 | * *** IMPORTANT: | |
| 93 | * *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched | |
| 94 | * OUT error[0,max_order-1] error for each order (more | |
| 95 | * specifically, the variance of | |
| 96 | * the error signal times # of | |
| 97 | * samples in the signal) | |
| 89 | * IN autoc[0,max_order] autocorrelation values | |
| 90 | * IN 0 < max_order <= FLAC__MAX_LPC_ORDER max LP order to compute | |
| 91 | * OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order | |
| 92 | * *** IMPORTANT: | |
| 93 | * *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched | |
| 94 | * OUT error[0,max_order-1] error for each order (more | |
| 95 | * specifically, the variance of | |
| 96 | * the error signal times # of | |
| 97 | * samples in the signal) | |
| 98 | 98 | * |
| 99 | * Example: if max_order is 9, the LP coefficients for order 9 will be | |
| 100 | * in lp_coeff[8][0,8], the LP coefficients for order 8 will be | |
| 101 | * in lp_coeff[7][0,7], etc. | |
| 99 | * Example: if max_order is 9, the LP coefficients for order 9 will be | |
| 100 | * in lp_coeff[8][0,8], the LP coefficients for order 8 will be | |
| 101 | * in lp_coeff[7][0,7], etc. | |
| 102 | 102 | */ |
| 103 | 103 | void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]); |
| 104 | 104 | |
| 105 | 105 | /* |
| 106 | * FLAC__lpc_quantize_coefficients() | |
| 107 | * -------------------------------------------------------------------- | |
| 108 | * Quantizes the LP coefficients. NOTE: precision + bits_per_sample | |
| 109 | * must be less than 32 (sizeof(FLAC__int32)*8). | |
| 106 | * FLAC__lpc_quantize_coefficients() | |
| 107 | * -------------------------------------------------------------------- | |
| 108 | * Quantizes the LP coefficients. NOTE: precision + bits_per_sample | |
| 109 | * must be less than 32 (sizeof(FLAC__int32)*8). | |
| 110 | 110 | * |
| 111 | * IN lp_coeff[0,order-1] LP coefficients | |
| 112 | * IN order LP order | |
| 113 | * IN FLAC__MIN_QLP_COEFF_PRECISION < precision | |
| 114 | * desired precision (in bits, including sign | |
| 115 | * bit) of largest coefficient | |
| 116 | * OUT qlp_coeff[0,order-1] quantized coefficients | |
| 117 | * OUT shift # of bits to shift right to get approximated | |
| 118 | * LP coefficients. NOTE: could be negative. | |
| 119 | * RETURN 0 => quantization OK | |
| 120 | * 1 => coefficients require too much shifting for *shift to | |
| 111 | * IN lp_coeff[0,order-1] LP coefficients | |
| 112 | * IN order LP order | |
| 113 | * IN FLAC__MIN_QLP_COEFF_PRECISION < precision | |
| 114 | * desired precision (in bits, including sign | |
| 115 | * bit) of largest coefficient | |
| 116 | * OUT qlp_coeff[0,order-1] quantized coefficients | |
| 117 | * OUT shift # of bits to shift right to get approximated | |
| 118 | * LP coefficients. NOTE: could be negative. | |
| 119 | * RETURN 0 => quantization OK | |
| 120 | * 1 => coefficients require too much shifting for *shift to | |
| 121 | 121 | * fit in the LPC subframe header. 'shift' is unset. |
| 122 | 122 | * 2 => coefficients are all zero, which is bad. 'shift' is |
| 123 | 123 | * unset. |
| r14260 | r14261 | |
| 125 | 125 | int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift); |
| 126 | 126 | |
| 127 | 127 | /* |
| 128 | * FLAC__lpc_compute_residual_from_qlp_coefficients() | |
| 129 | * -------------------------------------------------------------------- | |
| 130 | * Compute the residual signal obtained from sutracting the predicted | |
| 131 | * signal from the original. | |
| 128 | * FLAC__lpc_compute_residual_from_qlp_coefficients() | |
| 129 | * -------------------------------------------------------------------- | |
| 130 | * Compute the residual signal obtained from sutracting the predicted | |
| 131 | * signal from the original. | |
| 132 | 132 | * |
| 133 | * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) | |
| 134 | * IN data_len length of original signal | |
| 135 | * IN qlp_coeff[0,order-1] quantized LP coefficients | |
| 136 | * IN order > 0 LP order | |
| 137 | * IN lp_quantization quantization of LP coefficients in bits | |
| 138 | * OUT residual[0,data_len-1] residual signal | |
| 133 | * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) | |
| 134 | * IN data_len length of original signal | |
| 135 | * IN qlp_coeff[0,order-1] quantized LP coefficients | |
| 136 | * IN order > 0 LP order | |
| 137 | * IN lp_quantization quantization of LP coefficients in bits | |
| 138 | * OUT residual[0,data_len-1] residual signal | |
| 139 | 139 | */ |
| 140 | 140 | void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); |
| 141 | 141 | void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); |
| r14260 | r14261 | |
| 151 | 151 | #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ |
| 152 | 152 | |
| 153 | 153 | /* |
| 154 | * FLAC__lpc_restore_signal() | |
| 155 | * -------------------------------------------------------------------- | |
| 156 | * Restore the original signal by summing the residual and the | |
| 157 | * predictor. | |
| 154 | * FLAC__lpc_restore_signal() | |
| 155 | * -------------------------------------------------------------------- | |
| 156 | * Restore the original signal by summing the residual and the | |
| 157 | * predictor. | |
| 158 | 158 | * |
| 159 | * IN residual[0,data_len-1] residual signal | |
| 160 | * IN data_len length of original signal | |
| 161 | * IN qlp_coeff[0,order-1] quantized LP coefficients | |
| 162 | * IN order > 0 LP order | |
| 163 | * IN lp_quantization quantization of LP coefficients in bits | |
| 164 | * *** IMPORTANT: the caller must pass in the historical samples: | |
| 165 | * IN data[-order,-1] previously-reconstructed historical samples | |
| 166 | * OUT data[0,data_len-1] original signal | |
| 159 | * IN residual[0,data_len-1] residual signal | |
| 160 | * IN data_len length of original signal | |
| 161 | * IN qlp_coeff[0,order-1] quantized LP coefficients | |
| 162 | * IN order > 0 LP order | |
| 163 | * IN lp_quantization quantization of LP coefficients in bits | |
| 164 | * *** IMPORTANT: the caller must pass in the historical samples: | |
| 165 | * IN data[-order,-1] previously-reconstructed historical samples | |
| 166 | * OUT data[0,data_len-1] original signal | |
| 167 | 167 | */ |
| 168 | 168 | void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); |
| 169 | 169 | void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); |
| r14260 | r14261 | |
| 182 | 182 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| 183 | 183 | |
| 184 | 184 | /* |
| 185 | * FLAC__lpc_compute_expected_bits_per_residual_sample() | |
| 186 | * -------------------------------------------------------------------- | |
| 187 | * Compute the expected number of bits per residual signal sample | |
| 188 | * based on the LP error (which is related to the residual variance). | |
| 185 | * FLAC__lpc_compute_expected_bits_per_residual_sample() | |
| 186 | * -------------------------------------------------------------------- | |
| 187 | * Compute the expected number of bits per residual signal sample | |
| 188 | * based on the LP error (which is related to the residual variance). | |
| 189 | 189 | * |
| 190 | * IN lpc_error >= 0.0 error returned from calculating LP coefficients | |
| 191 | * IN total_samples > 0 # of samples in residual signal | |
| 192 | * RETURN expected bits per sample | |
| 190 | * IN lpc_error >= 0.0 error returned from calculating LP coefficients | |
| 191 | * IN total_samples > 0 # of samples in residual signal | |
| 192 | * RETURN expected bits per sample | |
| 193 | 193 | */ |
| 194 | 194 | FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples); |
| 195 | 195 | FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale); |
| 196 | 196 | |
| 197 | 197 | /* |
| 198 | * FLAC__lpc_compute_best_order() | |
| 199 | * -------------------------------------------------------------------- | |
| 200 | * Compute the best order from the array of signal errors returned | |
| 201 | * during coefficient computation. | |
| 198 | * FLAC__lpc_compute_best_order() | |
| 199 | * -------------------------------------------------------------------- | |
| 200 | * Compute the best order from the array of signal errors returned | |
| 201 | * during coefficient computation. | |
| 202 | 202 | * |
| 203 | * IN lpc_error[0,max_order-1] >= 0.0 error returned from calculating LP coefficients | |
| 204 | * IN max_order > 0 max LP order | |
| 205 | * IN total_samples > 0 # of samples in residual signal | |
| 206 | * IN overhead_bits_per_order # of bits overhead for each increased LP order | |
| 207 | * (includes warmup sample size and quantized LP coefficient) | |
| 208 | * RETURN [1,max_order] best order | |
| 203 | * IN lpc_error[0,max_order-1] >= 0.0 error returned from calculating LP coefficients | |
| 204 | * IN max_order > 0 max LP order | |
| 205 | * IN total_samples > 0 # of samples in residual signal | |
| 206 | * IN overhead_bits_per_order # of bits overhead for each increased LP order | |
| 207 | * (includes warmup sample size and quantized LP coefficient) | |
| 208 | * RETURN [1,max_order] best order | |
| 209 | 209 | */ |
| 210 | 210 | unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order); |
| 211 | 211 |
| r14260 | r14261 | |
|---|---|---|
| 40 | 40 | #include "flac/format.h" |
| 41 | 41 | |
| 42 | 42 | /* |
| 43 | * FLAC__fixed_compute_best_predictor() | |
| 44 | * -------------------------------------------------------------------- | |
| 45 | * Compute the best fixed predictor and the expected bits-per-sample | |
| 43 | * FLAC__fixed_compute_best_predictor() | |
| 44 | * -------------------------------------------------------------------- | |
| 45 | * Compute the best fixed predictor and the expected bits-per-sample | |
| 46 | 46 | * of the residual signal for each order. The _wide() version uses |
| 47 | 47 | * 64-bit integers which is statistically necessary when bits-per- |
| 48 | 48 | * sample + log2(blocksize) > 30 |
| 49 | 49 | * |
| 50 | * IN data[0,data_len-1] | |
| 51 | * IN data_len | |
| 52 | * OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER] | |
| 50 | * IN data[0,data_len-1] | |
| 51 | * IN data_len | |
| 52 | * OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER] | |
| 53 | 53 | */ |
| 54 | 54 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| 55 | 55 | unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); |
| r14260 | r14261 | |
| 67 | 67 | #endif |
| 68 | 68 | |
| 69 | 69 | /* |
| 70 | * FLAC__fixed_compute_residual() | |
| 71 | * -------------------------------------------------------------------- | |
| 72 | * Compute the residual signal obtained from sutracting the predicted | |
| 73 | * signal from the original. | |
| 70 | * FLAC__fixed_compute_residual() | |
| 71 | * -------------------------------------------------------------------- | |
| 72 | * Compute the residual signal obtained from sutracting the predicted | |
| 73 | * signal from the original. | |
| 74 | 74 | * |
| 75 | * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) | |
| 76 | * IN data_len length of original signal | |
| 77 | * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order | |
| 78 | * OUT residual[0,data_len-1] residual signal | |
| 75 | * IN data[-order,data_len-1] original signal (NOTE THE INDICES!) | |
| 76 | * IN data_len length of original signal | |
| 77 | * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order | |
| 78 | * OUT residual[0,data_len-1] residual signal | |
| 79 | 79 | */ |
| 80 | 80 | void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]); |
| 81 | 81 | |
| 82 | 82 | /* |
| 83 | * FLAC__fixed_restore_signal() | |
| 84 | * -------------------------------------------------------------------- | |
| 85 | * Restore the original signal by summing the residual and the | |
| 86 | * predictor. | |
| 83 | * FLAC__fixed_restore_signal() | |
| 84 | * -------------------------------------------------------------------- | |
| 85 | * Restore the original signal by summing the residual and the | |
| 86 | * predictor. | |
| 87 | 87 | * |
| 88 | * IN residual[0,data_len-1] residual signal | |
| 89 | * IN data_len length of original signal | |
| 90 | * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order | |
| 91 | * *** IMPORTANT: the caller must pass in the historical samples: | |
| 92 | * IN data[-order,-1] previously-reconstructed historical samples | |
| 93 | * OUT data[0,data_len-1] original signal | |
| 88 | * IN residual[0,data_len-1] residual signal | |
| 89 | * IN data_len length of original signal | |
| 90 | * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order | |
| 91 | * *** IMPORTANT: the caller must pass in the historical samples: | |
| 92 | * IN data[-order,-1] previously-reconstructed historical samples | |
| 93 | * OUT data[0,data_len-1] original signal | |
| 94 | 94 | */ |
| 95 | 95 | void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]); |
| 96 | 96 |
| r14260 | r14261 | |
|---|---|---|
| 74 | 74 | #define FLAC__fixedpoint_div(x, y) ( (FLAC__fixedpoint) ( ( ((FLAC__int64)(x)<<32) / (FLAC__int64)(y) ) >> 16 ) ) |
| 75 | 75 | |
| 76 | 76 | /* |
| 77 | * FLAC__fixedpoint_log2() | |
| 78 | * -------------------------------------------------------------------- | |
| 79 | * Returns the base-2 logarithm of the fixed-point number 'x' using an | |
| 80 | * algorithm by Knuth for x >= 1.0 | |
| 77 | * FLAC__fixedpoint_log2() | |
| 78 | * -------------------------------------------------------------------- | |
| 79 | * Returns the base-2 logarithm of the fixed-point number 'x' using an | |
| 80 | * algorithm by Knuth for x >= 1.0 | |
| 81 | 81 | * |
| 82 | * 'fracbits' is the number of fractional bits of 'x'. 'fracbits' must | |
| 83 | * be < 32 and evenly divisible by 4 (0 is OK but not very precise). | |
| 82 | * 'fracbits' is the number of fractional bits of 'x'. 'fracbits' must | |
| 83 | * be < 32 and evenly divisible by 4 (0 is OK but not very precise). | |
| 84 | 84 | * |
| 85 | * 'precision' roughly limits the number of iterations that are done; | |
| 86 | * use (unsigned)(-1) for maximum precision. | |
| 85 | * 'precision' roughly limits the number of iterations that are done; | |
| 86 | * use (unsigned)(-1) for maximum precision. | |
| 87 | 87 | * |
| 88 | * If 'x' is less than one -- that is, x < (1<<fracbits) -- then this | |
| 89 | * function will punt and return 0. | |
| 88 | * If 'x' is less than one -- that is, x < (1<<fracbits) -- then this | |
| 89 | * function will punt and return 0. | |
| 90 | 90 | * |
| 91 | * | |
| 91 | * The return value will also have 'fracbits' fractional bits. | |
| 92 | 92 | */ |
| 93 | 93 | FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision); |
| 94 | 94 |
| r14260 | r14261 | |
|---|---|---|
| 42 | 42 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| 43 | 43 | |
| 44 | 44 | /* |
| 45 | * FLAC__window_*() | |
| 46 | * -------------------------------------------------------------------- | |
| 47 | * Calculates window coefficients according to different apodization | |
| 48 | * functions. | |
| 45 | * FLAC__window_*() | |
| 46 | * -------------------------------------------------------------------- | |
| 47 | * Calculates window coefficients according to different apodization | |
| 48 | * functions. | |
| 49 | 49 | * |
| 50 | * OUT window[0,L-1] | |
| 51 | * IN L (number of points in window) | |
| 50 | * OUT window[0,L-1] | |
| 51 | * IN L (number of points in window) | |
| 52 | 52 | */ |
| 53 | 53 | void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L); |
| 54 | 54 | void FLAC__window_bartlett_hann(FLAC__real *window, const FLAC__int32 L); |
| r14260 | r14261 | |
|---|---|---|
| 79 | 79 | namespace Encoder { |
| 80 | 80 | |
| 81 | 81 | /** \ingroup flacpp_encoder |
| 82 | * \brief | |
| 83 | * This class wraps the ::FLAC__StreamEncoder. If you are | |
| 84 | * encoding to a file, FLAC::Encoder::File may be more | |
| 85 | * convenient. | |
| 86 | * | |
| 87 | * The usage of this class is similar to FLAC__StreamEncoder, | |
| 88 | * except instead of providing callbacks to | |
| 89 | * FLAC__stream_encoder_init*_stream(), you will inherit from this | |
| 90 | * class and override the virtual callback functions with your | |
| 91 | * own implementations, then call init() or init_ogg(). The rest of | |
| 92 | * the calls work the same as in the C layer. | |
| 93 | * | |
| 94 | * Only the write callback is mandatory. The others are | |
| 95 | * optional; this class provides default implementations that do | |
| 96 | * nothing. In order for some STREAMINFO and SEEKTABLE data to | |
| 97 | * be written properly, you must overide seek_callback() and | |
| 98 | * tell_callback(); see FLAC__stream_encoder_init_stream() as to | |
| 99 | * why. | |
| 100 | */ | |
| 82 | * \brief | |
| 83 | * This class wraps the ::FLAC__StreamEncoder. If you are | |
| 84 | * encoding to a file, FLAC::Encoder::File may be more | |
| 85 | * convenient. | |
| 86 | * | |
| 87 | * The usage of this class is similar to FLAC__StreamEncoder, | |
| 88 | * except instead of providing callbacks to | |
| 89 | * FLAC__stream_encoder_init*_stream(), you will inherit from this | |
| 90 | * class and override the virtual callback functions with your | |
| 91 | * own implementations, then call init() or init_ogg(). The rest of | |
| 92 | * the calls work the same as in the C layer. | |
| 93 | * | |
| 94 | * Only the write callback is mandatory. The others are | |
| 95 | * optional; this class provides default implementations that do | |
| 96 | * nothing. In order for some STREAMINFO and SEEKTABLE data to | |
| 97 | * be written properly, you must overide seek_callback() and | |
| 98 | * tell_callback(); see FLAC__stream_encoder_init_stream() as to | |
| 99 | * why. | |
| 100 | */ | |
| 101 | 101 | class FLACPP_API Stream { |
| 102 | 102 | public: |
| 103 | 103 | /** This class is a wrapper around FLAC__StreamEncoderState. |
| 104 | ||
| 104 | */ | |
| 105 | 105 | class FLACPP_API State { |
| 106 | 106 | public: |
| 107 | 107 | inline State(::FLAC__StreamEncoderState state): state_(state) { } |
| r14260 | r14261 | |
| 117 | 117 | |
| 118 | 118 | //@{ |
| 119 | 119 | /** Call after construction to check the that the object was created |
| 120 | * successfully. If not, use get_state() to find out why not. | |
| 121 | * | |
| 122 | */ | |
| 120 | * successfully. If not, use get_state() to find out why not. | |
| 121 | * | |
| 122 | */ | |
| 123 | 123 | virtual bool is_valid() const; |
| 124 | 124 | inline operator bool() const { return is_valid(); } ///< See is_valid() |
| 125 | 125 | //@} |
| r14260 | r14261 | |
| 210 | 210 | }; |
| 211 | 211 | |
| 212 | 212 | /** \ingroup flacpp_encoder |
| 213 | * \brief | |
| 214 | * This class wraps the ::FLAC__StreamEncoder. If you are | |
| 215 | * not encoding to a file, you may need to use | |
| 216 | * FLAC::Encoder::Stream. | |
| 217 | * | |
| 218 | * The usage of this class is similar to FLAC__StreamEncoder, | |
| 219 | * except instead of providing callbacks to | |
| 220 | * FLAC__stream_encoder_init*_FILE() or | |
| 221 | * FLAC__stream_encoder_init*_file(), you will inherit from this | |
| 222 | * class and override the virtual callback functions with your | |
| 223 | * own implementations, then call init() or init_ogg(). The rest | |
| 224 | * of the calls work the same as in the C layer. | |
| 225 | * | |
| 226 | * There are no mandatory callbacks; all the callbacks from | |
| 227 | * FLAC::Encoder::Stream are implemented here fully and support | |
| 228 | * full post-encode STREAMINFO and SEEKTABLE updating. There is | |
| 229 | * only an optional progress callback which you may override to | |
| 230 | * get periodic reports on the progress of the encode. | |
| 231 | */ | |
| 213 | * \brief | |
| 214 | * This class wraps the ::FLAC__StreamEncoder. If you are | |
| 215 | * not encoding to a file, you may need to use | |
| 216 | * FLAC::Encoder::Stream. | |
| 217 | * | |
| 218 | * The usage of this class is similar to FLAC__StreamEncoder, | |
| 219 | * except instead of providing callbacks to | |
| 220 | * FLAC__stream_encoder_init*_FILE() or | |
| 221 | * FLAC__stream_encoder_init*_file(), you will inherit from this | |
| 222 | * class and override the virtual callback functions with your | |
| 223 | * own implementations, then call init() or init_ogg(). The rest | |
| 224 | * of the calls work the same as in the C layer. | |
| 225 | * | |
| 226 | * There are no mandatory callbacks; all the callbacks from | |
| 227 | * FLAC::Encoder::Stream are implemented here fully and support | |
| 228 | * full post-encode STREAMINFO and SEEKTABLE updating. There is | |
| 229 | * only an optional progress callback which you may override to | |
| 230 | * get periodic reports on the progress of the encode. | |
| 231 | */ | |
| 232 | 232 | class FLACPP_API File: public Stream { |
| 233 | 233 | public: |
| 234 | 234 | File(); |
| r14260 | r14261 | |
|---|---|---|
| 81 | 81 | // ============================================================ |
| 82 | 82 | |
| 83 | 83 | /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes |
| 84 | * \ingroup flacpp_metadata | |
| 85 | * | |
| 86 | * This module contains classes representing FLAC metadata | |
| 87 | * blocks in memory. | |
| 88 | * | |
| 89 | * The behavior closely mimics the C layer interface; be | |
| 90 | * sure to read the detailed description of the | |
| 91 | * \link flac_metadata_object C metadata object module \endlink. | |
| 92 | * | |
| 93 | * Any time a metadata object is constructed or assigned, you | |
| 94 | * should check is_valid() to make sure the underlying | |
| 95 | * ::FLAC__StreamMetadata object was able to be created. | |
| 96 | * | |
| 97 | * \warning | |
| 98 | * When the get_*() methods of any metadata object method | |
| 99 | * return you a const pointer, DO NOT disobey and write into it. | |
| 100 | * Always use the set_*() methods. | |
| 101 | * | |
| 102 | * \{ | |
| 103 | */ | |
| 84 | * \ingroup flacpp_metadata | |
| 85 | * | |
| 86 | * This module contains classes representing FLAC metadata | |
| 87 | * blocks in memory. | |
| 88 | * | |
| 89 | * The behavior closely mimics the C layer interface; be | |
| 90 | * sure to read the detailed description of the | |
| 91 | * \link flac_metadata_object C metadata object module \endlink. | |
| 92 | * | |
| 93 | * Any time a metadata object is constructed or assigned, you | |
| 94 | * should check is_valid() to make sure the underlying | |
| 95 | * ::FLAC__StreamMetadata object was able to be created. | |
| 96 | * | |
| 97 | * \warning | |
| 98 | * When the get_*() methods of any metadata object method | |
| 99 | * return you a const pointer, DO NOT disobey and write into it. | |
| 100 | * Always use the set_*() methods. | |
| 101 | * | |
| 102 | * \{ | |
| 103 | */ | |
| 104 | 104 | |
| 105 | 105 | /** Base class for all metadata block types. |
| 106 | * See the \link flacpp_metadata_object overview \endlink for more. | |
| 107 | */ | |
| 106 | * See the \link flacpp_metadata_object overview \endlink for more. | |
| 107 | */ | |
| 108 | 108 | class FLACPP_API Prototype { |
| 109 | 109 | protected: |
| 110 | 110 | //@{ |
| 111 | 111 | /** Constructs a copy of the given object. This form |
| 112 | * always performs a deep copy. | |
| 113 | */ | |
| 112 | * always performs a deep copy. | |
| 113 | */ | |
| 114 | 114 | Prototype(const Prototype &); |
| 115 | 115 | Prototype(const ::FLAC__StreamMetadata &); |
| 116 | 116 | Prototype(const ::FLAC__StreamMetadata *); |
| 117 | 117 | //@} |
| 118 | 118 | |
| 119 | 119 | /** Constructs an object with copy control. When \a copy |
| 120 | * is \c true, behaves identically to | |
| 121 | * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object). | |
| 122 | * When \a copy is \c false, the instance takes ownership of | |
| 123 | * the pointer and the ::FLAC__StreamMetadata object will | |
| 124 | * be freed by the destructor. | |
| 125 | * | |
| 126 | * \assert | |
| 127 | * \code object != NULL \endcode | |
| 128 | */ | |
| 120 | * is \c true, behaves identically to | |
| 121 | * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object). | |
| 122 | * When \a copy is \c false, the instance takes ownership of | |
| 123 | * the pointer and the ::FLAC__StreamMetadata object will | |
| 124 | * be freed by the destructor. | |
| 125 | * | |
| 126 | * \assert | |
| 127 | * \code object != NULL \endcode | |
| 128 | */ | |
| 129 | 129 | Prototype(::FLAC__StreamMetadata *object, bool copy); |
| 130 | 130 | |
| 131 | 131 | //@{ |
| r14260 | r14261 | |
| 136 | 136 | //@} |
| 137 | 137 | |
| 138 | 138 | /** Assigns an object with copy control. See |
| 139 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 140 | */ | |
| 139 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 140 | */ | |
| 141 | 141 | Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy); |
| 142 | 142 | |
| 143 | 143 | /** Deletes the underlying ::FLAC__StreamMetadata object. |
| 144 | ||
| 144 | */ | |
| 145 | 145 | virtual void clear(); |
| 146 | 146 | |
| 147 | 147 | ::FLAC__StreamMetadata *object_; |
| 148 | 148 | public: |
| 149 | 149 | /** Deletes the underlying ::FLAC__StreamMetadata object. |
| 150 | ||
| 150 | */ | |
| 151 | 151 | virtual ~Prototype(); |
| 152 | 152 | |
| 153 | 153 | //@{ |
| 154 | 154 | /** Check for equality, performing a deep compare by following pointers. |
| 155 | ||
| 155 | */ | |
| 156 | 156 | inline bool operator==(const Prototype &) const; |
| 157 | 157 | inline bool operator==(const ::FLAC__StreamMetadata &) const; |
| 158 | 158 | inline bool operator==(const ::FLAC__StreamMetadata *) const; |
| r14260 | r14261 | |
| 169 | 169 | friend class Iterator; |
| 170 | 170 | |
| 171 | 171 | /** Returns \c true if the object was correctly constructed |
| 172 | * (i.e. the underlying ::FLAC__StreamMetadata object was | |
| 173 | * properly allocated), else \c false. | |
| 174 | */ | |
| 172 | * (i.e. the underlying ::FLAC__StreamMetadata object was | |
| 173 | * properly allocated), else \c false. | |
| 174 | */ | |
| 175 | 175 | inline bool is_valid() const; |
| 176 | 176 | |
| 177 | 177 | /** Returns \c true if this block is the last block in a |
| 178 | * stream, else \c false. | |
| 179 | * | |
| 180 | * \assert | |
| 181 | * \code is_valid() \endcode | |
| 182 | */ | |
| 178 | * stream, else \c false. | |
| 179 | * | |
| 180 | * \assert | |
| 181 | * \code is_valid() \endcode | |
| 182 | */ | |
| 183 | 183 | bool get_is_last() const; |
| 184 | 184 | |
| 185 | 185 | /** Returns the type of the block. |
| 186 | * | |
| 187 | * \assert | |
| 188 | * \code is_valid() \endcode | |
| 189 | */ | |
| 186 | * | |
| 187 | * \assert | |
| 188 | * \code is_valid() \endcode | |
| 189 | */ | |
| 190 | 190 | ::FLAC__MetadataType get_type() const; |
| 191 | 191 | |
| 192 | 192 | /** Returns the stream length of the metadata block. |
| 193 | * | |
| 194 | * \note | |
| 195 | * The length does not include the metadata block header, | |
| 196 | * per spec. | |
| 197 | * | |
| 198 | * \assert | |
| 199 | * \code is_valid() \endcode | |
| 200 | */ | |
| 193 | * | |
| 194 | * \note | |
| 195 | * The length does not include the metadata block header, | |
| 196 | * per spec. | |
| 197 | * | |
| 198 | * \assert | |
| 199 | * \code is_valid() \endcode | |
| 200 | */ | |
| 201 | 201 | unsigned get_length() const; |
| 202 | 202 | |
| 203 | 203 | /** Sets the "is_last" flag for the block. When using the iterators |
| 204 | * it is not necessary to set this flag; they will do it for you. | |
| 205 | * | |
| 206 | * \assert | |
| 207 | * \code is_valid() \endcode | |
| 208 | */ | |
| 204 | * it is not necessary to set this flag; they will do it for you. | |
| 205 | * | |
| 206 | * \assert | |
| 207 | * \code is_valid() \endcode | |
| 208 | */ | |
| 209 | 209 | void set_is_last(bool); |
| 210 | 210 | |
| 211 | 211 | /** Returns a pointer to the underlying ::FLAC__StreamMetadata |
| 212 | * object. This can be useful for plugging any holes between | |
| 213 | * the C++ and C interfaces. | |
| 214 | * | |
| 215 | * \assert | |
| 216 | * \code is_valid() \endcode | |
| 217 | */ | |
| 212 | * object. This can be useful for plugging any holes between | |
| 213 | * the C++ and C interfaces. | |
| 214 | * | |
| 215 | * \assert | |
| 216 | * \code is_valid() \endcode | |
| 217 | */ | |
| 218 | 218 | inline operator const ::FLAC__StreamMetadata *() const; |
| 219 | 219 | private: |
| 220 | 220 | /** Private and undefined so you can't use it. */ |
| r14260 | r14261 | |
| 264 | 264 | |
| 265 | 265 | |
| 266 | 266 | /** STREAMINFO metadata block. |
| 267 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 268 | * and the <A HREF="../format.html#metadata_block_streaminfo">format specification</A>. | |
| 269 | */ | |
| 267 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 268 | * and the <A HREF="../format.html#metadata_block_streaminfo">format specification</A>. | |
| 269 | */ | |
| 270 | 270 | class FLACPP_API StreamInfo : public Prototype { |
| 271 | 271 | public: |
| 272 | 272 | StreamInfo(); |
| 273 | 273 | |
| 274 | 274 | //@{ |
| 275 | 275 | /** Constructs a copy of the given object. This form |
| 276 | * always performs a deep copy. | |
| 277 | */ | |
| 276 | * always performs a deep copy. | |
| 277 | */ | |
| 278 | 278 | inline StreamInfo(const StreamInfo &object): Prototype(object) { } |
| 279 | 279 | inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 280 | 280 | inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 281 | 281 | //@} |
| 282 | 282 | |
| 283 | 283 | /** Constructs an object with copy control. See |
| 284 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 285 | */ | |
| 284 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 285 | */ | |
| 286 | 286 | inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 287 | 287 | |
| 288 | 288 | ~StreamInfo(); |
| r14260 | r14261 | |
| 295 | 295 | //@} |
| 296 | 296 | |
| 297 | 297 | /** Assigns an object with copy control. See |
| 298 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 299 | */ | |
| 298 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 299 | */ | |
| 300 | 300 | inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 301 | 301 | |
| 302 | 302 | //@{ |
| r14260 | r14261 | |
| 338 | 338 | }; |
| 339 | 339 | |
| 340 | 340 | /** PADDING metadata block. |
| 341 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 342 | * and the <A HREF="../format.html#metadata_block_padding">format specification</A>. | |
| 343 | */ | |
| 341 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 342 | * and the <A HREF="../format.html#metadata_block_padding">format specification</A>. | |
| 343 | */ | |
| 344 | 344 | class FLACPP_API Padding : public Prototype { |
| 345 | 345 | public: |
| 346 | 346 | Padding(); |
| 347 | 347 | |
| 348 | 348 | //@{ |
| 349 | 349 | /** Constructs a copy of the given object. This form |
| 350 | * always performs a deep copy. | |
| 351 | */ | |
| 350 | * always performs a deep copy. | |
| 351 | */ | |
| 352 | 352 | inline Padding(const Padding &object): Prototype(object) { } |
| 353 | 353 | inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 354 | 354 | inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 355 | 355 | //@} |
| 356 | 356 | |
| 357 | 357 | /** Constructs an object with copy control. See |
| 358 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 359 | */ | |
| 358 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 359 | */ | |
| 360 | 360 | inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 361 | 361 | |
| 362 | 362 | ~Padding(); |
| r14260 | r14261 | |
| 369 | 369 | //@} |
| 370 | 370 | |
| 371 | 371 | /** Assigns an object with copy control. See |
| 372 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 373 | */ | |
| 372 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 373 | */ | |
| 374 | 374 | inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 375 | 375 | |
| 376 | 376 | //@{ |
| r14260 | r14261 | |
| 391 | 391 | }; |
| 392 | 392 | |
| 393 | 393 | /** APPLICATION metadata block. |
| 394 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 395 | * and the <A HREF="../format.html#metadata_block_application">format specification</A>. | |
| 396 | */ | |
| 394 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 395 | * and the <A HREF="../format.html#metadata_block_application">format specification</A>. | |
| 396 | */ | |
| 397 | 397 | class FLACPP_API Application : public Prototype { |
| 398 | 398 | public: |
| 399 | 399 | Application(); |
| 400 | 400 | // |
| 401 | 401 | //@{ |
| 402 | 402 | /** Constructs a copy of the given object. This form |
| 403 | * always performs a deep copy. | |
| 404 | */ | |
| 403 | * always performs a deep copy. | |
| 404 | */ | |
| 405 | 405 | inline Application(const Application &object): Prototype(object) { } |
| 406 | 406 | inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 407 | 407 | inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 408 | 408 | //@} |
| 409 | 409 | |
| 410 | 410 | /** Constructs an object with copy control. See |
| 411 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 412 | */ | |
| 411 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 412 | */ | |
| 413 | 413 | inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 414 | 414 | |
| 415 | 415 | ~Application(); |
| r14260 | r14261 | |
| 422 | 422 | //@} |
| 423 | 423 | |
| 424 | 424 | /** Assigns an object with copy control. See |
| 425 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 426 | */ | |
| 425 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 426 | */ | |
| 427 | 427 | inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 428 | 428 | |
| 429 | 429 | //@{ |
| r14260 | r14261 | |
| 450 | 450 | }; |
| 451 | 451 | |
| 452 | 452 | /** SEEKTABLE metadata block. |
| 453 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 454 | * and the <A HREF="../format.html#metadata_block_seektable">format specification</A>. | |
| 455 | */ | |
| 453 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 454 | * and the <A HREF="../format.html#metadata_block_seektable">format specification</A>. | |
| 455 | */ | |
| 456 | 456 | class FLACPP_API SeekTable : public Prototype { |
| 457 | 457 | public: |
| 458 | 458 | SeekTable(); |
| 459 | 459 | |
| 460 | 460 | //@{ |
| 461 | 461 | /** Constructs a copy of the given object. This form |
| 462 | * always performs a deep copy. | |
| 463 | */ | |
| 462 | * always performs a deep copy. | |
| 463 | */ | |
| 464 | 464 | inline SeekTable(const SeekTable &object): Prototype(object) { } |
| 465 | 465 | inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 466 | 466 | inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 467 | 467 | //@} |
| 468 | 468 | |
| 469 | 469 | /** Constructs an object with copy control. See |
| 470 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 471 | */ | |
| 470 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 471 | */ | |
| 472 | 472 | inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 473 | 473 | |
| 474 | 474 | ~SeekTable(); |
| r14260 | r14261 | |
| 481 | 481 | //@} |
| 482 | 482 | |
| 483 | 483 | /** Assigns an object with copy control. See |
| 484 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 485 | */ | |
| 484 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 485 | */ | |
| 486 | 486 | inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 487 | 487 | |
| 488 | 488 | //@{ |
| r14260 | r14261 | |
| 516 | 516 | }; |
| 517 | 517 | |
| 518 | 518 | /** VORBIS_COMMENT metadata block. |
| 519 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 520 | * and the <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>. | |
| 521 | */ | |
| 519 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 520 | * and the <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>. | |
| 521 | */ | |
| 522 | 522 | class FLACPP_API VorbisComment : public Prototype { |
| 523 | 523 | public: |
| 524 | 524 | /** Convenience class for encapsulating Vorbis comment |
| 525 | * entries. An entry is a vendor string or a comment | |
| 526 | * field. In the case of a vendor string, the field | |
| 527 | * name is undefined; only the field value is relevant. | |
| 528 | * | |
| 529 | * A \a field as used in the methods refers to an | |
| 530 | * entire 'NAME=VALUE' string; for convenience the | |
| 531 | * string is NUL-terminated. A length field is | |
| 532 | * required in the unlikely event that the value | |
| 533 | * contains contain embedded NULs. | |
| 534 | * | |
| 535 | * A \a field_name is what is on the left side of the | |
| 536 | * first '=' in the \a field. By definition it is ASCII | |
| 537 | * and so is NUL-terminated and does not require a | |
| 538 | * length to describe it. \a field_name is undefined | |
| 539 | * for a vendor string entry. | |
| 540 | * | |
| 541 | * A \a field_value is what is on the right side of the | |
| 542 | * first '=' in the \a field. By definition, this may | |
| 543 | * contain embedded NULs and so a \a field_value_length | |
| 544 | * is required to describe it. However in practice, | |
| 545 | * embedded NULs are not known to be used, so it is | |
| 546 | * generally safe to treat field values as NUL- | |
| 547 | * terminated UTF-8 strings. | |
| 548 | * | |
| 549 | * Always check is_valid() after the constructor or operator= | |
| 550 | * to make sure memory was properly allocated and that the | |
| 551 | * Entry conforms to the Vorbis comment specification. | |
| 552 | */ | |
| 525 | * entries. An entry is a vendor string or a comment | |
| 526 | * field. In the case of a vendor string, the field | |
| 527 | * name is undefined; only the field value is relevant. | |
| 528 | * | |
| 529 | * A \a field as used in the methods refers to an | |
| 530 | * entire 'NAME=VALUE' string; for convenience the | |
| 531 | * string is NUL-terminated. A length field is | |
| 532 | * required in the unlikely event that the value | |
| 533 | * contains contain embedded NULs. | |
| 534 | * | |
| 535 | * A \a field_name is what is on the left side of the | |
| 536 | * first '=' in the \a field. By definition it is ASCII | |
| 537 | * and so is NUL-terminated and does not require a | |
| 538 | * length to describe it. \a field_name is undefined | |
| 539 | * for a vendor string entry. | |
| 540 | * | |
| 541 | * A \a field_value is what is on the right side of the | |
| 542 | * first '=' in the \a field. By definition, this may | |
| 543 | * contain embedded NULs and so a \a field_value_length | |
| 544 | * is required to describe it. However in practice, | |
| 545 | * embedded NULs are not known to be used, so it is | |
| 546 | * generally safe to treat field values as NUL- | |
| 547 | * terminated UTF-8 strings. | |
| 548 | * | |
| 549 | * Always check is_valid() after the constructor or operator= | |
| 550 | * to make sure memory was properly allocated and that the | |
| 551 | * Entry conforms to the Vorbis comment specification. | |
| 552 | */ | |
| 553 | 553 | class FLACPP_API Entry { |
| 554 | 554 | public: |
| 555 | 555 | Entry(); |
| r14260 | r14261 | |
| 607 | 607 | |
| 608 | 608 | //@{ |
| 609 | 609 | /** Constructs a copy of the given object. This form |
| 610 | * always performs a deep copy. | |
| 611 | */ | |
| 610 | * always performs a deep copy. | |
| 611 | */ | |
| 612 | 612 | inline VorbisComment(const VorbisComment &object): Prototype(object) { } |
| 613 | 613 | inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 614 | 614 | inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 615 | 615 | //@} |
| 616 | 616 | |
| 617 | 617 | /** Constructs an object with copy control. See |
| 618 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 619 | */ | |
| 618 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 619 | */ | |
| 620 | 620 | inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 621 | 621 | |
| 622 | 622 | ~VorbisComment(); |
| r14260 | r14261 | |
| 629 | 629 | //@} |
| 630 | 630 | |
| 631 | 631 | /** Assigns an object with copy control. See |
| 632 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 633 | */ | |
| 632 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 633 | */ | |
| 634 | 634 | inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 635 | 635 | |
| 636 | 636 | //@{ |
| r14260 | r14261 | |
| 668 | 668 | }; |
| 669 | 669 | |
| 670 | 670 | /** CUESHEET metadata block. |
| 671 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 672 | * and the <A HREF="../format.html#metadata_block_cuesheet">format specification</A>. | |
| 673 | */ | |
| 671 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 672 | * and the <A HREF="../format.html#metadata_block_cuesheet">format specification</A>. | |
| 673 | */ | |
| 674 | 674 | class FLACPP_API CueSheet : public Prototype { |
| 675 | 675 | public: |
| 676 | 676 | /** Convenience class for encapsulating a cue sheet |
| 677 | * track. | |
| 678 | * | |
| 679 | * Always check is_valid() after the constructor or operator= | |
| 680 | * to make sure memory was properly allocated. | |
| 681 | */ | |
| 677 | * track. | |
| 678 | * | |
| 679 | * Always check is_valid() after the constructor or operator= | |
| 680 | * to make sure memory was properly allocated. | |
| 681 | */ | |
| 682 | 682 | class FLACPP_API Track { |
| 683 | 683 | protected: |
| 684 | 684 | ::FLAC__StreamMetadata_CueSheet_Track *object_; |
| r14260 | r14261 | |
| 710 | 710 | void set_type(unsigned value); |
| 711 | 711 | inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; } |
| 712 | 712 | |
| 713 | ||
| 713 | ||
| 714 | 714 | //@@@ It's awkward but to insert/delete index points |
| 715 | 715 | //@@@ you must use the routines in the CueSheet class. |
| 716 | 716 | }; |
| r14260 | r14261 | |
| 719 | 719 | |
| 720 | 720 | //@{ |
| 721 | 721 | /** Constructs a copy of the given object. This form |
| 722 | * always performs a deep copy. | |
| 723 | */ | |
| 722 | * always performs a deep copy. | |
| 723 | */ | |
| 724 | 724 | inline CueSheet(const CueSheet &object): Prototype(object) { } |
| 725 | 725 | inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 726 | 726 | inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 727 | 727 | //@} |
| 728 | 728 | |
| 729 | 729 | /** Constructs an object with copy control. See |
| 730 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 731 | */ | |
| 730 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 731 | */ | |
| 732 | 732 | inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 733 | 733 | |
| 734 | 734 | ~CueSheet(); |
| r14260 | r14261 | |
| 741 | 741 | //@} |
| 742 | 742 | |
| 743 | 743 | /** Assigns an object with copy control. See |
| 744 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 745 | */ | |
| 744 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 745 | */ | |
| 746 | 746 | inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 747 | 747 | |
| 748 | 748 | //@{ |
| r14260 | r14261 | |
| 795 | 795 | }; |
| 796 | 796 | |
| 797 | 797 | /** PICTURE metadata block. |
| 798 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 799 | * and the <A HREF="../format.html#metadata_block_picture">format specification</A>. | |
| 800 | */ | |
| 798 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 799 | * and the <A HREF="../format.html#metadata_block_picture">format specification</A>. | |
| 800 | */ | |
| 801 | 801 | class FLACPP_API Picture : public Prototype { |
| 802 | 802 | public: |
| 803 | 803 | Picture(); |
| 804 | 804 | |
| 805 | 805 | //@{ |
| 806 | 806 | /** Constructs a copy of the given object. This form |
| 807 | * always performs a deep copy. | |
| 808 | */ | |
| 807 | * always performs a deep copy. | |
| 808 | */ | |
| 809 | 809 | inline Picture(const Picture &object): Prototype(object) { } |
| 810 | 810 | inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 811 | 811 | inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 812 | 812 | //@} |
| 813 | 813 | |
| 814 | 814 | /** Constructs an object with copy control. See |
| 815 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 816 | */ | |
| 815 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 816 | */ | |
| 817 | 817 | inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 818 | 818 | |
| 819 | 819 | ~Picture(); |
| r14260 | r14261 | |
| 826 | 826 | //@} |
| 827 | 827 | |
| 828 | 828 | /** Assigns an object with copy control. See |
| 829 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 830 | */ | |
| 829 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 830 | */ | |
| 831 | 831 | inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 832 | 832 | |
| 833 | 833 | //@{ |
| r14260 | r14261 | |
| 872 | 872 | }; |
| 873 | 873 | |
| 874 | 874 | /** Opaque metadata block for storing unknown types. |
| 875 | * This should not be used unless you know what you are doing; | |
| 876 | * it is currently used only internally to support forward | |
| 877 | * compatibility of metadata blocks. | |
| 878 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 879 | */ | |
| 875 | * This should not be used unless you know what you are doing; | |
| 876 | * it is currently used only internally to support forward | |
| 877 | * compatibility of metadata blocks. | |
| 878 | * See the \link flacpp_metadata_object overview \endlink for more, | |
| 879 | */ | |
| 880 | 880 | class FLACPP_API Unknown : public Prototype { |
| 881 | 881 | public: |
| 882 | 882 | Unknown(); |
| 883 | 883 | // |
| 884 | 884 | //@{ |
| 885 | 885 | /** Constructs a copy of the given object. This form |
| 886 | * always performs a deep copy. | |
| 887 | */ | |
| 886 | * always performs a deep copy. | |
| 887 | */ | |
| 888 | 888 | inline Unknown(const Unknown &object): Prototype(object) { } |
| 889 | 889 | inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 890 | 890 | inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
| 891 | 891 | //@} |
| 892 | 892 | |
| 893 | 893 | /** Constructs an object with copy control. See |
| 894 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 895 | */ | |
| 894 | * Prototype(::FLAC__StreamMetadata *object, bool copy). | |
| 895 | */ | |
| 896 | 896 | inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
| 897 | 897 | |
| 898 | 898 | ~Unknown(); |
| r14260 | r14261 | |
| 905 | 905 | //@} |
| 906 | 906 | |
| 907 | 907 | /** Assigns an object with copy control. See |
| 908 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 909 | */ | |
| 908 | * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). | |
| 909 | */ | |
| 910 | 910 | inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } |
| 911 | 911 | |
| 912 | 912 | //@{ |
| r14260 | r14261 | |
| 934 | 934 | |
| 935 | 935 | |
| 936 | 936 | /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface |
| 937 | * \ingroup flacpp_metadata | |
| 938 | * | |
| 939 | * \brief | |
| 940 | * Level 0 metadata iterators. | |
| 941 | * | |
| 942 | * See the \link flac_metadata_level0 C layer equivalent \endlink | |
| 943 | * for more. | |
| 944 | * | |
| 945 | * \{ | |
| 946 | */ | |
| 937 | * \ingroup flacpp_metadata | |
| 938 | * | |
| 939 | * \brief | |
| 940 | * Level 0 metadata iterators. | |
| 941 | * | |
| 942 | * See the \link flac_metadata_level0 C layer equivalent \endlink | |
| 943 | * for more. | |
| 944 | * | |
| 945 | * \{ | |
| 946 | */ | |
| 947 | 947 | |
| 948 | 948 | FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); ///< See FLAC__metadata_get_streaminfo(). |
| 949 | 949 | |
| r14260 | r14261 | |
| 960 | 960 | |
| 961 | 961 | |
| 962 | 962 | /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface |
| 963 | * \ingroup flacpp_metadata | |
| 964 | * | |
| 965 | * \brief | |
| 966 | * Level 1 metadata iterator. | |
| 967 | * | |
| 968 | * The flow through the iterator in the C++ layer is similar | |
| 969 | * to the C layer: | |
| 970 | * - Create a SimpleIterator instance | |
| 971 | * - Check SimpleIterator::is_valid() | |
| 972 | * - Call SimpleIterator::init() and check the return | |
| 973 | * - Traverse and/or edit. Edits are written to file | |
| 974 | * immediately. | |
| 975 | * - Destroy the SimpleIterator instance | |
| 976 | * | |
| 977 | * The ownership of pointers in the C++ layer follows that in | |
| 978 | * the C layer, i.e. | |
| 979 | * - The objects returned by get_block() are yours to | |
| 980 | * modify, but changes are not reflected in the FLAC file | |
| 981 | * until you call set_block(). The objects are also | |
| 982 | * yours to delete; they are not automatically deleted | |
| 983 | * when passed to set_block() or insert_block_after(). | |
| 984 | * | |
| 985 | * See the \link flac_metadata_level1 C layer equivalent \endlink | |
| 986 | * for more. | |
| 987 | * | |
| 988 | * \{ | |
| 989 | */ | |
| 963 | * \ingroup flacpp_metadata | |
| 964 | * | |
| 965 | * \brief | |
| 966 | * Level 1 metadata iterator. | |
| 967 | * | |
| 968 | * The flow through the iterator in the C++ layer is similar | |
| 969 | * to the C layer: | |
| 970 | * - Create a SimpleIterator instance | |
| 971 | * - Check SimpleIterator::is_valid() | |
| 972 | * - Call SimpleIterator::init() and check the return | |
| 973 | * - Traverse and/or edit. Edits are written to file | |
| 974 | * immediately. | |
| 975 | * - Destroy the SimpleIterator instance | |
| 976 | * | |
| 977 | * The ownership of pointers in the C++ layer follows that in | |
| 978 | * the C layer, i.e. | |
| 979 | * - The objects returned by get_block() are yours to | |
| 980 | * modify, but changes are not reflected in the FLAC file | |
| 981 | * until you call set_block(). The objects are also | |
| 982 | * yours to delete; they are not automatically deleted | |
| 983 | * when passed to set_block() or insert_block_after(). | |
| 984 | * | |
| 985 | * See the \link flac_metadata_level1 C layer equivalent \endlink | |
| 986 | * for more. | |
| 987 | * | |
| 988 | * \{ | |
| 989 | */ | |
| 990 | 990 | |
| 991 | 991 | /** This class is a wrapper around the FLAC__metadata_simple_iterator |
| 992 | * structures and methods; see the | |
| 993 | * \link flacpp_metadata_level1 usage guide \endlink and | |
| 994 | * ::FLAC__Metadata_SimpleIterator. | |
| 995 | */ | |
| 992 | * structures and methods; see the | |
| 993 | * \link flacpp_metadata_level1 usage guide \endlink and | |
| 994 | * ::FLAC__Metadata_SimpleIterator. | |
| 995 | */ | |
| 996 | 996 | class FLACPP_API SimpleIterator { |
| 997 | 997 | public: |
| 998 | 998 | /** This class is a wrapper around FLAC__Metadata_SimpleIteratorStatus. |
| 999 | ||
| 999 | */ | |
| 1000 | 1000 | class FLACPP_API Status { |
| 1001 | 1001 | public: |
| 1002 | 1002 | inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { } |
| r14260 | r14261 | |
| 1038 | 1038 | |
| 1039 | 1039 | |
| 1040 | 1040 | /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface |
| 1041 | * \ingroup flacpp_metadata | |
| 1042 | * | |
| 1043 | * \brief | |
| 1044 | * Level 2 metadata iterator. | |
| 1045 | * | |
| 1046 | * The flow through the iterator in the C++ layer is similar | |
| 1047 | * to the C layer: | |
| 1048 | * - Create a Chain instance | |
| 1049 | * - Check Chain::is_valid() | |
| 1050 | * - Call Chain::read() and check the return | |
| 1051 | * - Traverse and/or edit with an Iterator or with | |
| 1052 | * Chain::merge_padding() or Chain::sort_padding() | |
| 1053 | * - Write changes back to FLAC file with Chain::write() | |
| 1054 | * - Destroy the Chain instance | |
| 1055 | * | |
| 1056 | * The ownership of pointers in the C++ layer is slightly | |
| 1057 | * different than in the C layer, i.e. | |
| 1058 | * - The objects returned by Iterator::get_block() are NOT | |
| 1059 | * owned by the iterator and should be deleted by the | |
| 1060 | * caller when finished, BUT, when you modify the block, | |
| 1061 | * it will directly edit what's in the chain and you do | |
| 1062 | * not need to call Iterator::set_block(). However the | |
| 1063 | * changes will not be reflected in the FLAC file until | |
| 1064 | * the chain is written with Chain::write(). | |
| 1065 | * - When you pass an object to Iterator::set_block(), | |
| 1066 | * Iterator::insert_block_before(), or | |
| 1067 | * Iterator::insert_block_after(), the iterator takes | |
| 1068 | * ownership of the block and it will be deleted by the | |
| 1069 | * chain. | |
| 1070 | * | |
| 1071 | * See the \link flac_metadata_level2 C layer equivalent \endlink | |
| 1072 | * for more. | |
| 1073 | * | |
| 1074 | * \{ | |
| 1075 | */ | |
| 1041 | * \ingroup flacpp_metadata | |
| 1042 | * | |
| 1043 | * \brief | |
| 1044 | * Level 2 metadata iterator. | |
| 1045 | * | |
| 1046 | * The flow through the iterator in the C++ layer is similar | |
| 1047 | * to the C layer: | |
| 1048 | * - Create a Chain instance | |
| 1049 | * - Check Chain::is_valid() | |
| 1050 | * - Call Chain::read() and check the return | |
| 1051 | * - Traverse and/or edit with an Iterator or with | |
| 1052 | * Chain::merge_padding() or Chain::sort_padding() | |
| 1053 | * - Write changes back to FLAC file with Chain::write() | |
| 1054 | * - Destroy the Chain instance | |
| 1055 | * | |
| 1056 | * The ownership of pointers in the C++ layer is slightly | |
| 1057 | * different than in the C layer, i.e. | |
| 1058 | * - The objects returned by Iterator::get_block() are NOT | |
| 1059 | * owned by the iterator and should be deleted by the | |
| 1060 | * caller when finished, BUT, when you modify the block, | |
| 1061 | * it will directly edit what's in the chain and you do | |
| 1062 | * not need to call Iterator::set_block(). However the | |
| 1063 | * changes will not be reflected in the FLAC file until | |
| 1064 | * the chain is written with Chain::write(). | |
| 1065 | * - When you pass an object to Iterator::set_block(), | |
| 1066 | * Iterator::insert_block_before(), or | |
| 1067 | * Iterator::insert_block_after(), the iterator takes | |
| 1068 | * ownership of the block and it will be deleted by the | |
| 1069 | * chain. | |
| 1070 | * | |
| 1071 | * See the \link flac_metadata_level2 C layer equivalent \endlink | |
| 1072 | * for more. | |
| 1073 | * | |
| 1074 | * \{ | |
| 1075 | */ | |
| 1076 | 1076 | |
| 1077 | 1077 | /** This class is a wrapper around the FLAC__metadata_chain |
| 1078 | * structures and methods; see the | |
| 1079 | * \link flacpp_metadata_level2 usage guide \endlink and | |
| 1080 | * ::FLAC__Metadata_Chain. | |
| 1081 | */ | |
| 1078 | * structures and methods; see the | |
| 1079 | * \link flacpp_metadata_level2 usage guide \endlink and | |
| 1080 | * ::FLAC__Metadata_Chain. | |
| 1081 | */ | |
| 1082 | 1082 | class FLACPP_API Chain { |
| 1083 | 1083 | public: |
| 1084 | 1084 | /** This class is a wrapper around FLAC__Metadata_ChainStatus. |
| 1085 | ||
| 1085 | */ | |
| 1086 | 1086 | class FLACPP_API Status { |
| 1087 | 1087 | public: |
| 1088 | 1088 | inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { } |
| r14260 | r14261 | |
| 1119 | 1119 | }; |
| 1120 | 1120 | |
| 1121 | 1121 | /** This class is a wrapper around the FLAC__metadata_iterator |
| 1122 | * structures and methods; see the | |
| 1123 | * \link flacpp_metadata_level2 usage guide \endlink and | |
| 1124 | * ::FLAC__Metadata_Iterator. | |
| 1125 | */ | |
| 1122 | * structures and methods; see the | |
| 1123 | * \link flacpp_metadata_level2 usage guide \endlink and | |
| 1124 | * ::FLAC__Metadata_Iterator. | |
| 1125 | */ | |
| 1126 | 1126 | class FLACPP_API Iterator { |
| 1127 | 1127 | public: |
| 1128 | 1128 | Iterator(); |
| r14260 | r14261 | |
|---|---|---|
| 78 | 78 | namespace Decoder { |
| 79 | 79 | |
| 80 | 80 | /** \ingroup flacpp_decoder |
| 81 | * \brief | |
| 82 | * This class wraps the ::FLAC__StreamDecoder. If you are | |
| 83 | * decoding from a file, FLAC::Decoder::File may be more | |
| 84 | * convenient. | |
| 85 | * | |
| 86 | * The usage of this class is similar to FLAC__StreamDecoder, | |
| 87 | * except instead of providing callbacks to | |
| 88 | * FLAC__stream_decoder_init*_stream(), you will inherit from this | |
| 89 | * class and override the virtual callback functions with your | |
| 90 | * own implementations, then call init() or init_ogg(). The rest | |
| 91 | * of the calls work the same as in the C layer. | |
| 92 | * | |
| 93 | * Only the read, write, and error callbacks are mandatory. The | |
| 94 | * others are optional; this class provides default | |
| 95 | * implementations that do nothing. In order for seeking to work | |
| 96 | * you must overide seek_callback(), tell_callback(), | |
| 97 | * length_callback(), and eof_callback(). | |
| 98 | */ | |
| 81 | * \brief | |
| 82 | * This class wraps the ::FLAC__StreamDecoder. If you are | |
| 83 | * decoding from a file, FLAC::Decoder::File may be more | |
| 84 | * convenient. | |
| 85 | * | |
| 86 | * The usage of this class is similar to FLAC__StreamDecoder, | |
| 87 | * except instead of providing callbacks to | |
| 88 | * FLAC__stream_decoder_init*_stream(), you will inherit from this | |
| 89 | * class and override the virtual callback functions with your | |
| 90 | * own implementations, then call init() or init_ogg(). The rest | |
| 91 | * of the calls work the same as in the C layer. | |
| 92 | * | |
| 93 | * Only the read, write, and error callbacks are mandatory. The | |
| 94 | * others are optional; this class provides default | |
| 95 | * implementations that do nothing. In order for seeking to work | |
| 96 | * you must overide seek_callback(), tell_callback(), | |
| 97 | * length_callback(), and eof_callback(). | |
| 98 | */ | |
| 99 | 99 | class FLACPP_API Stream { |
| 100 | 100 | public: |
| 101 | 101 | /** This class is a wrapper around FLAC__StreamDecoderState. |
| 102 | ||
| 102 | */ | |
| 103 | 103 | class FLACPP_API State { |
| 104 | 104 | public: |
| 105 | 105 | inline State(::FLAC__StreamDecoderState state): state_(state) { } |
| r14260 | r14261 | |
| 115 | 115 | |
| 116 | 116 | //@{ |
| 117 | 117 | /** Call after construction to check the that the object was created |
| 118 | * successfully. If not, use get_state() to find out why not. | |
| 119 | */ | |
| 118 | * successfully. If not, use get_state() to find out why not. | |
| 119 | */ | |
| 120 | 120 | virtual bool is_valid() const; |
| 121 | 121 | inline operator bool() const { return is_valid(); } ///< See is_valid() |
| 122 | 122 | //@} |
| r14260 | r14261 | |
| 201 | 201 | }; |
| 202 | 202 | |
| 203 | 203 | /** \ingroup flacpp_decoder |
| 204 | * \brief | |
| 205 | * This class wraps the ::FLAC__StreamDecoder. If you are | |
| 206 | * not decoding from a file, you may need to use | |
| 207 | * FLAC::Decoder::Stream. | |
| 208 | * | |
| 209 | * The usage of this class is similar to FLAC__StreamDecoder, | |
| 210 | * except instead of providing callbacks to | |
| 211 | * FLAC__stream_decoder_init*_FILE() or | |
| 212 | * FLAC__stream_decoder_init*_file(), you will inherit from this | |
| 213 | * class and override the virtual callback functions with your | |
| 214 | * own implementations, then call init() or init_off(). The rest | |
| 215 | * of the calls work the same as in the C layer. | |
| 216 | * | |
| 217 | * Only the write, and error callbacks from FLAC::Decoder::Stream | |
| 218 | * are mandatory. The others are optional; this class provides | |
| 219 | * full working implementations for all other callbacks and | |
| 220 | * supports seeking. | |
| 221 | */ | |
| 204 | * \brief | |
| 205 | * This class wraps the ::FLAC__StreamDecoder. If you are | |
| 206 | * not decoding from a file, you may need to use | |
| 207 | * FLAC::Decoder::Stream. | |
| 208 | * | |
| 209 | * The usage of this class is similar to FLAC__StreamDecoder, | |
| 210 | * except instead of providing callbacks to | |
| 211 | * FLAC__stream_decoder_init*_FILE() or | |
| 212 | * FLAC__stream_decoder_init*_file(), you will inherit from this | |
| 213 | * class and override the virtual callback functions with your | |
| 214 | * own implementations, then call init() or init_off(). The rest | |
| 215 | * of the calls work the same as in the C layer. | |
| 216 | * | |
| 217 | * Only the write, and error callbacks from FLAC::Decoder::Stream | |
| 218 | * are mandatory. The others are optional; this class provides | |
| 219 | * full working implementations for all other callbacks and | |
| 220 | * supports seeking. | |
| 221 | */ | |
| 222 | 222 | class FLACPP_API File: public Stream { |
| 223 | 223 | public: |
| 224 | 224 | File(); |
| r14260 | r14261 | |
|---|---|---|
| 75 | 75 | if(err <= n) |
| 76 | 76 | return 0; |
| 77 | 77 | /* |
| 78 | * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. | |
| 79 | * These allow us later to know we won't lose too much precision in the | |
| 80 | * fixed-point division (err<<fracbits)/n. | |
| 81 | */ | |
| 78 | * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. | |
| 79 | * These allow us later to know we won't lose too much precision in the | |
| 80 | * fixed-point division (err<<fracbits)/n. | |
| 81 | */ | |
| 82 | 82 | |
| 83 | 83 | fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2(err)+1); |
| 84 | 84 | |
| r14260 | r14261 | |
| 87 | 87 | /* err now holds err/n with fracbits fractional bits */ |
| 88 | 88 | |
| 89 | 89 | /* |
| 90 | * Whittle err down to 16 bits max. 16 significant bits is enough for | |
| 91 | * our purposes. | |
| 92 | */ | |
| 90 | * Whittle err down to 16 bits max. 16 significant bits is enough for | |
| 91 | * our purposes. | |
| 92 | */ | |
| 93 | 93 | FLAC__ASSERT(err > 0); |
| 94 | 94 | bits = FLAC__bitmath_ilog2(err)+1; |
| 95 | 95 | if(bits > 16) { |
| r14260 | r14261 | |
| 118 | 118 | return 0; |
| 119 | 119 | |
| 120 | 120 | /* |
| 121 | * The return value must have 16 fractional bits. Since the whole part | |
| 122 | * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits | |
| 123 | * must be >= -3, these assertion allows us to be able to shift rbps | |
| 124 | * left if necessary to get 16 fracbits without losing any bits of the | |
| 125 | * whole part of rbps. | |
| 126 | * | |
| 127 | * There is a slight chance due to accumulated error that the whole part | |
| 128 | * will require 6 bits, so we use 6 in the assertion. Really though as | |
| 129 | * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. | |
| 130 | */ | |
| 121 | * The return value must have 16 fractional bits. Since the whole part | |
| 122 | * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits | |
| 123 | * must be >= -3, these assertion allows us to be able to shift rbps | |
| 124 | * left if necessary to get 16 fracbits without losing any bits of the | |
| 125 | * whole part of rbps. | |
| 126 | * | |
| 127 | * There is a slight chance due to accumulated error that the whole part | |
| 128 | * will require 6 bits, so we use 6 in the assertion. Really though as | |
| 129 | * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. | |
| 130 | */ | |
| 131 | 131 | FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6); |
| 132 | 132 | FLAC__ASSERT(fracbits >= -3); |
| 133 | 133 | |
| r14260 | r14261 | |
| 154 | 154 | if(err <= n) |
| 155 | 155 | return 0; |
| 156 | 156 | /* |
| 157 | * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. | |
| 158 | * These allow us later to know we won't lose too much precision in the | |
| 159 | * fixed-point division (err<<fracbits)/n. | |
| 160 | */ | |
| 157 | * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1. | |
| 158 | * These allow us later to know we won't lose too much precision in the | |
| 159 | * fixed-point division (err<<fracbits)/n. | |
| 160 | */ | |
| 161 | 161 | |
| 162 | 162 | fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2_wide(err)+1); |
| 163 | 163 | |
| r14260 | r14261 | |
| 166 | 166 | /* err now holds err/n with fracbits fractional bits */ |
| 167 | 167 | |
| 168 | 168 | /* |
| 169 | * Whittle err down to 16 bits max. 16 significant bits is enough for | |
| 170 | * our purposes. | |
| 171 | */ | |
| 169 | * Whittle err down to 16 bits max. 16 significant bits is enough for | |
| 170 | * our purposes. | |
| 171 | */ | |
| 172 | 172 | FLAC__ASSERT(err > 0); |
| 173 | 173 | bits = FLAC__bitmath_ilog2_wide(err)+1; |
| 174 | 174 | if(bits > 16) { |
| r14260 | r14261 | |
| 197 | 197 | return 0; |
| 198 | 198 | |
| 199 | 199 | /* |
| 200 | * The return value must have 16 fractional bits. Since the whole part | |
| 201 | * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits | |
| 202 | * must be >= -3, these assertion allows us to be able to shift rbps | |
| 203 | * left if necessary to get 16 fracbits without losing any bits of the | |
| 204 | * whole part of rbps. | |
| 205 | * | |
| 206 | * There is a slight chance due to accumulated error that the whole part | |
| 207 | * will require 6 bits, so we use 6 in the assertion. Really though as | |
| 208 | * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. | |
| 209 | */ | |
| 200 | * The return value must have 16 fractional bits. Since the whole part | |
| 201 | * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits | |
| 202 | * must be >= -3, these assertion allows us to be able to shift rbps | |
| 203 | * left if necessary to get 16 fracbits without losing any bits of the | |
| 204 | * whole part of rbps. | |
| 205 | * | |
| 206 | * There is a slight chance due to accumulated error that the whole part | |
| 207 | * will require 6 bits, so we use 6 in the assertion. Really though as | |
| 208 | * long as it fits in 13 bits (32 - (16 - (-3))) we are fine. | |
| 209 | */ | |
| 210 | 210 | FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6); |
| 211 | 211 | FLAC__ASSERT(fracbits >= -3); |
| 212 | 212 | |
| r14260 | r14261 | |
| 290 | 290 | FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); |
| 291 | 291 | FLAC__int32 error, save; |
| 292 | 292 | /* total_error_* are 64-bits to avoid overflow when encoding |
| 293 | * erratic signals when the bits-per-sample and blocksize are | |
| 294 | * large. | |
| 295 | */ | |
| 293 | * erratic signals when the bits-per-sample and blocksize are | |
| 294 | * large. | |
| 295 | */ | |
| 296 | 296 | FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; |
| 297 | 297 | unsigned i, order; |
| 298 | 298 |
| r14260 | r14261 | |
|---|---|---|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /* |
| 220 | * set the target for reading, taking into account word alignment and endianness | |
| 221 | */ | |
| 220 | * set the target for reading, taking into account word alignment and endianness | |
| 221 | */ | |
| 222 | 222 | bytes = (br->capacity - br->words) * FLAC__BYTES_PER_WORD - br->bytes; |
| 223 | 223 | if(bytes == 0) |
| 224 | 224 | return false; /* no space left, buffer is too small; see note for FLAC__BITREADER_DEFAULT_CAPACITY */ |
| 225 | 225 | target = ((FLAC__byte*)(br->buffer+br->words)) + br->bytes; |
| 226 | 226 | |
| 227 | 227 | /* before reading, if the existing reader looks like this (say brword is 32 bits wide) |
| 228 | * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 (partial tail word is left-justified) | |
| 229 | * buffer[BE]: 11 22 33 44 55 ?? ?? ?? (shown layed out as bytes sequentially in memory) | |
| 230 | * buffer[LE]: 44 33 22 11 ?? ?? ?? 55 (?? being don't-care) | |
| 231 | * ^^-------target, bytes=3 | |
| 232 | * on LE machines, have to byteswap the odd tail word so nothing is | |
| 233 | * overwritten: | |
| 234 | */ | |
| 228 | * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 (partial tail word is left-justified) | |
| 229 | * buffer[BE]: 11 22 33 44 55 ?? ?? ?? (shown layed out as bytes sequentially in memory) | |
| 230 | * buffer[LE]: 44 33 22 11 ?? ?? ?? 55 (?? being don't-care) | |
| 231 | * ^^-------target, bytes=3 | |
| 232 | * on LE machines, have to byteswap the odd tail word so nothing is | |
| 233 | * overwritten: | |
| 234 | */ | |
| 235 | 235 | #if WORDS_BIGENDIAN |
| 236 | 236 | #else |
| 237 | 237 | if(br->bytes) |
| r14260 | r14261 | |
| 239 | 239 | #endif |
| 240 | 240 | |
| 241 | 241 | /* now it looks like: |
| 242 | * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 | |
| 243 | * buffer[BE]: 11 22 33 44 55 ?? ?? ?? | |
| 244 | * buffer[LE]: 44 33 22 11 55 ?? ?? ?? | |
| 245 | * ^^-------target, bytes=3 | |
| 246 | */ | |
| 242 | * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 | |
| 243 | * buffer[BE]: 11 22 33 44 55 ?? ?? ?? | |
| 244 | * buffer[LE]: 44 33 22 11 55 ?? ?? ?? | |
| 245 | * ^^-------target, bytes=3 | |
| 246 | */ | |
| 247 | 247 | |
| 248 | 248 | /* read in the data; note that the callback may return a smaller number of bytes */ |
| 249 | 249 | if(!br->read_callback(target, &bytes, br->client_data)) |
| 250 | 250 | return false; |
| 251 | 251 | |
| 252 | 252 | /* after reading bytes 66 77 88 99 AA BB CC DD EE FF from the client: |
| 253 | * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | |
| 254 | * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? | |
| 255 | * buffer[LE]: 44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ?? | |
| 256 | * now have to byteswap on LE machines: | |
| 257 | */ | |
| 253 | * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | |
| 254 | * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? | |
| 255 | * buffer[LE]: 44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ?? | |
| 256 | * now have to byteswap on LE machines: | |
| 257 | */ | |
| 258 | 258 | #if WORDS_BIGENDIAN |
| 259 | 259 | #else |
| 260 | 260 | end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD; |
| r14260 | r14261 | |
| 270 | 270 | #endif |
| 271 | 271 | |
| 272 | 272 | /* now it looks like: |
| 273 | * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | |
| 274 | * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? | |
| 275 | * buffer[LE]: 44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD | |
| 276 | * finally we'll update the reader values: | |
| 277 | */ | |
| 273 | * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | |
| 274 | * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ?? | |
| 275 | * buffer[LE]: 44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD | |
| 276 | * finally we'll update the reader values: | |
| 277 | */ | |
| 278 | 278 | end = br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes; |
| 279 | 279 | br->words = end / FLAC__BYTES_PER_WORD; |
| 280 | 280 | br->bytes = end % FLAC__BYTES_PER_WORD; |
| r14260 | r14261 | |
| 293 | 293 | FLAC__BitReader *br = (FLAC__BitReader*)calloc(1, sizeof(FLAC__BitReader)); |
| 294 | 294 | |
| 295 | 295 | /* calloc() implies: |
| 296 | memset(br, 0, sizeof(FLAC__BitReader)); | |
| 297 | br->buffer = 0; | |
| 298 | br->capacity = 0; | |
| 299 | br->words = br->bytes = 0; | |
| 300 | br->consumed_words = br->consumed_bits = 0; | |
| 301 | br->read_callback = 0; | |
| 302 | br->client_data = 0; | |
| 303 | */ | |
| 296 | memset(br, 0, sizeof(FLAC__BitReader)); | |
| 297 | br->buffer = 0; | |
| 298 | br->capacity = 0; | |
| 299 | br->words = br->bytes = 0; | |
| 300 | br->consumed_words = br->consumed_bits = 0; | |
| 301 | br->read_callback = 0; | |
| 302 | br->client_data = 0; | |
| 303 | */ | |
| 304 | 304 | return br; |
| 305 | 305 | } |
| 306 | 306 | |
| r14260 | r14261 | |
| 487 | 487 | } |
| 488 | 488 | else { |
| 489 | 489 | /* in this case we're starting our read at a partial tail word; |
| 490 | * the reader has guaranteed that we have at least 'bits' bits | |
| 491 | * available to read, which makes this case simpler. | |
| 492 | */ | |
| 490 | * the reader has guaranteed that we have at least 'bits' bits | |
| 491 | * available to read, which makes this case simpler. | |
| 492 | */ | |
| 493 | 493 | /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */ |
| 494 | 494 | if(br->consumed_bits) { |
| 495 | 495 | /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ |
| r14260 | r14261 | |
| 566 | 566 | FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits) |
| 567 | 567 | { |
| 568 | 568 | /* |
| 569 | * OPT: a faster implementation is possible but probably not that useful | |
| 570 | * since this is only called a couple of times in the metadata readers. | |
| 571 | */ | |
| 569 | * OPT: a faster implementation is possible but probably not that useful | |
| 570 | * since this is only called a couple of times in the metadata readers. | |
| 571 | */ | |
| 572 | 572 | FLAC__ASSERT(0 != br); |
| 573 | 573 | FLAC__ASSERT(0 != br->buffer); |
| 574 | 574 | |
| r14260 | r14261 | |
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | /* at this point we've eaten up all the whole words; have to try |
| 743 | * reading through any tail bytes before calling the read callback. | |
| 744 | * this is a repeat of the above logic adjusted for the fact we | |
| 745 | * don't have a whole word. note though if the client is feeding | |
| 746 | * us data a byte at a time (unlikely), br->consumed_bits may not | |
| 747 | * be zero. | |
| 748 | */ | |
| 743 | * reading through any tail bytes before calling the read callback. | |
| 744 | * this is a repeat of the above logic adjusted for the fact we | |
| 745 | * don't have a whole word. note though if the client is feeding | |
| 746 | * us data a byte at a time (unlikely), br->consumed_bits may not | |
| 747 | * be zero. | |
| 748 | */ | |
| 749 | 749 | if(br->bytes) { |
| 750 | 750 | const unsigned end = br->bytes * 8; |
| 751 | 751 | brword b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits; |
| r14260 | r14261 | |
| 808 | 808 | unsigned bits; /* the # of binary LSBs left to read to finish a rice codeword */ |
| 809 | 809 | |
| 810 | 810 | /* try and get br->consumed_words and br->consumed_bits into register; |
| 811 | * must remember to flush them back to *br before calling other | |
| 812 | * bitwriter functions that use them, and before returning */ | |
| 811 | * must remember to flush them back to *br before calling other | |
| 812 | * bitwriter functions that use them, and before returning */ | |
| 813 | 813 | register unsigned cwords; |
| 814 | 814 | register unsigned cbits; |
| 815 | 815 | |
| r14260 | r14261 | |
| 863 | 863 | } |
| 864 | 864 | } |
| 865 | 865 | /* at this point we've eaten up all the whole words; have to try |
| 866 | * reading through any tail bytes before calling the read callback. | |
| 867 | * this is a repeat of the above logic adjusted for the fact we | |
| 868 | * don't have a whole word. note though if the client is feeding | |
| 869 | * us data a byte at a time (unlikely), br->consumed_bits may not | |
| 870 | * be zero. | |
| 871 | */ | |
| 866 | * reading through any tail bytes before calling the read callback. | |
| 867 | * this is a repeat of the above logic adjusted for the fact we | |
| 868 | * don't have a whole word. note though if the client is feeding | |
| 869 | * us data a byte at a time (unlikely), br->consumed_bits may not | |
| 870 | * be zero. | |
| 871 | */ | |
| 872 | 872 | if(br->bytes) { |
| 873 | 873 | const unsigned end = br->bytes * 8; |
| 874 | 874 | brword b = (br->buffer[cwords] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << cbits; |
| r14260 | r14261 | |
| 889 | 889 | } |
| 890 | 890 | } |
| 891 | 891 | /* flush registers and read; bitreader_read_from_client_() does |
| 892 | * not touch br->consumed_bits at all but we still need to set | |
| 893 | * it in case it fails and we have to return false. | |
| 894 | */ | |
| 892 | * not touch br->consumed_bits at all but we still need to set | |
| 893 | * it in case it fails and we have to return false. | |
| 894 | */ | |
| 895 | 895 | br->consumed_bits = cbits; |
| 896 | 896 | br->consumed_words = cwords; |
| 897 | 897 | if(!bitreader_read_from_client_(br)) |
| r14260 | r14261 | |
| 905 | 905 | if(bits) { |
| 906 | 906 | while((br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits < bits) { |
| 907 | 907 | /* flush registers and read; bitreader_read_from_client_() does |
| 908 | * not touch br->consumed_bits at all but we still need to set | |
| 909 | * it in case it fails and we have to return false. | |
| 910 | */ | |
| 908 | * not touch br->consumed_bits at all but we still need to set | |
| 909 | * it in case it fails and we have to return false. | |
| 910 | */ | |
| 911 | 911 | br->consumed_bits = cbits; |
| 912 | 912 | br->consumed_words = cwords; |
| 913 | 913 | if(!bitreader_read_from_client_(br)) |
| r14260 | r14261 | |
| 948 | 948 | } |
| 949 | 949 | else { |
| 950 | 950 | /* in this case we're starting our read at a partial tail word; |
| 951 | * the reader has guaranteed that we have at least 'bits' bits | |
| 952 | * available to read, which makes this case simpler. | |
| 953 | */ | |
| 951 | * the reader has guaranteed that we have at least 'bits' bits | |
| 952 | * available to read, which makes this case simpler. | |
| 953 | */ | |
| 954 | 954 | uval <<= bits; |
| 955 | 955 | if(cbits) { |
| 956 | 956 | /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ |
| r14260 | r14261 | |
| 989 | 989 | unsigned uval = 0; |
| 990 | 990 | |
| 991 | 991 | /* try and get br->consumed_words and br->consumed_bits into register; |
| 992 | * must remember to flush them back to *br before calling other | |
| 993 | * bitwriter functions that use them, and before returning */ | |
| 992 | * must remember to flush them back to *br before calling other | |
| 993 | * bitwriter functions that use them, and before returning */ | |
| 994 | 994 | register unsigned cwords; |
| 995 | 995 | register unsigned cbits; |
| 996 | 996 | unsigned ucbits; /* keep track of the number of unconsumed bits in the buffer */ |
| r14260 | r14261 | |
| 1046 | 1046 | } |
| 1047 | 1047 | } |
| 1048 | 1048 | /* at this point we've eaten up all the whole words; have to try |
| 1049 | * reading through any tail bytes before calling the read callback. | |
| 1050 | * this is a repeat of the above logic adjusted for the fact we | |
| 1051 | * don't have a whole word. note though if the client is feeding | |
| 1052 | * us data a byte at a time (unlikely), br->consumed_bits may not | |
| 1053 | * be zero. | |
| 1054 | */ | |
| 1049 | * reading through any tail bytes before calling the read callback. | |
| 1050 | * this is a repeat of the above logic adjusted for the fact we | |
| 1051 | * don't have a whole word. note though if the client is feeding | |
| 1052 | * us data a byte at a time (unlikely), br->consumed_bits may not | |
| 1053 | * be zero. | |
| 1054 | */ | |
| 1055 | 1055 | if(br->bytes) { |
| 1056 | 1056 | const unsigned end = br->bytes * 8; |
| 1057 | 1057 | brword b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end)) << cbits; |
| r14260 | r14261 | |
| 1071 | 1071 | } |
| 1072 | 1072 | } |
| 1073 | 1073 | /* flush registers and read; bitreader_read_from_client_() does |
| 1074 | * not touch br->consumed_bits at all but we still need to set | |
| 1075 | * it in case it fails and we have to return false. | |
| 1076 | */ | |
| 1074 | * not touch br->consumed_bits at all but we still need to set | |
| 1075 | * it in case it fails and we have to return false. | |
| 1076 | */ | |
| 1077 | 1077 | br->consumed_bits = cbits; |
| 1078 | 1078 | br->consumed_words = cwords; |
| 1079 | 1079 | if(!bitreader_read_from_client_(br)) |
| r14260 | r14261 | |
| 1081 | 1081 | cwords = br->consumed_words; |
| 1082 | 1082 | ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits + uval; |
| 1083 | 1083 | /* + uval to offset our count by the # of unary bits already |
| 1084 | * consumed before the read, because we will add these back | |
| 1085 | * in all at once at break1 | |
| 1086 | */ | |
| 1084 | * consumed before the read, because we will add these back | |
| 1085 | * in all at once at break1 | |
| 1086 | */ | |
| 1087 | 1087 | } |
| 1088 | 1088 | break1: |
| 1089 | 1089 | ucbits -= uval; |
| r14260 | r14261 | |
| 1095 | 1095 | if(parameter) { |
| 1096 | 1096 | while(ucbits < parameter) { |
| 1097 | 1097 | /* flush registers and read; bitreader_read_from_client_() does |
| 1098 | * not touch br->consumed_bits at all but we still need to set | |
| 1099 | * it in case it fails and we have to return false. | |
| 1100 | */ | |
| 1098 | * not touch br->consumed_bits at all but we still need to set | |
| 1099 | * it in case it fails and we have to return false. | |
| 1100 | */ | |
| 1101 | 1101 | br->consumed_bits = cbits; |
| 1102 | 1102 | br->consumed_words = cwords; |
| 1103 | 1103 | if(!bitreader_read_from_client_(br)) |
| r14260 | r14261 | |
| 1135 | 1135 | } |
| 1136 | 1136 | else { |
| 1137 | 1137 | /* in this case we're starting our read at a partial tail word; |
| 1138 | * the reader has guaranteed that we have at least 'parameter' | |
| 1139 | * bits available to read, which makes this case simpler. | |
| 1140 | */ | |
| 1138 | * the reader has guaranteed that we have at least 'parameter' | |
| 1139 | * bits available to read, which makes this case simpler. | |
| 1140 | */ | |
| 1141 | 1141 | uval <<= parameter; |
| 1142 | 1142 | if(cbits) { |
| 1143 | 1143 | /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ |
| r14260 | r14261 | |
|---|---|---|
| 57 | 57 | static const FLAC__uint32 log2_lookup[][LOG2_LOOKUP_PRECISION] = { |
| 58 | 58 | { |
| 59 | 59 | /* |
| 60 | * 0 fraction bits | |
| 61 | */ | |
| 60 | * 0 fraction bits | |
| 61 | */ | |
| 62 | 62 | /* undefined */ 0x00000000, |
| 63 | 63 | /* lg(2/1) = */ 0x00000001, |
| 64 | 64 | /* lg(4/3) = */ 0x00000000, |
| r14260 | r14261 | |
| 78 | 78 | }, |
| 79 | 79 | { |
| 80 | 80 | /* |
| 81 | * 4 fraction bits | |
| 82 | */ | |
| 81 | * 4 fraction bits | |
| 82 | */ | |
| 83 | 83 | /* undefined */ 0x00000000, |
| 84 | 84 | /* lg(2/1) = */ 0x00000010, |
| 85 | 85 | /* lg(4/3) = */ 0x00000007, |
| r14260 | r14261 | |
| 99 | 99 | }, |
| 100 | 100 | { |
| 101 | 101 | /* |
| 102 | * 8 fraction bits | |
| 103 | */ | |
| 102 | * 8 fraction bits | |
| 103 | */ | |
| 104 | 104 | /* undefined */ 0x00000000, |
| 105 | 105 | /* lg(2/1) = */ 0x00000100, |
| 106 | 106 | /* lg(4/3) = */ 0x0000006a, |
| r14260 | r14261 | |
| 120 | 120 | }, |
| 121 | 121 | { |
| 122 | 122 | /* |
| 123 | * 12 fraction bits | |
| 124 | */ | |
| 123 | * 12 fraction bits | |
| 124 | */ | |
| 125 | 125 | /* undefined */ 0x00000000, |
| 126 | 126 | /* lg(2/1) = */ 0x00001000, |
| 127 | 127 | /* lg(4/3) = */ 0x000006a4, |
| r14260 | r14261 | |
| 141 | 141 | }, |
| 142 | 142 | { |
| 143 | 143 | /* |
| 144 | * 16 fraction bits | |
| 145 | */ | |
| 144 | * 16 fraction bits | |
| 145 | */ | |
| 146 | 146 | /* undefined */ 0x00000000, |
| 147 | 147 | /* lg(2/1) = */ 0x00010000, |
| 148 | 148 | /* lg(4/3) = */ 0x00006a40, |
| r14260 | r14261 | |
| 162 | 162 | }, |
| 163 | 163 | { |
| 164 | 164 | /* |
| 165 | * 20 fraction bits | |
| 166 | */ | |
| 165 | * 20 fraction bits | |
| 166 | */ | |
| 167 | 167 | /* undefined */ 0x00000000, |
| 168 | 168 | /* lg(2/1) = */ 0x00100000, |
| 169 | 169 | /* lg(4/3) = */ 0x0006a3fe, |
| r14260 | r14261 | |
| 183 | 183 | }, |
| 184 | 184 | { |
| 185 | 185 | /* |
| 186 | * 24 fraction bits | |
| 187 | */ | |
| 186 | * 24 fraction bits | |
| 187 | */ | |
| 188 | 188 | /* undefined */ 0x00000000, |
| 189 | 189 | /* lg(2/1) = */ 0x01000000, |
| 190 | 190 | /* lg(4/3) = */ 0x006a3fe6, |
| r14260 | r14261 | |
| 204 | 204 | }, |
| 205 | 205 | { |
| 206 | 206 | /* |
| 207 | * 28 fraction bits | |
| 208 | */ | |
| 207 | * 28 fraction bits | |
| 208 | */ | |
| 209 | 209 | /* undefined */ 0x00000000, |
| 210 | 210 | /* lg(2/1) = */ 0x10000000, |
| 211 | 211 | /* lg(4/3) = */ 0x06a3fe5c, |
| r14260 | r14261 | |
| 229 | 229 | static const FLAC__uint64 log2_lookup_wide[] = { |
| 230 | 230 | { |
| 231 | 231 | /* |
| 232 | * 32 fraction bits | |
| 233 | */ | |
| 232 | * 32 fraction bits | |
| 233 | */ | |
| 234 | 234 | /* undefined */ 0x00000000, |
| 235 | 235 | /* lg(2/1) = */ FLAC__U64L(0x100000000), |
| 236 | 236 | /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c6), |
| r14260 | r14261 | |
| 250 | 250 | }, |
| 251 | 251 | { |
| 252 | 252 | /* |
| 253 | * 48 fraction bits | |
| 254 | */ | |
| 253 | * 48 fraction bits | |
| 254 | */ | |
| 255 | 255 | /* undefined */ 0x00000000, |
| 256 | 256 | /* lg(2/1) = */ FLAC__U64L(0x1000000000000), |
| 257 | 257 | /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c60429), |
| r14260 | r14261 | |
| 282 | 282 | |
| 283 | 283 | if(x < ONE) |
| 284 | 284 | return 0; |
| 285 | ||
| 285 | ||
| 286 | 286 | if(precision > LOG2_LOOKUP_PRECISION) |
| 287 | 287 | precision = LOG2_LOOKUP_PRECISION; |
| 288 | 288 |
| r14260 | r14261 | |
|---|---|---|
| 268 | 268 | /* we have to make sure that the string we're taking over is null-terminated */ |
| 269 | 269 | |
| 270 | 270 | /* |
| 271 | * Stripping the const from src->entry is OK since we're taking | |
| 272 | * ownership of the pointer. This is a hack around a deficiency | |
| 273 | * in the API where the same function is used for 'copy' and | |
| 274 | * 'own', but the source entry is a const pointer. If we were | |
| 275 | * precise, the 'own' flavor would be a separate function with a | |
| 276 | * non-const source pointer. But it's not, so we hack away. | |
| 277 | */ | |
| 271 | * Stripping the const from src->entry is OK since we're taking | |
| 272 | * ownership of the pointer. This is a hack around a deficiency | |
| 273 | * in the API where the same function is used for 'copy' and | |
| 274 | * 'own', but the source entry is a const pointer. If we were | |
| 275 | * precise, the 'own' flavor would be a separate function with a | |
| 276 | * non-const source pointer. But it's not, so we hack away. | |
| 277 | */ | |
| 278 | 278 | if(!ensure_null_terminated_((FLAC__byte**)(&src->entry), src->length)) |
| 279 | 279 | return false; |
| 280 | 280 | *dest = *src; |
| r14260 | r14261 | |
| 447 | 447 | break; |
| 448 | 448 | case FLAC__METADATA_TYPE_PADDING: |
| 449 | 449 | /* calloc() took care of this for us: |
| 450 | object->length = 0; | |
| 451 | */ | |
| 450 | object->length = 0; | |
| 451 | */ | |
| 452 | 452 | break; |
| 453 | 453 | case FLAC__METADATA_TYPE_APPLICATION: |
| 454 | 454 | object->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; |
| 455 | 455 | /* calloc() took care of this for us: |
| 456 | object->data.application.data = 0; | |
| 457 | */ | |
| 456 | object->data.application.data = 0; | |
| 457 | */ | |
| 458 | 458 | break; |
| 459 | 459 | case FLAC__METADATA_TYPE_SEEKTABLE: |
| 460 | 460 | /* calloc() took care of this for us: |
| 461 | object->length = 0; | |
| 462 | object->data.seek_table.num_points = 0; | |
| 463 | object->data.seek_table.points = 0; | |
| 464 | */ | |
| 461 | object->length = 0; | |
| 462 | object->data.seek_table.num_points = 0; | |
| 463 | object->data.seek_table.points = 0; | |
| 464 | */ | |
| 465 | 465 | break; |
| 466 | 466 | case FLAC__METADATA_TYPE_VORBIS_COMMENT: |
| 467 | 467 | object->data.vorbis_comment.vendor_string.length = (unsigned)strlen(FLAC__VENDOR_STRING); |
| r14260 | r14261 | |
| 490 | 490 | object->data.picture.mime_type = 0; |
| 491 | 491 | object->data.picture.description = 0; |
| 492 | 492 | /* calloc() took care of this for us: |
| 493 | object->data.picture.width = 0; | |
| 494 | object->data.picture.height = 0; | |
| 495 | object->data.picture.depth = 0; | |
| 496 | object->data.picture.colors = 0; | |
| 497 | object->data.picture.data_length = 0; | |
| 498 | object->data.picture.data = 0; | |
| 499 | */ | |
| 493 | object->data.picture.width = 0; | |
| 494 | object->data.picture.height = 0; | |
| 495 | object->data.picture.depth = 0; | |
| 496 | object->data.picture.colors = 0; | |
| 497 | object->data.picture.data_length = 0; | |
| 498 | object->data.picture.data = 0; | |
| 499 | */ | |
| 500 | 500 | /* now initialize mime_type and description with empty strings to make things easier on the client */ |
| 501 | 501 | if(!copy_cstring_(&object->data.picture.mime_type, "")) { |
| 502 | 502 | free(object); |
| r14260 | r14261 | |
| 511 | 511 | break; |
| 512 | 512 | default: |
| 513 | 513 | /* calloc() took care of this for us: |
| 514 | object->length = 0; | |
| 515 | object->data.unknown.data = 0; | |
| 516 | */ | |
| 514 | object->length = 0; | |
| 515 | object->data.unknown.data = 0; | |
| 516 | */ | |
| 517 | 517 | break; |
| 518 | 518 | } |
| 519 | 519 | } |
| r14260 | r14261 | |
| 1330 | 1330 | memcpy(entry->entry+nn+1, field_value, nv); |
| 1331 | 1331 | entry->entry[entry->length] = '\0'; |
| 1332 | 1332 | } |
| 1333 | ||
| 1333 | ||
| 1334 | 1334 | return true; |
| 1335 | 1335 | } |
| 1336 | 1336 |
| r14260 | r14261 | |
|---|---|---|
| 123 | 123 | new_capacity = bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD); |
| 124 | 124 | |
| 125 | 125 | /* it's possible (due to pessimism in the growth estimation that |
| 126 | * leads to this call) that we don't actually need to grow | |
| 127 | */ | |
| 126 | * leads to this call) that we don't actually need to grow | |
| 127 | */ | |
| 128 | 128 | if(bw->capacity >= new_capacity) |
| 129 | 129 | return true; |
| 130 | 130 | |
| r14260 | r14261 | |
| 288 | 288 | void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw) |
| 289 | 289 | { |
| 290 | 290 | /* nothing to do. in the future, strict checking of a 'writer-is-in- |
| 291 | * get-mode' flag could be added everywhere and then cleared here | |
| 292 | */ | |
| 291 | * get-mode' flag could be added everywhere and then cleared here | |
| 292 | */ | |
| 293 | 293 | (void)bw; |
| 294 | 294 | } |
| 295 | 295 | |
| r14260 | r14261 | |
| 629 | 629 | } |
| 630 | 630 | else { |
| 631 | 631 | /* if bw->bits == 0, left==FLAC__BITS_PER_WORD which will always |
| 632 | * be > lsbits (because of previous assertions) so it would have | |
| 633 | * triggered the (lsbits<left) case above. | |
| 634 | */ | |
| 632 | * be > lsbits (because of previous assertions) so it would have | |
| 633 | * triggered the (lsbits<left) case above. | |
| 634 | */ | |
| 635 | 635 | FLAC__ASSERT(bw->bits); |
| 636 | 636 | FLAC__ASSERT(left < FLAC__BITS_PER_WORD); |
| 637 | 637 | bw->accum <<= left; |
| r14260 | r14261 | |
|---|---|---|
| 264 | 264 | (void)decoder; |
| 265 | 265 | |
| 266 | 266 | /* |
| 267 | * we assume we only get here when the one metadata block we were | |
| 268 | * looking for was passed to us | |
| 269 | */ | |
| 267 | * we assume we only get here when the one metadata block we were | |
| 268 | * looking for was passed to us | |
| 269 | */ | |
| 270 | 270 | if(!cd->got_error && 0 == cd->object) { |
| 271 | 271 | if(0 == (cd->object = FLAC__metadata_object_clone(metadata))) |
| 272 | 272 | cd->got_error = true; |
| r14260 | r14261 | |
| 906 | 906 | FLAC__Metadata_ChainStatus status; |
| 907 | 907 | off_t first_offset, last_offset; |
| 908 | 908 | /* |
| 909 | * This is the length of the chain initially read from the FLAC file. | |
| 910 | * it is used to compare against the current length to decide whether | |
| 911 | * or not the whole file has to be rewritten. | |
| 912 | */ | |
| 909 | * This is the length of the chain initially read from the FLAC file. | |
| 910 | * it is used to compare against the current length to decide whether | |
| 911 | * or not the whole file has to be rewritten. | |
| 912 | */ | |
| 913 | 913 | off_t initial_length; |
| 914 | 914 | /* @@@ hacky, these are currently only needed by ogg reader */ |
| 915 | 915 | FLAC__IOHandle handle; |
| r14260 | r14261 | |
| 1613 | 1613 | FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding) |
| 1614 | 1614 | { |
| 1615 | 1615 | /* This does all the same checks that are in chain_prepare_for_write_() |
| 1616 | * but doesn't actually alter the chain. Make sure to update the logic | |
| 1617 | * here if chain_prepare_for_write_() changes. | |
| 1618 | */ | |
| 1616 | * but doesn't actually alter the chain. Make sure to update the logic | |
| 1617 | * here if chain_prepare_for_write_() changes. | |
| 1618 | */ | |
| 1619 | 1619 | const off_t current_length = chain_calculate_length_(chain); |
| 1620 | 1620 | |
| 1621 | 1621 | FLAC__ASSERT(0 != chain); |
| r14260 | r14261 | |
| 1811 | 1811 | FLAC__ASSERT(0 != chain); |
| 1812 | 1812 | |
| 1813 | 1813 | /* |
| 1814 | * Don't try and be too smart... this simple algo is good enough for | |
| 1815 | * the small number of nodes that we deal with. | |
| 1816 | */ | |
| 1814 | * Don't try and be too smart... this simple algo is good enough for | |
| 1815 | * the small number of nodes that we deal with. | |
| 1816 | */ | |
| 1817 | 1817 | for(i = 0, node = chain->head; i < chain->nodes; i++) { |
| 1818 | 1818 | if(node->data->type == FLAC__METADATA_TYPE_PADDING) { |
| 1819 | 1819 | save = node->next; |
| r14260 | r14261 | |
| 1835 | 1835 | FLAC__Metadata_Iterator *iterator = (FLAC__Metadata_Iterator*)calloc(1, sizeof(FLAC__Metadata_Iterator)); |
| 1836 | 1836 | |
| 1837 | 1837 | /* calloc() implies: |
| 1838 | iterator->current = 0; | |
| 1839 | iterator->chain = 0; | |
| 1840 | */ | |
| 1838 | iterator->current = 0; | |
| 1839 | iterator->chain = 0; | |
| 1840 | */ | |
| 1841 | 1841 | |
| 1842 | 1842 | return iterator; |
| 1843 | 1843 | } |
| r14260 | r14261 | |
| 2087 | 2087 | *length = unpack_uint32_(raw_header + 1, 3); |
| 2088 | 2088 | |
| 2089 | 2089 | /* Note that we don't check: |
| 2090 | * if(iterator->type >= FLAC__METADATA_TYPE_UNDEFINED) | |
| 2091 | * we just will read in an opaque block | |
| 2092 | */ | |
| 2090 | * if(iterator->type >= FLAC__METADATA_TYPE_UNDEFINED) | |
| 2091 | * we just will read in an opaque block | |
| 2092 | */ | |
| 2093 | 2093 | |
| 2094 | 2094 | return true; |
| 2095 | 2095 | } |
| r14260 | r14261 | |
| 2126 | 2126 | b = buffer; |
| 2127 | 2127 | |
| 2128 | 2128 | /* we are using hardcoded numbers for simplicity but we should |
| 2129 | * probably eventually write a bit-level unpacker and use the | |
| 2130 | * _STREAMINFO_ constants. | |
| 2131 | */ | |
| 2129 | * probably eventually write a bit-level unpacker and use the | |
| 2130 | * _STREAMINFO_ constants. | |
| 2131 | */ | |
| 2132 | 2132 | block->min_blocksize = unpack_uint32_(b, 2); b += 2; |
| 2133 | 2133 | block->max_blocksize = unpack_uint32_(b, 2); b += 2; |
| 2134 | 2134 | block->min_framesize = unpack_uint32_(b, 3); b += 3; |
| r14260 | r14261 | |
| 2555 | 2555 | const unsigned bps1 = block->bits_per_sample - 1; |
| 2556 | 2556 | |
| 2557 | 2557 | /* we are using hardcoded numbers for simplicity but we should |
| 2558 | * probably eventually write a bit-level packer and use the | |
| 2559 | * _STREAMINFO_ constants. | |
| 2560 | */ | |
| 2558 | * probably eventually write a bit-level packer and use the | |
| 2559 | * _STREAMINFO_ constants. | |
| 2560 | */ | |
| 2561 | 2561 | pack_uint32_(block->min_blocksize, buffer, 2); |
| 2562 | 2562 | pack_uint32_(block->max_blocksize, buffer+2, 2); |
| 2563 | 2563 | pack_uint32_(block->min_framesize, buffer+4, 3); |
| r14260 | r14261 | |
| 3066 | 3066 | |
| 3067 | 3067 | if(fixup_is_last_code != 0) { |
| 3068 | 3068 | /* |
| 3069 | * if code == 1, it means a block was appended to the end so | |
| 3070 | * we have to clear the is_last flag of the previous block | |
| 3071 | * if code == -1, it means the last block was deleted so | |
| 3072 | * we have to set the is_last flag of the previous block | |
| 3073 | */ | |
| 3069 | * if code == 1, it means a block was appended to the end so | |
| 3070 | * we have to clear the is_last flag of the previous block | |
| 3071 | * if code == -1, it means the last block was deleted so | |
| 3072 | * we have to set the is_last flag of the previous block | |
| 3073 | */ | |
| 3074 | 3074 | /* MAGIC NUMBERs here; we know the is_last flag is the high bit of the byte at this location */ |
| 3075 | 3075 | FLAC__byte x; |
| 3076 | 3076 | if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) { |
| r14260 | r14261 | |
|---|---|---|
| 71 | 71 | FLAC__ASSERT(lag <= data_len); |
| 72 | 72 | |
| 73 | 73 | /* |
| 74 | * Technically we should subtract the mean first like so: | |
| 75 | * for(i = 0; i < data_len; i++) | |
| 76 | * data[i] -= mean; | |
| 77 | * but it appears not to make enough of a difference to matter, and | |
| 78 | * most signals are already closely centered around zero | |
| 79 | */ | |
| 74 | * Technically we should subtract the mean first like so: | |
| 75 | * for(i = 0; i < data_len; i++) | |
| 76 | * data[i] -= mean; | |
| 77 | * but it appears not to make enough of a difference to matter, and | |
| 78 | * most signals are already closely centered around zero | |
| 79 | */ | |
| 80 | 80 | while(lag--) { |
| 81 | 81 | for(i = lag, d = 0.0; i < data_len; i++) |
| 82 | 82 | d += data[i] * data[i - lag]; |
| r14260 | r14261 | |
| 85 | 85 | #endif |
| 86 | 86 | |
| 87 | 87 | /* |
| 88 | * this version tends to run faster because of better data locality | |
| 89 | * ('data_len' is usually much larger than 'lag') | |
| 90 | */ | |
| 88 | * this version tends to run faster because of better data locality | |
| 89 | * ('data_len' is usually much larger than 'lag') | |
| 90 | */ | |
| 91 | 91 | FLAC__real d; |
| 92 | 92 | unsigned sample, coeff; |
| 93 | 93 | const unsigned limit = data_len - lag; |
| r14260 | r14261 | |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | /* negative shift is very rare but due to design flaw, negative shift is |
| 226 | * a NOP in the decoder, so it must be handled specially by scaling down | |
| 227 | * coeffs | |
| 228 | */ | |
| 226 | * a NOP in the decoder, so it must be handled specially by scaling down | |
| 227 | * coeffs | |
| 228 | */ | |
| 229 | 229 | else { |
| 230 | 230 | const int nshift = -(*shift); |
| 231 | 231 | FLAC__double error = 0.0; |
| r14260 | r14261 | |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /* Here's a slower but clearer version: |
| 300 | for(i = 0; i < data_len; i++) { | |
| 301 | sum = 0; | |
| 302 | for(j = 0; j < order; j++) | |
| 303 | sum += qlp_coeff[j] * data[i-j-1]; | |
| 304 | residual[i] = data[i] - (sum >> lp_quantization); | |
| 305 | } | |
| 306 | */ | |
| 300 | for(i = 0; i < data_len; i++) { | |
| 301 | sum = 0; | |
| 302 | for(j = 0; j < order; j++) | |
| 303 | sum += qlp_coeff[j] * data[i-j-1]; | |
| 304 | residual[i] = data[i] - (sum >> lp_quantization); | |
| 305 | } | |
| 306 | */ | |
| 307 | 307 | } |
| 308 | 308 | #else /* fully unrolled version for normal use */ |
| 309 | 309 | { |
| r14260 | r14261 | |
| 314 | 314 | FLAC__ASSERT(order <= 32); |
| 315 | 315 | |
| 316 | 316 | /* |
| 317 | * We do unique versions up to 12th order since that's the subset limit. | |
| 318 | * Also they are roughly ordered to match frequency of occurrence to | |
| 319 | * minimize branching. | |
| 320 | */ | |
| 317 | * We do unique versions up to 12th order since that's the subset limit. | |
| 318 | * Also they are roughly ordered to match frequency of occurrence to | |
| 319 | * minimize branching. | |
| 320 | */ | |
| 321 | 321 | if(order <= 12) { |
| 322 | 322 | if(order > 8) { |
| 323 | 323 | if(order > 10) { |
| r14260 | r14261 | |
| 576 | 576 | FLAC__ASSERT(order <= 32); |
| 577 | 577 | |
| 578 | 578 | /* |
| 579 | * We do unique versions up to 12th order since that's the subset limit. | |
| 580 | * Also they are roughly ordered to match frequency of occurrence to | |
| 581 | * minimize branching. | |
| 582 | */ | |
| 579 | * We do unique versions up to 12th order since that's the subset limit. | |
| 580 | * Also they are roughly ordered to match frequency of occurrence to | |
| 581 | * minimize branching. | |
| 582 | */ | |
| 583 | 583 | if(order <= 12) { |
| 584 | 584 | if(order > 8) { |
| 585 | 585 | if(order > 10) { |
| r14260 | r14261 | |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | /* Here's a slower but clearer version: |
| 830 | for(i = 0; i < data_len; i++) { | |
| 831 | sum = 0; | |
| 832 | for(j = 0; j < order; j++) | |
| 833 | sum += qlp_coeff[j] * data[i-j-1]; | |
| 834 | data[i] = residual[i] + (sum >> lp_quantization); | |
| 835 | } | |
| 836 | */ | |
| 830 | for(i = 0; i < data_len; i++) { | |
| 831 | sum = 0; | |
| 832 | for(j = 0; j < order; j++) | |
| 833 | sum += qlp_coeff[j] * data[i-j-1]; | |
| 834 | data[i] = residual[i] + (sum >> lp_quantization); | |
| 835 | } | |
| 836 | */ | |
| 837 | 837 | } |
| 838 | 838 | #else /* fully unrolled version for normal use */ |
| 839 | 839 | { |
| r14260 | r14261 | |
| 844 | 844 | FLAC__ASSERT(order <= 32); |
| 845 | 845 | |
| 846 | 846 | /* |
| 847 | * We do unique versions up to 12th order since that's the subset limit. | |
| 848 | * Also they are roughly ordered to match frequency of occurrence to | |
| 849 | * minimize branching. | |
| 850 | */ | |
| 847 | * We do unique versions up to 12th order since that's the subset limit. | |
| 848 | * Also they are roughly ordered to match frequency of occurrence to | |
| 849 | * minimize branching. | |
| 850 | */ | |
| 851 | 851 | if(order <= 12) { |
| 852 | 852 | if(order > 8) { |
| 853 | 853 | if(order > 10) { |
| r14260 | r14261 | |
| 1106 | 1106 | FLAC__ASSERT(order <= 32); |
| 1107 | 1107 | |
| 1108 | 1108 | /* |
| 1109 | * We do unique versions up to 12th order since that's the subset limit. | |
| 1110 | * Also they are roughly ordered to match frequency of occurrence to | |
| 1111 | * minimize branching. | |
| 1112 | */ | |
| 1109 | * We do unique versions up to 12th order since that's the subset limit. | |
| 1110 | * Also they are roughly ordered to match frequency of occurrence to | |
| 1111 | * minimize branching. | |
| 1112 | */ | |
| 1113 | 1113 | if(order <= 12) { |
| 1114 | 1114 | if(order > 8) { |
| 1115 | 1115 | if(order > 10) { |
| r14260 | r14261 | |
|---|---|---|
| 398 | 398 | #endif |
| 399 | 399 | |
| 400 | 400 | /* |
| 401 | * get the CPU info and set the function pointers | |
| 402 | */ | |
| 401 | * get the CPU info and set the function pointers | |
| 402 | */ | |
| 403 | 403 | FLAC__cpu_info(&decoder->private_->cpuinfo); |
| 404 | 404 | /* first default to the non-asm routines */ |
| 405 | 405 | decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal; |
| r14260 | r14261 | |
| 547 | 547 | return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS; |
| 548 | 548 | |
| 549 | 549 | /* |
| 550 | * To make sure that our file does not go unclosed after an error, we | |
| 551 | * must assign the FILE pointer before any further error can occur in | |
| 552 | * this routine. | |
| 553 | */ | |
| 550 | * To make sure that our file does not go unclosed after an error, we | |
| 551 | * must assign the FILE pointer before any further error can occur in | |
| 552 | * this routine. | |
| 553 | */ | |
| 554 | 554 | if(file == stdin) |
| 555 | 555 | file = get_binary_stdin_(); /* just to be safe */ |
| 556 | 556 | |
| r14260 | r14261 | |
| 610 | 610 | FLAC__ASSERT(0 != decoder); |
| 611 | 611 | |
| 612 | 612 | /* |
| 613 | * To make sure that our file does not go unclosed after an error, we | |
| 614 | * have to do the same entrance checks here that are later performed | |
| 615 | * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned. | |
| 616 | */ | |
| 613 | * To make sure that our file does not go unclosed after an error, we | |
| 614 | * have to do the same entrance checks here that are later performed | |
| 615 | * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned. | |
| 616 | */ | |
| 617 | 617 | if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) |
| 618 | 618 | return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED; |
| 619 | 619 | |
| r14260 | r14261 | |
| 665 | 665 | return true; |
| 666 | 666 | |
| 667 | 667 | /* see the comment in FLAC__seekable_stream_decoder_reset() as to why we |
| 668 | * always call FLAC__MD5Final() | |
| 669 | */ | |
| 668 | * always call FLAC__MD5Final() | |
| 669 | */ | |
| 670 | 670 | FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context); |
| 671 | 671 | |
| 672 | 672 | if(decoder->private_->has_seek_table && 0 != decoder->private_->seek_table.data.seek_table.points) { |
| r14260 | r14261 | |
| 677 | 677 | FLAC__bitreader_free(decoder->private_->input); |
| 678 | 678 | for(i = 0; i < FLAC__MAX_CHANNELS; i++) { |
| 679 | 679 | /* WATCHOUT: |
| 680 | * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the | |
| 681 | * output arrays have a buffer of up to 3 zeroes in front | |
| 682 | * (at negative indices) for alignment purposes; we use 4 | |
| 683 | * to keep the data well-aligned. | |
| 684 | */ | |
| 680 | * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the | |
| 681 | * output arrays have a buffer of up to 3 zeroes in front | |
| 682 | * (at negative indices) for alignment purposes; we use 4 | |
| 683 | * to keep the data well-aligned. | |
| 684 | */ | |
| 685 | 685 | if(0 != decoder->private_->output[i]) { |
| 686 | 686 | free(decoder->private_->output[i]-4); |
| 687 | 687 | decoder->private_->output[i] = 0; |
| r14260 | r14261 | |
| 985 | 985 | #endif |
| 986 | 986 | |
| 987 | 987 | /* Rewind if necessary. If FLAC__stream_decoder_init() is calling us, |
| 988 | * (internal_reset_hack) don't try to rewind since we are already at | |
| 989 | * the beginning of the stream and don't want to fail if the input is | |
| 990 | * not seekable. | |
| 991 | */ | |
| 988 | * (internal_reset_hack) don't try to rewind since we are already at | |
| 989 | * the beginning of the stream and don't want to fail if the input is | |
| 990 | * not seekable. | |
| 991 | */ | |
| 992 | 992 | if(!decoder->private_->internal_reset_hack) { |
| 993 | 993 | if(decoder->private_->file == stdin) |
| 994 | 994 | return false; /* can't rewind stdin, reset fails */ |
| r14260 | r14261 | |
| 1008 | 1008 | } |
| 1009 | 1009 | decoder->private_->do_md5_checking = decoder->protected_->md5_checking; |
| 1010 | 1010 | /* |
| 1011 | * This goes in reset() and not flush() because according to the spec, a | |
| 1012 | * fixed-blocksize stream must stay that way through the whole stream. | |
| 1013 | */ | |
| 1011 | * This goes in reset() and not flush() because according to the spec, a | |
| 1012 | * fixed-blocksize stream must stay that way through the whole stream. | |
| 1013 | */ | |
| 1014 | 1014 | decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0; |
| 1015 | 1015 | |
| 1016 | 1016 | /* We initialize the FLAC__MD5Context even though we may never use it. This |
| 1017 | * is because md5 checking may be turned on to start and then turned off if | |
| 1018 | * a seek occurs. So we init the context here and finalize it in | |
| 1019 | * FLAC__stream_decoder_finish() to make sure things are always cleaned up | |
| 1020 | * properly. | |
| 1021 | */ | |
| 1017 | * is because md5 checking may be turned on to start and then turned off if | |
| 1018 | * a seek occurs. So we init the context here and finalize it in | |
| 1019 | * FLAC__stream_decoder_finish() to make sure things are always cleaned up | |
| 1020 | * properly. | |
| 1021 | */ | |
| 1022 | 1022 | FLAC__MD5Init(&decoder->private_->md5context); |
| 1023 | 1023 | |
| 1024 | 1024 | decoder->private_->first_frame_offset = 0; |
| r14260 | r14261 | |
| 1276 | 1276 | { |
| 1277 | 1277 | #if 0 |
| 1278 | 1278 | /* if something breaks here it is probably due to the presence or |
| 1279 | * absence of an underscore before the identifiers 'setmode', | |
| 1280 | * 'fileno', and/or 'O_BINARY'; check your system header files. | |
| 1281 | */ | |
| 1279 | * absence of an underscore before the identifiers 'setmode', | |
| 1280 | * 'fileno', and/or 'O_BINARY'; check your system header files. | |
| 1281 | */ | |
| 1282 | 1282 | #if defined _MSC_VER || defined __MINGW32__ |
| 1283 | 1283 | _setmode(_fileno(stdin), _O_BINARY); |
| 1284 | #elif defined __CYGWIN__ | |
| 1284 | #elif defined __CYGWIN__ | |
| 1285 | 1285 | /* almost certainly not needed for any modern Cygwin, but let's be safe... */ |
| 1286 | 1286 | setmode(_fileno(stdin), _O_BINARY); |
| 1287 | 1287 | #elif defined __EMX__ |
| r14260 | r14261 | |
| 1314 | 1314 | |
| 1315 | 1315 | for(i = 0; i < channels; i++) { |
| 1316 | 1316 | /* WATCHOUT: |
| 1317 | * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the | |
| 1318 | * output arrays have a buffer of up to 3 zeroes in front | |
| 1319 | * (at negative indices) for alignment purposes; we use 4 | |
| 1320 | * to keep the data well-aligned. | |
| 1321 | */ | |
| 1317 | * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the | |
| 1318 | * output arrays have a buffer of up to 3 zeroes in front | |
| 1319 | * (at negative indices) for alignment purposes; we use 4 | |
| 1320 | * to keep the data well-aligned. | |
| 1321 | */ | |
| 1322 | 1322 | tmp = (FLAC__int32*)safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/); |
| 1323 | 1323 | if(tmp == 0) { |
| 1324 | 1324 | decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; |
| r14260 | r14261 | |
| 1328 | 1328 | decoder->private_->output[i] = tmp + 4; |
| 1329 | 1329 | |
| 1330 | 1330 | /* WATCHOUT: |
| 1331 | * minimum of quadword alignment for PPC vector optimizations is REQUIRED: | |
| 1332 | */ | |
| 1331 | * minimum of quadword alignment for PPC vector optimizations is REQUIRED: | |
| 1332 | */ | |
| 1333 | 1333 | if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decoder->private_->residual[i])) { |
| 1334 | 1334 | decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR; |
| 1335 | 1335 | return false; |
| r14260 | r14261 | |
| 2009 | 2009 | return false; |
| 2010 | 2010 | for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) { |
| 2011 | 2011 | /* |
| 2012 | * first figure the correct bits-per-sample of the subframe | |
| 2013 | */ | |
| 2012 | * first figure the correct bits-per-sample of the subframe | |
| 2013 | */ | |
| 2014 | 2014 | unsigned bps = decoder->private_->frame.header.bits_per_sample; |
| 2015 | 2015 | switch(decoder->private_->frame.header.channel_assignment) { |
| 2016 | 2016 | case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: |
| r14260 | r14261 | |
| 2035 | 2035 | FLAC__ASSERT(0); |
| 2036 | 2036 | } |
| 2037 | 2037 | /* |
| 2038 | * now read it | |
| 2039 | */ | |
| 2038 | * now read it | |
| 2039 | */ | |
| 2040 | 2040 | if(!read_subframe_(decoder, channel, bps, do_full_decode)) |
| 2041 | 2041 | return false; |
| 2042 | 2042 | if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */ |
| r14260 | r14261 | |
| 2048 | 2048 | return true; |
| 2049 | 2049 | |
| 2050 | 2050 | /* |
| 2051 | * Read the frame CRC-16 from the footer and check | |
| 2052 | */ | |
| 2051 | * Read the frame CRC-16 from the footer and check | |
| 2052 | */ | |
| 2053 | 2053 | frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input); |
| 2054 | 2054 | if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN)) |
| 2055 | 2055 | return false; /* read_callback_ sets the state for us */ |
| r14260 | r14261 | |
| 2151 | 2151 | is_unparseable = true; |
| 2152 | 2152 | |
| 2153 | 2153 | /* |
| 2154 | * Note that along the way as we read the header, we look for a sync | |
| 2155 | * code inside. If we find one it would indicate that our original | |
| 2156 | * sync was bad since there cannot be a sync code in a valid header. | |
| 2157 | * | |
| 2158 | * Three kinds of things can go wrong when reading the frame header: | |
| 2159 | * 1) We may have sync'ed incorrectly and not landed on a frame header. | |
| 2160 | * If we don't find a sync code, it can end up looking like we read | |
| 2161 | * a valid but unparseable header, until getting to the frame header | |
| 2162 | * CRC. Even then we could get a false positive on the CRC. | |
| 2163 | * 2) We may have sync'ed correctly but on an unparseable frame (from a | |
| 2164 | * future encoder). | |
| 2165 | * 3) We may be on a damaged frame which appears valid but unparseable. | |
| 2166 | * | |
| 2167 | * For all these reasons, we try and read a complete frame header as | |
| 2168 | * long as it seems valid, even if unparseable, up until the frame | |
| 2169 | * header CRC. | |
| 2170 | */ | |
| 2154 | * Note that along the way as we read the header, we look for a sync | |
| 2155 | * code inside. If we find one it would indicate that our original | |
| 2156 | * sync was bad since there cannot be a sync code in a valid header. | |
| 2157 | * | |
| 2158 | * Three kinds of things can go wrong when reading the frame header: | |
| 2159 | * 1) We may have sync'ed incorrectly and not landed on a frame header. | |
| 2160 | * If we don't find a sync code, it can end up looking like we read | |
| 2161 | * a valid but unparseable header, until getting to the frame header | |
| 2162 | * CRC. Even then we could get a false positive on the CRC. | |
| 2163 | * 2) We may have sync'ed correctly but on an unparseable frame (from a | |
| 2164 | * future encoder). | |
| 2165 | * 3) We may be on a damaged frame which appears valid but unparseable. | |
| 2166 | * | |
| 2167 | * For all these reasons, we try and read a complete frame header as | |
| 2168 | * long as it seems valid, even if unparseable, up until the frame | |
| 2169 | * header CRC. | |
| 2170 | */ | |
| 2171 | 2171 | |
| 2172 | 2172 | /* |
| 2173 | * read in the raw header as bytes so we can CRC it, and parse it on the way | |
| 2174 | */ | |
| 2173 | * read in the raw header as bytes so we can CRC it, and parse it on the way | |
| 2174 | */ | |
| 2175 | 2175 | for(i = 0; i < 2; i++) { |
| 2176 | 2176 | if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) |
| 2177 | 2177 | return false; /* read_callback_ sets the state for us */ |
| r14260 | r14261 | |
| 2462 | 2462 | decoder->private_->frame.subframes[channel].wasted_bits = 0; |
| 2463 | 2463 | |
| 2464 | 2464 | /* |
| 2465 | * Lots of magic numbers here | |
| 2466 | */ | |
| 2465 | * Lots of magic numbers here | |
| 2466 | */ | |
| 2467 | 2467 | if(x & 0x80) { |
| 2468 | 2468 | send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC); |
| 2469 | 2469 | decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC; |
| r14260 | r14261 | |
| 2663 | 2663 | if(do_full_decode) { |
| 2664 | 2664 | memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order); |
| 2665 | 2665 | /*@@@@@@ technically not pessimistic enough, should be more like |
| 2666 | if( (FLAC__uint64)order * ((((FLAC__uint64)1)<<bps)-1) * ((1<<subframe->qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) ) | |
| 2667 | */ | |
| 2666 | if( (FLAC__uint64)order * ((((FLAC__uint64)1)<<bps)-1) * ((1<<subframe->qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) ) | |
| 2667 | */ | |
| 2668 | 2668 | if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32) |
| 2669 | 2669 | if(bps <= 16 && subframe->qlp_coeff_precision <= 16) { |
| 2670 | 2670 | if(order <= 8) |
| r14260 | r14261 | |
| 2793 | 2793 | } |
| 2794 | 2794 | else if(*bytes > 0) { |
| 2795 | 2795 | /* While seeking, it is possible for our seek to land in the |
| 2796 | * middle of audio data that looks exactly like a frame header | |
| 2797 | * from a future version of an encoder. When that happens, our | |
| 2798 | * error callback will get an | |
| 2799 | * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its | |
| 2800 | * unparseable_frame_count. But there is a remote possibility | |
| 2801 | * that it is properly synced at such a "future-codec frame", | |
| 2802 | * so to make sure, we wait to see many "unparseable" errors in | |
| 2803 | * a row before bailing out. | |
| 2804 | */ | |
| 2796 | * middle of audio data that looks exactly like a frame header | |
| 2797 | * from a future version of an encoder. When that happens, our | |
| 2798 | * error callback will get an | |
| 2799 | * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its | |
| 2800 | * unparseable_frame_count. But there is a remote possibility | |
| 2801 | * that it is properly synced at such a "future-codec frame", | |
| 2802 | * so to make sure, we wait to see many "unparseable" errors in | |
| 2803 | * a row before bailing out. | |
| 2804 | */ | |
| 2805 | 2805 | if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) { |
| 2806 | 2806 | decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED; |
| 2807 | 2807 | return false; |
| r14260 | r14261 | |
| 2845 | 2845 | return false; |
| 2846 | 2846 | } |
| 2847 | 2847 | /* [1] @@@ HACK NOTE: The end-of-stream checking has to be hacked around |
| 2848 | * for Ogg FLAC. This is because the ogg decoder aspect can lose sync | |
| 2849 | * and at the same time hit the end of the stream (for example, seeking | |
| 2850 | * to a point that is after the beginning of the last Ogg page). There | |
| 2851 | * is no way to report an Ogg sync loss through the callbacks (see note | |
| 2852 | * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0. | |
| 2853 | * So to keep the decoder from stopping at this point we gate the call | |
| 2854 | * to the eof_callback and let the Ogg decoder aspect set the | |
| 2855 | * end-of-stream state when it is needed. | |
| 2856 | */ | |
| 2848 | * for Ogg FLAC. This is because the ogg decoder aspect can lose sync | |
| 2849 | * and at the same time hit the end of the stream (for example, seeking | |
| 2850 | * to a point that is after the beginning of the last Ogg page). There | |
| 2851 | * is no way to report an Ogg sync loss through the callbacks (see note | |
| 2852 | * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0. | |
| 2853 | * So to keep the decoder from stopping at this point we gate the call | |
| 2854 | * to the eof_callback and let the Ogg decoder aspect set the | |
| 2855 | * end-of-stream state when it is needed. | |
| 2856 | */ | |
| 2857 | 2857 | } |
| 2858 | 2858 | |
| 2859 | 2859 | #if FLAC__HAS_OGG |
| r14260 | r14261 | |
| 2863 | 2863 | case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK: |
| 2864 | 2864 | return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; |
| 2865 | 2865 | /* we don't really have a way to handle lost sync via read |
| 2866 | * callback so we'll let it pass and let the underlying | |
| 2867 | * FLAC decoder catch the error | |
| 2868 | */ | |
| 2866 | * callback so we'll let it pass and let the underlying | |
| 2867 | * FLAC decoder catch the error | |
| 2868 | */ | |
| 2869 | 2869 | case FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC: |
| 2870 | 2870 | return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; |
| 2871 | 2871 | case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM: |
| r14260 | r14261 | |
| 2941 | 2941 | } |
| 2942 | 2942 | else { |
| 2943 | 2943 | /* |
| 2944 | * If we never got STREAMINFO, turn off MD5 checking to save | |
| 2945 | * cycles since we don't have a sum to compare to anyway | |
| 2946 | */ | |
| 2944 | * If we never got STREAMINFO, turn off MD5 checking to save | |
| 2945 | * cycles since we don't have a sum to compare to anyway | |
| 2946 | */ | |
| 2947 | 2947 | if(!decoder->private_->has_stream_info) |
| 2948 | 2948 | decoder->private_->do_md5_checking = false; |
| 2949 | 2949 | if(decoder->private_->do_md5_checking) { |
| r14260 | r14261 | |
| 2989 | 2989 | if(max_framesize > 0) |
| 2990 | 2990 | approx_bytes_per_frame = (max_framesize + min_framesize) / 2 + 1; |
| 2991 | 2991 | /* |
| 2992 | * Check if it's a known fixed-blocksize stream. Note that though | |
| 2993 | * the spec doesn't allow zeroes in the STREAMINFO block, we may | |
| 2994 | * never get a STREAMINFO block when decoding so the value of | |
| 2995 | * min_blocksize might be zero. | |
| 2996 | */ | |
| 2992 | * Check if it's a known fixed-blocksize stream. Note that though | |
| 2993 | * the spec doesn't allow zeroes in the STREAMINFO block, we may | |
| 2994 | * never get a STREAMINFO block when decoding so the value of | |
| 2995 | * min_blocksize might be zero. | |
| 2996 | */ | |
| 2997 | 2997 | else if(min_blocksize == max_blocksize && min_blocksize > 0) { |
| 2998 | 2998 | /* note there are no () around 'bps/8' to keep precision up since it's an integer calulation */ |
| 2999 | 2999 | approx_bytes_per_frame = min_blocksize * channels * bps/8 + 64; |
| r14260 | r14261 | |
| 3002 | 3002 | approx_bytes_per_frame = 4096 * channels * bps/8 + 64; |
| 3003 | 3003 | |
| 3004 | 3004 | /* |
| 3005 | * First, we set an upper and lower bound on where in the | |
| 3006 | * stream we will search. For now we assume the worst case | |
| 3007 | * scenario, which is our best guess at the beginning of | |
| 3008 | * the first frame and end of the stream. | |
| 3009 | */ | |
| 3005 | * First, we set an upper and lower bound on where in the | |
| 3006 | * stream we will search. For now we assume the worst case | |
| 3007 | * scenario, which is our best guess at the beginning of | |
| 3008 | * the first frame and end of the stream. | |
| 3009 | */ | |
| 3010 | 3010 | lower_bound = first_frame_offset; |
| 3011 | 3011 | lower_bound_sample = 0; |
| 3012 | 3012 | upper_bound = stream_length; |
| 3013 | 3013 | upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/; |
| 3014 | 3014 | |
| 3015 | 3015 | /* |
| 3016 | * Now we refine the bounds if we have a seektable with | |
| 3017 | * suitable points. Note that according to the spec they | |
| 3018 | * must be ordered by ascending sample number. | |
| 3019 | * | |
| 3020 | * Note: to protect against invalid seek tables we will ignore points | |
| 3021 | * that have frame_samples==0 or sample_number>=total_samples | |
| 3022 | */ | |
| 3016 | * Now we refine the bounds if we have a seektable with | |
| 3017 | * suitable points. Note that according to the spec they | |
| 3018 | * must be ordered by ascending sample number. | |
| 3019 | * | |
| 3020 | * Note: to protect against invalid seek tables we will ignore points | |
| 3021 | * that have frame_samples==0 or sample_number>=total_samples | |
| 3022 | */ | |
| 3023 | 3023 | if(seek_table) { |
| 3024 | 3024 | FLAC__uint64 new_lower_bound = lower_bound; |
| 3025 | 3025 | FLAC__uint64 new_upper_bound = upper_bound; |
| r14260 | r14261 | |
| 3066 | 3066 | |
| 3067 | 3067 | FLAC__ASSERT(upper_bound_sample >= lower_bound_sample); |
| 3068 | 3068 | /* there are 2 insidious ways that the following equality occurs, which |
| 3069 | * we need to fix: | |
| 3070 | * 1) total_samples is 0 (unknown) and target_sample is 0 | |
| 3071 | * 2) total_samples is 0 (unknown) and target_sample happens to be | |
| 3072 | * exactly equal to the last seek point in the seek table; this | |
| 3073 | * means there is no seek point above it, and upper_bound_samples | |
| 3074 | * remains equal to the estimate (of target_samples) we made above | |
| 3075 | * in either case it does not hurt to move upper_bound_sample up by 1 | |
| 3076 | */ | |
| 3069 | * we need to fix: | |
| 3070 | * 1) total_samples is 0 (unknown) and target_sample is 0 | |
| 3071 | * 2) total_samples is 0 (unknown) and target_sample happens to be | |
| 3072 | * exactly equal to the last seek point in the seek table; this | |
| 3073 | * means there is no seek point above it, and upper_bound_samples | |
| 3074 | * remains equal to the estimate (of target_samples) we made above | |
| 3075 | * in either case it does not hurt to move upper_bound_sample up by 1 | |
| 3076 | */ | |
| 3077 | 3077 | if(upper_bound_sample == lower_bound_sample) |
| 3078 | 3078 | upper_bound_sample++; |
| 3079 | 3079 | |
| r14260 | r14261 | |
| 3111 | 3111 | return false; |
| 3112 | 3112 | } |
| 3113 | 3113 | /* Now we need to get a frame. First we need to reset our |
| 3114 | * unparseable_frame_count; if we get too many unparseable | |
| 3115 | * frames in a row, the read callback will return | |
| 3116 | * FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing | |
| 3117 | * FLAC__stream_decoder_process_single() to return false. | |
| 3118 | */ | |
| 3114 | * unparseable_frame_count; if we get too many unparseable | |
| 3115 | * frames in a row, the read callback will return | |
| 3116 | * FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing | |
| 3117 | * FLAC__stream_decoder_process_single() to return false. | |
| 3118 | */ | |
| 3119 | 3119 | decoder->private_->unparseable_frame_count = 0; |
| 3120 | 3120 | if(!FLAC__stream_decoder_process_single(decoder)) { |
| 3121 | 3121 | decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; |
| r14260 | r14261 | |
| 3142 | 3142 | } |
| 3143 | 3143 | /* our last move backwards wasn't big enough, try again */ |
| 3144 | 3144 | approx_bytes_per_frame = approx_bytes_per_frame? approx_bytes_per_frame * 2 : 16; |
| 3145 | continue; | |
| 3145 | continue; | |
| 3146 | 3146 | } |
| 3147 | 3147 | /* allow one seek over upper bound, so we can get a correct upper_bound_sample for streams with unknown total_samples */ |
| 3148 | 3148 | first_seek = false; |
| 3149 | ||
| 3149 | ||
| 3150 | 3150 | /* make sure we are not seeking in corrupted stream */ |
| 3151 | 3151 | if (this_frame_sample < lower_bound_sample) { |
| 3152 | 3152 | decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; |
| r14260 | r14261 | |
| 3186 | 3186 | FLAC__bool did_a_seek; |
| 3187 | 3187 | unsigned iteration = 0; |
| 3188 | 3188 | |
| 3189 | /* In the first iterations, we will calculate the target byte position | |
| 3190 | * by the distance from the target sample to left_sample and | |
| 3191 | * right_sample (let's call it "proportional search"). After that, we | |
| 3192 | * will switch to binary search. | |
| 3193 | */ | |
| 3189 | /* In the first iterations, we will calculate the target byte position | |
| 3190 | * by the distance from the target sample to left_sample and | |
| 3191 | * right_sample (let's call it "proportional search"). After that, we | |
| 3192 | * will switch to binary search. | |
| 3193 | */ | |
| 3194 | 3194 | unsigned BINARY_SEARCH_AFTER_ITERATION = 2; |
| 3195 | 3195 | |
| 3196 | 3196 | /* We will switch to a linear search once our current sample is less |
| 3197 | * than this number of samples ahead of the target sample | |
| 3198 | */ | |
| 3197 | * than this number of samples ahead of the target sample | |
| 3198 | */ | |
| 3199 | 3199 | static const FLAC__uint64 LINEAR_SEARCH_WITHIN_SAMPLES = FLAC__MAX_BLOCK_SIZE * 2; |
| 3200 | 3200 | |
| 3201 | 3201 | /* If the total number of samples is unknown, use a large value, and |
| 3202 | * force binary search immediately. | |
| 3203 | */ | |
| 3202 | * force binary search immediately. | |
| 3203 | */ | |
| 3204 | 3204 | if(right_sample == 0) { |
| 3205 | 3205 | right_sample = (FLAC__uint64)(-1); |
| 3206 | 3206 | BINARY_SEARCH_AFTER_ITERATION = 0; |
| r14260 | r14261 | |
| 3228 | 3228 | pos = (FLAC__int64)((((target_sample-left_sample)>>8) * ((right_pos-left_pos)>>8)) / ((right_sample-left_sample)>>16)); |
| 3229 | 3229 | #endif |
| 3230 | 3230 | /* @@@ TODO: might want to limit pos to some distance |
| 3231 | * before EOF, to make sure we land before the last frame, | |
| 3232 | * thereby getting a this_frame_sample and so having a better | |
| 3233 | * estimate. | |
| 3234 | */ | |
| 3231 | * before EOF, to make sure we land before the last frame, | |
| 3232 | * thereby getting a this_frame_sample and so having a better | |
| 3233 | * estimate. | |
| 3234 | */ | |
| 3235 | 3235 | } |
| 3236 | 3236 | |
| 3237 | 3237 | /* physical seek */ |
| r14260 | r14261 | |
| 3256 | 3256 | if(!decoder->private_->got_a_frame) { |
| 3257 | 3257 | if(did_a_seek) { |
| 3258 | 3258 | /* this can happen if we seek to a point after the last frame; we drop |
| 3259 | * to binary search right away in this case to avoid any wasted | |
| 3260 | * iterations of proportional search. | |
| 3261 | */ | |
| 3259 | * to binary search right away in this case to avoid any wasted | |
| 3260 | * iterations of proportional search. | |
| 3261 | */ | |
| 3262 | 3262 | right_pos = pos; |
| 3263 | 3263 | BINARY_SEARCH_AFTER_ITERATION = 0; |
| 3264 | 3264 | } |
| 3265 | 3265 | else { |
| 3266 | 3266 | /* this can probably only happen if total_samples is unknown and the |
| 3267 | * target_sample is past the end of the stream | |
| 3268 | */ | |
| 3267 | * target_sample is past the end of the stream | |
| 3268 | */ | |
| 3269 | 3269 | decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; |
| 3270 | 3270 | return false; |
| 3271 | 3271 | } |
| r14260 | r14261 | |
| 3281 | 3281 | if (did_a_seek) { |
| 3282 | 3282 | if (this_frame_sample <= target_sample) { |
| 3283 | 3283 | /* The 'equal' case should not happen, since |
| 3284 | * FLAC__stream_decoder_process_single() | |
| 3285 | * should recognize that it has hit the | |
| 3286 | * target sample and we would exit through | |
| 3287 | * the 'break' above. | |
| 3288 | */ | |
| 3284 | * FLAC__stream_decoder_process_single() | |
| 3285 | * should recognize that it has hit the | |
| 3286 | * target sample and we would exit through | |
| 3287 | * the 'break' above. | |
| 3288 | */ | |
| 3289 | 3289 | FLAC__ASSERT(this_frame_sample != target_sample); |
| 3290 | 3290 | |
| 3291 | 3291 | left_sample = this_frame_sample; |
| r14260 | r14261 | |
|---|---|---|
| 143 | 143 | { |
| 144 | 144 | register FLAC__uint32 x; |
| 145 | 145 | do { |
| 146 | x = *buf; | |
| 146 | x = *buf; | |
| 147 | 147 | x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); |
| 148 | 148 | *buf++ = (x >> 16) | (x << 16); |
| 149 | 149 | } while (--words); |
| r14260 | r14261 | |
|---|---|---|
| 211 | 211 | #endif |
| 212 | 212 | |
| 213 | 213 | /* |
| 214 | * now have to check for OS support of SSE/SSE2 | |
| 215 | */ | |
| 214 | * now have to check for OS support of SSE/SSE2 | |
| 215 | */ | |
| 216 | 216 | if(info->data.ia32.fxsr || info->data.ia32.sse || info->data.ia32.sse2) { |
| 217 | 217 | #if defined FLAC__NO_SSE_OS |
| 218 | 218 | /* assume user knows better than us; turn it off */ |
| r14260 | r14261 | |
|---|---|---|
| 88 | 88 | * parameter estimation in this encoder is very good, almost always |
| 89 | 89 | * yielding compression within 0.1% of the optimal parameters. |
| 90 | 90 | */ |
| 91 | #undef ENABLE_RICE_PARAMETER_SEARCH | |
| 91 | #undef ENABLE_RICE_PARAMETER_SEARCH | |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | typedef struct { |
| r14260 | r14261 | |
| 224 | 224 | #endif |
| 225 | 225 | |
| 226 | 226 | static unsigned evaluate_verbatim_subframe_( |
| 227 | FLAC__StreamEncoder *encoder, | |
| 227 | FLAC__StreamEncoder *encoder, | |
| 228 | 228 | const FLAC__int32 signal[], |
| 229 | 229 | unsigned blocksize, |
| 230 | 230 | unsigned subframe_bps, |
| r14260 | r14261 | |
| 406 | 406 | FLAC__uint64 *abs_residual_partition_sums_unaligned; |
| 407 | 407 | unsigned *raw_bits_per_partition_unaligned; |
| 408 | 408 | /* |
| 409 | * These fields have been moved here from private function local | |
| 410 | * declarations merely to save stack space during encoding. | |
| 411 | */ | |
| 409 | * These fields have been moved here from private function local | |
| 410 | * declarations merely to save stack space during encoding. | |
| 411 | */ | |
| 412 | 412 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| 413 | 413 | FLAC__real lp_coeff[FLAC__MAX_LPC_ORDER][FLAC__MAX_LPC_ORDER]; /* from process_subframe_() */ |
| 414 | 414 | #endif |
| 415 | 415 | FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_extra[2]; /* from find_best_partition_order_() */ |
| 416 | 416 | /* |
| 417 | * The data for the verify section | |
| 418 | */ | |
| 417 | * The data for the verify section | |
| 418 | */ | |
| 419 | 419 | struct { |
| 420 | 420 | FLAC__StreamDecoder *decoder; |
| 421 | 421 | EncoderStateHint state_hint; |
| r14260 | r14261 | |
| 825 | 825 | metadata_picture_has_type1 = true; |
| 826 | 826 | /* standard icon must be 32x32 pixel PNG */ |
| 827 | 827 | if( |
| 828 | m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD && | |
| 828 | m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD && | |
| 829 | 829 | ( |
| 830 | 830 | (strcmp(m->data.picture.mime_type, "image/png") && strcmp(m->data.picture.mime_type, "-->")) || |
| 831 | 831 | m->data.picture.width != 32 || |
| r14260 | r14261 | |
| 894 | 894 | encoder->private_->use_wide_by_partition = (false); /*@@@ need to set this */ |
| 895 | 895 | |
| 896 | 896 | /* |
| 897 | * get the CPU info and set the function pointers | |
| 898 | */ | |
| 897 | * get the CPU info and set the function pointers | |
| 898 | */ | |
| 899 | 899 | FLAC__cpu_info(&encoder->private_->cpuinfo); |
| 900 | 900 | /* first default to the non-asm routines */ |
| 901 | 901 | #ifndef FLAC__INTEGER_ONLY_LIBRARY |
| r14260 | r14261 | |
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /* |
| 980 | * Set up the verify stuff if necessary | |
| 981 | */ | |
| 980 | * Set up the verify stuff if necessary | |
| 981 | */ | |
| 982 | 982 | if(encoder->protected_->verify) { |
| 983 | 983 | /* |
| 984 | * First, set up the fifo which will hold the | |
| 985 | * original signal to compare against | |
| 986 | */ | |
| 984 | * First, set up the fifo which will hold the | |
| 985 | * original signal to compare against | |
| 986 | */ | |
| 987 | 987 | encoder->private_->verify.input_fifo.size = encoder->protected_->blocksize+OVERREAD_; |
| 988 | 988 | for(i = 0; i < encoder->protected_->channels; i++) { |
| 989 | 989 | if(0 == (encoder->private_->verify.input_fifo.data[i] = (FLAC__int32*)safe_malloc_mul_2op_(sizeof(FLAC__int32), /*times*/encoder->private_->verify.input_fifo.size))) { |
| r14260 | r14261 | |
| 994 | 994 | encoder->private_->verify.input_fifo.tail = 0; |
| 995 | 995 | |
| 996 | 996 | /* |
| 997 | * Now set up a stream decoder for verification | |
| 998 | */ | |
| 997 | * Now set up a stream decoder for verification | |
| 998 | */ | |
| 999 | 999 | encoder->private_->verify.decoder = FLAC__stream_decoder_new(); |
| 1000 | 1000 | if(0 == encoder->private_->verify.decoder) { |
| 1001 | 1001 | encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR; |
| r14260 | r14261 | |
| 1015 | 1015 | encoder->private_->verify.error_stats.got = 0; |
| 1016 | 1016 | |
| 1017 | 1017 | /* |
| 1018 | * These must be done before we write any metadata, because that | |
| 1019 | * calls the write_callback, which uses these values. | |
| 1020 | */ | |
| 1018 | * These must be done before we write any metadata, because that | |
| 1019 | * calls the write_callback, which uses these values. | |
| 1020 | */ | |
| 1021 | 1021 | encoder->private_->first_seekpoint_to_check = 0; |
| 1022 | 1022 | encoder->private_->samples_written = 0; |
| 1023 | 1023 | encoder->protected_->streaminfo_offset = 0; |
| r14260 | r14261 | |
| 1025 | 1025 | encoder->protected_->audio_offset = 0; |
| 1026 | 1026 | |
| 1027 | 1027 | /* |
| 1028 | * write the stream header | |
| 1029 | */ | |
| 1028 | * write the stream header | |
| 1029 | */ | |
| 1030 | 1030 | if(encoder->protected_->verify) |
| 1031 | 1031 | encoder->private_->verify.state_hint = ENCODER_IN_MAGIC; |
| 1032 | 1032 | if(!FLAC__bitwriter_write_raw_uint32(encoder->private_->frame, FLAC__STREAM_SYNC, FLAC__STREAM_SYNC_LEN)) { |
| r14260 | r14261 | |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | /* |
| 1042 | * write the STREAMINFO metadata block | |
| 1043 | */ | |
| 1042 | * write the STREAMINFO metadata block | |
| 1043 | */ | |
| 1044 | 1044 | if(encoder->protected_->verify) |
| 1045 | 1045 | encoder->private_->verify.state_hint = ENCODER_IN_METADATA; |
| 1046 | 1046 | encoder->private_->streaminfo.type = FLAC__METADATA_TYPE_STREAMINFO; |
| r14260 | r14261 | |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | /* |
| 1070 | * Now that the STREAMINFO block is written, we can init this to an | |
| 1071 | * absurdly-high value... | |
| 1072 | */ | |
| 1070 | * Now that the STREAMINFO block is written, we can init this to an | |
| 1071 | * absurdly-high value... | |
| 1072 | */ | |
| 1073 | 1073 | encoder->private_->streaminfo.data.stream_info.min_framesize = (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN) - 1; |
| 1074 | 1074 | /* ... and clear this to 0 */ |
| 1075 | 1075 | encoder->private_->streaminfo.data.stream_info.total_samples = 0; |
| 1076 | 1076 | |
| 1077 | 1077 | /* |
| 1078 | * Check to see if the supplied metadata contains a VORBIS_COMMENT; | |
| 1079 | * if not, we will write an empty one (FLAC__add_metadata_block() | |
| 1080 | * automatically supplies the vendor string). | |
| 1081 | * | |
| 1082 | * WATCHOUT: the Ogg FLAC mapping requires us to write this block after | |
| 1083 | * the STREAMINFO. (In the case that metadata_has_vorbis_comment is | |
| 1084 | * true it will have already insured that the metadata list is properly | |
| 1085 | * ordered.) | |
| 1086 | */ | |
| 1078 | * Check to see if the supplied metadata contains a VORBIS_COMMENT; | |
| 1079 | * if not, we will write an empty one (FLAC__add_metadata_block() | |
| 1080 | * automatically supplies the vendor string). | |
| 1081 | * | |
| 1082 | * WATCHOUT: the Ogg FLAC mapping requires us to write this block after | |
| 1083 | * the STREAMINFO. (In the case that metadata_has_vorbis_comment is | |
| 1084 | * true it will have already insured that the metadata list is properly | |
| 1085 | * ordered.) | |
| 1086 | */ | |
| 1087 | 1087 | if(!metadata_has_vorbis_comment) { |
| 1088 | 1088 | FLAC__StreamMetadata vorbis_comment; |
| 1089 | 1089 | vorbis_comment.type = FLAC__METADATA_TYPE_VORBIS_COMMENT; |
| r14260 | r14261 | |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | /* |
| 1107 | * write the user's metadata blocks | |
| 1108 | */ | |
| 1107 | * write the user's metadata blocks | |
| 1108 | */ | |
| 1109 | 1109 | for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) { |
| 1110 | 1110 | encoder->protected_->metadata[i]->is_last = (i == encoder->protected_->num_metadata_blocks - 1); |
| 1111 | 1111 | if(!FLAC__add_metadata_block(encoder->protected_->metadata[i], encoder->private_->frame)) { |
| r14260 | r14261 | |
| 1172 | 1172 | /*is_ogg=*/true |
| 1173 | 1173 | ); |
| 1174 | 1174 | } |
| 1175 | ||
| 1175 | ||
| 1176 | 1176 | static FLAC__StreamEncoderInitStatus init_FILE_internal_( |
| 1177 | 1177 | FLAC__StreamEncoder *encoder, |
| 1178 | 1178 | FILE *file, |
| r14260 | r14261 | |
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | /* |
| 1199 | * To make sure that our file does not go unclosed after an error, we | |
| 1200 | * must assign the FILE pointer before any further error can occur in | |
| 1201 | * this routine. | |
| 1202 | */ | |
| 1199 | * To make sure that our file does not go unclosed after an error, we | |
| 1200 | * must assign the FILE pointer before any further error can occur in | |
| 1201 | * this routine. | |
| 1202 | */ | |
| 1203 | 1203 | if(file == stdout) |
| 1204 | 1204 | file = get_binary_stdout_(); /* just to be safe */ |
| 1205 | 1205 | |
| r14260 | r14261 | |
| 1234 | 1234 | |
| 1235 | 1235 | return init_status; |
| 1236 | 1236 | } |
| 1237 | ||
| 1237 | ||
| 1238 | 1238 | FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE( |
| 1239 | 1239 | FLAC__StreamEncoder *encoder, |
| 1240 | 1240 | FILE *file, |
| r14260 | r14261 | |
| 1244 | 1244 | { |
| 1245 | 1245 | return init_FILE_internal_(encoder, file, progress_callback, client_data, /*is_ogg=*/false); |
| 1246 | 1246 | } |
| 1247 | ||
| 1247 | ||
| 1248 | 1248 | FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE( |
| 1249 | 1249 | FLAC__StreamEncoder *encoder, |
| 1250 | 1250 | FILE *file, |
| r14260 | r14261 | |
| 1268 | 1268 | FLAC__ASSERT(0 != encoder); |
| 1269 | 1269 | |
| 1270 | 1270 | /* |
| 1271 | * To make sure that our file does not go unclosed after an error, we | |
| 1272 | * have to do the same entrance checks here that are later performed | |
| 1273 | * in FLAC__stream_encoder_init_FILE() before the FILE* is assigned. | |
| 1274 | */ | |
| 1271 | * To make sure that our file does not go unclosed after an error, we | |
| 1272 | * have to do the same entrance checks here that are later performed | |
| 1273 | * in FLAC__stream_encoder_init_FILE() before the FILE* is assigned. | |
| 1274 | */ | |
| 1275 | 1275 | if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED) |
| 1276 | 1276 | return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED; |
| 1277 | 1277 | |
| r14260 | r14261 | |
| 2033 | 2033 | |
| 2034 | 2034 | j = k = 0; |
| 2035 | 2035 | /* |
| 2036 | * we have several flavors of the same basic loop, optimized for | |
| 2037 | * different conditions: | |
| 2038 | */ | |
| 2036 | * we have several flavors of the same basic loop, optimized for | |
| 2037 | * different conditions: | |
| 2038 | */ | |
| 2039 | 2039 | if(encoder->protected_->do_mid_side_stereo && channels == 2) { |
| 2040 | 2040 | /* |
| 2041 | * stereo coding: unroll channel loop | |
| 2042 | */ | |
| 2041 | * stereo coding: unroll channel loop | |
| 2042 | */ | |
| 2043 | 2043 | do { |
| 2044 | 2044 | if(encoder->protected_->verify) |
| 2045 | 2045 | append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); |
| r14260 | r14261 | |
| 2073 | 2073 | } |
| 2074 | 2074 | else { |
| 2075 | 2075 | /* |
| 2076 | * independent channel coding: buffer each channel in inner loop | |
| 2077 | */ | |
| 2076 | * independent channel coding: buffer each channel in inner loop | |
| 2077 | */ | |
| 2078 | 2078 | do { |
| 2079 | 2079 | if(encoder->protected_->verify) |
| 2080 | 2080 | append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); |
| r14260 | r14261 | |
| 2259 | 2259 | ok = true; |
| 2260 | 2260 | |
| 2261 | 2261 | /* WATCHOUT: FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx() |
| 2262 | * requires that the input arrays (in our case the integer signals) | |
| 2263 | * have a buffer of up to 3 zeroes in front (at negative indices) for | |
| 2264 | * alignment purposes; we use 4 in front to keep the data well-aligned. | |
| 2265 | */ | |
| 2262 | * requires that the input arrays (in our case the integer signals) | |
| 2263 | * have a buffer of up to 3 zeroes in front (at negative indices) for | |
| 2264 | * alignment purposes; we use 4 in front to keep the data well-aligned. | |
| 2265 | */ | |
| 2266 | 2266 | |
| 2267 | 2267 | for(i = 0; ok && i < encoder->protected_->channels; i++) { |
| 2268 | 2268 | ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_unaligned[i], &encoder->private_->integer_signal[i]); |
| r14260 | r14261 | |
| 2436 | 2436 | } |
| 2437 | 2437 | |
| 2438 | 2438 | /* |
| 2439 | * Watch for the STREAMINFO block and first SEEKTABLE block to go by and store their offsets. | |
| 2440 | */ | |
| 2439 | * Watch for the STREAMINFO block and first SEEKTABLE block to go by and store their offsets. | |
| 2440 | */ | |
| 2441 | 2441 | if(samples == 0) { |
| 2442 | 2442 | FLAC__MetadataType type = (buffer[0] & 0x7f); |
| 2443 | 2443 | if(type == FLAC__METADATA_TYPE_STREAMINFO) |
| r14260 | r14261 | |
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | /* |
| 2450 | * Mark the current seek point if hit (if audio_offset == 0 that | |
| 2451 | * means we're still writing metadata and haven't hit the first | |
| 2452 | * frame yet) | |
| 2453 | */ | |
| 2450 | * Mark the current seek point if hit (if audio_offset == 0 that | |
| 2451 | * means we're still writing metadata and haven't hit the first | |
| 2452 | * frame yet) | |
| 2453 | */ | |
| 2454 | 2454 | if(0 != encoder->private_->seek_table && encoder->protected_->audio_offset > 0 && encoder->private_->seek_table->num_points > 0) { |
| 2455 | 2455 | const unsigned blocksize = FLAC__stream_encoder_get_blocksize(encoder); |
| 2456 | 2456 | const FLAC__uint64 frame_first_sample = encoder->private_->samples_written; |
| r14260 | r14261 | |
| 2468 | 2468 | encoder->private_->seek_table->points[i].frame_samples = blocksize; |
| 2469 | 2469 | encoder->private_->first_seekpoint_to_check++; |
| 2470 | 2470 | /* DO NOT: "break;" and here's why: |
| 2471 | * The seektable template may contain more than one target | |
| 2472 | * sample for any given frame; we will keep looping, generating | |
| 2473 | * duplicate seekpoints for them, and we'll clean it up later, | |
| 2474 | * just before writing the seektable back to the metadata. | |
| 2475 | */ | |
| 2471 | * The seektable template may contain more than one target | |
| 2472 | * sample for any given frame; we will keep looping, generating | |
| 2473 | * duplicate seekpoints for them, and we'll clean it up later, | |
| 2474 | * just before writing the seektable back to the metadata. | |
| 2475 | */ | |
| 2476 | 2476 | } |
| 2477 | 2477 | else { |
| 2478 | 2478 | encoder->private_->first_seekpoint_to_check++; |
| r14260 | r14261 | |
| 2502 | 2502 | encoder->private_->bytes_written += bytes; |
| 2503 | 2503 | encoder->private_->samples_written += samples; |
| 2504 | 2504 | /* we keep a high watermark on the number of frames written because |
| 2505 | * when the encoder goes back to write metadata, 'current_frame' | |
| 2506 | * will drop back to 0. | |
| 2507 | */ | |
| 2505 | * when the encoder goes back to write metadata, 'current_frame' | |
| 2506 | * will drop back to 0. | |
| 2507 | */ | |
| 2508 | 2508 | encoder->private_->frames_written = max(encoder->private_->frames_written, encoder->private_->current_frame_number+1); |
| 2509 | 2509 | } |
| 2510 | 2510 | else |
| r14260 | r14261 | |
| 2527 | 2527 | FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO); |
| 2528 | 2528 | |
| 2529 | 2529 | /* All this is based on intimate knowledge of the stream header |
| 2530 | * layout, but a change to the header format that would break this | |
| 2531 | * would also break all streams encoded in the previous format. | |
| 2532 | */ | |
| 2530 | * layout, but a change to the header format that would break this | |
| 2531 | * would also break all streams encoded in the previous format. | |
| 2532 | */ | |
| 2533 | 2533 | |
| 2534 | 2534 | /* |
| 2535 | * Write MD5 signature | |
| 2536 | */ | |
| 2535 | * Write MD5 signature | |
| 2536 | */ | |
| 2537 | 2537 | { |
| 2538 | 2538 | const unsigned md5_offset = |
| 2539 | 2539 | FLAC__STREAM_METADATA_HEADER_LENGTH + |
| r14260 | r14261 | |
| 2560 | 2560 | } |
| 2561 | 2561 | |
| 2562 | 2562 | /* |
| 2563 | * Write total samples | |
| 2564 | */ | |
| 2563 | * Write total samples | |
| 2564 | */ | |
| 2565 | 2565 | { |
| 2566 | 2566 | const unsigned total_samples_byte_offset = |
| 2567 | 2567 | FLAC__STREAM_METADATA_HEADER_LENGTH + |
| r14260 | r14261 | |
| 2593 | 2593 | } |
| 2594 | 2594 | |
| 2595 | 2595 | /* |
| 2596 | * Write min/max framesize | |
| 2597 | */ | |
| 2596 | * Write min/max framesize | |
| 2597 | */ | |
| 2598 | 2598 | { |
| 2599 | 2599 | const unsigned min_framesize_offset = |
| 2600 | 2600 | FLAC__STREAM_METADATA_HEADER_LENGTH + |
| r14260 | r14261 | |
| 2621 | 2621 | } |
| 2622 | 2622 | |
| 2623 | 2623 | /* |
| 2624 | * Write seektable | |
| 2625 | */ | |
| 2624 | * Write seektable | |
| 2625 | */ | |
| 2626 | 2626 | if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) { |
| 2627 | 2627 | unsigned i; |
| 2628 | 2628 | |
| r14260 | r14261 | |
| 2692 | 2692 | FLAC__ASSERT(0 != encoder->private_->seek_callback); |
| 2693 | 2693 | |
| 2694 | 2694 | /* Pre-check that client supports seeking, since we don't want the |
| 2695 | * ogg_helper code to ever have to deal with this condition. | |
| 2696 | */ | |
| 2695 | * ogg_helper code to ever have to deal with this condition. | |
| 2696 | */ | |
| 2697 | 2697 | if(encoder->private_->seek_callback(encoder, 0, encoder->private_->client_data) == FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED) |
| 2698 | 2698 | return; |
| 2699 | 2699 | |
| 2700 | 2700 | /* All this is based on intimate knowledge of the stream header |
| 2701 | * layout, but a change to the header format that would break this | |
| 2702 | * would also break all streams encoded in the previous format. | |
| 2703 | */ | |
| 2701 | * layout, but a change to the header format that would break this | |
| 2702 | * would also break all streams encoded in the previous format. | |
| 2703 | */ | |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
| 2706 | ** Write STREAMINFO stats | |
| 2707 | **/ | |
| 2706 | ** Write STREAMINFO stats | |
| 2707 | **/ | |
| 2708 | 2708 | simple_ogg_page__init(&page); |
| 2709 | 2709 | if(!simple_ogg_page__get_at(encoder, encoder->protected_->streaminfo_offset, &page, encoder->private_->seek_callback, encoder->private_->read_callback, encoder->private_->client_data)) { |
| 2710 | 2710 | simple_ogg_page__clear(&page); |
| r14260 | r14261 | |
| 2712 | 2712 | } |
| 2713 | 2713 | |
| 2714 | 2714 | /* |
| 2715 | * Write MD5 signature | |
| 2716 | */ | |
| 2715 | * Write MD5 signature | |
| 2716 | */ | |
| 2717 | 2717 | { |
| 2718 | 2718 | const unsigned md5_offset = |
| 2719 | 2719 | FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + |
| r14260 | r14261 | |
| 2738 | 2738 | } |
| 2739 | 2739 | |
| 2740 | 2740 | /* |
| 2741 | * Write total samples | |
| 2742 | */ | |
| 2741 | * Write total samples | |
| 2742 | */ | |
| 2743 | 2743 | { |
| 2744 | 2744 | const unsigned total_samples_byte_offset = |
| 2745 | 2745 | FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + |
| r14260 | r14261 | |
| 2770 | 2770 | } |
| 2771 | 2771 | |
| 2772 | 2772 | /* |
| 2773 | * Write min/max framesize | |
| 2774 | */ | |
| 2773 | * Write min/max framesize | |
| 2774 | */ | |
| 2775 | 2775 | { |
| 2776 | 2776 | const unsigned min_framesize_offset = |
| 2777 | 2777 | FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + |
| r14260 | r14261 | |
| 2801 | 2801 | simple_ogg_page__clear(&page); |
| 2802 | 2802 | |
| 2803 | 2803 | /* |
| 2804 | * Write seektable | |
| 2805 | */ | |
| 2804 | * Write seektable | |
| 2805 | */ | |
| 2806 | 2806 | if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) { |
| 2807 | 2807 | unsigned i; |
| 2808 | 2808 | FLAC__byte *p; |
| r14260 | r14261 | |
| 2865 | 2865 | FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK); |
| 2866 | 2866 | |
| 2867 | 2867 | /* |
| 2868 | * Accumulate raw signal to the MD5 signature | |
| 2869 | */ | |
| 2868 | * Accumulate raw signal to the MD5 signature | |
| 2869 | */ | |
| 2870 | 2870 | if(encoder->protected_->do_md5 && !FLAC__MD5Accumulate(&encoder->private_->md5context, (const FLAC__int32 * const *)encoder->private_->integer_signal, encoder->protected_->channels, encoder->protected_->blocksize, (encoder->protected_->bits_per_sample+7) / 8)) { |
| 2871 | 2871 | encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; |
| 2872 | 2872 | return false; |
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | 2875 | /* |
| 2876 | * Process the frame header and subframes into the frame bitbuffer | |
| 2877 | */ | |
| 2876 | * Process the frame header and subframes into the frame bitbuffer | |
| 2877 | */ | |
| 2878 | 2878 | if(!process_subframes_(encoder, is_fractional_block)) { |
| 2879 | 2879 | /* the above function sets the state for us in case of an error */ |
| 2880 | 2880 | return false; |
| 2881 | 2881 | } |
| 2882 | 2882 | |
| 2883 | 2883 | /* |
| 2884 | * Zero-pad the frame to a byte_boundary | |
| 2885 | */ | |
| 2884 | * Zero-pad the frame to a byte_boundary | |
| 2885 | */ | |
| 2886 | 2886 | if(!FLAC__bitwriter_zero_pad_to_byte_boundary(encoder->private_->frame)) { |
| 2887 | 2887 | encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR; |
| 2888 | 2888 | return false; |
| 2889 | 2889 | } |
| 2890 | 2890 | |
| 2891 | 2891 | /* |
| 2892 | * CRC-16 the whole thing | |
| 2893 | */ | |
| 2892 | * CRC-16 the whole thing | |
| 2893 | */ | |
| 2894 | 2894 | FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(encoder->private_->frame)); |
| 2895 | 2895 | if( |
| 2896 | 2896 | !FLAC__bitwriter_get_write_crc16(encoder->private_->frame, &crc) || |
| r14260 | r14261 | |
| 2901 | 2901 | } |
| 2902 | 2902 | |
| 2903 | 2903 | /* |
| 2904 | * Write it | |
| 2905 | */ | |
| 2904 | * Write it | |
| 2905 | */ | |
| 2906 | 2906 | if(!write_bitbuffer_(encoder, encoder->protected_->blocksize, is_last_block)) { |
| 2907 | 2907 | /* the above function sets the state for us in case of an error */ |
| 2908 | 2908 | return false; |
| 2909 | 2909 | } |
| 2910 | 2910 | |
| 2911 | 2911 | /* |
| 2912 | * Get ready for the next frame | |
| 2913 | */ | |
| 2912 | * Get ready for the next frame | |
| 2913 | */ | |
| 2914 | 2914 | encoder->private_->current_sample_number = 0; |
| 2915 | 2915 | encoder->private_->current_frame_number++; |
| 2916 | 2916 | encoder->private_->streaminfo.data.stream_info.total_samples += (FLAC__uint64)encoder->protected_->blocksize; |
| r14260 | r14261 | |
| 2925 | 2925 | FLAC__bool do_independent, do_mid_side; |
| 2926 | 2926 | |
| 2927 | 2927 | /* |
| 2928 | * Calculate the min,max Rice partition orders | |
| 2929 | */ | |
| 2928 | * Calculate the min,max Rice partition orders | |
| 2929 | */ | |
| 2930 | 2930 | if(is_fractional_block) { |
| 2931 | 2931 | max_partition_order = 0; |
| 2932 | 2932 | } |
| r14260 | r14261 | |
| 2937 | 2937 | min_partition_order = min(min_partition_order, max_partition_order); |
| 2938 | 2938 | |
| 2939 | 2939 | /* |
| 2940 | * Setup the frame | |
| 2941 | */ | |
| 2940 | * Setup the frame | |
| 2941 | */ | |
| 2942 | 2942 | frame_header.blocksize = encoder->protected_->blocksize; |
| 2943 | 2943 | frame_header.sample_rate = encoder->protected_->sample_rate; |
| 2944 | 2944 | frame_header.channels = encoder->protected_->channels; |
| r14260 | r14261 | |
| 2948 | 2948 | frame_header.number.frame_number = encoder->private_->current_frame_number; |
| 2949 | 2949 | |
| 2950 | 2950 | /* |
| 2951 | * Figure out what channel assignments to try | |
| 2952 | */ | |
| 2951 | * Figure out what channel assignments to try | |
| 2952 | */ | |
| 2953 | 2953 | if(encoder->protected_->do_mid_side_stereo) { |
| 2954 | 2954 | if(encoder->protected_->loose_mid_side_stereo) { |
| 2955 | 2955 | if(encoder->private_->loose_mid_side_stereo_frame_count == 0) { |
| r14260 | r14261 | |
| 2974 | 2974 | FLAC__ASSERT(do_independent || do_mid_side); |
| 2975 | 2975 | |
| 2976 | 2976 | /* |
| 2977 | * Check for wasted bits; set effective bps for each subframe | |
| 2978 | */ | |
| 2977 | * Check for wasted bits; set effective bps for each subframe | |
| 2978 | */ | |
| 2979 | 2979 | if(do_independent) { |
| 2980 | 2980 | for(channel = 0; channel < encoder->protected_->channels; channel++) { |
| 2981 | 2981 | const unsigned w = get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize); |
| r14260 | r14261 | |
| 2993 | 2993 | } |
| 2994 | 2994 | |
| 2995 | 2995 | /* |
| 2996 | * First do a normal encoding pass of each independent channel | |
| 2997 | */ | |
| 2996 | * First do a normal encoding pass of each independent channel | |
| 2997 | */ | |
| 2998 | 2998 | if(do_independent) { |
| 2999 | 2999 | for(channel = 0; channel < encoder->protected_->channels; channel++) { |
| 3000 | 3000 | if(! |
| r14260 | r14261 | |
| 3017 | 3017 | } |
| 3018 | 3018 | |
| 3019 | 3019 | /* |
| 3020 | * Now do mid and side channels if requested | |
| 3021 | */ | |
| 3020 | * Now do mid and side channels if requested | |
| 3021 | */ | |
| 3022 | 3022 | if(do_mid_side) { |
| 3023 | 3023 | FLAC__ASSERT(encoder->protected_->channels == 2); |
| 3024 | 3024 | |
| r14260 | r14261 | |
| 3043 | 3043 | } |
| 3044 | 3044 | |
| 3045 | 3045 | /* |
| 3046 | * Compose the frame bitbuffer | |
| 3047 | */ | |
| 3046 | * Compose the frame bitbuffer | |
| 3047 | */ | |
| 3048 | 3048 | if(do_mid_side) { |
| 3049 | 3049 | unsigned left_bps = 0, right_bps = 0; /* initialized only to prevent superfluous compiler warning */ |
| 3050 | 3050 | FLAC__Subframe *left_subframe = 0, *right_subframe = 0; /* initialized only to prevent superfluous compiler warning */ |
| r14260 | r14261 | |
| 3734 | 3734 | |
| 3735 | 3735 | { |
| 3736 | 3736 | /* |
| 3737 | * We are allowed to de-const the pointer based on our special | |
| 3738 | * knowledge; it is const to the outside world. | |
| 3739 | */ | |
| 3737 | * We are allowed to de-const the pointer based on our special | |
| 3738 | * knowledge; it is const to the outside world. | |
| 3739 | */ | |
| 3740 | 3740 | FLAC__EntropyCodingMethod_PartitionedRiceContents* prc = (FLAC__EntropyCodingMethod_PartitionedRiceContents*)best_ecm->data.partitioned_rice.contents; |
| 3741 | 3741 | unsigned partition; |
| 3742 | 3742 | |
| r14260 | r14261 | |
| 3746 | 3746 | if(do_escape_coding) |
| 3747 | 3747 | memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(unsigned)*(1<<(best_partition_order))); |
| 3748 | 3748 | /* |
| 3749 | * Now need to check if the type should be changed to | |
| 3750 | * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the | |
| 3751 | * size of the rice parameters. | |
| 3752 | */ | |
| 3749 | * Now need to check if the type should be changed to | |
| 3750 | * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the | |
| 3751 | * size of the rice parameters. | |
| 3752 | */ | |
| 3753 | 3753 | for(partition = 0; partition < (1u<<best_partition_order); partition++) { |
| 3754 | 3754 | if(prc->parameters[partition] >= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) { |
| 3755 | 3755 | best_ecm->type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2; |
| r14260 | r14261 | |
| 3932 | 3932 | ) |
| 3933 | 3933 | - (partition_samples >> 1) |
| 3934 | 3934 | /* -(partition_samples>>1) to subtract out extra contributions to the abs_residual_partition_sum. |
| 3935 | * The actual number of bits used is closer to the sum(for all i in the partition) of abs(residual[i])>>(rice_parameter-1) | |
| 3936 | * By using the abs_residual_partition sum, we also add in bits in the LSBs that would normally be shifted out. | |
| 3937 | * So the subtraction term tries to guess how many extra bits were contributed. | |
| 3938 | * If the LSBs are randomly distributed, this should average to 0.5 extra bits per sample. | |
| 3939 | */ | |
| 3935 | * The actual number of bits used is closer to the sum(for all i in the partition) of abs(residual[i])>>(rice_parameter-1) | |
| 3936 | * By using the abs_residual_partition sum, we also add in bits in the LSBs that would normally be shifted out. | |
| 3937 | * So the subtraction term tries to guess how many extra bits were contributed. | |
| 3938 | * If the LSBs are randomly distributed, this should average to 0.5 extra bits per sample. | |
| 3939 | */ | |
| 3940 | 3940 | ; |
| 3941 | 3941 | } |
| 3942 | 3942 | #endif |
| r14260 | r14261 | |
| 4038 | 4038 | } |
| 4039 | 4039 | mean = abs_residual_partition_sums[partition]; |
| 4040 | 4040 | /* we are basically calculating the size in bits of the |
| 4041 | * average residual magnitude in the partition: | |
| 4042 | * rice_parameter = floor(log2(mean/partition_samples)) | |
| 4043 | * 'mean' is not a good name for the variable, it is | |
| 4044 | * actually the sum of magnitudes of all residual values | |
| 4045 | * in the partition, so the actual mean is | |
| 4046 | * mean/partition_samples | |
| 4047 | */ | |
| 4041 | * average residual magnitude in the partition: | |
| 4042 | * rice_parameter = floor(log2(mean/partition_samples)) | |
| 4043 | * 'mean' is not a good name for the variable, it is | |
| 4044 | * actually the sum of magnitudes of all residual values | |
| 4045 | * in the partition, so the actual mean is | |
| 4046 | * mean/partition_samples | |
| 4047 | */ | |
| 4048 | 4048 | for(rice_parameter = 0, k = partition_samples; k < mean; rice_parameter++, k <<= 1) |
| 4049 | 4049 | ; |
| 4050 | 4050 | if(rice_parameter >= rice_parameter_limit) { |
| r14260 | r14261 | |
| 4174 | 4174 | else { |
| 4175 | 4175 | if(encoded_bytes == 0) { |
| 4176 | 4176 | /* |
| 4177 | * If we get here, a FIFO underflow has occurred, | |
| 4178 | * which means there is a bug somewhere. | |
| 4179 | */ | |
| 4177 | * If we get here, a FIFO underflow has occurred, | |
| 4178 | * which means there is a bug somewhere. | |
| 4179 | */ | |
| 4180 | 4180 | FLAC__ASSERT(0); |
| 4181 | 4181 | return FLAC__STREAM_DECODER_READ_STATUS_ABORT; |
| 4182 | 4182 | } |
| r14260 | r14261 | |
| 4306 | 4306 | FLAC__bool call_it = 0 != encoder->private_->progress_callback && ( |
| 4307 | 4307 | #if FLAC__HAS_OGG |
| 4308 | 4308 | /* We would like to be able to use 'samples > 0' in the |
| 4309 | * clause here but currently because of the nature of our | |
| 4310 | * Ogg writing implementation, 'samples' is always 0 (see | |
| 4311 | * ogg_encoder_aspect.c). The downside is extra progress | |
| 4312 | * callbacks. | |
| 4313 | */ | |
| 4309 | * clause here but currently because of the nature of our | |
| 4310 | * Ogg writing implementation, 'samples' is always 0 (see | |
| 4311 | * ogg_encoder_aspect.c). The downside is extra progress | |
| 4312 | * callbacks. | |
| 4313 | */ | |
| 4314 | 4314 | encoder->private_->is_ogg? true : |
| 4315 | 4315 | #endif |
| 4316 | 4316 | samples > 0 |
| 4317 | 4317 | ); |
| 4318 | 4318 | if(call_it) { |
| 4319 | 4319 | /* NOTE: We have to add +bytes, +samples, and +1 to the stats |
| 4320 | * because at this point in the callback chain, the stats | |
| 4321 | * have not been updated. Only after we return and control | |
| 4322 | * gets back to write_frame_() are the stats updated | |
| 4323 | */ | |
| 4320 | * because at this point in the callback chain, the stats | |
| 4321 | * have not been updated. Only after we return and control | |
| 4322 | * gets back to write_frame_() are the stats updated | |
| 4323 | */ | |
| 4324 | 4324 | encoder->private_->progress_callback(encoder, encoder->private_->bytes_written+bytes, encoder->private_->samples_written+samples, encoder->private_->frames_written+(samples?1:0), encoder->private_->total_frames_estimate, encoder->private_->client_data); |
| 4325 | 4325 | } |
| 4326 | 4326 | return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; |
| r14260 | r14261 | |
| 4336 | 4336 | { |
| 4337 | 4337 | #if 0 |
| 4338 | 4338 | /* if something breaks here it is probably due to the presence or |
| 4339 | * absence of an underscore before the identifiers 'setmode', | |
| 4340 | * 'fileno', and/or 'O_BINARY'; check your system header files. | |
| 4341 | */ | |
| 4339 | * absence of an underscore before the identifiers 'setmode', | |
| 4340 | * 'fileno', and/or 'O_BINARY'; check your system header files. | |
| 4341 | */ | |
| 4342 | 4342 | #if defined _MSC_VER || defined __MINGW32__ |
| 4343 | 4343 | _setmode(_fileno(stdout), _O_BINARY); |
| 4344 | 4344 | #elif defined __CYGWIN__ |
| r14260 | r14261 | |
|---|---|---|
| 59 | 59 | return false; |
| 60 | 60 | |
| 61 | 61 | /* |
| 62 | * First, for VORBIS_COMMENTs, adjust the length to reflect our vendor string | |
| 63 | */ | |
| 62 | * First, for VORBIS_COMMENTs, adjust the length to reflect our vendor string | |
| 63 | */ | |
| 64 | 64 | i = metadata->length; |
| 65 | 65 | if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { |
| 66 | 66 | FLAC__ASSERT(metadata->data.vorbis_comment.vendor_string.length == 0 || 0 != metadata->data.vorbis_comment.vendor_string.entry); |
| r14260 | r14261 | |
|---|---|---|
| 275 | 275 | case JDCT_ISLOW: |
| 276 | 276 | { |
| 277 | 277 | /* For LL&M IDCT method, multipliers are equal to raw quantization |
| 278 | * coefficients, but are stored as ints to ensure access efficiency. | |
| 279 | */ | |
| 278 | * coefficients, but are stored as ints to ensure access efficiency. | |
| 279 | */ | |
| 280 | 280 | ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; |
| 281 | 281 | for (i = 0; i < DCTSIZE2; i++) { |
| 282 | 282 | ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; |
| r14260 | r14261 | |
| 288 | 288 | case JDCT_IFAST: |
| 289 | 289 | { |
| 290 | 290 | /* For AA&N IDCT method, multipliers are equal to quantization |
| 291 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 292 | * scalefactor[0] = 1 | |
| 293 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 294 | * For integer operation, the multiplier table is to be scaled by | |
| 295 | * IFAST_SCALE_BITS. | |
| 296 | */ | |
| 291 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 292 | * scalefactor[0] = 1 | |
| 293 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 294 | * For integer operation, the multiplier table is to be scaled by | |
| 295 | * IFAST_SCALE_BITS. | |
| 296 | */ | |
| 297 | 297 | IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; |
| 298 | 298 | #define CONST_BITS 14 |
| 299 | 299 | static const INT16 aanscales[DCTSIZE2] = { |
| r14260 | r14261 | |
| 322 | 322 | case JDCT_FLOAT: |
| 323 | 323 | { |
| 324 | 324 | /* For float AA&N IDCT method, multipliers are equal to quantization |
| 325 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 326 | * scalefactor[0] = 1 | |
| 327 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 328 | * We apply a further scale factor of 1/8. | |
| 329 | */ | |
| 325 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 326 | * scalefactor[0] = 1 | |
| 327 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 328 | * We apply a further scale factor of 1/8. | |
| 329 | */ | |
| 330 | 330 | FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; |
| 331 | 331 | int row, col; |
| 332 | 332 | static const double aanscalefactor[DCTSIZE] = { |
| r14260 | r14261 | |
|---|---|---|
| 220 | 220 | /* |
| 221 | 221 | * Fill in the standard error-handling methods in a jpeg_error_mgr object. |
| 222 | 222 | * Typical call is: |
| 223 | * struct jpeg_compress_struct cinfo; | |
| 224 | * struct jpeg_error_mgr err; | |
| 223 | * struct jpeg_compress_struct cinfo; | |
| 224 | * struct jpeg_error_mgr err; | |
| 225 | 225 | * |
| 226 | * | |
| 226 | * cinfo.err = jpeg_std_error(&err); | |
| 227 | 227 | * after which the application may override some of the methods. |
| 228 | 228 | */ |
| 229 | 229 |
| r14260 | r14261 | |
|---|---|---|
| 186 | 186 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 187 | 187 | SIZEOF(c_derived_tbl)); |
| 188 | 188 | dtbl = *pdtbl; |
| 189 | ||
| 189 | ||
| 190 | 190 | /* Figure C.1: make table of Huffman code length for each symbol */ |
| 191 | 191 | |
| 192 | 192 | p = 0; |
| r14260 | r14261 | |
| 199 | 199 | } |
| 200 | 200 | huffsize[p] = 0; |
| 201 | 201 | lastp = p; |
| 202 | ||
| 202 | ||
| 203 | 203 | /* Figure C.2: generate the codes themselves */ |
| 204 | 204 | /* We also validate that the counts represent a legal Huffman code tree. */ |
| 205 | 205 | |
| r14260 | r14261 | |
| 219 | 219 | code <<= 1; |
| 220 | 220 | si++; |
| 221 | 221 | } |
| 222 | ||
| 222 | ||
| 223 | 223 | /* Figure C.3: generate encoding tables */ |
| 224 | 224 | /* These are code and size indexed by symbol value */ |
| 225 | 225 | |
| r14260 | r14261 | |
| 316 | 316 | ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); |
| 317 | 317 | |
| 318 | 318 | put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */ |
| 319 | ||
| 319 | ||
| 320 | 320 | put_bits += size; /* new number of bits in buffer */ |
| 321 | ||
| 321 | ||
| 322 | 322 | put_buffer <<= 24 - put_bits; /* align incoming bits */ |
| 323 | 323 | |
| 324 | 324 | put_buffer |= state->cur.put_buffer; /* and merge with old buffer contents */ |
| 325 | ||
| 325 | ||
| 326 | 326 | while (put_bits >= 8) { |
| 327 | 327 | int c = (int) ((put_buffer >> 16) & 0xFF); |
| 328 | ||
| 328 | ||
| 329 | 329 | emit_byte_s(state, c, return FALSE); |
| 330 | 330 | if (c == 0xFF) { /* need to stuff a zero byte? */ |
| 331 | 331 | emit_byte_s(state, 0, return FALSE); |
| r14260 | r14261 | |
| 358 | 358 | return; /* do nothing if we're only getting stats */ |
| 359 | 359 | |
| 360 | 360 | put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */ |
| 361 | ||
| 361 | ||
| 362 | 362 | put_bits += size; /* new number of bits in buffer */ |
| 363 | 363 | |
| 364 | 364 | put_buffer <<= 24 - put_bits; /* align incoming bits */ |
| r14260 | r14261 | |
| 580 | 580 | /* This code assumes we are on a two's complement machine */ |
| 581 | 581 | temp2--; |
| 582 | 582 | } |
| 583 | ||
| 583 | ||
| 584 | 584 | /* Find the number of bits needed for the magnitude of the coefficient */ |
| 585 | 585 | nbits = 0; |
| 586 | 586 | while (temp) { |
| r14260 | r14261 | |
| 592 | 592 | */ |
| 593 | 593 | if (nbits > MAX_COEF_BITS+1) |
| 594 | 594 | ERREXIT(cinfo, JERR_BAD_DCT_COEF); |
| 595 | ||
| 595 | ||
| 596 | 596 | /* Count/emit the Huffman-coded symbol for the number of bits */ |
| 597 | 597 | emit_dc_symbol(entropy, compptr->dc_tbl_no, nbits); |
| 598 | ||
| 598 | ||
| 599 | 599 | /* Emit that number of bits of the value, if positive, */ |
| 600 | 600 | /* or the complement of its magnitude, if negative. */ |
| 601 | 601 | if (nbits) /* emit_bits rejects calls with size 0 */ |
| r14260 | r14261 | |
| 651 | 651 | block = MCU_data[0]; |
| 652 | 652 | |
| 653 | 653 | /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ |
| 654 | ||
| 654 | ||
| 655 | 655 | r = 0; /* r = run length of zeros */ |
| 656 | ||
| 656 | ||
| 657 | 657 | for (k = cinfo->Ss; k <= Se; k++) { |
| 658 | 658 | if ((temp = (*block)[natural_order[k]]) == 0) { |
| 659 | 659 | r++; |
| r14260 | r14261 | |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ |
| 833 | ||
| 833 | ||
| 834 | 834 | r = 0; /* r = run length of zeros */ |
| 835 | 835 | BR = 0; /* BR = count of buffered bits added now */ |
| 836 | 836 | BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ |
| r14260 | r14261 | |
| 1127 | 1127 | register int k, r; |
| 1128 | 1128 | int Se = cinfo->lim_Se; |
| 1129 | 1129 | const int * natural_order = cinfo->natural_order; |
| 1130 | ||
| 1130 | ||
| 1131 | 1131 | /* Encode the DC coefficient difference per section F.1.2.1 */ |
| 1132 | ||
| 1132 | ||
| 1133 | 1133 | temp = block[0] - last_dc_val; |
| 1134 | 1134 | if (temp < 0) |
| 1135 | 1135 | temp = -temp; |
| 1136 | ||
| 1136 | ||
| 1137 | 1137 | /* Find the number of bits needed for the magnitude of the coefficient */ |
| 1138 | 1138 | nbits = 0; |
| 1139 | 1139 | while (temp) { |
| r14260 | r14261 | |
| 1148 | 1148 | |
| 1149 | 1149 | /* Count the Huffman symbol for the number of bits */ |
| 1150 | 1150 | dc_counts[nbits]++; |
| 1151 | ||
| 1151 | ||
| 1152 | 1152 | /* Encode the AC coefficients per section F.1.2.2 */ |
| 1153 | ||
| 1153 | ||
| 1154 | 1154 | r = 0; /* r = run length of zeros */ |
| 1155 | ||
| 1155 | ||
| 1156 | 1156 | for (k = 1; k <= Se; k++) { |
| 1157 | 1157 | if ((temp = block[natural_order[k]]) == 0) { |
| 1158 | 1158 | r++; |
| r14260 | r14261 | |
| 1162 | 1162 | ac_counts[0xF0]++; |
| 1163 | 1163 | r -= 16; |
| 1164 | 1164 | } |
| 1165 | ||
| 1165 | ||
| 1166 | 1166 | /* Find the number of bits needed for the magnitude of the coefficient */ |
| 1167 | 1167 | if (temp < 0) |
| 1168 | 1168 | temp = -temp; |
| 1169 | ||
| 1169 | ||
| 1170 | 1170 | /* Find the number of bits needed for the magnitude of the coefficient */ |
| 1171 | 1171 | nbits = 1; /* there must be at least one 1 bit */ |
| 1172 | 1172 | while ((temp >>= 1)) |
| r14260 | r14261 | |
| 1174 | 1174 | /* Check for out-of-range coefficient values */ |
| 1175 | 1175 | if (nbits > MAX_COEF_BITS) |
| 1176 | 1176 | ERREXIT(cinfo, JERR_BAD_DCT_COEF); |
| 1177 | ||
| 1177 | ||
| 1178 | 1178 | /* Count Huffman symbol for run length / number of bits */ |
| 1179 | 1179 | ac_counts[(r << 4) + nbits]++; |
| 1180 | ||
| 1180 | ||
| 1181 | 1181 | r = 0; |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
| r14260 | r14261 | |
| 1269 | 1269 | MEMZERO(codesize, SIZEOF(codesize)); |
| 1270 | 1270 | for (i = 0; i < 257; i++) |
| 1271 | 1271 | others[i] = -1; /* init links to empty */ |
| 1272 | ||
| 1272 | ||
| 1273 | 1273 | freq[256] = 1; /* make sure 256 has a nonzero count */ |
| 1274 | 1274 | /* Including the pseudo-symbol 256 in the Huffman procedure guarantees |
| 1275 | 1275 | * that no real symbol is given code-value of all ones, because 256 |
| r14260 | r14261 | |
| 1304 | 1304 | /* Done if we've merged everything into one frequency */ |
| 1305 | 1305 | if (c2 < 0) |
| 1306 | 1306 | break; |
| 1307 | ||
| 1307 | ||
| 1308 | 1308 | /* Else merge the two counts/trees */ |
| 1309 | 1309 | freq[c1] += freq[c2]; |
| 1310 | 1310 | freq[c2] = 0; |
| r14260 | r14261 | |
| 1315 | 1315 | c1 = others[c1]; |
| 1316 | 1316 | codesize[c1]++; |
| 1317 | 1317 | } |
| 1318 | ||
| 1318 | ||
| 1319 | 1319 | others[c1] = c2; /* chain c2 onto c1's tree branch */ |
| 1320 | ||
| 1320 | ||
| 1321 | 1321 | /* Increment the codesize of everything in c2's tree branch */ |
| 1322 | 1322 | codesize[c2]++; |
| 1323 | 1323 | while (others[c2] >= 0) { |
| r14260 | r14261 | |
| 1348 | 1348 | * shortest nonzero BITS entry is converted into a prefix for two code words |
| 1349 | 1349 | * one bit longer. |
| 1350 | 1350 | */ |
| 1351 | ||
| 1351 | ||
| 1352 | 1352 | for (i = MAX_CLEN; i > 16; i--) { |
| 1353 | 1353 | while (bits[i] > 0) { |
| 1354 | 1354 | j = i - 2; /* find length of new prefix to be used */ |
| 1355 | 1355 | while (bits[j] == 0) |
| 1356 | 1356 | j--; |
| 1357 | ||
| 1357 | ||
| 1358 | 1358 | bits[i] -= 2; /* remove two symbols */ |
| 1359 | 1359 | bits[i-1]++; /* one goes in this length */ |
| 1360 | 1360 | bits[j+1] += 2; /* two new symbols in this length */ |
| r14260 | r14261 | |
| 1366 | 1366 | while (bits[i] == 0) /* find largest codelength still in use */ |
| 1367 | 1367 | i--; |
| 1368 | 1368 | bits[i]--; |
| 1369 | ||
| 1369 | ||
| 1370 | 1370 | /* Return final symbol counts (only for lengths 0..16) */ |
| 1371 | 1371 | MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); |
| 1372 | ||
| 1372 | ||
| 1373 | 1373 | /* Return a list of the symbols sorted by code length */ |
| 1374 | 1374 | /* It's not real clear to me why we don't need to consider the codelength |
| 1375 | 1375 | * changes made above, but the JPEG spec seems to think this works. |
| r14260 | r14261 | |
|---|---|---|
| 120 | 120 | * before using GET_BITS, PEEK_BITS, or DROP_BITS. |
| 121 | 121 | * The variables get_buffer and bits_left are assumed to be locals, |
| 122 | 122 | * but the state struct might not be (jpeg_huff_decode needs this). |
| 123 | * CHECK_BIT_BUFFER(state,n,action); | |
| 124 | * Ensure there are N bits in get_buffer; if suspend, take action. | |
| 123 | * CHECK_BIT_BUFFER(state,n,action); | |
| 124 | * Ensure there are N bits in get_buffer; if suspend, take action. | |
| 125 | 125 | * val = GET_BITS(n); |
| 126 | * | |
| 126 | * Fetch next N bits. | |
| 127 | 127 | * val = PEEK_BITS(n); |
| 128 | * Fetch next N bits without removing them from the buffer. | |
| 129 | * DROP_BITS(n); | |
| 130 | * Discard next N bits. | |
| 128 | * Fetch next N bits without removing them from the buffer. | |
| 129 | * DROP_BITS(n); | |
| 130 | * Discard next N bits. | |
| 131 | 131 | * The value N should be a simple variable, not an expression, because it |
| 132 | 132 | * is evaluated multiple times. |
| 133 | 133 | */ |
| r14260 | r14261 | |
| 350 | 350 | SIZEOF(d_derived_tbl)); |
| 351 | 351 | dtbl = *pdtbl; |
| 352 | 352 | dtbl->pub = htbl; /* fill in back link */ |
| 353 | ||
| 353 | ||
| 354 | 354 | /* Figure C.1: make table of Huffman code length for each symbol */ |
| 355 | 355 | |
| 356 | 356 | p = 0; |
| r14260 | r14261 | |
| 363 | 363 | } |
| 364 | 364 | huffsize[p] = 0; |
| 365 | 365 | numsymbols = p; |
| 366 | ||
| 366 | ||
| 367 | 367 | /* Figure C.2: generate the codes themselves */ |
| 368 | 368 | /* We also validate that the counts represent a legal Huffman code tree. */ |
| 369 | ||
| 369 | ||
| 370 | 370 | code = 0; |
| 371 | 371 | si = huffsize[0]; |
| 372 | 372 | p = 0; |
| r14260 | r14261 | |
| 493 | 493 | /* If it's 0xFF, check and discard stuffed zero byte */ |
| 494 | 494 | if (c == 0xFF) { |
| 495 | 495 | /* Loop here to discard any padding FF's on terminating marker, |
| 496 | * so that we can save a valid unread_marker value. NOTE: we will | |
| 497 | * accept multiple FF's followed by a 0 as meaning a single FF data | |
| 498 | * byte. This data pattern is not valid according to the standard. | |
| 499 | */ | |
| 496 | * so that we can save a valid unread_marker value. NOTE: we will | |
| 497 | * accept multiple FF's followed by a 0 as meaning a single FF data | |
| 498 | * byte. This data pattern is not valid according to the standard. | |
| 499 | */ | |
| 500 | 500 | do { |
| 501 | 501 | if (bytes_in_buffer == 0) { |
| 502 | 502 | if (! (*cinfo->src->fill_input_buffer) (cinfo)) |
| r14260 | r14261 | |
| 513 | 513 | c = 0xFF; |
| 514 | 514 | } else { |
| 515 | 515 | /* Oops, it's actually a marker indicating end of compressed data. |
| 516 | * Save the marker code for later use. | |
| 517 | * Fine point: it might appear that we should save the marker into | |
| 518 | * bitread working state, not straight into permanent state. But | |
| 519 | * once we have hit a marker, we cannot need to suspend within the | |
| 520 | * current MCU, because we will read no more bytes from the data | |
| 521 | * source. So it is OK to update permanent state right away. | |
| 522 | */ | |
| 516 | * Save the marker code for later use. | |
| 517 | * Fine point: it might appear that we should save the marker into | |
| 518 | * bitread working state, not straight into permanent state. But | |
| 519 | * once we have hit a marker, we cannot need to suspend within the | |
| 520 | * current MCU, because we will read no more bytes from the data | |
| 521 | * source. So it is OK to update permanent state right away. | |
| 522 | */ | |
| 523 | 523 | cinfo->unread_marker = c; |
| 524 | 524 | /* See if we need to insert some fake zero bits. */ |
| 525 | 525 | goto no_more_bytes; |
| r14260 | r14261 | |
| 671 | 671 | /* |
| 672 | 672 | * Huffman MCU decoding. |
| 673 | 673 | * Each of these routines decodes and returns one MCU's worth of |
| 674 | * Huffman-compressed coefficients. | |
| 674 | * Huffman-compressed coefficients. | |
| 675 | 675 | * The coefficients are reordered from zigzag order into natural array order, |
| 676 | 676 | * but are not dequantized. |
| 677 | 677 | * |
| r14260 | r14261 | |
| 693 | 693 | |
| 694 | 694 | METHODDEF(boolean) |
| 695 | 695 | decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 696 | { | |
| 696 | { | |
| 697 | 697 | huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; |
| 698 | 698 | int Al = cinfo->Al; |
| 699 | 699 | register int s, r; |
| r14260 | r14261 | |
| 764 | 764 | |
| 765 | 765 | METHODDEF(boolean) |
| 766 | 766 | decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 767 | { | |
| 767 | { | |
| 768 | 768 | huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; |
| 769 | 769 | register int s, k, r; |
| 770 | 770 | unsigned int EOBRUN; |
| r14260 | r14261 | |
| 853 | 853 | |
| 854 | 854 | METHODDEF(boolean) |
| 855 | 855 | decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 856 | { | |
| 856 | { | |
| 857 | 857 | huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; |
| 858 | 858 | int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ |
| 859 | 859 | int blkn; |
| r14260 | r14261 | |
| 902 | 902 | |
| 903 | 903 | METHODDEF(boolean) |
| 904 | 904 | decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) |
| 905 | { | |
| 905 | { | |
| 906 | 906 | huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; |
| 907 | 907 | register int s, k, r; |
| 908 | 908 | unsigned int EOBRUN; |
| r14260 | r14261 | |
| 976 | 976 | /* note s = 0 for processing ZRL */ |
| 977 | 977 | } |
| 978 | 978 | /* Advance over already-nonzero coefs and r still-zero coefs, |
| 979 | * appending correction bits to the nonzeroes. A correction bit is 1 | |
| 980 | * if the absolute value of the coefficient must be increased. | |
| 981 | */ | |
| 979 | * appending correction bits to the nonzeroes. A correction bit is 1 | |
| 980 | * if the absolute value of the coefficient must be increased. | |
| 981 | */ | |
| 982 | 982 | do { |
| 983 | 983 | thiscoef = *block + natural_order[k]; |
| 984 | 984 | if (*thiscoef != 0) { |
| r14260 | r14261 | |
| 1127 | 1127 | r = GET_BITS(s); |
| 1128 | 1128 | s = HUFF_EXTEND(r, s); |
| 1129 | 1129 | /* Output coefficient in natural (dezigzagged) order. |
| 1130 | * Note: the extra entries in natural_order[] will save us | |
| 1131 | * if k > Se, which could happen if the data is corrupted. | |
| 1132 | */ | |
| 1130 | * Note: the extra entries in natural_order[] will save us | |
| 1131 | * if k > Se, which could happen if the data is corrupted. | |
| 1132 | */ | |
| 1133 | 1133 | (*block)[natural_order[k]] = (JCOEF) s; |
| 1134 | 1134 | } else { |
| 1135 | 1135 | if (r != 15) |
| r14260 | r14261 | |
| 1251 | 1251 | r = GET_BITS(s); |
| 1252 | 1252 | s = HUFF_EXTEND(r, s); |
| 1253 | 1253 | /* Output coefficient in natural (dezigzagged) order. |
| 1254 | * Note: the extra entries in jpeg_natural_order[] will save us | |
| 1255 | * if k >= DCTSIZE2, which could happen if the data is corrupted. | |
| 1256 | */ | |
| 1254 | * Note: the extra entries in jpeg_natural_order[] will save us | |
| 1255 | * if k >= DCTSIZE2, which could happen if the data is corrupted. | |
| 1256 | */ | |
| 1257 | 1257 | (*block)[jpeg_natural_order[k]] = (JCOEF) s; |
| 1258 | 1258 | } else { |
| 1259 | 1259 | if (r != 15) |
| r14260 | r14261 | |
|---|---|---|
| 8 | 8 | * |
| 9 | 9 | * This file contains master control logic for the JPEG compressor. |
| 10 | 10 | * These routines are concerned with parameter validation, initial setup, |
| 11 | * and inter-pass control (determining the number of passes and the work | |
| 11 | * and inter-pass control (determining the number of passes and the work | |
| 12 | 12 | * to be done in each pass). |
| 13 | 13 | */ |
| 14 | 14 | |
| r14260 | r14261 | |
| 381 | 381 | #ifdef C_PROGRESSIVE_SUPPORTED |
| 382 | 382 | cinfo->progressive_mode = TRUE; |
| 383 | 383 | last_bitpos_ptr = & last_bitpos[0][0]; |
| 384 | for (ci = 0; ci < cinfo->num_components; ci++) | |
| 384 | for (ci = 0; ci < cinfo->num_components; ci++) | |
| 385 | 385 | for (coefi = 0; coefi < DCTSIZE2; coefi++) |
| 386 | 386 | *last_bitpos_ptr++ = -1; |
| 387 | 387 | #else |
| r14260 | r14261 | |
| 389 | 389 | #endif |
| 390 | 390 | } else { |
| 391 | 391 | cinfo->progressive_mode = FALSE; |
| 392 | for (ci = 0; ci < cinfo->num_components; ci++) | |
| 392 | for (ci = 0; ci < cinfo->num_components; ci++) | |
| 393 | 393 | component_sent[ci] = FALSE; |
| 394 | 394 | } |
| 395 | 395 | |
| r14260 | r14261 | |
| 575 | 575 | { |
| 576 | 576 | int ci, mcublks, tmp; |
| 577 | 577 | jpeg_component_info *compptr; |
| 578 | ||
| 578 | ||
| 579 | 579 | if (cinfo->comps_in_scan == 1) { |
| 580 | ||
| 580 | ||
| 581 | 581 | /* Noninterleaved (single-component) scan */ |
| 582 | 582 | compptr = cinfo->cur_comp_info[0]; |
| 583 | ||
| 583 | ||
| 584 | 584 | /* Overall image size in MCUs */ |
| 585 | 585 | cinfo->MCUs_per_row = compptr->width_in_blocks; |
| 586 | 586 | cinfo->MCU_rows_in_scan = compptr->height_in_blocks; |
| 587 | ||
| 587 | ||
| 588 | 588 | /* For noninterleaved scan, always one block per MCU */ |
| 589 | 589 | compptr->MCU_width = 1; |
| 590 | 590 | compptr->MCU_height = 1; |
| r14260 | r14261 | |
| 597 | 597 | tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); |
| 598 | 598 | if (tmp == 0) tmp = compptr->v_samp_factor; |
| 599 | 599 | compptr->last_row_height = tmp; |
| 600 | ||
| 600 | ||
| 601 | 601 | /* Prepare array describing MCU composition */ |
| 602 | 602 | cinfo->blocks_in_MCU = 1; |
| 603 | 603 | cinfo->MCU_membership[0] = 0; |
| 604 | ||
| 604 | ||
| 605 | 605 | } else { |
| 606 | ||
| 606 | ||
| 607 | 607 | /* Interleaved (multi-component) scan */ |
| 608 | 608 | if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) |
| 609 | 609 | ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, |
| 610 | 610 | MAX_COMPS_IN_SCAN); |
| 611 | ||
| 611 | ||
| 612 | 612 | /* Overall image size in MCUs */ |
| 613 | 613 | cinfo->MCUs_per_row = (JDIMENSION) |
| 614 | 614 | jdiv_round_up((long) cinfo->jpeg_width, |
| r14260 | r14261 | |
| 616 | 616 | cinfo->MCU_rows_in_scan = (JDIMENSION) |
| 617 | 617 | jdiv_round_up((long) cinfo->jpeg_height, |
| 618 | 618 | (long) (cinfo->max_v_samp_factor * cinfo->block_size)); |
| 619 | ||
| 619 | ||
| 620 | 620 | cinfo->blocks_in_MCU = 0; |
| 621 | ||
| 621 | ||
| 622 | 622 | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
| 623 | 623 | compptr = cinfo->cur_comp_info[ci]; |
| 624 | 624 | /* Sampling factors give # of blocks of component in each MCU */ |
| r14260 | r14261 | |
| 641 | 641 | cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; |
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | ||
| 644 | ||
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /* Convert restart specified in rows to actual MCU count. */ |
| r14260 | r14261 | |
|---|---|---|
| 191 | 191 | * processes are inner loops and need to be as fast as possible. On most |
| 192 | 192 | * machines, particularly CPUs with pipelines or instruction prefetch, |
| 193 | 193 | * a (subscript-check-less) C table lookup |
| 194 | * | |
| 194 | * x = sample_range_limit[x]; | |
| 195 | 195 | * is faster than explicit tests |
| 196 | * if (x < 0) x = 0; | |
| 197 | * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; | |
| 196 | * if (x < 0) x = 0; | |
| 197 | * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; | |
| 198 | 198 | * These processes all use a common table prepared by the routine below. |
| 199 | 199 | * |
| 200 | 200 | * For most steps we can mathematically guarantee that the initial value |
| 201 | 201 | * of x is within MAXJSAMPLE+1 of the legal range, so a table running from |
| 202 | 202 | * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial |
| 203 | * limiting step (just after the IDCT), a wildly out-of-range value is | |
| 203 | * limiting step (just after the IDCT), a wildly out-of-range value is | |
| 204 | 204 | * possible if the input data is corrupt. To avoid any chance of indexing |
| 205 | 205 | * off the end of memory and getting a bad-pointer trap, we perform the |
| 206 | 206 | * post-IDCT limiting thus: |
| 207 | * | |
| 207 | * x = range_limit[x & MASK]; | |
| 208 | 208 | * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit |
| 209 | 209 | * samples. Under normal circumstances this is more than enough range and |
| 210 | 210 | * a correct output will be generated; with bogus input data the mask will |
| r14260 | r14261 | |
|---|---|---|
| 196 | 196 | * With typical images and quantization tables, half or more of the |
| 197 | 197 | * column DCT calculations can be simplified this way. |
| 198 | 198 | */ |
| 199 | ||
| 199 | ||
| 200 | 200 | if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && |
| 201 | 201 | inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && |
| 202 | 202 | inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && |
| r14260 | r14261 | |
| 212 | 212 | wsptr[DCTSIZE*5] = dcval; |
| 213 | 213 | wsptr[DCTSIZE*6] = dcval; |
| 214 | 214 | wsptr[DCTSIZE*7] = dcval; |
| 215 | ||
| 215 | ||
| 216 | 216 | inptr++; /* advance pointers to next column */ |
| 217 | 217 | quantptr++; |
| 218 | 218 | wsptr++; |
| 219 | 219 | continue; |
| 220 | 220 | } |
| 221 | ||
| 221 | ||
| 222 | 222 | /* Even part */ |
| 223 | 223 | |
| 224 | 224 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
| r14260 | r14261 | |
| 236 | 236 | tmp3 = tmp10 - tmp13; |
| 237 | 237 | tmp1 = tmp11 + tmp12; |
| 238 | 238 | tmp2 = tmp11 - tmp12; |
| 239 | ||
| 239 | ||
| 240 | 240 | /* Odd part */ |
| 241 | 241 | |
| 242 | 242 | tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
| r14260 | r14261 | |
| 273 | 273 | quantptr++; |
| 274 | 274 | wsptr++; |
| 275 | 275 | } |
| 276 | ||
| 276 | ||
| 277 | 277 | /* Pass 2: process rows from work array, store into output array. */ |
| 278 | 278 | /* Note that we must descale the results by a factor of 8 == 2**3, */ |
| 279 | 279 | /* and also undo the PASS1_BITS scaling. */ |
| r14260 | r14261 | |
| 288 | 288 | * test takes more time than it's worth. In that case this section |
| 289 | 289 | * may be commented out. |
| 290 | 290 | */ |
| 291 | ||
| 291 | ||
| 292 | 292 | #ifndef NO_ZERO_ROW_TEST |
| 293 | 293 | if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && |
| 294 | 294 | wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { |
| 295 | 295 | /* AC terms all zero */ |
| 296 | 296 | JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) |
| 297 | 297 | & RANGE_MASK]; |
| 298 | ||
| 298 | ||
| 299 | 299 | outptr[0] = dcval; |
| 300 | 300 | outptr[1] = dcval; |
| 301 | 301 | outptr[2] = dcval; |
| r14260 | r14261 | |
| 309 | 309 | continue; |
| 310 | 310 | } |
| 311 | 311 | #endif |
| 312 | ||
| 312 | ||
| 313 | 313 | /* Even part */ |
| 314 | 314 | |
| 315 | 315 | tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); |
| r14260 | r14261 | |
|---|---|---|
| 204 | 204 | { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; |
| 205 | 205 | static const UINT8 val_dc_luminance[] = |
| 206 | 206 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; |
| 207 | ||
| 207 | ||
| 208 | 208 | static const UINT8 bits_dc_chrominance[17] = |
| 209 | 209 | { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; |
| 210 | 210 | static const UINT8 val_dc_chrominance[] = |
| 211 | 211 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; |
| 212 | ||
| 212 | ||
| 213 | 213 | static const UINT8 bits_ac_luminance[17] = |
| 214 | 214 | { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; |
| 215 | 215 | static const UINT8 val_ac_luminance[] = |
| r14260 | r14261 | |
| 234 | 234 | 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, |
| 235 | 235 | 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, |
| 236 | 236 | 0xf9, 0xfa }; |
| 237 | ||
| 237 | ||
| 238 | 238 | static const UINT8 bits_ac_chrominance[17] = |
| 239 | 239 | { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; |
| 240 | 240 | static const UINT8 val_ac_chrominance[] = |
| r14260 | r14261 | |
| 259 | 259 | 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, |
| 260 | 260 | 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, |
| 261 | 261 | 0xf9, 0xfa }; |
| 262 | ||
| 262 | ||
| 263 | 263 | add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], |
| 264 | 264 | bits_dc_luminance, val_dc_luminance); |
| 265 | 265 | add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], |
| r14260 | r14261 | |
|---|---|---|
| 105 | 105 | * Errors are accumulated into the array fserrors[], at a resolution of |
| 106 | 106 | * 1/16th of a pixel count. The error at a given pixel is propagated |
| 107 | 107 | * to its not-yet-processed neighbors using the standard F-S fractions, |
| 108 | * ... (here) 7/16 | |
| 109 | * 3/16 5/16 1/16 | |
| 108 | * ... (here) 7/16 | |
| 109 | * 3/16 5/16 1/16 | |
| 110 | 110 | * We work left-to-right on even rows, right-to-left on odd rows. |
| 111 | 111 | * |
| 112 | 112 | * We can get away with a single array (holding one row's worth of errors) |
| r14260 | r14261 | |
| 424 | 424 | |
| 425 | 425 | /* |
| 426 | 426 | * Create the ordered-dither tables. |
| 427 | * Components having the same number of representative colors may | |
| 427 | * Components having the same number of representative colors may | |
| 428 | 428 | * share a dither table. |
| 429 | 429 | */ |
| 430 | 430 | |
| r14260 | r14261 | |
| 542 | 542 | |
| 543 | 543 | for (col = width; col > 0; col--) { |
| 544 | 544 | /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, |
| 545 | * select output value, accumulate into output code for this pixel. | |
| 546 | * Range-limiting need not be done explicitly, as we have extended | |
| 547 | * the colorindex table to produce the right answers for out-of-range | |
| 548 | * inputs. The maximum dither is +- MAXJSAMPLE; this sets the | |
| 549 | * required amount of padding. | |
| 550 | */ | |
| 545 | * select output value, accumulate into output code for this pixel. | |
| 546 | * Range-limiting need not be done explicitly, as we have extended | |
| 547 | * the colorindex table to produce the right answers for out-of-range | |
| 548 | * inputs. The maximum dither is +- MAXJSAMPLE; this sets the | |
| 549 | * required amount of padding. | |
| 550 | */ | |
| 551 | 551 | *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; |
| 552 | 552 | input_ptr += nc; |
| 553 | 553 | output_ptr++; |
| r14260 | r14261 | |
| 662 | 662 | |
| 663 | 663 | for (col = width; col > 0; col--) { |
| 664 | 664 | /* cur holds the error propagated from the previous pixel on the |
| 665 | * current line. Add the error propagated from the previous line | |
| 666 | * to form the complete error correction term for this pixel, and | |
| 667 | * round the error term (which is expressed * 16) to an integer. | |
| 668 | * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct | |
| 669 | * for either sign of the error value. | |
| 670 | * Note: errorptr points to *previous* column's array entry. | |
| 671 | */ | |
| 665 | * current line. Add the error propagated from the previous line | |
| 666 | * to form the complete error correction term for this pixel, and | |
| 667 | * round the error term (which is expressed * 16) to an integer. | |
| 668 | * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct | |
| 669 | * for either sign of the error value. | |
| 670 | * Note: errorptr points to *previous* column's array entry. | |
| 671 | */ | |
| 672 | 672 | cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); |
| 673 | 673 | /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. |
| 674 | * The maximum error is +- MAXJSAMPLE; this sets the required size | |
| 675 | * of the range_limit array. | |
| 676 | */ | |
| 674 | * The maximum error is +- MAXJSAMPLE; this sets the required size | |
| 675 | * of the range_limit array. | |
| 676 | */ | |
| 677 | 677 | cur += GETJSAMPLE(*input_ptr); |
| 678 | 678 | cur = GETJSAMPLE(range_limit[cur]); |
| 679 | 679 | /* Select output value, accumulate into output code for this pixel */ |
| r14260 | r14261 | |
| 684 | 684 | /* pixel code, because the colormap is orthogonal. */ |
| 685 | 685 | cur -= GETJSAMPLE(colormap_ci[pixcode]); |
| 686 | 686 | /* Compute error fractions to be propagated to adjacent pixels. |
| 687 | * Add these into the running sums, and simultaneously shift the | |
| 688 | * next-line error sums left by 1 column. | |
| 689 | */ | |
| 687 | * Add these into the running sums, and simultaneously shift the | |
| 688 | * next-line error sums left by 1 column. | |
| 689 | */ | |
| 690 | 690 | bnexterr = cur; |
| 691 | 691 | delta = cur * 2; |
| 692 | 692 | cur += delta; /* form error * 3 */ |
| r14260 | r14261 | |
| 696 | 696 | belowerr = bnexterr; |
| 697 | 697 | cur += delta; /* form error * 7 */ |
| 698 | 698 | /* At this point cur contains the 7/16 error value to be propagated |
| 699 | * to the next pixel on the current line, and all the errors for the | |
| 700 | * next line have been shifted over. We are therefore ready to move on. | |
| 701 | */ | |
| 699 | * to the next pixel on the current line, and all the errors for the | |
| 700 | * next line have been shifted over. We are therefore ready to move on. | |
| 701 | */ | |
| 702 | 702 | input_ptr += dirnc; /* advance input ptr to next column */ |
| 703 | 703 | output_ptr += dir; /* advance output ptr to next column */ |
| 704 | 704 | errorptr += dir; /* advance errorptr to current column */ |
| r14260 | r14261 | |
|---|---|---|
| 41 | 41 | * color space, and repeatedly splits the "largest" remaining box until we |
| 42 | 42 | * have as many boxes as desired colors. Then the mean color in each |
| 43 | 43 | * remaining box becomes one of the possible output colors. |
| 44 | * | |
| 44 | * | |
| 45 | 45 | * The second pass over the image maps each input pixel to the closest output |
| 46 | 46 | * color (optionally after applying a Floyd-Steinberg dithering correction). |
| 47 | 47 | * This mapping is logically trivial, but making it go fast enough requires |
| r14260 | r14261 | |
| 158 | 158 | * Errors are accumulated into the array fserrors[], at a resolution of |
| 159 | 159 | * 1/16th of a pixel count. The error at a given pixel is propagated |
| 160 | 160 | * to its not-yet-processed neighbors using the standard F-S fractions, |
| 161 | * ... (here) 7/16 | |
| 162 | * 3/16 5/16 1/16 | |
| 161 | * ... (here) 7/16 | |
| 162 | * 3/16 5/16 1/16 | |
| 163 | 163 | * We work left-to-right on even rows, right-to-left on odd rows. |
| 164 | 164 | * |
| 165 | 165 | * We can get away with a single array (holding one row's worth of errors) |
| r14260 | r14261 | |
| 278 | 278 | register int i; |
| 279 | 279 | register long maxc = 0; |
| 280 | 280 | boxptr which = NULL; |
| 281 | ||
| 281 | ||
| 282 | 282 | for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { |
| 283 | 283 | if (boxp->colorcount > maxc && boxp->volume > 0) { |
| 284 | 284 | which = boxp; |
| r14260 | r14261 | |
| 298 | 298 | register int i; |
| 299 | 299 | register INT32 maxv = 0; |
| 300 | 300 | boxptr which = NULL; |
| 301 | ||
| 301 | ||
| 302 | 302 | for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { |
| 303 | 303 | if (boxp->volume > maxv) { |
| 304 | 304 | which = boxp; |
| r14260 | r14261 | |
| 321 | 321 | int c0min,c0max,c1min,c1max,c2min,c2max; |
| 322 | 322 | INT32 dist0,dist1,dist2; |
| 323 | 323 | long ccount; |
| 324 | ||
| 324 | ||
| 325 | 325 | c0min = boxp->c0min; c0max = boxp->c0max; |
| 326 | 326 | c1min = boxp->c1min; c1max = boxp->c1max; |
| 327 | 327 | c2min = boxp->c2min; c2max = boxp->c2max; |
| 328 | ||
| 328 | ||
| 329 | 329 | if (c0max > c0min) |
| 330 | 330 | for (c0 = c0min; c0 <= c0max; c0++) |
| 331 | 331 | for (c1 = c1min; c1 <= c1max; c1++) { |
| r14260 | r14261 | |
| 405 | 405 | dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; |
| 406 | 406 | dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; |
| 407 | 407 | boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; |
| 408 | ||
| 408 | ||
| 409 | 409 | /* Now scan remaining volume of box and compute population */ |
| 410 | 410 | ccount = 0; |
| 411 | 411 | for (c0 = c0min; c0 <= c0max; c0++) |
| r14260 | r14261 | |
| 511 | 511 | long c0total = 0; |
| 512 | 512 | long c1total = 0; |
| 513 | 513 | long c2total = 0; |
| 514 | ||
| 514 | ||
| 515 | 515 | c0min = boxp->c0min; c0max = boxp->c0max; |
| 516 | 516 | c1min = boxp->c1min; c1max = boxp->c1max; |
| 517 | 517 | c2min = boxp->c2min; c2max = boxp->c2max; |
| 518 | ||
| 518 | ||
| 519 | 519 | for (c0 = c0min; c0 <= c0max; c0++) |
| 520 | 520 | for (c1 = c1min; c1 <= c1max; c1++) { |
| 521 | 521 | histp = & histogram[c0][c1][c2min]; |
| r14260 | r14261 | |
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | ||
| 531 | ||
| 532 | 532 | cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); |
| 533 | 533 | cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); |
| 534 | 534 | cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); |
| r14260 | r14261 | |
| 797 | 797 | bptr = bestdist; |
| 798 | 798 | for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) |
| 799 | 799 | *bptr++ = 0x7FFFFFFFL; |
| 800 | ||
| 800 | ||
| 801 | 801 | /* For each color selected by find_nearby_colors, |
| 802 | 802 | * compute its distance to the center of each cell in the box. |
| 803 | 803 | * If that's less than best-so-far, update best distance and color number. |
| 804 | 804 | */ |
| 805 | ||
| 805 | ||
| 806 | 806 | /* Nominal steps between cell centers ("x" in Thomas article) */ |
| 807 | 807 | #define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) |
| 808 | 808 | #define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) |
| 809 | 809 | #define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) |
| 810 | ||
| 810 | ||
| 811 | 811 | for (i = 0; i < numcolors; i++) { |
| 812 | 812 | icolor = GETJSAMPLE(colorlist[i]); |
| 813 | 813 | /* Compute (square of) distance from minc0/c1/c2 to this color */ |
| r14260 | r14261 | |
| 881 | 881 | minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); |
| 882 | 882 | minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); |
| 883 | 883 | minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); |
| 884 | ||
| 884 | ||
| 885 | 885 | /* Determine which colormap entries are close enough to be candidates |
| 886 | 886 | * for the nearest entry to some cell in the update box. |
| 887 | 887 | */ |
| r14260 | r14261 | |
|---|---|---|
| 216 | 216 | */ |
| 217 | 217 | |
| 218 | 218 | LOCAL(void) |
| 219 | arith_encode (j_compress_ptr cinfo, unsigned char *st, int val) | |
| 219 | arith_encode (j_compress_ptr cinfo, unsigned char *st, int val) | |
| 220 | 220 | { |
| 221 | 221 | register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy; |
| 222 | 222 | register unsigned char nl, nm; |
| r14260 | r14261 | |
| 278 | 278 | e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */ |
| 279 | 279 | e->sc = 0; |
| 280 | 280 | /* Note: The 3 spacer bits in the C register guarantee |
| 281 | * that the new buffer byte can't be 0xFF here | |
| 282 | * (see page 160 in the P&M JPEG book). */ | |
| 281 | * that the new buffer byte can't be 0xFF here | |
| 282 | * (see page 160 in the P&M JPEG book). */ | |
| 283 | 283 | e->buffer = temp & 0xFF; /* new output byte, might overflow later */ |
| 284 | 284 | } else if (temp == 0xFF) { |
| 285 | 285 | ++e->sc; /* stack 0xFF byte (which might overflow later) */ |
| r14260 | r14261 | |
|---|---|---|
| 8 | 8 | * This include file contains common declarations for the forward and |
| 9 | 9 | * inverse DCT modules. These declarations are private to the DCT managers |
| 10 | 10 | * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. |
| 11 | * The individual DCT algorithms are kept in separate files to ease | |
| 11 | * The individual DCT algorithms are kept in separate files to ease | |
| 12 | 12 | * machine-dependent tuning (e.g., assembly coding). |
| 13 | 13 | */ |
| 14 | 14 |
| r14260 | r14261 | |
|---|---|---|
| 31 | 31 | * YCbCr is defined per CCIR 601-1, except that Cb and Cr are |
| 32 | 32 | * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. |
| 33 | 33 | * The conversion equations to be implemented are therefore |
| 34 | * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B | |
| 35 | * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE | |
| 36 | * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE | |
| 34 | * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B | |
| 35 | * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE | |
| 36 | * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE | |
| 37 | 37 | * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) |
| 38 | 38 | * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, |
| 39 | 39 | * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and |
| r14260 | r14261 | |
|---|---|---|
| 238 | 238 | * machines, but may be too small if longs are 64 bits or more. |
| 239 | 239 | */ |
| 240 | 240 | |
| 241 | static const size_t first_pool_slop[JPOOL_NUMPOOLS] = | |
| 241 | static const size_t first_pool_slop[JPOOL_NUMPOOLS] = | |
| 242 | 242 | { |
| 243 | 243 | 1600, /* first PERMANENT pool */ |
| 244 | 244 | 16000 /* first IMAGE pool */ |
| 245 | 245 | }; |
| 246 | 246 | |
| 247 | static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = | |
| 247 | static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = | |
| 248 | 248 | { |
| 249 | 249 | 0, /* additional PERMANENT pools */ |
| 250 | 250 | 5000 /* additional IMAGE pools */ |
| r14260 | r14261 | |
|---|---|---|
| 19 | 19 | M_SOF1 = 0xc1, |
| 20 | 20 | M_SOF2 = 0xc2, |
| 21 | 21 | M_SOF3 = 0xc3, |
| 22 | ||
| 22 | ||
| 23 | 23 | M_SOF5 = 0xc5, |
| 24 | 24 | M_SOF6 = 0xc6, |
| 25 | 25 | M_SOF7 = 0xc7, |
| 26 | ||
| 26 | ||
| 27 | 27 | M_JPG = 0xc8, |
| 28 | 28 | M_SOF9 = 0xc9, |
| 29 | 29 | M_SOF10 = 0xca, |
| 30 | 30 | M_SOF11 = 0xcb, |
| 31 | ||
| 31 | ||
| 32 | 32 | M_SOF13 = 0xcd, |
| 33 | 33 | M_SOF14 = 0xce, |
| 34 | 34 | M_SOF15 = 0xcf, |
| 35 | ||
| 35 | ||
| 36 | 36 | M_DHT = 0xc4, |
| 37 | ||
| 37 | ||
| 38 | 38 | M_DAC = 0xcc, |
| 39 | ||
| 39 | ||
| 40 | 40 | M_RST0 = 0xd0, |
| 41 | 41 | M_RST1 = 0xd1, |
| 42 | 42 | M_RST2 = 0xd2, |
| r14260 | r14261 | |
| 45 | 45 | M_RST5 = 0xd5, |
| 46 | 46 | M_RST6 = 0xd6, |
| 47 | 47 | M_RST7 = 0xd7, |
| 48 | ||
| 48 | ||
| 49 | 49 | M_SOI = 0xd8, |
| 50 | 50 | M_EOI = 0xd9, |
| 51 | 51 | M_SOS = 0xda, |
| r14260 | r14261 | |
| 54 | 54 | M_DRI = 0xdd, |
| 55 | 55 | M_DHP = 0xde, |
| 56 | 56 | M_EXP = 0xdf, |
| 57 | ||
| 57 | ||
| 58 | 58 | M_APP0 = 0xe0, |
| 59 | 59 | M_APP1 = 0xe1, |
| 60 | 60 | M_APP2 = 0xe2, |
| r14260 | r14261 | |
| 71 | 71 | M_APP13 = 0xed, |
| 72 | 72 | M_APP14 = 0xee, |
| 73 | 73 | M_APP15 = 0xef, |
| 74 | ||
| 74 | ||
| 75 | 75 | M_JPG0 = 0xf0, |
| 76 | 76 | M_JPG13 = 0xfd, |
| 77 | 77 | M_COM = 0xfe, |
| 78 | ||
| 78 | ||
| 79 | 79 | M_TEM = 0x01, |
| 80 | ||
| 80 | ||
| 81 | 81 | M_ERROR = 0x100 |
| 82 | 82 | } JPEG_MARKER; |
| 83 | 83 | |
| r14260 | r14261 | |
| 188 | 188 | { |
| 189 | 189 | JHUFF_TBL * htbl; |
| 190 | 190 | int length, i; |
| 191 | ||
| 191 | ||
| 192 | 192 | if (is_ac) { |
| 193 | 193 | htbl = cinfo->ac_huff_tbl_ptrs[index]; |
| 194 | 194 | index += 0x10; /* output index has AC bit set */ |
| r14260 | r14261 | |
| 198 | 198 | |
| 199 | 199 | if (htbl == NULL) |
| 200 | 200 | ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); |
| 201 | ||
| 201 | ||
| 202 | 202 | if (! htbl->sent_table) { |
| 203 | 203 | emit_marker(cinfo, M_DHT); |
| 204 | ||
| 204 | ||
| 205 | 205 | length = 0; |
| 206 | 206 | for (i = 1; i <= 16; i++) |
| 207 | 207 | length += htbl->bits[i]; |
| 208 | ||
| 208 | ||
| 209 | 209 | emit_2bytes(cinfo, length + 2 + 1 + 16); |
| 210 | 210 | emit_byte(cinfo, index); |
| 211 | ||
| 211 | ||
| 212 | 212 | for (i = 1; i <= 16; i++) |
| 213 | 213 | emit_byte(cinfo, htbl->bits[i]); |
| 214 | ||
| 214 | ||
| 215 | 215 | for (i = 0; i < length; i++) |
| 216 | 216 | emit_byte(cinfo, htbl->huffval[i]); |
| 217 | ||
| 217 | ||
| 218 | 218 | htbl->sent_table = TRUE; |
| 219 | 219 | } |
| 220 | 220 | } |
| r14260 | r14261 | |
| 274 | 274 | /* Emit a DRI marker */ |
| 275 | 275 | { |
| 276 | 276 | emit_marker(cinfo, M_DRI); |
| 277 | ||
| 277 | ||
| 278 | 278 | emit_2bytes(cinfo, 4); /* fixed length */ |
| 279 | 279 | |
| 280 | 280 | emit_2bytes(cinfo, (int) cinfo->restart_interval); |
| r14260 | r14261 | |
| 287 | 287 | { |
| 288 | 288 | int ci; |
| 289 | 289 | jpeg_component_info *compptr; |
| 290 | ||
| 290 | ||
| 291 | 291 | emit_marker(cinfo, code); |
| 292 | ||
| 292 | ||
| 293 | 293 | emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ |
| 294 | 294 | |
| 295 | 295 | /* Make sure image isn't bigger than SOF field can handle */ |
| r14260 | r14261 | |
| 318 | 318 | { |
| 319 | 319 | int i, td, ta; |
| 320 | 320 | jpeg_component_info *compptr; |
| 321 | ||
| 321 | ||
| 322 | 322 | emit_marker(cinfo, M_SOS); |
| 323 | ||
| 323 | ||
| 324 | 324 | emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ |
| 325 | ||
| 325 | ||
| 326 | 326 | emit_byte(cinfo, cinfo->comps_in_scan); |
| 327 | ||
| 327 | ||
| 328 | 328 | for (i = 0; i < cinfo->comps_in_scan; i++) { |
| 329 | 329 | compptr = cinfo->cur_comp_info[i]; |
| 330 | 330 | emit_byte(cinfo, compptr->component_id); |
| r14260 | r14261 | |
| 352 | 352 | /* Emit a pseudo SOS marker */ |
| 353 | 353 | { |
| 354 | 354 | emit_marker(cinfo, M_SOS); |
| 355 | ||
| 355 | ||
| 356 | 356 | emit_2bytes(cinfo, 2 + 1 + 3); /* length */ |
| 357 | ||
| 357 | ||
| 358 | 358 | emit_byte(cinfo, 0); /* Ns */ |
| 359 | 359 | |
| 360 | 360 | emit_byte(cinfo, 0); /* Ss */ |
| r14260 | r14261 | |
| 368 | 368 | /* Emit a JFIF-compliant APP0 marker */ |
| 369 | 369 | { |
| 370 | 370 | /* |
| 371 | * Length of APP0 block (2 bytes) | |
| 372 | * Block ID (4 bytes - ASCII "JFIF") | |
| 373 | * Zero byte (1 byte to terminate the ID string) | |
| 374 | * Version Major, Minor (2 bytes - major first) | |
| 375 | * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) | |
| 376 | * Xdpu (2 bytes - dots per unit horizontal) | |
| 377 | * Ydpu (2 bytes - dots per unit vertical) | |
| 378 | * Thumbnail X size (1 byte) | |
| 379 | * Thumbnail Y size (1 byte) | |
| 371 | * Length of APP0 block (2 bytes) | |
| 372 | * Block ID (4 bytes - ASCII "JFIF") | |
| 373 | * Zero byte (1 byte to terminate the ID string) | |
| 374 | * Version Major, Minor (2 bytes - major first) | |
| 375 | * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) | |
| 376 | * Xdpu (2 bytes - dots per unit horizontal) | |
| 377 | * Ydpu (2 bytes - dots per unit vertical) | |
| 378 | * Thumbnail X size (1 byte) | |
| 379 | * Thumbnail Y size (1 byte) | |
| 380 | 380 | */ |
| 381 | ||
| 381 | ||
| 382 | 382 | emit_marker(cinfo, M_APP0); |
| 383 | ||
| 383 | ||
| 384 | 384 | emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ |
| 385 | 385 | |
| 386 | 386 | emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ |
| r14260 | r14261 | |
| 403 | 403 | /* Emit an Adobe APP14 marker */ |
| 404 | 404 | { |
| 405 | 405 | /* |
| 406 | * Length of APP14 block (2 bytes) | |
| 407 | * Block ID (5 bytes - ASCII "Adobe") | |
| 408 | * Version Number (2 bytes - currently 100) | |
| 409 | * Flags0 (2 bytes - currently 0) | |
| 410 | * Flags1 (2 bytes - currently 0) | |
| 411 | * Color transform (1 byte) | |
| 406 | * Length of APP14 block (2 bytes) | |
| 407 | * Block ID (5 bytes - ASCII "Adobe") | |
| 408 | * Version Number (2 bytes - currently 100) | |
| 409 | * Flags0 (2 bytes - currently 0) | |
| 410 | * Flags1 (2 bytes - currently 0) | |
| 411 | * Color transform (1 byte) | |
| 412 | 412 | * |
| 413 | 413 | * Although Adobe TN 5116 mentions Version = 101, all the Adobe files |
| 414 | 414 | * now in circulation seem to use Version = 100, so that's what we write. |
| r14260 | r14261 | |
| 417 | 417 | * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with |
| 418 | 418 | * whether the encoder performed a transformation, which is pretty useless. |
| 419 | 419 | */ |
| 420 | ||
| 420 | ||
| 421 | 421 | emit_marker(cinfo, M_APP14); |
| 422 | ||
| 422 | ||
| 423 | 423 | emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ |
| 424 | 424 | |
| 425 | 425 | emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ |
| r14260 | r14261 | |
| 514 | 514 | int ci, prec; |
| 515 | 515 | boolean is_baseline; |
| 516 | 516 | jpeg_component_info *compptr; |
| 517 | ||
| 517 | ||
| 518 | 518 | /* Emit DQT for each quantization table. |
| 519 | 519 | * Note that emit_dqt() suppresses any duplicate tables. |
| 520 | 520 | */ |
| r14260 | r14261 | |
|---|---|---|
| 119 | 119 | /* Not more than the distance to the end of the image. Need this test |
| 120 | 120 | * in case the image height is not a multiple of max_v_samp_factor: |
| 121 | 121 | */ |
| 122 | if (num_rows > upsample->rows_to_go) | |
| 122 | if (num_rows > upsample->rows_to_go) | |
| 123 | 123 | num_rows = upsample->rows_to_go; |
| 124 | 124 | /* And not more than what the client can accept: */ |
| 125 | 125 | out_rows_avail -= *out_row_ctr; |
| r14260 | r14261 | |
|---|---|---|
| 23 | 23 | M_SOF1 = 0xc1, |
| 24 | 24 | M_SOF2 = 0xc2, |
| 25 | 25 | M_SOF3 = 0xc3, |
| 26 | ||
| 26 | ||
| 27 | 27 | M_SOF5 = 0xc5, |
| 28 | 28 | M_SOF6 = 0xc6, |
| 29 | 29 | M_SOF7 = 0xc7, |
| 30 | ||
| 30 | ||
| 31 | 31 | M_JPG = 0xc8, |
| 32 | 32 | M_SOF9 = 0xc9, |
| 33 | 33 | M_SOF10 = 0xca, |
| 34 | 34 | M_SOF11 = 0xcb, |
| 35 | ||
| 35 | ||
| 36 | 36 | M_SOF13 = 0xcd, |
| 37 | 37 | M_SOF14 = 0xce, |
| 38 | 38 | M_SOF15 = 0xcf, |
| 39 | ||
| 39 | ||
| 40 | 40 | M_DHT = 0xc4, |
| 41 | ||
| 41 | ||
| 42 | 42 | M_DAC = 0xcc, |
| 43 | ||
| 43 | ||
| 44 | 44 | M_RST0 = 0xd0, |
| 45 | 45 | M_RST1 = 0xd1, |
| 46 | 46 | M_RST2 = 0xd2, |
| r14260 | r14261 | |
| 49 | 49 | M_RST5 = 0xd5, |
| 50 | 50 | M_RST6 = 0xd6, |
| 51 | 51 | M_RST7 = 0xd7, |
| 52 | ||
| 52 | ||
| 53 | 53 | M_SOI = 0xd8, |
| 54 | 54 | M_EOI = 0xd9, |
| 55 | 55 | M_SOS = 0xda, |
| r14260 | r14261 | |
| 58 | 58 | M_DRI = 0xdd, |
| 59 | 59 | M_DHP = 0xde, |
| 60 | 60 | M_EXP = 0xdf, |
| 61 | ||
| 61 | ||
| 62 | 62 | M_APP0 = 0xe0, |
| 63 | 63 | M_APP1 = 0xe1, |
| 64 | 64 | M_APP2 = 0xe2, |
| r14260 | r14261 | |
| 75 | 75 | M_APP13 = 0xed, |
| 76 | 76 | M_APP14 = 0xee, |
| 77 | 77 | M_APP15 = 0xef, |
| 78 | ||
| 78 | ||
| 79 | 79 | M_JPG0 = 0xf0, |
| 80 | 80 | M_JPG13 = 0xfd, |
| 81 | 81 | M_COM = 0xfe, |
| 82 | ||
| 82 | ||
| 83 | 83 | M_TEM = 0x01, |
| 84 | ||
| 84 | ||
| 85 | 85 | M_ERROR = 0x100 |
| 86 | 86 | } JPEG_MARKER; |
| 87 | 87 | |
| r14260 | r14261 | |
| 199 | 199 | /* Process an SOI marker */ |
| 200 | 200 | { |
| 201 | 201 | int i; |
| 202 | ||
| 202 | ||
| 203 | 203 | TRACEMS(cinfo, 1, JTRC_SOI); |
| 204 | 204 | |
| 205 | 205 | if (cinfo->marker->saw_SOI) |
| r14260 | r14261 | |
| 278 | 278 | cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) |
| 279 | 279 | ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 280 | 280 | cinfo->num_components * SIZEOF(jpeg_component_info)); |
| 281 | ||
| 281 | ||
| 282 | 282 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 283 | 283 | ci++, compptr++) { |
| 284 | 284 | compptr->component_index = ci; |
| r14260 | r14261 | |
| 330 | 330 | for (i = 0; i < n; i++) { |
| 331 | 331 | INPUT_BYTE(cinfo, cc, return FALSE); |
| 332 | 332 | INPUT_BYTE(cinfo, c, return FALSE); |
| 333 | ||
| 333 | ||
| 334 | 334 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 335 | 335 | ci++, compptr++) { |
| 336 | 336 | if (cc == compptr->component_id) |
| r14260 | r14261 | |
| 344 | 344 | cinfo->cur_comp_info[i] = compptr; |
| 345 | 345 | compptr->dc_tbl_no = (c >> 4) & 15; |
| 346 | 346 | compptr->ac_tbl_no = (c ) & 15; |
| 347 | ||
| 347 | ||
| 348 | 348 | TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, |
| 349 | 349 | compptr->dc_tbl_no, compptr->ac_tbl_no); |
| 350 | 350 | } |
| r14260 | r14261 | |
| 384 | 384 | |
| 385 | 385 | INPUT_2BYTES(cinfo, length, return FALSE); |
| 386 | 386 | length -= 2; |
| 387 | ||
| 387 | ||
| 388 | 388 | while (length > 0) { |
| 389 | 389 | INPUT_BYTE(cinfo, index, return FALSE); |
| 390 | 390 | INPUT_BYTE(cinfo, val, return FALSE); |
| r14260 | r14261 | |
| 433 | 433 | |
| 434 | 434 | INPUT_2BYTES(cinfo, length, return FALSE); |
| 435 | 435 | length -= 2; |
| 436 | ||
| 436 | ||
| 437 | 437 | while (length > 16) { |
| 438 | 438 | INPUT_BYTE(cinfo, index, return FALSE); |
| 439 | 439 | |
| 440 | 440 | TRACEMS1(cinfo, 1, JTRC_DHT, index); |
| 441 | ||
| 441 | ||
| 442 | 442 | bits[0] = 0; |
| 443 | 443 | count = 0; |
| 444 | 444 | for (i = 1; i <= 16; i++) { |
| r14260 | r14261 | |
| 478 | 478 | |
| 479 | 479 | if (*htblptr == NULL) |
| 480 | 480 | *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); |
| 481 | ||
| 481 | ||
| 482 | 482 | MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); |
| 483 | 483 | MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); |
| 484 | 484 | } |
| r14260 | r14261 | |
| 515 | 515 | |
| 516 | 516 | if (n >= NUM_QUANT_TBLS) |
| 517 | 517 | ERREXIT1(cinfo, JERR_DQT_INDEX, n); |
| 518 | ||
| 518 | ||
| 519 | 519 | if (cinfo->quant_tbl_ptrs[n] == NULL) |
| 520 | 520 | cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); |
| 521 | 521 | quant_ptr = cinfo->quant_tbl_ptrs[n]; |
| r14260 | r14261 | |
| 590 | 590 | INPUT_VARS(cinfo); |
| 591 | 591 | |
| 592 | 592 | INPUT_2BYTES(cinfo, length, return FALSE); |
| 593 | ||
| 593 | ||
| 594 | 594 | if (length != 4) |
| 595 | 595 | ERREXIT(cinfo, JERR_BAD_LENGTH); |
| 596 | 596 | |
| r14260 | r14261 | |
| 887 | 887 | |
| 888 | 888 | INPUT_2BYTES(cinfo, length, return FALSE); |
| 889 | 889 | length -= 2; |
| 890 | ||
| 890 | ||
| 891 | 891 | TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); |
| 892 | 892 | |
| 893 | 893 | INPUT_SYNC(cinfo); /* do before skip_input_data */ |
| r14260 | r14261 | |
| 1059 | 1059 | return JPEG_SUSPENDED; |
| 1060 | 1060 | cinfo->unread_marker = 0; /* processed the marker */ |
| 1061 | 1061 | return JPEG_REACHED_SOS; |
| 1062 | ||
| 1062 | ||
| 1063 | 1063 | case M_EOI: |
| 1064 | 1064 | TRACEMS(cinfo, 1, JTRC_EOI); |
| 1065 | 1065 | cinfo->unread_marker = 0; /* processed the marker */ |
| 1066 | 1066 | return JPEG_REACHED_EOI; |
| 1067 | ||
| 1067 | ||
| 1068 | 1068 | case M_DAC: |
| 1069 | 1069 | if (! get_dac(cinfo)) |
| 1070 | 1070 | return JPEG_SUSPENDED; |
| 1071 | 1071 | break; |
| 1072 | ||
| 1072 | ||
| 1073 | 1073 | case M_DHT: |
| 1074 | 1074 | if (! get_dht(cinfo)) |
| 1075 | 1075 | return JPEG_SUSPENDED; |
| 1076 | 1076 | break; |
| 1077 | ||
| 1077 | ||
| 1078 | 1078 | case M_DQT: |
| 1079 | 1079 | if (! get_dqt(cinfo)) |
| 1080 | 1080 | return JPEG_SUSPENDED; |
| 1081 | 1081 | break; |
| 1082 | ||
| 1082 | ||
| 1083 | 1083 | case M_DRI: |
| 1084 | 1084 | if (! get_dri(cinfo)) |
| 1085 | 1085 | return JPEG_SUSPENDED; |
| 1086 | 1086 | break; |
| 1087 | ||
| 1087 | ||
| 1088 | 1088 | case M_APP0: |
| 1089 | 1089 | case M_APP1: |
| 1090 | 1090 | case M_APP2: |
| r14260 | r14261 | |
| 1105 | 1105 | cinfo->unread_marker - (int) M_APP0]) (cinfo)) |
| 1106 | 1106 | return JPEG_SUSPENDED; |
| 1107 | 1107 | break; |
| 1108 | ||
| 1108 | ||
| 1109 | 1109 | case M_COM: |
| 1110 | 1110 | if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) |
| 1111 | 1111 | return JPEG_SUSPENDED; |
| r14260 | r14261 | |
| 1239 | 1239 | { |
| 1240 | 1240 | int marker = cinfo->unread_marker; |
| 1241 | 1241 | int action = 1; |
| 1242 | ||
| 1242 | ||
| 1243 | 1243 | /* Always put up a warning. */ |
| 1244 | 1244 | WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); |
| 1245 | ||
| 1245 | ||
| 1246 | 1246 | /* Outer loop handles repeated decision after scanning forward. */ |
| 1247 | 1247 | for (;;) { |
| 1248 | 1248 | if (marker < (int) M_SOF0) |
| r14260 | r14261 | |
|---|---|---|
| 95 | 95 | * With typical images and quantization tables, half or more of the |
| 96 | 96 | * column DCT calculations can be simplified this way. |
| 97 | 97 | */ |
| 98 | ||
| 98 | ||
| 99 | 99 | if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && |
| 100 | 100 | inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && |
| 101 | 101 | inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && |
| 102 | 102 | inptr[DCTSIZE*7] == 0) { |
| 103 | 103 | /* AC terms all zero */ |
| 104 | 104 | FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
| 105 | ||
| 105 | ||
| 106 | 106 | wsptr[DCTSIZE*0] = dcval; |
| 107 | 107 | wsptr[DCTSIZE*1] = dcval; |
| 108 | 108 | wsptr[DCTSIZE*2] = dcval; |
| r14260 | r14261 | |
| 111 | 111 | wsptr[DCTSIZE*5] = dcval; |
| 112 | 112 | wsptr[DCTSIZE*6] = dcval; |
| 113 | 113 | wsptr[DCTSIZE*7] = dcval; |
| 114 | ||
| 114 | ||
| 115 | 115 | inptr++; /* advance pointers to next column */ |
| 116 | 116 | quantptr++; |
| 117 | 117 | wsptr++; |
| 118 | 118 | continue; |
| 119 | 119 | } |
| 120 | ||
| 120 | ||
| 121 | 121 | /* Even part */ |
| 122 | 122 | |
| 123 | 123 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
| r14260 | r14261 | |
| 135 | 135 | tmp3 = tmp10 - tmp13; |
| 136 | 136 | tmp1 = tmp11 + tmp12; |
| 137 | 137 | tmp2 = tmp11 - tmp12; |
| 138 | ||
| 138 | ||
| 139 | 139 | /* Odd part */ |
| 140 | 140 | |
| 141 | 141 | tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
| r14260 | r14261 | |
| 172 | 172 | quantptr++; |
| 173 | 173 | wsptr++; |
| 174 | 174 | } |
| 175 | ||
| 175 | ||
| 176 | 176 | /* Pass 2: process rows from work array, store into output array. */ |
| 177 | 177 | |
| 178 | 178 | wsptr = workspace; |
| r14260 | r14261 | |
| 183 | 183 | * the simplification applies less often (typically 5% to 10% of the time). |
| 184 | 184 | * And testing floats for zero is relatively expensive, so we don't bother. |
| 185 | 185 | */ |
| 186 | ||
| 186 | ||
| 187 | 187 | /* Even part */ |
| 188 | 188 | |
| 189 | 189 | /* Apply signed->unsigned and prepare float->int conversion */ |
| r14260 | r14261 | |
| 227 | 227 | outptr[5] = range_limit[((int) (tmp2 - tmp5)) & RANGE_MASK]; |
| 228 | 228 | outptr[3] = range_limit[((int) (tmp3 + tmp4)) & RANGE_MASK]; |
| 229 | 229 | outptr[4] = range_limit[((int) (tmp3 - tmp4)) & RANGE_MASK]; |
| 230 | ||
| 230 | ||
| 231 | 231 | wsptr += DCTSIZE; /* advance pointer to next row */ |
| 232 | 232 | } |
| 233 | 233 | } |
| r14260 | r14261 | |
|---|---|---|
| 315 | 315 | xindex = 0; |
| 316 | 316 | } |
| 317 | 317 | /* Fill in any dummy blocks needed in this row. |
| 318 | * Dummy blocks are filled in the same way as in jccoefct.c: | |
| 319 | * all zeroes in the AC entries, DC entries equal to previous | |
| 320 | * block's DC value. The init routine has already zeroed the | |
| 321 | * AC entries, so we need only set the DC entries correctly. | |
| 322 | */ | |
| 318 | * Dummy blocks are filled in the same way as in jccoefct.c: | |
| 319 | * all zeroes in the AC entries, DC entries equal to previous | |
| 320 | * block's DC value. The init routine has already zeroed the | |
| 321 | * AC entries, so we need only set the DC entries correctly. | |
| 322 | */ | |
| 323 | 323 | for (; xindex < compptr->MCU_width; xindex++) { |
| 324 | 324 | MCU_buffer[blkn] = coef->dummy_buffer[blkn]; |
| 325 | 325 | MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; |
| r14260 | r14261 | |
|---|---|---|
| 225 | 225 | |
| 226 | 226 | /* Even part: reverse the even part of the forward DCT. */ |
| 227 | 227 | /* The rotator is sqrt(2)*c(-6). */ |
| 228 | ||
| 228 | ||
| 229 | 229 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
| 230 | 230 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
| 231 | 231 | |
| r14260 | r14261 | |
| 256 | 256 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
| 257 | 257 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
| 258 | 258 | tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
| 259 | ||
| 259 | ||
| 260 | 260 | z2 = tmp0 + tmp2; |
| 261 | 261 | z3 = tmp1 + tmp3; |
| 262 | 262 | |
| r14260 | r14261 | |
| 288 | 288 | wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); |
| 289 | 289 | wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); |
| 290 | 290 | wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); |
| 291 | ||
| 291 | ||
| 292 | 292 | inptr++; /* advance pointers to next column */ |
| 293 | 293 | quantptr++; |
| 294 | 294 | wsptr++; |
| r14260 | r14261 | |
| 332 | 332 | |
| 333 | 333 | /* Even part: reverse the even part of the forward DCT. */ |
| 334 | 334 | /* The rotator is sqrt(2)*c(-6). */ |
| 335 | ||
| 335 | ||
| 336 | 336 | z2 = (INT32) wsptr[2]; |
| 337 | 337 | z3 = (INT32) wsptr[6]; |
| 338 | 338 | |
| r14260 | r14261 | |
| 346 | 346 | |
| 347 | 347 | tmp0 = (z2 + z3) << CONST_BITS; |
| 348 | 348 | tmp1 = (z2 - z3) << CONST_BITS; |
| 349 | ||
| 349 | ||
| 350 | 350 | tmp10 = tmp0 + tmp2; |
| 351 | 351 | tmp13 = tmp0 - tmp2; |
| 352 | 352 | tmp11 = tmp1 + tmp3; |
| r14260 | r14261 | |
| 835 | 835 | |
| 836 | 836 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
| 837 | 837 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
| 838 | ||
| 838 | ||
| 839 | 839 | tmp10 = (tmp0 + tmp2) << PASS1_BITS; |
| 840 | 840 | tmp12 = (tmp0 - tmp2) << PASS1_BITS; |
| 841 | 841 | |
| r14260 | r14261 | |
| 2851 | 2851 | * With typical images and quantization tables, half or more of the |
| 2852 | 2852 | * column DCT calculations can be simplified this way. |
| 2853 | 2853 | */ |
| 2854 | ||
| 2854 | ||
| 2855 | 2855 | if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && |
| 2856 | 2856 | inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && |
| 2857 | 2857 | inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && |
| 2858 | 2858 | inptr[DCTSIZE*7] == 0) { |
| 2859 | 2859 | /* AC terms all zero */ |
| 2860 | 2860 | int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; |
| 2861 | ||
| 2861 | ||
| 2862 | 2862 | wsptr[DCTSIZE*0] = dcval; |
| 2863 | 2863 | wsptr[DCTSIZE*1] = dcval; |
| 2864 | 2864 | wsptr[DCTSIZE*2] = dcval; |
| r14260 | r14261 | |
| 2867 | 2867 | wsptr[DCTSIZE*5] = dcval; |
| 2868 | 2868 | wsptr[DCTSIZE*6] = dcval; |
| 2869 | 2869 | wsptr[DCTSIZE*7] = dcval; |
| 2870 | ||
| 2870 | ||
| 2871 | 2871 | inptr++; /* advance pointers to next column */ |
| 2872 | 2872 | quantptr++; |
| 2873 | 2873 | wsptr++; |
| 2874 | 2874 | continue; |
| 2875 | 2875 | } |
| 2876 | ||
| 2876 | ||
| 2877 | 2877 | /* Even part: reverse the even part of the forward DCT. */ |
| 2878 | 2878 | /* The rotator is sqrt(2)*c(-6). */ |
| 2879 | ||
| 2879 | ||
| 2880 | 2880 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
| 2881 | 2881 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
| 2882 | ||
| 2882 | ||
| 2883 | 2883 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); |
| 2884 | 2884 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); |
| 2885 | 2885 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); |
| 2886 | ||
| 2886 | ||
| 2887 | 2887 | z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
| 2888 | 2888 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
| 2889 | 2889 | z2 <<= CONST_BITS; |
| r14260 | r14261 | |
| 2893 | 2893 | |
| 2894 | 2894 | tmp0 = z2 + z3; |
| 2895 | 2895 | tmp1 = z2 - z3; |
| 2896 | ||
| 2896 | ||
| 2897 | 2897 | tmp10 = tmp0 + tmp2; |
| 2898 | 2898 | tmp13 = tmp0 - tmp2; |
| 2899 | 2899 | tmp11 = tmp1 + tmp3; |
| 2900 | 2900 | tmp12 = tmp1 - tmp3; |
| 2901 | ||
| 2901 | ||
| 2902 | 2902 | /* Odd part per figure 8; the matrix is unitary and hence its |
| 2903 | 2903 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
| 2904 | 2904 | */ |
| 2905 | ||
| 2905 | ||
| 2906 | 2906 | tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); |
| 2907 | 2907 | tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); |
| 2908 | 2908 | tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); |
| 2909 | 2909 | tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); |
| 2910 | ||
| 2910 | ||
| 2911 | 2911 | z2 = tmp0 + tmp2; |
| 2912 | 2912 | z3 = tmp1 + tmp3; |
| 2913 | 2913 | |
| r14260 | r14261 | |
| 2928 | 2928 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ |
| 2929 | 2929 | tmp1 += z1 + z3; |
| 2930 | 2930 | tmp2 += z1 + z2; |
| 2931 | ||
| 2931 | ||
| 2932 | 2932 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
| 2933 | ||
| 2933 | ||
| 2934 | 2934 | wsptr[DCTSIZE*0] = (int) RIGHT_SHIFT(tmp10 + tmp3, CONST_BITS-PASS1_BITS); |
| 2935 | 2935 | wsptr[DCTSIZE*7] = (int) RIGHT_SHIFT(tmp10 - tmp3, CONST_BITS-PASS1_BITS); |
| 2936 | 2936 | wsptr[DCTSIZE*1] = (int) RIGHT_SHIFT(tmp11 + tmp2, CONST_BITS-PASS1_BITS); |
| r14260 | r14261 | |
| 2939 | 2939 | wsptr[DCTSIZE*5] = (int) RIGHT_SHIFT(tmp12 - tmp1, CONST_BITS-PASS1_BITS); |
| 2940 | 2940 | wsptr[DCTSIZE*3] = (int) RIGHT_SHIFT(tmp13 + tmp0, CONST_BITS-PASS1_BITS); |
| 2941 | 2941 | wsptr[DCTSIZE*4] = (int) RIGHT_SHIFT(tmp13 - tmp0, CONST_BITS-PASS1_BITS); |
| 2942 | ||
| 2942 | ||
| 2943 | 2943 | inptr++; /* advance pointers to next column */ |
| 2944 | 2944 | quantptr++; |
| 2945 | 2945 | wsptr++; |
| r14260 | r14261 | |
| 3688 | 3688 | |
| 3689 | 3689 | z2 = (INT32) wsptr[2]; |
| 3690 | 3690 | z3 = (INT32) wsptr[6]; |
| 3691 | ||
| 3691 | ||
| 3692 | 3692 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); |
| 3693 | 3693 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); |
| 3694 | 3694 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); |
| 3695 | ||
| 3695 | ||
| 3696 | 3696 | /* Add fudge factor here for final descale. */ |
| 3697 | 3697 | z2 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
| 3698 | 3698 | z3 = (INT32) wsptr[4]; |
| 3699 | ||
| 3699 | ||
| 3700 | 3700 | tmp0 = (z2 + z3) << CONST_BITS; |
| 3701 | 3701 | tmp1 = (z2 - z3) << CONST_BITS; |
| 3702 | ||
| 3702 | ||
| 3703 | 3703 | tmp10 = tmp0 + tmp2; |
| 3704 | 3704 | tmp13 = tmp0 - tmp2; |
| 3705 | 3705 | tmp11 = tmp1 + tmp3; |
| r14260 | r14261 | |
| 3819 | 3819 | wsptr[6*2] = (int) RIGHT_SHIFT(tmp10 - tmp0, CONST_BITS-PASS1_BITS); |
| 3820 | 3820 | wsptr[6*1] = (int) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS); |
| 3821 | 3821 | } |
| 3822 | ||
| 3822 | ||
| 3823 | 3823 | /* Pass 2: process 3 rows from work array, store into output array. |
| 3824 | 3824 | * 6-point IDCT kernel, cK represents sqrt(2) * cos(K*pi/12). |
| 3825 | 3825 | */ |
| r14260 | r14261 | |
| 4134 | 4134 | wsptr[8*7] = (int) RIGHT_SHIFT(tmp27 + tmp13, CONST_BITS-PASS1_BITS); |
| 4135 | 4135 | wsptr[8*8] = (int) RIGHT_SHIFT(tmp27 - tmp13, CONST_BITS-PASS1_BITS); |
| 4136 | 4136 | } |
| 4137 | ||
| 4137 | ||
| 4138 | 4138 | /* Pass 2: process rows from work array, store into output array. */ |
| 4139 | 4139 | /* Note that we must descale the results by a factor of 8 == 2**3, */ |
| 4140 | 4140 | /* and also undo the PASS1_BITS scaling. */ |
| r14260 | r14261 | |
| 4142 | 4142 | wsptr = workspace; |
| 4143 | 4143 | for (ctr = 0; ctr < 16; ctr++) { |
| 4144 | 4144 | outptr = output_buf[ctr] + output_col; |
| 4145 | ||
| 4145 | ||
| 4146 | 4146 | /* Even part: reverse the even part of the forward DCT. */ |
| 4147 | 4147 | /* The rotator is sqrt(2)*c(-6). */ |
| 4148 | ||
| 4148 | ||
| 4149 | 4149 | z2 = (INT32) wsptr[2]; |
| 4150 | 4150 | z3 = (INT32) wsptr[6]; |
| 4151 | ||
| 4151 | ||
| 4152 | 4152 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); |
| 4153 | 4153 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); |
| 4154 | 4154 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); |
| 4155 | ||
| 4155 | ||
| 4156 | 4156 | /* Add fudge factor here for final descale. */ |
| 4157 | 4157 | z2 = (INT32) wsptr[0] + (ONE << (PASS1_BITS+2)); |
| 4158 | 4158 | z3 = (INT32) wsptr[4]; |
| 4159 | ||
| 4159 | ||
| 4160 | 4160 | tmp0 = (z2 + z3) << CONST_BITS; |
| 4161 | 4161 | tmp1 = (z2 - z3) << CONST_BITS; |
| 4162 | ||
| 4162 | ||
| 4163 | 4163 | tmp10 = tmp0 + tmp2; |
| 4164 | 4164 | tmp13 = tmp0 - tmp2; |
| 4165 | 4165 | tmp11 = tmp1 + tmp3; |
| 4166 | 4166 | tmp12 = tmp1 - tmp3; |
| 4167 | ||
| 4167 | ||
| 4168 | 4168 | /* Odd part per figure 8; the matrix is unitary and hence its |
| 4169 | 4169 | * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. |
| 4170 | 4170 | */ |
| 4171 | ||
| 4171 | ||
| 4172 | 4172 | tmp0 = (INT32) wsptr[7]; |
| 4173 | 4173 | tmp1 = (INT32) wsptr[5]; |
| 4174 | 4174 | tmp2 = (INT32) wsptr[3]; |
| 4175 | 4175 | tmp3 = (INT32) wsptr[1]; |
| 4176 | ||
| 4176 | ||
| 4177 | 4177 | z2 = tmp0 + tmp2; |
| 4178 | 4178 | z3 = tmp1 + tmp3; |
| 4179 | 4179 | |
| r14260 | r14261 | |
| 4194 | 4194 | tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ |
| 4195 | 4195 | tmp1 += z1 + z3; |
| 4196 | 4196 | tmp2 += z1 + z2; |
| 4197 | ||
| 4197 | ||
| 4198 | 4198 | /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ |
| 4199 | ||
| 4199 | ||
| 4200 | 4200 | outptr[0] = range_limit[(int) RIGHT_SHIFT(tmp10 + tmp3, |
| 4201 | 4201 | CONST_BITS+PASS1_BITS+3) |
| 4202 | 4202 | & RANGE_MASK]; |
| r14260 | r14261 | |
| 4221 | 4221 | outptr[4] = range_limit[(int) RIGHT_SHIFT(tmp13 - tmp0, |
| 4222 | 4222 | CONST_BITS+PASS1_BITS+3) |
| 4223 | 4223 | & RANGE_MASK]; |
| 4224 | ||
| 4224 | ||
| 4225 | 4225 | wsptr += DCTSIZE; /* advance pointer to next row */ |
| 4226 | 4226 | } |
| 4227 | 4227 | } |
| r14260 | r14261 | |
| 4794 | 4794 | |
| 4795 | 4795 | z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); |
| 4796 | 4796 | z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); |
| 4797 | ||
| 4797 | ||
| 4798 | 4798 | z1 = MULTIPLY(z2 + z3, FIX_0_541196100); |
| 4799 | 4799 | tmp2 = z1 + MULTIPLY(z2, FIX_0_765366865); |
| 4800 | 4800 | tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); |
| 4801 | ||
| 4801 | ||
| 4802 | 4802 | z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); |
| 4803 | 4803 | z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); |
| 4804 | 4804 | z2 <<= CONST_BITS; |
| r14260 | r14261 | |
| 4808 | 4808 | |
| 4809 | 4809 | tmp0 = z2 + z3; |
| 4810 | 4810 | tmp1 = z2 - z3; |
| 4811 | ||
| 4811 | ||
| 4812 | 4812 | tmp10 = tmp0 + tmp2; |
| 4813 | 4813 | tmp13 = tmp0 - tmp2; |
| 4814 | 4814 | tmp11 = tmp1 + tmp3; |
| r14260 | r14261 | |
| 4900 | 4900 | outptr[2] = range_limit[(int) RIGHT_SHIFT(tmp12 - tmp2, |
| 4901 | 4901 | CONST_BITS+PASS1_BITS+3) |
| 4902 | 4902 | & RANGE_MASK]; |
| 4903 | ||
| 4903 | ||
| 4904 | 4904 | wsptr += 4; /* advance pointer to next row */ |
| 4905 | 4905 | } |
| 4906 | 4906 | } |
| r14260 | r14261 | |
| 5116 | 5116 | quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; |
| 5117 | 5117 | |
| 5118 | 5118 | /* Even part */ |
| 5119 | ||
| 5119 | ||
| 5120 | 5120 | tmp10 = DEQUANTIZE(coef_block[DCTSIZE*0], quantptr[DCTSIZE*0]); |
| 5121 | 5121 | /* Add fudge factor here for final descale. */ |
| 5122 | 5122 | tmp10 += ONE << 2; |
| r14260 | r14261 | |
|---|---|---|
| 378 | 378 | jvirt_barray_ptr * dst_coef_arrays; |
| 379 | 379 | int file_index; |
| 380 | 380 | /* We assume all-in-memory processing and can therefore use only a |
| 381 | * single file pointer for sequential input and output operation. | |
| 381 | * single file pointer for sequential input and output operation. | |
| 382 | 382 | */ |
| 383 | 383 | FILE * fp; |
| 384 | 384 |
| r14260 | r14261 | |
|---|---|---|
| 391 | 391 | { |
| 392 | 392 | int ci, mcublks, tmp; |
| 393 | 393 | jpeg_component_info *compptr; |
| 394 | ||
| 394 | ||
| 395 | 395 | if (cinfo->comps_in_scan == 1) { |
| 396 | ||
| 396 | ||
| 397 | 397 | /* Noninterleaved (single-component) scan */ |
| 398 | 398 | compptr = cinfo->cur_comp_info[0]; |
| 399 | ||
| 399 | ||
| 400 | 400 | /* Overall image size in MCUs */ |
| 401 | 401 | cinfo->MCUs_per_row = compptr->width_in_blocks; |
| 402 | 402 | cinfo->MCU_rows_in_scan = compptr->height_in_blocks; |
| 403 | ||
| 403 | ||
| 404 | 404 | /* For noninterleaved scan, always one block per MCU */ |
| 405 | 405 | compptr->MCU_width = 1; |
| 406 | 406 | compptr->MCU_height = 1; |
| r14260 | r14261 | |
| 413 | 413 | tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); |
| 414 | 414 | if (tmp == 0) tmp = compptr->v_samp_factor; |
| 415 | 415 | compptr->last_row_height = tmp; |
| 416 | ||
| 416 | ||
| 417 | 417 | /* Prepare array describing MCU composition */ |
| 418 | 418 | cinfo->blocks_in_MCU = 1; |
| 419 | 419 | cinfo->MCU_membership[0] = 0; |
| 420 | ||
| 420 | ||
| 421 | 421 | } else { |
| 422 | ||
| 422 | ||
| 423 | 423 | /* Interleaved (multi-component) scan */ |
| 424 | 424 | if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) |
| 425 | 425 | ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, |
| 426 | 426 | MAX_COMPS_IN_SCAN); |
| 427 | ||
| 427 | ||
| 428 | 428 | /* Overall image size in MCUs */ |
| 429 | 429 | cinfo->MCUs_per_row = (JDIMENSION) |
| 430 | 430 | jdiv_round_up((long) cinfo->image_width, |
| r14260 | r14261 | |
| 432 | 432 | cinfo->MCU_rows_in_scan = (JDIMENSION) |
| 433 | 433 | jdiv_round_up((long) cinfo->image_height, |
| 434 | 434 | (long) (cinfo->max_v_samp_factor * cinfo->block_size)); |
| 435 | ||
| 435 | ||
| 436 | 436 | cinfo->blocks_in_MCU = 0; |
| 437 | ||
| 437 | ||
| 438 | 438 | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
| 439 | 439 | compptr = cinfo->cur_comp_info[ci]; |
| 440 | 440 | /* Sampling factors give # of blocks of component in each MCU */ |
| r14260 | r14261 | |
| 457 | 457 | cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; |
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | ||
| 460 | ||
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | |
| r14260 | r14261 | |
| 578 | 578 | } |
| 579 | 579 | inputctl->inheaders = 0; |
| 580 | 580 | /* Note: start_input_pass must be called by jdmaster.c |
| 581 | * before any more input can be consumed. jdapimin.c is | |
| 582 | * responsible for enforcing this sequencing. | |
| 583 | */ | |
| 581 | * before any more input can be consumed. jdapimin.c is | |
| 582 | * responsible for enforcing this sequencing. | |
| 583 | */ | |
| 584 | 584 | } else { /* 2nd or later SOS marker */ |
| 585 | 585 | if (! inputctl->pub.has_multiple_scans) |
| 586 | 586 | ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ |
| r14260 | r14261 | |
| 596 | 596 | ERREXIT(cinfo, JERR_SOF_NO_SOS); |
| 597 | 597 | } else { |
| 598 | 598 | /* Prevent infinite loop in coef ctlr's decompress_data routine |
| 599 | * if user set output_scan_number larger than number of scans. | |
| 600 | */ | |
| 599 | * if user set output_scan_number larger than number of scans. | |
| 600 | */ | |
| 601 | 601 | if (cinfo->output_scan_number > cinfo->input_scan_number) |
| 602 | 602 | cinfo->output_scan_number = cinfo->input_scan_number; |
| 603 | 603 | } |
| r14260 | r14261 | |
|---|---|---|
| 14 | 14 | * (ie, box filtering), we can save some work in color conversion by |
| 15 | 15 | * calculating all the output pixels corresponding to a pair of chroma |
| 16 | 16 | * samples at one time. In the conversion equations |
| 17 | * R = Y + K1 * Cr | |
| 18 | * G = Y + K2 * Cb + K3 * Cr | |
| 19 | * B = Y + K4 * Cb | |
| 17 | * R = Y + K1 * Cr | |
| 18 | * G = Y + K2 * Cb + K3 * Cr | |
| 19 | * B = Y + K4 * Cb | |
| 20 | 20 | * only the Y term varies among the group of pixels corresponding to a pair |
| 21 | 21 | * of chroma samples, so the rest of the terms can be calculated just once. |
| 22 | 22 | * At typical sampling ratios, this eliminates half or three-quarters of the |
| 23 | 23 | * multiplications needed for color conversion. |
| 24 | 24 | * |
| 25 | 25 | * This file currently provides implementations for the following cases: |
| 26 | * YCbCr => RGB color conversion only. | |
| 27 | * Sampling ratios of 2h1v or 2h2v. | |
| 28 | * No scaling needed at upsample time. | |
| 29 | * Corner-aligned (non-CCIR601) sampling alignment. | |
| 26 | * YCbCr => RGB color conversion only. | |
| 27 | * Sampling ratios of 2h1v or 2h2v. | |
| 28 | * No scaling needed at upsample time. | |
| 29 | * Corner-aligned (non-CCIR601) sampling alignment. | |
| 30 | 30 | * Other special cases could be added, but in most applications these are |
| 31 | 31 | * the only common cases. (For uncommon cases we fall back on the more |
| 32 | 32 | * general code in jdsample.c and jdcolor.c.) |
| r14260 | r14261 | |
|---|---|---|
| 568 | 568 | DC9 = (int) next_block_row[1][0]; |
| 569 | 569 | } |
| 570 | 570 | /* Compute coefficient estimates per K.8. |
| 571 | * An estimate is applied only if coefficient is still zero, | |
| 572 | * and is not known to be fully accurate. | |
| 573 | */ | |
| 571 | * An estimate is applied only if coefficient is still zero, | |
| 572 | * and is not known to be fully accurate. | |
| 573 | */ | |
| 574 | 574 | /* AC01 */ |
| 575 | 575 | if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { |
| 576 | 576 | num = 36 * Q00 * (DC4 - DC6); |
| r14260 | r14261 | |
|---|---|---|
| 137 | 137 | /* The decompressor output side may not use these variables. */ |
| 138 | 138 | int dc_tbl_no; /* DC entropy table selector (0..3) */ |
| 139 | 139 | int ac_tbl_no; /* AC entropy table selector (0..3) */ |
| 140 | ||
| 140 | ||
| 141 | 141 | /* Remaining fields should be treated as private by applications. */ |
| 142 | ||
| 142 | ||
| 143 | 143 | /* These values are computed during compression or decompression startup: */ |
| 144 | 144 | /* Component's size in DCT blocks. |
| 145 | 145 | * Any dummy blocks added to complete an MCU are not counted; therefore |
| r14260 | r14261 | |
| 369 | 369 | UINT16 X_density; /* Horizontal pixel density */ |
| 370 | 370 | UINT16 Y_density; /* Vertical pixel density */ |
| 371 | 371 | boolean write_Adobe_marker; /* should an Adobe marker be written? */ |
| 372 | ||
| 372 | ||
| 373 | 373 | /* State variable: index of next scanline to be written to |
| 374 | 374 | * jpeg_write_scanlines(). Application may use this to control its |
| 375 | 375 | * processing loop, e.g., "while (next_scanline < image_height)". |
| r14260 | r14261 | |
| 397 | 397 | * There are v_samp_factor * DCTSIZE sample rows of each component in an |
| 398 | 398 | * "iMCU" (interleaved MCU) row. |
| 399 | 399 | */ |
| 400 | ||
| 400 | ||
| 401 | 401 | /* |
| 402 | 402 | * These fields are valid during any one scan. |
| 403 | 403 | * They describe the components and MCUs actually appearing in the scan. |
| r14260 | r14261 | |
| 405 | 405 | int comps_in_scan; /* # of JPEG components in this scan */ |
| 406 | 406 | jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; |
| 407 | 407 | /* *cur_comp_info[i] describes component that appears i'th in SOS */ |
| 408 | ||
| 408 | ||
| 409 | 409 | JDIMENSION MCUs_per_row; /* # of MCUs across the image */ |
| 410 | 410 | JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ |
| 411 | ||
| 411 | ||
| 412 | 412 | int blocks_in_MCU; /* # of DCT blocks per MCU */ |
| 413 | 413 | int MCU_membership[C_MAX_BLOCKS_IN_MCU]; |
| 414 | 414 | /* MCU_membership[i] is index in cur_comp_info of component owning */ |
| r14260 | r14261 | |
| 691 | 691 | #define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ |
| 692 | 692 | /* Reset error state variables at start of a new image */ |
| 693 | 693 | JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); |
| 694 | ||
| 694 | ||
| 695 | 695 | /* The message ID code and any parameters are saved here. |
| 696 | 696 | * A message can have one string parameter or up to 8 int parameters. |
| 697 | 697 | */ |
| r14260 | r14261 | |
| 701 | 701 | int i[8]; |
| 702 | 702 | char s[JMSG_STR_PARM_MAX]; |
| 703 | 703 | } msg_parm; |
| 704 | ||
| 704 | ||
| 705 | 705 | /* Standard state variables for error facility */ |
| 706 | ||
| 706 | ||
| 707 | 707 | int trace_level; /* max msg_level that will be displayed */ |
| 708 | ||
| 708 | ||
| 709 | 709 | /* For recoverable corrupt-data errors, we emit a warning message, |
| 710 | 710 | * but keep going unless emit_message chooses to abort. emit_message |
| 711 | 711 | * should count warnings in num_warnings. The surrounding application |
| r14260 | r14261 | |
| 863 | 863 | /* Short forms of external names for systems with brain-damaged linkers. |
| 864 | 864 | * We shorten external names to be unique in the first six letters, which |
| 865 | 865 | * is good enough for all known systems. |
| 866 | * (If your compiler itself needs names to be unique in less than 15 | |
| 866 | * (If your compiler itself needs names to be unique in less than 15 | |
| 867 | 867 | * characters, you are out of luck. Get a better compiler.) |
| 868 | 868 | */ |
| 869 | 869 | |
| r14260 | r14261 | |
| 1049 | 1049 | EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); |
| 1050 | 1050 | EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); |
| 1051 | 1051 | /* Return value is one of: */ |
| 1052 | /* #define JPEG_SUSPENDED | |
| 1052 | /* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ | |
| 1053 | 1053 | #define JPEG_REACHED_SOS 1 /* Reached start of new scan */ |
| 1054 | 1054 | #define JPEG_REACHED_EOI 2 /* Reached end of image */ |
| 1055 | 1055 | #define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ |
| r14260 | r14261 | |
|---|---|---|
| 125 | 125 | data = 0xFF; /* discard stuffed zero byte */ |
| 126 | 126 | else { |
| 127 | 127 | /* Note: Different from the Huffman decoder, hitting |
| 128 | * a marker while processing the compressed data | |
| 129 | * segment is legal in arithmetic coding. | |
| 130 | * The convention is to supply zero data | |
| 131 | * then until decoding is complete. | |
| 132 | */ | |
| 128 | * a marker while processing the compressed data | |
| 129 | * segment is legal in arithmetic coding. | |
| 130 | * The convention is to supply zero data | |
| 131 | * then until decoding is complete. | |
| 132 | */ | |
| 133 | 133 | cinfo->unread_marker = data; |
| 134 | 134 | data = 0; |
| 135 | 135 | } |
| r14260 | r14261 | |
| 765 | 765 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 766 | 766 | cinfo->num_components*DCTSIZE2*SIZEOF(int)); |
| 767 | 767 | coef_bit_ptr = & cinfo->coef_bits[0][0]; |
| 768 | for (ci = 0; ci < cinfo->num_components; ci++) | |
| 768 | for (ci = 0; ci < cinfo->num_components; ci++) | |
| 769 | 769 | for (i = 0; i < DCTSIZE2; i++) |
| 770 | 770 | *coef_bit_ptr++ = -1; |
| 771 | 771 | } |
| r14260 | r14261 | |
|---|---|---|
| 208 | 208 | if (main->pass_mode != JBUF_SAVE_SOURCE) { |
| 209 | 209 | if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { |
| 210 | 210 | /* If compressor did not consume the whole row, then we must need to |
| 211 | * suspend processing and return to the application. In this situation | |
| 212 | * we pretend we didn't yet consume the last input row; otherwise, if | |
| 213 | * it happened to be the last row of the image, the application would | |
| 214 | * think we were done. | |
| 215 | */ | |
| 211 | * suspend processing and return to the application. In this situation | |
| 212 | * we pretend we didn't yet consume the last input row; otherwise, if | |
| 213 | * it happened to be the last row of the image, the application would | |
| 214 | * think we were done. | |
| 215 | */ | |
| 216 | 216 | if (! main->suspended) { |
| 217 | 217 | (*in_row_ctr)--; |
| 218 | 218 | main->suspended = TRUE; |
| r14260 | r14261 | |
|---|---|---|
| 37 | 37 | if (version != JPEG_LIB_VERSION) |
| 38 | 38 | ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); |
| 39 | 39 | if (structsize != SIZEOF(struct jpeg_compress_struct)) |
| 40 | ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, | |
| 40 | ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, | |
| 41 | 41 | (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); |
| 42 | 42 | |
| 43 | 43 | /* For debugging purposes, we zero the whole master structure. |
| r14260 | r14261 | |
| 244 | 244 | * To produce a pair of files containing abbreviated tables and abbreviated |
| 245 | 245 | * image data, one would proceed as follows: |
| 246 | 246 | * |
| 247 | * initialize JPEG object | |
| 248 | * set JPEG parameters | |
| 249 | * set destination to table file | |
| 250 | * jpeg_write_tables(cinfo); | |
| 251 | * set destination to image file | |
| 252 | * jpeg_start_compress(cinfo, FALSE); | |
| 253 | * write data... | |
| 254 | * jpeg_finish_compress(cinfo); | |
| 247 | * initialize JPEG object | |
| 248 | * set JPEG parameters | |
| 249 | * set destination to table file | |
| 250 | * jpeg_write_tables(cinfo); | |
| 251 | * set destination to image file | |
| 252 | * jpeg_start_compress(cinfo, FALSE); | |
| 253 | * write data... | |
| 254 | * jpeg_finish_compress(cinfo); | |
| 255 | 255 | * |
| 256 | 256 | * jpeg_write_tables has the side effect of marking all tables written |
| 257 | 257 | * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress |
| r14260 | r14261 | |
|---|---|---|
| 37 | 37 | if (version != JPEG_LIB_VERSION) |
| 38 | 38 | ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); |
| 39 | 39 | if (structsize != SIZEOF(struct jpeg_decompress_struct)) |
| 40 | ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, | |
| 40 | ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, | |
| 41 | 41 | (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); |
| 42 | 42 | |
| 43 | 43 | /* For debugging purposes, we zero the whole master structure. |
| r14260 | r14261 | |
| 122 | 122 | cinfo->jpeg_color_space = JCS_GRAYSCALE; |
| 123 | 123 | cinfo->out_color_space = JCS_GRAYSCALE; |
| 124 | 124 | break; |
| 125 | ||
| 125 | ||
| 126 | 126 | case 3: |
| 127 | 127 | if (cinfo->saw_JFIF_marker) { |
| 128 | 128 | cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ |
| r14260 | r14261 | |
| 157 | 157 | /* Always guess RGB is proper output colorspace. */ |
| 158 | 158 | cinfo->out_color_space = JCS_RGB; |
| 159 | 159 | break; |
| 160 | ||
| 160 | ||
| 161 | 161 | case 4: |
| 162 | 162 | if (cinfo->saw_Adobe_marker) { |
| 163 | 163 | switch (cinfo->Adobe_transform) { |
| r14260 | r14261 | |
| 178 | 178 | } |
| 179 | 179 | cinfo->out_color_space = JCS_CMYK; |
| 180 | 180 | break; |
| 181 | ||
| 181 | ||
| 182 | 182 | default: |
| 183 | 183 | cinfo->jpeg_color_space = JCS_UNKNOWN; |
| 184 | 184 | cinfo->out_color_space = JCS_UNKNOWN; |
| r14260 | r14261 | |
|---|---|---|
| 34 | 34 | * YCbCr is defined per CCIR 601-1, except that Cb and Cr are |
| 35 | 35 | * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. |
| 36 | 36 | * The conversion equations to be implemented are therefore |
| 37 | * R = Y + 1.40200 * Cr | |
| 38 | * G = Y - 0.34414 * Cb - 0.71414 * Cr | |
| 39 | * B = Y + 1.77200 * Cb | |
| 37 | * R = Y + 1.40200 * Cr | |
| 38 | * G = Y - 0.34414 * Cb - 0.71414 * Cr | |
| 39 | * B = Y + 1.77200 * Cb | |
| 40 | 40 | * where Cb and Cr represent the incoming values less CENTERJSAMPLE. |
| 41 | 41 | * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) |
| 42 | 42 | * |
| r14260 | r14261 | |
|---|---|---|
| 90 | 90 | qval = divisors[i]; |
| 91 | 91 | temp = workspace[i]; |
| 92 | 92 | /* Divide the coefficient value by qval, ensuring proper rounding. |
| 93 | * Since C does not specify the direction of rounding for negative | |
| 94 | * quotients, we have to force the dividend positive for portability. | |
| 95 | * | |
| 96 | * In most files, at least half of the output values will be zero | |
| 97 | * (at default quantization settings, more like three-quarters...) | |
| 98 | * so we should ensure that this case is fast. On many machines, | |
| 99 | * a comparison is enough cheaper than a divide to make a special test | |
| 100 | * a win. Since both inputs will be nonnegative, we need only test | |
| 101 | * for a < b to discover whether a/b is 0. | |
| 102 | * If your machine's division is fast enough, define FAST_DIVIDE. | |
| 103 | */ | |
| 93 | * Since C does not specify the direction of rounding for negative | |
| 94 | * quotients, we have to force the dividend positive for portability. | |
| 95 | * | |
| 96 | * In most files, at least half of the output values will be zero | |
| 97 | * (at default quantization settings, more like three-quarters...) | |
| 98 | * so we should ensure that this case is fast. On many machines, | |
| 99 | * a comparison is enough cheaper than a divide to make a special test | |
| 100 | * a win. Since both inputs will be nonnegative, we need only test | |
| 101 | * for a < b to discover whether a/b is 0. | |
| 102 | * If your machine's division is fast enough, define FAST_DIVIDE. | |
| 103 | */ | |
| 104 | 104 | #ifdef FAST_DIVIDE |
| 105 | 105 | #define DIVIDE_BY(a,b) a /= b |
| 106 | 106 | #else |
| r14260 | r14261 | |
| 153 | 153 | /* Apply the quantization and scaling factor */ |
| 154 | 154 | temp = workspace[i] * divisors[i]; |
| 155 | 155 | /* Round to nearest integer. |
| 156 | * Since C does not specify the direction of rounding for negative | |
| 157 | * quotients, we have to force the dividend positive for portability. | |
| 158 | * The maximum coefficient size is +-16K (for 12-bit data), so this | |
| 159 | * code should work for either 16-bit or 32-bit ints. | |
| 160 | */ | |
| 156 | * Since C does not specify the direction of rounding for negative | |
| 157 | * quotients, we have to force the dividend positive for portability. | |
| 158 | * The maximum coefficient size is +-16K (for 12-bit data), so this | |
| 159 | * code should work for either 16-bit or 32-bit ints. | |
| 160 | */ | |
| 161 | 161 | output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); |
| 162 | 162 | } |
| 163 | 163 | } |
| r14260 | r14261 | |
| 376 | 376 | case JDCT_IFAST: |
| 377 | 377 | { |
| 378 | 378 | /* For AA&N IDCT method, divisors are equal to quantization |
| 379 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 380 | * scalefactor[0] = 1 | |
| 381 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 382 | * We apply a further scale factor of 8. | |
| 383 | */ | |
| 379 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 380 | * scalefactor[0] = 1 | |
| 381 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 382 | * We apply a further scale factor of 8. | |
| 383 | */ | |
| 384 | 384 | #define CONST_BITS 14 |
| 385 | 385 | static const INT16 aanscales[DCTSIZE2] = { |
| 386 | 386 | /* precomputed values scaled up by 14 bits */ |
| r14260 | r14261 | |
| 415 | 415 | case JDCT_FLOAT: |
| 416 | 416 | { |
| 417 | 417 | /* For float AA&N IDCT method, divisors are equal to quantization |
| 418 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 419 | * scalefactor[0] = 1 | |
| 420 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 421 | * We apply a further scale factor of 8. | |
| 422 | * What's actually stored is 1/divisor so that the inner loop can | |
| 423 | * use a multiplication rather than a division. | |
| 424 | */ | |
| 418 | * coefficients scaled by scalefactor[row]*scalefactor[col], where | |
| 419 | * scalefactor[0] = 1 | |
| 420 | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | |
| 421 | * We apply a further scale factor of 8. | |
| 422 | * What's actually stored is 1/divisor so that the inner loop can | |
| 423 | * use a multiplication rather than a division. | |
| 424 | */ | |
| 425 | 425 | FAST_FLOAT * fdtbl; |
| 426 | 426 | int row, col; |
| 427 | 427 | static const double aanscalefactor[DCTSIZE] = { |
| r14260 | r14261 | |
|---|---|---|
| 274 | 274 | #------------------------------------------------- |
| 275 | 275 | |
| 276 | 276 | FLACOPTS=-DFLAC__NO_ASM -DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 |
| 277 | ||
| 277 | ||
| 278 | 278 | LIBFLACOBJS = \ |
| 279 | 279 | $(LIBOBJ)/libflac/bitmath.o \ |
| 280 | 280 | $(LIBOBJ)/libflac/bitreader.o \ |
| r14260 | r14261 | |
|---|---|---|
| 2142 | 2142 | offset++; |
| 2143 | 2143 | } |
| 2144 | 2144 | for (secoff=0;secoff<CD_MAX_SUBCODE_DATA;secoff++) |
| 2145 | { | |
| 2145 | { | |
| 2146 | 2146 | if (src[offset]!=0x00) |
| 2147 | 2147 | is_likely_cd = false; |
| 2148 | 2148 | |
| r14260 | r14261 | |
| 2171 | 2171 | tempbytes = bytes; |
| 2172 | 2172 | temperror = err; |
| 2173 | 2173 | tempstrategy = 0; |
| 2174 | } | |
| 2174 | } | |
| 2175 | 2175 | |
| 2176 | 2176 | /* try strategy 1 - flac */ |
| 2177 | 2177 | if (chd->codecintf->secondary_compress != NULL) |
| 2178 | 2178 | { |
| 2179 | 2179 | strategy = 1; |
| 2180 | ||
| 2180 | ||
| 2181 | 2181 | err = (*chd->codecintf->secondary_compress)(chd, src, &bytes); |
| 2182 | 2182 | |
| 2183 | 2183 | /* check against previous compression attempt if that was successful */ |
| r14260 | r14261 | |
| 2217 | 2217 | { |
| 2218 | 2218 | data = chd->compressed; |
| 2219 | 2219 | newentry.length = bytes; |
| 2220 | ||
| 2220 | ||
| 2221 | 2221 | if (strategy == 0) |
| 2222 | 2222 | { |
| 2223 | 2223 | newentry.flags = MAP_ENTRY_TYPE_COMPRESSED; |
| r14260 | r14261 | |
| 3085 | 3085 | printf("ERROR: allocating encoder\n"); |
| 3086 | 3086 | return CHDERR_COMPRESSION_ERROR; |
| 3087 | 3087 | } |
| 3088 | ||
| 3088 | ||
| 3089 | 3089 | ok &= FLAC__stream_encoder_set_verify(encoder, false); // we trust libFLAC ;-) |
| 3090 | 3090 | ok &= FLAC__stream_encoder_set_compression_level(encoder, 8); |
| 3091 | 3091 | ok &= FLAC__stream_encoder_set_channels(encoder, 2); |
| r14260 | r14261 | |
| 3094 | 3094 | ok &= FLAC__stream_encoder_set_total_samples_estimate(encoder, 0); |
| 3095 | 3095 | ok &= FLAC__stream_encoder_set_streamable_subset(encoder, false); |
| 3096 | 3096 | ok &= FLAC__stream_encoder_set_blocksize(encoder, ((CD_MAX_SECTOR_DATA)*CD_FRAMES_PER_HUNK) ); |
| 3097 | ||
| 3097 | ||
| 3098 | 3098 | if (!ok) |
| 3099 | 3099 | { |
| 3100 | 3100 | printf("error setting up stream encoder\n"); |
| r14260 | r14261 | |
| 3121 | 3121 | if (!swap) flac_encoder_client_ptr->pcm[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)flac_encoder_client_ptr->tempbuffer[2*i] << 8) | (FLAC__int16)flac_encoder_client_ptr->tempbuffer[2*i+1]); |
| 3122 | 3122 | else flac_encoder_client_ptr->pcm[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)flac_encoder_client_ptr->tempbuffer[2*i+1] << 8) | (FLAC__int16)flac_encoder_client_ptr->tempbuffer[2*i]); |
| 3123 | 3123 | } |
| 3124 | ||
| 3124 | ||
| 3125 | 3125 | ok = FLAC__stream_encoder_process_interleaved(encoder, flac_encoder_client_ptr->pcm, FLAC_ENCODER_READSIZE); |
| 3126 | 3126 | } |
| 3127 | 3127 | |
| r14260 | r14261 | |
| 3142 | 3142 | printf("error finishing!\n"); |
| 3143 | 3143 | return CHDERR_COMPRESSION_ERROR; |
| 3144 | 3144 | } |
| 3145 | ||
| 3145 | ||
| 3146 | 3146 | int totalout = flac_encoder_client_ptr->flac_output_buffer_total-FLAC_HEADER_SIZE; |
| 3147 | 3147 | |
| 3148 | ||
| 3149 | 3148 | |
| 3149 | ||
| 3150 | 3150 | FLAC__stream_encoder_delete(encoder); |
| 3151 | 3151 | |
| 3152 | 3152 | if (totalout >= chd->header.hunkbytes) |
| r14260 | r14261 | |
| 3197 | 3197 | UINT64 amount_to_decode; |
| 3198 | 3198 | }; |
| 3199 | 3199 | |
| 3200 | FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) | |
| 3200 | FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) | |
| 3201 | 3201 | { |
| 3202 | ||
| 3202 | ||
| 3203 | 3203 | int blocksize = frame->header.blocksize; |
| 3204 | 3204 | int i = 0; |
| 3205 | 3205 | while (blocksize && ((flac_decoder_data*)client_data)->amount_to_decode) |
| r14260 | r14261 | |
| 3212 | 3212 | ((flac_decoder_data*)client_data)->amount_to_decode-=4; |
| 3213 | 3213 | ((flac_decoder_data*)client_data)->writeoffset++; |
| 3214 | 3214 | } |
| 3215 | ||
| 3215 | ||
| 3216 | 3216 | return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; |
| 3217 | 3217 | } |
| 3218 | 3218 | |
| r14260 | r14261 | |
| 3237 | 3237 | |
| 3238 | 3238 | |
| 3239 | 3239 | |
| 3240 | void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) | |
| 3240 | void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) | |
| 3241 | 3241 | { |
| 3242 | 3242 | |
| 3243 | 3243 | } |
| 3244 | 3244 | |
| 3245 | void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) | |
| 3245 | void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) | |
| 3246 | 3246 | { |
| 3247 | 3247 | |
| 3248 | 3248 | } |
| r14260 | r14261 | |
| 3259 | 3259 | flac_decoder_client_ptr->readbuffer = (UINT8*)malloc(flac_decoder_client_ptr->readbuffersize); |
| 3260 | 3260 | flac_decoder_client_ptr->amount_to_decode = (CD_MAX_SECTOR_DATA*CD_FRAMES_PER_HUNK); |
| 3261 | 3261 | int frames_to_decode = flac_decoder_client_ptr->amount_to_decode / CD_MAX_SECTOR_DATA; |
| 3262 | ||
| 3262 | ||
| 3263 | 3263 | flac_decoder_client_ptr->writeoffset = 0; |
| 3264 | 3264 | |
| 3265 | 3265 | memcpy(flac_decoder_client_ptr->readbuffer, flacHeader, FLAC_HEADER_SIZE); |
| r14260 | r14261 | |
| 3274 | 3274 | if(FLAC__stream_decoder_init_stream( |
| 3275 | 3275 | decoder, |
| 3276 | 3276 | flac_decoder_read_callback, |
| 3277 | NULL, | |
| 3278 | 3277 | NULL, |
| 3279 | 3278 | NULL, |
| 3280 | 3279 | NULL, |
| 3280 | NULL, | |
| 3281 | 3281 | flac_decoder_write_callback, |
| 3282 | 3282 | flac_decoder_metadata_callback, |
| 3283 | 3283 | flac_decoder_error_callback, |
| r14260 | r14261 | |
| 3300 | 3300 | return CHDERR_READ_ERROR; |
| 3301 | 3301 | } |
| 3302 | 3302 | |
| 3303 | ||
| 3303 | ||
| 3304 | 3304 | int srcoffset = 0; |
| 3305 | 3305 | UINT8* dest2 = (UINT8*)dest; |
| 3306 | 3306 | for (int frame = 0; frame<frames_to_decode;frame++) |
| 3307 | 3307 | { |
| 3308 | 3308 | int destoffset = frame * (CD_FRAME_SIZE); |
| 3309 | ||
| 3310 | 3309 | |
| 3310 | ||
| 3311 | 3311 | int index; |
| 3312 | 3312 | |
| 3313 | 3313 | for (index = 0; index < 2352; index += 2 ) |
| 3314 | 3314 | { |
| 3315 | 3315 | dest2[ destoffset + index +1 ] = flac_decoder_client_ptr->tempbuffer[srcoffset] & 0xff; |
| 3316 | 3316 | dest2[ destoffset + index ] = flac_decoder_client_ptr->tempbuffer[srcoffset] >> 8; |
| 3317 | ||
| 3317 | ||
| 3318 | 3318 | srcoffset++; |
| 3319 | 3319 | } |
| 3320 | 3320 | } |
| 3321 | ||
| 3322 | 3321 | |
| 3322 | ||
| 3323 | 3323 | if (FLAC__stream_decoder_finish (decoder) != true) |
| 3324 | 3324 | { |
| 3325 | 3325 | printf("unable to finish FLAC decoder\n"); |
| r14260 | r14261 | |
|---|---|---|
| 56 | 56 | #define CD_MAX_SUBCODE_DATA (96) |
| 57 | 57 | |
| 58 | 58 | #define CD_FRAME_SIZE (CD_MAX_SECTOR_DATA + CD_MAX_SUBCODE_DATA) |
| 59 | #define CD_FRAMES_PER_HUNK ( | |
| 59 | #define CD_FRAMES_PER_HUNK (4) // should be 8 for v5 CDs, with a 4-frame pad at the end to maintain SHA1 compatibility | |
| 60 | 60 | |
| 61 | 61 | #define CD_METADATA_WORDS (1+(CD_MAX_TRACKS * 6)) |
| 62 | 62 |
| r14260 | r14261 | |
|---|---|---|
| 78 | 78 | class entry_t |
| 79 | 79 | { |
| 80 | 80 | friend class tagmap_t<_ElementType, _HashSize>; |
| 81 | ||
| 81 | ||
| 82 | 82 | public: |
| 83 | 83 | // construction/destruction |
| 84 | 84 | entry_t(const char *tag, UINT32 fullhash, _ElementType object) |
| r14260 | r14261 | |
| 86 | 86 | m_fullhash(fullhash), |
| 87 | 87 | m_tag(tag), |
| 88 | 88 | m_object(object) { } |
| 89 | ||
| 89 | ||
| 90 | 90 | // accessors |
| 91 | 91 | const astring &tag() const { return m_tag; } |
| 92 | 92 | _ElementType object() const { return m_object; } |
| 93 | ||
| 93 | ||
| 94 | 94 | // setters |
| 95 | 95 | void set_object(_ElementType object) { m_object = object; } |
| 96 | 96 | |
| r14260 | r14261 | |
| 151 | 151 | |
| 152 | 152 | // find by tag |
| 153 | 153 | _ElementType find(const char *tag) const { return find(tag, hash(tag)); } |
| 154 | ||
| 154 | ||
| 155 | 155 | // find by tag with precomputed hash |
| 156 | 156 | _ElementType find(const char *tag, UINT32 fullhash) const |
| 157 | 157 | { |
| r14260 | r14261 | |
| 170 | 170 | return entry->object(); |
| 171 | 171 | return NULL; |
| 172 | 172 | } |
| 173 | ||
| 173 | ||
| 174 | 174 | // return first object in the table |
| 175 | 175 | entry_t *first() const { return next(NULL); } |
| 176 | ||
| 176 | ||
| 177 | 177 | // return next object in the table |
| 178 | 178 | entry_t *next(entry_t *after) const |
| 179 | 179 | { |
| r14260 | r14261 | |
| 186 | 186 | for (UINT32 hashindex = firstindex; hashindex < ARRAY_LENGTH(m_table); hashindex++) |
| 187 | 187 | if (m_table[hashindex] != NULL) |
| 188 | 188 | return m_table[hashindex]; |
| 189 | ||
| 189 | ||
| 190 | 190 | // all out |
| 191 | 191 | return NULL; |
| 192 | 192 | } |
| r14260 | r14261 | |
| 194 | 194 | private: |
| 195 | 195 | // internal helpers |
| 196 | 196 | tagmap_error add_common(const char *tag, _ElementType object, bool replace_if_duplicate, bool unique_hash); |
| 197 | ||
| 197 | ||
| 198 | 198 | // remove an entry given a pointer to its pointer |
| 199 | 199 | void remove_common(entry_t **entryptr) |
| 200 | 200 | { |
| r14260 | r14261 | |
| 214 | 214 | //************************************************************************** |
| 215 | 215 | |
| 216 | 216 | //------------------------------------------------- |
| 217 | // add_common - core implementation of a tagmap | |
| 217 | // add_common - core implementation of a tagmap | |
| 218 | 218 | // addition |
| 219 | 219 | //------------------------------------------------- |
| 220 | 220 |
| r14260 | r14261 | |
|---|---|---|
| 38 | 38 | ***************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | extern const char build_version[]; |
| 41 | const char build_version[] = "0.144u | |
| 41 | const char build_version[] = "0.144u7 ("__DATE__")"; |
| Previous | 15994 Revisions | Next |