Bug 448994 – <video> element causes floating point exception [@ oggplay_callback_predetected] when playing theora file (updates liboggplay to svn r3693)

This commit is contained in:
Chris Double 2008-08-13 08:23:42 +02:00
parent 34454bbe97
commit 474a77ef71
18 changed files with 376 additions and 369 deletions

View File

@ -14,7 +14,11 @@ Dependencies
For the core library (liboggplay), you need
* libogg, libvorbis, libspeex -- from http://www.xiph.org/
* libogg, libvorbis, libtheora, optionally libspeex -- from http://www.xiph.org/
svn co http://svn.xiph.org/trunk/ogg/ ogg
svn co http://svn.xiph.org/trunk/vorbis/ vorbis
svn co http://svn.xiph.org/trunk/theora/ theora
* liboggz and libfishsound -- from svn.annodex.net:
@ -28,15 +32,15 @@ Optionally, for Kate stream support, you need
See the README files associated with these libraries for installation
instructions.
To build src/tests/glut-player, you need:
To build src/examples/glut-player, you need:
* The core liboggplay dependencies (listed above)
* GLUT -- see http://www.opengl.org/resources/libraries/
To build src/tests/dump-all-streams, you need:
To build src/examples/dump-all-streams, you need:
* The core liboggplay dependencies (listed above)
* libsndfile -- from http://www.mega-nerd.com/libsndfile/
To build src/tests/dump-first-frame, you need:
To build src/tools/oggplay-dump-first-frame, you need:
* The core liboggplay dependencies (listed above)
* Imlib2 -- from your distribution or from
http://sourceforge.net/project/showfiles.php?group_id=2&package_id=11130

View File

@ -5,5 +5,4 @@ the Mozilla build system.
http://svn.annodex.net/liboggplay/trunk/
The svn revision number used was r3673. There is currently no official
source release of liboggplay, hence the reason an svn build was used.
The svn revision number used was r3693.

View File

@ -8,7 +8,7 @@
#define HAVE_FISHSOUND
/* Define if we have GLUT. */
/* #undef HAVE_GLUT */
#define HAVE_GLUT
/* Define if have Imlib2 */
/* #undef HAVE_IMLIB2 */
@ -85,3 +85,4 @@
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
#undef HAVE_GLUT

View File

@ -32,7 +32,7 @@
/*
* oggplay.c
*
*
* Shane Stephens <shane.stephens@annodex.net>
* Michael Martin
*/
@ -49,7 +49,7 @@ OggPlay *
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 @@ oggplay_new_with_reader(OggPlayReader *reader) {
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 @@ oggplay_initialise(OggPlay *me, int block) {
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 @@ oggplay_initialise(OggPlay *me, int block) {
* 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 @@ oggplay_initialise(OggPlay *me, int block) {
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 @@ oggplay_initialise(OggPlay *me, int block) {
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 @@ oggplay_open_with_reader(OggPlayReader *reader) {
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(OggPlay *me, OggPlayDataCallback callback,
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 @@ oggplay_set_data_callback_force(OggPlay *me, OggPlayDataCallback callback,
me->callback = callback;
me->callback_user_ptr = user;
}
@ -190,13 +190,13 @@ oggplay_set_callback_num_frames(OggPlay *me, int track, int frames) {
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 @@ oggplay_set_offset(OggPlay *me, int track, ogg_int64_t offset) {
}
me->decode_data[track]->offset = (offset << 32);
return E_OGGPLAY_OK;
}
@ -219,7 +219,7 @@ oggplay_set_offset(OggPlay *me, int track, ogg_int64_t offset) {
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 @@ oggplay_get_video_fps(OggPlay *me, int track, int* fps_denom, int* fps_num) {
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 @@ OggPlayErrorCode
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 @@ oggplay_get_video_y_size(OggPlay *me, int track, int *y_width, int *y_height) {
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 @@ oggplay_get_video_uv_size(OggPlay *me, int track, int *uv_width, int *uv_height)
{
OggPlayTheoraDecode *decode;
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@ -292,18 +292,18 @@ oggplay_get_video_uv_size(OggPlay *me, int track, int *uv_width, int *uv_height)
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
@ -362,7 +362,7 @@ oggplay_get_audio_samplerate(OggPlay *me, int track, int* rate) {
int
oggplay_get_kate_category(OggPlay *me, int track, const char** category) {
#ifdef HAVE_KATE
OggPlayKateDecode * decode;
if (me == NULL) {
@ -379,6 +379,7 @@ oggplay_get_kate_category(OggPlay *me, int track, const char** category) {
decode = (OggPlayKateDecode *)(me->decode_data[track]);
#ifdef HAVE_KATE
(*category) = decode->k.ki->category;
return E_OGGPLAY_OK;
#else
@ -472,16 +473,14 @@ read_more_data:
continue;
if (me->decode_data[i]->content_type == OGGZ_CONTENT_CMML)
continue;
#ifdef HAVE_KATE
if (me->decode_data[i]->content_type == OGGZ_CONTENT_KATE)
continue;
#endif
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;
@ -491,7 +490,7 @@ read_more_data:
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
@ -501,7 +500,7 @@ read_more_data:
if (chunk_count > MAX_CHUNK_COUNT) {
return E_OGGPLAY_TIMEOUT;
}
chunk_count += 1;
r = oggz_read(me->oggz, OGGZ_READ_CHUNK_SIZE);
@ -518,10 +517,10 @@ read_more_data:
}
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
*/
@ -543,7 +542,7 @@ read_more_data:
} else {
r = 0;
}
/*
* clean the data lists
*/
@ -571,9 +570,9 @@ OggPlayErrorCode
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;
}
}
@ -582,7 +581,7 @@ OggPlayErrorCode
oggplay_close(OggPlay *me) {
int i;
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@ -593,21 +592,21 @@ oggplay_close(OggPlay *me) {
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
@ -630,7 +629,7 @@ oggplay_get_available(OggPlay *me) {
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);
}
@ -641,7 +640,7 @@ oggplay_get_duration(OggPlay *me) {
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
return me->reader->duration(me->reader);
}

View File

@ -43,7 +43,7 @@
#define OGGPLAY_DEFAULT_BUFFER_SIZE 20
#define WRAP_INC(c, s) ((c + 1) % s)
/*
@ -70,9 +70,9 @@ oggplay_buffer_new_buffer(int size) {
buffer->last_emptied = -1;
SEM_CREATE(buffer->frame_sem, size);
return buffer;
}
void
@ -80,9 +80,9 @@ oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *vbuffer) {
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 @@ oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *vbuffer) {
free(ti);
}
}
free(buffer->buffer_list);
free(buffer->buffer_mirror);
SEM_CLOSE(buffer->frame_sem);
@ -102,7 +102,7 @@ oggplay_buffer_shutdown(OggPlay *me, volatile OggPlayBuffer *vbuffer) {
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 @@ oggplay_buffer_set_last_data(OggPlay *me, volatile OggPlayBuffer *buffer)
int i;
OggPlayCallbackInfo *p;
/*
/*
* we're at last data before we've even started!
*/
if (buffer->last_filled == -1) {
@ -136,7 +136,7 @@ oggplay_buffer_set_last_data(OggPlay *me, volatile OggPlayBuffer *buffer)
}
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 @@ oggplay_buffer_callback(OggPlay *me, int tracks,
int required;
buffer = (OggPlayBuffer *)me->buffer;
if (buffer == NULL) {
return -1;
}
@ -158,7 +158,7 @@ oggplay_buffer_callback(OggPlay *me, int tracks,
if (me->shutdown) {
return -1;
}
/*
* lock the item going into the buffer so that it doesn't get cleaned up
*/
@ -174,10 +174,10 @@ oggplay_buffer_callback(OggPlay *me, int tracks,
* 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 @@ oggplay_buffer_callback(OggPlay *me, int tracks,
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 @@ oggplay_buffer_callback(OggPlay *me, int tracks,
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 @@ oggplay_buffer_retrieve_next(OggPlay *me) {
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 @@ oggplay_buffer_retrieve_next(OggPlay *me) {
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 @@ oggplay_buffer_release(OggPlay *me, OggPlayCallbackInfo **track_info) {
if (buffer == NULL) {
return E_OGGPLAY_CALLBACK_MODE;
}
if (buffer->buffer_list[buffer->last_emptied] == NULL) {
return E_OGGPLAY_UNINITIALISED;
}
@ -292,9 +292,9 @@ oggplay_buffer_release(OggPlay *me, OggPlayCallbackInfo **track_info) {
free(track_info);
buffer->buffer_list[buffer->last_emptied] = NULL;
SEM_SIGNAL(buffer->frame_sem);
return E_OGGPLAY_OK;
}
@ -316,7 +316,7 @@ oggplay_use_buffer(OggPlay *me, int size) {
*/
return E_OGGPLAY_OK;
}
me->buffer = oggplay_buffer_new_buffer(size);
/*
@ -325,23 +325,22 @@ oggplay_use_buffer(OggPlay *me, int size) {
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;
}
}
}

View File

@ -32,7 +32,7 @@
/*
* oggplay_callback.c
*
*
* Shane Stephens <shane.stephens@annodex.net>
*/
#include "oggplay_private.h"
@ -50,7 +50,7 @@ void
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 @@ oggplay_shutdown_theora(void *user_data) {
}
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 @@ oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
int granuleshift;
long frame;
#if TIME_THEORA_DECODE
#if TIME_THEORA_DECODE
struct timeval tv;
struct timeval tv2;
int musec;
@ -109,7 +109,7 @@ oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
theora_decode_init(&(decoder->video_handle), &(decoder->video_info));
}
return 0;
}
}
else if (decoder->remaining_header_packets != 0) {
/*
* Invalid Ogg file. Missing headers
@ -124,18 +124,18 @@ oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
*/
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 @@ oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
#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 @@ oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
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 @@ oggplay_callback_theora (OGGZ * oggz, ogg_packet * op, long serialno,
* 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 @@ oggplay_callback_cmml (OGGZ * oggz, ogg_packet * op, long serialno,
}
common->current_loc = granulepos * common->granuleperiod;
oggplay_data_handle_cmml_data (&(decoder->decoder), op->packet, op->bytes);
}
return 0;
}
void
@ -235,27 +235,35 @@ static inline unsigned long extract_int32(unsigned char *data) {
}
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);
bt_den = extract_int64(op->packet + 36);
decoder->presentation_time = (pt_num << 32) * 1000 / pt_den;
decoder->base_time = (bt_num << 32) / bt_den;
if (pt_den != 0) {
decoder->presentation_time = (pt_num << 32) * 1000 / pt_den;
} else {
decoder->presentation_time = 0;
}
if (bt_den != 0) {
decoder->base_time = (bt_num << 32) / bt_den;
} else {
decoder->base_time = 0;
}
/* 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 +271,7 @@ oggplay_callback_skel (OGGZ * oggz, ogg_packet * op, long serialno,
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 +279,9 @@ oggplay_callback_skel (OGGZ * oggz, ogg_packet * op, long serialno,
}
}
}
return 0;
}
int
@ -293,10 +301,10 @@ oggplay_fish_sound_callback_floats(FishSound * fsound, float ** pcm,
common->current_loc = -1;
}
if
if
(
(common->current_loc == -1)
||
(common->current_loc == -1)
||
(common->current_loc >= common->player->presentation_time)
)
{
@ -305,9 +313,9 @@ oggplay_fish_sound_callback_floats(FishSound * fsound, float ** pcm,
/*
* 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 +325,15 @@ oggplay_init_audio (void * user_data) {
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 +347,25 @@ oggplay_shutdown_audio(void *user_data) {
}
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 +373,7 @@ oggplay_callback_audio (OGGZ * oggz, ogg_packet * op, long serialno,
common->active = 0;
common->player->active_tracks--;
}
return 0;
}
@ -391,7 +399,7 @@ oggplay_shutdown_kate(void *user_data) {
}
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 +424,25 @@ oggplay_callback_kate (OGGZ * oggz, ogg_packet * op, long serialno,
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 +450,37 @@ oggplay_callback_kate (OGGZ * oggz, ogg_packet * op, long serialno,
}
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,24 +500,28 @@ oggplay_initialise_decoder(OggPlay *me, int content_type, int serialno) {
/*
* 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);
/*
* convert num and denom to a 32.32 fixed point value
*/
decoder->granuleperiod = (denom << 32) / num;
if (num != 0) {
decoder->granuleperiod = (denom << 32) / num;
} else {
decoder->granuleperiod = 0;
}
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 +537,14 @@ oggplay_callback_shutdown(OggPlayDecode *decoder) {
}
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 +567,12 @@ oggplay_callback_predetected (OGGZ *oggz, ogg_packet *op, long serialno,
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 +582,10 @@ oggplay_callback_predetected (OGGZ *oggz, ogg_packet *op, long serialno,
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 +595,21 @@ oggplay_callback_predetected (OGGZ *oggz, ogg_packet *op, long serialno,
}
}
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;
}

View File

@ -32,7 +32,7 @@
/*
* oggplay_data.c
*
*
* Shane Stephens <shane.stephens@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 @@ oggplay_data_initialise_list (OggPlayDecode *decode) {
*/
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 @@ oggplay_data_add_to_list_end(OggPlayDecode *decode, OggPlayDataHeader *data) {
decode->end_of_data_list = data;
}
}
}
#define M(x) ((x) >> 32)
@ -117,25 +117,25 @@ _print_list(char *name, OggPlayDataHeader *p) {
}
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 @@ oggplay_data_add_to_list (OggPlayDecode *decode, OggPlayDataHeader *data) {
*/
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 @@ oggplay_data_add_to_list (OggPlayDecode *decode, OggPlayDataHeader *data) {
/*
* 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_shutdown_list (OggPlayDecode *decode) {
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 @@ oggplay_data_clean_list (OggPlayDecode *decode) {
OggPlayDataHeader * p = NULL;
while (header != NULL) {
if
if
(
header->lock == 0
&&
@ -230,7 +230,7 @@ oggplay_data_clean_list (OggPlayDecode *decode) {
)
)
)
)
{
if (p == NULL) {
decode->data_list = decode->data_list->next;
@ -253,7 +253,7 @@ oggplay_data_clean_list (OggPlayDecode *decode) {
}
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 @@ oggplay_data_initialise_header (OggPlayDecode *decode,
}
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 @@ oggplay_data_handle_cmml_data(OggPlayDecode *decode, unsigned char *data,
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 @@ oggplay_data_handle_theora_frame (OggPlayTheoraDecode *decode,
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 @@ oggplay_data_handle_theora_frame (OggPlayTheoraDecode *decode,
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 @@ oggplay_data_handle_theora_frame (OggPlayTheoraDecode *decode,
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 @@ oggplay_data_handle_kate_data(OggPlayKateDecode *decode, const kate_event *ev) {
// 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));

View File

@ -32,7 +32,7 @@
/*
* oggplay_data.h
*
*
* Shane Stephens <shane.stephens@annodex.net>
*/
#ifndef __OGGPLAY_DATA_H__
@ -50,7 +50,7 @@ oggplay_data_handle_audio_data (OggPlayDecode *decode, void *data,
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

View File

@ -32,7 +32,7 @@
/*
* oggplay_file_reader.c
*
*
* Shane Stephens <shane.stephens@annodex.net>
* Michael Martin
*/
@ -52,13 +52,13 @@ oggplay_file_reader_initialise(OggPlayReader * opr, int block) {
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 @@ oggplay_file_reader_destroy(OggPlayReader * opr) {
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 @@ oggplay_file_reader_available(OggPlayReader * opr, ogg_int64_t current_bytes,
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 @@ oggplay_file_reader_io_read(void * user_handle, void * buf, size_t n) {
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 @@ oggplay_file_reader_new(char *file_name) {
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;
}

View File

@ -32,7 +32,7 @@
/*
* oggplay_file_reader.h
*
*
* Shane Stephens <shane.stephens@annodex.net>
* Michael Martin
*/

View File

@ -32,7 +32,7 @@
/*
* oggplay_private.h
*
*
* Shane Stephens <shane.stephens@annodex.net>
* Michael Martin
*/
@ -123,14 +123,14 @@ struct _OggPlayCallbackInfo {
* 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
*/
@ -215,7 +215,7 @@ struct _OggPlay {
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;
@ -231,7 +231,7 @@ oggplay_take_out_trash(OggPlay *me, OggPlaySeekTrash *trash);
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;
@ -247,7 +247,7 @@ static inline void _free(void *x) {
free(x);
}
static inline void *_malloc(int s) {
static inline void *_malloc(int s) {
void *x;
printf("%d ", s);
x = malloc(s);

View File

@ -32,7 +32,7 @@
/*
* oggplay_query.c
*
*
* Shane Stephens <shane.stephens@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 @@ oggplay_get_num_tracks (OggPlay * me) {
}
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 @@ oggplay_get_track_type (OggPlay * me, int track_num) {
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 @@ oggplay_get_track_typename (OggPlay * me, int track_num) {
if (track_num < 0 || track_num >= me->num_tracks) {
return NULL;
}
return me->decode_data[track_num]->content_type_name;
}
@ -105,7 +105,7 @@ OggPlayErrorCode
oggplay_set_track_active(OggPlay *me, int track_num) {
ogg_int64_t p;
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@ -130,34 +130,30 @@ oggplay_set_track_active(OggPlay *me, int track_num) {
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.
*/
if (me->decode_data[track_num]->content_type != OGGZ_CONTENT_CMML
#ifdef HAVE_KATE
&& me->decode_data[track_num]->content_type != OGGZ_CONTENT_KATE
#endif
) {
if (me->decode_data[track_num]->content_type != OGGZ_CONTENT_CMML && me->decode_data[track_num]->content_type != OGGZ_CONTENT_KATE) {
me->active_tracks ++;
}
}
return E_OGGPLAY_OK;
}
OggPlayErrorCode
@ -182,18 +178,14 @@ oggplay_set_track_inactive(OggPlay *me, int track_num) {
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;
/*
* see above comment in oggplay_set_track_active
*/
if (me->decode_data[track_num]->content_type != OGGZ_CONTENT_CMML
#ifdef HAVE_KATE
&& me->decode_data[track_num]->content_type != OGGZ_CONTENT_KATE
#endif
) {
if (me->decode_data[track_num]->content_type != OGGZ_CONTENT_CMML && me->decode_data[track_num]->content_type != OGGZ_CONTENT_KATE) {
me->active_tracks --;
}
}

View File

@ -32,7 +32,7 @@
/*
* oggplay_enums.h
*
*
* Shane Stephens <shane.stephens@annodex.net>
*/
@ -46,7 +46,7 @@ oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) {
OggPlayDataHeader ** end_of_list_p;
int i;
int eof;
if (me == NULL) {
return E_OGGPLAY_BAD_OGGPLAY;
}
@ -61,10 +61,10 @@ oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) {
}
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 @@ oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) {
}
/*
* 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 @@ oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) {
* 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 @@ oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) {
/*
* 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 @@ oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) {
while (*p != NULL) {
p = &((*p)->next);
}
*p = trash;
return E_OGGPLAY_OK;
}
void

View File

@ -32,7 +32,7 @@
/*
* oggplay_tcp_reader.c
*
*
* Shane Stephens <shane.stephens@annodex.net>
* Michael Martin
*/
@ -74,7 +74,7 @@ typedef int SOCKET;
#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 @@ SOCKET
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 @@ oggplay_create_socket() {
}
/*
* 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 @@ oggplay_hostname_and_path(char *location, char *proxy, int proxy_port,
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 @@ oggplay_connect_to_host(SOCKET socket, struct sockaddr *addr) {
#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 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
free(host);
free(path);
if (he == NULL) {
printf("Host not found\n");
return E_OGGPLAY_BAD_INPUT;
@ -350,9 +350,9 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
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 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
/*
* 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 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
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 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
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 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
}
}
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 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
}
/*
* Read in enough data to fill the buffer.
*/
@ -453,7 +453,7 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
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 @@ oggplay_tcp_reader_initialise(OggPlayReader * opr, int block) {
}
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 @@ oggplay_tcp_reader_destroy(OggPlayReader * opr) {
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 @@ grab_some_data(OggPlayTCPReader *me, int block) {
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 @@ grab_some_data(OggPlayTCPReader *me, int block) {
#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 @@ oggplay_tcp_reader_new(char *location, char *proxy, int proxy_port) {
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;
}

View File

@ -32,7 +32,7 @@
/*
* oggplay_tools.c
*
*
* Shane Stephens <shane.stephens@annodex.net>
* Michael Martin
*/
@ -56,7 +56,7 @@ oggplay_sys_time_in_ms(void) {
void
oggplay_millisleep(long ms) {
#ifdef WIN32
#ifdef WIN32
Sleep(ms);
#else
struct timespec ts = {0, (ogg_int64_t)ms * 1000000LL};

View File

@ -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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
* 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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
/* 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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
* 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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2rgb(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
*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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
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 @@ void oggplay_yuv2bgr(OggPlayYUVChannels * yuv, OggPlayRGBChannels * rgb) {
*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);

View File

@ -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 @@ typedef MPSemaphoreID semaphore;
#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,

View File

@ -3,6 +3,7 @@
# Copies the needed files from a directory containing the original
# liboggplay source that we need for the Mozilla HTML5 media support.
sed s/\#define\ __SSE2__\ 1//g $1/config.h >./src/liboggplay/config.h
echo "#undef HAVE_GLUT" >>./src/liboggplay/config.h
cp $1/include/oggplay/oggplay_callback_info.h ./include/oggplay/oggplay_callback_info.h
cp $1/include/oggplay/oggplay_query.h ./include/oggplay/oggplay_query.h
cp $1/include/oggplay/oggplay_seek.h ./include/oggplay/oggplay_seek.h