static void
clutter_x11_texture_pixmap_init (ClutterX11TexturePixmap *self)
{
  self->priv =
      G_TYPE_INSTANCE_GET_PRIVATE (self,
                                   CLUTTER_X11_TYPE_TEXTURE_PIXMAP,
                                   ClutterX11TexturePixmapPrivate);

  if (!check_extensions (self))
    {
      /* FIMXE: means display lacks needed extensions for at least auto.
       *        - a _can_autoupdate() method ?
      */
    }

  self->priv->image = NULL;
  self->priv->automatic_updates = FALSE;
  self->priv->damage = None;
  self->priv->damage_drawable = None;
  self->priv->window = None;
  self->priv->pixmap = None;
  self->priv->pixmap_height = 0;
  self->priv->pixmap_width = 0;
  self->priv->shminfo.shmid = -1;
  self->priv->window_mapped = FALSE;
  self->priv->destroyed = FALSE;
  self->priv->override_redirect = FALSE;
  self->priv->allow_alpha = TRUE;
  self->priv->window_x = 0;
  self->priv->window_y = 0;
  self->priv->shapes = 0;
}
Пример #2
0
/* MTA2 in containers */
VGMSTREAM * init_vgmstream_mta2_container(STREAMFILE *streamFile) {
    VGMSTREAM *vgmstream = NULL;
    STREAMFILE *temp_streamFile = NULL;
    off_t subfile_offset;


    /* checks */
    /* .dbm: iPod metadata + mta2 with KCEJ blocks, .bgm: mta2 with KCEJ blocks (fake?) */
    if ( !check_extensions(streamFile,"dbm,bgm,mta2"))
        goto fail;

    if (read_32bitBE(0x00,streamFile) == 0x444C424D) { /* "DLBM" */
        subfile_offset = 0x800;
    }
    else if (read_32bitBE(0x00,streamFile) == 0x00000010) {
        subfile_offset = 0x00;
    }
    else {
        goto fail;
    }
    /* subfile size is implicit in KCEJ blocks */

    temp_streamFile = setup_mta2_streamfile(streamFile, subfile_offset, 1, "mta2");
    if (!temp_streamFile) goto fail;

    vgmstream = init_vgmstream_mta2(temp_streamFile);
    close_streamfile(temp_streamFile);

    return vgmstream;

fail:
    close_streamfile(temp_streamFile);
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #3
0
/* MIB+MIH - SCEE MultiStream interleaved bank (header+data) [namCollection: Ace Combat 2 (PS2), Rampage: Total Destruction (PS2)] */
VGMSTREAM * init_vgmstream_mib_mih(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    STREAMFILE * streamHeader = NULL;
    off_t start_offset;
    size_t data_size, frame_size, frame_last, frame_count;
    int channel_count, loop_flag;

    /* check extension */
    if (!check_extensions(streamFile, "mib"))
        goto fail;

    streamHeader = open_streamfile_by_ext(streamFile,"mih");
    if (!streamHeader) goto fail;

    if (read_32bitBE(0x00,streamHeader) != 0x40000000) /* header size */
        goto fail;

    loop_flag = 0; /* MIB+MIH don't PS-ADPCM loop flags */
    channel_count = read_32bitLE(0x08,streamHeader);
    start_offset = 0x00;

    /* 0x04: padding (0x20, MIH header must be multiple of 0x40) */
    frame_last  = (uint16_t)read_16bitLE(0x05,streamHeader);
    frame_size  = read_32bitLE(0x10,streamHeader);
    frame_count = read_32bitLE(0x14,streamHeader);
    if (frame_count == 0) { /* rarely [Gladius (PS2)] */
        frame_count = get_streamfile_size(streamFile) / (frame_size * channel_count);
    }

    data_size  = frame_count * frame_size;
    data_size -= frame_last ? (frame_size-frame_last) : 0; /* last frame has less usable data */
    data_size *= channel_count;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = read_32bitLE(0x0C,streamHeader);
    vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count);

    vgmstream->meta_type = meta_PS2_MIB_MIH;
    vgmstream->coding_type = coding_PSX;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = frame_size;

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    close_streamfile(streamHeader);
    return vgmstream;

fail:
close_streamfile(streamHeader);
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #4
0
/* 04SW - found in Driver: Parallel Lines (Wii) */
VGMSTREAM * init_vgmstream_wii_04sw(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count;
    size_t file_size, data_size;


    /* checks */
    /* ".04sw" is just the ID, the real filename inside the file uses .XA */
    if (!check_extensions(streamFile,"xa,04sw"))
        goto fail;
    if (read_32bitBE(0x00,streamFile) != 0x30345357) /* "04SW" */
        goto fail;

    /* after the ID goes a semi-standard DSP header */
    if (read_32bitBE(0x10,streamFile) != 0) goto fail; /* should be non looping */
    loop_flag = 0;
    /* not in header it seems so just dual header check */
    channel_count = (read_32bitBE(0x04,streamFile) == read_32bitBE(0x64,streamFile)) ? 2 : 1;

    start_offset = read_32bitBE(0x04 + 0x60*channel_count,streamFile);

    file_size = get_streamfile_size(streamFile);
    data_size = read_32bitBE(0x04 + 0x60*channel_count + 0x04,streamFile);
    if (data_size+start_offset != file_size) goto fail;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = read_32bitBE(0x0c,streamFile);
    vgmstream->num_samples = read_32bitBE(0x04,streamFile);

    vgmstream->coding_type = coding_NGC_DSP;
    vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
    vgmstream->interleave_block_size = 0x8000;
    vgmstream->interleave_last_block_size = (read_32bitBE(0x08,streamFile) / 2 % vgmstream->interleave_block_size + 7) / 8 * 8;

    dsp_read_coefs_be(vgmstream,streamFile,0x20, 0x60);
    /* the initial history offset seems different thatn standard DSP and possibly always zero */

    vgmstream->meta_type = meta_WII_04SW;
    /* the rest of the header has unknown values (several repeats) and the filename */


    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #5
0
VGMSTREAM * init_vgmstream_ngc_adpdtk(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset = 0;
    int channel_count = 2, loop_flag = 0; /* always stereo, no loop */

    /* check extension, case insensitive */
    if ( !check_extensions(streamFile,"dtk,adp"))
        goto fail;

    /* .adp files have no header, and the ext is common, so all we can do is look for valid first frames */
    if (check_extensions(streamFile,"adp")) {
        int i;
        for (i = 0; i < 10; i++) { /* try a bunch of frames */
            if (read_8bit(0x00 + i*0x20,streamFile) != read_8bit(0x02 + i*0x20,streamFile) ||
                read_8bit(0x01 + i*0x20,streamFile) != read_8bit(0x03 + i*0x20,streamFile))
                goto fail;
        }
    }


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count, loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->num_samples = get_streamfile_size(streamFile) / 32 * 28;
    vgmstream->sample_rate = 48000;
    vgmstream->coding_type = coding_NGC_DTK;
    vgmstream->layout_type = layout_none;
    vgmstream->meta_type = meta_NGC_ADPDTK;


    /* open the file for reading */
    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;

    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #6
0
bool
EGL_KHR_create_context_setup(EGLint renderable_type_mask)
{
	EGLint config_attribs[] = {
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT,
		EGL_RED_SIZE, 1,
		EGL_GREEN_SIZE, 1,
		EGL_BLUE_SIZE, 1,
		EGL_DEPTH_SIZE, 1,
		EGL_RENDERABLE_TYPE, renderable_type_mask,
		EGL_NONE
	};
	EGLint count;

	dpy = XOpenDisplay(NULL);
	if (dpy == NULL) {
		fprintf(stderr, "couldn't open display\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	egl_dpy = eglGetDisplay(dpy);
	if (egl_dpy == EGL_NO_DISPLAY) {
		fprintf(stderr, "eglGetDisplay() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
		fprintf(stderr, "eglInitialize() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	if (!eglChooseConfig(egl_dpy, config_attribs, &cfg, 1, &count) ||
	    count == 0) {
		if (eglGetError() == EGL_BAD_ATTRIBUTE) {
			/* Piglit requests only valid attributes, therefore
			 * EGL_BAD_ATTRIBUTE should not be emitted.
			 */
			fprintf(stderr, "eglChooseConfig() emitted "
			        "EGL_BAD_ATTRIBUTE\n");
			piglit_report_result(PIGLIT_FAIL);
		}

		return false;
	}

	check_extensions();
	return true;
}
Пример #7
0
/* MSA (from Psyvariar -Complete Edition-) */
VGMSTREAM * init_vgmstream_ps2_msa(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset, datasize, filesize;
    int loop_flag, channel_count;

    /* check extension, case insensitive */
    if (!check_extensions(streamFile, "msa")) goto fail;

    /* check header */
    if (read_32bitBE(0x00,streamFile) != 0x00000000)
        goto fail;

    loop_flag = 0;
    channel_count = 2;

    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    start_offset = 0x14;
    datasize = read_32bitLE(0x4,streamFile);
    filesize = get_streamfile_size(streamFile);
    vgmstream->channels = channel_count;
    vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
    vgmstream->num_samples = datasize*28/(16*channel_count);
    vgmstream->coding_type = coding_PSX;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x4000;
    vgmstream->meta_type = meta_PS2_MSA;

    /* MSAs are strangely truncated, so manually calculate samples
     *  data after last usable block is always silence or garbage */
    if (datasize > filesize) {
        off_t usable_size = filesize - start_offset;
        usable_size -= usable_size % (vgmstream->interleave_block_size*channel_count);/* block-aligned */
        vgmstream->num_samples = usable_size * 28 / (16*channel_count);
    }


    /* open the file for reading */
    if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #8
0
static gboolean
gst_vaapi_display_x11_bind_display (GstVaapiDisplay * base_display,
    gpointer native_display)
{
  GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
  GstVaapiDisplayX11Private *const priv = display->priv;

  priv->x11_display = native_display;
  priv->x11_screen = DefaultScreen (native_display);
  priv->use_foreign_display = TRUE;

  check_extensions (display);

  if (!set_display_name (display, XDisplayString (priv->x11_display)))
    return FALSE;
  return TRUE;
}
Пример #9
0
/* .ASS - from Dai Senryaku VII: Exceed (PS2) */
VGMSTREAM * init_vgmstream_ps2_ass(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    size_t channel_size, interleave;
    int loop_flag, channel_count, sample_rate;
    int32_t num_samples, loop_start = 0, loop_end = 0;


    /* checks */
    if (!check_extensions(streamFile, "ass"))
        goto fail;

    start_offset = 0x800;
    channel_count = read_32bitLE(0x00,streamFile); /* assumed */
    if (channel_count != 2) goto fail;
    sample_rate = read_32bitLE(0x04,streamFile);
    channel_size = read_32bitLE(0x08,streamFile);
    interleave = read_32bitLE(0x0c,streamFile);
    num_samples = ps_bytes_to_samples(channel_size,1);

    loop_flag = ps_find_loop_offsets(streamFile, start_offset, channel_size*channel_count, channel_count, interleave, &loop_start, &loop_end);
    loop_flag = loop_flag && (num_samples > 10*sample_rate); /* disable looping for smaller files (in seconds) */


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->meta_type = meta_PS2_ASS;
    vgmstream->sample_rate = sample_rate;
    vgmstream->num_samples = num_samples;
    vgmstream->loop_start_sample = loop_start;
    vgmstream->loop_end_sample = loop_end;

    vgmstream->coding_type = coding_PSX;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = interleave;

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #10
0
/* .SMV - from Cho Aniki Zero (PSP) */
VGMSTREAM * init_vgmstream_smv(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count;
    size_t channel_size, loop_start;


    /* check extension */
    if (!check_extensions(streamFile, "smv"))
        goto fail;

    channel_size = read_32bitLE(0x00,streamFile);
    /* 0x08: number of full interleave blocks */
    channel_count = read_16bitLE(0x0a,streamFile);
    loop_start = read_32bitLE(0x18,streamFile);
    loop_flag = (loop_start != -1);
    start_offset = 0x800;

    if (channel_size * channel_count + start_offset != get_streamfile_size(streamFile))
        goto fail;

    channel_size -= 0x10; /* last value has SPU end frame without flag 0x7 as it should */

    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count, loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = read_32bitLE(0x10, streamFile);
    vgmstream->num_samples = ps_bytes_to_samples(channel_size*channel_count, channel_count);
    vgmstream->loop_start_sample = ps_bytes_to_samples(loop_start*channel_count, channel_count);
    vgmstream->loop_end_sample = vgmstream->num_samples;

    vgmstream->meta_type = meta_SMV;
    vgmstream->coding_type = coding_PSX;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = read_32bitLE(0x04, streamFile);
    vgmstream->interleave_last_block_size = read_32bitLE(0x0c, streamFile);

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #11
0
/* NXAP - Nex Entertainment header [Time Crisis 4 (PS3), Time Crisis Razing Storm (PS3)] */
VGMSTREAM * init_vgmstream_nxap(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count;


    /* checks */
    if (!check_extensions(streamFile, "adp"))
        goto fail;
    if (read_32bitBE(0x00,streamFile) != 0x4E584150) /* "NXAP" */
        goto fail;
    if (read_32bitLE(0x14,streamFile) != 0x40 ||    /* expected frame size? */
        read_32bitLE(0x18,streamFile) != 0x40)      /* expected interleave? */
        goto fail;

    start_offset = read_32bitLE(0x04,streamFile);
    channel_count = read_32bitLE(0x0c,streamFile);
    loop_flag = 0; //(read_32bitLE(0x24,streamFile) > 0); //todo


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count, loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = read_32bitLE(0x10, streamFile);
    vgmstream->num_samples = read_32bitLE(0x1c,streamFile) * (0x40-0x04)*2 / channel_count; /* number of frames */

    /* unknown loop format, also 0x28/2c values seem related */
    //vgmstream->loop_start_sample = read_32bitLE(0x20,streamFile) * (0x40-0x04)*2 / channel_count;
    //vgmstream->loop_end_sample = read_32bitLE(0x24,streamFile) * (0x40-0x04)*2 / channel_count;
    //vgmstream->loop_end_sample = vgmstream->loop_start_sample + vgmstream->loop_end_sample;

    vgmstream->meta_type = meta_NXAP;
    vgmstream->coding_type = coding_NXAP;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x40;

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #12
0
/* STRM - from Final Fantasy Tactics A2 (NDS) */
VGMSTREAM * init_vgmstream_nds_strm_ffta2(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count;


    /* checks*/
    /* .bin: actual extension
     * .strm: header id */
    if (!check_extensions(streamFile,"bin,strm"))
        goto fail;

    /* check header */
    if (read_32bitBE(0x00,streamFile) != 0x52494646 ||  /* "RIFF" */
        read_32bitBE(0x08,streamFile) != 0x494D4120)    /* "IMA " */
        goto fail;

    loop_flag = (read_32bitLE(0x20,streamFile) !=0);
    channel_count = read_32bitLE(0x24,streamFile);
    start_offset = 0x2C;

    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->channels = channel_count;
    vgmstream->sample_rate = read_32bitLE(0x0C,streamFile);
    vgmstream->num_samples = (read_32bitLE(0x04,streamFile)-start_offset);
    vgmstream->loop_start_sample = read_32bitLE(0x20,streamFile);
    vgmstream->loop_end_sample = read_32bitLE(0x28,streamFile);

    vgmstream->meta_type = meta_NDS_STRM_FFTA2;

    vgmstream->coding_type = coding_FFTA2_IMA;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x80;

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #13
0
/* .RXW - legacy fake ext/header for poorly split XWH+XWB files generated by old tools (incorrect header/chunk sizes) */
VGMSTREAM * init_vgmstream_ps2_rxw(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    int loop_flag=0, channel_count;
    off_t start_offset;

    /* check extension, case insensitive */
    if (!check_extensions(streamFile,"rxw")) goto fail;

    /* check RXWS/FORM Header */
    if (!((read_32bitBE(0x00,streamFile) == 0x52585753) && 
          (read_32bitBE(0x10,streamFile) == 0x464F524D)))
        goto fail;

    loop_flag = (read_32bitLE(0x3C,streamFile)!=0xFFFFFFFF);
    channel_count=2; /* Always stereo files */
    
    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = read_32bitLE(0x2E,streamFile);
    vgmstream->num_samples = (read_32bitLE(0x38,streamFile)*28/16)/2;

    /* Get loop point values */
    if(vgmstream->loop_flag) {
        vgmstream->loop_start_sample = read_32bitLE(0x3C,streamFile)/16*14;
        vgmstream->loop_end_sample = read_32bitLE(0x38,streamFile)/16*14;
    }

    vgmstream->interleave_block_size = read_32bitLE(0x1c,streamFile)+0x10;
    vgmstream->coding_type = coding_PSX;
    vgmstream->layout_type = layout_interleave;
    vgmstream->meta_type = meta_PS2_RXWS;
    start_offset = 0x40;

    /* open the file for reading */
    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;

    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #14
0
static gboolean
gst_mfx_display_x11_open_display (GstMfxDisplay * base_display,
    const gchar * name)
{
  GstMfxDisplayX11 *const display = GST_MFX_DISPLAY_X11_CAST (base_display);
  GstMfxDisplayX11Private *const priv = &display->priv;

  set_display_name (display, name);

  GST_MFX_DISPLAY_HANDLE (base_display) = XOpenDisplay (priv->display_name);
  if (!GST_MFX_DISPLAY_HANDLE (base_display))
    return FALSE;

  priv->x11_screen = DefaultScreen (GST_MFX_DISPLAY_HANDLE (base_display));

  check_extensions (base_display);
  return TRUE;
}
Пример #15
0
/* .208 - from Ocean game(s?) [Last Rites (PC)] */
VGMSTREAM * init_vgmstream_208(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count, sample_rate;
    size_t data_size;


    /* checks */
    if (!check_extensions(streamFile, "208"))
        goto fail;
    /* possible validation: (0x04 == 0 and 0xcc == 0x1F7D984D) or 0x04 == 0xf0 and 0xcc == 0) */
    if (!((read_32bitLE(0x04,streamFile) == 0x00 && read_32bitBE(0xcc,streamFile) == 0x1F7D984D) ||
          (read_32bitLE(0x04,streamFile) == 0xF0 && read_32bitBE(0xcc,streamFile) == 0x00000000)))
        goto fail;

    start_offset    = read_32bitLE(0x00,streamFile);
    data_size       = read_32bitLE(0x0c,streamFile);
    sample_rate     = read_32bitLE(0x34,streamFile);
    channel_count   = read_32bitLE(0x3C,streamFile); /* assumed */
    loop_flag = 0;

    if (start_offset + data_size != get_streamfile_size(streamFile))
        goto fail;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count, loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->meta_type = meta_208;
    vgmstream->sample_rate = sample_rate;
    vgmstream->num_samples = pcm_bytes_to_samples(data_size, channel_count, 8);
    vgmstream->coding_type = coding_PCM8_U;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x1;

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #16
0
static void
run_subtest(const struct subtest_t st, bool *pass)
{
	enum piglit_result result;
	bool local_pass = true;
	int index, i = 0;

	if (*st.prog == -1 || !check_extensions(*st.prog, st.programInterface)) {
		result = PIGLIT_SKIP;
		goto report_result;
	}

	if (st.programInterface != GL_ATOMIC_COUNTER_BUFFER) {
		index = glGetProgramResourceIndex(*st.prog,
						  st.programInterface, st.name);
		piglit_check_gl_error(GL_NO_ERROR);
		if (index < 0) {
			printf("	Could not find resource '%s' in program"
			       " %u\n", st.name, *st.prog);
			result = PIGLIT_FAIL;
			goto report_result;
		}
	} else {
		/* As we cannot query the index of an atomic variable, let's
		 * hardcode it to 0 and make sure the program only has ONE
		 * atomic variable. In our case, we only use the fs_atom stage
		 * which defines only one variable.
		 */
		index = 0;
	}

	while (st.props[i].prop != 0) {
		check_prop(*st.prog, st.programInterface, index, st.name,
			   st.inputs, st.props[i], &local_pass);
		i++;
	}

	*pass = *pass && local_pass;
	result = local_pass ? PIGLIT_PASS : PIGLIT_FAIL;

report_result:
	piglit_report_subtest_result(result, "%s on %s", st.name,
				  piglit_get_gl_enum_name(st.programInterface));
}
Пример #17
0
/* .PCM - KCE Japan East PS2 games (Ephemeral Fantasia, Yu-Gi-Oh! The Duelists of the Roses, 7 Blades) */
VGMSTREAM * init_vgmstream_ps2_pcm(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count;

    /* check extension */
    if ( !check_extensions(streamFile,"pcm") )
        goto fail;

    /* check header (data_size vs num_samples) */
    if (pcm_bytes_to_samples(read_32bitLE(0x00,streamFile), 2, 16) != read_32bitLE(0x04,streamFile))
        goto fail;
    /* should work too */
    //if (read_32bitLE(0x00,streamFile)+0x800 != get_streamfile_size(streamFile))
    //    goto fail;

    loop_flag = (read_32bitLE(0x0C,streamFile) != 0x00);
    channel_count = 2;
    start_offset = 0x800;

    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->channels = channel_count;
    vgmstream->sample_rate = 24000;
    vgmstream->num_samples = read_32bitLE(0x04,streamFile);
    vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile);
    vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile);

    vgmstream->coding_type = coding_PCM16LE;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x2;
    vgmstream->meta_type = meta_PS2_PCM;

    /* open the file for reading */
    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;
    return vgmstream;

fail:
    if (vgmstream) close_vgmstream(vgmstream);
    return NULL;
}
Пример #18
0
/* MUSC - from Krome's PS2 games (The Legend of Spyro, Ty the Tasmanian Tiger) */
VGMSTREAM * init_vgmstream_musc(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    int loop_flag, channel_count;
    off_t start_offset;
    size_t data_size;

    /* .mus is the real extension, .musc is the header ID */
    if (!check_extensions(streamFile,"mus,musc"))
        goto fail;
    if (read_32bitBE(0x00,streamFile) != 0x4D555343) /* "MUSC" */
        goto fail;

    start_offset = read_32bitLE(0x10,streamFile);
    data_size    = read_32bitLE(0x14,streamFile);
    if (start_offset + data_size != get_streamfile_size(streamFile))
        goto fail;
    /* always does full loops unless it ends in silence */
    loop_flag = read_32bitBE(get_streamfile_size(streamFile) - 0x10,streamFile) != 0x0C000000;
    channel_count = 2;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = (uint16_t)read_16bitLE(0x06,streamFile);
    vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count);
    vgmstream->loop_start_sample = 0;
    vgmstream->loop_end_sample = vgmstream->num_samples;

    vgmstream->meta_type = meta_MUSC;
    vgmstream->coding_type = coding_PSX;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = read_32bitLE(0x18,streamFile) / 2;

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;

    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #19
0
static gboolean
gst_vaapi_display_x11_open_display (GstVaapiDisplay * base_display,
    const gchar * name)
{
  GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
  GstVaapiDisplayX11Private *const priv = display->priv;

  if (!set_display_name (display, name))
    return FALSE;

  priv->x11_display = XOpenDisplay (get_display_name (display));
  if (!priv->x11_display)
    return FALSE;
  priv->use_foreign_display = FALSE;

  priv->x11_screen = DefaultScreen (priv->x11_display);

  check_extensions (display);
  return TRUE;
}
Пример #20
0
/* A2M - from Artificial Mind & Movement games [Scooby-Doo! Unmasked (PS2)] */
VGMSTREAM * init_vgmstream_a2m(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    size_t data_size;
    int loop_flag, channel_count;


    /* checks */
    if ( !check_extensions(streamFile,"int") )
        goto fail;
    if (read_32bitBE(0x00,streamFile) != 0x41324D00) /* "A2M\0" */
        goto fail;
    if (read_32bitBE(0x04,streamFile) != 0x50533200) /* "PS2\0" */
        goto fail;

    start_offset = 0x30;
    data_size = get_streamfile_size(streamFile) - start_offset;
    channel_count = 2;
    loop_flag = 0;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->meta_type = meta_A2M;
    vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
    vgmstream->num_samples = ps_bytes_to_samples(data_size,channel_count);

    vgmstream->coding_type = coding_PSX;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x6000;

    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #21
0
/* .VAI - from Asobo Studio games [Ratatouille (GC)] */
VGMSTREAM * init_vgmstream_vai(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    size_t data_size;
    int loop_flag, channel_count;


    /* checks */
    if ( !check_extensions(streamFile,"vai") )
        goto fail;

    start_offset = 0x4060;
    data_size = get_streamfile_size(streamFile) - start_offset;
    if (read_32bitBE(0x04,streamFile) != data_size)
        goto fail;

    channel_count = 2;
    loop_flag = 0;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->meta_type = meta_VAI;
    vgmstream->sample_rate = read_32bitBE(0x00,streamFile);
    vgmstream->num_samples = dsp_bytes_to_samples(data_size,channel_count);

    vgmstream->coding_type = coding_NGC_DSP;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x4000;
    dsp_read_coefs_be(vgmstream,streamFile,0x0c,0x20);

    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #22
0
/* ASTL - found in Dead Rising (PC) */
VGMSTREAM * init_vgmstream_pc_ast(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
	off_t start_offset, data_size;
    int loop_flag, channel_count;

    /* check extension, case insensitive */
    if ( !check_extensions(streamFile,"ast"))
        goto fail;

    if (read_32bitBE(0x00,streamFile) != 0x4153544C) /* "ASTL" */
        goto fail;


    loop_flag = 0; //TODO - Find hidden loop point calc and flag
	channel_count = read_8bit(0x32, streamFile);
	data_size = read_32bitLE(0x20,streamFile);


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

	/* TODO - Find non-obvious loop points and flag (if any) */
    start_offset = read_32bitLE(0x10,streamFile);
    vgmstream->sample_rate = read_32bitLE(0x34,streamFile);
	vgmstream->coding_type = coding_PCM16LE;
    vgmstream->num_samples = data_size/(channel_count*2);
	vgmstream->layout_type = layout_interleave;
	vgmstream->interleave_block_size = 0x2;
    vgmstream->meta_type = meta_PC_AST;

    /* open the file for reading */
    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #23
0
/* ADS in containers */
VGMSTREAM * init_vgmstream_ps2_ads_container(STREAMFILE *streamFile) {
    VGMSTREAM *vgmstream = NULL;
    STREAMFILE *temp_streamFile = NULL;
    off_t subfile_offset;
    size_t subfile_size;

    /* checks */
    if (!check_extensions(streamFile, "ads"))
        goto fail;

    if (read_32bitBE(0x00,streamFile) == 0x41445343 &&  /* "ADSC" */
        read_32bitBE(0x04,streamFile) == 0x01000000) {
        /* Kenka Bancho 2, Kamen Rider Hibiki/Kabuto, Shinjuku no Okami */
        subfile_offset = 0x08;
    }
    else if (read_32bitBE(0x00,streamFile) == 0x63617669 && /* "cavi" */
             read_32bitBE(0x04,streamFile) == 0x61207374 && /* "a st" */
             read_32bitBE(0x08,streamFile) == 0x7265616D) { /* "ream" */
        /* cavia games: Drakengard 1/2, Dragon Quest Yangus, GITS: Stand Alone Complex */
        subfile_offset = 0x7d8;
    }
    else {
        goto fail;
    }

    subfile_size = get_streamfile_size(streamFile) - subfile_offset;

    temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, NULL);
    if (!temp_streamFile) goto fail;

    vgmstream = init_vgmstream_ps2_ads(temp_streamFile);
    close_streamfile(temp_streamFile);

    return vgmstream;

fail:
    close_streamfile(temp_streamFile);
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #24
0
/* Maxis XA - found in Sim City 3000 (PC) */
VGMSTREAM * init_vgmstream_maxis_xa(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count;

    /* check extension, case insensitive */
    if (!check_extensions(streamFile,"xa"))
        goto fail;

    /* check header */
    if ((read_32bitBE(0x00,streamFile) != 0x58414900) && /* "XAI\0" */
        (read_32bitBE(0x00,streamFile) != 0x58414A00))   /* "XAJ\0" (some odd song uses this, no apparent diffs) */
        goto fail;

    loop_flag = 0;
    channel_count = read_16bitLE(0x0A,streamFile);
    start_offset = 0x18;

    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = read_32bitLE(0x0C,streamFile);
    vgmstream->num_samples = read_32bitLE(0x04,streamFile)/2/channel_count;

    vgmstream->meta_type = meta_MAXIS_XA;
    vgmstream->coding_type = coding_MAXIS_XA;
    vgmstream->layout_type = layout_none;

    /* open streams */
    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #25
0
/* AL" - headerless a-law, found in Conquest of Elysium 3 (PC) */
VGMSTREAM * init_vgmstream_pc_al2(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag = 0, channel_count;


    if ( !check_extensions(streamFile,"al2"))
        goto fail;

    channel_count = 2;

    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = 22050;
    vgmstream->coding_type = coding_ALAW;
    vgmstream->layout_type = layout_interleave;
    vgmstream->interleave_block_size = 0x01;
    vgmstream->meta_type = meta_PC_AL2;
    vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(streamFile), channel_count, 8);
    if (loop_flag) {
        vgmstream->loop_start_sample = 0;
        vgmstream->loop_end_sample = vgmstream->num_samples;
    }

    start_offset = 0;

    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #26
0
/* MTA2 - found in Metal Gear Solid 4 (PS3) */
VGMSTREAM * init_vgmstream_mta2(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag, channel_count, sample_rate;
    int32_t loop_start, loop_end;
    uint32_t sample_rate_int;


    /* checks */
    if ( !check_extensions(streamFile,"mta2"))
        goto fail;

    if (read_32bitBE(0x00,streamFile) != 0x4d544132) /* "MTA2" */
        goto fail;
    /* allow truncated files for now? */
    //if (read_32bitBE(0x04, streamFile) + 0x08 != get_streamfile_size(streamFile))
    //    goto fail;

    /* base header (everything is very similar to MGS3's MTAF but BE) */
    /* 0x08(4): version? (1),  0x0c(52): null */

    /* HEAD chunk */
    if (read_32bitBE(0x40, streamFile) != 0x48454144) /* "HEAD" */
        goto fail;
    if (read_32bitBE(0x44, streamFile) != 0xB0) /* HEAD size */
        goto fail;

    /* 0x48(4): null,  0x4c: ? (0x10),   0x50(4): 0x7F (vol?),  0x54(2): 0x40 (pan?) */
    channel_count = read_16bitBE(0x56, streamFile); /* counting all tracks */
    /* 0x60(4): full block size (0x110 * channels), indirectly channels_per_track = channels / (block_size / 0x110) */
    /* 0x80 .. 0xf8: null */

    loop_start = read_32bitBE(0x58, streamFile);
    loop_end   = read_32bitBE(0x5c, streamFile);
    loop_flag = (loop_start != loop_end); /* also flag possibly @ 0x73 */
#if 0
    /* those values look like some kind of loop offsets */
    if (loop_start/0x100 != read_32bitBE(0x68, streamFile) ||
        loop_end  /0x100 != read_32bitBE(0x6C, streamFile) ) {
        VGM_LOG("MTA2: wrong loop points\n");
        goto fail;
    }
#endif

    sample_rate_int = read_32bitBE(0x7c, streamFile);
    if (sample_rate_int) { /* sample rate in 32b float (WHY?) typically 48000.0 */
        float* sample_float = (float*)&sample_rate_int;
        sample_rate = (int)*sample_float;
    } else { /* default when not specified (most of the time) */
        sample_rate = 48000;
    }


    /* TRKP chunks (x16) */
    /* just seem to contain pan/vol stuff (0x7f/0x40), TRKP per track (sometimes +1 main track?) */
    /* there is channel layout bitmask at 0x0f (ex. 1ch = 0x04, 3ch = 0x07, 4ch = 0x33, 6ch = 0x3f), surely:
     * FL 0x01, FR 0x02, FC = 0x04, BL = 0x08, BR = 0x10, BC = 0x20 */

    start_offset = 0x800;

    /* DATA chunk */
    if (read_32bitBE(0x7f8, streamFile) != 0x44415441) // "DATA"
        goto fail;
    //if (read_32bitBE(0x7fc, streamFile) + start_offset != get_streamfile_size(streamFile))
    //    goto fail;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = sample_rate;
    vgmstream->num_samples = loop_end;
    vgmstream->loop_start_sample = loop_start;
    vgmstream->loop_end_sample = loop_end;

    vgmstream->coding_type = coding_MTA2;
    vgmstream->layout_type = layout_none;
    vgmstream->meta_type = meta_MTA2;

    /* open the file for reading */
    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #27
0
/* EA SCHl with fixed header - from EA games (~1997? ex. NHL 97 PC) */
VGMSTREAM * init_vgmstream_ea_schl_fixed(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    size_t header_size;
    ea_header ea = {0};


    /* check extension */
    if (!check_extensions(streamFile,"asf"))
        goto fail;

    /* check header (see ea_schl.c for more info about blocks) */
    if (read_32bitBE(0x00,streamFile) != 0x5343486C) /* "SCHl" */
        goto fail;

    header_size = read_32bitLE(0x04,streamFile);

    if (!parse_fixed_header(streamFile,&ea, 0x08))
        goto fail;

    start_offset = header_size;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(ea.channels, ea.loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = ea.sample_rate;
    vgmstream->num_samples = ea.num_samples;
    //vgmstream->loop_start_sample = ea.loop_start;
    //vgmstream->loop_end_sample = ea.loop_end;

    vgmstream->codec_endian = ea.big_endian;

    vgmstream->meta_type = meta_EA_SCHL_fixed;

    vgmstream->layout_type = layout_blocked_ea_schl;

    switch (ea.codec) {
        case EA_CODEC_PCM:
            vgmstream->coding_type = ea.bps==8 ? coding_PCM8 : (ea.big_endian ? coding_PCM16BE : coding_PCM16LE);
            break;

        case EA_CODEC_IMA:
            vgmstream->coding_type = coding_DVI_IMA; /* stereo/mono, high nibble first */
            break;

        default:
            VGM_LOG("EA: unknown codec 0x%02x\n", ea.codec);
            goto fail;
    }


    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #28
0
/* .OPUS - from Switch games (Lego City Undercover, Ultra SF II, Disgaea 5) */
VGMSTREAM * init_vgmstream_nsw_opus(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    int loop_flag = 0, channel_count;
    int num_samples = 0, loop_start = 0, loop_end = 0;
    off_t offset = 0;

    /* check extension, case insensitive */
    if ( !check_extensions(streamFile,"opus,lopus")) /* no relation to Ogg Opus */
        goto fail;

    /* variations, maybe custom */
    if (read_32bitBE(0x00,streamFile) == 0x01000080) { /* Lego City Undercover */
        offset = 0x00;
    }
    else if ((read_32bitBE(0x04,streamFile) == 0x00000000 && read_32bitBE(0x0c,streamFile) == 0x00000000) ||
             (read_32bitBE(0x04,streamFile) == 0xFFFFFFFF && read_32bitBE(0x0c,streamFile) == 0xFFFFFFFF)) { /* Disgaea 5 */
        offset = 0x10;

        loop_start = read_32bitLE(0x00,streamFile);
        loop_end = read_32bitLE(0x08,streamFile);
    }
    else if (read_32bitLE(0x04,streamFile) == 0x02) { /* Ultra Street Fighter II */
        offset = read_32bitLE(0x1c,streamFile);

        num_samples = read_32bitLE(0x00,streamFile);
        loop_start = read_32bitLE(0x08,streamFile);
        loop_end = read_32bitLE(0x0c,streamFile);
    }
    else {
        offset = 0x00;
    }

    if (read_32bitBE(offset + 0x00,streamFile) != 0x01000080)
        goto fail;

    start_offset = offset + 0x28;
    channel_count = read_8bit(offset + 0x09,streamFile); /* assumed */
    /* 0x0a: packet size if CBR?, other values: no idea */

    loop_flag = (loop_end > 0); /* -1 when not set */


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count,loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->sample_rate = read_32bitLE(offset + 0x0c,streamFile);
    vgmstream->meta_type = meta_NSW_OPUS;

    vgmstream->num_samples = num_samples;
    vgmstream->loop_start_sample = loop_start;
    vgmstream->loop_end_sample = loop_end;

#ifdef VGM_USE_FFMPEG
    {
        uint8_t buf[0x100];
        size_t bytes, skip, data_size;
        ffmpeg_custom_config cfg;

        data_size = get_streamfile_size(streamFile) - start_offset;
        skip = 0; //todo

        bytes = ffmpeg_make_opus_header(buf,0x100, vgmstream->channels, skip, vgmstream->sample_rate);
        if (bytes <= 0) goto fail;

        memset(&cfg, 0, sizeof(ffmpeg_custom_config));
        cfg.type = FFMPEG_SWITCH_OPUS;

        vgmstream->codec_data = init_ffmpeg_config(streamFile, buf,bytes, start_offset,data_size, &cfg);
        if (!vgmstream->codec_data) goto fail;

        vgmstream->coding_type = coding_FFmpeg;
        vgmstream->layout_type = layout_none;

        if (vgmstream->num_samples == 0)
            vgmstream->num_samples = switch_opus_get_samples(start_offset, data_size, vgmstream->sample_rate, streamFile);
    }
#else
    goto fail;
#endif

    /* open the file for reading */
    if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #29
0
/* XPCM - from Circus games [Eternal Fantasy (PC), D.C. White Season (PC)] */
VGMSTREAM * init_vgmstream_xpcm(STREAMFILE *streamFile) {
    VGMSTREAM * vgmstream = NULL;
    off_t start_offset;
    size_t decompressed_size;
    int loop_flag, channel_count, codec, subcodec, sample_rate;


    /* checks */
    if (!check_extensions(streamFile, "pcm"))
        goto fail;

    if (read_32bitBE(0x00,streamFile) != 0x5850434D) /* "XPCM" "*/
        goto fail;

    decompressed_size = read_32bitLE(0x04,streamFile); /* (data_size for PCM) */
    codec    = read_8bit(0x08, streamFile);
    subcodec = read_8bit(0x09, streamFile);
    /* 0x0a: always null */
    /* 0x0c: always 0x01 (PCM codec) */
    channel_count = read_16bitLE(0x0e,streamFile);
    sample_rate = read_32bitLE(0x10,streamFile);
    /* 0x14: average bitrate */
    /* 0x18: block size */
    /* 0x1a: output bits (16) */
    start_offset = 0x1c; /* compressed size in codec 0x01/03 */

    loop_flag  = 0;


    /* build the VGMSTREAM */
    vgmstream = allocate_vgmstream(channel_count, loop_flag);
    if (!vgmstream) goto fail;

    vgmstream->meta_type = meta_XPCM;
    vgmstream->sample_rate = sample_rate;
    vgmstream->num_samples = decompressed_size / sizeof(int16_t) / channel_count;

    switch(codec) {
        case 0x00:
            if (subcodec != 0) goto fail;
            vgmstream->coding_type = coding_PCM16LE;
            vgmstream->layout_type = layout_interleave;
            vgmstream->interleave_block_size = 0x02;
            break;
        case 0x02:
            if (subcodec != 0) goto fail;
            vgmstream->coding_type = coding_CIRCUS_ADPCM;
            vgmstream->layout_type = layout_interleave;
            vgmstream->interleave_block_size = 0x01;
            break;

        case 0x01: /* LZSS + VQ */
        case 0x03: /* unknown */
        default:
            goto fail;
    }

    if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
        goto fail;
    return vgmstream;

fail:
    close_vgmstream(vgmstream);
    return NULL;
}
Пример #30
0
char *find_executable(char *exename) {
    int n;
    char *p, *s;
    static char exepath[MAX_FILENAME_LEN + 1];

    if (exename == NULL || !*exename)
        return (NULL);

#ifdef _WIN32

    /* full path */

    if (*exename == '/' || *exename == '\\' || *(exename + 1) == ':') {
        strcpy(exepath, exename);
        return (check_extensions(exepath) ? exepath : NULL);
    }

    /* get current directory */

    if (NULL == _getcwd(exepath, MAX_FILENAME_LEN))
        error("find_executable", "couldn't get working directory");
    p = exepath + strlen(exepath);
    if (*(p - 1) == '\\')
        *--p = 0;

    /* relative path */

    if (0 == strncmp(exename, ".\\", 2) ||
            0 == strncmp(exename, "..\\", 3) ||
            0 == strncmp(exename, "./", 2) ||
            0 == strncmp(exename, "../", 3)) {
        if (exename[1] != '.')
            strcpy(p, &exename[1]);
        else {
            if (NULL == (p = strrchr(exepath, '\\')))
                p = exepath;
            strcpy(p, &exename[2]);
        }
        return (check_extensions(exepath) ? exepath : NULL);
    }

    /* current directory */

    *p++ = '\\';
    strcpy(p, exename);
    if (check_extensions(exepath))
        return (exepath);

#else

    /* full path */

    if (*exename == '/') {
        if (is_executable(exename))
            return (strcpy(exepath, exename));
        return (NULL);
    }

    /* relative path */

    if (0 == strncmp(exename, "./", 2) ||
            0 == strncmp(exename, "../", 3)) {
        if (NULL == getcwd(exepath, MAX_FILENAME_LEN))
            error("find_executable", "couldn't get working directory\n");
        p = exepath + strlen(exepath);
        if (*(p - 1) == '/')
            *--p = 0;
        if (exename[1] != '.')
            strcpy(p, &exename[1]);
        else {
            if (NULL == (p = strrchr(exepath, '/')))
                p = exepath;
            strcpy(p, &exename[2]);
        }
        return (is_executable(exepath) ? exepath : NULL);
    }

#endif

    /* scan $PATH environment variable */

    if (NULL == (p = getenv("PATH")))
        return (NULL);
    while (*p) {
        if (NULL == (s = strchr(p, PATH_DELIM))) {
            strcpy(exepath, p);
            n = strlen(exepath);
        } else {
            n = (int) (s++ - p);
            strncpy(exepath, p, n);
            exepath[n] = 0;
        }
        if (n) {
            p = exepath + n;
#ifdef _WIN32
            if (*(p - 1) != '\\')
                *p++ = '\\';
            strcpy(p, exename);
            if (check_extensions(exepath))
                return (exepath);
#else
            if (*(p - 1) != '/')
                *p++ = '/';
            strcpy(p, exename);
            if (is_executable(exepath))
                return (exepath);
#endif
        }
        if (NULL == (p = s)) break;
    }
    return (NULL);
}