From 687c9d10046194dd25f36fc9610b8f6544748d88 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 25 Mar 2005 14:44:24 +0000 Subject: *** empty log message *** --- src/decoder.cc | 100 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/src/decoder.cc b/src/decoder.cc index 4d1f0ac..debff33 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -105,59 +105,57 @@ void Decoder::decode() /* NOTE: we only decode video, we only need the data from stream_index 0 */ /* (stream 0: video, stream 1: audio) */ - while(len > 0) { - if(pkt.stream_index == 0) { - int ret; - int got_picture; - // buf_t *buf = buf_alloc(); - FFFrame *fff = new FFFrame(); - DVFrame *dvf = new DVFrame(); - dvf->type = DVF_VIDEO; - - memcpy(dvf->frame, ptr, len); - - // fprintf(stderr, "DVBufferSize: [%d]bytes\n", len); - ret = avcodec_decode_video(&fc->streams[0]->codec, - fff->frame, &got_picture, ptr, len); - - if(ret < 0) { - fprintf(stderr, "Error while decoding stream\n"); - exit(1); - } - - len -= ret; - ptr += ret; - - pthread_mutex_lock(mutex); - encode_queue->push(dvf); - player_queue->push(fff); - pthread_mutex_unlock(mutex); - - sem_post(encode_sem); - - user_event.type = SDL_USEREVENT; - user_event.user.code = 0; - user_event.user.data1 = NULL; - user_event.user.data2 = NULL; - SDL_PushEvent(&user_event); - } + while(pkt.stream_index == 0 && len > 0) { + int ret; + int got_picture; + // buf_t *buf = buf_alloc(); + FFFrame *fff = new FFFrame(); + DVFrame *dvf = new DVFrame(); + dvf->type = DVF_VIDEO; + + memcpy(dvf->frame, ptr, len); - // For later use, when audio must be implemented - if(pkt.stream_index == 1) { - DVFrame *dvf = new DVFrame(); - dvf->type = DVF_AUDIO; - - memcpy(dvf->frame, ptr, sizeof(dvf->frame)); - - ptr += sizeof(dvf->frame); - len -= sizeof(dvf->frame); - - pthread_mutex_lock(mutex); - encode_queue->push(dvf); - pthread_mutex_unlock(mutex); - - sem_post(encode_sem); + // fprintf(stderr, "DVBufferSize: [%d]bytes\n", len); + ret = avcodec_decode_video(&fc->streams[0]->codec, + fff->frame, &got_picture, ptr, len); + + if(ret < 0) { + fprintf(stderr, "Error while decoding stream\n"); + exit(1); } + + len -= ret; + ptr += ret; + + pthread_mutex_lock(mutex); + encode_queue->push(dvf); + player_queue->push(fff); + pthread_mutex_unlock(mutex); + + sem_post(encode_sem); + + user_event.type = SDL_USEREVENT; + user_event.user.code = 0; + user_event.user.data1 = NULL; + user_event.user.data2 = NULL; + SDL_PushEvent(&user_event); + } + + // For later use, when audio must be implemented + while(pkt.stream_index == 1 && len > 0) { + DVFrame *dvf = new DVFrame(); + dvf->type = DVF_AUDIO; + + memcpy(dvf->frame, ptr, sizeof(dvf->frame)); + + ptr += sizeof(dvf->frame); + len -= sizeof(dvf->frame); + + pthread_mutex_lock(mutex); + encode_queue->push(dvf); + pthread_mutex_unlock(mutex); + + sem_post(encode_sem); } av_free_packet(&pkt); } -- cgit v1.2.3