summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2005-03-25 14:44:24 +0000
committerdeva <deva>2005-03-25 14:44:24 +0000
commit687c9d10046194dd25f36fc9610b8f6544748d88 (patch)
tree9cb88e24d25bcf8f5e33ebcc5ed0252071c7cc21
parent80b52138689e75f6ee6e55fa3be877500780bb17 (diff)
*** empty log message ***
-rw-r--r--src/decoder.cc100
1 files 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);
}