summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2005-03-25 14:42:13 +0000
committerdeva <deva>2005-03-25 14:42:13 +0000
commit80b52138689e75f6ee6e55fa3be877500780bb17 (patch)
treedf188d0f66a7abb2e7a3d0e0eac4dd9a3f107764
parent8d103b961932ee608dc9d0c866e92853a4d48194 (diff)
enabled audio.
-rw-r--r--src/decoder.cc101
1 files changed, 51 insertions, 50 deletions
diff --git a/src/decoder.cc b/src/decoder.cc
index 2171b1a..4d1f0ac 100644
--- a/src/decoder.cc
+++ b/src/decoder.cc
@@ -105,59 +105,60 @@ void Decoder::decode()
/* NOTE: we only decode video, we only need the data from stream_index 0 */
/* (stream 0: video, stream 1: audio) */
- 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);
-
- // 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);
+ 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);
}
- 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);
+ // 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);
+ }
}
- */
av_free_packet(&pkt);
}