diff options
author | deva <deva> | 2005-04-14 17:28:21 +0000 |
---|---|---|
committer | deva <deva> | 2005-04-14 17:28:21 +0000 |
commit | d5e1739f5288355869eccd53ab3eb1a4000d1cab (patch) | |
tree | 15f9f20fb8d5c92fbf0b2ef5e34f150ce660168f /src/decoder.cc | |
parent | f742dd679138b1e3428b72e8f934fee15ade9ecb (diff) |
Unified the frame types.
Diffstat (limited to 'src/decoder.cc')
-rw-r--r-- | src/decoder.cc | 73 |
1 files changed, 17 insertions, 56 deletions
diff --git a/src/decoder.cc b/src/decoder.cc index 10ef245..9633f18 100644 --- a/src/decoder.cc +++ b/src/decoder.cc @@ -27,14 +27,15 @@ #include <fcntl.h> #include <errno.h> #include <libraw1394/raw1394.h> + #include "decoder.h" #include "debug.h" Decoder::Decoder(Error* err, sem_t *gencode_sem, sem_t *gplayer_sem, - Queue<DVFrame> *gencode_queue, - Queue<FFFrame> *gplayer_queue, + Queue<Frame> *gencode_queue, + Queue<Frame> *gplayer_queue, pthread_mutex_t *gmutex, volatile int *grunning) { @@ -46,24 +47,12 @@ Decoder::Decoder(Error* err, mutex = gmutex; running = grunning; - AVCodec *dec_codec; - - // Find ffmpeg-dv-codec - if(!(dec_codec = avcodec_find_decoder(CODEC_ID_DVVIDEO))) { - errobj->pushError("Unable to find codec."); - return; - } - - // Initialize ffmpeg-dv-codec - if(avcodec_open(&dvcodec, dec_codec) < 0) { - errobj->pushError("Error while opening codec for input stream."); - return; - } + // Initialize libdv } Decoder::~Decoder() { - avcodec_close(&dvcodec); + // Close libdv } static int raw_reader( raw1394handle_t handle, int channel, size_t length, quadlet_t *data ) @@ -120,7 +109,7 @@ static int raw_reader( raw1394handle_t handle, int channel, size_t length, quadl memcpy( framedata + dif_sequence * 150 * 80 + ( 7 + ( dif_block / 15 ) + dif_block ) * 80, p, 480 ); break; - default: // we canĀ“t handle any other data + default: // we can't handle any other data break; } } @@ -164,69 +153,41 @@ void Decoder::decode() raw1394_start_iso_rcv( handle, channel); while(*running) { - AVPacket pkt; uint8_t *ptr; int len; SDL_Event user_event; + // Read a dvframe while(1) { raw1394_loop_iterate(handle); - pkt.data = (uint8_t *)raw1394_get_userdata(handle); - if(pkt.data) { + ptr = (uint8_t *)raw1394_get_userdata(handle); + if(ptr) { raw1394_set_userdata(handle, NULL); break; } + len = DVPACKAGE_SIZE; } -printf("1"); fflush(stdout); - len = pkt.size = DVPACKAGE_SIZE; - ptr = pkt.data; - pkt.stream_index = 0; - - // 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(); ALLOC(fff, "FFFrame in decode"); - memset(fff->frame, 0 , sizeof(AVFrame)); - //DVFrame *dvf = new DVFrame(); ALLOC(dvf, "DVFrame in decode"); - // dvf->type = DVF_VIDEO; - - // memcpy(dvf->frame, ptr, len); - -printf("2"); fflush(stdout); - ret = avcodec_decode_video(&dvcodec, fff->frame, &got_picture, ptr, len); -printf("3"); fflush(stdout); - - if(ret < 0) { - errobj->pushError("Error while decoding stream."); - return; - } - -printf("4"); fflush(stdout); + Frame *frame = new Frame((void*)ptr, len); + pthread_mutex_lock(mutex); - // encode_queue->push(dvf); - player_queue->push(fff); + encode_queue->push(frame); + player_queue->push(frame); pthread_mutex_unlock(mutex); -printf("5"); fflush(stdout); sem_post(encode_sem); + // Create and send SDL event. user_event.type = SDL_USEREVENT; user_event.user.code = 0; user_event.user.data1 = NULL; user_event.user.data2 = NULL; -printf("6"); fflush(stdout); SDL_PushEvent(&user_event); -printf("7"); fflush(stdout); + // Free framedata. free(ptr); -printf("8"); fflush(stdout); } -printf("9"); fflush(stdout); - /* Kick the others so they wake up with empty queues */ + // Kick the others so they wake up with empty queues sem_post(encode_sem); pthread_exit(NULL); } |