summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-08-01 02:23:26 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-08-01 02:23:26 +0000
commit776b251aa23217f866ea1f592abe5ed2c7550df1 (patch)
treee952bd3ebc1a310a5fa86300c607c8b481337a4c
parentc43a103858359c60a71aad43fd901ed47c5f1162 (diff)
Removed per-frame metadata support from chdman. Creating an A/V
now simply requires an AVI file input. Relaxed VBI Manchester code clocking to allow for a little bit of wiggle when finding the clock. Changed laserdisc support to parse white flags and other data from the VBI data directly, rather than relying on the textual metadata. Expanded video frame cache to 3. Changed the way frames are assembled to decrease the likelihood of getting an interlaced weave. Fixed sound creation so that it is done at reset time instead of device start, when the sound devices aren't yet live. Fixed bug in winwork that caused the creation of single work items to return NULL, and thus lead to massive memory leaks when using A/V CHDs.
-rw-r--r--src/emu/machine/laserdsc.c207
-rw-r--r--src/emu/machine/laserdsc.h9
-rw-r--r--src/lib/util/chd.c6
-rw-r--r--src/lib/util/chd.h2
-rw-r--r--src/lib/util/vbiparse.c10
-rw-r--r--src/mame/drivers/dlair.c60
-rw-r--r--src/osd/windows/winwork.c5
-rw-r--r--src/tools/chdman.c122
8 files changed, 172 insertions, 249 deletions
diff --git a/src/emu/machine/laserdsc.c b/src/emu/machine/laserdsc.c
index 0987270e16c..0f99d12e94c 100644
--- a/src/emu/machine/laserdsc.c
+++ b/src/emu/machine/laserdsc.c
@@ -14,6 +14,7 @@
#include "avcomp.h"
#include "profiler.h"
#include "streams.h"
+#include "vbiparse.h"
#include "sound/custom.h"
@@ -24,6 +25,8 @@
#define PRINTF_COMMANDS 1
+#define LOG_POSITION(x) /*printf x*/
+
#define CMDPRINTF(x) do { if (PRINTF_COMMANDS) mame_printf_debug x; } while (0)
@@ -173,7 +176,6 @@ struct _ldv1000_info
UINT32 readpos; /* current read position */
UINT32 readtotal; /* current read position */
UINT8 readbuf[256]; /* temporary read buffer */
- UINT8 statusmask; /* status bits mask */
};
@@ -202,8 +204,6 @@ struct _vp932_info
typedef struct _field_metadata field_metadata;
struct _field_metadata
{
- UINT8 version; /* version of the data */
- UINT8 frameflags; /* per-frame flags */
UINT8 whiteflag; /* white flag */
UINT32 line16; /* line 16 Philips code */
UINT32 line17; /* line 17 Philips code */
@@ -224,9 +224,9 @@ struct _laserdisc_state
UINT32 fieldnum; /* field number (0 or 1) */
/* video data */
- bitmap_t * videoframe[2]; /* currently cached frames */
- UINT8 videofields[2]; /* number of fields in each frame */
- UINT32 videoframenum[2]; /* frame number contained in each frame */
+ bitmap_t * videoframe[3]; /* currently cached frames */
+ UINT8 videofields[3]; /* number of fields in each frame */
+ UINT32 videoframenum[3]; /* frame number contained in each frame */
UINT8 videoindex; /* index of the current video buffer */
bitmap_t * emptyframe; /* blank frame */
@@ -236,6 +236,7 @@ struct _laserdisc_state
UINT32 audiobufin; /* input index */
UINT32 audiobufout; /* output index */
int audiocustom; /* custom sound index */
+ int samplerate; /* playback samplerate */
/* metadata */
field_metadata metadata[2]; /* metadata parsed from the stream, for each field */
@@ -312,7 +313,7 @@ struct _sound_token
static int update_position(laserdisc_state *ld);
static void read_track_data(laserdisc_state *ld);
static void process_track_data(laserdisc_state *ld);
-static int parse_metadata(const UINT8 *rawdata, UINT32 track, UINT8 which, field_metadata *metadata);
+static void parse_metadata(const UINT16 *videodata, UINT32 rowpixels, UINT32 width, UINT32 track, UINT8 which, field_metadata *metadata);
static void *custom_start(int clock, const struct CustomSound_interface *config);
static void custom_stream_callback(void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
@@ -601,6 +602,10 @@ INLINE int frame_from_metadata(const field_metadata *metadata)
data = metadata->line17 & 0x7ffff;
else if ((metadata->line18 & 0xf80000) == 0xf80000)
data = metadata->line18 & 0x7ffff;
+ else if (metadata->line17 == 0x88ffff || metadata->line18 == 0x88ffff)
+ return 0;
+ else if (metadata->line17 == 0x80eeee || metadata->line18 == 0x80eeee)
+ return 99999;
else
return -1;
@@ -937,7 +942,7 @@ UINT32 laserdisc_get_video(const device_config *device, bitmap_t **bitmap)
/* determine the most recent live set of frames */
frameindex = ld->videoindex;
if (ld->videofields[frameindex] < 2)
- frameindex ^= 1;
+ frameindex = (frameindex + ARRAY_LENGTH(ld->videofields) - 1) % ARRAY_LENGTH(ld->videofields);
/* if no video present, return the empty frame */
if (!video_active(ld) || ld->videofields[frameindex] < 2)
@@ -969,9 +974,6 @@ UINT32 laserdisc_get_field_code(const device_config *device, UINT8 code)
switch (code)
{
- case LASERDISC_CODE_FRAME_FLAGS:
- return ld->metadata[field].frameflags;
-
case LASERDISC_CODE_WHITE_FLAG:
return ld->metadata[field].whiteflag;
@@ -1038,31 +1040,52 @@ static int update_position(laserdisc_state *ld)
/* if we have no target, don't do anything */
if (ld->targetframe == 0)
return TRUE;
+
+ LOG_POSITION(("%d:track=%5d frame=%5d target=%5d ... ", fieldnum, tracknum, frame, ld->targetframe));
+
+ /* if we hit the first field of our frame, we're done */
+ if (ld->last_frame == ld->targetframe && frame_from_metadata(&ld->metadata[fieldnum ^ 1]) == ld->targetframe && ld->metadata[fieldnum ^ 1].whiteflag)
+ {
+ ld->curfractrack = INT_TO_FRAC(tracknum);
+ LOG_POSITION(("hit target\n"));
+ return TRUE;
+ }
/* if we didn't get any frame information this field, move onto the next */
if (frame == -1)
{
- /* if we're in the lead-in section, advance more aggressively */
- if (ld->metadata[fieldnum].line17 == 0x88ffff || ld->metadata[fieldnum].line18 == 0x88ffff)
- add_to_current_track(ld, 10 * ONE_TRACK);
-
/* if we're on the second field of a frame, the next frame is on the next track */
/* but don't do it if we're seeking to frame 1, since that might be the very first frame */
- else if (fieldnum == 1 && (ld->last_frame == 1 || ld->targetframe != 1))
+ if (fieldnum == 1)// && (ld->last_frame == 1 || ld->targetframe != 1))
+ {
add_to_current_track(ld, ONE_TRACK);
+ LOG_POSITION(("on 2nd field, going to next track\n"));
+ }
+ else
+ LOG_POSITION(("no metadata; waiting for next field\n"));
return FALSE;
}
- /* if we hit our frame, we're done */
- if (frame == ld->targetframe)
+ /* if we're in the lead-in or lead-out sections, advance more aggressively */
+ if (frame == 0)
{
- ld->curfractrack = INT_TO_FRAC(tracknum);
- return TRUE;
+ LOG_POSITION(("in lead-in, advancing by 10\n"));
+ add_to_current_track(ld, 10 * ONE_TRACK);
+ return FALSE;
+ }
+ if (frame == 99999)
+ {
+ LOG_POSITION(("in lead-out, advancing by 10\n"));
+ add_to_current_track(ld, -10 * ONE_TRACK);
+ return FALSE;
}
- /* determine the frame delta and direction */
- framedelta = ld->targetframe - frame;
- direction = (framedelta < 0) ? -1 : 1;
+ /* determine the frame delta and direction; for backwards seeks, aim to overshoot by 1 frame */
+ if (ld->targetframe < frame && ld->targetframe != 1)
+ framedelta = ld->targetframe - 1 - frame;
+ else
+ framedelta = ld->targetframe - frame;
+ direction = (framedelta <= 0) ? -1 : 1;
/* if we're going backwards, go back at least 2 frames since we tend to move forward */
if (framedelta == -1)
@@ -1077,6 +1100,7 @@ static int update_position(laserdisc_state *ld)
framedelta = INT_TO_FRAC(abs(framedelta));
/* determine the stepdelta */
+ LOG_POSITION(("advancing by %08X\n", MIN(framedelta, speed / 2) * direction));
add_to_current_track(ld, MIN(framedelta, speed / 2) * direction);
return FALSE;
}
@@ -1137,30 +1161,24 @@ static void read_track_data(laserdisc_state *ld)
chd_error err;
/* initialize the decompression structure */
- ld->avconfig.decode_mask = AVCOMP_DECODE_META;
- ld->avconfig.video_buffer = NULL;
+ ld->avconfig.decode_mask = AVCOMP_DECODE_VIDEO;
ld->avconfig.video_xor = BYTE_XOR_LE(0);
ld->avconfig.audio_xor = BYTE_XOR_BE(0);
-
- /* if video is active, enable video decoding */
- if (video_active(ld))
+
+ /* if the previous field had the white flag, force the new field to pair with it */
+ if (ld->metadata[fieldnum ^ 1].whiteflag)
+ ld->videofields[ld->videoindex] = 1;
+
+ /* if we already have both fields on the current videoindex, advance */
+ if (ld->videofields[ld->videoindex] >= 2)
{
- /* if the flags on the previous field indicate that the next field
- is part of the same frame, then keep steady; otherwise, bump to
- the next videoindex */
- if (ld->videofields[ld->videoindex] > 0 && !(ld->metadata[fieldnum ^ 1].frameflags & FRAMEFLAG_NEXT_SAME_FRAME))
- {
- ld->videoindex ^= 1;
- ld->videofields[ld->videoindex] = 0;
- }
-
- /* enable video and configure it to read into the videoframe */
- ld->avconfig.decode_mask |= AVCOMP_DECODE_VIDEO;
- ld->avconfig.video_buffer = (UINT8 *)BITMAP_ADDR16(ld->videoframe[ld->videoindex], fieldnum, 0);
- ld->avconfig.video_stride = 4 * ld->videoframe[ld->videoindex]->rowpixels;
+ ld->videoindex = (ld->videoindex + 1) % ARRAY_LENGTH(ld->videofields);
+ ld->videofields[ld->videoindex] = 0;
}
- else
- ld->videofields[0] = ld->videofields[1] = 0;
+
+ /* set the video buffer information */
+ ld->avconfig.video_buffer = (UINT8 *)BITMAP_ADDR16(ld->videoframe[ld->videoindex], fieldnum, 0);
+ ld->avconfig.video_stride = 4 * ld->videoframe[ld->videoindex]->rowpixels;
/* if audio is active, enable audio decoding */
if (audio_channel_active(ld, 0))
@@ -1207,7 +1225,11 @@ static void process_track_data(laserdisc_state *ld)
ld->readpending = FALSE;
/* parse the metadata */
- parse_metadata(rawdata, tracknum, fieldnum, &ld->metadata[fieldnum]);
+ if (ld->avconfig.video_buffer != NULL)
+ {
+ parse_metadata((const UINT16 *)ld->avconfig.video_buffer, ld->avconfig.video_stride / 2, ld->videoframe[0]->width, tracknum, fieldnum, &ld->metadata[fieldnum]);
+ //printf("Track %5d: Metadata = %d %08X %08X %08X\n", tracknum, ld->metadata[fieldnum].whiteflag, ld->metadata[fieldnum].line16, ld->metadata[fieldnum].line17, ld->metadata[fieldnum].line18);
+ }
/* update the last seen frame and chapter */
frame = frame_from_metadata(&ld->metadata[fieldnum]);
@@ -1272,45 +1294,27 @@ static void process_track_data(laserdisc_state *ld)
something more useful
-------------------------------------------------*/
-static int parse_metadata(const UINT8 *rawdata, UINT32 track, UINT8 which, field_metadata *metadata)
+static void parse_metadata(const UINT16 *videodata, UINT32 rowpixels, UINT32 width, UINT32 track, UINT8 which, field_metadata *metadata)
{
- /* verify we have data to parse */
- if (rawdata == NULL || rawdata[4] < 1)
- goto fakeit;
+ UINT8 bits[24];
+ UINT8 bitnum;
+
+ metadata->whiteflag = vbi_parse_white_flag(videodata + 11 * rowpixels, width, 8);
- /* first byte is the version */
- metadata->version = rawdata[12+0];
+ metadata->line16 = 0;
+ if (vbi_parse_manchester_code(videodata + 16 * rowpixels, width, 8, 24, bits) == 24)
+ for (bitnum = 0; bitnum < 24; bitnum++)
+ metadata->line16 = (metadata->line16 << 1) | bits[bitnum];
- /* version 1 data */
- if (metadata->version == 2 && rawdata[4] == 12)
- {
- /*
- 1 byte = version
- 1 byte = internal flags
- D0 = prev field is same frame
- D1 = next field is same frame
- 1 byte = white flag
- 3 bytes = line 16 Philips code
- 3 bytes = line 17 Philips code
- 3 bytes = line 18 Philips code
- */
- metadata->frameflags = rawdata[12+1];
- metadata->whiteflag = rawdata[12+2];
- metadata->line16 = (rawdata[12+3] << 16) | (rawdata[12+4] << 8) | rawdata[12+5];
- metadata->line17 = (rawdata[12+6] << 16) | (rawdata[12+7] << 8) | rawdata[12+8];
- metadata->line18 = (rawdata[12+9] << 16) | (rawdata[12+10] << 8) | rawdata[12+11];
- return TRUE;
- }
+ metadata->line17 = 0;
+ if (vbi_parse_manchester_code(videodata + 17 * rowpixels, width, 8, 24, bits) == 24)
+ for (bitnum = 0; bitnum < 24; bitnum++)
+ metadata->line17 = (metadata->line17 << 1) | bits[bitnum];
-fakeit:
- metadata->frameflags = (which == 0) ? 0x02 : 0x01;
- metadata->whiteflag = (which == 0) ? 1 : 0;
- metadata->line16 = 0x000000;
- if (which == 0)
- metadata->line17 = metadata->line18 = 0xf80000 | (((track / 10000) % 10) << 16) | (((track / 1000) % 10) << 12) | (((track / 100) % 10) << 8) | (((track / 10) % 10) << 4) | (track % 10);
- else
- metadata->line17 = metadata->line18 = 0x000000;
- return FALSE;
+ metadata->line18 = 0;
+ if (vbi_parse_manchester_code(videodata + 18 * rowpixels, width, 8, 24, bits) == 24)
+ for (bitnum = 0; bitnum < 24; bitnum++)
+ metadata->line18 = (metadata->line18 << 1) | bits[bitnum];
}
@@ -1402,20 +1406,20 @@ static void custom_stream_callback(void *param, stream_sample_t **inputs, stream
static DEVICE_START( laserdisc )
{
- int fps = 30, fpsfrac = 0, width = 720, height = 240, interlaced = 1, channels = 2, rate = 44100, metabytes = 0;
+ int fps = 30, fpsfrac = 0, width = 720, height = 240, interlaced = 1, channels = 2, rate = 44100;
const laserdisc_config *config = device->inline_config;
UINT32 fps_times_1million, max_samples_per_track;
laserdisc_state *ld = get_safe_token(device);
char metadata[256];
chd_error err;
- int sndnum;
+ int sndnum, index;
/* copy config data to the live state */
ld->type = config->type;
ld->disc = get_disk_handle(config->disknum);
for (sndnum = 0; sndnum < MAX_SOUND; sndnum++)
if (device->machine->config->sound[sndnum].tag != NULL && strcmp(device->machine->config->sound[sndnum].tag, config->soundtag) == 0)
- ld->audiocustom = sndnum;
+ sndnum_to_sndti(sndnum, &ld->audiocustom);
/* get the disc metadata and extract the ld */
if (ld->disc != NULL)
@@ -1428,7 +1432,7 @@ static DEVICE_START( laserdisc )
err = chd_get_metadata(ld->disc, AV_METADATA_TAG, 0, metadata, sizeof(metadata), NULL, NULL);
if (err != CHDERR_NONE)
fatalerror("Non-A/V CHD file specified");
- if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate, &metabytes) != 8)
+ if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7)
fatalerror("Invalid metadata in CHD file");
/* require interlaced video */
@@ -1443,10 +1447,11 @@ static DEVICE_START( laserdisc )
ld->maxfractrack = INT_TO_FRAC(54000);
/* allocate video frames */
- ld->videoframe[0] = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16);
- fillbitmap_yuy16(ld->videoframe[0], 40, 109, 240);
- ld->videoframe[1] = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16);
- fillbitmap_yuy16(ld->videoframe[1], 40, 109, 240);
+ for (index = 0; index < ARRAY_LENGTH(ld->videofields); index++)
+ {
+ ld->videoframe[index] = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16);
+ fillbitmap_yuy16(ld->videoframe[index], 40, 109, 240);
+ }
ld->emptyframe = auto_bitmap_alloc(width, height * 2, BITMAP_FORMAT_YUY16);
fillbitmap_yuy16(ld->emptyframe, 0, 128, 128);
@@ -1456,14 +1461,7 @@ static DEVICE_START( laserdisc )
ld->audiobufsize = max_samples_per_track * 4;
ld->audiobuffer[0] = auto_malloc(ld->audiobufsize * sizeof(ld->audiobuffer[0][0]));
ld->audiobuffer[1] = auto_malloc(ld->audiobufsize * sizeof(ld->audiobuffer[1][0]));
-
- /* attempt to wire up the audio */
- if (sndti_exists(SOUND_CUSTOM, ld->audiocustom))
- {
- sound_token *token = custom_get_token(ld->audiocustom);
- token->ld = ld;
- stream_set_sample_rate(token->stream, rate);
- }
+ ld->samplerate = rate;
}
@@ -1490,6 +1488,14 @@ static DEVICE_RESET( laserdisc )
laserdisc_state *ld = get_safe_token(device);
int i;
+ /* attempt to wire up the audio */
+ if (sndti_exists(SOUND_CUSTOM, ld->audiocustom))
+ {
+ sound_token *token = custom_get_token(ld->audiocustom);
+ token->ld = ld;
+ stream_set_sample_rate(token->stream, ld->samplerate);
+ }
+
/* set up the general ld */
ld->video = VIDEO_ENABLE;
ld->audio = AUDIO_CH1_ENABLE | AUDIO_CH2_ENABLE;
@@ -2326,7 +2332,6 @@ static void ldv1000_soft_reset(laserdisc_state *ld)
ld->display = FALSE;
ldv1000->mode = LDV1000_MODE_STATUS;
ldv1000->activereg = 0;
- ldv1000->statusmask = 0xff;
write_16bits_to_ram_be(ldv1000->ram, 0, 1);
}
@@ -2343,15 +2348,7 @@ static void ldv1000_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data)
/* 0xFF bytes are used for synchronization */
if (data == 0xff)
- {
- ldv1000->statusmask = 0xff; /* EHC 012207: reset our status mask */
- return;
- }
-
- /* if we're not ready, return, otherwise signal ourselves busy */
- if (ldv1000->statusmask == 0x7f)
return;
- ldv1000->statusmask = 0x7f;
/* look for and process numbers */
if (process_number(ld, data, numbers))
@@ -2750,7 +2747,7 @@ static UINT8 ldv1000_status_r(laserdisc_state *ld)
}
/* bit 7 indicates our busy status */
- return status & ldv1000->statusmask;
+ return status;
}
diff --git a/src/emu/machine/laserdsc.h b/src/emu/machine/laserdsc.h
index 6ba56f7833c..c695b740ed2 100644
--- a/src/emu/machine/laserdsc.h
+++ b/src/emu/machine/laserdsc.h
@@ -43,11 +43,10 @@ enum
#define LASERDISC_OUTPUT_LINES 4
/* laserdisc field codes */
-#define LASERDISC_CODE_FRAME_FLAGS 0
-#define LASERDISC_CODE_WHITE_FLAG 1
-#define LASERDISC_CODE_LINE16 2
-#define LASERDISC_CODE_LINE17 3
-#define LASERDISC_CODE_LINE18 4
+#define LASERDISC_CODE_WHITE_FLAG 0
+#define LASERDISC_CODE_LINE16 1
+#define LASERDISC_CODE_LINE17 2
+#define LASERDISC_CODE_LINE18 3
/* device configuration */
enum
diff --git a/src/lib/util/chd.c b/src/lib/util/chd.c
index d9083fc73e1..e8fda05e2ad 100644
--- a/src/lib/util/chd.c
+++ b/src/lib/util/chd.c
@@ -2827,7 +2827,7 @@ static chd_error av_codec_config(chd_file *chd, int param, void *config)
static chd_error av_codec_postinit(chd_file *chd)
{
- int fps, fpsfrac, width, height, interlaced, channels, rate, metabytes;
+ int fps, fpsfrac, width, height, interlaced, channels, rate;
UINT32 fps_times_1million, max_samples_per_frame, bytes_per_frame;
av_codec_data *data = chd->codecdata;
char metadata[256];
@@ -2843,13 +2843,13 @@ static chd_error av_codec_postinit(chd_file *chd)
return err;
/* extract the info */
- if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate, &metabytes) != 8)
+ if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7)
return CHDERR_INVALID_METADATA;
/* compute the bytes per frame */
fps_times_1million = fps * 1000000 + fpsfrac;
max_samples_per_frame = ((UINT64)rate * 1000000 + fps_times_1million - 1) / fps_times_1million;
- bytes_per_frame = 12 + metabytes + channels * max_samples_per_frame * 2 + width * height * 2;
+ bytes_per_frame = 12 + channels * max_samples_per_frame * 2 + width * height * 2;
if (bytes_per_frame > chd->header.hunkbytes)
return CHDERR_INVALID_METADATA;
diff --git a/src/lib/util/chd.h b/src/lib/util/chd.h
index f6aef5d8da3..0e3af6f94f5 100644
--- a/src/lib/util/chd.h
+++ b/src/lib/util/chd.h
@@ -126,7 +126,7 @@
/* standard A/V metadata */
#define AV_METADATA_TAG 0x41564156 /* 'AVAV' */
-#define AV_METADATA_FORMAT "FPS:%d.%06d WIDTH:%d HEIGHT:%d INTERLACED:%d CHANNELS:%d SAMPLERATE:%d META:%d"
+#define AV_METADATA_FORMAT "FPS:%d.%06d WIDTH:%d HEIGHT:%d INTERLACED:%d CHANNELS:%d SAMPLERATE:%d"
/* CHD open values */
#define CHD_OPEN_READ 1
diff --git a/src/lib/util/vbiparse.c b/src/lib/util/vbiparse.c
index b11941cb71f..0c3b7847e85 100644
--- a/src/lib/util/vbiparse.c
+++ b/src/lib/util/vbiparse.c
@@ -101,7 +101,15 @@ int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sources
if (srcabs[curbit + 1 + 0] != srcabs[curbit + 1 + 1] || srcabs[curbit - 1 + 0] != srcabs[curbit - 1 + 1])
{
/* only continue if we're still in the running */
- if (++error < besterr)
+ if ((error += 1) < besterr)
+ continue;
+ }
+
+ /* off-by-two? */
+ if (srcabs[curbit + 2 + 0] != srcabs[curbit + 2 + 1] || srcabs[curbit - 2 + 0] != srcabs[curbit - 2 + 1])
+ {
+ /* only continue if we're still in the running */
+ if ((error += 2) < besterr)
continue;
}
diff --git a/src/mame/drivers/dlair.c b/src/mame/drivers/dlair.c
index fb13eb44326..f2665821042 100644
--- a/src/mame/drivers/dlair.c
+++ b/src/mame/drivers/dlair.c
@@ -473,8 +473,8 @@ static ADDRESS_MAP_START( dlus_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x9fff) AM_ROM
AM_RANGE(0xa000, 0xa7ff) AM_MIRROR(0x1800) AM_RAM
AM_RANGE(0xc000, 0xc000) AM_MIRROR(0x1fc7) AM_READ(AY8910_read_port_0_r)
- AM_RANGE(0xc008, 0xc008) AM_MIRROR(0x1fc7) AM_READ(input_port_2_r)
- AM_RANGE(0xc010, 0xc010) AM_MIRROR(0x1fc7) AM_READ(input_port_3_r)
+ AM_RANGE(0xc008, 0xc008) AM_MIRROR(0x1fc7) AM_READ_PORT("CONTROLS")
+ AM_RANGE(0xc010, 0xc010) AM_MIRROR(0x1fc7) AM_READ_PORT("SERVICE")
AM_RANGE(0xc020, 0xc020) AM_MIRROR(0x1fc7) AM_READ(laserdisc_r)
AM_RANGE(0xe000, 0xe000) AM_MIRROR(0x1fc7) AM_WRITE(AY8910_write_port_0_w)
AM_RANGE(0xe008, 0xe008) AM_MIRROR(0x1fc7) AM_WRITE(misc_w)
@@ -586,47 +586,47 @@ Address in ROM:
static INPUT_PORTS_START( dlair )
PORT_START_TAG("DSW1")
- PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("A:1,0")
+ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("A:2,1")
PORT_DIPSETTING( 0x01, DEF_STR( 3C_1C ) )
// PORT_DIPSETTING( 0x02, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( Unused ) )
- PORT_DIPNAME( 0x04, 0x00, "Difficulty Mode" ) PORT_DIPLOCATION("A:2")
+ PORT_DIPNAME( 0x04, 0x00, "Difficulty Mode" ) PORT_DIPLOCATION("A:3")
PORT_DIPSETTING( 0x04, "Mode 1" )
PORT_DIPSETTING( 0x00, "Mode 2" )
- PORT_DIPNAME( 0x08, 0x00, "Engineering mode" ) PORT_DIPLOCATION("A:3")
+ PORT_DIPNAME( 0x08, 0x00, "Engineering mode" ) PORT_DIPLOCATION("A:4")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) )
- PORT_DIPNAME( 0x10, 0x00, "2 Credits/Free play" ) PORT_DIPLOCATION("A:4")
+ PORT_DIPNAME( 0x10, 0x00, "2 Credits/Free play" ) PORT_DIPLOCATION("A:5")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x10, DEF_STR( On ) )
- PORT_DIPNAME( 0x20, 0x20, DEF_STR( Lives ) ) PORT_DIPLOCATION("A:5")
+ PORT_DIPNAME( 0x20, 0x20, DEF_STR( Lives ) ) PORT_DIPLOCATION("A:6")
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPSETTING( 0x20, "5" )
- PORT_DIPNAME( 0x40, 0x00, "Pay as you go" ) PORT_DIPLOCATION("A:6")
+ PORT_DIPNAME( 0x40, 0x00, "Pay as you go" ) PORT_DIPLOCATION("A:7")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x40, DEF_STR( On ) )
- PORT_SERVICE_DIPLOC( 0x80, IP_ACTIVE_HIGH, "A:7" )
+ PORT_SERVICE_DIPLOC( 0x80, IP_ACTIVE_HIGH, "A:8" )
PORT_START_TAG("DSW2")
- PORT_DIPNAME( 0x01, 0x01, "Sound every 8 attracts" ) PORT_DIPLOCATION("B:0")
+ PORT_DIPNAME( 0x01, 0x01, "Sound every 8 attracts" ) PORT_DIPLOCATION("B:1")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, DEF_STR( On ) )
- PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("B:1")
+ PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("B:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x04, 0x00, "Unlimited Dirks" ) PORT_DIPLOCATION("B:2")
+ PORT_DIPNAME( 0x04, 0x00, "Unlimited Dirks" ) PORT_DIPLOCATION("B:3")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x04, DEF_STR( On ) )
- PORT_DIPNAME( 0x08, 0x08, "Joystick Feedback Sound" ) PORT_DIPLOCATION("B:3")
+ PORT_DIPNAME( 0x08, 0x08, "Joystick Feedback Sound" ) PORT_DIPLOCATION("B:4")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) )
- PORT_DIPNAME( 0x60, 0x60, "Pay as you go options" ) PORT_DIPLOCATION("B:6,5")
+ PORT_DIPNAME( 0x60, 0x60, "Pay as you go options" ) PORT_DIPLOCATION("B:7,6")
PORT_DIPSETTING( 0x00, "PAYG1" )
PORT_DIPSETTING( 0x20, "PAYG2" )
PORT_DIPSETTING( 0x40, "PAYG3" )
PORT_DIPSETTING( 0x60, "PAYG4" )
- PORT_DIPNAME( 0x90, 0x10, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("B:7,4")
+ PORT_DIPNAME( 0x90, 0x10, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("B:8,5")
PORT_DIPSETTING( 0x00, "Increase after 5" ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING( 0x10, "Increase after 9" ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING( 0x80, DEF_STR( Easy ) ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x00)
@@ -636,7 +636,7 @@ static INPUT_PORTS_START( dlair )
PORT_DIPSETTING( 0x80, DEF_STR( Easy ) ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x04)
PORT_DIPSETTING( 0x90, DEF_STR( Easy ) ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x04)
- PORT_START /* IN0 */
+ PORT_START_TAG("CONTROLS")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
@@ -646,7 +646,7 @@ static INPUT_PORTS_START( dlair )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */
- PORT_START /* IN2 */
+ PORT_START_TAG("SERVICE")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
@@ -688,47 +688,47 @@ static INPUT_PORTS_START( dleuro )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(laserdisc_command_r, 0) /* command strobe */
PORT_START_TAG("DSW1")
- PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("A:1,0")
+ PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("A:2,1")
PORT_DIPSETTING( 0x01, DEF_STR( 3C_1C ) )
// PORT_DIPSETTING( 0x02, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( Unused ) )
- PORT_DIPNAME( 0x04, 0x00, "Difficulty Mode" ) PORT_DIPLOCATION("A:2")
+ PORT_DIPNAME( 0x04, 0x00, "Difficulty Mode" ) PORT_DIPLOCATION("A:3")
PORT_DIPSETTING( 0x04, "Mode 1" )
PORT_DIPSETTING( 0x00, "Mode 2" )
- PORT_DIPNAME( 0x08, 0x00, "Engineering mode" ) PORT_DIPLOCATION("A:3")
+ PORT_DIPNAME( 0x08, 0x00, "Engineering mode" ) PORT_DIPLOCATION("A:4")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) )
- PORT_DIPNAME( 0x10, 0x00, "2 Credits/Free play" ) PORT_DIPLOCATION("A:4")
+ PORT_DIPNAME( 0x10, 0x00, "2 Credits/Free play" ) PORT_DIPLOCATION("A:5")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x10, DEF_STR( On ) )
- PORT_DIPNAME( 0x20, 0x20, DEF_STR( Lives ) ) PORT_DIPLOCATION("A:5")
+ PORT_DIPNAME( 0x20, 0x20, DEF_STR( Lives ) ) PORT_DIPLOCATION("A:6")
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPSETTING( 0x20, "5" )
- PORT_DIPNAME( 0x40, 0x00, "Pay as you go" ) PORT_DIPLOCATION("A:6")
+ PORT_DIPNAME( 0x40, 0x00, "Pay as you go" ) PORT_DIPLOCATION("A:7")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x40, DEF_STR( On ) )
- PORT_SERVICE_DIPLOC( 0x80, IP_ACTIVE_HIGH, "A:7" )
+ PORT_SERVICE_DIPLOC( 0x80, IP_ACTIVE_HIGH, "A:8" )
PORT_START_TAG("DSW2")
- PORT_DIPNAME( 0x01, 0x01, "Sound every 8 attracts" ) PORT_DIPLOCATION("B:0")
+ PORT_DIPNAME( 0x01, 0x01, "Sound every 8 attracts" ) PORT_DIPLOCATION("B:1")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, DEF_STR( On ) )
- PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("B:1")
+ PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("B:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
- PORT_DIPNAME( 0x04, 0x00, "Unlimited Dirks" ) PORT_DIPLOCATION("B:2")
+ PORT_DIPNAME( 0x04, 0x00, "Unlimited Dirks" ) PORT_DIPLOCATION("B:3")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x04, DEF_STR( On ) )
- PORT_DIPNAME( 0x08, 0x08, "Joystick Feedback Sound" ) PORT_DIPLOCATION("B:3")
+ PORT_DIPNAME( 0x08, 0x08, "Joystick Feedback Sound" ) PORT_DIPLOCATION("B:4")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) )
- PORT_DIPNAME( 0x60, 0x60, "Pay as you go options" ) PORT_DIPLOCATION("B:6,5")
+ PORT_DIPNAME( 0x60, 0x60, "Pay as you go options" ) PORT_DIPLOCATION("B:7,6")
PORT_DIPSETTING( 0x00, "PAYG1" )
PORT_DIPSETTING( 0x20, "PAYG2" )
PORT_DIPSETTING( 0x40, "PAYG3" )
PORT_DIPSETTING( 0x60, "PAYG4" )
- PORT_DIPNAME( 0x90, 0x10, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("B:7,4")
+ PORT_DIPNAME( 0x90, 0x10, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("B:8,5s")
PORT_DIPSETTING( 0x00, "Increase after 5" ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING( 0x10, "Increase after 9" ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x00)
PORT_DIPSETTING( 0x80, DEF_STR( Easy ) ) PORT_CONDITION("DSW1",0x04,PORTCOND_EQUALS,0x00)
diff --git a/src/osd/windows/winwork.c b/src/osd/windows/winwork.c
index 5d3ff1d9b0b..c4fa67c11d9 100644
--- a/src/osd/windows/winwork.c
+++ b/src/osd/windows/winwork.c
@@ -492,7 +492,7 @@ void osd_work_queue_free(osd_work_queue *queue)
osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_callback callback, INT32 numitems, void *parambase, INT32 paramstep, UINT32 flags)
{
- osd_work_item *itemlist = NULL;
+ osd_work_item *itemlist = NULL, *lastitem = NULL;
osd_work_item **item_tailptr = &itemlist;
INT32 lockslot;
int itemnum;
@@ -528,6 +528,7 @@ osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_call
item->done = FALSE;
// advance to the next
+ lastitem = item;
*item_tailptr = item;
item_tailptr = &item->next;
parambase = (UINT8 *)parambase + paramstep;
@@ -571,7 +572,7 @@ osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_call
worker_thread_process(queue, &queue->thread[0]);
// only return the item if it won't get released automatically
- return (flags & WORK_ITEM_FLAG_AUTO_RELEASE) ? NULL : *item_tailptr;
+ return (flags & WORK_ITEM_FLAG_AUTO_RELEASE) ? NULL : lastitem;
}
diff --git a/src/tools/chdman.c b/src/tools/chdman.c
index b80c1307a40..d81e74aac68 100644
--- a/src/tools/chdman.c
+++ b/src/tools/chdman.c
@@ -191,11 +191,11 @@ static int usage(void)
printf(" or: chdman -createhd inputhd.raw output.chd [inputoffs [cylinders heads sectors [sectorsize [hunksize]]]]\n");
printf(" or: chdman -createblankhd output.chd cylinders heads sectors [sectorsize [hunksize]]\n");
printf(" or: chdman -createcd input.toc output.chd\n");
- printf(" or: chdman -createav input.avi inputmeta.txt output.chd [firstframe [numframes]]\n");
+ printf(" or: chdman -createav input.avi output.chd [firstframe [numframes]]\n");
printf(" or: chdman -copydata input.chd output.chd\n");
printf(" or: chdman -extract input.chd output.raw\n");
printf(" or: chdman -extractcd input.chd output.toc output.bin\n");
- printf(" or: chdman -extractav input.chd output.avi outputmeta.txt [firstframe [numframes]]\n");
+ printf(" or: chdman -extractav input.chd output.avi [firstframe [numframes]]\n");
printf(" or: chdman -verify input.chd\n");
printf(" or: chdman -verifyfix input.chd\n");
printf(" or: chdman -update input.chd output.chd\n");
@@ -718,62 +718,35 @@ cleanup:
static int do_createav(int argc, char *argv[], int param)
{
- UINT32 fps_times_1million, width, height, interlaced, channels, rate, metabytes = 0, totalframes;
+ UINT32 fps_times_1million, width, height, interlaced, channels, rate, totalframes;
UINT32 max_samples_per_frame, bytes_per_frame, firstframe, numframes;
- const char *inputfile, *metafile, *outputfile;
+ const char *inputfile, *outputfile;
bitmap_t videobitmap = { 0 };
const avi_movie_info *info;
const chd_header *header;
- char metadata[256];
chd_file *chd = NULL;
avi_file *avi = NULL;
UINT8 *cache = NULL;
double ratio = 1.0;
- FILE *meta = NULL;
+ char metadata[256];
avi_error avierr;
chd_error err;
UINT32 framenum;
- /* require 5-7 args total */
- if (argc < 5 || argc > 7)
+ /* require 4-6 args total */
+ if (argc < 4 || argc > 6)
return usage();
/* extract the first few parameters */
inputfile = argv[2];
- metafile = argv[3];
- outputfile = argv[4];
- firstframe = (argc > 5) ? atoi(argv[5]) : 0;
- numframes = (argc > 6) ? atoi(argv[6]) : 1000000;
+ outputfile = argv[3];
+ firstframe = (argc > 4) ? atoi(argv[4]) : 0;
+ numframes = (argc > 5) ? atoi(argv[5]) : 1000000;
/* print some info */
printf("Input file: %s\n", inputfile);
- printf("Meta file: %s\n", (metafile == NULL) ? "(none)" : metafile);
printf("Output file: %s\n", outputfile);
- /* open the meta file */
- if (metafile != NULL)
- {
- meta = fopen(metafile, "r");
- if (meta == NULL)
- {
- fprintf(stderr, "Error opening meta file\n");
- err = CHDERR_INVALID_FILE;
- goto cleanup;
- }
- if (fgets(metadata, sizeof(metadata), meta) == NULL || sscanf(metadata, "chdmeta %d\n", &metabytes) != 1)
- {
- fprintf(stderr, "Invalid data header in metafile\n");
- err = CHDERR_INVALID_FILE;
- goto cleanup;
- }
- if (metabytes > 255)
- {
- fprintf(stderr, "Metadata too large (255 bytes maximum)\n");
- err = CHDERR_INVALID_FILE;
- goto cleanup;
- }
- }
-
/* open the source file */
avierr = avi_open(inputfile, &avi);
if (avierr != AVIERR_NONE)
@@ -813,7 +786,6 @@ static int do_createav(int argc, char *argv[], int param)
printf("Frame rate: %d.%06d\n", fps_times_1million / 1000000, fps_times_1million % 1000000);
printf("Frame size: %d x %d %s\n", width, height, interlaced ? "interlaced" : "non-interlaced");
printf("Audio: %d channels at %d Hz\n", channels, rate);
- printf("Metadata: %d bytes/frame\n", metabytes);
printf("Total frames: %d (%02d:%02d:%02d)\n", totalframes,
(UINT32)((UINT64)totalframes * 1000000 / fps_times_1million / 60 / 60),
(UINT32)(((UINT64)totalframes * 1000000 / fps_times_1million / 60) % 60),
@@ -831,7 +803,7 @@ static int do_createav(int argc, char *argv[], int param)
/* determine the number of bytes per frame */
max_samples_per_frame = ((UINT64)rate * 1000000 + fps_times_1million - 1) / fps_times_1million;
- bytes_per_frame = 12 + metabytes + channels * max_samples_per_frame * 2 + width * height * 2;
+ bytes_per_frame = 12 + channels * max_samples_per_frame * 2 + width * height * 2;
/* create the new CHD */
err = chd_create(outputfile, (UINT64)numframes * (UINT64)bytes_per_frame, bytes_per_frame, CHDCOMPRESSION_AV, NULL);
@@ -851,7 +823,7 @@ static int do_createav(int argc, char *argv[], int param)
header = chd_get_header(chd);
/* write the metadata */
- sprintf(metadata, AV_METADATA_FORMAT, fps_times_1million / 1000000, fps_times_1million % 1000000, width, height, interlaced, channels, rate, metabytes);
+ sprintf(metadata, AV_METADATA_FORMAT, fps_times_1million / 1000000, fps_times_1million % 1000000, width, height, interlaced, channels, rate);
err = chd_set_metadata(chd, AV_METADATA_TAG, 0, metadata, strlen(metadata) + 1);
if (err != CHDERR_NONE)
{
@@ -873,7 +845,7 @@ static int do_createav(int argc, char *argv[], int param)
cache[1] = 'h';
cache[2] = 'a';
cache[3] = 'v';
- cache[4] = metabytes;
+ cache[4] = 0;
cache[5] = channels;
cache[6] = max_samples_per_frame >> 8;
cache[7] = max_samples_per_frame;
@@ -893,24 +865,6 @@ static int do_createav(int argc, char *argv[], int param)
/* progress */
progress(framenum == 0, "Compressing hunk %d/%d... (ratio=%d%%) \r", framenum, header->totalhunks, (int)(100.0 * ratio));
- /* read the metadata */
- if (metabytes > 0)
- {
- memset(&cache[12], 0, metabytes);
- if (meta != NULL && fgets(metadata, sizeof(metadata), meta) != NULL)
- {
- int metaoffs, stroffs, length = strlen(metadata);
-
- for (metaoffs = stroffs = 0; metaoffs < metabytes && stroffs < length; metaoffs++, stroffs += 2)
- {
- int data;
- if (sscanf(&metadata[stroffs], "%02X", &data) != 1)
- break;
- cache[12 + metaoffs] = data;
- }
- }
- }
-
/* read the frame into its proper format in the cache */
avierr = read_avi_frame(avi, firstframe + framenum, cache, &videobitmap, interlaced, bytes_per_frame);
if (avierr != AVIERR_NONE)
@@ -938,8 +892,6 @@ cleanup:
avi_close(avi);
if (chd != NULL)
chd_close(chd);
- if (meta != NULL)
- fclose(meta);
if (cache != NULL)
free(cache);
if (videobitmap.base != NULL)
@@ -1468,8 +1420,8 @@ cleanup:
static int do_extractav(int argc, char *argv[], int param)
{
- int fps, fpsfrac, width, height, interlaced, channels, rate, metabytes, totalframes;
- const char *inputfile, *metafile, *outputfile;
+ int fps, fpsfrac, width, height, interlaced, channels, rate, totalframes;
+ const char *inputfile, *outputfile;
int firstframe, numframes;
bitmap_t videobitmap = { 0 };
UINT32 fps_times_1million;
@@ -1479,26 +1431,23 @@ static int do_extractav(int argc, char *argv[], int param)
avi_movie_info info;
char metadata[256];
void *hunk = NULL;
- FILE *meta = NULL;
avi_error avierr;
chd_error err;
int framenum;
- /* require 5-7 args total */
- if (argc < 5 || argc > 7)
+ /* require 4-6 args total */
+ if (argc < 4 || argc > 6)
return usage();
/* extract the data */
inputfile = argv[2];
outputfile = argv[3];
- metafile = argv[4];
- firstframe = (argc > 5) ? atoi(argv[5]) : 0;
- numframes = (argc > 6) ? atoi(argv[6]) : 1000000;
+ firstframe = (argc > 4) ? atoi(argv[4]) : 0;
+ numframes = (argc > 5) ? atoi(argv[5]) : 1000000;
/* print some info */
printf("Input file: %s\n", inputfile);
printf("Output file: %s\n", outputfile);
- printf("Meta file: %s\n", (metafile == NULL) ? "(none)" : metafile);
/* get the header */
err = chd_open(inputfile, CHD_OPEN_READ, NULL, &chd);
@@ -1518,7 +1467,7 @@ static int do_extractav(int argc, char *argv[], int param)
}
/* extract the info */
- if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate, &metabytes) != 8)
+ if (sscanf(metadata, AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7)
{
fprintf(stderr, "Improperly formatted metadata\n");
err = CHDERR_INVALID_METADATA;
@@ -1554,15 +1503,11 @@ static int do_extractav(int argc, char *argv[], int param)
printf("Frame rate: %d.%06d\n", fps_times_1million / 1000000, fps_times_1million % 1000000);
printf("Frame size: %d x %d %s\n", width, height, interlaced ? "interlaced" : "non-interlaced");
printf("Audio: %d channels at %d Hz\n", channels, rate);
- printf("Metadata: %d bytes/frame\n", metabytes);
printf("Total frames: %d (%02d:%02d:%02d)\n", totalframes,
(UINT32)((UINT64)totalframes * 1000000 / fps_times_1million / 60 / 60),
(UINT32)(((UINT64)totalframes * 1000000 / fps_times_1million / 60) % 60),
(UINT32)(((UINT64)totalframes * 1000000 / fps_times_1million) % 60));
- if (metabytes > 0 && metafile == NULL)
- fprintf(stderr, "Warning: per-frame metadata included but not extracted\n");
-
/* allocate memory to hold a hunk */
hunk = malloc(header->hunkbytes);
if (hunk == NULL)
@@ -1595,19 +1540,6 @@ static int do_extractav(int argc, char *argv[], int param)
goto cleanup;
}
- /* create the metadata file */
- if (metafile != NULL && metabytes > 0)
- {
- meta = fopen(metafile, "w");
- if (meta == NULL)
- {
- fprintf(stderr, "Error opening meta file '%s': %s\n", metafile, avi_error_string(avierr));
- err = CHDERR_CANT_CREATE_FILE;
- goto cleanup;
- }
- fprintf(meta, "chdmeta %d\n", metabytes);
- }
-
/* loop over hunks, reading and writing */
for (framenum = 0; framenum < numframes; framenum++)
{
@@ -1622,15 +1554,6 @@ static int do_extractav(int argc, char *argv[], int param)
goto cleanup;
}
- /* write the metadata */
- if (meta != NULL)
- {
- int metaoffs;
- for (metaoffs = 0; metaoffs < metabytes; metaoffs++)
- fprintf(meta, "%02X", ((UINT8 *)hunk)[12 + metaoffs]);
- fprintf(meta, "\n");
- }
-
/* write the hunk to the file */
avierr = write_avi_frame(avi, framenum, hunk, &videobitmap);
if (avierr != AVIERR_NONE)
@@ -1652,13 +1575,8 @@ cleanup:
free(videobitmap.base);
if (chd != NULL)
chd_close(chd);
- if (meta != NULL)
- fclose(meta);
if (err != CHDERR_NONE)
- {
osd_rmfile(outputfile);
- osd_rmfile(metafile);
- }
return (err != CHDERR_NONE);
}