comparison read_cache.c @ 242:f794e1c17947 src

porting AMD64 patches from xine (provided by Goetz Waschk and Gwenole Beauchesne from Mandrake)
author mroi
date Wed, 03 Mar 2004 16:48:36 +0000
parents 065a2835ba90
children ef3b33441db5
comparison
equal deleted inserted replaced
241:12cff2e56f55 242:f794e1c17947
1 /* 1 /*
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net> 2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net>
3 * 2001-2004 the dvdnav project
3 * 4 *
4 * This file is part of libdvdnav, a DVD navigation library. 5 * This file is part of libdvdnav, a DVD navigation library.
5 * 6 *
6 * libdvdnav is free software; you can redistribute it and/or modify 7 * libdvdnav is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
179 use = i; 180 use = i;
180 if (use >= 0) { 181 if (use >= 0) {
181 self->chunk[use].cache_buffer_base = realloc(self->chunk[use].cache_buffer_base, 182 self->chunk[use].cache_buffer_base = realloc(self->chunk[use].cache_buffer_base,
182 block_count * DVD_VIDEO_LB_LEN + ALIGNMENT); 183 block_count * DVD_VIDEO_LB_LEN + ALIGNMENT);
183 self->chunk[use].cache_buffer = 184 self->chunk[use].cache_buffer =
184 (uint8_t *)(((uintptr_t)self->chunk[use].cache_buffer_base & ~(ALIGNMENT - 1)) + ALIGNMENT); 185 (uint8_t *)(((uintptr_t)self->chunk[use].cache_buffer_base & ~((uintptr_t)(ALIGNMENT - 1))) + ALIGNMENT);
185 dprintf("pre_cache DVD read realloc happened\n"); 186 dprintf("pre_cache DVD read realloc happened\n");
186 self->chunk[use].cache_malloc_size = block_count; 187 self->chunk[use].cache_malloc_size = block_count;
187 } else { 188 } else {
188 /* we still haven't found a cache chunk, let's allocate a new one */ 189 /* we still haven't found a cache chunk, let's allocate a new one */
189 for (i = 0; i < READ_CACHE_CHUNKS; i++) 190 for (i = 0; i < READ_CACHE_CHUNKS; i++)
197 * This is so that fewer realloc's happen if at all. 198 * This is so that fewer realloc's happen if at all.
198 */ 199 */
199 self->chunk[i].cache_buffer_base = 200 self->chunk[i].cache_buffer_base =
200 malloc((block_count > 500 ? block_count : 500) * DVD_VIDEO_LB_LEN + ALIGNMENT); 201 malloc((block_count > 500 ? block_count : 500) * DVD_VIDEO_LB_LEN + ALIGNMENT);
201 self->chunk[i].cache_buffer = 202 self->chunk[i].cache_buffer =
202 (uint8_t *)(((uintptr_t)self->chunk[i].cache_buffer_base & ~(ALIGNMENT - 1)) + ALIGNMENT); 203 (uint8_t *)(((uintptr_t)self->chunk[i].cache_buffer_base & ~((uintptr_t)(ALIGNMENT - 1))) + ALIGNMENT);
203 self->chunk[i].cache_malloc_size = block_count > 500 ? block_count : 500; 204 self->chunk[i].cache_malloc_size = block_count > 500 ? block_count : 500;
204 dprintf("pre_cache DVD read malloc %d blocks\n", 205 dprintf("pre_cache DVD read malloc %d blocks\n",
205 (block_count > 500 ? block_count : 500 )); 206 (block_count > 500 ? block_count : 500 ));
206 } 207 }
207 } 208 }