[xiph-commits] r3678 - liboggplay/trunk/src/liboggplay
giles at svn.annodex.net
giles at svn.annodex.net
Mon Aug 4 21:22:58 PDT 2008
Author: giles
Date: 2008-08-04 21:22:57 -0700 (Mon, 04 Aug 2008)
New Revision: 3678
Modified:
liboggplay/trunk/src/liboggplay/oggplay.c
liboggplay/trunk/src/liboggplay/oggplay_buffer.c
liboggplay/trunk/src/liboggplay/oggplay_callback.c
liboggplay/trunk/src/liboggplay/oggplay_data.c
liboggplay/trunk/src/liboggplay/oggplay_data.h
liboggplay/trunk/src/liboggplay/oggplay_file_reader.c
liboggplay/trunk/src/liboggplay/oggplay_file_reader.h
liboggplay/trunk/src/liboggplay/oggplay_private.h
liboggplay/trunk/src/liboggplay/oggplay_query.c
liboggplay/trunk/src/liboggplay/oggplay_seek.c
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
liboggplay/trunk/src/liboggplay/oggplay_tools.c
liboggplay/trunk/src/liboggplay/oggplay_yuv2rgb.c
liboggplay/trunk/src/liboggplay/std_semaphore.h
Log:
Remove some trailing whitespace.
Modified: liboggplay/trunk/src/liboggplay/oggplay.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay.c
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
* Michael Martin
*/
@@ -49,7 +49,7 @@
oggplay_new_with_reader(OggPlayReader *reader) {
OggPlay * me = (OggPlay *)malloc(sizeof(OggPlay));
-
+
me->reader = reader;
me->decode_data = NULL;
me->callback_info = NULL;
@@ -59,7 +59,7 @@
me->callback = NULL;
me->target = 0L;
me->active_tracks = 0;
- me->buffer = NULL;
+ me->buffer = NULL;
me->shutdown = 0;
me->trash = NULL;
me->oggz = NULL;
@@ -74,9 +74,9 @@
OggPlayErrorCode return_val;
int i;
-
+
return_val = me->reader->initialise(me->reader, block);
-
+
if (return_val != E_OGGPLAY_OK) {
return return_val;
}
@@ -86,7 +86,7 @@
* We'll reinitialise it when/if we encounter a skeleton header
*/
me->presentation_time = 0;
-
+
/*
* start to retrieve data, until we get all of the track info. We need
* to do this now so that the user can query us for this info before entering
@@ -97,9 +97,9 @@
oggz_io_set_seek(me->oggz, me->reader->io_seek, me->reader);
oggz_io_set_tell(me->oggz, me->reader->io_tell, me->reader);
oggz_set_read_callback(me->oggz, -1, oggplay_callback_predetected, me);
-
+
while (1) {
-
+
if (oggz_read(me->oggz, OGGZ_READ_CHUNK_SIZE) < 0) {
return E_OGGPLAY_BAD_INPUT;
}
@@ -115,23 +115,23 @@
for (i = 0; i < me->num_tracks; i++) {
me->decode_data[i]->active = 0;
}
-
+
/*
* if the buffer was set up before initialisation, prepare it now
*/
if (me->buffer != NULL) {
oggplay_buffer_prepare(me);
}
-
+
return E_OGGPLAY_OK;
-
+
}
-
+
OggPlay *
oggplay_open_with_reader(OggPlayReader *reader) {
OggPlay *me = oggplay_new_with_reader(reader);
-
+
int r = E_OGGPLAY_TIMEOUT;
while (r == E_OGGPLAY_TIMEOUT) {
r = oggplay_initialise(me, 0);
@@ -144,13 +144,13 @@
return me;
}
-
+
/*
* API function to prevent bad input, and to prevent data callbacks being registered
* in buffer mode
*/
OggPlayErrorCode
-oggplay_set_data_callback(OggPlay *me, OggPlayDataCallback callback,
+oggplay_set_data_callback(OggPlay *me, OggPlayDataCallback callback,
void *user) {
if (me == NULL) {
@@ -163,11 +163,11 @@
oggplay_set_data_callback_force(me, callback, user);
return E_OGGPLAY_OK;
-
+
}
/*
- * internal function that doesn't perform error checking. Used so the buffer
+ * internal function that doesn't perform error checking. Used so the buffer
* can register a callback!
*/
void
@@ -176,7 +176,7 @@
me->callback = callback;
me->callback_user_ptr = user;
-
+
}
@@ -190,13 +190,13 @@
if (track < 0 || track >= me->num_tracks) {
return E_OGGPLAY_BAD_TRACK;
}
-
+
me->callback_period = me->decode_data[track]->granuleperiod * frames;
me->target = me->presentation_time + me->callback_period - 1;
-
+
return E_OGGPLAY_OK;
-
+
}
OggPlayErrorCode
@@ -211,7 +211,7 @@
}
me->decode_data[track]->offset = (offset << 32);
-
+
return E_OGGPLAY_OK;
}
@@ -219,7 +219,7 @@
OggPlayErrorCode
oggplay_get_video_fps(OggPlay *me, int track, int* fps_denom, int* fps_num) {
OggPlayTheoraDecode *decode;
-
+
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@@ -234,7 +234,7 @@
decode = (OggPlayTheoraDecode *)(me->decode_data[track]);
- if ((decode->video_info.fps_denominator == 0)
+ if ((decode->video_info.fps_denominator == 0)
|| (decode->video_info.fps_numerator == 0)) {
return E_OGGPLAY_UNINITIALISED;
}
@@ -249,7 +249,7 @@
oggplay_get_video_y_size(OggPlay *me, int track, int *y_width, int *y_height) {
OggPlayTheoraDecode *decode;
-
+
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@@ -261,18 +261,18 @@
if (me->decode_data[track]->decoded_type != OGGPLAY_YUV_VIDEO) {
return E_OGGPLAY_WRONG_TRACK_TYPE;
}
-
+
decode = (OggPlayTheoraDecode *)(me->decode_data[track]);
-
+
if (decode->y_width == 0) {
return E_OGGPLAY_UNINITIALISED;
}
-
+
(*y_width) = decode->y_width;
(*y_height) = decode->y_height;
-
+
return E_OGGPLAY_OK;
-
+
}
OggPlayErrorCode
@@ -280,7 +280,7 @@
{
OggPlayTheoraDecode *decode;
-
+
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@@ -292,18 +292,18 @@
if (me->decode_data[track]->decoded_type != OGGPLAY_YUV_VIDEO) {
return E_OGGPLAY_WRONG_TRACK_TYPE;
}
-
+
decode = (OggPlayTheoraDecode *)(me->decode_data[track]);
-
+
if (decode->y_width == 0) {
return E_OGGPLAY_UNINITIALISED;
}
-
+
(*uv_width) = decode->uv_width;
(*uv_height) = decode->uv_height;
-
+
return E_OGGPLAY_OK;
-
+
}
int
@@ -475,12 +475,12 @@
continue;
if (me->decode_data[i]->content_type == OGGZ_CONTENT_KATE)
continue;
- if
+ if
(
- me->decode_data[i]->current_loc
- <
+ me->decode_data[i]->current_loc
+ <
me->target + me->decode_data[i]->offset
- )
+ )
{
need_data = 1;
break;
@@ -490,7 +490,7 @@
if (!need_data) {
break;
}
-
+
/*
* get a chunk of data. If we're at the end of the file, then we must
* have some final frames to render (?). E_OGGPLAY_END_OF_FILE is
@@ -500,7 +500,7 @@
if (chunk_count > MAX_CHUNK_COUNT) {
return E_OGGPLAY_TIMEOUT;
}
-
+
chunk_count += 1;
r = oggz_read(me->oggz, OGGZ_READ_CHUNK_SIZE);
@@ -517,10 +517,10 @@
}
if (info != NULL) {
- me->callback (me, num_records, info, me->callback_user_ptr);
+ me->callback (me, num_records, info, me->callback_user_ptr);
oggplay_callback_info_destroy(me, info);
}
-
+
/*
* ensure all tracks have their final data packet set to end_of_stream
*/
@@ -542,7 +542,7 @@
} else {
r = 0;
}
-
+
/*
* clean the data lists
*/
@@ -570,9 +570,9 @@
oggplay_start_decoding(OggPlay *me) {
int r;
-
+
while (1) {
- if ((r = oggplay_step_decoding(me)) != E_OGGPLAY_CONTINUE)
+ if ((r = oggplay_step_decoding(me)) != E_OGGPLAY_CONTINUE)
return (OggPlayErrorCode)r;
}
}
@@ -581,7 +581,7 @@
oggplay_close(OggPlay *me) {
int i;
-
+
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@@ -592,21 +592,21 @@
for (i = 0; i < me->num_tracks; i++) {
oggplay_callback_shutdown(me->decode_data[i]);
- }
-
+ }
+
oggz_close(me->oggz);
-
+
if (me->buffer != NULL) {
oggplay_buffer_shutdown(me, me->buffer);
}
-
+
free(me);
return E_OGGPLAY_OK;
}
/*
- * this function is required to release the frame_sem in the buffer, if
+ * this function is required to release the frame_sem in the buffer, if
* the buffer is being used.
*/
void
@@ -629,7 +629,7 @@
current_time = oggz_tell_units(me->oggz);
current_byte = (ogg_int64_t)oggz_tell(me->oggz);
-
+
return me->reader->available(me->reader, current_byte, current_time);
}
@@ -640,7 +640,7 @@
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
-
+
return me->reader->duration(me->reader);
}
Modified: liboggplay/trunk/src/liboggplay/oggplay_buffer.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_buffer.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_buffer.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -43,9 +43,9 @@
#define OGGPLAY_DEFAULT_BUFFER_SIZE 20
#define WRAP_INC(c, s) ((c + 1) % s)
-
+
/*
* Call this function to initialise the oggplay lock-free buffer. Do not use
* the buffer and the callback together!
@@ -70,9 +70,9 @@
buffer->last_emptied = -1;
SEM_CREATE(buffer->frame_sem, size);
-
+
return buffer;
-
+
}
void
@@ -80,9 +80,9 @@
int i;
int j;
-
+
OggPlayBuffer *buffer = (OggPlayBuffer *)vbuffer;
-
+
for (i = 0; i < buffer->buffer_size; i++) {
if (buffer->buffer_mirror[i] != NULL) {
OggPlayCallbackInfo *ti = (OggPlayCallbackInfo *)buffer->buffer_mirror[i];
@@ -92,7 +92,7 @@
free(ti);
}
}
-
+
free(buffer->buffer_list);
free(buffer->buffer_mirror);
SEM_CLOSE(buffer->frame_sem);
@@ -102,7 +102,7 @@
int
oggplay_buffer_is_full(volatile OggPlayBuffer *buffer) {
- return
+ return
(
(buffer == NULL) || (
buffer->buffer_list[WRAP_INC(buffer->last_filled, buffer->buffer_size)]
@@ -120,7 +120,7 @@
int i;
OggPlayCallbackInfo *p;
- /*
+ /*
* we're at last data before we've even started!
*/
if (buffer->last_filled == -1) {
@@ -136,7 +136,7 @@
}
int
-oggplay_buffer_callback(OggPlay *me, int tracks,
+oggplay_buffer_callback(OggPlay *me, int tracks,
OggPlayCallbackInfo **track_info, void *user) {
int i;
@@ -148,7 +148,7 @@
int required;
buffer = (OggPlayBuffer *)me->buffer;
-
+
if (buffer == NULL) {
return -1;
}
@@ -158,7 +158,7 @@
if (me->shutdown) {
return -1;
}
-
+
/*
* lock the item going into the buffer so that it doesn't get cleaned up
*/
@@ -174,10 +174,10 @@
* check for and clean up empties
*/
for (k = 0; k < buffer->buffer_size; k++) {
- if
+ if
(
- (buffer->buffer_list[k] == NULL)
- &&
+ (buffer->buffer_list[k] == NULL)
+ &&
(buffer->buffer_mirror[k] != NULL)
) {
OggPlayCallbackInfo *ti = (OggPlayCallbackInfo *)buffer->buffer_mirror[k];
@@ -187,7 +187,7 @@
for (j = 0; j < required; j++) {
oggplay_callback_info_unlock_item(headers[j]);
}
- /* free these here, because we couldn't free them in
+ /* free these here, because we couldn't free them in
* oggplay_callback_info_destroy for buffer mode
*/
free((ti + i)->records);
@@ -196,35 +196,35 @@
buffer->buffer_mirror[k] = NULL;
}
}
-
+
/*
* replace the decode_data buffer for the next callback
*/
me->callback_info = (OggPlayCallbackInfo *)calloc(me->num_tracks, sizeof (OggPlayCallbackInfo));
-
+
/*
* fill both mirror and list, mirror first to avoid getting inconsistencies
*/
buffer->last_filled = WRAP_INC(buffer->last_filled, buffer->buffer_size);
-
+
/*
* set the buffer pointer in the first record
*/
ptr->buffer = buffer;
-
+
buffer->buffer_mirror[buffer->last_filled] = ptr;
buffer->buffer_list[buffer->last_filled] = ptr;
if (oggplay_buffer_is_full(buffer)) {
- /*
- * user interrupt when we fill the buffer rather than when we have a
+ /*
+ * user interrupt when we fill the buffer rather than when we have a
* decoded frame and the buffer is already full
*/
return -1;
}
-
+
return 0;
}
@@ -236,20 +236,20 @@
OggPlayCallbackInfo * next_item;
OggPlayCallbackInfo ** return_val;
int i;
-
+
if (me == NULL) {
return NULL;
}
-
+
buffer = (OggPlayBuffer *)me->buffer;
-
+
if (buffer == NULL) {
return NULL;
}
-
+
next_loc = WRAP_INC(buffer->last_emptied, buffer->buffer_size);
- if (buffer->buffer_list[next_loc] == NULL) {
+ if (buffer->buffer_list[next_loc] == NULL) {
return NULL;
}
@@ -257,13 +257,13 @@
buffer->last_emptied = next_loc;
return_val = malloc(sizeof (OggPlayCallbackInfo *) * me->num_tracks);
-
+
for (i = 0; i < me->num_tracks; i++) {
return_val[i] = next_item + i;
}
return return_val;
-
+
}
OggPlayErrorCode
@@ -284,7 +284,7 @@
if (buffer == NULL) {
return E_OGGPLAY_CALLBACK_MODE;
}
-
+
if (buffer->buffer_list[buffer->last_emptied] == NULL) {
return E_OGGPLAY_UNINITIALISED;
}
@@ -292,9 +292,9 @@
free(track_info);
buffer->buffer_list[buffer->last_emptied] = NULL;
-
+
SEM_SIGNAL(buffer->frame_sem);
-
+
return E_OGGPLAY_OK;
}
@@ -316,7 +316,7 @@
*/
return E_OGGPLAY_OK;
}
-
+
me->buffer = oggplay_buffer_new_buffer(size);
/*
@@ -325,23 +325,22 @@
if (me->all_tracks_initialised) {
oggplay_buffer_prepare(me);
}
-
+
return E_OGGPLAY_OK;
}
void
oggplay_buffer_prepare(OggPlay *me) {
-
+
int i;
-
+
oggplay_set_data_callback_force(me, &oggplay_buffer_callback, NULL);
for (i = 0; i < me->num_tracks; i++) {
- if (oggplay_get_track_type(me, i) == OGGZ_CONTENT_THEORA) {
+ if (oggplay_get_track_type(me, i) == OGGZ_CONTENT_THEORA) {
oggplay_set_callback_num_frames(me, i, 1);
break;
}
}
}
-
Modified: liboggplay/trunk/src/liboggplay/oggplay_callback.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_callback.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_callback.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_callback.c
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
*/
#include "oggplay_private.h"
@@ -50,7 +50,7 @@
oggplay_init_theora(void *user_data) {
OggPlayTheoraDecode * decoder = (OggPlayTheoraDecode *)user_data;
-
+
theora_info_init(&(decoder->video_info));
theora_comment_init(&(decoder->video_comment));
decoder->remaining_header_packets = 3;
@@ -73,7 +73,7 @@
}
int
-oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
+oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data) {
OggPlayTheoraDecode * decoder = (OggPlayTheoraDecode *)user_data;
@@ -83,7 +83,7 @@
int granuleshift;
long frame;
-#if TIME_THEORA_DECODE
+#if TIME_THEORA_DECODE
struct timeval tv;
struct timeval tv2;
int musec;
@@ -109,7 +109,7 @@
theora_decode_init(&(decoder->video_handle), &(decoder->video_info));
}
return 0;
- }
+ }
else if (decoder->remaining_header_packets != 0) {
/*
* Invalid Ogg file. Missing headers
@@ -117,25 +117,25 @@
*/
return -1;
}
-
+
if (!decoder->decoder.active) {
/*
* don't decode other packets
*/
return 0;
}
-
+
/*
* if we get to here then we've passed all the header packets
*/
if (common->current_loc == -1)
common->current_loc = 0;
-
+
/*
* Decode the frame
*/
-#if TIME_THEORA_DECODE
+#if TIME_THEORA_DECODE
gettimeofday(&tv, NULL);
#endif
@@ -148,7 +148,7 @@
#if TIME_THEORA_DECODE
gettimeofday(&tv2, NULL);
musec = tv2.tv_usec - tv.tv_usec;
- if (tv2.tv_sec > tv.tv_sec)
+ if (tv2.tv_sec > tv.tv_sec)
musec += (tv2.tv_sec - tv.tv_sec) * 1000000;
printf("decode took %dus\n", musec);
#endif
@@ -162,10 +162,10 @@
common->current_loc = -1;
}
- if
+ if
(
- (common->current_loc == -1)
- ||
+ (common->current_loc == -1)
+ ||
(common->current_loc >= common->player->presentation_time)
)
{
@@ -173,17 +173,17 @@
* store the frame,
* use the buffer stride for the width to avoid passing negative stride
* issues on to the user.
- * */
+ * */
oggplay_data_handle_theora_frame(decoder, &buffer);
}
-
+
if (op->e_o_s) {
common->active = 0;
common->player->active_tracks--;
}
-
+
return 0;
-
+
}
void
@@ -213,12 +213,12 @@
}
common->current_loc = granulepos * common->granuleperiod;
-
+
oggplay_data_handle_cmml_data (&(decoder->decoder), op->packet, op->bytes);
}
-
+
return 0;
-
+
}
void
@@ -235,19 +235,19 @@
}
static inline ogg_int64_t extract_int64(unsigned char *data) {
- return ((ogg_int64_t)(extract_int32(data))) |
+ return ((ogg_int64_t)(extract_int32(data))) |
(((ogg_int64_t)(extract_int32(data + 4))) << 32);
}
int
-oggplay_callback_skel (OGGZ * oggz, ogg_packet * op, long serialno,
+oggplay_callback_skel (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data) {
OggPlaySkeletonDecode * decoder = (OggPlaySkeletonDecode *)user_data;
if (strncmp((char *)op->packet, "fishead", 7) == 0) {
ogg_int64_t pt_num, pt_den, bt_num, bt_den;
-
+
pt_num = extract_int64(op->packet + 12);
pt_den = extract_int64(op->packet + 20);
bt_num = extract_int64(op->packet + 28);
@@ -255,7 +255,7 @@
decoder->presentation_time = (pt_num << 32) * 1000 / pt_den;
decoder->base_time = (bt_num << 32) / bt_den;
-
+
/* initialise the presentation times in the player to the values recorded in the skeleton */
decoder->decoder.player->presentation_time = decoder->presentation_time;
} else {
@@ -263,7 +263,7 @@
long preroll = extract_int32(op->packet + 44);
long serialno = extract_int32(op->packet + 12);
//ogg_int64_t start_granule = extract_int64(op->packet + 36);
-
+
for (i = 1; i < decoder->decoder.player->num_tracks; i++) {
if (decoder->decoder.player->decode_data[i]->serialno == serialno) {
decoder->decoder.player->decode_data[i]->preroll = preroll;
@@ -271,9 +271,9 @@
}
}
}
-
+
return 0;
-
+
}
int
@@ -293,10 +293,10 @@
common->current_loc = -1;
}
- if
+ if
(
- (common->current_loc == -1)
- ||
+ (common->current_loc == -1)
+ ||
(common->current_loc >= common->player->presentation_time)
)
{
@@ -305,9 +305,9 @@
/*
* store the frame
*/
- oggplay_data_handle_audio_data(&(decoder->decoder), (short *)pcm, frames,
+ oggplay_data_handle_audio_data(&(decoder->decoder), (short *)pcm, frames,
sizeof(float));
- }
+ }
return FISH_SOUND_CONTINUE;
}
@@ -317,15 +317,15 @@
OggPlayAudioDecode * decoder = (OggPlayAudioDecode *)user_data;
- decoder->sound_handle = fish_sound_new(FISH_SOUND_DECODE,
+ decoder->sound_handle = fish_sound_new(FISH_SOUND_DECODE,
&(decoder->sound_info));
- decoder->sound_info.channels = 0;
+ decoder->sound_info.channels = 0;
fish_sound_set_interleave(decoder->sound_handle, 1);
- fish_sound_set_decoded_float_ilv(decoder->sound_handle,
- oggplay_fish_sound_callback_floats,
+ fish_sound_set_decoded_float_ilv(decoder->sound_handle,
+ oggplay_fish_sound_callback_floats,
(void *)decoder);
-
+
decoder->decoder.decoded_type = OGGPLAY_FLOATS_AUDIO;
}
@@ -339,25 +339,25 @@
}
int
-oggplay_callback_audio (OGGZ * oggz, ogg_packet * op, long serialno,
+oggplay_callback_audio (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data) {
OggPlayAudioDecode * decoder = (OggPlayAudioDecode *)user_data;
OggPlayDecode * common = &(decoder->decoder);
ogg_int64_t granulepos = oggz_tell_granulepos(oggz);
-
+
if (granulepos > 0 && (!decoder->decoder.active)) {
return 0;
}
common->last_granulepos = granulepos;
- fish_sound_prepare_truncation (decoder->sound_handle, op->granulepos,
+ fish_sound_prepare_truncation (decoder->sound_handle, op->granulepos,
op->e_o_s);
fish_sound_decode (decoder->sound_handle, op->packet, op->bytes);
if (decoder->sound_info.channels == 0) {
- fish_sound_command(decoder->sound_handle, FISH_SOUND_GET_INFO,
+ fish_sound_command(decoder->sound_handle, FISH_SOUND_GET_INFO,
&(decoder->sound_info), sizeof(FishSoundInfo));
}
@@ -365,7 +365,7 @@
common->active = 0;
common->player->active_tracks--;
}
-
+
return 0;
}
@@ -391,7 +391,7 @@
}
int
-oggplay_callback_kate (OGGZ * oggz, ogg_packet * op, long serialno,
+oggplay_callback_kate (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data) {
#ifdef HAVE_KATE
@@ -416,25 +416,25 @@
common->current_loc = -1;
}
- if
+ if
(
- (common->current_loc == -1)
- ||
+ (common->current_loc == -1)
+ ||
(common->current_loc >= common->player->presentation_time)
)
{
/*
* process the data from the packet
- * */
+ * */
if (ev) {
oggplay_data_handle_kate_data(decoder, ev);
}
}
-
+
if (op->e_o_s) {
common->active = 0;
}
-
+
#endif
return 0;
@@ -442,37 +442,37 @@
}
OggPlayCallbackFunctions callbacks[] = {
- {oggplay_init_theora, oggplay_callback_theora, oggplay_shutdown_theora,
+ {oggplay_init_theora, oggplay_callback_theora, oggplay_shutdown_theora,
sizeof(OggPlayTheoraDecode)}, /* THEORA */
- {oggplay_init_audio, oggplay_callback_audio, oggplay_shutdown_audio,
+ {oggplay_init_audio, oggplay_callback_audio, oggplay_shutdown_audio,
sizeof(OggPlayAudioDecode)}, /* VORBIS */
- {oggplay_init_audio, oggplay_callback_audio, oggplay_shutdown_audio,
+ {oggplay_init_audio, oggplay_callback_audio, oggplay_shutdown_audio,
sizeof(OggPlayAudioDecode)}, /* SPEEX */
{NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* PCM */
- {oggplay_init_cmml, oggplay_callback_cmml, NULL, sizeof(OggPlayCmmlDecode)},
+ {oggplay_init_cmml, oggplay_callback_cmml, NULL, sizeof(OggPlayCmmlDecode)},
{NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* ANX2 */
- {oggplay_init_skel, oggplay_callback_skel, NULL,
- sizeof(OggPlaySkeletonDecode)},
+ {oggplay_init_skel, oggplay_callback_skel, NULL,
+ sizeof(OggPlaySkeletonDecode)},
{NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* FLAC0 */
{NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* FLAC */
{NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* ANXDATA */
{NULL, NULL, NULL, sizeof(OggPlayDecode)}, /* CELT */
- {oggplay_init_kate, oggplay_callback_kate, oggplay_shutdown_kate,
+ {oggplay_init_kate, oggplay_callback_kate, oggplay_shutdown_kate,
sizeof(OggPlayKateDecode)}, /* KATE */
{NULL, NULL, NULL, sizeof(OggPlayDecode)} /* UNKNOWN */
};
OggPlayDecode *
oggplay_initialise_decoder(OggPlay *me, int content_type, int serialno) {
-
+
ogg_int64_t num;
ogg_int64_t denom;
-
+
OggPlayDecode * decoder = malloc (callbacks[content_type].size);
-
+
decoder->serialno = serialno;
decoder->content_type = content_type;
- decoder->content_type_name =
+ decoder->content_type_name =
oggz_stream_get_content_type (me->oggz, serialno);
decoder->active = 1;
decoder->final_granulepos = -1;
@@ -492,11 +492,11 @@
/*
* the offset is how far advanced or delayed this track is to the "standard"
- * time position. An offset of 1000, for example, indicates that data for
+ * time position. An offset of 1000, for example, indicates that data for
* this track arrives 1 second in advance of data for other tracks
*/
decoder->offset = 0;
-
+
oggz_get_granulerate(me->oggz, serialno, &num, &denom);
/*
@@ -504,12 +504,12 @@
*/
decoder->granuleperiod = (denom << 32) / num;
- if (callbacks[content_type].init != NULL) {
+ if (callbacks[content_type].init != NULL) {
callbacks[content_type].init(decoder);
}
oggplay_data_initialise_list(decoder);
-
+
return decoder;
}
@@ -525,14 +525,14 @@
}
oggplay_data_shutdown_list(decoder);
-
+
free(decoder);
-
+
}
-
+
/*
- * this is the callback that is used before all track types have been
+ * this is the callback that is used before all track types have been
* determined - i.e. at the beginning of an ogg bitstream or at the start
* of a new chain
*/
@@ -555,12 +555,12 @@
if (serialno == me->decode_data[i]->serialno) {
me->all_tracks_initialised = 1;
-
+
/*
* call appropriate callback
*/
if (callbacks[content_type].callback != NULL) {
- callbacks[content_type].callback(oggz, op, serialno,
+ callbacks[content_type].callback(oggz, op, serialno,
me->decode_data[i]);
}
@@ -570,10 +570,10 @@
for (i = 0; i < me->num_tracks; i++) {
serialno = me->decode_data[i]->serialno;
content_type = oggz_stream_get_content (me->oggz, serialno);
- oggz_set_read_callback(me->oggz, serialno,
+ oggz_set_read_callback(me->oggz, serialno,
callbacks[content_type].callback, me->decode_data[i]);
}
-
+
/*
* destroy this callback
*/
@@ -583,21 +583,21 @@
}
}
- me->callback_info = realloc (me->callback_info,
+ me->callback_info = realloc (me->callback_info,
sizeof (OggPlayCallbackInfo) * ++me->num_tracks);
me->decode_data = realloc (me->decode_data, sizeof (long) * me->num_tracks);
- me->decode_data[me->num_tracks - 1] = oggplay_initialise_decoder(me,
+ me->decode_data[me->num_tracks - 1] = oggplay_initialise_decoder(me,
content_type, serialno);
/*me->decode_data->callback_info = me->callback_info + (me->num_tracks - 1);*/
-
+
/*
* call appropriate callback
*/
if (callbacks[content_type].callback != NULL) {
- callbacks[content_type].callback(oggz, op, serialno,
+ callbacks[content_type].callback(oggz, op, serialno,
me->decode_data[me->num_tracks - 1]);
}
return 0;
-
+
}
Modified: liboggplay/trunk/src/liboggplay/oggplay_data.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_data.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_data.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_data.c
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
*/
@@ -54,7 +54,7 @@
/*
* the normal lifecycle for a frame is:
*
- * (1) frame gets decoded and added to list with a locking value of 1
+ * (1) frame gets decoded and added to list with a locking value of 1
* (2) frame gets delivered to user
* (3) frame becomes out-of-date (its presentation time expires) and its
* lock is decremented
@@ -62,7 +62,7 @@
*
* This can be modified by:
* (a) early consumption by user (user calls oggplay_mark_record_consumed)
- * (b) frame locking by user (user calls oggplay_mark_record_locked) and
+ * (b) frame locking by user (user calls oggplay_mark_record_locked) and
* subsequent unlocking (user calls oggplay_mark_record_consumed)
*/
@@ -79,9 +79,9 @@
*/
void
oggplay_data_add_to_list_end(OggPlayDecode *decode, OggPlayDataHeader *data) {
-
+
data->next = NULL;
-
+
if (decode->data_list == NULL) {
decode->data_list = data;
decode->end_of_data_list = data;
@@ -90,7 +90,7 @@
decode->end_of_data_list = data;
}
-}
+}
#define M(x) ((x) >> 32)
@@ -117,25 +117,25 @@
}
printf("\n");
}
-
+
void
oggplay_data_add_to_list (OggPlayDecode *decode, OggPlayDataHeader *data) {
-
+
/*
* if this is a packet with an unknown display time, prepend it to
* the untimed_data_list for later timestamping.
*/
-
+
ogg_int64_t samples_in_next_in_list;
-
+
//_print_list("before", decode->data_list);
//_print_list("untimed before", decode->untimed_data_list);
-
+
if (data->presentation_time == -1) {
data->next = decode->untimed_data_list;
decode->untimed_data_list = data;
- } else {
+ } else {
/*
* process the untimestamped data into the timestamped data list.
*
@@ -143,17 +143,17 @@
*/
ogg_int64_t presentation_time = data->presentation_time;
samples_in_next_in_list = data->samples_in_record;
-
+
while (decode->untimed_data_list != NULL) {
OggPlayDataHeader *untimed = decode->untimed_data_list;
- presentation_time -=
+ presentation_time -=
samples_in_next_in_list * decode->granuleperiod;
- untimed->presentation_time = presentation_time;
+ untimed->presentation_time = presentation_time;
decode->untimed_data_list = untimed->next;
samples_in_next_in_list = untimed->samples_in_record;
-
+
if (untimed->presentation_time >= decode->player->presentation_time) {
oggplay_data_add_to_list_front(decode, untimed);
} else {
@@ -166,16 +166,16 @@
/*
* if the StreamInfo is still at uninitialised, then this is the first
- * meaningful data packet! StreamInfo will be updated to
+ * meaningful data packet! StreamInfo will be updated to
* OGGPLAY_STREAM_INITIALISED in oggplay_callback_info.c as part of the
* callback process.
*/
if (decode->stream_info == OGGPLAY_STREAM_UNINITIALISED) {
decode->stream_info = OGGPLAY_STREAM_FIRST_DATA;
}
-
+
}
-
+
//_print_list("after", decode->data_list);
//_print_list("untimed after", decode->untimed_data_list);
@@ -198,12 +198,12 @@
oggplay_data_free_list(decode->data_list);
oggplay_data_free_list(decode->untimed_data_list);
-}
+}
/*
* this function removes any displayed, unlocked frames from the list.
*
- * this function also removes any undisplayed frames that are before the
+ * this function also removes any undisplayed frames that are before the
* global presentation time.
*/
void
@@ -214,7 +214,7 @@
OggPlayDataHeader * p = NULL;
while (header != NULL) {
- if
+ if
(
header->lock == 0
&&
@@ -230,7 +230,7 @@
)
)
- )
+ )
{
if (p == NULL) {
decode->data_list = decode->data_list->next;
@@ -253,7 +253,7 @@
}
void
-oggplay_data_initialise_header (OggPlayDecode *decode,
+oggplay_data_initialise_header (OggPlayDecode *decode,
OggPlayDataHeader *header) {
/*
* the frame is not cleaned until its presentation time has passed. We'll
@@ -267,37 +267,37 @@
}
void
-oggplay_data_handle_audio_data (OggPlayDecode *decode, void *data,
+oggplay_data_handle_audio_data (OggPlayDecode *decode, void *data,
int samples, int samplesize) {
int num_channels;
OggPlayAudioRecord * record;
-
+
num_channels = ((OggPlayAudioDecode *)decode)->sound_info.channels;
- record = (OggPlayAudioRecord*)calloc(sizeof(OggPlayAudioRecord) +
+ record = (OggPlayAudioRecord*)calloc(sizeof(OggPlayAudioRecord) +
samples * samplesize * num_channels, 1);
oggplay_data_initialise_header(decode, &(record->header));
record->header.samples_in_record = samples;
-
+
record->data = (void *)(record + 1);
memcpy(record->data, data, samples * samplesize * num_channels);
/*
- printf("[%f%f%f]\n", ((float *)record->data)[0], ((float *)record->data)[1],
+ printf("[%f%f%f]\n", ((float *)record->data)[0], ((float *)record->data)[1],
((float *)record->data)[2]);
*/
oggplay_data_add_to_list(decode, &(record->header));
}
void
-oggplay_data_handle_cmml_data(OggPlayDecode *decode, unsigned char *data,
+oggplay_data_handle_cmml_data(OggPlayDecode *decode, unsigned char *data,
int size) {
OggPlayTextRecord * record;
-
- record =
+
+ record =
(OggPlayTextRecord*)calloc (sizeof(OggPlayTextRecord) + size + 1, 1);
oggplay_data_initialise_header(decode, &(record->header));
@@ -308,11 +308,11 @@
record->data[size] = '\0';
oggplay_data_add_to_list(decode, &(record->header));
-
+
}
void
-oggplay_data_handle_theora_frame (OggPlayTheoraDecode *decode,
+oggplay_data_handle_theora_frame (OggPlayTheoraDecode *decode,
yuv_buffer *buffer) {
int size = sizeof (OggPlayVideoRecord);
@@ -323,7 +323,7 @@
unsigned char * q2;
OggPlayVideoRecord * record;
OggPlayVideoData * data;
-
+
if (buffer->y_stride < 0) {
size -= buffer->y_stride * buffer->y_height;
size -= buffer->uv_stride * buffer->uv_height * 2;
@@ -331,7 +331,7 @@
size += buffer->y_stride * buffer->y_height;
size += buffer->uv_stride * buffer->uv_height * 2;
}
-
+
/*
* we need to set the output strides to the input widths because we are
* trying not to pass negative output stride issues on to the poor user.
@@ -344,7 +344,7 @@
data->y = (unsigned char *)(record + 1);
data->u = data->y + (decode->y_stride * decode->y_height);
data->v = data->u + (decode->uv_stride * decode->uv_height);
-
+
/*
* *grumble* theora plays silly buggers with pointers so we need to do
* a row-by-row copy (stride may be negative)
@@ -380,7 +380,7 @@
// TODO: should be able to send the data rendered as YUV data, but just text for now
OggPlayTextRecord * record;
-
+
record = (OggPlayTextRecord*)calloc (sizeof(OggPlayTextRecord) + ev->len0, 1);
oggplay_data_initialise_header(&decode->decoder, &(record->header));
Modified: liboggplay/trunk/src/liboggplay/oggplay_data.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_data.h 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_data.h 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_data.h
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
*/
#ifndef __OGGPLAY_DATA_H__
@@ -50,7 +50,7 @@
int samples, int samplesize);
void
-oggplay_data_handle_cmml_data(OggPlayDecode *decode, unsigned char *data,
+oggplay_data_handle_cmml_data(OggPlayDecode *decode, unsigned char *data,
int size);
#ifdef HAVE_KATE
Modified: liboggplay/trunk/src/liboggplay/oggplay_file_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_file_reader.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_file_reader.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_file_reader.c
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
* Michael Martin
*/
@@ -52,13 +52,13 @@
if (me == NULL) {
return E_OGGPLAY_BAD_READER;
}
-
+
me->file = fopen(me->file_name, "rb");
if (me->file == NULL) {
return E_OGGPLAY_BAD_INPUT;
}
-
+
fseek(me->file, SEEK_END, 0);
me->size = ftell(me->file);
fseek(me->file, SEEK_SET, 0);
@@ -77,12 +77,12 @@
fclose(me->file);
free(me);
-
+
return E_OGGPLAY_OK;
}
int
-oggplay_file_reader_available(OggPlayReader * opr, ogg_int64_t current_bytes,
+oggplay_file_reader_available(OggPlayReader * opr, ogg_int64_t current_bytes,
ogg_int64_t current_time) {
OggPlayFileReader *me = (OggPlayFileReader *)opr;
@@ -92,15 +92,15 @@
int
oggplay_file_reader_finished_retrieving(OggPlayReader *opr) {
-
+
return 1;
}
-
+
static size_t
oggplay_file_reader_io_read(void * user_handle, void * buf, size_t n) {
-
+
OggPlayFileReader *me = (OggPlayFileReader *)user_handle;
int r;
r = fread(buf, 1, n, me->file);
@@ -113,21 +113,21 @@
static int
oggplay_file_reader_io_seek(void * user_handle, long offset, int whence) {
-
+
OggPlayFileReader * me = (OggPlayFileReader *)user_handle;
int r;
-
+
r = fseek(me->file, offset, whence);
me->current_position = ftell(me->file);
return r;
-
+
}
-
+
static long
oggplay_file_reader_io_tell(void * user_handle) {
OggPlayFileReader * me = (OggPlayFileReader *)user_handle;
-
+
return ftell(me->file);
}
@@ -146,10 +146,10 @@
me->functions.available = &oggplay_file_reader_available;
me->functions.finished_retrieving = &oggplay_file_reader_finished_retrieving;
me->functions.seek = NULL;
- me->functions.io_read = &oggplay_file_reader_io_read;
+ me->functions.io_read = &oggplay_file_reader_io_read;
me->functions.io_seek = &oggplay_file_reader_io_seek;
me->functions.io_tell = &oggplay_file_reader_io_tell;
-
+
return (OggPlayReader *)me;
}
Modified: liboggplay/trunk/src/liboggplay/oggplay_file_reader.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_file_reader.h 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_file_reader.h 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_file_reader.h
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
* Michael Martin
*/
Modified: liboggplay/trunk/src/liboggplay/oggplay_private.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_private.h 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_private.h 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_private.h
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
* Michael Martin
*/
@@ -119,14 +119,14 @@
* data_list, end_of_data_list: Contain decoded data packets for this track.
* These packets are time-ordered, and have a
* known presentation time
- *
+ *
* untimed_data_list: Contains decoded data packets for this track.
- * These packets are reverse time-ordered, and
+ * These packets are reverse time-ordered, and
* have not got a known presentation time. This
- * list gets constructed when a new Ogg file is
+ * list gets constructed when a new Ogg file is
* first being read, and gets torn down as soon as
* the first packet with a granulepos is processed
- *
+ *
* granuleperiod The period between adjacent samples in this
* track
*/
@@ -211,7 +211,7 @@
void * callback_user_ptr;
ogg_int64_t target;
int active_tracks;
- volatile OggPlayBuffer * buffer;
+ volatile OggPlayBuffer * buffer;
ogg_int64_t presentation_time;
OggPlaySeekTrash * trash;
int shutdown;
@@ -227,7 +227,7 @@
typedef struct {
void (*init)(void *user_data);
- int (*callback)(OGGZ * oggz, ogg_packet * op, long serialno,
+ int (*callback)(OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data);
void (*shutdown)(void *user_data);
int size;
@@ -243,7 +243,7 @@
free(x);
}
-static inline void *_malloc(int s) {
+static inline void *_malloc(int s) {
void *x;
printf("%d ", s);
x = malloc(s);
Modified: liboggplay/trunk/src/liboggplay/oggplay_query.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_query.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_query.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_query.c
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
*/
@@ -40,7 +40,7 @@
int
oggplay_get_num_tracks (OggPlay * me) {
-
+
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@@ -54,12 +54,12 @@
}
return me->num_tracks;
-
+
}
OggzStreamContent
oggplay_get_track_type (OggPlay * me, int track_num) {
-
+
if (me == NULL) {
return (OggzStreamContent)E_OGGPLAY_BAD_OGGPLAY;
}
@@ -75,13 +75,13 @@
if (track_num < 0 || track_num >= me->num_tracks) {
return (OggzStreamContent)E_OGGPLAY_BAD_TRACK;
}
-
+
return (OggzStreamContent)me->decode_data[track_num]->content_type;
}
const char *
oggplay_get_track_typename (OggPlay * me, int track_num) {
-
+
if (me == NULL) {
return NULL;
}
@@ -97,7 +97,7 @@
if (track_num < 0 || track_num >= me->num_tracks) {
return NULL;
}
-
+
return me->decode_data[track_num]->content_type_name;
}
@@ -105,7 +105,7 @@
oggplay_set_track_active(OggPlay *me, int track_num) {
ogg_int64_t p;
-
+
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@@ -130,19 +130,19 @@
if (me->decode_data[track_num]->content_type == OGGZ_CONTENT_SKELETON) {
return E_OGGPLAY_TRACK_IS_SKELETON;
}
-
+
if ((p = me->decode_data[track_num]->final_granulepos) != -1) {
if (p * me->decode_data[track_num]->granuleperiod > me->target) {
return E_OGGPLAY_TRACK_IS_OVER;
}
}
-
+
if (me->decode_data[track_num]->active == 0) {
me->decode_data[track_num]->active = 1;
/*
* CMML tracks aren't counted when deciding whether we've read enough data
- * from the stream. This is because CMML data is not continuous, and
+ * from the stream. This is because CMML data is not continuous, and
* determining that we've read enough data from each other stream is enough
* to determing that we've read any CMML data that is available.
* This also applies to Kate streams.
@@ -153,7 +153,7 @@
}
return E_OGGPLAY_OK;
-
+
}
OggPlayErrorCode
@@ -178,7 +178,7 @@
if (me->decode_data[track_num]->content_type == OGGZ_CONTENT_SKELETON) {
return E_OGGPLAY_TRACK_IS_SKELETON;
}
-
+
if (me->decode_data[track_num]->active == 1) {
me->decode_data[track_num]->active = 0;
Modified: liboggplay/trunk/src/liboggplay/oggplay_seek.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_seek.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_seek.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_enums.h
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
*/
@@ -46,7 +46,7 @@
OggPlayDataHeader ** end_of_list_p;
int i;
int eof;
-
+
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@@ -61,10 +61,10 @@
}
if (me->reader->seek != NULL) {
- if
+ if
(
- me->reader->seek(me->reader, me->oggz, milliseconds)
- ==
+ me->reader->seek(me->reader, me->oggz, milliseconds)
+ ==
E_OGGPLAY_CANT_SEEK
)
{
@@ -77,11 +77,11 @@
}
/*
- * first, create a trash object to store the context that we want to
- * delete but can't until the presentation thread is no longer using it -
+ * first, create a trash object to store the context that we want to
+ * delete but can't until the presentation thread is no longer using it -
* this will occur as soon as the thread calls oggplay_buffer_release_next
*/
-
+
trash = malloc(sizeof(OggPlaySeekTrash));
/*
@@ -94,13 +94,13 @@
* will start using this buffer instead.
*/
me->buffer = oggplay_buffer_new_buffer(me->buffer->buffer_size);
-
+
/*
* strip all of the data packets out of the streams and put them into the
* trash. We can free the untimed packets immediately - they are USELESS
* SCUM OF THE EARTH (and also unreferenced by the buffer).
*/
- end_of_list_p = &trash->old_data;
+ end_of_list_p = &trash->old_data;
for (i = 0; i < me->num_tracks; i++) {
OggPlayDecode *track = me->decode_data[i];
if (track->data_list != NULL) {
@@ -117,7 +117,7 @@
/*
* set the presentation time
*/
- me->presentation_time = milliseconds;
+ me->presentation_time = milliseconds;
me->target = me->callback_period - 1;
me->pt_update_valid = 1;
@@ -127,11 +127,11 @@
while (*p != NULL) {
p = &((*p)->next);
}
-
+
*p = trash;
return E_OGGPLAY_OK;
-
+
}
void
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_tcp_reader.c
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
* Michael Martin
*/
@@ -74,7 +74,7 @@
#define START_TIMEOUT(ref) \
(ref) = oggplay_sys_time_in_ms()
-#ifdef WIN32
+#ifdef WIN32
#define CHECK_ERROR(error) \
(WSAGetLastError() == WSA##error)
#else
@@ -113,14 +113,14 @@
oggplay_create_socket() {
SOCKET sock;
-#ifdef WIN32
+#ifdef WIN32
WORD wVersionRequested;
WSADATA wsaData;
-#ifdef HAVE_WINSOCK2
+#ifdef HAVE_WINSOCK2
wVersionRequested = MAKEWORD(2,2);
#else
wVersionRequested = MAKEWORD(1,1);
-#endif
+#endif
if (WSAStartup(wVersionRequested, &wsaData) == -1) {
printf("Socket open error\n");
return INVALID_SOCKET;
@@ -145,7 +145,7 @@
}
/*
- * this function guarantees it will return malloced versions of host and
+ * this function guarantees it will return malloced versions of host and
* path
*/
void
@@ -183,7 +183,7 @@
return;
}
- /*
+ /*
* if there's a slash and it's before colon, there's no port. Hence, after
* this code, the only time that there's a port is when colon is non-NULL
*/
@@ -229,16 +229,16 @@
#ifdef WIN32
/* see http://msdn2.microsoft.com/en-us/library/ms737625.aspx */
|| CHECK_ERROR(EWOULDBLOCK) || CHECK_ERROR(EINVAL)
-#endif
+#endif
) {
RETURN_ON_TIMEOUT_OR_CONTINUE(time_ref);
- }
- else if CHECK_ERROR(EISCONN)
+ }
+ else if CHECK_ERROR(EISCONN)
{
break;
}
printf("Could not connect to host; error code is %d\n", errno);
- return CHECK_ERROR(ETIMEDOUT) ? E_OGGPLAY_TIMEOUT :
+ return CHECK_ERROR(ETIMEDOUT) ? E_OGGPLAY_TIMEOUT :
E_OGGPLAY_SOCKET_ERROR;
}
@@ -318,7 +318,7 @@
free(host);
free(path);
-
+
if (he == NULL) {
printf("Host not found\n");
return E_OGGPLAY_BAD_INPUT;
@@ -350,9 +350,9 @@
oggplay_set_socket_blocking_state(me->socket, 1);
pos = http_request_header;
len = strlen(http_request_header);
-#ifdef WIN32
+#ifdef WIN32
nbytes = send(me->socket, pos, len, 0);
-#else
+#else
nbytes = write(me->socket, pos, len);
#endif
assert(nbytes == len);
@@ -364,7 +364,7 @@
/*
* Strip out the HTTP response by finding the first Ogg packet.
- */
+ */
if (me->state == OTRS_SENT_HEADER) {
int offset;
int found_http_response = 0;
@@ -380,10 +380,10 @@
remaining = TCP_READER_MAX_IN_MEMORY - me->amount_in_memory - 1;
#ifdef WIN32
- nbytes = recv(me->socket, (char*)(me->buffer + me->amount_in_memory),
+ nbytes = recv(me->socket, (char*)(me->buffer + me->amount_in_memory),
remaining, 0);
#else
- nbytes = read(me->socket, (char*)(me->buffer + me->amount_in_memory),
+ nbytes = read(me->socket, (char*)(me->buffer + me->amount_in_memory),
remaining);
#endif
if (nbytes < 0) {
@@ -403,14 +403,14 @@
continue;
}
- if
+ if
(
(!found_http_response)
&&
- strncmp((char *)me->buffer, "HTTP/1.1 200 OK", 15) != 0
+ strncmp((char *)me->buffer, "HTTP/1.1 200 OK", 15) != 0
&&
strncmp((char *)me->buffer, "HTTP/1.0 200 OK", 15) != 0
- )
+ )
{
return E_OGGPLAY_BAD_INPUT;
} else {
@@ -428,11 +428,11 @@
}
}
- offset = pos - (char *)(me->buffer);
+ offset = pos - (char *)(me->buffer);
memmove(me->buffer, pos, me->amount_in_memory - offset);
me->amount_in_memory -= offset;
- me->backing_store = tmpfile();
- fwrite(me->buffer, 1, me->amount_in_memory, me->backing_store);
+ me->backing_store = tmpfile();
+ fwrite(me->buffer, 1, me->amount_in_memory, me->backing_store);
me->current_position = 0;
me->stored_offset = me->amount_in_memory;
me->amount_in_memory = 0;
@@ -440,7 +440,7 @@
}
-
+
/*
* Read in enough data to fill the buffer.
*/
@@ -453,7 +453,7 @@
START_TIMEOUT(time_ref);
while (remaining > 0) {
#ifdef WIN32
- nbytes = recv(me->socket, (char*)(me->buffer + me->amount_in_memory),
+ nbytes = recv(me->socket, (char*)(me->buffer + me->amount_in_memory),
remaining, 0);
#else
nbytes = read(me->socket, me->buffer + me->amount_in_memory, remaining);
@@ -475,8 +475,8 @@
}
me->amount_in_memory += nbytes;
remaining -= nbytes;
- }
- fwrite(me->buffer, 1, me->amount_in_memory, me->backing_store);
+ }
+ fwrite(me->buffer, 1, me->amount_in_memory, me->backing_store);
me->stored_offset += me->amount_in_memory;
me->amount_in_memory = 0;
me->state = OTRS_INIT_COMPLETE;
@@ -521,16 +521,16 @@
OggPlayErrorCode
grab_some_data(OggPlayTCPReader *me, int block) {
-
+
int remaining;
int r;
-
+
if (me->socket == INVALID_SOCKET) return E_OGGPLAY_OK;
/*
* see if we can grab some more data
* if we're not blocking, make sure there's some available data
- */
+ */
if (!block) {
struct timeval tv;
fd_set reads;
@@ -540,16 +540,16 @@
tv.tv_usec = 0;
FD_ZERO(&reads);
FD_ZERO(&empty);
- FD_SET(me->socket, &reads);
- if (select(me->socket + 1, &reads, &empty, &empty, &tv) == 0) {
+ FD_SET(me->socket, &reads);
+ if (select(me->socket + 1, &reads, &empty, &empty, &tv) == 0) {
return E_OGGPLAY_OK;
- }
+ }
}
remaining = me->buffer_size;
-#ifdef WIN32
- r = recv(me->socket, (char*)(me->buffer + me->amount_in_memory),
- remaining, 0);
+#ifdef WIN32
+ r = recv(me->socket, (char*)(me->buffer + me->amount_in_memory),
+ remaining, 0);
#else
r = read(me->socket, me->buffer + me->amount_in_memory, remaining);
#endif
@@ -566,10 +566,10 @@
#endif
me->socket = INVALID_SOCKET;
}
-
+
fwrite(me->buffer, 1, r, me->backing_store);
me->stored_offset += r;
-
+
return E_OGGPLAY_OK;
}
@@ -681,7 +681,7 @@
me->functions.io_read = &oggplay_tcp_reader_io_read;
me->functions.io_seek = &oggplay_tcp_reader_io_seek;
me->functions.io_tell = &oggplay_tcp_reader_io_tell;
-
+
return (OggPlayReader *)me;
}
Modified: liboggplay/trunk/src/liboggplay/oggplay_tools.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tools.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_tools.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -32,7 +32,7 @@
/*
* oggplay_tools.c
- *
+ *
* Shane Stephens <shane.stephens at annodex.net>
* Michael Martin
*/
@@ -56,7 +56,7 @@
void
oggplay_millisleep(long ms) {
-#ifdef WIN32
+#ifdef WIN32
Sleep(ms);
#else
struct timespec ts = {0, (ogg_int64_t)ms * 1000000LL};
Modified: liboggplay/trunk/src/liboggplay/oggplay_yuv2rgb.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_yuv2rgb.c 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/oggplay_yuv2rgb.c 2008-08-05 04:22:57 UTC (rev 3678)
@@ -46,13 +46,13 @@
* YUV -> RGB conversion
* R = Y + 1.140V
* G = Y - 0.395U - 0.581V
- * B = Y + 2.032U
- *
+ * B = Y + 2.032U
+ *
* RGB -> YUV conversion
* Y = 0.299 R + 0.587 G + 0.114 B
* U = 0.147 R - 0.289 G + 0.436 B
* V = 0.615 R - 0.515 G - 0.100 B
- */
+ */
#if defined(__MMX__) || defined(__SSE__) || defined(__SSE2__) || defined(__SSE3__)
@@ -69,7 +69,7 @@
/* YUV -> RGB Intel MMX implementation */
void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
- int i;
+ int i;
unsigned char * restrict ptry;
unsigned char * restrict ptru;
unsigned char * restrict ptrv;
@@ -79,8 +79,8 @@
register __m64 r, g, b;
register __m64 tmp, tmp2;
- zero = _mm_setzero_si64();
-
+ zero = _mm_setzero_si64();
+
ptry = yuv->ptry;
ptru = yuv->ptru;
ptrv = yuv->ptrv;
@@ -92,17 +92,17 @@
for (j = 0; j < yuv->y_width; j += 8) {
y = (__m64*)&ptry[j];
-
+
ut = _m_from_int(*(int *)(ptru + j/2));
vt = _m_from_int(*(int *)(ptrv + j/2));
//ut = _m_from_int(0);
//vt = _m_from_int(0);
-
+
ut = _m_punpcklbw(ut, zero);
vt = _m_punpcklbw(vt, zero);
-
- /* subtract 128 from u and v */
+
+ /* subtract 128 from u and v */
imm = _mm_set1_pi16(128);
ut = _m_psubw(ut, imm);
vt = _m_psubw(vt, imm);
@@ -116,20 +116,20 @@
r = _m_pmullw(vt, imm);
imm = _mm_set1_pi16(-74);
imm = _m_pmullw(vt, imm);
- g = _m_paddsw(g, imm);
+ g = _m_paddsw(g, imm);
/* add 64 to r, g and b registers */
imm = _mm_set1_pi16(64);
r = _m_paddsw(r, imm);
g = _m_paddsw(g, imm);
imm = _mm_set1_pi16(32);
- b = _m_paddsw(b, imm);
+ b = _m_paddsw(b, imm);
/* shift r, g and b registers to the right */
r = _m_psrawi(r, 7);
g = _m_psrawi(g, 7);
b = _m_psrawi(b, 6);
-
+
/* subtract 16 from r, g and b registers */
imm = _mm_set1_pi16(16);
r = _m_psubsw(r, imm);
@@ -137,7 +137,7 @@
b = _m_psubsw(b, imm);
y = (__m64*)&ptry[j];
-
+
/* duplicate u and v channels and add y
* each of r,g, b in the form [s1(16), s2(16), s3(16), s4(16)]
* first interleave, so tmp is [s1(16), s1(16), s2(16), s2(16)]
@@ -145,7 +145,7 @@
* then pack with saturation, to get the desired output of
* [s1(8), s1(8), s2(8), s2(8), s3(8), s3(8), s4(8), s4(8)]
*/
- tmp = _m_punpckhwd(r, r);
+ tmp = _m_punpckhwd(r, r);
imm = _m_punpckhbw(*y, zero);
//printf("tmp: %llx imm: %llx\n", tmp, imm);
tmp = _m_paddsw(tmp, imm);
@@ -153,20 +153,20 @@
imm2 = _m_punpcklbw(*y, zero);
tmp2 = _m_paddsw(tmp2, imm2);
r = _m_packuswb(tmp2, tmp);
-
+
tmp = _m_punpckhwd(g, g);
tmp2 = _m_punpcklwd(g, g);
tmp = _m_paddsw(tmp, imm);
tmp2 = _m_paddsw(tmp2, imm2);
g = _m_packuswb(tmp2, tmp);
-
+
tmp = _m_punpckhwd(b, b);
tmp2 = _m_punpcklwd(b, b);
tmp = _m_paddsw(tmp, imm);
tmp2 = _m_paddsw(tmp2, imm2);
b = _m_packuswb(tmp2, tmp);
//printf("duplicated r g and b: %llx %llx %llx\n", r, g, b);
-
+
/* now we have 8 8-bit r, g and b samples. we want these to be packed
* into 32-bit values.
*/
@@ -177,7 +177,7 @@
tmp2 = _m_punpcklbw(g, imm);
*o++ = _m_punpcklbw(tmp, tmp2);
*o++ = _m_punpckhbw(tmp, tmp2);
- //printf("tmp, tmp2, write1, write2: %llx %llx %llx %llx\n", tmp, tmp2,
+ //printf("tmp, tmp2, write1, write2: %llx %llx %llx %llx\n", tmp, tmp2,
// _m_punpcklbw(tmp, tmp2), _m_punpckhbw(tmp, tmp2));
tmp = _m_punpckhbw(r, b);
tmp2 = _m_punpckhbw(g, imm);
@@ -199,7 +199,7 @@
/* YUV -> BGR Intel MMX implementation */
void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
- int i;
+ int i;
unsigned char * restrict ptry;
unsigned char * restrict ptru;
unsigned char * restrict ptrv;
@@ -209,8 +209,8 @@
register __m64 r, g, b;
register __m64 tmp, tmp2;
- zero = _mm_setzero_si64();
-
+ zero = _mm_setzero_si64();
+
ptry = yuv->ptry;
ptru = yuv->ptru;
ptrv = yuv->ptrv;
@@ -222,17 +222,17 @@
for (j = 0; j < yuv->y_width; j += 8) {
y = (__m64*)&ptry[j];
-
+
ut = _m_from_int(*(int *)(ptru + j/2));
vt = _m_from_int(*(int *)(ptrv + j/2));
//ut = _m_from_int(0);
//vt = _m_from_int(0);
-
+
ut = _m_punpcklbw(ut, zero);
vt = _m_punpcklbw(vt, zero);
-
- /* subtract 128 from u and v */
+
+ /* subtract 128 from u and v */
imm = _mm_set1_pi16(128);
ut = _m_psubw(ut, imm);
vt = _m_psubw(vt, imm);
@@ -246,20 +246,20 @@
r = _m_pmullw(vt, imm);
imm = _mm_set1_pi16(-74);
imm = _m_pmullw(vt, imm);
- g = _m_paddsw(g, imm);
+ g = _m_paddsw(g, imm);
/* add 64 to r, g and b registers */
imm = _mm_set1_pi16(64);
r = _m_paddsw(r, imm);
g = _m_paddsw(g, imm);
imm = _mm_set1_pi16(32);
- b = _m_paddsw(b, imm);
+ b = _m_paddsw(b, imm);
/* shift r, g and b registers to the right */
r = _m_psrawi(r, 7);
g = _m_psrawi(g, 7);
b = _m_psrawi(b, 6);
-
+
/* subtract 16 from r, g and b registers */
imm = _mm_set1_pi16(16);
r = _m_psubsw(r, imm);
@@ -267,7 +267,7 @@
b = _m_psubsw(b, imm);
y = (__m64*)&ptry[j];
-
+
/* duplicate u and v channels and add y
* each of r,g, b in the form [s1(16), s2(16), s3(16), s4(16)]
* first interleave, so tmp is [s1(16), s1(16), s2(16), s2(16)]
@@ -275,7 +275,7 @@
* then pack with saturation, to get the desired output of
* [s1(8), s1(8), s2(8), s2(8), s3(8), s3(8), s4(8), s4(8)]
*/
- tmp = _m_punpckhwd(r, r);
+ tmp = _m_punpckhwd(r, r);
imm = _m_punpckhbw(*y, zero);
//printf("tmp: %llx imm: %llx\n", tmp, imm);
tmp = _m_paddsw(tmp, imm);
@@ -283,20 +283,20 @@
imm2 = _m_punpcklbw(*y, zero);
tmp2 = _m_paddsw(tmp2, imm2);
r = _m_packuswb(tmp2, tmp);
-
+
tmp = _m_punpckhwd(g, g);
tmp2 = _m_punpcklwd(g, g);
tmp = _m_paddsw(tmp, imm);
tmp2 = _m_paddsw(tmp2, imm2);
g = _m_packuswb(tmp2, tmp);
-
+
tmp = _m_punpckhwd(b, b);
tmp2 = _m_punpcklwd(b, b);
tmp = _m_paddsw(tmp, imm);
tmp2 = _m_paddsw(tmp2, imm2);
b = _m_packuswb(tmp2, tmp);
//printf("duplicated r g and b: %llx %llx %llx\n", r, g, b);
-
+
/* now we have 8 8-bit r, g and b samples. we want these to be packed
* into 32-bit values.
*/
@@ -307,7 +307,7 @@
tmp2 = _m_punpcklbw(g, imm);
*o++ = _m_punpcklbw(tmp, tmp2);
*o++ = _m_punpckhbw(tmp, tmp2);
- //printf("tmp, tmp2, write1, write2: %llx %llx %llx %llx\n", tmp, tmp2,
+ //printf("tmp, tmp2, write1, write2: %llx %llx %llx %llx\n", tmp, tmp2,
// _m_punpcklbw(tmp, tmp2), _m_punpckhbw(tmp, tmp2));
tmp = _m_punpckhbw(b, r);
tmp2 = _m_punpckhbw(g, imm);
@@ -359,10 +359,10 @@
short pr, pg, pb;
short r, g, b;
-
+
//pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
pr = (-41344 + ptrv[j/2] * 292) >> 8;
- //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
+ //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
// /* 0.395 & 0.581 */
pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
//pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
@@ -376,11 +376,11 @@
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(b);
*ptro2++ = 255;
-
+
r = ptry[j + 1] + pr;
g = ptry[j + 1] + pg;
b = ptry[j + 1] + pb;
-
+
*ptro2++ = CLAMP(r);
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(b);
@@ -411,10 +411,10 @@
short pr, pg, pb;
short r, g, b;
-
+
//pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
pr = (-41344 + ptrv[j/2] * 292) >> 8;
- //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
+ //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16;
// /* 0.395 & 0.581 */
pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
//pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
@@ -428,11 +428,11 @@
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(r);
*ptro2++ = 255;
-
+
r = ptry[j + 1] + pr;
g = ptry[j + 1] + pg;
b = ptry[j + 1] + pb;
-
+
*ptro2++ = CLAMP(b);
*ptro2++ = CLAMP(g);
*ptro2++ = CLAMP(r);
Modified: liboggplay/trunk/src/liboggplay/std_semaphore.h
===================================================================
--- liboggplay/trunk/src/liboggplay/std_semaphore.h 2008-08-05 04:22:00 UTC (rev 3677)
+++ liboggplay/trunk/src/liboggplay/std_semaphore.h 2008-08-05 04:22:57 UTC (rev 3678)
@@ -30,13 +30,13 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
- * ***** END LICENSE BLOCK ***** */
+ * ***** END LICENSE BLOCK ***** */
#ifndef _STD_SEMAPHORE_H
#define _STD_SEMAPHORE_H
#if defined(linux)
#include <semaphore.h>
-#define SEM_CREATE(p,s) sem_init(&(p), 1, s)
+#define SEM_CREATE(p,s) sem_init(&(p), 1, s)
#define SEM_SIGNAL(p) sem_post(&(p))
#define SEM_WAIT(p) sem_wait(&(p))
#define SEM_CLOSE(p) sem_destroy(&(p))
@@ -63,7 +63,7 @@
#if defined(XP_UX)
sem_init(&(pointers->sem), 1, LIBOGGPLAY_BUFFER_SIZE);
#elif defined(XP_WIN)
- pointers->sem = CreateSemaphore(NULL, (long)LIBOGGPLAY_BUFFER_SIZE,
+ pointers->sem = CreateSemaphore(NULL, (long)LIBOGGPLAY_BUFFER_SIZE,
(long)LIBOGGPLAY_BUFFER_SIZE, NULL);
#elif defined(XP_MACOSX)
MPCreateSemaphore(LIBOGGPLAY_BUFFER_SIZE, LIBOGGPLAY_BUFFER_SIZE,
More information about the commits
mailing list